Beispiel #1
0
 /**
  * ファイルインプットボックス出力
  * 画像の場合は画像タグ、その他の場合はファイルへのリンク
  * そして削除用のチェックボックスを表示する
  * [カスタムオプション]
  * imgsize・・・画像のサイズを指定する
  * 
  * @param string $fieldName
  * @param array $options
  * @return string
  * @access public
  */
 function file($fieldName, $options = array())
 {
     $linkOptions = $_options = array('imgsize' => 'midium', 'rel' => '', 'title' => '');
     $options = $this->_initInputField($fieldName, Set::merge($_options, $options));
     $linkOptions['imgsize'] = $options['imgsize'];
     $linkOptions['rel'] = $options['rel'];
     $linkOptions['title'] = $options['title'];
     unset($options['imgsize']);
     unset($options['rel']);
     unset($options['title']);
     $view =& ClassRegistry::getObject('view');
     $_field = $view->entity();
     $modelName = $_field[0];
     $field = $_field[1];
     if (ClassRegistry::isKeySet($modelName)) {
         $model =& ClassRegistry::getObject($modelName);
     } else {
         return;
     }
     $fileLinkTag = $this->fileLink($fieldName, $linkOptions);
     $fileTag = parent::file($fieldName, $options);
     $delCheckTag = parent::checkbox($modelName . '.' . $field . '_delete') . parent::label($modelName . '.' . $field . '_delete', '削除する');
     $hiddenValue = $this->value($fieldName . '_');
     $fileValue = $this->value($fieldName);
     if (is_array($fileValue) && empty($fileValue['tmp_name']) && $hiddenValue) {
         $hiddenTag = parent::hidden($modelName . '.' . $field . '_', array('value' => $hiddenValue));
     } else {
         $hiddenTag = parent::hidden($modelName . '.' . $field . '_', array('value' => $this->value($fieldName)));
     }
     $out = $fileTag;
     if ($fileLinkTag) {
         $out .= '&nbsp;' . $delCheckTag . $hiddenTag . '<br />' . $fileLinkTag;
     }
     return '<div class="upload-file">' . $out . '</div>';
 }
 /**
  * Returns a formatted LABEL element for HTML FORMs. Will automatically generate
  * a `for` attribute if one is not provided.
  *
  * @param string       $fieldName This should be "Modelname.fieldname"
  * @param string       $text      Text that will appear in the label field. If
  *                                $text is left undefined the text will be inflected from the
  *                                fieldName.
  * @param array|string $options   An array of HTML attributes, or a string, to be used as a class name.
  * @return string The formatted label element
  */
 public function label($fieldName = null, $text = null, $options = [])
 {
     if (empty($options)) {
         $options = 'control-label';
     }
     return parent::label($fieldName, $text, $options);
 }
Beispiel #3
0
 /**
  * Cleans up labels text in admin interface
  * @param null $fieldName
  * @param null $text
  * @param array $options
  * @return string
  */
 public function label($fieldName = null, $text = null, $options = array())
 {
     if (!empty($this->request->params['admin'])) {
         if ($text === null) {
             if (strpos($fieldName, '.') !== false) {
                 $fieldElements = explode('.', $fieldName);
                 $text = array_pop($fieldElements);
             } else {
                 $text = $fieldName;
             }
             if (substr($text, -3) == '_id') {
                 $text = substr($text, 0, -3);
             }
             $text = __d('admin', Inflector::humanize(Inflector::underscore($text)));
         }
         $response = parent::label($fieldName, $text, $options);
     }
     return parent::label($fieldName, $text, $options);
 }
Beispiel #4
0
 /**
  * _construct_label
  *
  * @param mixed $options
  * @access public
  * @return void
  */
 public function _constructLabel($options, $basic = true)
 {
     if ($options["label"] === false) {
         return "";
     }
     if (in_array($options["type"], array("checkbox"))) {
         $opt = $options;
         $opt["type"] = "";
         $input = $this->_constructInput($opt);
         $options["label"] = parent::label($options["field"], $input . $options["label"], "checkbox");
     } else {
         $class = !$basic ? "control-label" : null;
         if (!empty($options["label"])) {
             $options["label"] = parent::label($options["field"], $options["label"], array("class" => $class));
         } else {
             $options["label"] = parent::label($options["field"], null, array("class" => $class));
         }
     }
     return $options["label"];
 }
    public function datePicker($fieldName, $attributes = array())
    {
        $text = $fieldName;
        if (isset($attributes['label'])) {
            $text = $attributes['label'];
        }
        $label = parent::label($text, null, array('class' => 'col-lg-2 control-label'));
        $id = $this->domId($fieldName);
        $inputId = $id . '_Input';
        $name = $this->_name(null, $fieldName);
        $name = $name['name'];
        $currentTime = '';
        if (isset($attributes['value'])) {
            $currentTime = $attributes['value'];
        }
        $html = <<<EOD
<div class="form-group">
\t{$label}
\t<div class="col-lg-10">\t\t\t\t
\t\t<div class='input-group date datepicker' id="{$id}">
\t\t<input type='text' class="form-control" value="{$currentTime}" />
\t\t<span class="input-group-addon">
\t\t<span class="glyphicon glyphicon-calendar"></span>
\t\t</span>
\t\t\t\t
\t\t<input type="hidden" name="{$name}[month]" id="{$id}Month" value="" />
\t\t<input type="hidden" name="{$name}[day]" id="{$id}Day" value="" />
\t\t<input type="hidden" name="{$name}[year]" id="{$id}Year" value="" />
\t\t<input type="hidden" name="{$name}[hour]" id="{$id}Hour" value="" />
\t\t<input type="hidden" name="{$name}[min]" id="{$id}Min" value="" />
\t\t<input type="hidden" name="{$name}[meridian]" id="{$id}Meridian" value="" />\t\t
\t\t\t\t\t
\t\t</div>
\t</div>\t\t\t\t
</div>\t\t
EOD;
        return $html;
    }
Beispiel #6
0
 /**
  * Returns a formatted LABEL element for HTML FORMs.
  *
  * Overriden to refer to field_names.po unless the label is explicitly passed
  *
  * @param string $fieldName This should be "Modelname.fieldname", "Modelname/fieldname" is deprecated
  * @param string $text Text that will appear in the label field.
  * @return string The formatted LABEL element
  */
 public function label($fieldName = null, $text = null, $attributes = array())
 {
     if (empty($fieldName)) {
         $view = ClassRegistry::getObject('view');
         $fieldName = implode('.', $view->entity());
     }
     if ($text === null) {
         if (strpos($fieldName, '.')) {
             $alias = explode('.', $fieldName);
             if (count($alias) == 3) {
                 $text = str_replace($alias[1] . '.', '', $fieldName);
             } else {
                 $text = $fieldName;
             }
             $alias = $alias[0];
             $text = str_replace('.', ' ', $fieldName);
         } else {
             $view = ClassRegistry::getObject('view');
             $alias = $view->association ? $view->association : $view->model;
             $text = $alias . ' ' . $fieldName;
         }
         if (substr($text, -3) == '_id') {
             $text = substr($text, 0, strlen($text) - 3);
         }
         $_text = Inflector::humanize(Inflector::underscore($text));
         $pluginDomain = '';
         if (!empty($this->params['plugin'])) {
             $models = MiCache::mi('models', $this->params['plugin']);
             if (in_array($alias, $models)) {
                 $pluginDomain = Inflector::underscore($this->params['plugin']) . '_';
             }
         }
         $text = __d($pluginDomain . 'field_names', $_text, true);
         if ($_text === $text) {
             $text = str_replace(Inflector::humanize(Inflector::underscore($alias)) . ' ', '', $_text);
         }
     }
     return parent::label($fieldName, $text, $attributes);
 }
 public function label($fieldName = null, $text = null, $options = array())
 {
     $options = $this->addClass($options, 'control-label');
     return parent::label($fieldName, $text, $options);
 }
Beispiel #8
0
 /**
  * Creates a checkbox input widget.
  * MODIFIED 2008/10/24 egashira
  *          hiddenタグを出力しないオプションを追加
  *
  * @param string $fieldNamem Name of a field, like this "Modelname.fieldname"
  * @param array $options Array of HTML attributes.
  *		'value' - the value of the checkbox
  *		'checked' - boolean indicate that this checkbox is checked.
  * @todo Right now, automatically setting the 'checked' value is dependent on whether or not the
  * 		 checkbox is bound to a model.  This should probably be re-evaluated in future versions.
  * @return string An HTML text input element
  * @access public
  */
 function checkbox($fieldName, $options = array())
 {
     // CUSTOMIZE ADD 2011/05/07 ryuring
     // >>> hiddenをデフォルトオプションに追加
     $options = array_merge(array('hidden' => true), $options);
     $hidden = $options['hidden'];
     unset($options['hidden']);
     // <<<
     $options = $this->_initInputField($fieldName, $options);
     $value = current($this->value());
     if (!isset($options['value']) || empty($options['value'])) {
         $options['value'] = 1;
     } elseif (!isset($options['checked']) && !empty($value) && $value === $options['value'] || !empty($options['checked'])) {
         $options['checked'] = 'checked';
     }
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // >>> hiddenオプションがある場合のみ、hiddenタグを出力
     /*$hiddenOptions = array(
     			'id' => $options['id'] . '_', 'name' => $options['name'],
     			'value' => '0', 'secure' => false
     		);
     		if (isset($options['disabled']) && $options['disabled'] == true) {
     			$hiddenOptions['disabled'] = 'disabled';
     		}
     		$output = $this->hidden($fieldName, $hiddenOptions);*/
     // ---
     if ($hidden) {
         $hiddenOptions = array('id' => $options['id'] . '_', 'name' => $options['name'], 'value' => '0', 'secure' => false);
         if (isset($options['disabled']) && $options['disabled'] == true) {
             $hiddenOptions['disabled'] = 'disabled';
         }
         $output = $this->hidden($fieldName, $hiddenOptions);
     } else {
         $output = '';
     }
     // <<<
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // >>> label を追加
     /*return $this->output($output . sprintf(
     			$this->Html->tags['checkbox'],
     			$options['name'],
     			$this->_parseAttributes($options, array('name'), null, ' ')
     		));*/
     // ---
     if (!empty($options['label'])) {
         $label = '&nbsp;' . parent::label($fieldName, $options['label']);
     } else {
         $label = '';
     }
     return $this->output($output . sprintf($this->Html->tags['checkbox'], $options['name'], $this->_parseAttributes($options, array('name'), null, ' '))) . $label;
     // <<<
 }
Beispiel #9
0
 /**
  * Creates a checkbox input widget.
  * MODIFIED 2008/10/24 egashira
  *          hiddenタグを出力しないオプションを追加
  *
  * ### Options:
  *
  * - `value` - the value of the checkbox
  * - `checked` - boolean indicate that this checkbox is checked.
  * - `hiddenField` - boolean to indicate if you want the results of checkbox() to include
  *    a hidden input with a value of ''.
  * - `disabled` - create a disabled input.
  * - `default` - Set the default value for the checkbox. This allows you to start checkboxes
  *    as checked, without having to check the POST data. A matching POST data value, will overwrite
  *    the default value.
  *
  * @param string $fieldName Name of a field, like this "Modelname.fieldname"
  * @param array $options Array of HTML attributes.
  * @return string An HTML text input element.
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-select-checkbox-and-radio-inputs
  */
 public function checkbox($fieldName, $options = array())
 {
     // CUSTOMIZE ADD 2011/05/07 ryuring
     // >>> hiddenをデフォルトオプションに追加
     $options = array_merge(array('hidden' => true), $options);
     $hidden = $options['hidden'];
     unset($options['hidden']);
     // <<<
     $valueOptions = array();
     if (isset($options['default'])) {
         $valueOptions['default'] = $options['default'];
         unset($options['default']);
     }
     $options += array('value' => 1, 'required' => false);
     $options = $this->_initInputField($fieldName, $options) + array('hiddenField' => true);
     $value = current($this->value($valueOptions));
     $output = '';
     if (!isset($options['checked']) && !empty($value) && $value == $options['value'] || !empty($options['checked'])) {
         $options['checked'] = 'checked';
     }
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // >>> hiddenオプションがある場合のみ、hiddenタグを出力
     // 2014/03/23 ryuring CakePHP側が実装していたが互換性の為に残す
     //if ($options['hiddenField']) {
     // ---
     if ($hidden !== false && $options['hiddenField'] !== false) {
         // <<<
         $hiddenOptions = array('id' => $options['id'] . '_', 'name' => $options['name'], 'value' => $options['hiddenField'] !== true ? $options['hiddenField'] : '0', 'form' => isset($options['form']) ? $options['form'] : null, 'secure' => false);
         if (isset($options['disabled']) && $options['disabled']) {
             $hiddenOptions['disabled'] = 'disabled';
         }
         $output = $this->hidden($fieldName, $hiddenOptions);
     }
     unset($options['hiddenField']);
     // CUSTOMIZE MODIFY 2011/05/07 ryuring
     // label を追加
     // CUSTOMIZE MODIRY 2014/10/27 ryuring
     // チェックボックスをラベルで囲う仕様に変更
     // >>>
     //return $output . $this->Html->useTag('checkbox', $options['name'], array_diff_key($options, array('name' => null)));
     // ---
     if (!empty($options['label'])) {
         return $output . parent::label($fieldName, $this->Html->useTag('checkbox', $options['name'], array_diff_key($options, array('name' => null))) . $options['label']);
     } else {
         return $output . $this->Html->useTag('checkbox', $options['name'], array_diff_key($options, array('name' => null)));
     }
     // <<<
 }
 /**
  *
  * Create & return a label message (Twitter Boostrap like).
  *
  **/
 public function label($fieldName = null, $text = null, $options = array())
 {
     if ($this->currentInputType == 'checkbox') {
         //  || $this->currentInputType == 'radio') {
         return $text;
     }
     if (!$this->inline) {
         $options = $this->addClass($options, 'control-label');
     }
     if ($this->horizontal) {
         $options = $this->addClass($options, $this->_getColClass('label'));
     }
     if ($this->inline) {
         $options = $this->addClass($options, 'sr-only');
     }
     return parent::label($fieldName, $text, $options);
 }
 protected function _clearfix($name, $input, $options)
 {
     $default = array('label' => null, 'type' => null, 'div' => array('class' => 'controls'));
     $options = Set::merge($default, $options);
     $out = array();
     if ($options['label'] !== false) {
         $text = $options['label']['text'];
         if ($options['type'] === 'checkbox') {
             unset($options['label']['text']);
             $options['label']['for'] = '';
         }
         $out[] = parent::label(FALSE, $text, $options['label']);
     }
     $out[] = $this->Html->div($options['div']['class'], $input, $options['div']);
     $clearfix = 'control-group';
     if (parent::error($name)) {
         $clearfix .= ' error';
     }
     return $this->Html->div($clearfix, implode("\n", $out));
 }
 /**
  *
  * Create & return a label message (Twitter Boostrap like).
  *
  **/
 public function label($fieldName = null, $text = null, $options = array())
 {
     if ($this->currentInputType == 'checkbox') {
         if ($text === null) {
             if (strpos($fieldName, '.') !== false) {
                 $fieldElements = explode('.', $fieldName);
                 $text = array_pop($fieldElements);
             } else {
                 $text = $fieldName;
             }
             if (substr($text, -3) === '_id') {
                 $text = substr($text, 0, -3);
             }
             $text = __(Inflector::humanize(Inflector::underscore($text)));
         }
         return $text;
     }
     if (!$this->inline) {
         $options = $this->addClass($options, 'control-label');
     }
     if ($this->horizontal) {
         $options = $this->addClass($options, $this->_getColClass('label'));
     }
     if ($this->inline) {
         $options = $this->addClass($options, 'sr-only');
     }
     return parent::label($fieldName, $text, $options);
 }
 /**
  * Create & return a label message (Twitter Boostrap like).
  *
  * @param string Field name.
  * @param string $text Label name string.
  * @param array $options Array of options for the label.
  * @return string HTML string of the label.
  */
 public function label($fieldName = null, $text = null, $options = [])
 {
     $this->setEntity($fieldName);
     $optField = $this->_magicOptions([]);
     if ($this->formType === GA_HORIZONTAL && $optField['type'] !== 'checkbox') {
         $options = $this->addClass($options, GA_CONTROL_LABEL);
     }
     return parent::label($fieldName, $text, $options);
 }
 function confirm($fieldName, $options = array(), $group = array())
 {
     $defaults = array('type' => null, 'appBefore' => null, 'appAfter' => null, 'appPath' => null, 'appPathOption' => null, 'appPathAfter' => null, 'appImg' => null);
     $options = array_merge($defaults, $options);
     //グループ設定
     $createTr = true;
     $closeTr = true;
     $this->displayed[] = $fieldName;
     //一列に複数フォーム表示する場合に
     //tr,tdのタグを使用するフラグを取得する
     if (!empty($group)) {
         $tr = $this->__getTrFlag($group);
         extract($tr);
     }
     $label = null;
     if (!empty($options['label'])) {
         $label = $options['label'];
     }
     $options['label'] = false;
     $view =& ClassRegistry::getObject('view');
     $this->setEntity($fieldName);
     $model =& ClassRegistry::getObject($this->model());
     $type = $model->getColumnType($this->field());
     if ($type == 'datetime') {
         $options = $this->setDatetimeOptions($options);
     }
     $before = $options['appBefore'];
     $after = $options['appAfter'];
     $path = $options['appPath'];
     $pathOption = $options['appPathOption'];
     $pathAfter = $options['appPathAfter'];
     $img = $options['appImg'];
     unset($options['appBefore'], $options['appAfter'], $options['appPath'], $options['appPathOption'], $options['appPathAfter'], $options['appImg']);
     //値を設定
     list($modelName, $field) = $view->entity();
     $value = $this->data[$modelName][$field];
     switch ($options['type']) {
         case 'select':
         case 'radio':
         case 'checkbox':
             $value = $options['options'][$value];
             break;
         case 'textarea':
             $value = nl2br($value);
             break;
         case 'file':
             if (empty($path)) {
                 break;
             }
             if ($img === true) {
                 $value = $this->Html->div('input checkbox required', $this->Html->image($path, !empty($pathOption) ? $pathOption : array()));
             } else {
                 $value = $this->Html->div('input checkbox required', $this->Html->link(__d('tools', 'Display file', true), $path, !empty($pathOption) ? $pathOption : array()));
             }
             break;
         default:
             break;
     }
     $tr_class = array();
     if (in_array($this->field(), $this->fieldset['validates'])) {
         $tr_class[] = 'required';
     }
     $out = '';
     if ($createTr) {
         $out .= "<tr" . (!empty($tr_class) ? ' class="' . implode(' ', $tr_class) . '"' : '') . ">\n";
         $out .= "<th class='vtop'>\n";
         $out .= parent::label($fieldName, $label);
         $out .= "</th>\n";
         $out .= "<td class='vtop'>\n";
     }
     $out .= $before . $value . $after;
     if ($closeTr) {
         $out .= "</td>\n";
         $out .= "</tr>\n";
     }
     return $out;
 }