public function run() { //begin form echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'class' => $this->class)); foreach ($this->model as $item) { if ($this->selector) { echo CHtml::checkBox('selector_' . $item['key']); } $name = Awecms::generateFriendlyName($item["key"]); ?> <div class="settings row"> <?php echo $this->getlabel($item['key']); switch ($item['type']) { //add new types here case 'textfield': echo $this->getFullTextField($item); break; case 'boolean': echo CHtml::hiddenField($item['key'], 0); echo CHtml::checkBox($item['key'], $item['value']); break; case 'image_url': echo $this->getFullTextField($item); echo "<a class=\"right\" href=\"{$item["value"]}\" target=\"_blank\"><img src=\"{$item["value"]}\" title=\"{$name}\" alt=\"{$name}\" /></a>"; break; case 'email': echo $this->getFullTextField($item); break; case 'textarea': echo CHtml::textArea($item['key'], $item['value']); case 'NULL': break; default: echo "Unsupported type: " . $item['type'] . " of " . $item['key'] . " with value " . $item['value'] . "<br/>"; break; } if (isset($item['hint'])) { ?> <p class="hint"> <?php echo $item['hint']; ?> </p> <?php } ?> </div> <?php } ?> <div class="row buttons"> <?php echo CHtml::submitButton('Submit!'); ?> </div> <?php echo CHtml::endForm(); }
/** * Display editor */ public function run() { // Resolve name and id list($name, $id) = $this->resolveNameID(); // Get assets dir $baseDir = dirname(__FILE__); $assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'ueditor1_2_5'); // Publish required assets $cs = Yii::app()->getClientScript(); $jsFile = $this->debug ? 'editor_all.js' : 'editor_all_min.js'; $cs->registerScriptFile($assets . '/' . $jsFile); $cs->registerScriptFile($assets . '/editor_config.js'); $this->htmlOptions['id'] = $id; if (!array_key_exists('style', $this->htmlOptions)) { $this->htmlOptions['style'] = "width:{$this->width};"; } if ($this->toolbars) { $this->editorOptions['toolbars'][] = $this->toolbars; } $options = CJSON::encode(array_merge(array('theme' => $this->theme, 'lang' => $this->language, 'UEDITOR_HOME_URL' => "{$assets}/", 'initialFrameWidth' => $this->width, 'initialFrameHeight' => $this->height), $this->editorOptions)); $js = <<<EOP UE.getEditor('{$id}',{$options}); EOP; // Register js code $cs->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_READY); // Do we have a model if ($this->hasModel()) { $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { $html = CHtml::textArea($name, $this->value, $this->htmlOptions); } echo $html; }
/** * Add WYMeditor to the page. */ public function run() { // Add textarea to the page if ($this->target === null) { list($name, $id) = $this->resolveNameID(); if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } } // Publish extension assets $assets = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.EWYMeditor') . '/assets'); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile($assets . '/jquery.wymeditor.js', CClientScript::POS_END); // Add the plugins to editor if ($this->plugins !== array()) { $this->_addPlugins($cs, $assets); } $options = CJavaScript::encode($this->options); if ($this->target === null) { $cs->registerScript('wym', "jQuery('#{$id}').wymeditor({$options});"); } else { $cs->registerScript('wym', "jQuery('{$this->target}').wymeditor({$options});"); } }
public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $name; } if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source'; $baseUrl = Yii::app()->getAssetManager()->publish($path); $js = 'jQuery(\'#' . $id . '\').xheditor(' . $options . ');'; $cs = Yii::app()->getClientScript(); Yii::app()->clientScript->registerCoreScript('jquery'); if (is_null($this->language)) { $this->language = Yii::app()->language; } $cs->registerScriptFile($baseUrl . '/xheditor-' . $this->language . '.min.js'); $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * Executes the widget. * This method registers all needed client scripts and renders * the text field. */ public function init() { $this->updateOptions(); $baseDir = dirname(__FILE__); $assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'assets'); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile($assets . '/edit_area_full.js', CClientScript::POS_HEAD); $rand = md5(uniqid(rand(), true)); if ($this->hasModel()) { if ($this->form) { $html = $this->form->textArea($this->model, $this->attribute, array('rows' => $this->options['rows'], 'cols' => $this->options['cols'], 'id' => $rand, 'encode' => true)); } else { $html = CHtml::activeTextArea($this->model, $this->attribute, array('rows' => $this->options['rows'], 'cols' => $this->options['cols'], 'id' => $rand, 'encode' => true)); } } else { $html = CHtml::textArea($this->options['name'], $this->options['value'], array('rows' => $this->options['rows'], 'cols' => $this->options['cols'], 'id' => $rand, 'encode' => true)); } unset($this->options['rows']); unset($this->options['cols']); unset($this->options['name']); unset($this->options['class']); unset($this->options['value']); $js = "\teditAreaLoader.init({ \n\t\tid : \"{$rand}\""; foreach ($this->options as $k => $v) { $js .= ",\n\t\t{$k}: '{$v}'"; } $js .= "\n\t});"; Yii::app()->clientScript->registerScript($rand, $js, CClientScript::POS_READY); echo $html; }
/** * Run widget. */ public function run() { if($this->hasModel()) echo CHtml::activeTextArea($this->model,$this->attribute,$this->htmlOptions); else echo CHtml::textArea($this->name,$this->value,$this->htmlOptions); }
/** * Display editor */ public function run() { // Resolve name and id list($name, $id) = $this->resolveNameID(); // Get assets dir $baseDir = dirname(__FILE__); $assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'assets'); // Publish required assets $cs = Yii::app()->getClientScript(); $jsFile = $this->debugMode ? 'redactor.js' : 'redactor.min.js'; $cs->registerScriptFile($assets . '/' . $jsFile); $cs->registerCssFile($assets . '/css/redactor.css'); $this->htmlOptions['id'] = $id; if (!array_key_exists('style', $this->htmlOptions)) { $this->htmlOptions['style'] = "width:{$this->width};height:{$this->height};"; } $options = CJSON::encode(array_merge($this->editorOptions, array('lang' => $this->lang, 'toolbar' => $this->toolbar))); $js = <<<EOP \t\t\$('#{$id}').redactor({$options}); EOP; // Register js code $cs->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_READY); // Do we have a model if ($this->hasModel()) { $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { $html = CHtml::textArea($name, $this->value, $this->htmlOptions); } echo $html; }
public function run() { $this->editorOptions = array_merge($this->editorOptions, $this->defaultOptions); list($name, $id) = $this->resolveNameID(); // Publishing assets. $dir = dirname(__FILE__); $assets = Yii::app()->getAssetManager()->publish($dir.DIRECTORY_SEPARATOR.'assets'); $this->editorOptions['script_url'] = $assets.'/tiny_mce.js'; // Registering javascript. $cs = Yii::app()->getClientScript(); $cs->registerCoreScript('jquery'); $cs->registerScriptFile($assets.'/jquery.tinymce.js'); $cs->registerScriptFile($assets.'/plugins/tinybrowser/tb_tinymce.js.php'); $cs->registerScript( 'Yii.'.get_class($this).'#'.$id, '$(function(){$("#'.$id.'").tinymce('.CJavaScript::encode($this->editorOptions).');});' ); $this->htmlOptions['id'] = $id; if($this->hasModel()) $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); else $html = CHtml::textArea($name, $this->value, $this->htmlOptions); echo $html; }
/** * Run script */ public function run() { $this->htmlOptions['id'] = $this->id; if (!isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = 'form-control textarea-control markitup-control'; } if (!isset($this->htmlOptions['contenteditable'])) { $this->htmlOptions['contenteditable'] = true; } $textarea = ''; if ($this->model instanceof CModel) { if (!$this->attribute) { throw new CException(Yii::t('yii', 'The $attribute argument must be a instance of CActiveRecord.')); } else { $textarea = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } } else { if (!$this->name) { throw new CException(Yii::t('yii', 'The $model or $name argument must be a filled.')); } else { $textarea = CHtml::textArea($this->name, $this->value, $this->htmlOptions); } } $this->render('rich-text', ['textarea' => $textarea, 'emoticonCategories' => EmoticonCategory::model()->findAll()]); }
/** * Renders field */ public function renderField() { if ($this->hasModel()) { echo \CHtml::activeTextArea($this->model, $this->attribute, $this->options); } else { echo \CHtml::textArea($this->options['name'], $this->value, $this->options); } }
public function run() { $htmlOptions = $this->htmlOptions; list($name, $id) = $this->resolveNameID(); echo CHtml::tag('div', $htmlOptions, CHtml::textArea($name, $this->value, array('id' => $id))); $config = json_encode($this->editorOptions); App()->getClientScript()->registerScript("initJsonEditor" . $id, "\$('#{$id}').jsonEditor({$config});", CClientScript::POS_READY); }
public function run() { list($name, $id) = $this->resolveNameID(); echo CHtml::tag('div', array('id' => $id . '_container', 'class' => 'editor'), false, false); echo CHtml::tag('div', array('id' => $id . '_editor', 'style' => 'height: ' . $this->height . 'px'), false, false); echo CHtml::closeTag('div'); echo CHtml::textArea($name, $this->value, array('id' => $id, 'class' => 'editorTextarea')); echo CHtml::closeTag('div'); }
/** * Run widget. */ public function run() { if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { if ($this->selector !== null) { echo CHtml::textArea($this->name, $this->value, $this->htmlOptions); } } }
/** * Generates a text area input. * @param string the input name * @param string the input value * @param array additional HTML attributes. Besides normal HTML attributes, a few special * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.) * @return string the generated text area * @see clientChange * @see inputField */ public static function textArea($name, $value = '', $htmlOptions = array()) { if (isset($htmlOptions['class'])) { if (stripos($htmlOptions['class'], 'ui-corner-all') === false) { $htmlOptions['class'] .= ' ui-corner-all'; } } else { $htmlOptions['class'] = 'ui-corner-all'; } return parent::textArea($name, $value, $htmlOptions); }
/** * @throws \Exception */ public function run() { list($name, $id) = $this->resolveNameID(); $this->htmlOptions['id'] = $id; if ($this->hasModel()) { echo \CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo \CHtml::textArea($name, $this->value, $this->htmlOptions); } $this->registerClientScript($id); }
/** * Renders field */ public function renderField() { list($name, $id) = $this->resolveNameID(); TbArray::defaultValue('id', $id, $this->htmlOptions); TbArray::defaultValue('name', $name, $this->htmlOptions); if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } }
public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '') { if ($hasError) { $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss; } $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName); if (ClonnableFields::isModel($model)) { return CHtml::activeTextArea($model, $attribute, $htmlOptions); } else { return CHtml::textArea($name, $value, $htmlOptions); } }
/** * Init widget. */ public function init() { parent::init(); if ($this->selector === null) { list($this->name, $this->id) = $this->resolveNameID(); $this->htmlOptions['id'] = $this->getId(); $this->selector = '#' . $this->getId(); if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($this->name, $this->value, $this->htmlOptions); } } $this->registerClientScript(); }
/** * Display editor */ public function run() { list($name, $id) = $this->resolveNameID(); $this->htmlOptions['id'] = $id; $this->registerClientScript($id); if (!array_key_exists('style', $this->htmlOptions)) { $this->htmlOptions['style'] = "width:{$this->width};height:{$this->height};"; } if ($this->hasModel()) { // Do we have a model? echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } }
/** * Renders field */ public function renderField() { list($name, $id) = $this->resolveNameID(); $this->options['id'] = ArrayHelper::getValue($this->options, 'id', $id); $this->options['name'] = ArrayHelper::getValue($this->options, 'name', $name); $tagOptions = $this->options; $tagOptions['id'] = 'aceEditor_' . $tagOptions['id']; echo \CHtml::tag('div', $tagOptions); $this->options['style'] = 'display:none'; if ($this->hasModel()) { echo \CHtml::activeTextArea($this->model, $this->attribute, $this->options); } else { echo \CHtml::textArea($name, $this->value, $this->options); } $this->options = $tagOptions; }
/** *### .run() * * Display editor */ public function run() { list($name, $id) = $this->resolveNameID(); $this->registerClientScript($id); $this->htmlOptions['id'] = $id; // Do we have a model? if ($this->hasModel()) { if ($this->form) { $html = $this->form->textArea($this->model, $this->attribute, $this->htmlOptions); } else { $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } } else { $html = CHtml::textArea($name, $this->value, $this->htmlOptions); } echo $html; }
/** * Renders field */ public function renderField() { list($name, $id) = $this->resolveNameID(); TbArray::defaultValue('id', $id, $this->htmlOptions); TbArray::defaultValue('name', $name, $this->htmlOptions); $tagOptions = $this->htmlOptions; $tagOptions['id'] = 'aceEditor_' . $tagOptions['id']; echo CHtml::openTag('div', $tagOptions); echo CHtml::closeTag('div'); $this->htmlOptions['style'] = 'display:none'; if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } $this->htmlOptions = $tagOptions; }
/** * Display editor */ public function run() { list($name, $id) = $this->resolveNameID(); $this->registerClientScript($id); // Markdown Editor looks for an id of wmd-input... $this->htmlOptions['id'] = $id; $this->htmlOptions['class'] = isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' wmd-input' : 'wmd-input'; if (!array_key_exists('style', $this->htmlOptions)) { $this->htmlOptions['style'] = "width:{$this->width};height:{$this->height};"; } // Do we have a model? if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } }
public function run() { list($name, $id) = $this->resolveNameID(); $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'jquery'; $baseUrl = Yii::app()->getAssetManager()->publish($dir); $cs = Yii::app()->getClientScript(); $cs->registerCoreScript('jquery'); $cs->registerScriptFile($baseUrl . '/jquery.autogrow.js'); if ($this->hasModel()) { $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { $html = CHtml::textArea($id, $this->value, $this->htmlOptions); } $js = $this->jsCode($id); $cs->registerScript(get_class($this) . '_' . $id, $js); echo $html; }
/** * Init widget. */ public function init() { parent::init(); if ($this->selector === null) { list($this->name, $this->id) = $this->resolveNameID(); $this->htmlOptions['id'] = $this->getId(); $this->selector = '#' . $this->getId(); if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($this->name, $this->value, $this->htmlOptions); } } $package = array_merge(array('baseUrl' => $this->getAssetsUrl()), $this->package); self::initClientScript($package, isset($this->options['lang']) && $this->options['lang'] !== 'en' ? $this->options['lang'] : null); $this->registerClientScript(); }
public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } if (isset($this->model)) { echo CHtml::textArea($name, CHtml::resolveValue($this->model, $this->attribute), $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } $this->registerScripts($id); }
public function formInput(&$controller, $tagOptions=array()) { ob_start(); $inputName = $this->formInputName(); $inputID = "i_{$inputName}"; echo CHtml::label($this->label, $inputID); echo CHtml::tag('br'); $tagOptions['id'] = $inputID; if($this->isReadonly) $tagOptions['disabled'] = true; $value = str_replace("<p>", "", $this->value); $value = str_replace("</p>", "", $value); $value = str_replace('<br/>', "\n", $value); $value = AAHelperForm::prepareTextForForm($value); echo CHtml::textArea($inputName, $value, $tagOptions); return ob_get_clean(); }
public function init() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $name; } $this->registerClientScript(); if ($this->hasModel()) { echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textArea($name, $this->value, $this->htmlOptions); } }
public function run() { parent::run(); list($name, $id) = $this->resolveNameID(); $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'); $options = $this->makeOptions(); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile($assets . '/ckeditor.js'); $this->htmlOptions['id'] = $id; $js = <<<EOP CKEDITOR.replace('{$name}',{$options}); EOP; $cs->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_LOAD); if ($this->hasModel()) { $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { $html = CHtml::textArea($name, $this->value, $this->htmlOptions); } echo $html; }
public function run() { // here render procedures echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'target' => $this->target)); // you better create a function but // for the sake of the example... foreach ($this->attributes as $attr) { // here we can actually say i // this is very simple but you get the idea echo CHtml::label($attr['label'], $attr['name']); if ($attr['type'] == 'text') { echo CHtml::textField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'textarea') { echo CHtml::textArea($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'password') { echo CHtml::passwordField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'checkbox') { echo CHtml::checkBox($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'checkboxlist') { echo CHtml::checkBoxList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'date') { echo CHtml::dateField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'dropdownlist') { echo CHtml::dropDownList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'file') { echo CHtml::fileField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'hidden') { echo CHtml::hiddenField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'radio') { echo CHtml::radioButton($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'radiolist') { echo CHtml::radioButtonList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } } } } } } } } } } } // do more here } echo "<br/><br/><div class='row-fluid'>"; echo CHtml::submitButton($this->submit['label'], $this->submit['options']); echo "</div>"; echo CHtml::endForm(); }