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


PHP modX::regClientCSS方法代码示例

本文整理汇总了PHP中modX::regClientCSS方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::regClientCSS方法的具体用法?PHP modX::regClientCSS怎么用?PHP modX::regClientCSS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在modX的用法示例。


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

示例1: init

 /**
  * Init scripts and add/delete only once
  */
 public function init()
 {
     if (!$this->getOption('init', null, false)) {
         if ($this->getOption('includeScripts')) {
             if ($this->getOption('jQueryPath') != '') {
                 $this->modx->regClientScript($this->getOption('jQueryPath'));
             }
             $this->modx->regClientScript($this->getOption('assetsUrl') . 'js/rememberthis.min.js?v=' . $this->getOption('version'));
             $script = $this->modx->getChunk($this->getOption('scriptTpl'), array('options' => json_encode($this->getOption('scriptOptions'))));
             $this->modx->regClientScript($script);
         }
         if ($this->getOption('includeCss')) {
             $this->modx->regClientCSS($this->getOption('assetsUrl') . 'css/rememberthis.css?v=' . $this->getOption('version'));
         }
         if ($this->getOption('useCookie')) {
             $this->getCookie();
         }
         // Add/remove items to/from the list
         if (isset($_GET[$this->getOption('queryAdd')])) {
             $this->add($_GET[$this->getOption('queryAdd')]);
         }
         if (isset($_GET[$this->getOption('queryDelete')])) {
             $this->delete(intval($_GET[$this->getOption('queryDelete')]));
         }
         $this->setOption('init', true);
     }
 }
开发者ID:Vitaliz,项目名称:RememberThis,代码行数:30,代码来源:rememberthis.class.php

示例2: loadJsCss

    /**
     * Loads javascript and styles for ajax pagination
     *
     */
    public function loadJsCss()
    {
        $assetsUrl = !empty($this->pdoTools->config['assetsUrl']) ? $this->pdoTools->config['assetsUrl'] : MODX_ASSETS_URL . 'components/pdotools/';
        if ($css = trim($this->pdoTools->config['frontend_css'])) {
            $this->modx->regClientCSS(str_replace('[[+assetsUrl]]', $assetsUrl, $css));
        }
        if ($js = trim($this->pdoTools->config['frontend_js'])) {
            $this->modx->regClientScript(str_replace('[[+assetsUrl]]', $assetsUrl, $js));
        }
        $limit = $this->pdoTools->config['limit'] > $this->pdoTools->config['maxLimit'] ? $this->pdoTools->config['maxLimit'] : $this->pdoTools->config['limit'];
        $moreChunk = $this->modx->getOption('ajaxTplMore', $this->pdoTools->config, '@INLINE <button class="btn btn-default btn-more">[[%pdopage_more]]</button>');
        $moreTpl = str_replace('"', '\\"', $this->pdoTools->getChunk($moreChunk, array('limit' => $limit)));
        $config = '{
			wrapper: "' . $this->modx->getOption('ajaxElemWrapper', $this->pdoTools->config, '#pdopage') . '",
			rows: "' . $this->modx->getOption('ajaxElemRows', $this->pdoTools->config, '#pdopage .rows') . '",
			pagination: "' . $this->modx->getOption('ajaxElemPagination', $this->pdoTools->config, '#pdopage .pagination') . '",
			link: "' . $this->modx->getOption('ajaxElemLink', $this->pdoTools->config, '#pdopage .pagination a') . '",
			more: "' . $this->modx->getOption('ajaxElemMore', $this->pdoTools->config, '#pdopage .btn-more') . '",
			moreTpl: "' . $moreTpl . '",
			mode: "' . $this->pdoTools->config['ajaxMode'] . '",
			pageVarKey: "' . $this->pdoTools->config['pageVarKey'] . '",
			pageLimit: ' . $limit . ',
			assetsUrl: "' . $assetsUrl . '"
		}';
        $this->modx->regClientStartupScript('<script type="text/javascript">pdoPage = {callbacks: {}, keys: {}};</script>', true);
        $this->modx->regClientScript('<script type="text/javascript">pdoPage.initialize(' . $config . ');</script>', true);
    }
开发者ID:Piterden,项目名称:modx_testfloor,代码行数:31,代码来源:pdopage.class.php

示例3: initialize

 /**
  * Initializes component into different contexts.
  *
  * @param string $ctx The context to load. Defaults to web.
  * @param array $scriptProperties
  *
  * @return boolean
  */
 public function initialize($ctx = 'web', $scriptProperties = array())
 {
     $this->config = array_merge($this->config, $scriptProperties);
     $this->config['ctx'] = $ctx;
     if (empty($this->initialized[$ctx])) {
         $properties = $this->ms2Gallery->getSourceProperties();
         $config_js = array('ctx' => $ctx, 'jsUrl' => $this->config['jsUrl'] . 'web/', 'cssUrl' => $this->config['cssUrl'] . 'web/', 'actionUrl' => $this->config['actionUrl'], 'source' => array('size' => !empty($properties['maxUploadSize']) ? $properties['maxUploadSize'] : 3145728, 'height' => !empty($properties['maxUploadHeight']) ? $properties['maxUploadHeight'] : 1080, 'width' => !empty($properties['maxUploadWidth']) ? $properties['maxUploadWidth'] : 1920, 'extensions' => !empty($properties['allowedFileTypes']) ? $properties['allowedFileTypes'] : 'jpg,jpeg,png,gif'));
         $this->modx->regClientStartupScript('<script type="text/javascript">ms2GalleryFormConfig=' . $this->modx->toJSON($config_js) . '</script>', true);
         $css = !empty($this->config['frontend_css']) ? $this->config['frontend_css'] : $this->config['cssUrl'] . 'web/default.css';
         if (!empty($css) && preg_match('/\\.css/i', $css)) {
             $this->modx->regClientCSS($css);
         }
         $js = !empty($this->config['frontend_js']) ? $this->config['frontend_js'] : $this->config['jsUrl'] . 'web/default.js';
         if (!empty($js) && preg_match('/\\.js/i', $js)) {
             $this->modx->regClientScript($js);
         }
         $this->modx->regClientScript($this->config['jsUrl'] . 'web/lib/plupload/plupload.full.min.js');
         $this->modx->regClientScript($this->config['jsUrl'] . 'web/files.js');
         $lang = $this->modx->getOption('cultureKey');
         if ($lang != 'en' && file_exists($this->config['jsUrl'] . 'web/lib/plupload/i18n/' . $lang . '.js')) {
             $this->modx->regClientScript($this->config['jsUrl'] . 'web/lib/plupload/i18n/' . $lang . '.js');
         }
         $this->initialized[$ctx] = true;
     }
     return true;
 }
开发者ID:bendasvadim,项目名称:ms2GalleryForm,代码行数:34,代码来源:ms2galleryform.class.php

示例4: initialize

    /**
     * Initializes mSearch2 into different contexts.
     *
     * @access public
     * @param string $ctx The context to load. Defaults to web.
     *
     * @return boolean
     */
    public function initialize($ctx = 'web', $scriptProperties = array())
    {
        switch ($ctx) {
            case 'mgr':
                if (!$this->modx->loadClass('msearch2.request.mSearch2ControllerRequest', $this->config['modelPath'], true, true)) {
                    return 'Could not load controller request handler.';
                }
                $this->request = new mSearch2ControllerRequest($this);
                return $this->request->handleRequest();
                break;
            default:
                $this->config = array_merge($this->config, $scriptProperties);
                $this->config['ctx'] = $ctx;
                if (!empty($this->initialized[$ctx])) {
                    return true;
                }
                if (!defined('MODX_API_MODE') || !MODX_API_MODE) {
                    $config = $this->makePlaceholders($this->config);
                    if ($css = $this->modx->getOption('mse2_frontend_css')) {
                        $this->modx->regClientCSS(str_replace($config['pl'], $config['vl'], $css));
                    }
                    if ($js = trim($this->modx->getOption('mse2_frontend_js'))) {
                        $this->modx->regClientStartupScript(str_replace('					', '', '
						<script type="text/javascript">
						mSearch2Config = {
							cssUrl: "' . $this->config['cssUrl'] . 'web/"
							,jsUrl: "' . $this->config['jsUrl'] . 'web/"
							,actionUrl: "' . $this->config['actionUrl'] . '"
							,pageId: ' . $this->modx->resource->id . '
							,filter_delimeter: "' . $this->config['filter_delimeter'] . '"
							,method_delimeter: "' . $this->config['method_delimeter'] . '"
							,values_delimeter: "' . $this->config['values_delimeter'] . '"
						};
						</script>
					'), true);
                        if (!empty($js) && preg_match('/\\.js$/i', $js)) {
                            $this->modx->regClientScript(str_replace('							', '', '
							<script type="text/javascript">
							if(typeof jQuery == "undefined") {
								document.write("<script src=\\"' . $this->config['jsUrl'] . 'web/lib/jquery.min.js\\" type=\\"text/javascript\\"><\\/script>");
							}
							</script>
							'), true);
                            $this->modx->regClientScript(str_replace($config['pl'], $config['vl'], $js));
                        }
                    }
                }
                $this->initialized[$ctx] = true;
        }
        return true;
    }
开发者ID:bendasvadim,项目名称:mSearch2,代码行数:59,代码来源:msearch2.class.php

示例5: loadJsCss

 /**
  * Independent registration of css and js
  *
  * @param string $objectName Name of object to initialize in javascript
  */
 public function loadJsCss($objectName = 'AjaxForm')
 {
     if ($css = trim($this->config['frontend_css'])) {
         if (preg_match('/\\.css/i', $css)) {
             $this->modx->regClientCSS(str_replace('[[+assetsUrl]]', $this->config['assetsUrl'], $css));
         }
     }
     if ($js = trim($this->config['frontend_js'])) {
         if (preg_match('/\\.js$/i', $js)) {
             $this->modx->regClientScript(str_replace('[[+assetsUrl]]', $this->config['assetsUrl'], $js));
         }
     }
     $config = $this->modx->toJSON(array('assetsUrl' => $this->config['assetsUrl'], 'actionUrl' => str_replace('[[+assetsUrl]]', $this->config['assetsUrl'], $this->config['actionUrl']), 'closeMessage' => $this->config['closeMessage'], 'formSelector' => "form.{$this->config['formSelector']}", 'pageId' => !empty($this->modx->resource) ? $this->modx->resource->get('id') : 0));
     $this->modx->regClientScript('<script type="text/javascript">' . trim($objectName) . '.initialize(' . $config . ');</script>', true);
 }
开发者ID:vashot,项目名称:AjaxForm,代码行数:20,代码来源:ajaxform.class.php

示例6: initialize

    /**
     * Initializes AjaxForm into different contexts.
     *
     * @param string $ctx The context to load. Defaults to web.
     * @param array $scriptProperties array with additional parameters
     *
     * @return boolean
     */
    public function initialize($ctx = 'web', $scriptProperties = array())
    {
        $this->config = array_merge($this->config, $scriptProperties);
        $this->config['ctx'] = $ctx;
        if (!empty($this->initialized[$ctx])) {
            return true;
        }
        switch ($ctx) {
            case 'mgr':
                break;
            default:
                if (!defined('MODX_API_MODE') || !MODX_API_MODE) {
                    if ($css = trim($this->config['frontend_css'])) {
                        if (preg_match('/\\.css/i', $css)) {
                            $this->modx->regClientCSS(str_replace('[[+assetsUrl]]', $this->config['assetsUrl'], $css));
                        }
                    }
                    $config_js = preg_replace(array('/^\\n/', '/\\t{6}/'), '', '
						afConfig = {
							assetsUrl: "' . $this->config['assetsUrl'] . '"
							,actionUrl: "' . str_replace('[[+assetsUrl]]', $this->config['assetsUrl'], $this->config['actionUrl']) . '"
							,closeMessage: "' . $this->config['closeMessage'] . '"
							,formSelector: "form.' . $this->config['formSelector'] . '"
						};
					');
                    if (file_put_contents($this->config['assetsPath'] . 'js/config.js', $config_js)) {
                        $this->modx->regClientStartupScript($this->config['assetsUrl'] . 'js/config.js');
                    } else {
                        $this->modx->regClientStartupScript("<script type=\"text/javascript\">\n" . $config_js . "\n</script>", true);
                    }
                    if ($js = trim($this->config['frontend_js'])) {
                        if (preg_match('/\\.js/i', $js)) {
                            $this->modx->regClientScript(preg_replace(array('/^\\n/', '/\\t{7}/'), '', '
								<script type="text/javascript">
									if(typeof jQuery == "undefined") {
										document.write("<script src=\\"' . $this->config['assetsUrl'] . 'js/lib/jquery.min.js\\" type=\\"text/javascript\\"><\\/script>");
									}
								</script>
							'), true);
                            $this->modx->regClientScript(str_replace('[[+assetsUrl]]', $this->config['assetsUrl'], $js));
                        }
                    }
                }
                $this->initialized[$ctx] = true;
                break;
        }
        return true;
    }
开发者ID:vasia123,项目名称:AjaxForm,代码行数:56,代码来源:ajaxform.class.php

示例7: initialize

 /**
  * Initializes mSearch2 into different contexts.
  *
  * @param string $ctx The context to load. Defaults to web.
  * @param array $scriptProperties
  *
  * @return boolean
  */
 public function initialize($ctx = 'web', $scriptProperties = array())
 {
     switch ($ctx) {
         case 'mgr':
             if (!$this->modx->loadClass('msearch2.request.mSearch2ControllerRequest', $this->config['modelPath'], true, true)) {
                 return 'Could not load controller request handler.';
             }
             $this->request = new mSearch2ControllerRequest($this);
             return $this->request->handleRequest();
             break;
         default:
             $this->config = array_merge($this->config, $scriptProperties);
             $this->config['ctx'] = $ctx;
             if (!defined('MODX_API_MODE') || !MODX_API_MODE) {
                 $config = $this->makePlaceholders($this->config);
                 if ($css = trim($this->modx->getOption('mse2_frontend_css'))) {
                     $this->modx->regClientCSS(str_replace($config['pl'], $config['vl'], $css));
                 }
                 if ($js = trim($this->modx->getOption('mse2_frontend_js'))) {
                     $this->modx->regClientScript(str_replace($config['pl'], $config['vl'], $js));
                 }
             }
     }
     return true;
 }
开发者ID:svyatoslavteterin,项目名称:belton.by,代码行数:33,代码来源:msearch2.class.php

示例8: output

 /**
  * Output the form inputs.
  *
  * @access public
  * @return string The output
  */
 public function output()
 {
     if ($this->config['addJquery']) {
         $this->modx->regClientScript('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
     }
     if ($this->config['addCss']) {
         $this->modx->regClientCSS($this->config['cssUrl'] . 'ajaxupload.css');
     }
     if ($this->config['addJscript']) {
         $this->modx->regClientScript($this->config['jsUrl'] . 'fileuploader.js');
         $this->modx->regClientScript($this->config['jsUrl'] . 'ajaxupload.js');
     }
     $this->modx->smarty->assign('_lang', $this->modx->lexicon->fetch('ajaxupload.', true));
     $this->modx->smarty->assign('params', $this->config);
     if (empty($this->config['filecopierPath'])) {
         $this->modx->regClientScript($this->modx->smarty->fetch($this->config['templatesPath'] . 'web/script.tpl'), true);
     } else {
         $this->modx->regClientStartupScript($this->modx->smarty->fetch($this->config['templatesPath'] . 'web/elfinder.tpl'), true);
     }
     // preload files from $_SESSION
     $itemList = '';
     if (is_array($_SESSION['ajaxupload'][$this->config['uid']])) {
         $itemList = $this->loadFiles($_SESSION['ajaxupload'][$this->config['uid']]);
     }
     $this->modx->smarty->assign('items', $itemList);
     return $this->modx->smarty->fetch($this->config['templatesPath'] . 'web/uploadSection.tpl');
 }
开发者ID:Vitaliz,项目名称:AjaxUpload,代码行数:33,代码来源:ajaxupload.class.php

示例9: loadJsCss

 /**
  * Loads javascript and styles for ajax pagination
  *
  */
 public function loadJsCss()
 {
     $assetsUrl = !empty($this->pdoTools->config['assetsUrl']) ? $this->pdoTools->config['assetsUrl'] : MODX_ASSETS_URL . 'components/pdotools/';
     if ($css = trim($this->pdoTools->config['frontend_css'])) {
         $this->modx->regClientCSS(str_replace('[[+assetsUrl]]', $assetsUrl, $css));
     }
     if ($js = trim($this->pdoTools->config['frontend_js'])) {
         $this->modx->regClientScript(str_replace('[[+assetsUrl]]', $assetsUrl, $js));
     }
     $ajaxHistory = $this->pdoTools->config['ajaxHistory'] === '' ? !in_array($this->pdoTools->config['ajaxMode'], array('scroll', 'button')) : !empty($this->pdoTools->config['ajaxHistory']);
     $limit = $this->pdoTools->config['limit'] > $this->pdoTools->config['maxLimit'] ? $this->pdoTools->config['maxLimit'] : $this->pdoTools->config['limit'];
     $moreChunk = $this->modx->getOption('ajaxTplMore', $this->pdoTools->config, '@INLINE <button class="btn btn-default btn-more">[[%pdopage_more]]</button>');
     $moreTpl = $this->pdoTools->getChunk($moreChunk, array('limit' => $limit));
     $hash = sha1($this->modx->toJSON($this->pdoTools->config));
     $_SESSION['pdoPage'][$hash] = $this->pdoTools->config;
     $config = $this->modx->toJSON(array('wrapper' => $this->modx->getOption('ajaxElemWrapper', $this->pdoTools->config, '#pdopage'), 'rows' => $this->modx->getOption('ajaxElemRows', $this->pdoTools->config, '#pdopage .rows'), 'pagination' => $this->modx->getOption('ajaxElemPagination', $this->pdoTools->config, '#pdopage .pagination'), 'link' => $this->modx->getOption('ajaxElemLink', $this->pdoTools->config, '#pdopage .pagination a'), 'more' => $this->modx->getOption('ajaxElemMore', $this->pdoTools->config, '#pdopage .btn-more'), 'moreTpl' => $moreTpl, 'mode' => $this->pdoTools->config['ajaxMode'], 'history' => (int) $ajaxHistory, 'pageVarKey' => $this->pdoTools->config['pageVarKey'], 'pageLimit' => $limit, 'assetsUrl' => $assetsUrl, 'connectorUrl' => rtrim($assetsUrl, '/') . '/connector.php', 'pageId' => $this->modx->resource->id, 'hash' => $hash));
     $this->modx->regClientStartupScript('<script type="text/javascript">pdoPage = {callbacks: {}, keys: {}, configs: {}};</script>', true);
     $this->modx->regClientScript('<script type="text/javascript">pdoPage.initialize(' . $config . ');</script>', true);
 }
开发者ID:Jako,项目名称:pdoTools,代码行数:23,代码来源:pdopage.class.php

示例10: __construct

 public function __construct(modX &$modx, $config = array())
 {
     require_once $modx->getOption('repoman.core_path', '', MODX_CORE_PATH . 'components/repoman/') . 'vendor/autoload.php';
     $controller = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'home';
     if (!in_array($controller, $this->valid_controllers)) {
         $_REQUEST['action'] = '404';
     }
     $assets_url = $modx->getOption('repoman.assets_url', '', MODX_ASSETS_URL . 'components/repoman/');
     $modx->regClientCSS($assets_url . 'style.css');
     parent::__construct($modx, $config);
 }
开发者ID:carnevlu,项目名称:repoman,代码行数:11,代码来源:repomanmanagercontroller.class.php

示例11: initialize

    /**
     * Initializes component into different contexts.
     *
     * @param string $ctx The context to load. Defaults to web.
     * @param array $scriptProperties Properties for initialization.
     *
     * @return bool
     */
    public function initialize($ctx = 'web', $scriptProperties = array())
    {
        $this->config = array_merge($this->config, $scriptProperties);
        $this->config['ctx'] = $ctx;
        if (!empty($this->initialized[$ctx])) {
            return true;
        }
        switch ($ctx) {
            case 'mgr':
                break;
            default:
                if (!MODX_API_MODE) {
                    $config = $this->makePlaceholders($this->config);
                    if ($css = $this->modx->getOption('uf_frontend_css')) {
                        $this->modx->regClientCSS(str_replace($config['pl'], $config['vl'], $css));
                    }
                    if ($js = $this->modx->getOption('uf_frontend_js')) {
                        $time = time();
                        $this->modx->regClientStartupScript(str_replace('					', '', '
						<script type="text/javascript">
							UploadifyConfig = {
								jsUrl: "' . $this->config['jsUrl'] . 'web/",
								actionUrl: "' . $this->config['actionUrl'] . '",
								cssUrl: "' . $this->config['cssUrl'] . 'web/",
								uploadiFive: ' . $this->config['uploadiFive'] . '
							};
							if(typeof jQuery == "undefined") {
								document.write("<script src=\\""+UploadifyConfig.jsUrl+"lib/jquery-1.9.1.min.js\\" type=\\"text/javascript\\"><\\/script>");
							}
						</script>
						'), true);
                        $this->modx->regClientScript(str_replace($config['pl'], $config['vl'], $js));
                    }
                }
                $this->initialized[$ctx] = true;
                break;
        }
        return true;
    }
开发者ID:bendasvadim,项目名称:modx-uploadify,代码行数:47,代码来源:uploadify.class.php

示例12: regClientCSS

 /**
  * @param $src
  * @param null $media
  */
 public function regClientCSS($src, $media = null)
 {
     if (empty($this->modx->config['fenom_sjscripts'])) {
         $this->modx->config['fenom_sjscripts'] = array();
     }
     $registered = count($this->modx->sjscripts);
     $this->modx->regClientCSS($src, $media);
     $this->modx->config['fenom_sjscripts'] = array_replace($this->modx->config['fenom_sjscripts'], array_slice($this->modx->sjscripts, $registered, null, true));
     if (empty($this->modx->config['fenom_loadedscripts'])) {
         $this->modx->config['fenom_loadedscripts'] = array();
     }
     $this->modx->config['fenom_loadedscripts'][$src] = true;
 }
开发者ID:Jako,项目名称:pdoTools,代码行数:17,代码来源:_micromodx.php

示例13: includeScriptAssets

 /**
  * Render supporting javascript to try and help it work with MIGX etc
  */
 public function includeScriptAssets()
 {
     $vers = $this->modx->getVersionData();
     if ($vers['major_version'] >= 3) {
         $this->modx->regClientCSS($this->options['assetsUrl'] . 'mgr/css/imageplus.css');
     } else {
         $this->modx->regClientCSS($this->options['assetsUrl'] . 'mgr/css/imageplus-22.css');
     }
     $this->modx->regClientCSS($this->options['assetsUrl'] . 'mgr/css/jquery/jquery.jcrop.min.css');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/imageplus.js');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/imageplus.panel.input.js');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/imageplus.window.editor.js');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/imageplus.migx_renderer.js');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/tools/JSON2.js');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/jquery/jquery.min.js');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/jquery/jquery.jcrop.min.js');
     $this->modx->regClientStartupScript($this->options['assetsUrl'] . 'mgr/js/imageplus.jquery.imagecrop.js');
     $this->modx->regClientStartupHTMLBlock('<script type="text/javascript">' . ' ImagePlus.config = ' . json_encode($this->options) . ';' . ' var $jIP = jQuery.noConflict();' . '</script>');
 }
开发者ID:Bruno17,项目名称:ImagePlus,代码行数:22,代码来源:imageplus.class.php

示例14: regClientCSS

 /**
  * @param $src
  * @param null $media
  */
 public function regClientCSS($src, $media = null)
 {
     $this->modx->regClientCSS($src, $media);
 }
开发者ID:suasti,项目名称:pdoTools,代码行数:8,代码来源:_micromodx.php

示例15: initialize

    /**
     * Initializes component into different contexts.
     *
     * @param string $ctx The context to load. Defaults to web.
     * @param array $scriptProperties Properties for initialization.
     *
     * @return bool
     */
    public function initialize($ctx = 'web', $scriptProperties = array())
    {
        $this->config = array_merge($this->config, $scriptProperties);
        $this->config['ctx'] = $ctx;
        if (!empty($this->initialized[$ctx])) {
            return true;
        }
        switch ($ctx) {
            case 'mgr':
                break;
            default:
                if (!defined('MODX_API_MODE') || !MODX_API_MODE) {
                    $config = $this->makePlaceholders($this->config);
                    if ($css = $this->modx->getOption('ms2_frontend_css')) {
                        $this->modx->regClientCSS(str_replace($config['pl'], $config['vl'], $css));
                    }
                    $config_js = preg_replace(array('/^\\n/', '/\\t{5}/'), '', '
					miniShop2 = {};
					miniShop2Config = {
						cssUrl: "' . $this->config['cssUrl'] . 'web/"
						,jsUrl: "' . $this->config['jsUrl'] . 'web/"
						,imagesUrl: "' . $this->config['imagesUrl'] . 'web/"
						,actionUrl: "' . $this->config['actionUrl'] . '"
						,ctx: "' . $this->modx->context->get('key') . '"
						,close_all_message: "' . $this->modx->lexicon('ms2_message_close_all') . '"
						,price_format: ' . $this->modx->getOption('ms2_price_format', null, '[2, ".", " "]') . '
						,price_format_no_zeros: ' . $this->modx->getOption('ms2_price_format_no_zeros', null, true) . '
						,weight_format: ' . $this->modx->getOption('ms2_weight_format', null, '[3, ".", " "]') . '
						,weight_format_no_zeros: ' . $this->modx->getOption('ms2_weight_format_no_zeros', null, true) . '
						,callbacksObjectTemplate: function() {
							return {
								before: function() {/*return false to prevent send data*/}
								,response: {success: function(response) {},error: function(response) {}}
								,ajax: {done: function(xhr) {},fail: function(xhr) {},always: function(xhr) {}}
							};
						}
					};
					miniShop2.Callbacks = miniShop2Config.Callbacks = {
						Cart: {
							add: miniShop2Config.callbacksObjectTemplate()
							,remove: miniShop2Config.callbacksObjectTemplate()
							,change: miniShop2Config.callbacksObjectTemplate()
							,clean: miniShop2Config.callbacksObjectTemplate()
						}
						,Order: {
							add: miniShop2Config.callbacksObjectTemplate()
							,getcost: miniShop2Config.callbacksObjectTemplate()
							,clean: miniShop2Config.callbacksObjectTemplate()
							,submit: miniShop2Config.callbacksObjectTemplate()
							,getRequired: miniShop2Config.callbacksObjectTemplate()
						}
					};');
                    if (file_put_contents($this->config['jsPath'] . 'web/config.js', $config_js)) {
                        $this->modx->regClientStartupScript($this->config['jsUrl'] . 'web/config.js');
                    } else {
                        $this->modx->regClientStartupScript("<script type=\"text/javascript\">\n" . $config_js . "\n</script>", true);
                    }
                    if ($js = trim($this->modx->getOption('ms2_frontend_js'))) {
                        if (!empty($js) && preg_match('/\\.js/i', $js)) {
                            $this->modx->regClientScript(preg_replace(array('/^\\n/', '/\\t{7}/'), '', '
							<script type="text/javascript">
								if(typeof jQuery == "undefined") {
									document.write("<script src=\\"' . $this->config['jsUrl'] . 'web/lib/jquery.min.js\\" type=\\"text/javascript\\"><\\/script>");
								}
							</script>
							'), true);
                            $this->modx->regClientScript(str_replace($config['pl'], $config['vl'], $js));
                        }
                    }
                }
                require_once dirname(__FILE__) . '/mscarthandler.class.php';
                $cart_class = $this->modx->getOption('ms2_cart_handler_class', null, 'msCartHandler');
                if ($cart_class != 'msCartHandler') {
                    $this->loadCustomClasses('cart');
                }
                if (!class_exists($cart_class)) {
                    $cart_class = 'msCartHandler';
                }
                $this->cart = new $cart_class($this, $this->config);
                if (!$this->cart instanceof msCartInterface || $this->cart->initialize($ctx) !== true) {
                    $this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not initialize miniShop2 cart handler class: "' . $cart_class . '"');
                    return false;
                }
                require_once dirname(__FILE__) . '/msorderhandler.class.php';
                $order_class = $this->modx->getOption('ms2_order_handler_class', null, 'msOrderHandler');
                if ($order_class != 'msOrderHandler') {
                    $this->loadCustomClasses('order');
                }
                if (!class_exists($order_class)) {
                    $order_class = 'msOrderHandler';
                }
                $this->order = new $order_class($this, $this->config);
//.........这里部分代码省略.........
开发者ID:bendasvadim,项目名称:miniShop2,代码行数:101,代码来源:minishop2.class.php


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