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


PHP HtmlHelper::js方法代码示例

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


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

示例1: startup

    function startup(&$controller)
    {
        $this->c =& $controller;
        if (!$this->runPlugin($controller)) {
            return false;
        }
        // Initialize vars
        $center = array();
        $address = '';
        $lat = 0;
        $lon = 0;
        if (!isset($controller->Config)) {
            $controller->Config = Configure::read('JreviewsSystem.Config');
        }
        if (!isset($controller->Access)) {
            $controller->Config = Configure::read('JreviewsSystem.Access');
        }
        $this->max_radius = Sanitize::getInt($controller->Config, 'geomaps.max_radius', $this->max_radius);
        $this->jr_lat = Sanitize::getString($controller->Config, 'geomaps.latitude');
        $this->jr_lon = Sanitize::getString($controller->Config, 'geomaps.longitude');
        if ($this->jr_lat == '' || $this->jr_lon == '') {
            return false;
        }
        // Setup vars used in startup and other plugin methods
        $this->google_url = Sanitize::getString($this->c->Config, 'geomaps.google_url', 'http://maps.google.com');
        $this->google_api_key = trim(Sanitize::getString($controller->Config, 'geomaps.google_key'));
        $this->google_api_url = $this->google_url . "/maps?file=api&v=2&async=2&key={$this->google_api_key}&sensor=false";
        $search_method = Sanitize::getString($controller->Config, 'geomaps.search_method', 'address');
        // address/disabled
        $search_address_field = Sanitize::getString($controller->Config, 'geomaps.advsearch_input');
        $default_radius = Sanitize::getString($controller->Config, 'geomaps.radius');
        $this->distance_metric = array('mi' => __t("Miles", true), 'km' => __t("Km", true));
        $this->distance_in = Sanitize::getString($controller->Config, 'geomaps.radius_metric', 'mi');
        $this->jr_address1 = Sanitize::getString($controller->Config, 'geomaps.address1');
        $this->jr_address2 = Sanitize::getString($controller->Config, 'geomaps.address2');
        $this->jr_city = Sanitize::getString($controller->Config, 'geomaps.city');
        $this->jr_state = Sanitize::getString($controller->Config, 'geomaps.state');
        $this->jr_postal_code = Sanitize::getString($controller->Config, 'geomaps.postal_code');
        $this->jr_country = Sanitize::getString($controller->Config, 'geomaps.country');
        $this->country_def = Sanitize::getString($controller->Config, 'geomaps.default_country');
        $this->gid = $controller->Access->gid;
        $this->address_fields = array_filter(array('address1' => $this->jr_address1, 'address2' => $this->jr_address2, 'city' => $this->jr_city, 'state' => $this->jr_state, 'postal_code' => $this->jr_postal_code, 'country' => $this->jr_country));
        $this->geo_fields = array('lat' => $this->jr_lat, 'lon' => $this->jr_lon);
        $this->c->set(array('address_fields' => $this->address_fields, 'geo_fields' => $this->geo_fields));
        /**
         * Address search checks
         */
        if (isset($controller->data['Field']['Listing'])) {
            $address = Sanitize::getString($controller->data['Field']['Listing'], $search_address_field);
        } else {
            $address = Sanitize::getString($controller->params, $search_address_field);
            $lat = Sanitize::getFloat($controller->params, $this->jr_lat);
            $lon = Sanitize::getFloat($controller->params, $this->jr_lon);
        }
        /**
         * Plugin does different things for different controller methods
         */
        switch ($controller->name) {
            case 'com_content':
                $this->published = true;
                $controller->Listing->cacheCallbacks[] = 'plgAfterAfterFind';
                $controller->Listing->fields[] = "`Field`.{$this->jr_lat} AS `Geomaps.lat`";
                $controller->Listing->fields[] = "`Field`.{$this->jr_lon} AS `Geomaps.lon`";
                $controller->Listing->fields[] = "JreviewsCategory.marker_icon AS `Geomaps.icon`";
                break;
            case 'listings':
                switch ($controller->action) {
                    // Load the geomaps js library
                    case 'create':
                        // Submit a new listing
                    // Submit a new listing
                    case 'edit':
                        // Edit a listing
                        $this->published = true;
                        $Html = new HtmlHelper();
                        $Html->app = 'jreviews';
                        $jsGlobals = 'var GeomapsGoogleApi = "' . $this->google_api_url . '";';
                        $jsGlobals .= 'var jr_lat = "' . $this->jr_lat . '";';
                        $jsGlobals .= 'var jr_lon = "' . $this->jr_lon . '";';
                        $jsGlobals .= 'var jr_country_def = "' . $this->country_def . '";';
                        $jsGlobals .= 'var geoAddressObj = {};';
                        foreach ($this->address_fields as $key => $field) {
                            $jsGlobals .= "geoAddressObj.{$key} = '{$field}';";
                        }
                        cmsFramework::addScript($controller->makeJS($jsGlobals), true);
                        $Html->js('geomaps', true);
                        if ($controller->action == 'edit') {
                            $mapit_field = Sanitize::getString($controller->Config, 'geomaps.mapit_field');
                            if ($mapit_field) {
                                $response = "jQuery(document).ready(function() { \r\n                                    jQuery('#{$mapit_field}','#jr_listingForm').after('<span id=\"gm_geocode\">\r\n                                        <input class=\"jrButton\" type=\"button\" onclick=\"geomaps.mapPopupSimple();\" value=\"" . __t("Map it", true) . "\" />&nbsp;\r\n                                        <input class=\"jrButton\" type=\"button\" onclick=\"geomaps.clearLatLng();\" value=\"" . __t("Clear LatLng", true) . "\" />\r\n                                    </span>');\r\n                                });";
                                cmsFramework::addScript($controller->makeJS($response), true);
                            }
                        }
                        break;
                        // Add geomaps buttons after form is loaded
                    // Add geomaps buttons after form is loaded
                    case '_loadForm':
                        // New listing - Loads submit listing form after category selection
                        $this->published = true;
                        $mapit_field = Sanitize::getString($controller->Config, 'geomaps.mapit_field');
//.........这里部分代码省略.........
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:101,代码来源:geomaps.php


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