/** * 凍結時用のコントロールを取得する * @param string $fieldName フィールド文字列 * @param array $options コントロールソース * @param array $attributes html属性 * @return string htmlタグ * @access public */ public function freezeControll($fieldName, $options, $attributes = array()) { $attributes = array_merge(array('class' => ''), $attributes); unset($attributes["separator"]); if (preg_match_all("/\\./", $fieldName, $regs) == 2) { list($model, $field, $detail) = explode('.', $fieldName); } else { list($model, $field) = explode('.', $fieldName); } // 値を取得 if (isset($attributes["value"])) { $value = $attributes["value"]; } else { // HABTAM if (!empty($attributes["multiple"]) && $attributes["multiple"] !== 'checkbox') { $value = $this->request->data[$model]; } else { if (!empty($this->request->data[$model][$field])) { $value = $this->request->data[$model][$field]; } else { $value = null; } } } // optionsによるソース有 「0」は通す if ($options && $value !== '' && !is_null($value)) { // HABTAM if (!empty($attributes["multiple"]) && $attributes["multiple"] !== 'checkbox') { $_value = ""; foreach ($value as $data) { if (isset($options[$data['id']])) { $_value .= sprintf($this->Html->_tags['li'], null, $options[$data['id']]); } } $value = sprintf($this->Html->_tags['ul'], " " . $this->_parseAttributes($attributes, null, '', ' '), $_value); $out = parent::hidden($fieldName, $attributes) . $value; // マルチチェック } elseif (!empty($attributes["multiple"]) && $attributes["multiple"] === 'checkbox') { $_value = ""; foreach ($value as $key => $data) { if (isset($options[$data])) { $_value .= sprintf($this->Html->_tags['li'], null, $options[$data]); } } $out = sprintf($this->Html->_tags['ul'], " " . $this->_parseAttributes($attributes, null, '', ' '), $_value); $out .= $this->hidden($fieldName, array('value' => $value, 'multiple' => true)); // 一般 } elseif (empty($detail)) { if (isset($options[$value])) { $value = $options[$value]; } else { $value = ''; } $out = parent::hidden($fieldName, $attributes) . $value; // datetime } else { if ($value[$detail]) { $value = $options[$value[$detail]]; } else { $value = ""; } $out = parent::hidden($fieldName, $attributes) . $value; } // 値なし } else { if ($options) { if (!$value && !empty($options[0])) { $value = $options[0]; } else { $value = ""; } } elseif (empty($detail)) { if (!empty($value)) { $value = $value; } else { $value = null; } } elseif (is_array($value) && isset($value[$detail])) { $value = $value[$detail]; } $out = parent::hidden($fieldName, $attributes) . $value; } return $out; }
/** * BurgerEditor 出力 */ public function editor($fieldName, $options = array()) { $fieldAry = explode('.', $fieldName); $model = isset($fieldAry[0]) ? $fieldAry[0] : ''; $column = isset($fieldAry[1]) ? $fieldAry[1] : ''; $draftId = 0; $bcFormHelper = new BcFormHelper($this->_View); echo $bcFormHelper->hidden($fieldName); // データ領域はここで出力 $editorHtml = ''; // 草稿機能を利用するかチェック if (!empty($options['editorUseDraft']) && !empty($options['editorDraftField'])) { $editorHtml .= '<div class="draft-btn clearfix">'; $editorHtml .= '<a id="CbeHonkouCopyBtn">本稿を草稿にコピー</a>'; $editorHtml .= '<a id="CbeSoukouCopyBtn">草稿を本稿にコピー</a>'; $editorHtml .= '<a id="CbeSoukouBtn">草稿</a>'; $editorHtml .= '<a id="CbeHonkouBtn" class="on">本稿</a>'; $editorHtml .= '</div>'; echo $bcFormHelper->hidden($model . '.' . $options['editorDraftField']); $draftId = Inflector::camelize(implode('_', array($model, $options['editorDraftField']))); $draftVal = empty($this->_View->data[$model][$options['editorDraftField']]) ? '' : $this->_View->data[$model][$options['editorDraftField']]; $editorHtml .= '<div id="DraftArea" class="bge-view-value bge_content" style="display:none;">' . $draftVal . '</div>'; } $editorHtml .= '<div id="ValueArea" class="bge-view-value bge_content">'; if (isset($this->_View->data[$model]) && isset($this->_View->data[$model][$column]) && $this->_View->data[$model][$column]) { $editorHtml .= $this->_View->data[$model][$column]; } $editorHtml .= '</div>'; $is_page = $this->request->params['controller'] == 'pages' ? true : false; $editorHtml .= $this->requestAction('/admin/burger_editor/burger_editor/editor', array('return', 'layout' => false, 'inputId' => Inflector::camelize(implode('_', $fieldAry)), 'draftId' => $draftId, 'is_page' => $is_page)); // load読み込み foreach (self::$useType as $type) { if (file_exists(self::$addonDir . "Type" . DS . $type . DS . 'load.php')) { include self::$addonDir . "Type" . DS . $type . DS . 'load.php'; } } $this->BcBaser->css(array('admin/ckeditor/editor', 'BurgerEditor.admin/burger_editor'), array('inline' => false)); $this->BcBaser->js(array('/burger_editor/js/admin/jquery.replacebox.min', 'admin/ckeditor/ckeditor', 'BurgerEditor.ckeditor/adapters/jquery'), array('inline' => false)); // ユーザ(サイト制作者)定義CSSの自動読込 $userCssList = array(); // themeのcss優先 if (file_exists(WWW_ROOT . 'theme' . DS . Configure::read('BcSite.theme') . DS . 'css' . DS . 'bge_style.css')) { $userCssList[] = "bge_style.css"; // themeになく、webroot/cssにあれば読込 } elseif (file_exists(WWW_ROOT . 'css' . DS . 'bge_style.css')) { $userCssList[] = "bge_style.css"; // themeになく、webroot/cssにもない場合、プラグイン標準のファイルを読み込む } else { $userCssList[] = 'BurgerEditor.bge_style'; } if ($userCssList) { $this->BcBaser->css($userCssList, array('inline' => false)); } $editorStartTitle = '<h2 style="text-align:left;">コンテンツ編集エリア</h2>'; echo $editorStartTitle; echo $editorHtml; echo $bcFormHelper->error($fieldName); }