当前位置: 首页>>代码示例>>PHP>>正文


PHP web\View类代码示例

本文整理汇总了PHP中yii\web\View的典型用法代码示例。如果您正苦于以下问题:PHP View类的具体用法?PHP View怎么用?PHP View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bizConfig

 /**
  *
  * @param View  $view
  * @param array $data
  */
 public static function bizConfig($view, $config = [], $position = View::POS_BEGIN)
 {
     $default = ['delay' => 1000, 'limit' => 20, 'checkStock' => false, 'debug' => YII_ENV == 'dev', 'pullUrl' => \yii\helpers\Url::to(['/master/sources/pull'])];
     $js = "\n var biz = biz || {};" . "\n biz.config = " . Json::encode(ArrayHelper::merge($default, $config)) . ";\n";
     $view->registerJs($js, $position);
     BizAsset::register($view);
 }
开发者ID:jimminababan,项目名称:sangkilbiz3,代码行数:12,代码来源:Helper.php

示例2: addAsset

 /**
  * Adds an asset to the view
  *
  * @param View   $view The View object
  * @param string $file The asset file name
  * @param string $type The asset file type (css or js)
  * @param string $class The class name of the AssetBundle
  *
  * @return void
  */
 protected function addAsset($view, $file, $type, $class)
 {
     if ($type == 'css' || $type == 'js') {
         $asset = $view->getAssetManager();
         $bundle = $asset->bundles[$class];
         if ($type == 'css') {
             $bundle->css[] = $file;
         } else {
             $bundle->js[] = $file;
         }
         $asset->bundles[$class] = $bundle;
         $view->setAssetManager($asset);
     }
 }
开发者ID:slavam,项目名称:placement,代码行数:24,代码来源:WidgetTrait.php

示例3: registerLanguage

    /**
     * @param string $language
     * @param View   $view
     */
    public function registerLanguage($language, $view)
    {
        if (file_exists($this->sourcePath . "/locale/{$language}.js")) {
            $this->js = array_merge($this->js, ['min/locales.min.js']);
            $view->registerJsFile($this->baseUrl . "/locale/{$language}.js");
            $js = <<<JS
moment.locale('{$language}');
JS;
            $view->registerJs($js, View::POS_READY, 'moment-locale-' . $language);
        }
    }
开发者ID:mzdani,项目名称:yii2-daterangepicker,代码行数:15,代码来源:MomentJSAsset.php

示例4: registerAssetFiles

 /**
  * Registers the CSS and JS files with the given view.
  * @param \yii\web\View $view the view that the asset files are to be registered with.
  */
 public function registerAssetFiles($view)
 {
     $manager = $view->getAssetManager();
     foreach ($this->css as $css) {
         $view->registerCssFile($manager->getAssetUrl($this, $css), $this->cssOptions);
     }
     $view->registerJsFile($this->basketJs);
     $jsFiles = [];
     foreach ($this->js as $js) {
         $jsFiles[] = Json::encode(['url' => $manager->getAssetUrl($this, $js)]);
     }
     $view->registerJs(sprintf('basket.require(%s);', implode(",\r\n", $jsFiles)), View::POS_END);
 }
开发者ID:hauntd,项目名称:yii2-basketjs-asset,代码行数:17,代码来源:BasketAssetBundle.php

示例5: applyTo

 /**
  * @param View $view
  */
 public function applyTo(View $view)
 {
     $attributes = $this->getAttributes(null, ['id', 'meta_id']);
     foreach ($attributes as $name => $value) {
         $view->registerMetaTag(['property' => 'twitter:' . $name, 'content' => $value]);
     }
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:10,代码来源:TwitterCard.php

示例6: registerAssetFiles

    /**
     * Registers the CSS and JS files with the given view.
     * @param \yii\web\View $view the view that the asset files are to be registered with.
     */
    public function registerAssetFiles($view)
    {
        if ($this->configuration !== null) {
            $view->registerJs('NProgress.configure(' . Json::encode($this->configuration) . ');');
        }
        $view->registerJs(<<<JS
jQuery(document).on('pjax:start', function() { NProgress.start(); });
jQuery(document).on('pjax:end',   function() { NProgress.done();  });
JS
);
        $view->registerJs(<<<JS
var exceptUrls = [

];

jQuery(document).on('ajaxSend',    function(e, xhr, options) {
    if( \$.inArray( options.url, exceptUrls ) == -1)
        NProgress.start();
});
jQuery(document).on('ajaxComplete', function(e, xhr, options) {
    if( \$.inArray( options.url, exceptUrls ) == -1 )
        NProgress.done();
});
JS
);
        parent::registerAssetFiles($view);
    }
开发者ID:yarisrespect,项目名称:yii2-nprogress,代码行数:31,代码来源:NprogressAsset.php

示例7: registerGlobalMetaTags

 /**
  * Register global meta tags like verifications and so on
  *
  * @param View $view
  */
 protected static function registerGlobalMetaTags($view)
 {
     $globalMetaTags = Yii::$app->cache->get('__globalMetaTags');
     if ($globalMetaTags === false) {
         $globalMetaTags = GlobalMetaTag::find()->andWhere(['active' => 1])->asArray()->all();
         Yii::$app->cache->set('__globalMetaTags', $globalMetaTags, 3600 * 24);
     }
     foreach ($globalMetaTags as $globalTag) {
         $view->registerMetaTag(['name' => $globalTag['name'], 'content' => $globalTag['content']], $globalTag['name']);
     }
 }
开发者ID:webvimark,项目名称:module-seo-panel,代码行数:16,代码来源:SeoPanelHelper.php

示例8: initPlugin

 /**
  * Initializes plugin
  * @param View $view
  * @return $this
  */
 public function initPlugin(View $view, $options = [])
 {
     $options = array_merge(['message' => Yii::t('mgcode/sessionWarning', 'Your session is going to expire at {time}.')], $options);
     $json = Json::encode($options);
     $view->registerJs("\$('#session-warning-modal').sessionWarning({$json});");
     return $this;
 }
开发者ID:mg-code,项目名称:yii2-session-timeout-warning,代码行数:12,代码来源:SessionWarningAsset.php

示例9: sendMessage

 public function sendMessage($to, $file, $params = [])
 {
     $view = new View();
     $message = ['from' => $this->from, 'to' => $to, 'to' => '+8618670366212', 'text' => $view->render($file, $params)];
     return;
     //@todo remove
     $this->getTransport()->send($message);
 }
开发者ID:weiyiyi,项目名称:base,代码行数:8,代码来源:TextMessage.php

示例10: registerScripts

 /**
  * Register scripts
  * @param View $view
  */
 protected function registerScripts(\yii\web\View $view)
 {
     if ($this->clientOptions !== false) {
         $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
         $js = "jQuery('#{$this->id}').fancybox({$options});";
         $view->registerJs($js, View::POS_READY);
     }
 }
开发者ID:bigpaulie,项目名称:yii2-fancybox,代码行数:12,代码来源:Widget.php

示例11: renderRazdelyTipa

/**
 * @param View $view
 * @param KursExtended $kursRecord
 * @param mixed $tip
 * @return string
 */
function renderRazdelyTipa($view, $kursRecord, $tip)
{
    $ret = '';
    $query = $kursRecord->getRazdelyKursaRel()->orderBy('nomer')->where(['tip' => TipRazdelaKursa::asSql($tip)]);
    foreach ($query->all() as $razdelRecord) {
        $ret .= $view->render('_razdel-kursa', compact('razdelRecord'));
    }
    return $ret;
}
开发者ID:tsyrya,项目名称:mybriop,代码行数:15,代码来源:programma-kursa.php

示例12: registerSelect

    /**
     * Registers JS code to help initialize Select2 widgets
     * with access to netis\crud\crud\ActiveController API.
     * @param \yii\web\View $view
     */
    public static function registerSelect($view)
    {
        $script = <<<JavaScript
(function (s2helper, \$, undefined) {
    "use strict";
    s2helper.formatResult = function (result, container, query, escapeMarkup, depth) {
        if (typeof depth == 'undefined') {
            depth = 0;
        }
        var markup = [];
        window.Select2.util.markMatch(result._label, query.term, markup, escapeMarkup);
        return markup.join("");
    };

    s2helper.formatSelection = function (item) {
        return item._label;
    };

    // generates query params
    s2helper.data = function (term, page) {
        return { search: term, page: page };
    };

    // builds query results from ajax response
    s2helper.results = function (data, page) {
        return { results: data.items, more: page < data._meta.pageCount };
    };

    s2helper.getParams = function (element) {
        var primaryKey = element.data('relation-pk');
        if (typeof primaryKey === 'undefined' || primaryKey === null) {
            primaryKey = 'id';
        }

        var params = {search: {}};
        params.search[primaryKey] = element.val();
        return params;
    };

    s2helper.initSingle = function (element, callback) {
        \$.getJSON(element.data('select2').opts.ajax.url, s2helper.getParams(element), function (data) {
            if (typeof data.items[0] != 'undefined') {
                callback(data.items[0]);
            }
        });
    };

    s2helper.initMulti = function (element, callback) {
        \$.getJSON(element.data('select2').opts.ajax.url, s2helper.getParams(element), function (data) {callback(data.items);});
    };
}( window.s2helper = window.s2helper || {}, jQuery ));
JavaScript;
        $view->registerJs($script, \yii\web\View::POS_END, 'netis.s2helper');
        \maddoger\widgets\Select2BootstrapAsset::register($view);
    }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:60,代码来源:FormBuilder.php

示例13: registerPluginEvents

 /**
  * Registers plugin events
  *
  * @param View $view The View object
  */
 protected function registerPluginEvents($view)
 {
     if (!empty($this->pluginEvents)) {
         $id = 'jQuery("#' . $this->options['id'] . '")';
         $js = [];
         foreach ($this->pluginEvents as $event => $handler) {
             $function = new JsExpression($handler);
             $js[] = "{$id}.on('{$event}', {$function});";
         }
         $js = implode("\n", $js);
         $view->registerJs($js);
     }
 }
开发者ID:CBETOBuT,项目名称:yii2-widgets,代码行数:18,代码来源:TypeaheadBasic.php

示例14: registerLocaleInternal

 /**
  * @param \yii\web\View $view
  * @throws \yii\base\InvalidConfigException If file with the locale is not exists.
  */
 public function registerLocaleInternal($view)
 {
     $localeFilePath = $this->tryFindLocale();
     if (YII_DEBUG && !$localeFilePath) {
         throw new InvalidConfigException('Locale file "' . \Yii::$app->language . '" not exists!');
     }
     $manager = $view->getAssetManager();
     $view->registerJsFile($manager->getAssetUrl($this, $this->locale), $this->jsOptions, 'moment-locale-' . $this->locale);
     if ($this->setLocaleOnReady) {
         $js = "moment().locale('" . $this->locale . "');";
         $view->registerJs($js, View::POS_READY, 'moment-set-default-locale');
     }
 }
开发者ID:madand,项目名称:yii2-momentjs,代码行数:17,代码来源:MomentJsLocaleAsset.php

示例15: registerLocaleInternal

 /**
  * @param \yii\web\View $view
  * @throws \yii\base\InvalidConfigException If file with the locale is not exists.
  */
 public function registerLocaleInternal($view)
 {
     $localeFile = strtolower($this->locale) . '.js';
     $localeFilePath = "{$this->sourcePath}/{$localeFile}";
     if (YII_DEBUG && !file_exists($localeFilePath)) {
         throw new InvalidConfigException('Locale file "' . $localeFilePath . '" not exists!');
     }
     $manager = $view->getAssetManager();
     $view->registerJsFile($manager->getAssetUrl($this, $localeFile), $this->jsOptions, 'moment-locale-' . $this->locale);
     if ($this->setLocaleOnReady) {
         $js = "moment.locale('{$this->locale}');'";
         $view->registerJs($js, View::POS_READY, 'moment-set-default-locale');
     }
 }
开发者ID:servocoder,项目名称:yii2-momentjs,代码行数:18,代码来源:MomentJsLocaleAsset.php


注:本文中的yii\web\View类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。