Example #1
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id;
     if (is_string($this->keys)) {
         $this->keys = array($this->keys);
     }
     echo CHtml::openTag('div', $this->htmlOptions);
     foreach ($this->keys as $key) {
         if (Yii::app()->user->hasFlash($key)) {
             echo strtr($this->template, array('{class}' => ' fade in', '{key}' => $key, '{message}' => Yii::app()->user->getFlash($key)));
         }
     }
     echo '</div>';
     /** @var CClientScript $cs */
     $cs = Yii::app()->getClientScript();
     $selector = "#{$id} .alert";
     $cs->registerScript(__CLASS__ . '#' . $id, "jQuery('{$selector}').alert();");
     // Register the "close" event-handler.
     if (isset($this->events['close'])) {
         $fn = CJavaScript::encode($this->events['close']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.close', "jQuery('{$selector}').bind('close', {$fn});");
     }
     // Register the "closed" event-handler.
     if (isset($this->events['closed'])) {
         $fn = CJavaScript::encode($this->events['closed']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.closed', "jQuery('{$selector}').bind('closed', {$fn});");
     }
 }
Example #2
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id;
     echo CHtml::openTag('div', $this->htmlOptions);
     echo '<div class="carousel-inner">';
     $this->renderItems($this->items);
     echo '</div>';
     echo '<a class="carousel-control left" href="#' . $id . '" data-slide="prev">' . $this->prev . '</a>';
     echo '<a class="carousel-control right" href="#' . $id . '" data-slide="next">' . $this->next . '</a>';
     echo '</div>';
     /** @var CClientScript $cs */
     $cs = Yii::app()->getClientScript();
     $options = !empty($this->options) ? CJavaScript::encode($this->options) : '';
     $cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').carousel({$options});");
     // Register the "slide" event-handler.
     if (isset($this->events['slide'])) {
         $fn = CJavaScript::encode($this->events['slide']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.slide', "jQuery('#{$id}').on('slide', {$fn});");
     }
     // Register the "slid" event-handler.
     if (isset($this->events['slid'])) {
         $fn = CJavaScript::encode($this->events['slid']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.slid', "jQuery('#{$id}').on('slid', {$fn});");
     }
 }
Example #3
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id;
     echo '</div>';
     /** @var CClientScript $cs */
     $cs = Yii::app()->getClientScript();
     $options = CJavaScript::encode($this->options);
     $cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').modal({$options});");
     // Register the "show" event-handler.
     if (isset($this->events['show'])) {
         $fn = CJavaScript::encode($this->events['show']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.show', "jQuery('#{$id}').on('show', {$fn});");
     }
     // Register the "shown" event-handler.
     if (isset($this->events['shown'])) {
         $fn = CJavaScript::encode($this->events['shown']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.shown', "jQuery('#{$id}').on('shown', {$fn});");
     }
     // Register the "hide" event-handler.
     if (isset($this->events['hide'])) {
         $fn = CJavaScript::encode($this->events['hide']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.hide', "jQuery('#{$id}').on('hide', {$fn});");
     }
     // Register the "hidden" event-handler.
     if (isset($this->events['hidden'])) {
         $fn = CJavaScript::encode($this->events['hidden']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.hidden', "jQuery('#{$id}').on('hidden', {$fn});");
     }
 }
 /**
  * Generates the required HTML and Javascript
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     $model = $this->model;
     if ($this->uploadTemplate === null) {
         $this->uploadTemplate = "#template-upload";
         $this->render("upload");
     }
     if ($this->downloadTemplate === null) {
         $this->downloadTemplate = "#template-download";
         $this->render("download");
     }
     if (!isset($this->htmlOptions['enctype'])) {
         $this->htmlOptions['enctype'] = 'multipart/form-data';
     }
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = get_class($model) . "-form";
     }
     $options = CJavaScript::encode($this->options);
     Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->htmlOptions['id'], "jQuery('#{$this->htmlOptions['id']}').fileupload({$options});", CClientScript::POS_READY);
     $htmlOptions = array();
     if ($this->multiple) {
         $htmlOptions["multiple"] = true;
         /* if($this->hasModel()){
                $this -> attribute = "[]" . $this -> attribute;
            }else{
                $this -> attribute = "[]" . $this -> name;
            }*/
     }
     $this->render("form", compact('htmlOptions'));
 }
Example #5
0
 public function run()
 {
     if (empty($this->config['action'])) {
         throw new CException('EAjaxUpload: param "action" cannot be empty.');
     }
     if (empty($this->config['allowedExtensions'])) {
         throw new CException('EAjaxUpload: param "allowedExtensions" cannot be empty.');
     }
     if (empty($this->config['sizeLimit'])) {
         throw new CException('EAjaxUpload: param "sizeLimit" cannot be empty.');
     }
     unset($this->config['element']);
     echo '<div id="' . $this->id . '"><noscript><p>Habilite Jva Script en este navegador para usar esta funcion .</p></noscript></div>';
     $assets = dirname(__FILE__) . '/assets';
     $baseUrl = Yii::app()->assetManager->publish($assets);
     Yii::app()->clientScript->registerScriptFile($baseUrl . '/fileuploader.js', CClientScript::POS_HEAD);
     $this->css = !empty($this->css) ? $this->css : $baseUrl . '/fileuploader.css';
     Yii::app()->clientScript->registerCssFile($this->css);
     $postParams = array('PHPSESSID' => session_id(), 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken);
     if (isset($this->postParams)) {
         $postParams = array_merge($postParams, $this->postParams);
     }
     $config = array('element' => 'js:document.getElementById("' . $this->id . '")', 'debug' => false, 'multiple' => false);
     $config = array_merge($config, $this->config);
     $config['params'] = $postParams;
     $config = CJavaScript::encode($config);
     Yii::app()->getClientScript()->registerScript("FileUploader_" . $this->id, "var FileUploader_" . $this->id . " = new qq.FileUploader({$config}); ", CClientScript::POS_LOAD);
 }
Example #6
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}); });");
 }
Example #7
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";
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionAdditem($item_id)
 {
     $user_id = Yii::app()->user->id;
     // find the users cart
     $user = User::model()->find(array('condition' => 'id=:user_id', 'params' => array(':user_id' => $user_id)));
     // find the users cart
     $cart = Cart::model()->find(array('condition' => 'cart_owner=:cart_owner', 'params' => array(':cart_owner' => $user_id)));
     // find the item being reffered to by item_id
     $item = Item::model()->find(array('condition' => 'id=:item_id', 'params' => array(':item_id' => $item_id)));
     if (is_null($cart)) {
         // if the cart is not found. create a cart for the user.
         $cart = new Cart();
         $cart->cart_owner = $user->id;
         $cart->save();
     }
     // check if the same order was already made & increment else, create new
     $order = Order::model()->find(array('condition' => 'item_id=:item_id AND cart_id=:cart_id AND order_by=:order_by', 'params' => array(':item_id' => $item_id, ':cart_id' => $cart->id, ':order_by' => $user->id)));
     if (is_null($order)) {
         $order = new Order();
         $order->create_time = time();
         $order->quantity = 1;
         $order->item_id = $item->id;
         $order->cart_id = $cart->id;
         $order->order_by = $user->id;
     } else {
         $order->quantity = 1 + $order->quantity;
         $order->update_time = time();
     }
     $order->save();
     // find all orders by this user.
     $orders = Order::model()->findAll('cart_id=:cart_id AND order_by=:order_by', array(':cart_id' => $cart->id, ':order_by' => $user->id));
     $return = array('success' => true, 'data' => $orders);
     echo CJavaScript::jsonEncode($return);
     Yii::app()->end();
 }
 /**
  * @param $model - profile model
  * @param $field - profile fields model item
  * @param $params - htmlOptions
  * @return string
  */
 public function editAttribute($model, $field, $htmlOptions = array())
 {
     if (!isset($htmlOptions['size'])) {
         $htmlOptions['size'] = 60;
     }
     if (!isset($htmlOptions['maxlength'])) {
         $htmlOptions['maxlength'] = $field->field_size ? $field->field_size : 10;
     }
     if (!isset($htmlOptions['id'])) {
         $htmlOptions['id'] = get_class($model) . '_' . $field->varname;
     }
     $id = $htmlOptions['id'];
     $options['dateFormat'] = 'yy-mm-dd';
     $options = CJavaScript::encode($options);
     $basePath = Yii::getPathOfAlias('admin.views.asset');
     $baseUrl = Yii::app()->getAssetManager()->publish($basePath);
     $cs = Yii::app()->getClientScript();
     $cs->registerCssFile($baseUrl . '/css/' . $this->params['ui-theme'] . '/jquery-ui.css');
     $cs->registerScriptFile($baseUrl . '/js/jquery-ui.min.js');
     $language = $this->params['language'];
     if ($language != 'en') {
         $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$language}'], {$options}));";
         $cs->registerScriptFile($baseUrl . '/js/jquery-ui-i18n.min.js');
     } else {
         $js = "jQuery('#{$id}').datepicker({$options});";
     }
     $cs->registerScript('ProfileFieldController' . '#' . $id, $js);
     return CHtml::activeTextField($model, $field->varname, $htmlOptions);
 }
 /**
  * Runs the widget.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     $id = $this->resolveId($id);
     if ($this->hasModel()) {
         echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo TbHtml::textField($name, $this->value, $this->htmlOptions);
     }
     if ($this->assetPath !== false) {
         $this->publishAssets($this->assetPath);
         $this->registerCssFile('/css/bootstrap-datetimepicker.css');
         if ($this->registerJs) {
             $this->registerScriptFile('/js/' . $this->resolveScriptVersion('bootstrap-datetimepicker.js'), CClientScript::POS_END);
             if (isset($this->locale)) {
                 $this->locale = str_replace('_', '-', $this->locale);
                 $this->registerScriptFile("/js/locales/bootstrap-datetimepicker.{$this->locale}.js", CClientScript::POS_END);
             }
         }
     }
     if ($this->bindPlugin) {
         $options = !empty($this->pluginOptions) ? CJavaScript::encode($this->pluginOptions) : '';
         $this->getClientScript()->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').datetimepicker({$options});");
     }
 }
Example #11
0
 /**
  */
 public function run()
 {
     /**
      * @var CClientScript $cs
      */
     $cs = Yii::app()->getClientScript();
     // Javascript var
     if (empty($this->jsVarName)) {
         $this->jsVarName = $this->getId() . 'Layout';
     }
     // Container ID
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = $this->getId();
     }
     $id = $this->htmlOptions['id'];
     echo CHtml::openTag('div', $this->htmlOptions);
     $layoutsOptions = $this->renderLayouts();
     echo '</div>';
     // Prepare options
     $options = CMap::mergeArray($this->options, $layoutsOptions);
     $options = empty($options) ? '' : CJavaScript::encode($options);
     // Register global JS var
     $cs->registerScript(__CLASS__ . '#jsVar#' . $this->getId(), 'var ' . $this->jsVarName . ';', CClientScript::POS_HEAD);
     // Register Layouts init script
     $cs->registerScript(__CLASS__ . '#init#' . $this->getId(), $this->jsVarName . ' = $("#' . $id . '").layout(' . $options . ');', CClientScript::POS_READY);
 }
 public function run()
 {
     list($this->name, $this->id) = $this->resolveNameId();
     if (isset($this->htmlOptions['placeholder'])) {
         $this->options['placeholder'] = $this->htmlOptions['placeholder'];
     }
     $data = array();
     if (isset($this->options['placeholder'])) {
         $data[''] = '';
     }
     $this->data = $data + $this->data;
     if ($this->hasModel()) {
         echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
     } else {
         $this->htmlOptions['id'] = $this->id;
         echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
     }
     $bu = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets/');
     $cs = Yii::app()->clientScript;
     $cs->registerCssFile($bu . '/select2.css');
     if ($this->scriptPosition === null) {
         $this->scriptPosition = $cs->coreScriptPosition;
     }
     $cs->registerScriptFile($bu . '/select2.js', $this->scriptPosition);
     $options = $this->options ? CJavaScript::encode($this->options) : '';
     $cs->registerScript(__CLASS__ . '#' . $this->id, "\$('#{$this->id}').select2({$options});");
 }
 protected function registerFiles()
 {
     $assetsDir = (defined(__DIR__) ? __DIR__ : dirname(__FILE__)) . '/assets';
     $assets = Yii::app()->assetManager->publish($assetsDir);
     $ext = defined('YII_DEBUG') ? 'js' : 'min.js';
     $cs = Yii::app()->clientScript;
     $cs->registerCoreScript('jquery');
     $cs->registerScriptFile($assets . '/fullcalendar/jalali.js');
     $cs->registerScriptFile($assets . '/fullcalendar/fullcalendar.' . $ext);
     $cs->registerScriptFile($assets . '/fullcalendar/jquery-ui-1.8.23.custom.min.js');
     /* $cs->registerCssFile($assets.'/fullcalendar/fullcalendar.css'); */
     $cs->registerCssFile($assets . '/fullcalendar/fullcalendar_theme.css');
     if ($this->loadPrintCss) {
         $cs->registerCssFile($assets . '/fullcalendar/fullcalendar.print.css');
     }
     if ($this->googleCalendarUrl) {
         $cs->registerScriptFile($assets . '/fullcalendar/gcal.js');
         $this->options['events'] = $this->googleCalendarUrl;
     }
     if ($this->themeCssFile) {
         $this->options['theme'] = true;
         $cs->registerCssFile($assets . '/themes/' . $this->themeCssFile);
     }
     $BootBoxBaseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.bootbox'));
     $cs->registerScriptFile($BootBoxBaseUrl . '/bootstrap.bootbox.min.js');
     $js = 'var ' . $this->id . ' = $("#' . $this->id . '").fullCalendar(' . CJavaScript::encode($this->options) . ');';
     $cs->registerScript(__CLASS__ . '#' . $this->id, $js, CClientScript::POS_READY);
 }
Example #14
0
 public function renderButton($button, $name, $config, $id, &$js)
 {
     $output = '';
     $buttonCssClass = 'cms-icon-' . $config['iconSize'] . '-' . $button['icon'];
     if ($button['click']) {
         $js .= "\$('#{$id}_{$name}').click(" . CJavaScript::encode($button['click']) . ");\n";
     }
     $output .= '<li id="' . $id . '_' . $name . '_li" class="' . $button['cssClass'] . '">';
     $output .= '<a id="' . $id . '_' . $name . '"
             title="' . $button['title'] . '" href="#">';
     if (isset($button['checked'])) {
         $output .= '<input ';
         if ($button['checked']) {
             $output .= ' checked="checked" ';
         }
         $output .= 'type="checkbox" id="' . $id . '_' . $name . '_checkbox" /><label for="' . $id . '_' . $name . '_checkbox">';
     }
     if ($config['showIcons']) {
         $output .= '<span class="' . $buttonCssClass . '"></span>';
     }
     if ($config['showTitles']) {
         $output .= $button['title'];
     }
     if (isset($button['checked'])) {
         $output .= '</label>';
     }
     $output .= '</a>';
     $output .= '</li>';
     return $output;
 }
Example #15
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id;
     echo CHtml::tag('input', $this->htmlOptions);
     $options = !empty($this->options) ? CJavaScript::encode($this->options) : '';
     Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').typeahead({$options});");
 }
Example #16
0
    public static function addMarker($model, $inMarker, $draggable = 'false')
    {
        if (!$model) {
            return false;
        }
        if ($model->lat && $model->lng) {
            self::$jsCode .= '
				var latLng' . $model->id . ' = new google.maps.LatLng(' . $model->lat . ', ' . $model->lng . ');

				latLngList.push(latLng' . $model->id . ');

				markersGMap[' . $model->id . '] = new google.maps.Marker({
					position: latLng' . $model->id . ',
					title: "' . CJavaScript::quote($model->getStrByLang('title')) . '",
					icon: "' . $model->getMapIconUrl() . '",
					map: mapGMap,
					draggable: ' . $draggable . '
				});

				markersForClasterGMap.push(markersGMap[' . $model->id . ']);

				infoWindowsGMap[' . $model->id . '] = new google.maps.InfoWindow({
					content: "' . CJavaScript::quote($inMarker) . '"
				});

				google.maps.event.addListener(markersGMap[' . $model->id . '], "click", function() {
				   infoWindowsGMap[' . $model->id . '].open(mapGMap, markersGMap[' . $model->id . ']);
				});

			';
        }
    }
    public function getFileBrowserCallback()
    {
        $connectorUrl = $this->settings['url'];
        $id = $this->getId();
        $settings = array_merge(array('places' => "", 'rememberLastDir' => false), $this->settings);
        $settings['dialog'] = array('zIndex' => 400001, 'width' => 900, 'modal' => true, 'title' => "Files");
        $settings['editorCallback'] = 'js:function(url) {
                        aWin.document.getElementById(field_name).value = url;
                        if (type == "image" && aFieldName=="src" && aWin.ImageDialog.showPreviewImage)
                            aWin.ImageDialog.showPreviewImage(url);
                    }';
        $settings['closeOnEditorCallback'] = true;
        $settings = CJavaScript::encode($settings);
        $script = <<<JS
        function(field_name, url, type, win) {
            var aFieldName = field_name, aWin = win;
            var el = \$("#{$id}");
            if(el.length == 0) {
                el = \$("<div/>").attr("id", "{$id}");
                \$("body").append(el);
                el.elfinder({$settings});
                //place it above tinymce dialogue
                el[0].elfinder.dialog.closest('.ui-dialog').css({'z-index':4000001});
            }
            else {
                el.elfinder("open","{$connectorUrl}");
            }
        }
JS;
        return 'js:' . $script;
    }
 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     $id = $this->getId();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (empty($this->options)) {
         $options = '';
     } else {
         $options = CJavaScript::encode($this->options);
     }
     if ($this->baseInputNameForSortableCollection != null) {
         echo ZurmoHtml::hiddenField($this->baseInputNameForSortableCollection);
     }
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').sortable({$options});");
     echo ZurmoHtml::openTag($this->tagName, $this->htmlOptions) . "\n";
     if (empty($this->items) && $this->showEmptyList) {
         echo '<li></li>' . "\n";
     }
     foreach ($this->items as $id => $data) {
         echo strtr($this->itemTemplate, array_merge(array('{id}' => $id), $data)) . "\n";
     }
     echo ZurmoHtml::closeTag($this->tagName);
 }
Example #19
0
 public function run()
 {
     if (empty($this->config['action'])) {
         throw new CException('EAjaxUpload: param "action" cannot be empty.');
     }
     if (empty($this->config['allowedExtensions'])) {
         throw new CException('EAjaxUpload: param "allowedExtensions" cannot be empty.');
     }
     if (empty($this->config['sizeLimit'])) {
         throw new CException('EAjaxUpload: param "sizeLimit" cannot be empty.');
     }
     unset($this->config['element']);
     echo '<div id="' . $this->id . '"><noscript><p>Для того, что бы воспользоваться плагином, включите javascript</p></noscript></div>';
     $assets = dirname(__FILE__) . '/assets';
     $baseUrl = Yii::app()->assetManager->publish($assets);
     Yii::app()->clientScript->registerScriptFile($baseUrl . '/fileuploader.js', CClientScript::POS_HEAD);
     $this->css = !empty($this->css) ? $this->css : $baseUrl . '/fileuploader.css';
     Yii::app()->clientScript->registerCssFile($this->css);
     $postParams = array('PHPSESSID' => session_id(), 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken);
     if (isset($this->postParams)) {
         $postParams = array_merge($postParams, $this->postParams);
     }
     $config = array('element' => 'js:document.getElementById("' . $this->id . '")', 'debug' => false, 'multiple' => true);
     $config = array_merge($config, $this->config);
     $config['params'] = $postParams;
     $config = CJavaScript::encode($config);
     echo "<script type = 'text/javascript'>var FileUploader_" . $this->id . " = new qq.FileUploader({$config}); </script>";
     echo '<div class = "b-file_upload_error_message" id = "j-error_message"></div>';
 }
Example #20
0
 public function returnControllerClientStateHtml($data, $tableId)
 {
     $states = Clients::getClientsStatesArray();
     $items = CJavaScript::encode($states);
     $options = array('onclick' => 'ajaxSetModerationClientState(this, "' . $tableId . '", "' . $data->id . '", "' . $items . '"); return false;');
     return '<div align="center" class="editable_select" id="editable_select_state-' . $data->id . '">' . CHtml::link($states[$data->state], '#', $options) . '</div>';
 }
Example #21
0
 private function buildInifiniteScrollOptions()
 {
     $options = array_merge($this->_options, $this->_default_options);
     $options = array_filter($options);
     $options = CJavaScript::encode($options);
     return $options;
 }
Example #22
0
 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'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($this->name, $this->value, $this->htmlOptions);
     }
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     $options = CJavaScript::encode($this->options);
     $cs = Yii::app()->getClientScript();
     $assetUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.YiiDateTimePicker.assets'));
     Yii::app()->clientScript->registerScriptFile($assetUrl . '/jquery.datetimepicker.js');
     Yii::app()->clientScript->registerCssFile($assetUrl . '/jquery.datetimepicker.css');
     $js = "\$('#{$id}').datetimepicker({$options});";
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
 /**
  * Register Script
  */
 public function registerScript()
 {
     $basePath = Yii::getPathOfAlias('application.modules.user.views.asset');
     $baseUrl = Yii::app()->getAssetManager()->publish($basePath);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerCssFile($baseUrl . '/css/redmond/jquery-ui.css');
     $cs->registerCssFile($baseUrl . '/css/style.css');
     $cs->registerScriptFile($baseUrl . '/js/jquery-ui.min.js');
     $cs->registerScriptFile($baseUrl . '/js/form.js');
     $cs->registerScriptFile($baseUrl . '/js/jquery.json.js');
     $widgets = self::getWidgets();
     $wgByTypes = ProfileField::itemAlias('field_type');
     foreach ($wgByTypes as $k => $v) {
         $wgByTypes[$k] = array();
     }
     foreach ($widgets[1] as $widget) {
         if (isset($widget['fieldType']) && count($widget['fieldType'])) {
             foreach ($widget['fieldType'] as $type) {
                 array_push($wgByTypes[$type], $widget['name']);
             }
         }
     }
     //echo '<pre>'; print_r($widgets[1]); die();
     $js = "\n\n\tvar name = \$('#name'),\n\tvalue = \$('#value'),\n\tallFields = \$([]).add(name).add(value),\n\ttips = \$('.validateTips');\n\t\n\tvar listWidgets = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($widgets[0])) . "');\n\tvar widgets = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($widgets[1])) . "');\n\tvar wgByType = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($wgByTypes)) . "');\n\t\n\tvar fieldType = {\n\t\t\t'INTEGER':{\n\t\t\t\t'hide':['match','other_validator','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':10,\n\t\t\t\t\t'default':'0',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'VARCHAR':{\n\t\t\t\t'hide':['widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':255,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'TEXT':{\n\t\t\t\t'hide':['field_size','range','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'DATE':{\n\t\t\t\t'hide':['field_size','field_size_min','match','range','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'0000-00-00',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'FLOAT':{\n\t\t\t\t'hide':['match','other_validator','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':'10.2',\n\t\t\t\t\t'default':'0.00',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'DECIMAL':{\n\t\t\t\t'hide':['match','other_validator','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':'10,2',\n\t\t\t\t\t'default':'0',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'BOOL':{\n\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':0,\n\t\t\t\t\t'range':'1==" . UserModule::t('Yes') . ";0==" . UserModule::t('No') . "',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'BLOB':{\n\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'BINARY':{\n\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\t\n\tfunction showWidgetList(type) {\n\t\t\$('div.widget select').empty();\n\t\t\$('div.widget select').append('<option value=\"\">" . UserModule::t('No') . "</option>');\n\t\tif (wgByType[type]) {\n\t\t\tfor (var k in wgByType[type]) {\n\t\t\t\t\$('div.widget select').append('<option value=\"'+wgByType[type][k]+'\">'+widgets[wgByType[type][k]]['label']+'</option>');\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\tfunction setFields(type) {\n\t\tif (fieldType[type]) {\n\t\t\tif (" . (isset($_GET['id']) ? 0 : 1) . ") {\n\t\t\t\tshowWidgetList(type);\n\t\t\t\t\$('#widgetlist option:first').attr('selected', 'selected');\n\t\t\t}\n\t\t\t\n\t\t\t\$('div.row').addClass('toshow').removeClass('tohide');\n\t\t\tif (fieldType[type].hide.length) \$('div.'+fieldType[type].hide.join(', div.')).addClass('tohide').removeClass('toshow');\n\t\t\tif (\$('div.widget select').val()) {\n\t\t\t\t\$('div.widgetparams').removeClass('tohide');\n\t\t\t}\n\t\t\t\$('div.toshow').show(500);\n\t\t\t\$('div.tohide').hide(500);\n\t\t\t" . (!isset($_GET['id']) ? "\n\t\t\tfor (var k in fieldType[type].val) { \n\t\t\t\t\$('div.'+k+' input').val(fieldType[type].val[k]);\n\t\t\t}" : '') . "\n\t\t}\n\t}\n\t\n\tfunction isArray(obj) {\n\t\tif (obj.constructor.toString().indexOf('Array') == -1)\n\t\t\treturn false;\n\t\telse\n\t\t\treturn true;\n\t}\n\t\t\n\t\$('#dialog-form').dialog({\n\t\tautoOpen: false,\n\t\theight: 400,\n\t\twidth: 400,\n\t\tmodal: true,\n\t\tbuttons: {\n\t\t\t'" . UserModule::t('Save') . "': function() {\n\t\t\t\tvar wparam = {};\n\t\t\t\tvar fparam = {};\n\t\t\t\t\$('#dialog-form fieldset .wparam').each(function(){\n\t\t\t\t\tif (\$(this).val()) wparam[\$(this).attr('name')] = \$(this).val();\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tvar tab = \$('#tabs ul li.ui-tabs-selected').text();\n\t\t\t\tfparam[tab] = {};\n\t\t\t\t\$('#dialog-form fieldset .tab-'+tab).each(function(){\n\t\t\t\t\tif (\$(this).val()) fparam[tab][\$(this).attr('name')] = \$(this).val();\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tif (\$.JSON.encode(wparam)!='{}') \$('div.widgetparams input').val(\$.JSON.encode(wparam));\n\t\t\t\tif (\$.JSON.encode(fparam[tab])!='{}') \$('div.other_validator input').val(\$.JSON.encode(fparam)); \n\t\t\t\t\n\t\t\t\t\$(this).dialog('close');\n\t\t\t},\n\t\t\t'" . UserModule::t('Cancel') . "': function() {\n\t\t\t\t\$(this).dialog('close');\n\t\t\t}\n\t\t},\n\t\tclose: function() {\n\t\t}\n\t});\n\n\n\t\$('#widgetparams').focus(function() {\n\t\tvar widget = widgets[\$('#widgetlist').val()];\n\t\tvar html = '';\n\t\tvar wparam = (\$('div.widgetparams input').val())?\$.JSON.decode(\$('div.widgetparams input').val()):{};\n\t\tvar fparam = (\$('div.other_validator input').val())?\$.JSON.decode(\$('div.other_validator input').val()):{};\n\t\t\n\t\t// Class params\n\t\tfor (var k in widget.params) {\n\t\t\thtml += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';\n\t\t\thtml += '<input type=\"text\" name=\"'+k+'\" id=\"widget_'+k+'\" class=\"text wparam ui-widget-content ui-corner-all\" value=\"'+((wparam[k])?wparam[k]:widget.params[k])+'\" />';\n\t\t}\n\t\t// Validator params\t\t\n\t\tif (widget.other_validator) {\n\t\t\tvar tabs = '';\n\t\t\tvar li = '';\n\t\t\tfor (var t in widget.other_validator) {\n\t\t\t\ttabs += '<div id=\"tab-'+t+'\" class=\"tab\">';\n\t\t\t\tli += '<li'+((fparam[t])?' class=\"ui-tabs-selected\"':'')+'><a href=\"#tab-'+t+'\">'+t+'</a></li>';\n\t\t\t\t\n\t\t\t\tfor (var k in widget.other_validator[t]) {\n\t\t\t\t\ttabs += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';\n\t\t\t\t\tif (isArray(widget.other_validator[t][k])) {\n\t\t\t\t\t\ttabs += '<select type=\"text\" name=\"'+k+'\" id=\"filter_'+k+'\" class=\"text fparam ui-widget-content ui-corner-all tab-'+t+'\">';\n\t\t\t\t\t\tfor (var i in widget.other_validator[t][k]) {\n\t\t\t\t\t\t\ttabs += '<option value=\"'+widget.other_validator[t][k][i]+'\"'+((fparam[t]&&fparam[t][k])?' selected=\"selected\"':'')+'>'+widget.other_validator[t][k][i]+'</option>';\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttabs += '</select>';\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttabs += '<input type=\"text\" name=\"'+k+'\" id=\"filter_'+k+'\" class=\"text fparam ui-widget-content ui-corner-all tab-'+t+'\" value=\"'+((fparam[t]&&fparam[t][k])?fparam[t][k]:widget.other_validator[t][k])+'\" />';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttabs += '</div>';\n\t\t\t}\n\t\t\thtml += '<div id=\"tabs\"><ul>'+li+'</ul>'+tabs+'</div>';\n\t\t}\n\t\t\n\t\t\$('#dialog-form fieldset').html(html);\n\t\t\n\t\t\$('#tabs').tabs();\n\t\t\n\t\t// Show form\n\t\t\$('#dialog-form').dialog('open');\n\t});\n\t\n\t\$('#field_type').change(function() {\n\t\tsetFields(\$(this).val());\n\t});\n\t\n\t\$('#widgetlist').change(function() {\n\t\tif (\$(this).val()) {\n\t\t\t\$('div.widgetparams').show(500);\n\t\t} else {\n\t\t\t\$('div.widgetparams').hide(500);\n\t\t}\n\t\t\n\t});\n\t\n\t// show all function \n\t\$('div.form p.note').append('<br/><a href=\"#\" id=\"showAll\">" . UserModule::t('Show all') . "</a>');\n \t\$('#showAll').click(function(){\n\t\t\$('div.row').show(500);\n\t\treturn false;\n\t});\n\t\n\t// init\n\tsetFields(\$('#field_type').val());\n\t\n\t";
     $cs->registerScript(__CLASS__ . '#dialog', $js);
 }
Example #24
0
 /**
  * ### .run()
  *
  * Runs the widget.
  */
 public function run()
 {
     $options = !empty($this->options) ? CJavaScript::encode($this->options) : '';
     $id = !empty($this->htmlOptions['id']) ? $this->htmlOptions['id'] : $this->getId();
     $elementId = !empty($this->options['elementId']) ? $this->options['elementId'] : 'null';
     $elementUrl = !empty($this->options['elementUrl']) ? $this->options['elementUrl'] : 'null';
     echo CHtml::openTag('div', $this->htmlOptions);
     echo CHtml::openTag('table');
     echo '<thead><tr class="head"><th id="prev" style="visibility: visible;"><i class="icon-arrow-left"></i></th><th colspan="5" class="switch" style="text-align:center;">' . date("Y") . "年" . date("n") . "月" . '</th><th id="next" style="visibility: visible;"><i class="icon-arrow-right-2"></i></th></thead>';
     echo '<tbody></tbody>';
     echo CHtml::closeTag('table');
     echo CHtml::closeTag('div');
     ob_start();
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';');
     if (isset($_GET['date'])) {
         $year = date("Y", strtotime($_GET['date']));
         $month = date("n", strtotime($_GET['date']));
         $day = date("j", strtotime($_GET['date']));
     } else {
         $year = date("Y");
         $month = date("n");
         $day = date("j");
     }
     $this->registerJs($id, $year, $month, $day, $elementId, $elementUrl);
 }
Example #25
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);
 }
Example #26
0
 /**
  * Add WYMeditor to the page.
  */
 public function run()
 {
     // Add textarea to the page
     if ($this->target === null) {
         list($name, $id) = $this->resolveNameID();
         if ($this->hasModel()) {
             echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo CHtml::textArea($name, $this->value, $this->htmlOptions);
         }
     }
     // Publish extension assets
     $assets = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.EWYMeditor') . '/assets');
     $cs = Yii::app()->getClientScript();
     $cs->registerScriptFile($assets . '/jquery.wymeditor.js', CClientScript::POS_END);
     // Add the plugins to editor
     if ($this->plugins !== array()) {
         $this->_addPlugins($cs, $assets);
     }
     $options = CJavaScript::encode($this->options);
     if ($this->target === null) {
         $cs->registerScript('wym', "jQuery('#{$id}').wymeditor({$options});");
     } else {
         $cs->registerScript('wym', "jQuery('{$this->target}').wymeditor({$options});");
     }
 }
 /**
  * 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);
 }
 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'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').{$this->mode}picker({$options});";
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
     }
     $cs = Yii::app()->getClientScript();
     $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
     $cs->registerCssFile($assets . self::ASSETS_NAME . '.css');
     $cs->registerScriptFile($assets . self::ASSETS_NAME . '.js', CClientScript::POS_END);
     $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.{$this->mode}picker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
Example #29
0
 public function run()
 {
     if (empty($this->config['action'])) {
         throw new CException('EAjaxUpload: param "action" cannot be empty.');
     }
     if (empty($this->config['allowedExtensions'])) {
         throw new CException('EAjaxUpload: param "allowedExtensions" cannot be empty.');
     }
     if (empty($this->config['sizeLimit'])) {
         throw new CException('EAjaxUpload: param "sizeLimit" cannot be empty.');
     }
     unset($this->config['element']);
     echo '<div id="' . $this->id . '"><noscript><p>Please enable JavaScript to use file uploader.</p></noscript></div>';
     //$assets = dirname(__FILE__).'/assets';
     //$baseUrl = Yii::app()->assetManager->publish($assets);
     //Yii::app()->clientScript->registerScriptFile($baseUrl . '/fileuploader.js', CClientScript::POS_HEAD);
     //$this->css=(!empty($this->css))?$this->css:$baseUrl.'/fileuploader.css';
     //Yii::app()->clientScript->registerCssFile($this->css);
     $this->css = !empty($this->css) ? $this->css : 'fileuploader.css';
     Yii::setPathOfAlias('ajaxupload', dirname(__FILE__));
     $cs = Yii::app()->getClientScript();
     $cs->packages['ajaxupload'] = array('basePath' => 'ajaxupload.assets', 'css' => array($this->css), 'js' => array('fileuploader.js'));
     $cs->registerPackage('ajaxupload');
     $postParams = array('PHPSESSID' => session_id(), 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken);
     if (isset($this->postParams)) {
         $postParams = array_merge($postParams, $this->postParams);
     }
     $config = array('button' => 'js:document.getElementById("' . $this->id . '")', 'debug' => false, 'multiple' => false);
     $config = array_merge($config, $this->config);
     $config['params'] = $postParams;
     $config = CJavaScript::encode($config);
     Yii::app()->getClientScript()->registerScript("FileUploader_" . $this->id, "var FileUploader_" . $this->id . " = new qq.FileUploaderBasic({$config}); ", CClientScript::POS_LOAD);
 }
Example #30
0
 public function run()
 {
 	$this->editorOptions = array_merge($this->editorOptions, $this->defaultOptions);
 	
     list($name, $id) = $this->resolveNameID();
     
     // Publishing assets.
     $dir = dirname(__FILE__);
     $assets = Yii::app()->getAssetManager()->publish($dir.DIRECTORY_SEPARATOR.'assets');
     $this->editorOptions['script_url'] = $assets.'/tiny_mce.js';
     
     // Registering javascript.
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerScriptFile($assets.'/jquery.tinymce.js');
     $cs->registerScriptFile($assets.'/plugins/tinybrowser/tb_tinymce.js.php');
     
     $cs->registerScript(
         'Yii.'.get_class($this).'#'.$id,
         '$(function(){$("#'.$id.'").tinymce('.CJavaScript::encode($this->editorOptions).');});'
     );
     
     $this->htmlOptions['id'] = $id;
     
     if($this->hasModel())
         $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
     else
         $html = CHtml::textArea($name, $this->value, $this->htmlOptions);
         
     echo $html;
 }