Exemplo n.º 1
1
 /**
  * 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);
 }
Exemplo n.º 2
0
 public function getImageUrl()
 {
     if (empty($this->owner->{$this->imageField})) {
         return '';
     }
     return CHtml::normalizeUrl('/store/' . $this->storagePath . '/' . $this->owner->{$this->imageField});
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 /**
  * 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;
         }
     }
 }
    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.
    }
Exemplo n.º 6
0
 /**
  * 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);
 }
Exemplo n.º 7
0
 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});");
 }
Exemplo n.º 8
0
 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);
     }
 }
 /**
  * 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;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 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');
 }
Exemplo n.º 12
0
 /**
  * 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()=='[+]')? '[&ndash;]' : '[+]';\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 ? '[&ndash;]' : '[+]', '#', 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);
 }
Exemplo n.º 13
0
 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();
 }
Exemplo n.º 14
0
 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";
 }
Exemplo n.º 15
0
    /**
     * 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);
    }
Exemplo n.º 16
0
 /**
  * Registers necessary client scripts.
  */
 public function registerClientScript()
 {
     $id = $this->getId();
     if ($this->ajaxUpdate === false) {
         $ajaxUpdate = array();
     } else {
         $ajaxUpdate = array_unique(preg_split('/\\s*,\\s*/', $this->ajaxUpdate . ',' . $id, -1, PREG_SPLIT_NO_EMPTY));
     }
     $options = array('ajaxUpdate' => $ajaxUpdate, 'ajaxVar' => $this->ajaxVar, 'pagerClass' => $this->pagerCssClass, 'loadingClass' => $this->loadingCssClass, 'sorterClass' => $this->sorterCssClass, 'enableHistory' => $this->enableHistory);
     if ($this->ajaxUrl !== null) {
         $options['url'] = CHtml::normalizeUrl($this->ajaxUrl);
     }
     if ($this->updateSelector !== null) {
         $options['updateSelector'] = $this->updateSelector;
     }
     foreach (array('beforeAjaxUpdate', 'afterAjaxUpdate', 'ajaxUpdateError') as $event) {
         if ($this->{$event} !== null) {
             if ($this->{$event} instanceof CJavaScriptExpression) {
                 $options[$event] = $this->{$event};
             } else {
                 $options[$event] = new CJavaScriptExpression($this->{$event});
             }
         }
     }
     $options = CJavaScript::encode($options);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('bbq', CClientScript::POS_HEAD);
     $cs->registerScriptFile($this->baseScriptUrl . '/jquery.yiilistview.js', CClientScript::POS_END);
     $cs->registerScript(__CLASS__ . '#' . $id, "\$(document).ready(function() { \$('#{$id}').yiiListView({$options}); });");
 }
Exemplo n.º 17
0
 /**
  * ### .
  * 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);
 }
Exemplo n.º 18
0
 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 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 ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     if ($this->sourceUrl !== null) {
         $this->options['source'] = CHtml::normalizeUrl($this->sourceUrl);
     } else {
         $this->options['source'] = $this->source;
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').autocomplete({$options}){$this->methodChain};";
     $cs = Yii::app()->getClientScript();
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
Exemplo n.º 19
0
 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 '&nbsp;&nbsp;<i class="icon icon_mt"></i>&nbsp;&nbsp;';
         }
         echo '<span typeof="v:Breadcrumb">' . $link . '</span>';
         $i++;
     }
     echo "</div>";
     //echo implode($this->separator,$links);
     echo CHtml::closeTag($this->tagName);
 }
Exemplo n.º 20
0
 /**
  * Initializes menu items
  */
 public function initItems()
 {
     if (!empty($this->items)) {
         $links = array();
         if ($this->homeLabel !== false) {
             $label = $this->homeLabel !== null ? $this->homeLabel : Icon::icon(Enum::ICON_HOME);
             $links[$label] = array('href' => $this->homeUrl !== null ? $this->homeUrl : \Yii::app()->homeUrl);
         }
         foreach ($this->items as $label => $options) {
             if (is_string($label)) {
                 if ($this->encodeLabel) {
                     $label = \CHtml::encode($label);
                 }
                 if (is_string($options)) {
                     $links[$label] = array('href' => \CHtml::normalizeUrl($options));
                 } else {
                     $url = ArrayHelper::removeValue($options, 'url', '');
                     $options['href'] = \CHtml::normalizeUrl($url);
                     $links[$label] = $options;
                 }
             } else {
                 $links[$options] = array('href' => '#');
             }
         }
         $this->items = $links;
     }
 }
Exemplo n.º 21
0
 public function run()
 {
     $links = array();
     $i = 0;
     foreach ($this->items as $label => $href) {
         $links[$i]['label'] = $label;
         if (is_array($href)) {
             $links[$i]['href'] = CHtml::normalizeUrl($href);
             // Check if the current item is the selected one..
             $route = $this->getController()->getRoute();
             // check if href is longer than the route, to see if we have
             // a complete route in href that begins with '/'
             if (strlen($href[0]) > strlen($route)) {
                 $href[0] = trim($href[0], '/');
             }
             // We consider it valid if the href equals to the right part of the route
             // and if the first char of the href is not a '/'. We also check that
             // $href['#'] is not set cause we don't automatically select an anchor
             if (substr($route, -strlen($href[0])) == $href[0] && substr($href[0], 0, 1) != '/' && !isset($href['#'])) {
                 $links[$i]['class'] = 'selected';
             }
         } else {
             $links[$i]['href'] = $href;
         }
         $i++;
     }
     // append the "last" class to last item
     $links[$i - 1]['class'] = (!empty($links[$i - 1]['class']) ? $links[$i - 1]['class'] . ' ' : '') . 'last';
     $this->getWidgetJs();
     $this->render('RightMenu', array('links' => $links));
 }
Exemplo n.º 22
0
 public function init()
 {
     $publishFolder = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets', false, -1, true);
     Yii::app()->clientScript->packages['_fileuploader'] = array('baseUrl' => $publishFolder, 'js' => array('js/vendor/jquery.ui.widget.js', 'js/jquery.iframe-transport.js', 'js/jquery.fileupload.js', 'js/jquery.fileupload-process.js'), 'css' => array('css/jquery.fileupload.css', 'css/jquery.fileupload-ui'), 'depends' => array('jquery', 'glyphicons'));
     Yii::app()->clientScript->registerPackage('_fileuploader');
     $this->render('index', array('controlId' => $this->id . '_uploader', 'uploadName' => $this->hasModel() ? CHtml::activeName($this->model, $this->attribute) : $this->name, 'uploadUrl' => CHtml::normalizeUrl($this->url), 'uploadId' => $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : "{$this->id}_{$this->name}", 'publicUrl' => $publishFolder));
 }
Exemplo n.º 23
0
 /**
  * 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('navbar');
     if (isset($this->type) && in_array($this->type, array(self::TYPE_INVERSE))) {
         $classes[] = 'navbar-' . $this->type;
     }
     if ($this->fixed !== false && in_array($this->fixed, array(self::FIXED_TOP, self::FIXED_BOTTOM))) {
         $classes[] = 'navbar-fixed-' . $this->fixed;
     }
     if (!empty($classes)) {
         $classes = implode(' ', $classes);
         if (isset($this->htmlOptions['class'])) {
             $this->htmlOptions['class'] .= ' ' . $classes;
         } else {
             $this->htmlOptions['class'] = $classes;
         }
     }
 }
Exemplo n.º 24
0
 public function run()
 {
     if (empty($this->template)) {
         return;
     }
     $url = trim(Yii::app()->request->url, '/');
     $items = MenuItem::model()->onSite()->byParent(0)->byMenuId($this->menuId)->orderDefault()->findAll();
     $itemsArr = array();
     foreach ($items as $item) {
         // Убираем язык из урла
         $domains = explode('/', ltrim($url, '/'));
         if (in_array($domains[0], array_keys(Yii::app()->params['languages']))) {
             array_shift($domains);
             $url = implode('/', $domains);
         }
         $select = strpos($url, trim($item->link, '/')) === 0 ? true : false;
         $blank = 0;
         if (strpos($item->link, 'http://') === 0 || strpos($item->link, 'https://') === 0) {
             $link = $item->link;
             $blank = 1;
         } else {
             $link = isset(Yii::app()->params['routes'][$item->link]) ? array('/' . Yii::app()->params['routes'][$item->link]) : '/' . $item->link;
             // Ссылка без языка, будет вести на дефолтную страницу
             $link = CHtml::normalizeUrl($link);
         }
         $iconUrl = $item->getIconUrl();
         $itemsArr[] = array('name' => $item->name, 'link' => $link, 'select' => $select, 'iconUrl' => $iconUrl, 'blank' => $blank, 'enabled' => $item->active);
     }
     $this->beforeRender($itemsArr);
     $this->render($this->template, array('items' => $itemsArr));
 }
Exemplo n.º 25
0
 protected function urlLink($url)
 {
     if (is_array($url)) {
         return CHtml::normalizeUrl($url);
     } else {
         return $url;
     }
 }
Exemplo n.º 26
0
 /**
  * Widget's initialization method
  * @throws \CException
  */
 public function init()
 {
     parent::init();
     if ($this->route === null) {
         throw new \CException(\Yii::t('wheels', '"route" attribute cannot be blank'));
     }
     $this->options['data-url'] = \CHtml::normalizeUrl($this->route);
 }
 /**
  * Registers the parsley html attributes.
  * @param CModel $object the data object being validated.
  * @param string $attribute the name of the attribute to be validated.
  * @param array $htmlOptions the HTML attributes.
  */
 public function registerClientValidation($object, $attribute, &$htmlOptions)
 {
     $htmlOptions['data-remote'] = CHtml::normalizeUrl($this->url);
     $htmlOptions['data-remote-method'] = strtoupper($this->method);
     if ($this->jsonp) {
         $htmlOptions['data-remote-datatype'] = 'jsonp';
     }
 }
 public function run()
 {
     $this->debug = true;
     if ($this->id == null) {
         $this->id = 'eyuiajaxaction0';
     }
     $defaultCssStyle = 'cursor: pointer; color: blue; text-decoration: underline;';
     $loading = $this->getResource("loading.gif");
     $htoptions = "";
     if (isset($this->htmlOptions) && is_array($this->htmlOptions)) {
         if (!isset($this->htmlOptions['style'])) {
             $this->htmlOptions['style'] = $defaultCssStyle;
         }
     } else {
         $this->htmlOptions['style'] = $defaultCssStyle;
     }
     foreach ($this->htmlOptions as $key => $val) {
         $htoptions .= " " . $key . "='" . $val . "' ";
     }
     if (is_array($this->action)) {
         $action = CHtml::normalizeUrl($this->action);
     } else {
         $action = $this->action;
     }
     if ($this->onSuccess == null) {
         $this->onSuccess = 'function(val,text){ }';
     }
     if ($this->onError == null) {
         $this->onError = 'function(e){ }';
     }
     if ($this->onBeforeAjaxCall == null) {
         $this->onBeforeAjaxCall = 'function(){ }';
     }
     if (!$this->onSuccess instanceof CJavaScriptExpression) {
         $this->onSuccess = new CJavaScriptExpression($this->onSuccess);
     }
     if (!$this->onError instanceof CJavaScriptExpression) {
         $this->onError = new CJavaScriptExpression($this->onError);
     }
     if (!$this->onBeforeAjaxCall instanceof CJavaScriptExpression) {
         $this->onBeforeAjaxCall = new CJavaScriptExpression($this->onBeforeAjaxCall);
     }
     if (!isset($this->ajaxoptions['url'])) {
         $this->ajaxoptions['url'] = CHtml::normalizeUrl($this->action);
     }
     if (!isset($this->ajaxoptions['success'])) {
         $this->ajaxoptions['success'] = new CJavaScriptExpression("function(data){ ({$this->onSuccess})(data); clearBusy(); }");
     }
     if (!isset($this->ajaxoptions['error'])) {
         $this->ajaxoptions['error'] = new CJavaScriptExpression("function(e){ ({$this->onError})(e); clearBusy(); }");
     }
     $ajxOptions = CJavaScript::encode($this->ajaxoptions);
     $options = CJavaScript::encode(array('onBeforeAjaxCall' => $this->onBeforeAjaxCall));
     $layout = "\n\t<div id='{$this->id}' {$htoptions}><span>{$this->label}</span><img src='{$loading}' style='display: none;'></div>\n\t\n";
     echo $layout;
     Yii::app()->getClientScript()->registerScript("script_{$this->id}", "\n\$('#{$this->id}').click(function(){\n\tvar options = {$options};\n\tvar img = \$(this).find('img');\n\tvar label = \$(this).find('span');\n\tlabel.html('{$this->labelOn}');\n\tvar obj = \$(this);\n\tif(obj.data('busy')==true)\n\t\treturn;\n\t// mark the components in its busy state\n\timg.show();\n\tobj.data('busy',true);\n\tobj.addClass('eyuiajaxaction-busy');\n\tvar clearBusy = function(){\n\t\tlabel.html('{$this->label}');\n\t\tobj.removeClass('eyuiajaxaction-busy');\n\t\tobj.data('busy',false);\n\t\timg.hide();\n\t}\n\toptions.onBeforeAjaxCall();\n\t\$.ajax({$ajxOptions});\n});\n", CClientScript::POS_END);
 }
 protected function renderDataCellContent($row, $data)
 {
     $value = CHtml::value($data, $this->name);
     $this->callbackUrl['pk'] = $data->primaryKey;
     $this->callbackUrl['name'] = urlencode($this->name);
     $this->callbackUrl['value'] = (int) empty($value);
     $link = CHtml::normalizeUrl($this->callbackUrl);
     echo CHtml::link(!empty($value) ? 'Y' : 'N', $link, array('class' => $this->_flagClass));
 }
Exemplo n.º 30
0
 public function init()
 {
     $this->assets = Yii::app()->assetManager->publish(Yii::getPathOfAlias('autocatalog.extensions.catalog.assets'), false, -1, true);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerScriptFile($this->assets . '/catalog.js');
     $default = array('urlCatalog' => CHtml::normalizeUrl(array('default/ajaxCatalog')), 'urlBrand' => CHtml::normalizeUrl(array('default/ajaxBrand')), 'urlModel' => CHtml::normalizeUrl(array('default/ajaxModel')), 'allowEmpty' => false);
     $this->options = array_merge($default, $this->options);
 }