Ejemplo n.º 1
0
 /**
  * Render the field as XHTML
  *
  * @params array     $params Additional HTML specific parameters
  * @params Doku_Form $form   The target Doku_Form object
  * @params int       $formid unique identifier of the form which contains this field
  */
 public function renderfield($params, Doku_Form $form, $formid)
 {
     if (!isset($this->opt['display'])) {
         $this->opt['display'] = $this->opt['label'];
     }
     parent::renderfield($params, $form, $formid);
 }
Ejemplo n.º 2
0
 /**
  * Initialize the appropriate column
  *
  * @param array $args
  */
 public function initialize($args)
 {
     parent::initialize($args);
     // find the column
     try {
         $this->column = $this->findColumn($this->opt['label']);
     } catch (StructException $e) {
         msg(hsc($e->getMessage()), -1);
     }
 }
Ejemplo n.º 3
0
 /**
  * Arguments:
  *  - cmd
  *  - label
  *  - ^ (optional)
  *
  * @param array $args The tokenized definition, only split at spaces
  */
 function initialize($args)
 {
     parent::initialize($args);
     $attr = array();
     if (!isset($this->opt['optional'])) {
         $attr['required'] = 'required';
     }
     $this->tpl = form_makePasswordField('@@NAME@@', '@@DISPLAY@@', '@@ID@@', '@@CLASS@@', $attr);
     if (!isset($this->opt['optional'])) {
         $this->tpl['class'] .= ' required';
     }
 }
Ejemplo n.º 4
0
 /**
  * @throws Exception max size, required or upload error
  */
 protected function _validate()
 {
     global $lang;
     parent::_validate();
     $file = $this->getParam('file');
     if ($file['error'] == 1 || $file['error'] == 2) {
         throw new Exception(sprintf($lang['uploadsize'], filesize_h(php_to_byte(ini_get('upload_max_filesize')))));
     } else {
         if ($file['error'] == 4) {
             if (!isset($this->opt['optional'])) {
                 throw new Exception(sprintf($this->getLang('e_required'), hsc($this->opt['label'])));
             }
         } else {
             if ($file['error'] || !is_uploaded_file($file['tmp_name'])) {
                 throw new Exception(hsc($this->opt['label']) . ' ' . $lang['uploadfail'] . ' (' . $file['error'] . ')');
             }
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Get an arbitrary parameter
  *
  * @param string $name
  * @return mixed|null
  */
 function getParam($name)
 {
     return $name === 'value' || in_array($name, array('page_tpl', 'page_tgt')) && $this->hidden ? null : parent::getParam($name);
 }
Ejemplo n.º 6
0
 /**
  * Arguments:
  *  - cmd
  *  - label
  *  - x123 (optional) as number of lines
  *  - ^ (optional)
  */
 public function initialize($args)
 {
     parent::initialize($args);
     $this->opt['class'] .= ' textareafield';
 }
 /**
  * Check for additional arguments and store their values
  *
  * @param array $args array with remaining definition arguments
  */
 protected function standardArgs($args)
 {
     // parse additional arguments
     foreach ($args as $arg) {
         if ($arg[0] == '=') {
             $this->setVal(substr($arg, 1));
         } elseif ($arg == '!') {
             $this->opt['optional'] = true;
         } elseif ($arg == '^') {
             //only one field has focus
             if (helper_plugin_bureaucracy_field::hasFocus()) {
                 $this->opt['id'] = 'focus__this';
             }
         } elseif ($arg == '@') {
             $this->opt['pagename'] = true;
         } elseif ($arg == '@@') {
             $this->opt['replyto'] = true;
         } elseif (preg_match('/x\\d/', $arg)) {
             $this->opt['rows'] = substr($arg, 1);
         } elseif ($arg[0] == '.') {
             $this->opt['class'] = substr($arg, 1);
         } elseif (preg_match('/0{2,}/', $arg)) {
             $this->opt['leadingzeros'] = strlen($arg);
         } else {
             $t = $arg[0];
             $d = substr($arg, 1);
             if (in_array($t, array('>', '<')) && !is_numeric($d)) {
                 break;
             }
             if ($t == '/') {
                 if (substr($d, -1) !== '/') {
                     break;
                 }
                 $d = substr($d, 0, -1);
             }
             if (!isset($this->checktypes[$t]) || !method_exists($this, 'validate_' . $this->checktypes[$t])) {
                 msg(sprintf($this->getLang('e_unknownconstraint'), hsc($t) . ' (' . hsc($arg) . ')'), -1);
                 return;
             }
             $this->checks[] = array('t' => $t, 'd' => $d);
         }
     }
 }
 /**
  * Get an arbitrary parameter
  *
  * @param string $name
  * @return mixed|null
  */
 function getParam($name)
 {
     return $name === 'value' ? null : parent::getParam($name);
 }
 /**
  * Handle a post to the field
  *
  * Accepts and validates a posted value.
  *
  * @param string                            $value  The passed value or array or null if none given
  * @param helper_plugin_bureaucracy_field[] $fields (reference) form fields (POST handled upto $this field)
  * @param int                               $index  index number of field in form
  * @param int                               $formid unique identifier of the form which contains this field
  * @return bool Whether the passed value is valid
  */
 public function handle_post($value, &$fields, $index, $formid)
 {
     if (is_array($value)) {
         $value = join(', ', $value);
     }
     return parent::handle_post($value, $fields, $index, $formid);
 }
Ejemplo n.º 10
0
 /**
  * Get an arbitrary parameter
  *
  * @param string $name
  * @return mixed|null
  */
 function getParam($name)
 {
     return $name === 'value' || in_array($name, array('template')) && $this->hidden ? null : parent::getParam($name);
 }
 /**
  * Get an arbitrary parameter
  *
  * @param string $name
  * @return mixed|null
  */
 function getParam($name)
 {
     if ($name === 'value') {
         return null;
     } else {
         return parent::getParam($name);
     }
 }
Ejemplo n.º 12
0
 /**
  * Render the field as XHTML
  *
  * @params array     $params Additional HTML specific parameters
  * @params Doku_Form $form   The target Doku_Form object
  * @params int       $formid unique identifier of the form which contains this field
  */
 public function renderfield($params, Doku_Form $form, $formid)
 {
     $id = 'bureaucracy__' . md5(rand());
     if (isset($this->opt['id'])) {
         $id = $this->opt['id'];
     }
     $params = array_merge(array('value' => false), $this->opt, $params);
     $check = $params['value'] ? 'checked="checked"' : '';
     $this->tpl = '<label class="@@CLASS@@" for="' . $id . '"><span>@@DISPLAY@@</span>' . '<input type="hidden" name="@@NAME@@" value="0" />' . '<input type="checkbox" name="@@NAME@@" value="1" id="' . $id . '" ' . $check . ' />' . '</label>';
     parent::renderfield($params, $form, $formid);
 }