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


PHP HtmlHelper::startup方法代码示例

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


在下文中一共展示了HtmlHelper::startup方法的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');
     }
     $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->_user->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';
                     $Html->startup();
                     $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() { \n                                \tvar polylines = false;\n                                \tif (jQuery('#cat_id').val() == 2) {\n                                \t\tpolylines = true;\n                                \t}\n                                    jQuery('#{$mapit_field}').after('<span id=\"gm_geocode\">\n                                        <button type=\"button\" onclick=\"geomaps.mapPopupSimple('+polylines+');\">" . __t("Map it", true) . "</button>&nbsp;\n                                        <button type=\"button\" onclick=\"geomaps.clearLatLng();\">" . __t("Clear LatLng", true) . "</button>\n                                    </span>');\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');
                     if ($mapit_field) {
                         $response = array();
                         // Overrode mapPopupSimple() with mapPopupLines()
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:geomaps.php


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