本文整理匯總了PHP中CHtml::link方法的典型用法代碼示例。如果您正苦於以下問題:PHP CHtml::link方法的具體用法?PHP CHtml::link怎麽用?PHP CHtml::link使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CHtml
的用法示例。
在下文中一共展示了CHtml::link方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderButton
/**
* 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);
}
}
}
示例2: run
/**
* 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));
}
示例3: actionCreate
/**
* 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));
}
}
}
}
示例4: init
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
}
示例5: run
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);
}
示例6: run
/**
* 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>';
}
示例7: run
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);
}
}
示例8: run
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();
}
示例9: actionShareAccount
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));
}
示例10: renderDataCellContent
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'));
}
}
}
示例11: getTreeItems
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)));
}
}
}
示例12: actionShareOpportunity
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));
}
示例13: actionAdmin
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));
}
示例14: renderItems
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>';
}
}
示例15: createPageButton
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>';
}