/** * Renders a link button. * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $url = \bootstrap\helpers\BSArray::popValue('url', $button, '#'); if (strcmp($url, '#') !== 0) { $url = $this->evaluateExpression($url, array('data' => $data, 'row' => $row)); } $imageUrl = \bootstrap\helpers\BSArray::popValue('imageUrl', $button, false); $label = \bootstrap\helpers\BSArray::popValue('label', $button, $id); $options = \bootstrap\helpers\BSArray::popValue('options', $button, array()); \bootstrap\helpers\BSArray::defaultValue('data-title', $label, $options); \bootstrap\helpers\BSArray::defaultValue('title', $label, $options); \bootstrap\helpers\BSArray::defaultValue('data-toggle', 'tooltip', $options); if ($icon = \bootstrap\helpers\BSArray::popValue('icon', $button, false)) { echo CHtml::link(BSHtml::icon($icon), $url, $options); } else { if ($imageUrl && is_string($imageUrl)) { echo CHtml::link(CHtml::image($imageUrl, $label), $url, $options); } else { echo CHtml::link($label, $url, $options); } } }
/** * 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)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Modelo(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Modelo'])) { $model->attributes = $_POST['Modelo']; if ($model->save()) { if (!empty($_POST['yt1'])) { Yii::app()->user->setFlash('modelo-created', "¡El modelo <b><i>"{$model->name}"</i></b> fue creado exitosamente!"); //$this->redirect(array('create')); $modelSaved = $model; $model = new Modelo(); $model->equipment_type_id = $modelSaved->equipment_type_id; $model->brand_id = $modelSaved->brand_id; } else { $this->redirect(array('view', 'id' => $model->id)); } } } if (EquipmentType::model()->count('active = 1') == 0 && Brand::model()->count('active = 1') == 0) { throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . ' y ' . CHtml::link('crear una Marca', array('brand/create')) . '.'); } else { if (EquipmentType::model()->count('active = 1') == 0) { throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . '.'); } else { if (Brand::model()->count('active = 1') == 0) { throw new CHttpException('', 'Primero debe ' . CHtml::link('crear una Marca', array('brand/create')) . '.'); } else { $this->render('create', array('model' => $model)); } } } }
public function init() { $translations = self::getLanguagesList(); ?> <div class="language-selector"> <ul class="languages"> <?php foreach (array_reverse(self::getLanguagesList()) as $language) { ?> <li class="language <?php if ($language === Yii::app()->getLanguage()) { echo 'current'; } ?> "> <?php echo CHtml::link($language, Yii::app()->request->requestUri, array('class' => $language === Yii::app()->getLanguage(), 'submit' => Yii::app()->request->requestUri, 'params' => array('languageSelector' => $language))); ?> </li> <?php } ?> </ul> </div> <?php }
public function run() { $file = CUploadedFile::getInstanceByName('file'); $path = $this->getUniquePath($this->filesDir(), $file->extensionName); $file->saveAs($path); echo CHtml::link($file->name, "http://" . $_SERVER["HTTP_HOST"] . '/' . $path); }
/** * Renders the content of the widget. * @throws CException */ public function run() { if (empty($this->links)) { return; } $links = array(); if (!isset($this->homeLink)) { $content = CHtml::link(Yii::t('bootstrap', 'Home'), 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::openTag('ul', $this->htmlOptions); echo implode('', $links); echo '</ul>'; }
public function run() { $moduleModel = SiteModule::model()->findByPk(4); if (!empty($moduleModel)) { $root = CatalogRubrics::getRoot(); $categories = $root->descendants()->findAll($root->id); $tree = ''; $level = 0; foreach ($categories as $n => $category) { if ($category->status == 1) { if ($category->level == $level) { $tree .= CHtml::closeTag('li') . "\r\n"; } else { if ($category->level > $level) { $tree .= CHtml::openTag('ul') . "\r\n"; } else { $tree .= CHtml::closeTag('li') . "\r\n"; for ($i = $level - $category->level; $i; $i--) { $tree .= CHtml::closeTag('ul') . "\r\n"; $tree .= CHtml::closeTag('li') . "\r\n"; } } } $tree .= CHtml::openTag('li'); $tree .= CHtml::link($category->name, Yii::app()->urlManager->createUrl($moduleModel->url_to_controller . '/element', array('param' => $category->url))); $level = $category->level; } } $tree .= CHtml::closeTag('li') . "\r\n"; $tree .= CHtml::closeTag('ul') . "\r\n"; $data['tree'] = $tree; $this->render('view_Categories', $data); } }
public function run() { $nav = $content = ''; $first = true; $type = rtrim($this->type, 's'); foreach ($this->items as $id => $item) { if (is_array($item['content'])) { $id = "{$this->id}-{$id}"; $opts = $first ? array('class' => 'active') : array(); $opts['class'] = isset($opts['class']) ? $opts['class'] . ' dropdown' : 'dropdown'; $dropdown = array(); foreach ($item['content'] as $subId => $subTab) { Yii::trace(CVarDumper::dumpAsString($subTab)); $subOpts = array(); $subOpts['id'] = "{$id}-{$subId}"; $subOpts['class'] = 'tab-pane'; $content .= CHtml::tag('div', $subOpts, $subTab['content']); $dropdown[$subTab['title']] = '#' . $subOpts['id']; } Yii::trace(CVarDumper::dumpAsString($dropdown)); $nav .= CHtml::tag('li', $opts, BHtml::dropdownToggle($item['title']) . BHtml::dropdownMenu($dropdown, array('linkOptions' => array('data-toggle' => 'tab')))); } else { $id = "{$this->id}-{$id}"; $opts = $first ? array('class' => 'active') : array(); $nav .= CHtml::tag('li', $opts, CHtml::link($item['title'], "#{$id}", array('data-toggle' => $type))); $opts['id'] = $id; $opts['class'] = isset($opts['class']) ? $opts['class'] . ' tab-pane' : 'tab-pane'; $content .= CHtml::tag('div', $opts, $item['content']); } $first = false; } echo CHtml::tag('div', $this->htmlOptions, CHtml::tag('ul', $this->navOptions, $nav) . CHtml::tag('div', array('class' => 'tab-content'), $content)); BHtml::registerBootstrapJs(); }
public function actionShareAccount($id) { $model = $this->loadModel($id); $body = "\n\n\n\n" . Yii::t('accounts', '{module} Record Details', array('{module}' => Modules::displayName(false))) . " <br />\n<br />" . Yii::t('accounts', 'Name') . ": {$model->name}\n<br />" . Yii::t('accounts', 'Description') . ": {$model->description}\n<br />" . Yii::t('accounts', 'Revenue') . ": {$model->annualRevenue}\n<br />" . Yii::t('accounts', 'Phone') . ": {$model->phone}\n<br />" . Yii::t('accounts', 'Website') . ": {$model->website}\n<br />" . Yii::t('accounts', 'Type') . ": {$model->type}\n<br />" . Yii::t('app', 'Link') . ": " . CHtml::link($model->name, array('/accounts/accounts/view', 'id' => $model->id)); $body = trim($body); $errors = array(); $status = array(); $email = array(); if (isset($_POST['email'], $_POST['body'])) { $subject = Yii::t('accounts', "Account Record") . ": {$model->name}"; $email['to'] = $this->parseEmailTo($this->decodeQuotes($_POST['email'])); $body = $_POST['body']; // if(empty($email) || !preg_match("/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/",$email)) if ($email['to'] === false) { $errors[] = 'email'; } if (empty($body)) { $errors[] = 'body'; } if (empty($errors)) { $status = $this->sendUserEmail($email, $subject, $body); } if (array_search('200', $status)) { $this->redirect(array('view', 'id' => $model->id)); return; } if ($email['to'] === false) { $email = $_POST['email']; } else { $email = $this->mailingListToString($email['to']); } } $this->render('shareAccount', array('model' => $model, 'body' => $body, 'email' => $email, 'status' => $status, 'errors' => $errors)); }
protected function renderDataCellContent($row, $data) { if (!$data instanceof CommentYii) { return; } $key = $data->id_object . '_' . $data->id_instance; $owner = null; if (isset($this->cache[$key])) { $owner = $this->cache[$key]; } if ($owner || !$owner && ($owner = $data->getOwnerModel())) { $this->cache[$key] = $owner; $method = ''; if (method_exists($owner, 'getCommentsUrl')) { $method = 'getCommentsUrl'; } elseif (method_exists($owner, 'getUrl')) { $method = 'getUrl'; } elseif (method_exists($owner, 'getViewUrl')) { $method = 'getViewUrl'; } if ($method) { Yii::app()->urlManager->frontendMode = true; $link = Yii::app()->createUrl($owner->{$method}()); Yii::app()->urlManager->frontendMode = false; echo CHtml::link('<i class=" glyphicon glyphicon-share"></i> просмотреть на сайте', $link, array('target' => '_blank')); } } }
private static function getTreeItems($modelRow) { if (!$modelRow) { return; } if (isset($modelRow->subcategories)) { $chump = self::getTreeItems($modelRow->subcategories); if ($chump != null) { $res = array('children' => $chump, 'text' => CHtml::link($modelRow->Name, '#', array('id' => $modelRow->id))); } else { $res = array('text' => CHtml::link($modelRow->Name, '#', array('id' => $modelRow->id))); } return $res; } else { if (is_array($modelRow)) { $arr = array(); foreach ($modelRow as $leaves) { $arr[] = self::getTreeItems($leaves); } return $arr; } else { return array('text' => CHtml::link($modelRow->Name, '#', array('id' => $modelRow->id))); } } }
public function actionShareOpportunity($id) { $model = $this->loadModel($id); $body = "\n\n\n\n" . Yii::t('opportunities', 'Opportunity Record Details') . " <br />\n<br />" . Yii::t('opportunities', 'Name') . ": {$model->name}\n<br />" . Yii::t('opportunities', 'Description') . ": {$model->description}\n<br />" . Yii::t('opportunities', 'Quote Amount') . ": {$model->quoteAmount}\n<br />" . Yii::t('opportunities', 'Opportunities Stage') . ": {$model->salesStage}\n<br />" . Yii::t('opportunities', 'Lead Source') . ": {$model->leadSource}\n<br />" . Yii::t('opportunities', 'Probability') . ": {$model->probability}\n<br />" . Yii::t('app', 'Link') . ": " . CHtml::link($model->name, 'http://' . Yii::app()->request->getServerName() . $this->createUrl('/opportunities/' . $model->id)); $body = trim($body); $errors = array(); $status = array(); $email = array(); if (isset($_POST['email'], $_POST['body'])) { $subject = Yii::t('opportunities', 'Opportunity Record Details'); $email['to'] = $this->parseEmailTo($this->decodeQuotes($_POST['email'])); $body = $_POST['body']; // if(empty($email) || !preg_match("/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/",$email)) if ($email['to'] === false) { $errors[] = 'email'; } if (empty($body)) { $errors[] = 'body'; } if (empty($errors)) { $status = $this->sendUserEmail($email, $subject, $body); } if (array_search('200', $status)) { $this->redirect(array('view', 'id' => $model->id)); return; } if ($email['to'] === false) { $email = $_POST['email']; } else { $email = $this->mailingListToString($email['to']); } } $this->render('shareOpportunity', array('model' => $model, 'body' => $body, 'currentWorkflow' => $this->getCurrentWorkflow($model->id, 'opportunities'), 'email' => $email, 'status' => $status, 'errors' => $errors)); }
public function actionAdmin() { $countNewsProduct = NewsProduct::getCountNoShow(); if ($countNewsProduct > 0) { Yii::app()->user->setFlash('info', Yii::t('common', 'There are new product news') . ': ' . CHtml::link(Yii::t('common', '{n} news', $countNewsProduct), array('/news/backend/main/product'))); } $this->rememberPage(); $this->getMaxSorter(); $this->getMinSorter(); $model = new Apartment('search'); $model->resetScope(); $model->unsetAttributes(); // clear any default values if (isset($_GET[$this->modelName])) { $model->attributes = $_GET[$this->modelName]; } $model->setRememberScenario('ads_remember'); $model = $model->with(array('user')); $this->params['paidServicesArray'] = array(); if (issetModule('paidservices')) { $paidServices = PaidServices::model()->findAll('id != ' . PaidServices::ID_ADD_FUNDS); $this->params['paidServicesArray'] = CHtml::listData($paidServices, 'id', 'name'); } $this->render('admin', array_merge(array('model' => $model), $this->params)); }
protected function renderItems($items) { foreach ($items as $i => $item) { if (!is_array($item)) { continue; } if (isset($item['visible']) && $item['visible'] === false) { continue; } if (!isset($item['itemOptions'])) { $item['itemOptions'] = array(); } $classes = array('item'); if ($i === 0) { $classes[] = 'active'; } if (!empty($classes)) { $classes = implode(' ', $classes); if (isset($item['itemOptions']['class'])) { $item['itemOptions']['class'] .= ' ' . $classes; } else { $item['itemOptions']['class'] = $classes; } } echo CHtml::openTag('div', $item['itemOptions']); if (isset($item['image'])) { if (!isset($item['alt'])) { $item['alt'] = ''; } if (!isset($item['imageOptions'])) { $item['imageOptions'] = array(); } $image = CHtml::image($item['image'], $item['alt'], $item['imageOptions']); if (isset($item['link'])) { echo CHtml::link($image, $item['link']); } else { echo $image; } } if (!empty($item['caption']) && (isset($item['label']) || isset($item['caption']))) { if (!isset($item['captionOptions'])) { $item['captionOptions'] = array(); } if (isset($item['captionOptions']['class'])) { $item['captionOptions']['class'] .= ' carousel-caption'; } else { $item['captionOptions']['class'] = 'carousel-caption'; } echo CHtml::openTag('div', $item['captionOptions']); if (isset($item['label'])) { echo '<h4>' . $item['label'] . '</h4>'; } if (isset($item['caption'])) { echo '<p>' . $item['caption'] . '</p>'; } echo '</div>'; } echo '</div>'; } }
protected function createPageButton($label, $page, $class, $hidden, $selected) { if ($hidden || $selected) { $class .= ' ' . ($hidden ? self::CSS_HIDDEN_PAGE : self::CSS_SELECTED_PAGE); } return '<li class="' . $class . '">' . CHtml::link($label, '#', array('onclick' => '$("input[name=page]").val(' . $page . ');SendSearchReg(true);')) . '</li>'; }
public function testHomeLink() { // default home link $widget = $this->makeWidget(); $widget->homeLink = null; $widget->links = array('test'); $this->runWidget($widget); $defaultHomeLink = CHtml::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl); $this->assertAttributeEquals($defaultHomeLink, 'homeLink', $widget); // no home link $widget = $this->makeWidget(); $widget->homeLink = false; $widget->links = array('test'); $content = $this->runWidget($widget); $actualHtml = new DOMDocument(); $actualHtml->loadHTML($content); $expectedHtml = new DOMDocument(); $expectedHtml->loadHTML('<ul class="breadcrumb"><li class="active">test</li></ul>'); $this->assertEquals($expectedHtml, $actualHtml); // home link as plain text $widget = $this->makeWidget(); $widget->homeLink = 'foobar'; $widget->links = array('test'); $content = $this->runWidget($widget); $actualHtml = new DOMDocument(); $actualHtml->loadHTML($content); $expectedHtml = new DOMDocument(); $expectedHtml->loadHTML('<ul class="breadcrumb"><li class="active">foobar</li><li class="active">test</li></ul>'); //echo $expectedHtml->saveHTML()."\n"; //echo $actualHtml->saveHTML(); $this->assertEquals($expectedHtml, $actualHtml); }
public function toHtml() { $this->htmlOptions['class'] .= ' ' . $this->options['level']; $this->htmlOptions['class'] .= ' event-action'; $label = CHtml::encode($this->label); if ($this->options['level'] === 'save') { $this->htmlOptions['class'] .= ' button secondary small'; } if ($this->options['level'] === 'delete') { $content = '<span class="icon-button-small-trash-can"></span>'; $content .= '<span class="hide-offscreen">' . $label . '</span>'; $label = $content; $this->htmlOptions['class'] .= ' button button-icon small'; } if ($this->options['level'] === 'cancel') { $this->htmlOptions['class'] .= ' button small'; } if ($this->options['disabled']) { $this->htmlOptions['class'] .= ' disabled'; $this->htmlOptions['disabled'] = 'disabled'; } if ($this->type == 'button') { return CHtml::htmlButton($label, $this->htmlOptions); } elseif ($this->type == 'link') { return CHtml::link($label, $this->href, $this->htmlOptions); } }
protected function createPageButton($label, $page, $class, $hidden, $selected) { if ($hidden || $selected) { $class .= ' ' . ($hidden ? self::CSS_HIDDEN_PAGE : self::CSS_SELECTED_PAGE); } return '<li class="' . $class . '">' . CHtml::link($label, $this->createPageUrl($page)) . '</li>'; }
/** * 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(); }
public function run() { if (empty($this->links)) { return; } $this->activeLinkTemplate = '<a href="{url}" title="{title}" rel="v:url" property="v:title">{label}</a>'; echo CHtml::openTag($this->tagName, $this->htmlOptions) . "\n"; $links = array(); if ($this->homeLink === null) { $links[] = CHtml::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl); } elseif ($this->homeLink !== false) { $links[] = $this->homeLink; } foreach ($this->links as $label => $url) { if (is_string($label) || is_array($url)) { $links[] = strtr($this->activeLinkTemplate, array('{url}' => CHtml::normalizeUrl($url), '{label}' => $this->encodeLabel ? CHtml::encode($label) : $label, '{title}' => $this->encodeLabel ? CHtml::encode($label) : $label)); } else { $links[] = str_replace('{label}', $this->encodeLabel ? CHtml::encode($url) : $url, $this->inactiveLinkTemplate); } } echo "<div xmlns:v='http://rdf.data-vocabulary.org/#'>"; $i = 0; foreach ($links as $link) { if ($i > 0) { echo ' <i class="icon icon_mt"></i> '; } echo '<span typeof="v:Breadcrumb">' . $link . '</span>'; $i++; } echo "</div>"; //echo implode($this->separator,$links); echo CHtml::closeTag($this->tagName); }
/** * Renders a link button. * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $label = isset($button['label']) ? $button['label'] : $id; $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#'; $options = isset($button['options']) ? $button['options'] : array(); if (!isset($options['title'])) { $options['title'] = $label; } //Forsing btn class if (!isset($options['class'])) { $options['class'] = 'btn'; } else { if (!preg_match('/[^A-z\\-]btn[^A-z\\-]/', $options['class'])) { $options['class'] = 'btn ' . $options['class']; } } if (isset($button['icon'])) { if (strpos($button['icon'], 'icon') === false) { $button['icon'] = 'icon-' . implode(' icon-', explode(' ', $button['icon'])); } echo CHtml::link('<i class="' . $button['icon'] . '"></i>', $url, $options); } else { echo CHtml::link($label, $url, $options); } }
protected function beforeAction($action) { if (parent::beforeAction($action)) { //print_r(Yii::app()->authManager->checkObject('list', Yii::app()->user->id)); $loginPage = $this->getModule() != null && $this->getModule()->getId() == 'user' && $this->getId() == 'user' && $action->getId() == 'login'; if (!Yii::app()->user->checkAccess('showAdminPanel')) { if (!$loginPage) { $errorPage = $this->getModule() == null && $this->getId() == 'static' && $action->getId() == 'error'; $logoutPage = $this->getModule() != null && $this->getModule()->getId() == 'user' && $this->getId() == 'user' && $action->getId() == 'logout'; if (Yii::app()->user->isGuest && !Yii::app()->request->isAjaxRequest && $action->getId() != 'captcha') { Yii::app()->user->setReturnUrl(Yii::app()->request->url); Yii::app()->user->loginRequired(); } else { if (!$errorPage && !$logoutPage) { $link = CHtml::link('авторизоваться заново', Yii::app()->createUrl('logout')); throw new CHttpException(403, '<div style="text-align: center;" class="alert alert-danger col-lg-7">Доступ к странице запрещен, попробуйте ' . $link . '.</div>'); } } } else { if (Yii::app()->user->returnUrl == '/') { Yii::app()->user->returnUrl = Yii::app()->createUrl(''); } } } else { if ($loginPage) { // переходим на главную Yii::app()->getRequest()->redirect(Yii::app()->createUrl('')); } } } return 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); }
/** * Renders a link button. * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $label = isset($button['label']) ? $button['label'] : $id; $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#'; $options = isset($button['options']) ? $button['options'] : array(); if (!isset($options['title'])) { $options['title'] = $label; } if (!isset($options['rel'])) { $options['rel'] = 'tooltip'; } if (isset($button['icon'])) { if (strpos($button['icon'], 'icon') === false) { $button['icon'] = 'icon-' . implode(' icon-', explode(' ', $button['icon'])); } echo CHtml::link('<i class="' . $button['icon'] . '"></i>', $url, $options); } else { if (isset($button['imageUrl']) && is_string($button['imageUrl'])) { echo CHtml::link(CHtml::image($button['imageUrl'], $label), $url, $options); } else { echo CHtml::link($label, $url, $options); } } }
public function run() { if (empty($this->links)) { return; } 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; } } $i = 1; foreach ($this->links as $label => $url) { if (is_string($label) || is_array($url)) { if (count($this->links) == $i) { $links[] = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url, array('class' => $this->lastCssClass)); } else { $links[] = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url); } } else { if (count($this->links) == $i) { $links[] = '<span class="' . $this->lastCssClass . '">' . ($this->encodeLabel ? CHtml::encode($url) : $url) . '</span>'; } else { $links[] = '<span>' . ($this->encodeLabel ? CHtml::encode($url) : $url) . '</span>'; } } $i++; } echo implode($this->separator, $links); echo CHtml::closeTag($this->tagName); }
public function run() { if (empty($this->links)) { return; } echo CHtml::openTag($this->tagName, $this->htmlOptions) . "\n"; $links = array(); echo '<span class="m_left20">当前位置:</span>'; if ($this->homeLink === null) { $links[] = CHtml::link("工作台", 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>'; } } echo implode($this->separator, $links); echo CHtml::closeTag($this->tagName); }
/** * Renders the content of the widget. */ public function run() { $links = array(); if ($this->homeLink === null || !(isset($this->homeLink['label']) && isset($this->homeLink['url']))) { $this->homeLink = array('label' => Yii::t('bootstrap', 'Home'), 'url' => Yii::app()->homeUrl); } if (!empty($this->links)) { $content = CHtml::link($this->homeLink['label'], $this->homeLink['url']); $links[] = $this->renderItem($content); } else { $links[] = $this->renderItem($this->homeLink['label'], true); } foreach ($this->links as $label => $url) { if (is_string($label) || is_array($url)) { $label = $this->encodeLabel ? CHtml::encode($label) : $label; $content = CHtml::link($label, $url); $links[] = $this->renderItem($content); } else { $links[] = $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, true); } } echo CHtml::openTag('ul', $this->htmlOptions); echo implode('', $links); echo '</ul>'; }
/** * ### . * run() * * Renders the content of the widget. */ public function run() { if (empty($this->links)) { return; } echo CHtml::openTag($this->tagName, $this->htmlOptions); if ($this->homeLink === null) { $this->homeLink = CHtml::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl); } if ($this->homeLink !== false) { // check whether home link is not a link $active = stripos($this->homeLink, '<a') === false ? ' class="active"' : ''; echo '<li' . $active . '>' . $this->homeLink . '</li>'; } end($this->links); $lastLink = key($this->links); foreach ($this->links as $label => $url) { if (is_string($label) || is_array($url)) { echo '<li>'; echo strtr($this->activeLinkTemplate, array('{url}' => CHtml::normalizeUrl($url), '{label}' => $this->encodeLabel ? CHtml::encode($label) : $label)); } else { echo '<li class="active">'; echo str_replace('{label}', $this->encodeLabel ? CHtml::encode($url) : $url, $this->inactiveLinkTemplate); } echo '</li>'; } echo CHtml::closeTag($this->tagName); }
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 successMessage() { if (Yii::app()->hasModule($this->moduleID)) { return 'The module has been generated successfully. You may ' . CHtml::link('try it now', Yii::app()->createUrl($this->moduleID), array('target' => '_blank')) . '.'; } $output = <<<EOD <p>The module has been generated successfully.</p> <p>To access the module, you need to modify the application configuration as follows:</p> EOD; $code = <<<EOD <?php return array( 'modules'=>array( '{$this->moduleID}', ), ...... ); EOD; $output2 = <<<EOD <p>You will also need to add entries to the event_type and element_type tables, create tables for each element type, and any additional tables you may require. A migration to do this has been created for you which you can run using:</p> EOD; $code2 = <<<EOD ./yiic migrate --migrationPath=application.modules.{$this->moduleID}.migrations EOD; return $output . highlight_string($code, true) . $output2 . highlight_string($code2, true); }