/**
  * @inheritdoc
  */
 public function run()
 {
     $inputId = $this->options['id'];
     $hasModel = $this->hasModel();
     if (array_key_exists('value', $this->options)) {
         $value = $this->options['value'];
     } elseif ($hasModel) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     $options = array_merge($this->options, ['multiple' => true, 'value' => $value]);
     if ($hasModel) {
         $output = Html::activeListBox($this->model, $this->attribute, $this->items, $options);
     } else {
         $output = Html::listBox($this->name, $this->value, $this->items, $options);
     }
     $clientOptions = array_merge(['filter' => $this->filter, 'multiple' => $this->multiple, 'multipleWidth' => $this->multipleWidth], $this->clientOptions);
     if (!array_key_exists('placeholder', $clientOptions) && array_key_exists('placeholder', $options)) {
         $clientOptions['placeholder'] = $options['placeholder'];
     }
     $js = 'jQuery(\'#' . $inputId . '\').multipleSelect(' . Json::htmlEncode($clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         MultipleSelectAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
Exemplo n.º 2
0
 public function init()
 {
     $value = $this->model->{$this->attribute};
     if (is_int($value) || is_float($value) || is_string($value) && strlen($value)) {
         $this->inputOptions['value'] = Text::date($this->dateFormat . $this->separator . $this->timeFormat, $value);
         $this->hiddenInputOptions['value'] = Text::date($this->altDateFormat . $this->altSeparator . $this->altTimeFormat, $value);
     }
     if (!$this->readOnly) {
         $pluginOptions = array_merge(['numberOfMonths' => 3, 'showButtonPanel' => true, 'altFieldTimeOnly' => false], $this->pluginOptions, ['dateFormat' => Text::juiDateFormat($this->dateFormat), 'altFormat' => Text::juiDateFormat($this->altDateFormat), 'separator' => $this->separator, 'altSeparator' => $this->altSeparator, 'timeFormat' => Text::juiTimeFormat($this->timeFormat), 'altTimeFormat' => Text::juiTimeFormat($this->altTimeFormat)]);
         $inputId = Html::getInputId($this->model, $this->attribute);
         $pluginOptions['altField'] = '#' . $inputId . '-alt';
         $js = 'jQuery(\'#' . $inputId . '\').datetimepicker(' . Json::encode($pluginOptions) . ');';
         $this->inputOptions['name'] = false;
         $this->hiddenInputOptions['id'] = $inputId . '-alt';
         $this->template .= "\n{hiddenInput}";
         $this->parts['{hiddenInput}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenInputOptions);
         if (Yii::$app->getRequest()->getIsAjax()) {
             $this->template .= "\n{script}";
             $this->parts['{script}'] = Html::script($js);
         } else {
             $view = $this->form->getView();
             TimePickerAsset::register($view);
             $view->registerJs($js);
         }
     }
     parent::init();
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  * @throw NotSupportedException
  */
 public function run()
 {
     if ($this->hasModel()) {
         if (!is_null($this->value)) {
             if (!in_array($this->attribute, $this->model->attributes())) {
                 throw new NotSupportedException('Unable to set value of the property \'' . $this->attribute . '\'.');
             }
             $stash = $this->model->{$this->attribute};
             $this->model->{$this->attribute} = $this->value;
         }
         $output = Html::activeListBox($this->model, $this->attribute, $this->items, $this->options);
         if (isset($stash)) {
             $this->model->{$this->attribute} = $stash;
         }
     } else {
         $output = Html::listBox($this->name, $this->value, $this->items, $this->options);
     }
     $js = 'jQuery(\'#' . $this->options['id'] . '\').select2(' . Json::htmlEncode($this->clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         Select2Asset::register($view);
         Select2LanguageAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
    public function run()
    {
        $chatModel = new \nitm\widgets\models\Replies(['constrain' => ['type' => 'chat']]);
        $notificationModel = new \nitm\widgets\models\Notification(['constrain' => ['user_id' => \Yii::$app->user->getId()], 'queryOptions' => ['read' => 0]]);
        $uniqid = uniqid();
        $chatWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-messages-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('comment') . Html::tag('span', $chatModel->hasNew(), ['class' => 'badge']), 'options' => ['class' => !$chatModel->hasNew() ? 'text-disabled' : 'text-success'], 'linkOptions' => ['id' => 'communication-center-messages-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#chat' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#chat' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/reply/index/chat/0', '__format' => 'html', \nitm\widgets\models\Replies::FORM_PARAM => true])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Messages...', ['class' => 'text-center']) . Html::script('$("#communication-center-messages-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['role' => 'chatParent', 'id' => 'chat' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $alertWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-notifications-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('bell') . Html::tag('span', $notificationModel->count(), ['class' => 'badge']), 'options' => ['class' => !$notificationModel->count() ? 'bg-disabled' : 'bg-success'], 'linkOptions' => ['id' => 'communication-center-notifications-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#communication-center-notifications' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#communication-center-notifications' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/alerts/notifications', '__format' => 'html'])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Alerts...', ['class' => 'text-center']) . Html::script('$("#communication-center-notifications-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['id' => 'communication-center-notifications' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $widget = $alertWidget . $chatWidget;
        //$js = "\$nitm.onModuleLoad('communication-center', function (module) {
        //	module.initChatTabs('#".$this->options['id']."');
        //});";
        $js = "";
        if ($this->chatUpdateOptions['enabled']) {
            $js .= "\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('chat', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\turl: '" . $this->chatUpdateOptions['url'] . "', \r\n\t\t\t\t\tinterval: " . $this->chatUpdateOptions['interval'] . ",\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('replies'), method: 'chatStatus'});\r\n\t\t\t});";
        }
        if ($this->notificationUpdateOptions['enabled']) {
            $js .= "\r\n\t\t\t\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('notifications', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\tinterval: " . $this->notificationUpdateOptions['interval'] . ",\r\n\t\t\t\t\turl: '" . $this->notificationUpdateOptions['url'] . "',\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('notifications'), method: 'notificationStatus'});\r\n\t\t\t});";
        }
        if ($js) {
            $js = Html::script($js, ['type' => 'text/javascript']);
        }
        return $widget . $js;
    }
 /**
  * @inheritdoc
  */
 public function run()
 {
     $inputId = $this->options['id'];
     $hasModel = $this->hasModel();
     if (array_key_exists('value', $this->options)) {
         $value = $this->options['value'];
     } elseif ($hasModel) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     $options = array_merge($this->options, ['value' => $value]);
     if ($hasModel) {
         $output = Html::activeTextInput($this->model, $this->attribute, $options);
     } else {
         $output = Html::textInput($this->name, $this->value, $options);
     }
     if (!is_null($this->alias)) {
         $clientOptions = array_merge($this->clientOptions, ['alias' => $this->alias]);
     } else {
         $clientOptions = array_merge($this->clientOptions, ['mask' => $this->mask]);
     }
     if (!array_key_exists('placeholder', $clientOptions) && array_key_exists('placeholder', $options)) {
         $clientOptions['placeholder'] = $options['placeholder'];
     }
     $js = 'jQuery(\'#' . $inputId . '\').inputmask(' . Json::htmlEncode($clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         InputMaskAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
Exemplo n.º 6
0
 /**
  * загружает картинки в CKEDITOR
  */
 public function actionUpload()
 {
     $this->actionUpload_clearTempFolder();
     $fileInfo = pathinfo($_FILES['upload']['name']);
     $path = UploadFolderDispatcher::createFolder(HtmlContent::$uploadFolder);
     $path->add(time() . '_' . Security::generateRandomString(10) . '.' . $fileInfo['extension']);
     if ($_FILES['upload'] == 'none' or empty($_FILES['upload']['name'])) {
         $message = 'No file uploaded';
     } else {
         if ($_FILES['upload']['size'] == 0) {
             $message = 'The file is of zero length';
         } else {
             if ($_FILES['upload']['type'] != 'image/jpeg' and $_FILES['upload']['type'] != 'image/png') {
                 $message = 'The image must be in either JPG or PNG format. Please upload a JPG or PNG instead';
             } else {
                 if (!is_uploaded_file($_FILES['upload']['tmp_name'])) {
                     $message = "You may be attempting to hack our server. We're on to you; expect a knock on the door sometime soon";
                 } else {
                     $message = '';
                     $move = @move_uploaded_file($_FILES['upload']['tmp_name'], $path->getPathFull());
                     if (!$move) {
                         $message = 'Error moving uploaded file. Check the script is granted Read/Write/Modify permissions';
                     }
                 }
             }
         }
     }
     $funcNum = (int) $_GET['CKEditorFuncNum'];
     return Html::script("window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$path->getPath()}', '{$message}');");
 }
 public function actionIndex()
 {
     $auth = \Yii::$app->authManager;
     $nameItem = \Yii::$app->request->post()['name'];
     $auth->removeRecursive($nameItem);
     Yii::$app->session->setFlash('info', $_POST['type'] == 1 ? 'Роль успешно удалена.' : 'Разрешение успешно удалено.');
     echo Html::script("\$('#rbacTree').jstree('refresh', true, true);");
     return $this->renderAjax('@app/views/layouts/flash.php');
 }
 public function run()
 {
     $inputId = $this->options['id'];
     $altInputId = $inputId . '-alt';
     $hasModel = $this->hasModel();
     if (array_key_exists('value', $this->options)) {
         $value = $this->options['value'];
     } elseif ($hasModel) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     $altOptions = ['id' => $altInputId, 'name' => $altInputId];
     if (!is_null($value) && $value !== '') {
         $formatter = Yii::$app->getFormatter();
         try {
             $this->options['value'] = $formatter->asDate($value, $this->dateFormat) . self::SEPARATOR . $formatter->asTime($value, $this->timeFormat);
             $altOptions['value'] = $formatter->asDate($value, $this->altDateFormat) . self::SEPARATOR . $formatter->asTime($value, $this->altTimeFormat);
         } catch (InvalidParamException $e) {
             // ignore exception and keep original value if it is not a valid date
         }
     }
     if ($hasModel) {
         $output = Html::activeTextInput($this->model, $this->attribute, $this->options) . (!$this->disableAlt ? Html::activeHiddenInput($this->model, $this->attribute, $altOptions) : null);
     } else {
         $output = Html::textInput($this->name, $this->value, $this->options) . (!$this->disableAlt ? Html::hiddenInput($this->name, $this->value, $altOptions) : null);
     }
     $this->clientOptions = array_merge(['numberOfMonths' => $this->numberOfMonths, 'showButtonPanel' => $this->showButtonPanel], $this->clientOptions, ['dateFormat' => FormatConverter::convertDatePhpOrIcuToJui($this->dateFormat), 'separator' => self::SEPARATOR, 'timeFormat' => FormatConverter::convertTimePhpOrIcuToJui($this->timeFormat), 'altFormat' => FormatConverter::convertDatePhpOrIcuToJui($this->altDateFormat), 'altSeparator' => self::SEPARATOR, 'altTimeFormat' => FormatConverter::convertTimePhpOrIcuToJui($this->altTimeFormat), 'altField' => '#' . $altInputId, 'altFieldTimeOnly' => false]);
     if (!$this->ignoreReadonly && array_key_exists('readonly', $this->options) && $this->options['readonly']) {
         $this->clientOptions['beforeShow'] = new JsExpression('function (input, inst) { return false; }');
     }
     if ($this->disableAlt) {
         foreach ($this->clientOptions as $keyCO => $valueCO) {
             if (strrpos($keyCO, 'alt') !== false) {
                 unset($this->clientOptions[$keyCO]);
             }
         }
     }
     $js = 'jQuery(\'#' . $inputId . '\').datetimepicker(' . Json::htmlEncode($this->clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         JuiDatetimePickerAsset::register($view);
         JuiDatetimePickerLanguageAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
Exemplo n.º 9
0
    public function run()
    {
        $title = Html::tag('h2', $this->header);
        switch ($this->asForm) {
            case true:
                $metadata = $this->getAsForm();
                break;
            default:
                $metadata = $this->getAsGrid();
                break;
        }
        $script = Html::script(new \yii\web\JsExpression('$nitm.onModuleLoad("entity:metadata", function (module) {
			module.initDefaults("#' . $this->options['id'] . '");
		});'));
        return $title . $metadata . $script;
    }
Exemplo n.º 10
0
 public function init()
 {
     parent::init();
     Cloud::getInst();
     if (empty($this->name)) {
         throw new InvalidConfigException('The "name" property must be set.');
     }
     $this->options['id'] = ArrayHelper::remove($this->options, 'id', $this->getId());
     echo Html::script($this->getTemplate(), ['type' => 'text/template', 'id' => 'qq-template-gallery-' . $this->getId()]);
     echo Html::tag('div', null, $this->options);
     if ($this->filesPath && $this->filesUrlPath) {
         $this->registerScript(true);
         echo $this->showSavedFiles();
     } else {
         $this->registerScript();
     }
 }
Exemplo n.º 11
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         $output = Html::activeTextarea($this->model, $this->attribute, $this->options);
     } else {
         $output = Html::textarea($this->name, $this->value, $this->options);
     }
     $js = 'jQuery(\'#' . $this->options['id'] . '\').tinymce(' . Json::htmlEncode($this->clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         TinymceAsset::register($view);
         TinymceLanguageAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
Exemplo n.º 12
0
 public function init()
 {
     if ($this->readOnly) {
         $pluginOptions = array_merge($this->pluginOptions, ['readonly' => true, 'menubar' => false, 'toolbar' => false, 'statusbar' => false]);
     } else {
         $pluginOptions = $this->pluginOptions;
     }
     $inputId = Html::getInputId($this->model, $this->attribute);
     $pluginOptions['selector'] = '#' . $inputId;
     $js = 'jQuery(\'#' . $inputId . '\').tinymce(' . Json::encode($pluginOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $this->template .= "\n{script}";
         $this->parts['{script}'] = Html::script($js);
     } else {
         $view = $this->form->getView();
         TinymceAsset::register($view);
         $view->registerJs($js);
     }
     parent::init();
 }
Exemplo n.º 13
0
 protected function getNavigation()
 {
     $new = $this->model->hasNew();
     switch ($new >= 1) {
         case true:
             $newMessage = $new . " new messages";
             $newClass = "bg-success";
             break;
         default:
             $newMessage = 'No new messages';
             $newClass = "bg-transparent";
             break;
     }
     $uniqid = uniqid();
     $ret_val = Tabs::widget(['options' => ['id' => 'nitm-chat-widget' . $uniqid], 'encodeLabels' => false, 'items' => [['label' => 'Messages ' . Html::tag('span', $this->model->hasNew(), ['class' => 'badge']), 'active' => false, 'content' => Html::tag('div', '', ['id' => 'chat-widget-container' . $uniqid, 'role' => 'chatParent', 'id' => 'chat' . $uniqid, 'class' => 'chat col-md-4 col-lg-4', 'style' => 'z-index: 10000; position: fixed;top: 6px; right: 6px;bottom: 40px;overflow: hidden;padding: 0px;box-shadow: 2px 2px 15px #000; background-color: rgba(153,153,153,0.9);']), 'options' => ['id' => 'chat-widget-messages' . $uniqid], 'headerOptions' => ['id' => 'chat-widget-messages-tab' . $uniqid], 'linkOptions' => ['role' => 'visibility', 'data-type' => 'html', 'data-on' => '#chat-widget-messages' . $uniqid . ':hidden', 'data-id' => '#chat' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/reply/index/chat/0', '__format' => 'html', \nitm\widgets\models\Replies::FORM_PARAM => true]), 'id' => 'chat-widget-messages-link' . $uniqid]], ['label' => '', 'content' => '', 'active' => true, 'headerOptions' => ['class' => 'hidden']]]]);
     if (isset($this->updateOptions['enable']) && $this->updateOptions['enable']) {
         $ret_val .= Html::script("\$nitm.module('replies').initChatActivity(\"[role='chatParent']\", '" . $this->updateOptions['url'] . "', " . $this->updateOptions['interval'] . ")");
     }
     return $ret_val;
 }
Exemplo n.º 14
0
 public function run()
 {
     $vote = '';
     switch (\Yii::$app->user->identity->isAdmin()) {
         case true:
             break;
     }
     switch (VoteModel::$individualCounts) {
         case true:
             $positive = Html::tag('div', Html::tag('strong', $this->model->rating()['positive'], ['id' => 'vote-value-positive' . $this->parentId]) . (VoteModel::$usePercentages ? '%' : ""), ['class' => 'text-success col-md-6 col-lg-6']);
             $negative = Html::tag('div', Html::tag('strong', $this->model->rating()['negative'], ['id' => 'vote-value-negative' . $this->parentId]) . (VoteModel::$usePercentages ? '%' : ""), ['class' => 'text-danger col-md-6 col-lg-6']);
             break;
         default:
             $negative = '';
             $positive = Html::tag('strong', $this->model->rating()['positive'], ['id' => 'vote-value-positive' . $this->parentId]) . (VoteModel::$usePercentages ? "%" : '');
             break;
     }
     $vote .= Html::tag('div', $positive . $negative, ['class' => 'center-block text-center']);
     $vote .= $this->getActions();
     $this->widgetOptions['id'] .= $this->parentId . $this->uniqid;
     return Html::tag('div', $vote, $this->widgetOptions) . Html::script(new \yii\web\JsExpression("\$nitm.onModuleLoad('vote', function () {\$nitm.module('vote').init('" . $this->widgetOptions['id'] . "');});"));
 }
Exemplo n.º 15
0
 public function actionIndex()
 {
     $auth = \Yii::$app->authManager;
     $model = new rbacForm();
     if (Yii::$app->request->isPjax && $model->load(Yii::$app->request->post()) && $model->validate()) {
         $parent = $auth->getRole($model->parent);
         $session = Yii::$app->session;
         if ($model->type == 1) {
             $role = $auth->createRole($model->name);
             $role->description = $model->description;
             $auth->add($role);
             if ($model->parent) {
                 $auth->addChild($parent, $role);
             }
             $session->setFlash('success', 'Роль успешно создана.');
         } else {
             $permission = $auth->createPermission($model->name);
             $permission->description = $model->description;
             $auth->add($permission);
             if ($model->parent) {
                 $auth->addChild($parent, $permission);
             }
             $session->setFlash('alerts', 'Разрешение успешно создано.');
         }
         echo $this->renderAjax('@app/views/layouts/response.php');
         $model = new rbacForm();
         $auth = \Yii::$app->authManager;
         echo Html::script("if(\$('#rbacTree').length) { \$('#rbacTree').jstree('refresh', true, true);};");
         return $this->render('index', ['model' => $model, 'auth' => $auth]);
     }
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     return $this->render('index', ['model' => $model, 'auth' => $auth]);
 }
Exemplo n.º 16
0
    /**
     * JS функция хелпер для постинга сообщений, используеться в [[self::refreshParent]]
     * @return string
     */
    private static function postMessageFunction()
    {
        return Html::script(<<<JS
    function postIframeMessage(name, message, target) {
        var data = {
            name: name,
            message: message
        };

        (target || window.parent).postMessage(JSON.stringify(data), window.location.origin || window.location.href);
    }
JS
);
    }
    /**
     * @param View $view
     */
    protected function _processing(View $view)
    {
        //Компиляция файлов js в один.
        if ($view->jsFiles && $this->jsFileCompile) {
            \Yii::beginProfile('Compress js files');
            foreach ($view->jsFiles as $pos => $files) {
                if ($files) {
                    $view->jsFiles[$pos] = $this->_processingJsFiles($files);
                }
            }
            \Yii::endProfile('Compress js files');
        }
        //Компиляция js кода который встречается на странице
        if ($view->js && $this->jsCompress) {
            \Yii::beginProfile('Compress js code');
            foreach ($view->js as $pos => $parts) {
                if ($parts) {
                    $view->js[$pos] = $this->_processingJs($parts);
                }
            }
            \Yii::endProfile('Compress js code');
        }
        //Компиляция css файлов который встречается на странице
        if ($view->cssFiles && $this->cssFileCompile) {
            \Yii::beginProfile('Compress css files');
            $view->cssFiles = $this->_processingCssFiles($view->cssFiles);
            \Yii::endProfile('Compress css files');
        }
        //Компиляция css файлов который встречается на странице
        if ($view->css && $this->cssCompress) {
            \Yii::beginProfile('Compress css code');
            $view->css = $this->_processingCss($view->css);
            \Yii::endProfile('Compress css code');
        }
        //Компиляция css файлов который встречается на странице
        if ($view->css && $this->cssCompress) {
            \Yii::beginProfile('Compress css code');
            $view->css = $this->_processingCss($view->css);
            \Yii::endProfile('Compress css code');
        }
        //Перенос файлов css вниз страницы, где файлы js View::POS_END
        if ($view->cssFiles && $this->cssFileBottom) {
            \Yii::beginProfile('Moving css files bottom');
            if ($this->cssFileBottomLoadOnJs) {
                \Yii::beginProfile('load css on js');
                $cssFilesString = implode("", $view->cssFiles);
                $view->cssFiles = [];
                $script = Html::script(new JsExpression(<<<JS
        document.write('{$cssFilesString}');
JS
));
                if (ArrayHelper::getValue($view->jsFiles, View::POS_END)) {
                    $view->jsFiles[View::POS_END] = ArrayHelper::merge($view->jsFiles[View::POS_END], [$script]);
                } else {
                    $view->jsFiles[View::POS_END][] = $script;
                }
                \Yii::endProfile('load css on js');
            } else {
                if (ArrayHelper::getValue($view->jsFiles, View::POS_END)) {
                    $view->jsFiles[View::POS_END] = ArrayHelper::merge($view->cssFiles, $view->jsFiles[View::POS_END]);
                } else {
                    $view->jsFiles[View::POS_END] = $view->cssFiles;
                }
                $view->cssFiles = [];
            }
            \Yii::endProfile('Moving css files bottom');
        }
    }
Exemplo n.º 18
0
    $formClass::end();
    echo Html::endTag('div');
    // panel-body
}
$pjax = Pjax::begin(['options' => ['class' => 'panel-grid-view'], 'linkSelector' => '.panel-grid-pager a, .grid-view .gv-headers a']);
$grid = $gridClass::begin($gridConfig);
$gridPager = $grid->renderPager();
$gridSummary = $grid->renderSummary();
$grid->layout = '{items}';
$gridClass::end();
$gridId = $grid->getId();
$js = 'jQuery(\'#' . $gridId . '\').closest(\'.panel\').find(\'.panel-grid-pager\').html(' . Json::encode($gridPager) . ');';
$js .= 'jQuery(\'#' . $gridId . '\').closest(\'.panel\').find(\'.panel-grid-summary\').html(' . Json::encode($gridSummary) . ');';
if ($gridSummary) {
    $this->title .= ' ' . strip_tags($gridSummary);
}
if (Yii::$app->getRequest()->getIsAjax()) {
    $js .= 'document.title = ' . Json::encode($this->title) . ';';
    echo Html::script($js);
} else {
    $js .= 'jQuery(\'#' . $pjax->getId() . '\').kinetic({\'cursor\': false, \'filterTarget\': function (target, event) { if (event.which != 2) { return false; } }});';
    $this->registerJs($js);
}
Pjax::end();
/*$footerButtons[] = Html::button('<span class="glyphicon glyphicon-arrow-up"></span> ' . Yii::t('mozayka', 'Up'), [
    'class' => 'btn btn-default',
    'onclick' => 'jQuery(document).scrollTop(0);'
]);*/
echo Html::tag('div', Html::tag('div', '&nbsp;', ['class' => 'panel-grid-pager pull-left']) . ButtonGroup::widget(['buttons' => $footerButtons, 'options' => ['class' => 'pull-right']]), ['class' => 'panel-footer clearfix hidden-print']);
echo Html::endTag('div');
// panel
Exemplo n.º 19
0
    <?php 
    echo Html::errorSummary($model);
} else {
    ?>
    <?php 
    echo Html::beginForm('https://www.liqpay.com/api/checkout', 'post', ['accept-charset' => 'utf8', 'id' => 'liqPay-form']);
    ?>
    <?php 
    echo Html::activeHiddenInput($model, 'data');
    ?>
    <?php 
    echo Html::activeHiddenInput($model, 'signature');
    ?>
    <?php 
    if ($autoSubmit) {
        ?>
        <?php 
        echo Html::script("setTimeout(function(){\n                document.getElementById(\"liqPay-form\").submit();\n            }, {$autoSubmitTimeout});");
        ?>
    <?php 
    } else {
        ?>
        <?php 
        echo Html::submitButton();
        ?>
    <?php 
    }
    ?>
    <?php 
    echo Html::endForm();
}
Exemplo n.º 20
0
 /**
  * Renders the content to be inserted within the default js block
  * The content is rendered using the registered JS code blocks and files.
  * @param boolean $ajaxMode whether the view is rendering in AJAX mode.
  * @return string the rendered content
  */
 protected function renderJsBlockHtml($ajaxMode = false)
 {
     $lines = [];
     if (true) {
         if (!empty($this->jsFiles[self::POS_JS_BLOCK])) {
             $lines[] = implode("\n\t", $this->jsFiles[self::POS_JS_BLOCK]);
             $this->jsFiles[self::POS_JS_BLOCK] = [];
         }
         if ($this->pagePlugin) {
             $this->addPagePlugin($this->pagePlugin, true);
             $this->pagePlugin = '';
         }
         if ($this->pagePlugins) {
             foreach ($this->pagePlugins as $pagePlugin) {
                 $lines[] = Html::jsFile($pagePlugin);
             }
             $this->pagePlugins = [];
         }
         if (!empty($this->jsFiles[self::POS_END])) {
             $lines[] = implode("\n\t", $this->jsFiles[self::POS_END]);
             $this->jsFiles[self::POS_END] = [];
         }
         if (empty($this->js[self::POS_READY])) {
             $this->js[self::POS_READY] = [];
         }
         if ($this->pageReadyJS) {
             array_unshift($this->js[self::POS_READY], $this->pageReadyJS);
             $this->pageReadyJS = '';
         }
         if ($this->pageReadyJSs) {
             $this->js[self::POS_READY] = array_merge($this->pageReadyJSs, $this->js[self::POS_READY]);
             $this->pageReadyJSs = [];
         }
         if ($this->pageReadyPriorityJSs) {
             $this->js[self::POS_READY] = array_merge($this->pageReadyPriorityJSs, $this->js[self::POS_READY]);
             $this->pageReadyPriorityJSs = [];
         }
         if ($this->pageReadyFinalJSs) {
             $this->js[self::POS_READY] = array_merge($this->js[self::POS_READY], $this->pageReadyFinalJSs);
             $this->pageReadyFinalJSs = [];
         }
         if (!empty($this->js[self::POS_READY])) {
             if ($ajaxMode) {
                 $js = "\n\t\t" . implode("\n\t\t", $this->js[self::POS_READY]) . "\n\t";
             } else {
                 $js = "\n\t\tjQuery(document).ready(function () {\n\t\t\t" . implode("\n\t\t\t", $this->js[self::POS_READY]) . "\n\t\t});\n\t";
             }
             $this->js[self::POS_READY] = [];
             $lines[] = Html::script($js, ['type' => 'text/javascript']);
         }
         if (empty($this->js[self::POS_LOAD])) {
             $this->js[self::POS_LOAD] = [];
         }
         if ($this->pageLoadJS) {
             array_unshift($this->js[self::POS_LOAD], $this->pageLoadJS);
             $this->pageLoadJS = '';
         }
         if ($this->pageLoadJSs) {
             $this->js[self::POS_LOAD] = array_merge($this->pageLoadJSs, $this->js[self::POS_READY]);
             $this->pageLoadJSs = [];
         }
         if ($this->pageLoadPriorityJSs) {
             $this->js[self::POS_LOAD] = array_merge($this->pageLoadPriorityJSs, $this->js[self::POS_LOAD]);
             $this->pageLoadPriorityJSs = [];
         }
         if ($this->pageLoadFinalJSs) {
             $this->js[self::POS_LOAD] = array_merge($this->js[self::POS_LOAD], $this->pageLoadFinalJSs);
             $this->pageLoadFinalJSs = [];
         }
         if (!empty($this->js[self::POS_LOAD])) {
             if ($ajaxMode) {
                 $js = "\n\t\t" . implode("\n\t\t", $this->js[self::POS_LOAD]) . "\n\t";
             } else {
                 $js = "\n\t\tjQuery(window).load(function () {\n\t\t\t" . implode("\n\t\t\t", $this->js[self::POS_LOAD]) . "\n\t\t});\n\t";
             }
             $this->js[self::POS_LOAD] = [];
             $lines[] = Html::script($js, ['type' => 'text/javascript']);
         }
     }
     return empty($lines) ? '' : "\t" . implode("\n\t", $lines) . "\n";
 }
Exemplo n.º 21
0
 /**
  * Renders the content to be inserted at the end of the body section.
  * The content is rendered using the registered JS code blocks and files.
  * @param boolean $ajaxMode whether the view is rendering in AJAX mode.
  * If true, the JS scripts registered at [[POS_READY]] and [[POS_LOAD]] positions
  * will be rendered at the end of the view like normal scripts.
  * @return string the rendered content
  */
 protected function renderBodyEndHtml($ajaxMode)
 {
     $lines = [];
     if (!empty($this->jsFiles[self::POS_END])) {
         $lines[] = implode("\n", $this->jsFiles[self::POS_END]);
     }
     if ($ajaxMode) {
         $scripts = [];
         if (!empty($this->js[self::POS_END])) {
             $scripts[] = implode("\n", $this->js[self::POS_END]);
         }
         if (!empty($this->js[self::POS_READY])) {
             $scripts[] = implode("\n", $this->js[self::POS_READY]);
         }
         if (!empty($this->js[self::POS_LOAD])) {
             $scripts[] = implode("\n", $this->js[self::POS_LOAD]);
         }
         if (!empty($scripts)) {
             $lines[] = Html::script(implode("\n", $scripts), ['type' => 'text/javascript']);
         }
     } else {
         if (!empty($this->js[self::POS_END])) {
             $lines[] = Html::script(implode("\n", $this->js[self::POS_END]), ['type' => 'text/javascript']);
         }
         if (!empty($this->js[self::POS_READY])) {
             $js = "jQuery(document).ready(function () {\n" . implode("\n", $this->js[self::POS_READY]) . "\n});";
             $lines[] = Html::script($js, ['type' => 'text/javascript']);
         }
         if (!empty($this->js[self::POS_LOAD])) {
             $js = "jQuery(window).on('load', function () {\n" . implode("\n", $this->js[self::POS_LOAD]) . "\n});";
             $lines[] = Html::script($js, ['type' => 'text/javascript']);
         }
     }
     return empty($lines) ? '' : implode("\n", $lines);
 }
Exemplo n.º 22
0
                            }')]]);
?>

                <?php 
echo $form->field($model, 'name', ['inputOptions' => ['class' => 'form-control', 'autocomplete' => 'off']]);
?>

                <?php 
echo $form->field($model, 'description', ['inputOptions' => ['class' => 'form-control', 'autocomplete' => 'off']]);
?>

                <?php 
echo Html::submitButton('Создать', ['class' => 'btn btn-primary btn-block']);
?>

                <?php 
ActiveForm::end();
?>
                <?php 
Pjax::end();
?>
            </div>
        </div>
    </div>
<?php 
if ($script) {
    echo Html::script("\$(document).unbind('submit');");
    foreach ($this->js[4] as $index => $script) {
        echo Html::script($script);
    }
}
Exemplo n.º 23
0
 public function testScript()
 {
     $content = 'a <>';
     $this->assertEquals("<script>{$content}</script>", Html::script($content));
     $this->assertEquals("<script type=\"text/js\">{$content}</script>", Html::script($content, ['type' => 'text/js']));
 }
Exemplo n.º 24
0
 /**
  * @return string
  */
 public function actionSaveCroppedImage()
 {
     $data = \Yii::$app->request->post('data');
     $data = $data ? Json::decode($data) : null;
     if ($data) {
         $fileId = $data['fileId'];
         $imageEntity = EntityToFile::find()->where('file_id = :id', [':id' => (int) $fileId])->one();
         if ($imageEntity) {
             //Find original img path
             $directory = FPM::getOriginalDirectory($imageEntity->file_id);
             FileHelper::createDirectory($directory, 0777, true);
             $fileName = $directory . DIRECTORY_SEPARATOR . FPM::getOriginalFileName($imageEntity->file_id, $imageEntity->file->base_name, $imageEntity->file->extension);
             //Delete cached image
             FPM::cache()->delete($imageEntity->file_id);
             //Delete thumbs
             $this->clearImageThumbs($imageEntity->file);
             Image::crop($fileName, $data['width'], $data['height'], $data['startX'], $data['startY'])->save($fileName);
             return Json::encode(['replaces' => [['what' => '#preview-image-' . $imageEntity->file_id, 'data' => Html::img(FPM::originalSrc($imageEntity->file_id) . '?' . time(), ['class' => 'file-preview-image', 'id' => 'preview-image-' . $imageEntity->file_id])]], 'js' => Html::script('hideModal(".modal")')]);
         }
     }
 }
Exemplo n.º 25
0
 /**
  * Will generate Stripe script tag with passed parameters
  * @return string the generated script tag
  */
 private function generateScriptTag()
 {
     return Html::script('', ['src' => $this->stripeJs, 'data-key' => Yii::$app->stripe->publicKey, 'data-amount' => $this->amount, 'data-name' => $this->name, 'data-description' => $this->description, 'data-image' => $this->image, 'data-currency' => $this->currency, 'data-panel-label' => $this->panelLabel, 'data-zip-code' => $this->validateZipCode, 'data-email' => $this->userEmail, 'data-label' => $this->label, 'data-allow-remember-me' => $this->allowRemember, 'data-billing-address' => $this->collectBillingAddress, 'class' => self::BUTTON_CLASS]);
 }
Exemplo n.º 26
0
 /**
  * Renders the content to be inserted at the end of the body section.
  * The content is rendered using the registered JS code blocks and files.
  * @return string the rendered content
  */
 protected function renderBodyEndHtml()
 {
     $lines = [];
     if (!empty($this->jsFiles[self::POS_END])) {
         $lines[] = implode("\n", $this->jsFiles[self::POS_END]);
     }
     if (!empty($this->js[self::POS_END])) {
         $lines[] = Html::script(implode("\n", $this->js[self::POS_END]), ['type' => 'text/javascript']);
     }
     if (!empty($this->js[self::POS_READY])) {
         $js = "jQuery(document).ready(function(){\n" . implode("\n", $this->js[self::POS_READY]) . "\n});";
         $lines[] = Html::script($js, ['type' => 'text/javascript']);
     }
     return empty($lines) ? '' : implode("\n", $lines);
 }
Exemplo n.º 27
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $hasModel = $this->hasModel();
     if ($hasModel) {
         if (array_key_exists('value', $this->options)) {
             $value = $this->options['value'];
         } else {
             $value = Html::getAttributeValue($this->model, $this->attribute);
         }
     } else {
         $value = $this->value;
     }
     if (is_int($value) || is_string($value) && strlen($value) || $value instanceof DateTime || $value instanceof DateTimeInterface) {
         $formatter = Yii::$app->getFormatter();
         try {
             $altValue = $formatter->asTime($value, $this->altTimeFormat);
             $value = $formatter->asTime($value, $this->timeFormat);
         } catch (InvalidParamException $e) {
             $altValue = $value;
         }
     } else {
         $altValue = $value;
     }
     if ($hasModel) {
         $this->options = array_merge($this->options, ['name' => false, 'value' => $value]);
         $this->altOptions['value'] = $altValue;
         $output = Html::activeTextInput($this->model, $this->attribute, $this->options);
         $output .= Html::activeHiddenInput($this->model, $this->attribute, $this->altOptions);
     } else {
         $output = Html::textInput(false, $value, $this->options);
         $output .= Html::hiddenInput($this->name, $altValue, $this->altOptions);
     }
     $js = 'jQuery(\'#' . $this->options['id'] . '\').timepicker(' . Json::htmlEncode($this->clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         TimePickerAsset::register($view);
         TimePickerLanguageAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
Exemplo n.º 28
0
 public function autoSubmit($formId, $timeout = 1000)
 {
     return Html::script("setTimeout(function(){\n            document.getElementById(\"{$formId}\").submit();}, {$timeout});");
 }
Exemplo n.º 29
0
 /**
  * render file input tag
  * @return string
  */
 private function renderTag()
 {
     $options = ['type' => 'text/plain', 'name' => $this->name, 'id' => $this->id];
     return Html::script($this->ucontent, $options);
 }
Exemplo n.º 30
-1
 /**
  * @inheritdoc
  */
 public function run()
 {
     $hasModel = $this->hasModel();
     if ($hasModel) {
         if (array_key_exists('value', $this->options)) {
             $value = $this->options['value'];
         } else {
             $value = Html::getAttributeValue($this->model, $this->attribute);
         }
     } else {
         $value = $this->value;
     }
     $altValue = $value;
     if ($hasModel) {
         $this->options = array_merge($this->options, ['name' => false, 'value' => $value]);
         $this->altOptions['value'] = $altValue;
         $output = Html::activeTextInput($this->model, $this->attribute, $this->options) . Html::activeHiddenInput($this->model, $this->attribute, $this->altOptions);
     } else {
         $output = Html::textInput(false, $value, $this->options) . Html::hiddenInput($this->name, $altValue, $this->altOptions);
     }
     $js = 'jQuery(\'#' . $this->options['id'] . '\').inputmask(' . Json::htmlEncode($this->clientOptions) . ').keyup(function (event) { jQuery(\'#' . $this->altOptions['id'] . '\').val(jQuery(this).inputmask(\'unmaskedvalue\')); });';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         InputMaskAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }