123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
- if (!defined('STATUSNET') && !defined('GNUSOCIAL')) {
- exit(1);
- }
- class ChooseThemeSettingsAction extends SettingsAction {
-
-
- function title() {
-
- return _m('Choose theme settings');
- }
-
- function getInstructions() {
-
- return _m('Choose theme');
- }
-
- function showContent() {
- $site_theme = common_config('site','theme');
- $prefs = $this->scoped->getPref('chosen_theme', 'theme',$site_theme);
- if ($prefs === null) {
- common_debug('No chosen theme found in database for user.');
- }
-
-
- $available_themes = Theme::listAvailable();
- $chosenone = array_search($prefs,$available_themes,true);
- $form = new ChooseThemeForm($this, $chosenone);
- $form->show();
- }
-
- function handlePost() {
-
-
- $available_themes = Theme::listAvailable();
- $chosen_theme = $available_themes[(int)$this->arg('dwct','0')];
-
- $this->success = true;
- $this->msg = _m('Settings saved.');
- $this->success = $this->scoped->setPref('chosen_theme', 'theme', $chosen_theme);
-
- if(!$this->success) $this->msg = _('No valid theme chosen.');
-
- $this->showForm(_($this->msg), $this->success);
- }
- }
- class ChooseThemeForm extends Form {
- protected $prefs = null;
-
- function __construct($out, $prefs) {
- parent::__construct($out);
- if ($prefs!=null) {
- $this->prefs = $prefs;
- } else {
- $prefs = common_config('site','theme');
- }
-
- }
-
- function formData() {
-
- $available_themes = Theme::listAvailable();
-
-
-
-
- $key = array_search('licenses',$available_themes);
- if($key!=false){
- unset($available_themes[$key]);
- }
-
- $this->elementStart('fieldset');
- $this->elementStart('ul', 'form_data');
- $this->elementStart('li');
- $this->dropdown('dwct',_m('Themes'),$available_themes,_m('Select a theme'),false, $this->prefs);
- $this->elementEnd('li');
- $this->elementEnd('ul');
- $this->elementEnd('fieldset');
-
- }
-
- function formActions()
- {
- $this->submit('submit', _('Save'));
- }
-
- function id() {
- return 'form_choosetheme_prefs';
- }
-
- function action() {
- return common_local_url('choosethemesettings');
- }
-
- function formClass() {
- return 'form_settings';
- }
- }
|