本文整理汇总了PHP中CHtml::normalizeUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::normalizeUrl方法的具体用法?PHP CHtml::normalizeUrl怎么用?PHP CHtml::normalizeUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::normalizeUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRightsReturnUrl
/**
* Returns the URL that the user should be redirected to
* after updating an authorization item.
* @param string $defaultUrl the default return URL in case it was not set previously. If this is null,
* the application entry URL will be considered as the default return URL.
* @return string the URL that the user should be redirected to
* after updating an authorization item.
*/
public function getRightsReturnUrl($defaultUrl = null)
{
if (($returnUrl = $this->getState('Rights_returnUrl')) !== null) {
$this->returnUrl = null;
}
return $returnUrl !== null ? CHtml::normalizeUrl($returnUrl) : CHtml::normalizeUrl($defaultUrl);
}
示例2: getImageUrl
public function getImageUrl()
{
if (empty($this->owner->{$this->imageField})) {
return '';
}
return CHtml::normalizeUrl('/store/' . $this->storagePath . '/' . $this->owner->{$this->imageField});
}
示例3: run
public function run()
{
if (empty($this->links)) {
return;
}
$this->activeLinkTemplate = '<a href="{url}" itemprop="url"><span title="{label}" itemprop="title">{label}</span></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 '<ul data-tracking-cat="breadcrumbs">';
$i = 0;
foreach ($links as $link) {
if ($i > 0) {
echo '<li class="separ"><span class="br-arr"></span></li>';
}
echo '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
' . $link . '
</li>';
$i++;
}
echo "</ul>";
//echo implode($this->separator,$links);
echo CHtml::closeTag($this->tagName);
}
示例4: init
/**
* Initializes the widget.
*/
public function init()
{
if ($this->brand !== false) {
if (!isset($this->brand)) {
$this->brand = CHtml::encode(Yii::app()->name);
}
if (!isset($this->brandUrl)) {
$this->brandUrl = Yii::app()->homeUrl;
}
$this->brandOptions['href'] = CHtml::normalizeUrl($this->brandUrl);
if (isset($this->brandOptions['class'])) {
$this->brandOptions['class'] .= ' brand';
} else {
$this->brandOptions['class'] = 'brand';
}
}
$classes = array('navbox');
if (isset($this->type) && in_array($this->type, array(self::TYPE_INVERSE))) {
$classes[] = 'navbox-' . $this->type;
}
if ($this->width !== false) {
$this->htmlOptions['style'] = "width:{$this->width}px";
}
if (!empty($classes)) {
$classes = implode(' ', $classes);
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' ' . $classes;
} else {
$this->htmlOptions['class'] = $classes;
}
}
}
示例5: run
public function run()
{
// este metodo sera ejecutado cuando el widget se inserta
// preparamos los assets.
// lo que se hace simplemente es obtener una entrada en el directorio
// de /tuapp/assets/ (ese directorio te lo da yii con el codigo que
// veras dentro del metodo _prepararassets).
// luego, copiamos a ese directorio todos nuestros scrips o css
$this->_prepararAssets();
// renderizamos el contenido que el widget va a darnos
//
?>
<!--<div style="background-color: #000066"></div>--> <?php
// toda la funcionalidad de JAVASCRIPT, CSS ha sido
// manejada dentro de componentes que estan en assets/
// por tanto el widget se limita a crear la estructura
// para usar todo eso junto y consistente.
echo "<div style='background-color: #6FACCF; width:400px; id={$this->id} class='demowidget'>\n\t \n </div>";
// preparamos algunas opciones para pasarselas al
// objeto javascript llamado DemoWidget que crearemos
// mas abajo.
$options = CJavaScript::encode(array('action' => CHtml::normalizeUrl($this->action), 'id' => $this->id, 'onSuccess' => new CJavaScriptExpression($this->onSuccess), 'onError' => new CJavaScriptExpression($this->onError), 'botonokclassname' => 'botonok'));
// insertamos el objeto Javascript DemoWidget, el cual reside
// en un archivo JS externo (en los assets).
// le pasamos las opciones a su constructor con el objeto de
// comunicar las dos piezas.
Yii::app()->getClientScript()->registerScript("demowidget_corescript", "new DemoWidget({$options})");
// nada mas es requerido.
}
示例6: init
/**
* Initializes the column.
*
* @see CDataColumn::init()
*/
public function init()
{
parent::init();
if (!isset($this->selectBoxHtmlOptions['class'])) {
$this->selectBoxHtmlOptions['class'] = 'selectColumn-' . $this->id;
}
$cs = Yii::app()->getClientScript();
$gridId = $this->grid->getId();
$script = '
jQuery(".' . $this->selectBoxHtmlOptions['class'] . '").live("change", function(e){
e.preventDefault();
$.ajax({
type: "POST",
dataType: "json",
cache: false,
url: "' . (is_array($this->actionUrl) ? CHtml::normalizeUrl($this->actionUrl) : $this->actionUrl) . '",
data: {
item: $(this).attr("itemId"),
value:$("option:selected",this).val()
},
success: function(data){
$("#' . $gridId . '").yiiGridView.update("' . $gridId . '");
}
});
});';
$cs->registerScript(__CLASS__ . $gridId . '#active_column-' . $this->id, $script);
}
示例7: run
public function run()
{
$id = $this->getId();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
echo CHtml::openTag($this->tagName, $this->htmlOptions) . "\n";
$tabsOut = "";
$contentOut = "";
$tabCount = 0;
foreach ($this->tabs as $title => $content) {
$tabId = is_array($content) && isset($content['id']) ? $content['id'] : $id . '_tab_' . $tabCount++;
if (!is_array($content)) {
$tabsOut .= strtr($this->headerTemplate, array('{title}' => $title, '{url}' => '#' . $tabId, '{id}' => '#' . $tabId)) . "\n";
$contentOut .= strtr($this->contentTemplate, array('{content}' => $content, '{id}' => $tabId)) . "\n";
} elseif (isset($content['ajax'])) {
$tabsOut .= strtr($this->headerTemplate, array('{title}' => $title, '{url}' => CHtml::normalizeUrl($content['ajax']), '{id}' => '#' . $tabId)) . "\n";
} else {
$tabsOut .= strtr($this->headerTemplate, array('{title}' => $title, '{url}' => '#' . $tabId, '{id}' => $tabId)) . "\n";
if (isset($content['content'])) {
$contentOut .= strtr($this->contentTemplate, array('{content}' => $content['content'], '{id}' => $tabId)) . "\n";
}
}
}
echo "<ul class='" . $this->ulClass . "'>\n" . $tabsOut . "</ul>\n";
echo $contentOut;
echo CHtml::closeTag($this->tagName) . "\n";
$options = CJavaScript::encode($this->options);
Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').tabs({$options});");
}
示例8: init
public function init()
{
$dir = dirname(__FILE__) . '/vendors/tinymce';
$this->assetsDir = Yii::app()->assetManager->publish($dir);
$this->settings = array_merge(self::$defaultSettings, $this->settings);
if ($this->language === false) {
$this->settings['language'] = Yii::app()->language;
} else {
$this->settings['language'] = $this->language;
}
if (!in_array($this->settings['language'], self::$languages)) {
$lang = false;
foreach (self::$languages as $i) {
if (strpos($this->settings['language'], $i)) {
$lang = $i;
}
}
if ($lang !== false) {
$this->settings['language'] = $lang;
} else {
$this->settings['language'] = 'en';
}
}
$this->settings['language'] = strtr($this->settings['language'], '_', '-');
if ($this->spellcheckerUrl !== false) {
$this->settings['plugins'][] = 'spellchecker';
$this->settings['spellchecker_rpc_url'] = CHtml::normalizeUrl($this->spellcheckerUrl);
}
}
示例9: __construct
/**
* constructor with arguments
*/
public function __construct($orderId, $userId)
{
parent::__construct();
$this->orderId = $orderId;
$this->encryptedOrderId = Yii::app()->getSecurityManager()->hashData($orderId);
$selectedOrders = null;
//if order id belongs to current user and is in 'order_start' status
//(other status mean order has already crossed the checkout process once)
//as order id's input has been added to checkout action to facilitate the
//order resumption. Note: As order is being modified or created in this function
//do check before any POST or GET if order can be modified. Order can be modified
//only and only if it is in 'order-start' status.
$selectedOrders = AOrder::model()->findAll(array('order' => 'id', 'condition' => 'is_deleted = "no" AND ordered_by2user_details = ' . $userId . ' AND order_unique_id = "' . $orderId . '" ' . ' AND status = "order_start" '));
if (!isset($selectedOrders) || count($selectedOrders) < 1) {
$this->render('cart_error', array('errorMessage' => "Either this page does not exists or has expired or you are not allowed to view this page.", 'link' => CHtml::normalizeUrl(array('cart/checkout'))));
Yii::app()->end();
}
$this->totalItemsInOrder = 0;
foreach ($selectedOrders as $row) {
$this->tiffinPriceTimeSelectionArr[] = new TiffinPriceTimeSelectionForm($row, $this->encryptedOrderId);
$this->destinationLocality = $row->destination_locality;
$this->totalItemsInOrder = $this->totalItemsInOrder + $row->num_of_units;
}
$this->totalAmountInWallet = AppCommonWallet::getTotalAmountInWalletForUser($userId);
$this->amountUsedFromWallet = 0;
$this->userId = $userId;
}
示例10: getURL
public function getURL($actions, $args = array(), $relative = true)
{
$theArg = array($actions, 'rec_name' => $this->actionParams['rec_name']);
//if ($this->isWizard) $theArg['wiz'] = 1;
$url = CHtml::normalizeUrl(array_merge($theArg, $args));
return $relative ? $url : O::app()->getRequest()->getHostInfo() . $url;
}
示例11: init
public function init()
{
$assetManager = Yii::app()->assetManager;
// set default language
if (!$this->defaultLanguage) {
$this->defaultLanguage = Yii::app()->language;
}
// normalize missingTranslation url
if ($this->onMissingTranslation) {
$this->onMissingTranslation = CHtml::normalizeUrl($this->onMissingTranslation);
}
// create arrays from params
if (!is_array($this->categories)) {
$this->categories = array($this->categories);
}
if (!is_array($this->languages)) {
$this->languages = array($this->languages);
}
// set paths
$this->_assetsPath = dirname(__FILE__) . '/assets';
$this->_publishPath = $assetManager->getPublishedPath($this->_assetsPath);
$this->_publishUrl = $assetManager->getPublishedUrl($this->_assetsPath);
// create hash
$hash = substr(md5(implode($this->categories) . ':' . implode($this->languages)), 0, 10);
$dictionaryFile = "JsTrans.dictionary.{$hash}.js";
// publish assets and generate dictionary file if neccessary
if (!file_exists($this->_publishPath) || YII_DEBUG) {
// publish and get new url and path
$assetsManager = Yii::app()->getAssetManager();
$forceCopy = empty($assetsManager) || !$assetsManager->linkAssets ? true : false;
$this->_publishUrl = $assetManager->publish($this->_assetsPath, false, -1, $forceCopy);
$this->_publishPath = $assetManager->getPublishedPath($this->_assetsPath);
// declare config (passed to JS)
$config = array('language' => $this->defaultLanguage, 'onMissingTranslation' => $this->onMissingTranslation);
// getting protected loadMessages method using Reflection to call it from outside
$messages = Yii::app()->messages;
$loadMessages = new ReflectionMethod(get_class($messages), 'loadMessages');
$loadMessages->setAccessible(true);
// loop message files and store translations in array
$dictionary = array();
foreach ($this->languages as $lang) {
if (!isset($dictionary[$lang])) {
$dictionary[$lang] = array();
}
foreach ($this->categories as $cat) {
$dictionary[$lang][$cat] = $loadMessages->invoke($messages, $cat, $lang);
}
}
// JSONify config/dictionary
$data = 'Yii.translate.config=' . CJSON::encode($config) . ';' . 'Yii.translate.dictionary=' . CJSON::encode($dictionary);
// save to dictionary file
if (!file_put_contents($this->_publishPath . '/' . $dictionaryFile, $data)) {
Yii::log('Error: Could not write dictionary file', 'trace', 'jstrans');
return null;
}
}
$jsTransFile = YII_DEBUG ? 'JsTrans.min.js' : 'JsTrans.js';
Yii::app()->getClientScript()->addPackage('JsTrans', ['baseUrl' => $this->_publishUrl, 'js' => [$jsTransFile, $dictionaryFile]]);
Yii::app()->getClientScript()->registerPackage('JsTrans');
}
示例12: run
/**
* Run this widget.
* This method registers necessary javascript and renders the needed HTML code.
*/
public function run()
{
$themeURL = Yii::app()->theme->getBaseUrl();
Yii::app()->clientScript->registerScript('logos', "\n\t\t\$(window).load(function(){\n\t\t\tif((!\$('#main-menu-icon').length) || (!\$('#x2touch-logo').length) || (!\$('#x2crm-logo').length)){\n\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\talert('Please put the logo back');\n\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t}\n\t\t\tvar touchlogosrc = \$('#x2touch-logo').attr('src');\n\t\t\tvar logosrc=\$('#x2crm-logo').attr('src');\n\t\t\tif(logosrc!='{$themeURL}/images/x2footer.png'|| touchlogosrc!='{$themeURL}/images/x2touch.png'){\n\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\talert('Please put the logo back');\n\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t}\n\t\t}); \n\t\t");
Yii::app()->clientScript->registerScript('toggleWidgetState', "\n\t\t\tfunction toggleWidgetState(widget,state) {\n\t\t\t\t\$.ajax({\n\t\t\t\t\turl: '" . CHtml::normalizeUrl(array('/site/widgetState')) . "',\n\t\t\t\t\ttype: 'GET',\n\t\t\t\t\tdata: 'widget='+widget+'&state='+state,\n\t\t\t\t\tsuccess: function(response) {\n\t\t\t\t\t\tif(response=='success') {\n\t\t\t\t\t\t\tvar link = \$('#widget_'+widget+' .portlet-minimize a');\n\t\t\t\t\t\t\tvar newLink = (link.html()=='[+]')? '[–]' : '[+]';\t\t\t// toggle link between [+] and [-]\n\t\t\t\t\t\t\tlink.html(newLink);\n\t\t\t\t\t\t\t\$('#widget_'+widget+' .portlet-content').toggle('blind',{},200);\t// slide widget open or closed\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t", CClientScript::POS_HEAD);
$id = $this->getId();
//get generated id
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
$options = empty($this->jQueryOptions) ? '' : CJavaScript::encode($this->jQueryOptions);
Yii::app()->getClientScript()->registerScript('SortableWidgets' . '#' . $id, "jQuery('#{$id}').sortable({$options});");
echo CHtml::openTag($this->tagName, $this->htmlOptions) . "\n";
$hideWidgetJs = '';
foreach ($this->portlets as $class => $properties) {
$visible = $properties['visibility'] == '1';
if (!$visible) {
$hideWidgetJs .= "\$('#widget_" . $class . " .portlet-content').hide();\n";
}
$minimizeLink = CHtml::link($visible ? '[–]' : '[+]', '#', array('onclick' => "toggleWidgetState('{$class}'," . ($visible ? 0 : 1) . "); return false;"));
// $t0 = microtime(true);
$this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('app', Yii::app()->params->registeredWidgets[$class]) . '<div class="portlet-minimize">' . $minimizeLink . '</div>', 'id' => $properties['id']));
$this->widget($class);
$this->endWidget();
// echo (round(microtime(true)-$t0,3)*1000).'ms';
}
Yii::app()->clientScript->registerScript('setWidgetState', "\n\t\t\t\$(document).ready(function() {\n\t\t\t\t" . $hideWidgetJs . "\n\t\t\t});", CClientScript::POS_HEAD);
echo CHtml::closeTag($this->tagName);
}
示例13: init
public function init()
{
$quotesAssetsUrl = $this->module->assetsUrl;
if (isset($_POST)) {
$startHidden = false;
}
if ($this->startHidden) {
if ($this->startHidden) {
Yii::app()->clientScript->registerScript('startQuotesHidden', "\$('#quotes-form').hide();", CClientScript::POS_READY);
}
// Set up the new create form:
Yii::app()->clientScript->registerScriptFile($quotesAssetsUrl . '/js/inlineQuotes.js', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($quotesAssetsUrl . '/js/LineItems.js', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFiles('InlineQuotesCss', array($quotesAssetsUrl . '/css/inlineQuotes.css', $quotesAssetsUrl . '/css/lineItemsMain.css', $quotesAssetsUrl . '/css/lineItemsWrite.css'), false);
Yii::app()->clientScript->registerCoreScript('jquery.ui');
$this->contact = X2Model::model('Contacts')->findByPk($this->contactId);
//$this->contact = Contacts::model()->findByPk($this->contactId);
$iqConfig = array('contact' => $this->contact instanceof Contacts ? CHtml::encode($this->contact->name) : '', 'account' => $this->account, 'sendingQuote' => false, 'lockedMessage' => Yii::t('quotes', 'This quote is locked. Are you sure you want to update this quote?'), 'deniedMessage' => Yii::t('quotes', 'This quote is locked.'), 'lockedDialogTitle' => Yii::t('quotes', 'Locked'), 'failMessage' => Yii::t('quotes', 'Could not save quote.'), 'reloadAction' => CHtml::normalizeUrl(array('/quotes/quotes/viewInline', 'recordId' => $this->recordId, 'recordType' => CHtml::encode($this->modelName))), 'createAction' => CHtml::normalizeUrl(array('/quotes/quotes/create', 'quick' => 1, 'recordId' => $this->recordId, 'recordType' => $this->modelName)), 'updateAction' => CHtml::normalizeUrl(array('/quotes/quotes/update', 'quick' => 1)));
Yii::app()->clientScript->registerScript('quickquote-vars', '
;(function () {
if(typeof x2 == "undefined"){
x2 = {};
}
var iqConfig = ' . CJSON::encode($iqConfig) . ';
if(typeof x2.inlineQuotes=="undefined") {
x2.inlineQuotes = iqConfig;
} else {
$.extend(x2.inlineQuotes,iqConfig);
}
}) ();', CClientScript::POS_HEAD);
}
parent::init();
}
示例14: init
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";
}
示例15: init
/**
* Initializes the column.
*
* @see CDataColumn::init()
*/
public function init()
{
parent::init();
if (!isset($this->htmlCheckBoxOptions['class'])) {
$this->htmlCheckBoxOptions['class'] = 'checkBoxColumn-' . $this->id;
}
$cs = Yii::app()->getClientScript();
$gridId = $this->grid->getId();
$script = '
jQuery(".' . $this->htmlCheckBoxOptions['class'] . '").live("click", function(e){
$.ajax({
type: "POST",
dataType: "json",
cache: false,
url: "' . (is_array($this->actionUrl) ? CHtml::normalizeUrl($this->actionUrl) : $this->actionUrl) . '",
data: {
attr: "' . $this->name . '",
model: "' . get_class($this->grid->filter) . '",
item: $(this).attr("itemid"),
checked: $(this).attr("checked")?1:0
},
success: function(data){
//alert();
$("#' . $gridId . '").yiiGridView.update("' . $gridId . '");
}
});
});';
$cs->registerScript(__CLASS__ . $gridId . '#active_column-' . $this->id, $script);
}