[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/config/settings/ -> extra.class.php (source)

   1  <?php
   2  /**
   3   * additional setting classes specific to these settings
   4   *
   5   * @author    Chris Smith <chris@jalakai.co.uk>
   6   */
   7  
   8  if (!class_exists('setting_sepchar')) {
   9    class setting_sepchar extends setting_multichoice {
  10  
  11      function setting_sepchar($key,$param=NULL) {
  12          $str = '_-.';
  13          for ($i=0;$i<strlen($str);$i++) $this->_choices[] = $str{$i};
  14  
  15          // call foundation class constructor
  16          $this->setting($key,$param);
  17      }
  18    }
  19  }
  20  
  21  if (!class_exists('setting_savedir')) {
  22    class setting_savedir extends setting_string {
  23  
  24      function update($input) {
  25          if ($this->is_protected()) return false;
  26  
  27          $value = is_null($this->_local) ? $this->_default : $this->_local;
  28          if ($value == $input) return false;
  29  
  30          if (!init_path($input)) {
  31            $this->_error = true;
  32            $this->_input = $input;
  33            return false;
  34          }
  35  
  36          $this->_local = $input;
  37          return true;
  38      }
  39    }
  40  }
  41  
  42  if (!class_exists('setting_authtype')) {
  43    class setting_authtype extends setting_multichoice {
  44  
  45      function initialize($default,$local,$protected) {
  46  
  47        // populate $this->_choices with a list of available auth mechanisms
  48        $authtypes = glob(DOKU_INC.'inc/auth/*.class.php');
  49        $authtypes = preg_replace('#^.*/([^/]*)\.class\.php$#i','$1', $authtypes);
  50        $authtypes = array_diff($authtypes, array('basic'));
  51        sort($authtypes);
  52  
  53        $this->_choices = $authtypes;
  54  
  55        parent::initialize($default,$local,$protected);
  56      }
  57    }
  58  }
  59  
  60  if (!class_exists('setting_im_convert')) {
  61    class setting_im_convert extends setting_string {
  62  
  63      function update($input) {
  64          if ($this->is_protected()) return false;
  65  
  66          $input = trim($input);
  67  
  68          $value = is_null($this->_local) ? $this->_default : $this->_local;
  69          if ($value == $input) return false;
  70  
  71          if ($input && !@file_exists($input)) {
  72            $this->_error = true;
  73            $this->_input = $input;
  74            return false;
  75          }
  76  
  77          $this->_local = $input;
  78          return true;
  79      }
  80    }
  81  }
  82  
  83  if (!class_exists('setting_disableactions')) {
  84    class setting_disableactions extends setting_multicheckbox {
  85  
  86      function html(&$plugin, $echo=false) {
  87          global $lang;
  88  
  89          // make some language adjustments (there must be a better way)
  90          // transfer some DokuWiki language strings to the plugin
  91          if (!$plugin->localised) $this->setupLocale();
  92          $plugin->lang[$this->_key.'_revisions'] = $lang['btn_revs'];
  93          $plugin->lang[$this->_key.'_register'] = $lang['register'];
  94  
  95          foreach ($this->_choices as $choice)
  96            if (isset($lang['btn_'.$choice])) $plugin->lang[$this->_key.'_'.$choice] = $lang['btn_'.$choice];
  97  
  98          return parent::html($plugin, $echo);
  99      }
 100    }
 101  }
 102  
 103  if (!class_exists('setting_compression')) {
 104    class setting_compression extends setting_multichoice {
 105  
 106      var $_choices = array('0');      // 0 = no compression, always supported
 107  
 108      function initialize($default,$local,$protected) {
 109  
 110        // populate _choices with the compression methods supported by this php installation
 111        if (function_exists('gzopen')) $this->_choices[] = 'gz';
 112        if (function_exists('bzopen')) $this->_choices[] = 'bz2';
 113  
 114        parent::initialize($default,$local,$protected);
 115      }
 116    }
 117  }
 118  
 119  if (!class_exists('setting_license')) {
 120    class setting_license extends setting_multichoice {
 121  
 122      var $_choices = array('');      // none choosen
 123  
 124      function initialize($default,$local,$protected) {
 125        global $license;
 126  
 127        foreach($license as $key => $data){
 128          $this->_choices[] = $key;
 129          $this->lang[$this->_key.'_o_'.$key] = $data['name'];
 130        }
 131  
 132        parent::initialize($default,$local,$protected);
 133      }
 134    }
 135  }
 136  
 137  
 138  if (!class_exists('setting_renderer')) {
 139    class setting_renderer extends setting_multichoice {
 140      var $_prompts = array();
 141  
 142      function initialize($default,$local,$protected) {
 143        $format = $this->_format;
 144  
 145        foreach (plugin_list('renderer') as $plugin) {
 146          $renderer =& plugin_load('renderer',$plugin);
 147          if (method_exists($renderer,'canRender') && $renderer->canRender($format)) {
 148            $this->_choices[] = $plugin;
 149  
 150            $info = $renderer->getInfo();
 151            $this->_prompts[$plugin] = $info['name'];
 152          }
 153        }
 154  
 155        parent::initialize($default,$local,$protected);
 156      }
 157  
 158      function html(&$plugin, $echo=false) {
 159  
 160        // make some language adjustments (there must be a better way)
 161        // transfer some plugin names to the config plugin
 162        if (!$plugin->localised) $this->setupLocale();
 163  
 164        foreach ($this->_choices as $choice) {
 165          if (!isset($plugin->lang[$this->_key.'_o_'.$choice])) {
 166            if (!isset($this->_prompts[$choice])) {
 167              $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__core'],$choice);
 168            } else {
 169              $plugin->lang[$this->_key.'_o_'.$choice] = sprintf($plugin->lang['renderer__plugin'],$this->_prompts[$choice]);
 170            }
 171          }
 172        }
 173        return parent::html($plugin, $echo);    
 174      }
 175    }
 176  }


Generated: Tue Dec 2 01:30:01 2008 Cross-referenced by PHPXref 0.7