Beispiel #1
0
 public function run()
 {
     Assets::register($this->getView());
     echo Html::beginTag('div', $this->containerOptions);
     if ($this->hasModel()) {
         echo Html::activeTextarea($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textarea($this->name, $this->value, $this->options);
     }
     echo Html::endTag('div');
     $js = ['mihaildev.ckEditor.registerOnChange(' . Json::encode($this->options['id']) . ');'];
     if (isset($this->editorOptions['filebrowserUploadUrl'])) {
         $js[] = "mihaildev.ckEditor.registerCsrf();";
     }
     if (!isset($this->editorOptions['on']['instanceReady'])) {
         $this->editorOptions['on']['instanceReady'] = new JsExpression("function( ev ){" . implode(' ', $js) . "}");
     }
     if ($this->_inline) {
         $JavaScript = "CKEDITOR.inline(";
         $JavaScript .= Json::encode($this->options['id']);
         $JavaScript .= empty($this->editorOptions) ? '' : ', ' . Json::encode($this->editorOptions);
         $JavaScript .= ");";
         $JavaScript .= "\$('#" . $this->options['id'] . "').on('change', function() {\n                function periodicData(data) {\n                    \$.ajax({\n                        type: 'POST',\n                        url: '" . $this->dataUrlEdit . "',\n                        dataType: 'json',\n                        data: {data: data,'attr':'" . $this->name . "'},\n                        beforeSend: function (data) {},\n                        success: function (data) {console.log(data)},\n                        error: function (xhr, ajaxOptions, thrownError) {\n                            alert(xhr.status);\n                            alert(thrownError);\n                        },\n                        complete: function (data) {}\n                    });\n                }\n                periodicData(\$(this).val());\n            });";
         $this->getView()->registerJs($JavaScript, View::POS_END);
         $this->getView()->registerCss('#' . $this->containerOptions['id'] . ', #' . $this->containerOptions['id'] . ' .cke_textarea_inline{height: ' . $this->editorOptions['height'] . 'px;}');
     } else {
         $JavaScript = "CKEDITOR.replace(";
         $JavaScript .= Json::encode($this->options['id']);
         $JavaScript .= empty($this->editorOptions) ? '' : ', ' . Json::encode($this->editorOptions);
         $JavaScript .= ");";
         $this->getView()->registerJs($JavaScript, View::POS_END);
     }
 }
Beispiel #2
0
 public function run()
 {
     if ($this->hasModel()) {
         $replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
     }
     $this->buttonOptions = array_merge($this->buttonOptions, ['class' => 'btn btn-default add-file', 'type' => 'button']);
     $replace['{button}'] = Html::tag('span', Html::tag('button', Html::tag('i', '', ['class' => 'fa fa-file-image-o']), $this->buttonOptions), ['class' => 'input-group-btn']);
     echo strtr($this->template, $replace);
     AssetsCallBack::register($this->getView());
     if (!empty($this->multiple)) {
         $this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(files, id){ var _f = []; for (var i in files) { _f.push(files[i].url); } \$('#' + id).val(_f.join(', ')).trigger('change', [files, id]); return true;}); \$(document).on('click','#" . $this->buttonOptions['id'] . "', function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
     } else {
         $this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){ \$('#' + id).val(file.url).trigger('change', [file, id]);; return true;}); \$(document).on('click', '#" . $this->buttonOptions['id'] . "', function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
     }
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function escape($text)
 {
     return Html::encode($text);
 }
Beispiel #4
0
 * File name: _item.php
 * @var $model \app\modules\content\models\ContentArticles;
 */
?>
<div class="container">
    <article class="main-news-article wow fadeIn" data-wow-offset="50" data-wow-duration="1.5s" data-wow-delay="0s">
        <div class="main-news-article__image col-sm-4">
            <img src="<?php 
echo $model->getUploadUrl('image');
?>
" alt="<?php 
echo $model->title;
?>
">
        </div>
        <div class="main-news-article__text col-sm-8">
            <h4><?php 
echo $model->title;
?>
</h4>
            <p><?php 
echo \yii\helpers\StringHelper::truncateWords(strip_tags($model->content), 20);
?>
</p>
            <?php 
echo \app\modules\admin\widgets\Html::a(Yii::t('text', 'Read more...'), ['/content/article/view', 'catslug' => $model->category->slug, 'slug' => $model->slug]);
?>
        </div>
    </article>
</div>
Beispiel #5
0
<section class="pag-nav">
    <div class="container pag-con">
        <nav class="pag-con__nav" aria-label="Page navigation">
            <ul class="pager news">
                <?php 
if ($model->getPrevious()) {
    ?>
                <li class="pre-nav">
                    <?php 
    echo Html::a('&lt;&lt;&lt; ' . Yii::t('content', 'previous news'), ['/content/article/view', 'catslug' => $model->previous->category->slug, 'slug' => $model->previous->slug]);
    ?>
                </li>
                <?php 
}
?>
                <?php 
if ($model->getNext()) {
    ?>
                <li class="next-nav">
                    <?php 
    echo Html::a(Yii::t('content', 'next news') . ' &gt;&gt;&gt;', ['/content/article/view', 'catslug' => $model->next->category->slug, 'slug' => $model->next->slug]);
    ?>
                </li>
                <?php 
}
?>
            </ul>
        </nav>
    </div>
</section>
Beispiel #6
0
    ?>
                        </tbody>
                    </table>
                    <p class="empty" style="display: <?php 
    echo count($model->medias) ? 'none' : 'block';
    ?>
;"><?php 
    echo Yii::t('admin', 'No photos uploaded yet');
    ?>
.</p>
                    <div class="divform" data-url="<?php 
    echo Url::to(['/admin/media/upload', 'id' => $model->id, 'type' => 'article']);
    ?>
">
                        <?php 
    echo Html::fileInput('', null, ['id' => 'photo-file', 'class' => 'hidden', 'multiple' => 'multiple']);
    ?>
                    </div>
                <?php 
} else {
    ?>
                    <?php 
    echo Yii::t('admin', 'First you need to save the item, and then the form appears with images');
    ?>
                <?php 
}
?>
            </div>
            <!-- /.tab-pane -->
        </div>
        <!-- /.tab-content -->
Beispiel #7
0
        <div class="news-photo">
            <a href="<?php 
echo Url::to(['/content/article/view', 'catslug' => $model->category->slug, 'slug' => $model->slug]);
?>
">
                <img src="<?php 
echo $model->getUploadUrl('image');
?>
" alt="<?php 
echo $model->title;
?>
">
            </a>
        </div>
    </div>

    <div class="col-sm-7">
        <h3>
            <?php 
echo Html::a($model->title, ['/content/article/view', 'catslug' => $model->category->slug, 'slug' => $model->slug]);
?>
        </h3>

        <p>
            <?php 
echo StringHelper::truncateWords(strip_tags($model->content), 20);
?>
        </p>
    </div>
</div>
Beispiel #8
0
                        <?php 
}
?>
                    </div>
                    <!-- /.lockscreen-image -->

                    <!-- lockscreen credentials (contains the form) -->
                    <?php 
$form = ActiveForm::begin(['action' => \yii\helpers\Url::to(['/admin/user/user/login']), 'options' => ['class' => 'lockscreen-credentials']]);
?>
                    <?php 
echo \app\modules\admin\widgets\Html::activeHiddenInput($model, 'username');
?>
                        <div class="input-group">
                            <?php 
echo Html::activeInput('password', $model, 'password', ['placeholder' => Yii::t('admin', 'Password'), 'class' => 'form-control']);
?>

                            <div class="input-group-btn">
                                <button type="submit" class="btn"><i class="fa fa-arrow-right text-muted"></i></button>
                            </div>
                        </div>
                    <?php 
ActiveForm::end();
?>
                    <!-- /.lockscreen credentials -->
                </div>
                <!-- /.lockscreen-item -->
                <div class="help-block text-center">
                    <?php 
echo Yii::t('user', 'Enter your password to retrieve your session');
Beispiel #9
0
 /**
  * @inheritdoc
  */
 protected function renderItem($item)
 {
     $item['badgeOptions'] = isset($item['badgeOptions']) ? $item['badgeOptions'] : [];
     if (!ArrayHelper::getValue($item, 'badgeOptions.class')) {
         $bg = isset($item['badgeBgClass']) ? $item['badgeBgClass'] : $this->badgeBgClass;
         $item['badgeOptions']['class'] = $this->badgeClass . ' ' . $bg;
     }
     if (isset($item['items']) && !isset($item['right-icon'])) {
         $item['right-icon'] = $this->parentRightIcon;
     }
     if (isset($item['url'])) {
         $template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
         return strtr($template, ['{badge}' => isset($item['badge']) && $item['badge'] > 0 ? Html::tag('small', $item['badge'], $item['badgeOptions']) : '', '{icon}' => isset($item['icon']) ? $item['icon'] : '', '{right-icon}' => isset($item['right-icon']) ? $item['right-icon'] : '', '{url}' => Url::to($item['url']), '{label}' => $item['label']]);
     } else {
         $template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
         return strtr($template, ['{badge}' => isset($item['badge']) ? Html::tag('small', $item['badge'], $item['badgeOptions']) : '', '{icon}' => isset($item['icon']) ? $item['icon'] : '', '{right-icon}' => isset($item['right-icon']) ? $item['right-icon'] : '', '{label}' => $item['label']]);
     }
 }
Beispiel #10
0
 public function actionGetSettings($file, $id = null, $lang = null)
 {
     if (Yii::$app->request->isAjax) {
         $return = '';
         $lang === null ? $lang = Language::findOne(Yii::$app->language) : ($lang = Language::findOne($lang));
         $model = Text::findOne($id);
         if ($model) {
             $model->language = $lang->language_id;
             $model->settingsAfterLanguage();
         }
         if ($id !== null && $model) {
             if ($model->settings && is_array($model->settings) && count($model->settings) && $file == $model->layout) {
                 $model->settings = array_merge($this->getLayouts($file)[0]['settings'], $model->settings);
                 foreach ($model->settings as $key => $setting) {
                     $return .= Html::settingField($key, $setting, 'text');
                 }
             } else {
                 foreach ($this->getLayouts($file)[0]['settings'] as $key => $setting) {
                     $return .= Html::settingField($key, $setting, 'text');
                 }
             }
         } else {
             foreach ($this->getLayouts($file)[0]['settings'] as $key => $setting) {
                 $return .= Html::settingField($key, $setting, 'text');
             }
         }
         return $this->renderAjax('get-settings', ['return' => $return]);
     } else {
         throw new NotFoundHttpException();
     }
 }