public static function fieldTips($tips, $htmlOptions = array()) { if (!isset($htmlOptions['class'])) { $htmlOptions['class'] = 'field-tips'; } return CHtml::tag('div', $htmlOptions, $tips); }
/** * Renders the content of the widget. * @throws CException */ public function run() { // Hide empty breadcrumbs. if (empty($this->links)) { return; } $links = array(); if (!isset($this->homeLink)) { $content = CHtml::link(Yii::t('zii', 'Inicio'), Yii::app()->homeUrl); $links[] = $this->renderItem($content); } else { if ($this->homeLink !== false) { $links[] = $this->renderItem($this->homeLink); } } foreach ($this->links as $label => $url) { if (is_string($label) || is_array($url)) { $content = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url); $links[] = $this->renderItem($content); } else { $links[] = $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, true); } } echo CHtml::tag('ul', $this->htmlOptions, implode('', $links)); }
public function init() { if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $id = $this->htmlOptions['id'] = $this->getId(); } if ($this->url !== null) { $this->url = CHtml::normalizeUrl($this->url); } $cs = Yii::app()->getClientScript(); //$cs->registerCoreScript('treeview'); $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.yii-jqTree.source')); $cs->registerScriptFile($baseUrl . '/tree.jquery.js'); $options = $this->getClientOptions(); $options = $options === array() ? '{}' : CJavaScript::encode($options); $cs->registerScript('Yii.JQTree#0' . $id, "if (jQuery.jqTree == undefined) {jQuery.jqTree = new Array;}"); $cs->registerScript('Yii.JQTree#' . $id, "jQuery.jqTree[\"{$id}\"] = jQuery(\"#{$id}\").tree({$options});"); if ($this->cssFile === null) { $cs->registerCssFile($baseUrl . '/jqtree.css'); } else { if ($this->cssFile !== false) { $cs->registerCssFile($this->cssFile); } } echo CHtml::tag('ul', $this->htmlOptions, false, false) . "\n"; }
/** * Runs the widget. */ public function run() { $id = $this->id; echo CHtml::tag('input', $this->htmlOptions); $options = !empty($this->options) ? CJavaScript::encode($this->options) : ''; Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').typeahead({$options});"); }
public function formInput(&$controller, $tagOptions=array()) { ob_start(); $inputName = $this->formInputName(); $inputID = "i_{$inputName}"; echo CHtml::label($this->label, $inputID); echo CHtml::tag('br'); if($this->isReadonly) $tagOptions['disabled'] = true; if($this->value) { $oldOptions = array('readonly'=>true); if($this->isReadonly) $tagOptions['disabled'] = true; echo CHtml::textField("{$inputName}[old]", $this->value, $oldOptions); unset($oldOptions['readonly']); ?> <label class="delfile"> <?php echo Yii::t('AutoAdmin.form', '<b class="warning">Delete</b> the file')?> <span class="tip">(<?php echo Yii::t('AutoAdmin.form', 'set checkbox on for confirm')?>)</span>: <?php echo CHtml::checkBox("{$inputName}[del]", false, $oldOptions);?> </label> <?php } $tagOptions['id'] = $inputID; echo CHtml::label(Yii::t('AutoAdmin.form', 'New file').':', $inputID); ?> <div class="tip inline"><a href=<?php echo $this->options['directoryPath']?>/</div> <?php echo CHtml::fileField(AutoAdmin::INPUT_PREFIX."[{$this->name}_new]", null, $tagOptions); return ob_get_clean(); }
/** * Renders the data item list. */ public function renderItems() { echo CHtml::openTag('table', array('class' => 'po-table mind-list')) . "\n"; echo CHtml::openTag('thead') . "\n"; echo CHtml::tag('th', array('width' => 20), ' ') . "\n"; echo CHtml::tag('th', array(), ' ') . "\n"; echo CHtml::tag('th', array('width' => 30), ' ') . "\n"; echo CHtml::tag('th', array('width' => 100), ' ') . "\n"; echo CHtml::tag('th', array('width' => 150), '<span class="mind-list__clear-all">удалить все</span>') . "\n"; echo CHtml::closeTag('thead'); echo CHtml::openTag($this->itemsTagName, array('class' => $this->itemsCssClass)) . "\n"; $data = $this->dataProvider->getData(); if (($n = count($data)) > 0) { $owner = $this->getOwner(); $viewFile = $owner->getViewFile($this->itemView); $j = 0; foreach ($data as $i => $item) { $data = $this->viewData; $data['index'] = $i; $data['data'] = $item; $data['widget'] = $this; $owner->renderFile($viewFile, $data); if ($j++ < $n - 1) { echo $this->separator; } } } echo CHtml::closeTag($this->itemsTagName); echo CHtml::closeTag('table'); }
/** * 第二个下拉菜单options动态输出 * @author gentle */ public function actionAdditionType($fieldType, $additionType = -1, $databaseId = -1, $datasetId = -1) { switch ($fieldType) { //独立字段 case 'normal': $data = array('text' => '文本', 'multitext' => '多行文本', 'number' => '数值', 'select' => '单选', 'multiselect' => '多选', 'image' => '图片'); break; //调用元素集字段 //调用元素集字段 case 'reference': $dsModel = $this->loadModel($databaseId, 'ds', 'database_id', true); $data = array(); foreach ($dsModel as $key => $value) { $data[$value->en_name] = $value->name; } break; } $dropDown = "<option value=''>选择附属类型</option>"; foreach ($data as $value => $name) { if ($additionType >= 0 && $value == $additionType) { $dropDown .= CHtml::tag('option', array('value' => $value, 'selected' => 'selected'), CHtml::encode($name), true); } else { $dropDown .= CHtml::tag('option', array('value' => $value), CHtml::encode($name), true); } } echo CJSON::encode(array('dropDown' => $dropDown)); }
protected function showOutput() { if (!isset($this->htmlOptions['id'])) { $this->htmlOptions['id'] = $this->id; } echo CHtml::tag('div', $this->htmlOptions, ''); }
public static function PrintDisabledMessage() { $html = null; $message = 'This message has been removed.'; $html .= CHtml::tag('div', array('class' => 'alert alert-error'), $message); return $html; }
public static function getHtmlTree() { $models = self::getRoot()->descendants()->findAll(); $depth = 0; $res = ''; foreach ($models as $n => $item) { if ($item->depth == $depth) { $res .= CHtml::closeTag('li') . "\n"; } else { if ($item->depth > $depth) { $res .= CHtml::openTag('ul', array('class' => 'depth_' . $item->depth)) . "\n"; } else { $res .= CHtml::closeTag('li') . "\n"; for ($i = $depth - $item->depth; $i; $i--) { $res .= CHtml::closeTag('ul') . "\n"; $res .= CHtml::closeTag('li') . "\n"; } } } $res .= CHtml::openTag('li', array('id' => 'items_' . $item->id, 'class' => 'depth_' . $item->depth)); $res .= CHtml::tag('div', array(), CHtml::encode($item->title) . '<img class="drag" src="/img/admin/hand.png" height="16" width="16" />'); $depth = $item->depth; } for ($i = $depth; $i; $i--) { $res .= CHtml::closeTag('li') . "\n"; $res .= CHtml::closeTag('ul') . "\n"; } return $res; }
public function run() { echo CHtml::tag($this->tag, array('id' => $this->id)); echo CHtml::closeTag($this->tag); $options = CJavaScript::encode($this->options); Yii::app()->getClientScript()->registerScript('jwplayer' . $this->id, "jwplayer('{$this->id}').setup({$options})"); }
public function render() { parent::appendOption($this->_htmlOptions, 'class', $this->_cssClass); echo CHtml::openTag('li', $this->_htmlOptions); if (!empty($this->_data)) { echo '<ul>'; foreach ($this->_data as $item) { $i = $item['icon']; $l = $item['label']; $u = $item['url']; echo '<li>'; if (!empty($i)) { if (is_array($i)) { $img = CHtml::tag('img', $i, ''); } else { $img = CHtml::image($i, CHtml::encode($l)); } $l = $img . $l; } echo CHtml::link($l, $u, @$item['htmlOptions']); echo '</li>'; } echo '</ul>'; } echo CHtml::closeTag('li'); }
public function getRank($attribute) { if ($this->{$attribute} <= 10) { return CHtml::tag('span', array('class' => 'top10'), $this->{$attribute}); } return $this->{$attribute}; }
/** * Run widget. */ public function run() { parent::run(); $this->htmlOptions['id'] = $this->map->id; echo Html::tag($this->tagName, $this->htmlOptions, ''); $this->onAfterRender(new \CEvent($this)); }
/** * @throws CException */ public function run() { $this->imageSrc = $this->user->getAvatar($this->size); $this->imageAlt = $this->user->nick_name; $this->width = $this->size . 'px'; $this->htmlOptions = ['class' => 'avatar avatar-' . $this->user->id]; if (!$this->height) { $this->height = $this->width; } Yii::app()->clientScript->registerCssFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('user.assets.css') . '/image-wrapper.css')); $htmlOptions = ['class' => 'img-wrapper-tocenter', 'style' => 'width: ' . $this->width . '; height: ' . $this->height . '; background-color: ' . $this->backgroundColor . ';']; if (isset($this->htmlOptions['class'])) { $class = $this->htmlOptions['class']; unset($this->htmlOptions['class']); $htmlOptions['class'] .= ' ' . $class; } if (isset($this->htmlOptions['style'])) { $style = $this->htmlOptions['style']; unset($this->htmlOptions['style']); $htmlOptions['style'] .= ' ' . $style; } if (is_array($this->htmlOptions) && count($this->htmlOptions) > 0) { $htmlOptions = array_merge($htmlOptions, $this->htmlOptions); } echo CHtml::tag('div', $htmlOptions, CHtml::image($this->imageSrc . ($this->noCache ? '?' . microtime(true) : ''), $this->imageAlt, $this->imageHtmlOptions)); }
/** * @param null $label * @param array $options * @return string */ public function getSubmitButtonRow($label = null, $options = array()) { if (!isset($options['color'])) { $options['color'] = TbHtml::BUTTON_COLOR_PRIMARY; } return CHtml::tag('div', array('class' => 'form-actions'), TbHtml::submitButton($label, $options)); }
public function actionUpdate($dir, $fileName) { if (isset($_POST['fileContent'])) { FileSystem::write('./'.$dir.'/'.$fileName, $_POST['fileContent'], 'w'); Y::end(); } $content = ''; $info = FileSystem::getInfo('./'.$dir.'/'.$fileName, array('name', 'ext')); if (in_array($info['ext'], array('js', 'css'))) { if (substr($dir, 0, 2) == 'js' || substr($dir, 0, 3) == 'css') { $content = FileSystem::read('./'.$dir.'/'.$fileName); } } $output = $this->renderPartial('fileDetails', array( 'fileName' => $fileName, 'content' => $content, 'type' => $info['ext'] == 'css' ? 'css' : 'javascript', 'filePath' => './'.$dir.'/'.$fileName ), true); Y::tab('Содержимое файла', $output); $output = Y::getTabs('cssFileForm', true); Y::clientScript()->render($output); echo CHtml::tag('div', array(), $output); }
/** * Renders plugin container */ public function renderContainer() { if ($this->date !== null) { $this->options['title'] = $this->date; echo \CHtml::tag($this->tag, $this->options, ' '); } }
/** * Renders the widget. If there are no items, nothing will be rendered. * TODO: Reuse TbCollapse somehow */ public function run() { $itemCount = count($this->items); if ($itemCount === 0) { return; } echo CHtml::openTag('div', $this->htmlOptions); foreach ($this->items as $k => $item) { $id = __CLASS__ . '_' . $this->id . '_' . $k; $contentId = $id . '_content'; $linkOptions = array('class' => 'accordion-toggle episode-toggle', 'data-content-id' => $contentId, 'data-toggle' => 'collapse', 'data-parent' => $this->id); // Add content-url data attributes to the link when available if (isset($item['contentUrl'])) { $linkOptions['data-content-url'] = $item['contentUrl']; } // Render the contents of the heading $heading = $this->render('_seasonAccordionHeading', array('linkUrl' => '#' . $id, 'linkOptions' => $linkOptions, 'season' => $item['season']), true); $bodyOptions = array('class' => 'accordion-body collapse', 'id' => $id); if ($itemCount === 1) { TbHtml::addCssClass('in', $bodyOptions); } echo CHtml::openTag('div', array('class' => 'accordion-group')); echo CHtml::tag('div', array('class' => 'accordion-heading'), $heading); echo CHtml::openTag('div', $bodyOptions); echo CHtml::tag('div', array('id' => $contentId, 'class' => 'accordion-inner'), $item['content']); echo CHtml::closeTag('div'); echo CHtml::closeTag('div'); } echo CHtml::closeTag('div'); }
/** * @return string the HTML for a watched icon. An empty string is returned * if the item has not been watched */ public function getWatchedIcon() { if ($this->playcount > 0) { return CHtml::tag('i', array('class' => 'watched-icon fa fa-check'), ''); } return ''; }
/** * Renders the input file field */ public function renderField() { list($name, $id) = $this->resolveNameID(); TbArray::defaultValue('id', $id, $this->htmlOptions); TbArray::defaultValue('name', $name, $this->htmlOptions); echo CHtml::openTag('div', $this->htmlOptions); echo CHtml::openTag('div', array('class' => 'input-prepend bfh-timepicker-toggle', 'data-toggle' => 'bfh-timepicker')); echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_TIME)); if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions); } else { echo CHtml::textField($name, $this->value, $this->inputOptions); } echo CHtml::closeTag('div'); echo '<div class="bfh-timepicker-popover"> <table class="table"> <tbody> <tr> <td class="hour"> <a class="next" href="#"><i class="icon-chevron-up"></i></a><br> <input type="text" class="input-mini" readonly><br> <a class="previous" href="#"><i class="icon-chevron-down"></i></a> </td> <td class="separator">:</td> <td class="minute"> <a class="next" href="#"><i class="icon-chevron-up"></i></a><br> <input type="text" class="input-mini" readonly><br> <a class="previous" href="#"><i class="icon-chevron-down"></i></a> </td> </tr> </tbody> </table> </div>'; echo CHtml::closeTag('div'); }
public function ajaxRefresh($player, $type) { $all = $type === 'all'; if (!is_array($type)) { $type = array($type); } $ret = array(); if ($all || in_array('tp', $type) || in_array('summon', $type)) { ob_start(); $error = ''; if (!Yii::app()->user->can($player->server_id, 'get players')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($player->server_id, 'get players', $players)) { $error = McBridge::get()->lastError(); } } if (strlen($error)) { echo CHtml::encode($error); } else { foreach ($players as $player) { echo CHtml::tag('option', array('value' => $player['id'], $player['id'] == @$defOther ? 'selected' : '' => 'selected'), CHtml::encode($player['name'])); } } $ret['summon'] = $ret['tp'] = ob_get_clean(); } return $ret; }
public function run() { if (empty($this->links)) { return; } if (isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] .= ' breadcrumb'; } else { $this->htmlOptions['class'] = 'breadcrumb'; } echo CHtml::openTag($this->tagName, $this->htmlOptions) . "\n"; $links = array(); if ($this->homeLink === null) { $links[] = CHtml::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl); } else { if ($this->homeLink !== false) { $links[] = $this->homeLink; } } foreach ($this->links as $label => $url) { if (is_string($label) || is_array($url)) { $links[] = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url); } else { $links[] = '<span>' . ($this->encodeLabel ? CHtml::encode($url) : $url) . '</span>'; } } $separator = CHtml::tag('span', array('class' => 'divider'), $this->separator) . CHtml::closeTag('li') . ' ' . CHtml::openTag('li'); echo CHtml::openTag('li') . implode($separator, $links) . CHtml::closeTag('li'); echo CHtml::closeTag($this->tagName); }
public function renderMeta() { if (empty($this->metaTitle)) { $this->metaTitle = Yii::app()->params['htmlMetadata']['title']; } if (empty($this->metaDescription)) { $this->metaDescription = Yii::app()->params['htmlMetadata']['description']; } if (empty($this->metaKeyword)) { $this->metaKeyword = Yii::app()->params['htmlMetadata']['keywords']; } if (empty($this->canonical)) { $this->canonical = Yii::app()->request->getHostInfo() . Yii::app()->request->url; } echo CHtml::tag('link', array('rel' => 'canonical', 'href' => $this->canonical)); $metaKeywords = CMap::mergeArray(array('title' => $this->metaTitle, 'description' => $this->metaDescription, 'keywords' => $this->metaKeyword), $this->metaKeyOthers); foreach ($metaKeywords as $name => $content) { echo CHtml::metaTag($content, $name) . PHP_EOL; } if (!empty($this->metaProperties)) { foreach ($this->metaProperties as $key => $content) { echo '<meta property="' . $content['name'] . '" content="' . $content['value'] . '" />' . PHP_EOL; } // we can't use Yii's method for this. } }
/** * Retrieves all cards in a particular category * @param string $id The category id */ public function actionGetCardsByCategory($id = NULL) { if ($id === NULL) { throw new CHttpException(400, Yii::t('Dashboard.main', 'Missing category id')); } $categories = Yii::app()->cache->get('cards_in_category'); if ($categories === false) { $this->getCards(); $categories = Yii::app()->cache->get('cards_in_category'); } $cards = $categories[$id]; $elements = $elementOptions = array(); // TODO: Fix multiple select //$elementOptions['multiple'] = 'multiple'; foreach ($cards as $k => $card) { $asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias($card['path']), true, -1, YII_DEBUG); $elements[] = $k; $elementOptions['options'][] = array('value' => $k, 'data-img-src' => Yii::app()->getBaseUrl(true) . $asset . '/default.png'); } $form = $this->beginWidget('ext.cii.widgets.CiiActiveForm', array('htmlOptions' => array('class' => 'pure-form pure-form-aligned item-selection-form'))); echo CHtml::openTag('div', array('class' => 'pure-form-group', 'style' => 'padding-bottom: 20px')); echo CHtml::link(Yii::t('Dashboard.main', 'Add to Dashboard'), '#', array('id' => 'add-cards-button', 'class' => 'pure-button pure-button-link pure-button-primary pull-right pure-button-small', 'style' => 'position: absolute; top: 15px; right: 3%;')); echo CHtml::tag('legend', array(), $id); echo CHtml::dropDownList('card', NULL, $elements, $elementOptions); echo CHtml::closeTag('div'); $this->endWidget(); }
protected function renderDataCellContent($row, $data) { ob_start(); parent::renderDataCellContent($row, $data); $cellContent = ob_get_contents(); ob_clean(); ob_end_clean(); if ($this->id === false && $this->dataAttr === false) { echo $cellContent; } else { if (isset($this->id) || isset($this->dataAttr)) { $containerHtmlOptions = array(); if (is_string($this->id)) { $id = $this->evaluateExpression($this->id, array('row' => $row, 'data' => $data)); $containerHtmlOptions['id'] = $id; } if (is_array($this->dataAttr)) { foreach ($this->dataAttr as $name => $value) { $containerHtmlOptions[$name] = $this->evaluateExpression($value, array('row' => $row, 'data' => $data)); } } echo CHtml::tag('div', $containerHtmlOptions, $cellContent, true); } } }
/** *### .run() * * Renders the content of the widget. * * @throws CException */ public function run() { // Hide empty breadcrumbs. if (empty($this->links)) { return; } $links = ''; if (!isset($this->homeLink)) { $content = CHtml::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl); $links .= $this->renderItem($content); } else { if ($this->homeLink !== false) { $links .= $this->renderItem($this->homeLink); } } $count = count($this->links); $counter = 0; foreach ($this->links as $label => $url) { ++$counter; // latest is the active one if (is_string($label) || is_array($url)) { $content = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url); $links .= $this->renderItem($content); } else { $links .= $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, $counter === $count); } } echo CHtml::tag('ul', $this->htmlOptions, $links); }
protected function createPageButton($label, $page, $class, $hidden, $selected) { if ($hidden || $selected) { $class .= ' ' . ($hidden ? 'disabled' : 'active'); } return CHtml::tag('li', array('class' => $class), CHtml::link($label, $this->createPageUrl($page), $this->linkOptions)); }
/** * @see CMenu::renderMenuRecursive */ protected function renderMenuRecursive($items) { foreach ($items as $item) { echo CHtml::openTag('li', isset($item['htmlOptions']) ? $item['htmlOptions'] : array()); if (isset($item['encodeLabel']) ? $item['encodeLabel'] : $this->encodeLabel) { $item['label'] = CHtml::encode($item['label']); } if (isset($item['url']) && !($this->activeLinkDisable && $item['active'])) { $menu = CHtml::link($item['label'], $item['url'], isset($item['linkOptions']) ? $item['linkOptions'] : array()); } else { $menu = CHtml::tag('span', isset($item['linkOptions']) ? $item['linkOptions'] : array(), $item['label']); } if (isset($this->itemTemplate) || isset($item['template'])) { $template = isset($item['template']) ? $item['template'] : $this->itemTemplate; echo strtr($template, array('{menu}' => $menu)); } else { echo $menu; } if (isset($item['items']) && count($item['items'])) { echo "\n" . CHtml::openTag('ul', CMap::mergeArray($this->submenuHtmlOptions, $item['submenuHtmlOptions'] ? $item['submenuHtmlOptions'] : array())) . "\n"; $this->renderMenuRecursive($item['items']); echo CHtml::closeTag('ul') . "\n"; } echo CHtml::closeTag('li') . "\n"; } }
public function run() { reset($this->tabs); if (!$this->activeTab) { $this->activeTab = key($this->tabs); } echo '<div class="tab-group">'; echo '<div class="tab-group-header">'; foreach ($this->tabs as $id => $tab) { echo '<span class="tab-header ' . ($this->activeTab == $id ? 'active' : '') . '" data-header-for="' . $id . '">' . $tab['header'] . '</span>'; } echo '</div>'; echo '<div class="tab-container">'; foreach ($this->tabs as $id => $tab) { $tab['htmlOptions']['data-tab-id'] = $tab['htmlOptions']['id']; if ($id == $this->activeTab) { $tab['htmlOptions']['class'] .= ' active'; } echo CHtml::tag('div', $tab['htmlOptions'], $tab['content']); } echo '</div>'; echo '</div>'; /** @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); $cs->registerScriptFile('/js/TabbedView.js', CClientScript::POS_END); }