Beispiel #1
0
 function __construct()
 {
     parent::__construct();
     Configure::write('Community.profileUrl', $this->profileUrl);
     if (file_exists(PATH_ROOT . 'components' . _DS . 'com_community' . _DS . 'community.php')) {
         $this->community = true;
         $Menu = ClassRegistry::getClass('MenuModel');
         $this->menu_id = $Menu->getComponentMenuId('com_community&view=frontpage');
         if (!$this->menu_id) {
             $this->menu_id = $Menu->getComponentMenuId('com_community&view=profile');
         }
         if (!$this->menu_id) {
             $this->menu_id = $Menu->getComponentMenuId('com_community');
         }
         // For JomSocial <= 2.1
         if (!file_exists(PATH_ROOT . 'components/com_community/assets/user_thumb.png')) {
             $this->default_thumb = 'components/com_community/assets/default_thumb.jpg';
         }
         $cache_key = 'jomsocial_config_' . md5(cmsFramework::getConfig('secret'));
         $JSConfig = S2Cache::read($cache_key);
         if (false == $JSConfig) {
             // Read the JomSocial configuration to determine the storage location for avatars
             $JSConfig = json_decode($this->query("SELECT params FROM #__community_config WHERE name = 'config'", 'loadResult'), true);
             $JSConfigForJReviews = array('user_avatar_storage' => $JSConfig['user_avatar_storage'], 'storages3bucket' => $JSConfig['storages3bucket']);
             S2Cache::write($cache_key, $JSConfigForJReviews);
         }
         $this->avatar_storage = $JSConfig['user_avatar_storage'];
         $this->s3_bucket = $JSConfig['storages3bucket'];
         Configure::write('Community.register_url', sprintf($this->registerUrl, $this->menu_id));
     }
 }
Beispiel #2
0
 function &getInstance()
 {
     static $instance = array();
     if (!isset($instance[0]) || !$instance[0]) {
         $instance[0] = new sef_jreviews();
         require dirname(__FILE__) . DS . 'jreviews' . DS . 'framework.php';
         App::import('Model', 'Menu', 'jreviews');
         $instance[0]->__Menu = ClassRegistry::getClass('MenuModel');
         // Read url param style setting from JReviews config cache file
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = S2Cache::read($cache_file);
         $instance[0]->joomla_style_params = is_object($Config) and isset($Config->url_param_joomla) ? $Config->url_param_joomla : false;
         $version = new JVersion();
         $instance[0]->cmsVersion = $version->RELEASE;
     }
     return $instance[0];
 }
 function onProfileDisplay()
 {
     if (!file_exists($this->_path . DS . 'admin.jreviews.php')) {
         return JText::_('jReviews is not installed. Please contact site administrator.');
     } else {
         $user = CFactory::getActiveProfile();
         $userId = $user->id;
         $cacheSetting = $this->params->get('cache', 1) ? JApplication::getCfg('caching') : 0;
         # Load CSS stylesheets -- done here because when cache is on css is not loaded
         if ($cacheSetting) {
             # MVC initalization script
             if (!defined('DS')) {
                 define('DS', DIRECTORY_SEPARATOR);
             }
             require 'components' . DS . 'com_jreviews' . DS . 'jreviews' . DS . 'framework.php';
             $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
             $Config =& S2Cache::read($cache_file);
             if (!is_object($Config)) {
                 //Create config file
                 $eParams['data']['controller'] = 'common';
                 $eParams['data']['action'] = 'index';
                 $Dispatcher = new S2Dispatcher('jreviews', false, true);
                 $Dispatcher->dispatch($eParams);
                 $Config =& S2Cache::read($cache_file);
                 unset($Dispatcher);
             }
             App::import('Helper', 'html');
             $Html =& RegisterClass::getInstance('HtmlHelper');
             $Html->viewTheme = $Config->template;
             $Html->app = 'jreviews';
             $Html->startup();
             App::import('Helper', 'libraries', 'jreviews');
             $Libraries =& RegisterClass::getInstance('LibrariesHelper');
             $Html->css(array('theme', 'plugins', 'paginator'));
             $Html->js(array('jreviews', 'jquery' => 'jquery', 'jq.scrollable'), $Libraries->js());
         }
         $cache =& JFactory::getCache('plgCommunityJreviews_myfavorites');
         $cache->setCaching($cacheSetting);
         $callback = array('plgCommunityJreviews_myfavorites', '_getPage');
         $contents = $cache->call($callback, $userId, $this->params, $cacheSetting);
         return $contents;
     }
 }
 function listings()
 {
     // Initialize variables
     $id = Sanitize::getInt($this->params, 'id');
     $option = Sanitize::getString($this->params, 'option');
     $view = Sanitize::getString($this->params, 'view');
     $menu_id = Sanitize::getString($this->params, 'Itemid');
     // Read params
     $cat_id = '';
     $criteria_ids = '';
     $in_detail_view = false;
     $detail_view = 1;
     $dir_id = Sanitize::getString($this->params, 'dir');
     $section_id = Sanitize::getString($this->params, 'section');
     $cat_id = Sanitize::getString($this->params, 'cat');
     $extension = 'com_content';
     $custom_where = null;
     $custom_fields = array();
     $click2search_auto = false;
     $cache = 0;
     $radius = 0;
     $mode = 0;
     if (isset($this->params['module'])) {
         // Read module parameters
         $click2search_auto = Sanitize::getBool($this->params['module'], 'click2search_auto', false);
         $custom_where = Sanitize::getString($this->params['module'], 'custom_where');
         $filter = Sanitize::getString($this->params['module'], 'filter');
         $detail_view = Sanitize::getString($this->params['module'], 'detail_view', 1);
         $dir_id = Sanitize::getString($this->params['module'], 'dir');
         $section_id = Sanitize::getString($this->params['module'], 'section');
         $cat_id = Sanitize::getString($this->params['module'], 'category');
         $listing_id = Sanitize::getString($this->params['module'], 'listing');
         $criteria_ids = Sanitize::getString($this->params['module'], 'criteria');
         $limit_results = Sanitize::getInt($this->params['module'], 'limit_results');
         $mode = Sanitize::getInt($this->params['module'], 'mode', 0);
         $custom_fields = str_replace(" ", "", Sanitize::getString($this->Config, 'geomaps.infowindow_fields'));
         $custom_fields = $custom_fields != '' ? explode(",", $custom_fields) : array();
         /**
          * 0 - Normal
          * 1 - GeoTargeting
          * 2 - Custom center and zoom
          */
         $radius = Sanitize::getInt($this->params['module'], 'radius');
         $cache = $mode == 1 ? 0 : Sanitize::getInt($this->params['module'], 'cache_map');
         $custom_lat = Sanitize::getFloat($this->params['module'], 'custom_lat');
         $custom_lon = Sanitize::getFloat($this->params['module'], 'custom_lon');
         if ($mode == 2 && ($custom_lat == 0 || $custom_lon == 0)) {
             echo __t("You selected the Custom Center mode, but did not specify the coordinates.");
             return;
         }
     }
     # Prevent sql injection
     $token = Sanitize::getString($this->params, 'token');
     $tokenMatch = 0 === strcmp($token, cmsFramework::formIntegrityToken($this->params, array('module', 'module_id', 'form', 'data'), false));
     $filters = $listing_id != '' || $dir_id != '' || $section_id != '' || $cat_id != '';
     if (!$filters && $id > 0 && 'article' == $view && 'com_content' == $option) {
         $sql = "SELECT catid FROM #__content WHERE id = " . $id;
         $this->_db->setQuery($sql);
         $cat_id_host_page = $this->_db->loadResult();
         if (!empty($cat_id_host_page) && $this->Category->isJreviewsCategory($cat_id_host_page)) {
             $in_detail_view = true;
             $cat_id = $cat_id_host_page;
         }
     }
     $detail_view = $this->params['module']['detail_view'] = (int) ($detail_view && $in_detail_view);
     # Custom WHERE
     $tokenMatch and $custom_where and $conditions[] = $custom_where;
     if ($click2search_auto && isset($this->params['tag'])) {
         $field = 'jr_' . Sanitize::getString($this->params['tag'], 'field');
         $value = Sanitize::getString($this->params['tag'], 'value');
         $query = "SELECT Field.type FROM #__jreviews_fields AS Field WHERE Field.name = " . $this->quote($field);
         $this->_db->setQuery($query);
         $type = $this->_db->loadResult();
         if (in_array($type, array('select', 'selectmultiple', 'checkboxes', 'radiobuttons'))) {
             $conditions[] = "Field.{$field} LIKE " . $this->quoteLike('*' . $value . '*');
         } else {
             $conditions[] = "Field.{$field} = " . $this->quote($value);
         }
     }
     # Category auto detect
     if (isset($this->params['module']) && Sanitize::getInt($this->params['module'], 'cat_auto') && $extension == 'com_content') {
         $ids = CommonController::_discoverIDs($this);
         extract($ids);
     }
     $autodetect = compact('dir_id', 'section_id', 'cat_id');
     // Check for cached version if cache enabled
     if ($cache) {
         $params = array();
         foreach ($this->params as $key => $value) {
             if ((!is_array($value) || $key == 'module') && !in_array($key, array('page', 'limit', 'order', 'Itemid'))) {
                 $params[$key] = $value;
             }
         }
         $cache_key = array_merge($params, $autodetect, Sanitize::getVar($this->params, 'tag', array()));
         $json_filename = 'geomaps_' . md5(serialize($cache_key)) . '.json';
         $json_data = S2Cache::read($json_filename);
         if ($json_data && $json_data != '') {
             $this->set('json_data', $json_data);
             S2Cache::write($json_filename, $json_data);
             return $this->render('modules', 'geomaps');
         }
     }
     $this->Listing->fields = array('Listing.id AS `Listing.listing_id`', 'Listing.title AS `Listing.title`', 'Listing.images AS `Listing.images`', 'CASE WHEN CHAR_LENGTH(Listing.alias) THEN Listing.alias ELSE "" END AS `Listing.slug`', 'Category.id AS `Listing.cat_id`', 'CASE WHEN CHAR_LENGTH(Category.alias) THEN Category.alias ELSE Category.title END AS `Category.slug`', 'Listing.sectionid AS `Listing.section_id`', 'JreviewsCategory.criteriaid AS `Criteria.criteria_id`', 'JreviewsCategory.dirid AS `Directory.dir_id`', 'JreviewsCategory.marker_icon AS `Geomaps.icon`', 'Field.featured AS `Listing.featured`', 'Totals.user_rating AS `Review.user_rating`', 'Totals.user_rating_count AS `Review.user_rating_count`', 'Totals.editor_rating AS `Review.editor_rating`', 'Totals.editor_rating_count AS `Review.editor_rating_count`', "Field.{$this->jr_lat} `Geomaps.lat`", "Field.{$this->jr_lon} `Geomaps.lon`", 'ListingType.state AS `Criteria.state`', 'ListingType.config AS `ListingType.config`');
     if ($custom_lon != '' and $custom_lat != '') {
         $this->set('CustomCenter', array('lon' => $custom_lon, 'lat' => $custom_lat));
     }
     // Geo Targeting OR Custom Center modes
     if ($mode == 1 || $mode == 2) {
         if ($mode == 1) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, 'http://www.geoplugin.net/php.gp?ip=' . s2GetIpAddress());
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
             $geoData = unserialize(curl_exec($ch));
             curl_close($ch);
             if (!empty($geoData) && isset($geoData['geoplugin_latitude']) && $geoData['geoplugin_latitude'] != '' && $geoData['geoplugin_longitude'] != '') {
                 $center = array('lon' => $geoData['geoplugin_longitude'], 'lat' => $geoData['geoplugin_latitude']);
             }
             $this->set('geoLocation', $geoData);
         }
         if ($mode == 2) {
             $center = array('lon' => $custom_lon, 'lat' => $custom_lat);
         }
         if (!empty($center) && $radius > 0) {
             $distanceIn = Sanitize::getString($this->Config, 'geomaps.radius_metric', 'mi');
             $degreeDistance = $distanceIn == 'mi' ? 69.172 : 40076 / 360;
             // Send center coordinates to theme
             $this->set('GeomapsCenter', $center);
             $lat_range = $radius / $degreeDistance;
             $lon_range = $radius / abs(cos($center['lat'] * pi() / 180) * $degreeDistance);
             $min_lat = $center['lat'] - $lat_range;
             $max_lat = $center['lat'] + $lat_range;
             $min_lon = $center['lon'] - $lon_range;
             $max_lon = $center['lon'] + $lon_range;
             $squareArea = "`Field`.{$this->jr_lat} BETWEEN {$min_lat} AND {$max_lat} AND `Field`.{$this->jr_lon} BETWEEN {$min_lon} AND {$max_lon}";
             $conditions[] = $squareArea;
         }
     }
     // Create marker_icons array
     $marker_icons = array();
     $icon_fields = array();
     $field_images = array();
     $query = "SELECT DISTINCT marker_icon FROM #__jreviews_categories WHERE marker_icon != ''";
     $this->_db->setQuery($query);
     $icon_rows = $this->_db->loadAssocList();
     foreach ($icon_rows as $icons) {
         $icon = (array) json_decode($icons['marker_icon']);
         if ($icon['field'] != '') {
             $icon_fields[$icon['field']] = "'" . $icon['field'] . "'";
         }
     }
     if (!empty($icon_fields)) {
         foreach ($icon_fields as $field_key => $field) {
             if (substr($field_key, 0, 3) == 'jr_') {
                 $this->Listing->fields[] = "Field.{$field_key} AS `Field.{$field_key}`";
             }
         }
     }
     if (!empty($custom_fields)) {
         foreach ($custom_fields as $field) {
             $this->Listing->fields[] = "Field.{$field} AS `Field.{$field}`";
         }
     }
     $this->Listing->joins = array("LEFT JOIN #__categories AS Category ON Listing.catid = Category.id", 'ParentCategory' => "LEFT JOIN #__categories AS ParentCategory ON Category.lft BETWEEN ParentCategory.lft AND ParentCategory.rgt", "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_content'", "LEFT JOIN #__jreviews_content AS `Field` ON Field.contentid = Listing.id", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_content'", "LEFT JOIN #__jreviews_criteria AS ListingType ON JreviewsCategory.criteriaid = ListingType.id", "LEFT JOIN #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id");
     // Don't regroup the results by model name keys to save time
     $this->Listing->primaryKey = false;
     # Set conditionals based on configuration parameters
     if ($detail_view) {
         $conditions[] = 'Listing.id = ' . $id;
     }
     if (!empty($cat_id)) {
         $conditions[] = $this->cmsVersion == CMS_JOOMLA15 ? 'Listing.catid IN (' . cleanIntegerCommaList($cat_id) . ')' : 'ParentCategory.id IN (' . cleanIntegerCommaList($cat_id) . ')';
     }
     if ($this->cmsVersion == CMS_JOOMLA15) {
         unset($this->Listing->joins['ParentCategory']);
     }
     empty($cat_id) and !empty($section_id) and $conditions[] = 'Listing.sectionid IN (' . cleanIntegerCommaList($section_id) . ')';
     empty($cat_id) and !empty($dir_id) and $conditions[] = 'JreviewsCategory.dirid IN (' . cleanIntegerCommaList($dir_id) . ')';
     empty($cat_id) and !empty($criteria_id) and $conditions[] = 'JreviewsCategory.criteriaid IN (' . cleanIntegerCommaList($criteria_id) . ')';
     if ($listing_id) {
         $conditions[] = 'Listing.id IN (' . $listing_id . ')';
     }
     if ($filter == 'featured' && !$detail_view) {
         $conditions[] = 'Field.featured = 1';
     }
     $conditions[] = "Field.{$this->jr_lat} <> ''";
     $conditions[] = "Field.{$this->jr_lon} <> ''";
     $conditions = array_merge($conditions, array('Listing.state = 1', '( Listing.publish_up = "' . NULL_DATE . '" OR DATE(Listing.publish_up) <= DATE("' . _CURRENT_SERVER_TIME . '") )', '( Listing.publish_down = "' . NULL_DATE . '" OR DATE(Listing.publish_down) >= DATE("' . _CURRENT_SERVER_TIME . '") )'));
     if ($this->cmsVersion == CMS_JOOMLA15) {
         //                    $conditions[] = 'Section.access <= ' . $this->Access->getAccessId();
         $conditions[] = 'Category.access <= ' . $this->Access->getAccessId();
         $conditions[] = 'Listing.access <= ' . $this->Access->getAccessId();
     } else {
         $conditions[] = 'Category.access IN (' . $this->Access->getAccessLevels() . ')';
         $conditions[] = 'Listing.access IN (' . $this->Access->getAccessLevels() . ')';
     }
     // Paid Listings - add plan cat id
     isset($this->PaidListings) and $this->PaidListings->applyBeforeFindListingChanges($this->Listing);
     $listings = $this->Listing->findAll(array('conditions' => $conditions, 'limit' => $limit_results), array());
     $custom_fields = array_filter(array_merge($custom_fields, array_keys($icon_fields)));
     $fieldOptionValues = array();
     // Extract custom field values to avoid loading all options for each fields
     // It's a trade-off between that and doing a foreach on all listings
     foreach ($listings as $key => $row) {
         $listings[$key]['Criteria']['state'] = $row['Criteria.state'];
         $listings[$key]['ListingType']['config'] = json_decode($row['ListingType.config'], true);
         unset($listings[$key]['Criteria.state'], $listings[$key]['ListingType.config']);
         foreach ($custom_fields as $field) {
             $optionValue = Sanitize::getVar($row, 'Field.' . $field);
             if ($optionValue != '' && $optionValue != '**') {
                 $fieldOptionValues = array_merge($fieldOptionValues, array_filter(explode('*', $optionValue)));
             }
         }
     }
     $fields = $this->Field->getFields($custom_fields, 'listing', $fieldOptionValues);
     $json_data = $this->Geomaps->makeJsonObject($listings, $fields, $this->params['module']);
     $this->set('json_data', $json_data);
     if ($cache) {
         S2Cache::write($json_filename, $json_data);
     }
     return $this->render('modules', 'geomaps');
 }
Beispiel #5
0
function S2cacheWrite($prefix, $key, $data)
{
    # Send to cache
    if ((!defined('MVC_FRAMEWORK_ADMIN') || MVC_FRAMEWORK_ADMIN == 0) && Configure::read('Cache.enable') && Configure::read('Cache.query')) {
        $cacheKey = $prefix . '_' . md5(cmsFramework::getConfig('secret') . serialize($key));
        S2Cache::write($cacheKey, $data);
    }
}
Beispiel #6
0
 /**
  * Object destructor
  *
  * Write cache file if changes have been made to the $__map or $__paths
  * @access private
  */
 function __destruct()
 {
     if ($this->__cache) {
         S2Cache::write($this->domain, array_filter($this->__domains));
     }
 }
 function listings()
 {
     // Initialize variables
     $id = Sanitize::getInt($this->params, 'id');
     $option = Sanitize::getString($this->params, 'option');
     $view = Sanitize::getString($this->params, 'view');
     $task = Sanitize::getString($this->params, 'task');
     $menu_id = Sanitize::getString($this->params, 'Itemid');
     // Read params
     $cat_id = '';
     $criteria_ids = '';
     $detail_view = 1;
     $dir_id = Sanitize::getString($this->params, 'dir');
     $section_id = Sanitize::getString($this->params, 'section');
     $cat_id = Sanitize::getString($this->params, 'cat');
     $extension = 'com_content';
     $custom_where = null;
     $custom_fields = array();
     $click2search_auto = false;
     $cache = 0;
     $radius = 0;
     $mode = 0;
     $fishingmap = 0;
     $this->set('listing_id', $id);
     $extracoords = array();
     if (isset($this->params['module'])) {
         // Read module parameters
         $click2search_auto = Sanitize::getBool($this->params['module'], 'click2search_auto', false);
         $custom_where = Sanitize::getString($this->params['module'], 'custom_where');
         $filter = Sanitize::getString($this->params['module'], 'filter');
         $detail_view = Sanitize::getString($this->params['module'], 'detail_view', 1);
         $dir_id = Sanitize::getString($this->params['module'], 'dir');
         $section_id = Sanitize::getString($this->params['module'], 'section');
         $cat_id = Sanitize::getString($this->params['module'], 'category');
         $listing_id = Sanitize::getString($this->params['module'], 'listing');
         $criteria_ids = Sanitize::getString($this->params['module'], 'criteria');
         $custom_fields = Sanitize::getString($this->params['module'], 'custom_fields', '');
         $custom_fields = $custom_fields != '' ? explode(',', str_replace(' ', '', $custom_fields)) : array();
         $limit_results = Sanitize::getInt($this->params['module'], 'limit_results');
         $mode = Sanitize::getInt($this->params['module'], 'mode', 0);
         /**
          * 0 - Normal
          * 1 - GeoTargeting
          * 2 - Custom center and zoom
          */
         $radius = Sanitize::getInt($this->params['module'], 'radius');
         $cache = $mode == 1 ? 0 : Sanitize::getInt($this->params['module'], 'cache_map');
         $custom_lat = Sanitize::getFloat($this->params['module'], 'custom_lat');
         $custom_lon = Sanitize::getFloat($this->params['module'], 'custom_lon');
         if ($mode == 2 && ($custom_lat == 0 || $custom_lon == 0)) {
             echo __t("You selected the Custom Center mode, but did not specify the coordinates.");
             return;
         }
         // Added for Hooked
         $extracoords = $this->params['module']['extracoords'];
         //$extracoords = "";
         $fishingmap = Sanitize::getInt($this->params['module'], 'fishingmap', 0);
     }
     $in_detail_view = $id > 0 && ('article' == $view || 'view' == $task) && 'com_content' == $option;
     $detail_view = $this->params['module']['detail_view'] = $detail_view && $in_detail_view;
     # Custom WHERE
     if ($custom_where) {
         $conditions[] = $custom_where;
     }
     if ($click2search_auto && isset($this->params['tag'])) {
         $field = 'jr_' . Sanitize::getString($this->params['tag'], 'field');
         $value = Sanitize::getString($this->params['tag'], 'value');
         $query = "SELECT Field.type FROM #__jreviews_fields AS Field WHERE Field.name = " . $this->quote($field);
         $this->_db->setQuery($query);
         $type = $this->_db->loadResult();
         if (in_array($type, array('select', 'selectmultiple', 'checkboxes', 'radiobuttons'))) {
             $conditions[] = "Field.{$field} LIKE " . $this->quoteLike('*' . $value . '*');
         } else {
             $conditions[] = "Field.{$field} = " . $this->quote($value);
         }
     }
     # Category auto detect
     if (isset($this->params['module']) && Sanitize::getInt($this->params['module'], 'cat_auto') && $extension == 'com_content') {
         // Only works for core articles
         switch ($option) {
             case 'com_jreviews':
                 # Get url params for current controller/action
                 $url = Sanitize::getString($this->passedArgs, 'url');
                 $route['url']['url'] = $url;
                 $route = S2Router::parse($route);
                 //                    $route = $route['url'];
                 $dir_id = Sanitize::getString($route, 'dir');
                 $section_id = Sanitize::getString($route, 'section');
                 $cat_id = Sanitize::getString($route, 'cat');
                 $criteria_ids = Sanitize::getString($route, 'criteria');
                 if ($cat_id != '') {
                     $category_ids = $this->makeParamsUsable($cat_id);
                     $category_ids = explode(",", $category_ids);
                     $this->cleanArray($category_ids);
                     $cat_id = implode(",", $category_ids);
                 } elseif ($section_id != '') {
                     $cat_id = $this->sectionToCat($section_id);
                 } elseif ($criteria_ids != '') {
                     // check criteriaids {
                     $criteriaids_url = $this->makeParamsUsable($criteria_ids);
                     $cat_id = $this->criteriaToCat($criteria_ids);
                 } else {
                     //Discover the params from the menu_id
                     $params = $this->Menu->getMenuParams($menu_id);
                     $dir_id = Sanitize::getString($params, 'dirid');
                     $cat_id = Sanitize::getString($params, 'catid');
                     $section_id = Sanitize::getString($params, 'sectionid');
                 }
                 break;
             case 'com_content':
                 if ('article' == $view || 'view' == $task) {
                     $sql = "SELECT catid FROM #__content WHERE id = " . $id;
                     $this->_db->setQuery($sql);
                     $cat_id = $this->_db->loadResult();
                 } elseif ($view == "section") {
                     $cat_id = $this->sectionToCat($id);
                 } elseif ($view == "category") {
                     $cat_id = $id;
                 }
                 break;
             default:
                 //                    $cat_id = null; // Catid not detected because the page is neither content nor jreviews
                 break;
         }
     }
     $autodetect = compact('dir_id', 'section_id', 'cat_id');
     // Check for cached version if cache enabled
     if ($cache) {
         $params = array();
         foreach ($this->params as $key => $value) {
             if ((!is_array($value) || $key == 'module') && !in_array($key, array('page', 'limit', 'order', 'Itemid'))) {
                 $params[$key] = $value;
             }
         }
         $cache_key = array_merge($params, $autodetect, Sanitize::getVar($this->params, 'tag', array()));
         $json_filename = 'geomaps_' . md5(serialize($cache_key)) . '.json';
         $json_data = S2Cache::read($json_filename);
         if ($json_data && $json_data != '') {
             $this->set('json_data', $json_data);
             S2Cache::write($json_filename, $json_data);
             return $this->render('modules', 'geomaps');
         }
     }
     $this->Listing->fields = array('Listing.id AS `Listing.listing_id`', 'Listing.title AS `Listing.title`', 'Listing.images AS `Listing.images`', 'CASE WHEN CHAR_LENGTH(Listing.alias) THEN Listing.alias ELSE "" END AS `Listing.slug`', 'Category.id AS `Listing.cat_id`', 'CASE WHEN CHAR_LENGTH(Category.alias) THEN Category.alias ELSE Category.title END AS `Category.slug`', 'Listing.sectionid AS `Listing.section_id`', 'JreviewsCategory.criteriaid AS `Criteria.criteria_id`', 'JreviewsCategory.dirid AS `Directory.dir_id`', 'Field.featured AS `Listing.featured`', 'Totals.user_rating AS `Review.user_rating`', 'Totals.user_rating_count AS `Review.user_rating_count`', 'Totals.editor_rating AS `Review.editor_rating`', 'Totals.editor_rating_count AS `Review.editor_rating_count`', "Field.{$this->jr_lat} `Geomaps.lat`", "Field.{$this->jr_lon} `Geomaps.lon`", 'JreviewsCategory.marker_icon AS `Geomaps.icon`');
     if ($fishingmap) {
         $this->Listing->fields[] = 'GROUP_CONCAT(Related.id2) AS `Listing.relations`';
     }
     // Geo Targeting OR Custom Center modes
     if ($mode == 1 || $mode == 2) {
         if ($mode == 1) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, 'http://www.geoplugin.net/php.gp?ip=' . s2GetIpAddress());
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
             $geoData = unserialize(curl_exec($ch));
             curl_close($ch);
             if (!empty($geoData) && $geoData['geoplugin_latitude'] != '' && $geoData['geoplugin_longitude'] != '') {
                 $center = array('lon' => $geoData['geoplugin_longitude'], 'lat' => $geoData['geoplugin_latitude']);
             }
             $this->set('geoLocation', $geoData);
         }
         if ($mode == 2) {
             $center = array('lon' => $custom_lon, 'lat' => $custom_lat);
         }
         if (!empty($center) && $radius > 0) {
             $distanceIn = Sanitize::getString($this->Config, 'geomaps.radius_metric', 'mi');
             $degreeDistance = $distanceIn == 'mi' ? 69.172 : 40076 / 360;
             // Send center coordinates to theme
             $this->set('GeomapsCenter', $center);
             $lat_range = $radius / $degreeDistance;
             $lon_range = $radius / abs(cos($center['lat'] * pi() / 180) * $degreeDistance);
             $min_lat = $center['lat'] - $lat_range;
             $max_lat = $center['lat'] + $lat_range;
             $min_lon = $center['lon'] - $lon_range;
             $max_lon = $center['lon'] + $lon_range;
             $squareArea = "`Field`.{$this->jr_lat} BETWEEN {$min_lat} AND {$max_lat} AND `Field`.{$this->jr_lon} BETWEEN {$min_lon} AND {$max_lon}";
             // Added for Hooked
             if ($extracoords) {
                 $squareArea = "((" . $squareArea . ")";
                 foreach ($extracoords as $extra) {
                     $e_lat = $extra->y;
                     $e_lon = $extra->x;
                     $lon_range = $radius / abs(cos($e_lat * pi() / 180) * $degreeDistance);
                     $min_lat = $e_lat - $lat_range;
                     $max_lat = $e_lat + $lat_range;
                     $min_lon = $e_lon - $lon_range;
                     $max_lon = $e_lon + $lon_range;
                     $squareArea .= " OR (`Field`.{$this->jr_lat} BETWEEN {$min_lat} AND {$max_lat} AND `Field`.{$this->jr_lon} BETWEEN {$min_lon} AND {$max_lon})";
                 }
                 $squareArea .= ")";
             }
             $conditions[] = $squareArea;
         }
     }
     // Create marker_icons array
     $marker_icons = array();
     $icon_fields = array();
     $field_images = array();
     $query = "SELECT DISTINCT marker_icon FROM #__jreviews_categories WHERE marker_icon != ''";
     $this->_db->setQuery($query);
     $icon_rows = $this->_db->loadAssocList();
     foreach ($icon_rows as $icons) {
         $icon = (array) json_decode($icons['marker_icon']);
         if ($icon['field'] != '') {
             $icon_fields[$icon['field']] = "'" . $icon['field'] . "'";
         }
     }
     if (!empty($icon_fields)) {
         foreach ($icon_fields as $field_key => $field) {
             $this->Listing->fields[] = "Field.{$field_key} AS `Field.{$field_key}`";
         }
     }
     if (!empty($custom_fields)) {
         foreach ($custom_fields as $field) {
             $this->Listing->fields[] = "Field.{$field} AS `Field.{$field}`";
         }
     }
     $this->Listing->joins = array("LEFT JOIN #__categories AS Category ON Listing.catid = Category.id", "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_content'", "LEFT JOIN #__jreviews_content AS `Field` ON Field.contentid = Listing.id", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_content'", "LEFT JOIN #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id");
     if ($fishingmap) {
         $this->Listing->joins[] = "LEFT JOIN #__relate_listings AS Related ON Related.id1 = Listing.id";
     }
     // Don't regroup the results by model name keys to save time
     $this->Listing->primaryKey = false;
     # Set conditionals based on configuration parameters
     if ($detail_view) {
         $conditions[] = 'Listing.id = ' . $id;
     }
     if ($dir_id) {
         $conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
     }
     if ($section_id) {
         $conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
     }
     if ($cat_id) {
         $conditions[] = 'Listing.catid IN (' . $cat_id . ')';
     }
     if ($listing_id) {
         $conditions[] = 'Listing.id IN (' . $listing_id . ')';
     }
     if ($filter == 'featured' && !$detail_view) {
         $conditions[] = 'Field.featured = 1';
     }
     $conditions[] = "Field.{$this->jr_lat} <> ''";
     $conditions[] = "Field.{$this->jr_lon} <> ''";
     $conditions[] = 'Listing.state = 1';
     if ($fishingmap) {
         $this->Listing->group = array('Listing.id');
     }
     // Paid Listings - add plan cat id
     isset($this->PaidListings) and $this->PaidListings->applyBeforeFindListingChanges($this->Listing);
     $listings = $this->Listing->findAll(array('conditions' => $conditions, 'limit' => $limit_results), array());
     $custom_fields = array_filter(array_merge($custom_fields, array_keys($icon_fields)));
     $fields = $this->Field->getFields($custom_fields);
     $json_data = $this->Geomaps->makeJsonObject($listings, $fields, $this->params['module']);
     $this->set('json_data', $json_data);
     if ($cache) {
         S2Cache::write($json_filename, $json_data);
     }
     return $this->render('modules', 'geomaps');
 }
Beispiel #8
0
 function __construct()
 {
     parent::__construct();
     # Check for cached version
     $cache_file = 'jreviews_menu_' . cmsFramework::locale() . '_' . md5(cmsFramework::getConfig('secret'));
     if ($cache = S2Cache::read($cache_file)) {
         $this->___menu_data = $cache['___menu_data'];
         return;
     }
     $menuList = array();
     switch ($this->cmsVersion) {
         case CMS_JOOMLA15:
             $select = "\n                    SELECT \n                        id,\n                        name,\n                        link AS menu_type,\n                        link,\n                        componentid,\n                        params,\n                        access,\n                        published\n                ";
             break;
         case CMS_JOOMLA16:
             $select = "\n                    SELECT \n                        id, \n                        title AS name,\n                        link AS menu_type,\n                        link,\n                        component_id AS componentid,\n                        params,\n                        access,\n                        published\n                ";
             break;
     }
     // Get all com_content category/section menus and JReviews menus
     $sql = $select . "\n            FROM #__menu\n            WHERE published = 1\n            ORDER BY link DESC\n        ";
     $this->_db->setQuery($sql);
     $menuList = $this->_db->loadObjectList();
     // Get itemid for each menu link and store it
     if (!empty($menuList)) {
         foreach ($menuList as $menu) {
             $params = stringToArray($menu->params);
             $m_name = Sanitize::getVar($params, 'sef_name') != '' ? Sanitize::getVar($params, 'sef_name') : $menu->name;
             function_exists("sefEncode") and $m_name = sefEncode($m_name);
             $m_action = Sanitize::getVar($params, 'action');
             $m_dir_id = str_replace(",", "-", Sanitize::getVar($params, 'dirid'));
             $m_cat_id = str_replace(",", "-", Sanitize::getVar($params, 'catid'));
             $m_section_id = str_replace(",", "-", Sanitize::getVar($params, 'sectionid'));
             $m_criteria_id = str_replace(",", "-", Sanitize::getVar($params, 'criteriaid'));
             // Create a variable to get Menu Name from Itemid
             $this->set('jr_itemid_' . $menu->id, $m_name);
             $this->set('jr_menu_' . $m_name, $menu->id);
             if (strpos($menu->menu_type, 'option=com_content&view=section&id=') || strpos($menu->menu_type, 'option=com_content&view=section&layout=blog&id=')) {
                 $menu->componentid = end(explode('id=', $menu->menu_type));
                 $menu->menu_type = 'content_section';
             } elseif (strpos($menu->menu_type, 'option=com_content&view=category&id=') || strpos($menu->menu_type, 'option=com_content&view=category&layout=blog&id=')) {
                 $menu->componentid = end(explode('id=', $menu->menu_type));
                 $menu->menu_type = 'content_category';
             } elseif (strpos($menu->menu_type, 'option=com_content&view=article&id=') || strpos($menu->menu_type, 'option=com_content&task=view&id=')) {
                 $menu->componentid = end(explode('id=', $menu->menu_type));
                 $menu->menu_type = 'content_item_link';
             }
             switch ($menu->menu_type) {
                 case 'content_section':
                 case 'content_blog_section':
                     if ($menu->componentid) {
                         // Only one section id
                         $this->set('core_section_menu_id_' . $menu->componentid, $menu->id);
                     } else {
                         $section_ids = explode(",", Sanitize::getVar($params, 'sectionid'));
                         $this->set('jr_manyIds_' . $menu->id, 1);
                         foreach ($section_ids as $section_id) {
                             $this->set('core_section_menu_id_' . $section_id, $menu->id);
                         }
                     }
                     break;
                 case 'content_category':
                 case 'content_blog_category':
                     if ($menu->componentid) {
                         // Only one category id
                         $this->set('core_category_menu_id_' . $menu->componentid, $menu->id);
                     } else {
                         $cat_ids = explode(",", Sanitize::getVar($params, 'categoryid'));
                         $this->set('jr_manyIds_' . $menu->id, 1);
                         foreach ($cat_ids as $cat_id) {
                             $this->set('core_category_menu_id_' . $cat_id, $menu->id);
                         }
                     }
                     break;
                 case 'content_item_link':
                     $this->set('core_content_menu_id_' . $menu->componentid, $menu->id);
                     break;
                 default:
                     if ($menu->componentid > 0 && strstr($menu->link, 'index.php?option=' . S2Paths::get('jreviews', 'S2_CMSCOMP'))) {
                         // It's a JReviews menu
                         $access = $this->cmsVersion == CMS_JOOMLA15 ? 0 : 1;
                         // Get a JReviews menu with public access to use in ajax requests
                         if ($menu->access == $access && $menu->published == 1) {
                             $this->set('jreviews_public', $menu->id);
                         }
                         $this->set('jr_menu_action_' . $m_dir_id, $m_action);
                         $this->set('menu_params_' . $menu->id, $params);
                         switch ($m_action) {
                             case '0':
                                 // Directory menu
                                 $this->set('jr_directory_menu_id_' . $m_dir_id, $menu->id);
                                 break;
                             case '1':
                                 // Section menu
                                 $this->set('jr_section_menu_id_' . $m_section_id, $menu->id);
                                 break;
                             case '2':
                                 // Category menu
                                 $this->set('jr_category_menu_id_' . $m_cat_id, $menu->id);
                                 break;
                             case '10':
                                 $this->set('jr_myreviews', $menu->id);
                                 break;
                             case '11':
                                 $m_criteria_id && $this->set('jr_advsearch_' . $m_criteria_id, $menu->id);
                                 !$m_criteria_id && $this->set('jr_advsearch', $menu->id);
                                 break;
                             case '12':
                                 $this->set('jr_mylistings', $menu->id);
                                 break;
                             case '18':
                                 $this->set('jr_reviewers', $menu->id);
                                 break;
                             default:
                                 $this->set('jr_menu_id_action_' . $m_action, $menu->id);
                                 break;
                         }
                     }
                     break;
             }
         }
         S2Cache::write($cache_file, array('___menu_data' => $this->___menu_data));
     }
     //        prx($this->___menu_data);exit;
 }
Beispiel #9
0
 function find($type, $queryData, $callbacks = array('plgAfterFind', 'afterFind', 'plgAfterAfterFind'), $cache = false)
 {
     $queryData = $this->__mergeArrays($queryData);
     if ($cache === true && !Configure::read('Cache.disable') && Configure::read('Cache.query') === true) {
         $cache_key = md5(cmsFramework::getConfig('secret') . $type . serialize($queryData) . serialize($callbacks));
         $rows = S2Cache::read($cache_key);
         /*            if($type != 'one' && in_array('plgAfterFind',$this->cacheCallbacks) && method_exists($this,'plgAfterFind')) {
                         $rows = $this->plgAfterFind($rows);
                     }
                     if($type != 'one' && in_array('afterFind',$this->cacheCallbacks) && method_exists($this,'afterFind')) {
                         $rows = $this->afterFind($rows);
                     }
         */
         if ($type != 'one' && in_array('plgAfterAfterFind', $this->cacheCallbacks) && method_exists($this, 'plgAfterAfterFind')) {
             $rows = $this->plgAfterAfterFind($rows);
         }
         if (false !== $rows) {
             return $rows;
         }
     }
     $query = "SELECT " . implode(",\n", $queryData['fields']) . "\n FROM " . $this->useTable . (!empty($queryData['joins']) ? "\n" . implode("\n", $queryData['joins']) : '') . (!empty($queryData['conditions']) ? "\n WHERE 1 = 1 AND ( \n   " . implode("\n   AND ", $queryData['conditions']) . "\n )" : '') . (!empty($queryData['group']) ? "\n GROUP BY " . implode(',', $queryData['group']) : '') . (!empty($queryData['having']) ? "\n HAVING " . implode(' AND ', $queryData['having']) : '') . (!empty($queryData['order']) ? "\n ORDER BY " . implode(',', $queryData['order']) : '') . (!empty($queryData['limit']) ? "\n LIMIT " . (Sanitize::getInt($queryData, 'offset', null) ? $queryData['offset'] . ", " : '') . $queryData['limit'] : '');
     $this->_db->setQuery($query);
     //        prx($this->_db->getQuery());
     $message = array();
     $message[] = '*********' . get_class($this) . ' | find';
     $message[] = $this->_db->getQuery();
     appLogMessage($message, 'database');
     switch ($type) {
         case 'all':
             $rows = $this->_db->loadObjectList();
             $rows = $this->__reformatArray($rows);
             break;
         case 'one':
             $rows = $this->_db->loadResult();
             break;
     }
     $message = array();
     if ($this->_db->getErrorMsg()) {
         $message[] = '*********' . get_class($this) . ' | find ERROR';
         $message[] = $this->_db->getErrorMsg();
         appLogMessage($message, 'database');
     }
     if ($type != 'one' && in_array('plgAfterFind', $callbacks) && method_exists($this, 'plgAfterFind')) {
         $rows = $this->plgAfterFind($rows);
     }
     if ($type != 'one' && in_array('afterFind', $callbacks) && method_exists($this, 'afterFind')) {
         $rows = $this->afterFind($rows);
     }
     if ($cache === true && !Configure::read('Cache.disable') && Configure::read('Cache.query') === true) {
         S2Cache::write($cache_key, $rows);
     }
     if ($type != 'one' && in_array('plgAfterAfterFind', $callbacks) && method_exists($this, 'plgAfterAfterFind')) {
         $rows = $this->plgAfterAfterFind($rows);
     }
     return $rows;
 }
Beispiel #10
0
 /**
  * Return the settings for current cache engine
  *
  * @param string $engine Name of the engine
  * @return array list of settings for this engine
  * @access public
  * @static
  */
 function settings($engine = null)
 {
     $_this =& S2Cache::getInstance();
     if (!$engine && isset($_this->__config[$_this->__name]['engine'])) {
         $engine = $_this->__config[$_this->__name]['engine'];
     }
     if (isset($_this->_Engine[$engine]) && !is_null($_this->_Engine[$engine])) {
         return $_this->_Engine[$engine]->settings();
     }
     return array();
 }
Beispiel #11
0
 /**
  * Facebook Open Graph implementation
  * 
  * @param mixed $listing
  * @param mixed $meta
  */
 function facebookOpenGraph(&$listing, $meta)
 {
     // http://developers.facebook.com/docs/opengraph/
     $option = Sanitize::getString($_REQUEST, 'option', '');
     $view = Sanitize::getString($_REQUEST, 'view', '');
     $id = Sanitize::getInt($_REQUEST, 'id');
     // Make sure this is a Joomla article page
     if (!($option == 'com_content' && $view == 'article' && $id)) {
         return;
     }
     $Config = Configure::read('JreviewsSystem.Config');
     if (empty($Config)) {
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = S2Cache::read($cache_file);
     }
     $facebook_xfbml = Sanitize::getBool($Config, 'facebook_opengraph') && Sanitize::getBool($Config, 'facebook_appid');
     // Make sure FB is enabled and we have an FB App Id
     if (!$facebook_xfbml) {
         return;
     }
     extract($meta);
     $title == '' and $title = $listing['Listing']['title'];
     $description == '' and $description = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'summary'));
     $image = isset($listing['Listing']['images'][0]) ? cmsFramework::makeAbsUrl(_DS . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path']) : null;
     if (!$image) {
         $img_src = '/<img[^>]+src[\\s=\'"]+([^"\'>\\s]+(jpg)+)/is';
         preg_match($img_src, $listing['Listing']['summary'], $matches);
         if (isset($matches[1])) {
             $image = $matches[1];
         }
     }
     $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true, 'ampreplace' => true));
     $fields = $listing['Field']['pairs'];
     // You can add other Open Graph meta tags by adding the attribute, custom field pair to the array below
     $tags = array('title' => $title, 'url' => $url, 'image' => $image, 'site_name' => cmsFramework::getConfig('sitename'), 'description' => $description, 'type' => Sanitize::getString($listing['ListingType']['config'], 'facebook_opengraph_type'), 'latitude' => Sanitize::getString($Config, 'geomaps.latitude'), 'longitude' => Sanitize::getString($Config, 'geomaps.longitude'), 'street-address' => Sanitize::getString($Config, 'geomaps.address1'), 'locality' => Sanitize::getString($Config, 'geomaps.city'), 'region' => Sanitize::getString($Config, 'geomaps.state'), 'postal-code' => Sanitize::getString($Config, 'geomaps.postal_code'), 'country-name' => Sanitize::getString($Config, 'geomaps.country', Sanitize::getString($Config, 'geomaps.default_country')));
     cmsFramework::addScript('<meta property="fb:app_id" content="' . Sanitize::getString($Config, 'facebook_appid') . '"/>');
     Sanitize::getString($Config, 'facebook_admins') != '' and cmsFramework::addScript('<meta property="fb:admins" content="' . str_replace(' ', '', $Config->facebook_admins) . '"/>');
     //        cmsFramework::addScript('<meta property="fb:admins" content="YOUR-ADMIN-ID"/>'); // It's app_id or this, not both
     # Loop through the tags array to add the additional FB meta tags
     foreach ($tags as $attr => $fname) {
         $content = '';
         if (substr($fname, 0, 3) == 'jr_') {
             // It's a custom field
             $content = isset($fields[$fname]) ? htmlspecialchars($fields[$fname]['text'][0], ENT_QUOTES, 'utf-8') : '';
         } elseif ($fname != '') {
             // It's a static text, not a custom field
             $content = htmlspecialchars($fname);
         }
         $content != '' and cmsFramework::addScript('<meta property="og:' . $attr . '" content="' . $content . '"/>');
     }
 }
Beispiel #12
0
 function startup(&$controller = null)
 {
     if ($Config = Configure::read('JreviewsSystem.Config')) {
         $this->merge($Config);
     } else {
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = S2Cache::read($cache_file);
         if (false == $Config || empty($Config)) {
             $Config = $this->load();
             S2Cache::write($cache_file, $Config);
         }
         $this->merge($Config);
         Configure::write('JreviewsSystem.Config', $Config);
     }
     Configure::write('System.version', strip_tags($this->version));
     Configure::write('Theme.name', $this->template);
     Configure::write('Community.extension', $this->community);
     Configure::write('Cache.enable', true);
     Configure::write('Cache.disable', false);
     Configure::write('Cache.expires', $this->cache_expires);
     Configure::write('Cache.query', (bool) $this->cache_query);
     Configure::write('Cache.view', (bool) $this->cache_view);
     Configure::write('Cache.assets_css', (bool) $this->cache_css);
     Configure::write('Cache.assets_js', (bool) $this->cache_js);
     Configure::write('Jreviews.editor_rank_exclude', (bool) $this->editor_rank_exclude);
 }
Beispiel #13
0
 function getParentCatIds($cat_id)
 {
     # Check for cached version
     $cache_file = 'jreviews_menu_cat_' . cmsFramework::locale() . '_' . cmsFramework::getCustomToken($cat_id);
     if (Configure::read('Cache.query') && ($cache = S2Cache::read($cache_file))) {
         return $cache['___menu_cat'];
     }
     $query = "\n        (\n            SELECT \n                ParentCategory.id AS cat_id,\n                ParentCategory.lft AS lft\n            FROM \n                #__categories AS Category, \n                #__categories AS ParentCategory\n            INNER JOIN\n                #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = ParentCategory.id\n            WHERE \n                (\n                    ParentCategory.id = " . (int) $cat_id . " AND ParentCategory.published = 1\n                )\n        )\n        UNION\n        (\n            SELECT \n                ParentCategory.id AS cat_id,\n                ParentCategory.lft AS lft\n            FROM\n                #__categories AS Category,\n                #__categories AS ParentCategory\n            INNER JOIN\n                #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = ParentCategory.id\n            WHERE\n                (            \n                    Category.published = 1\n                    AND Category.lft BETWEEN ParentCategory.lft AND ParentCategory.rgt\n                    AND Category.id = " . (int) $cat_id . "\n                    AND ParentCategory.parent_id > 0\n                )\n            ORDER BY \n                Category.lft\n        )\n        ";
     $rows = $this->query($query, 'loadObjectList');
     $last = array_shift($rows);
     array_push($rows, $last);
     Configure::read('Cache.query') and S2Cache::write($cache_file, array('___menu_cat' => $rows));
     return $rows;
 }
Beispiel #14
0
 /**
  * S2Object destructor.
  *
  * Writes cache file if changes have been made to the $__map or $__paths
  *
  * @return void
  * @access private
  */
 function __destruct()
 {
     if ($this->__cache) {
         $core = Configure::corePaths('s2framework');
         unset($this->__paths[rtrim($core[0], DS)]);
         S2Cache::write('dir_map', array_filter($this->__paths), '_s2framework_core_');
         S2Cache::write('file_map', array_filter($this->__map), '_s2framework_core_');
     }
 }
Beispiel #15
0
 function store($arr = null)
 {
     $db = cmsFramework::getDB();
     if (is_null($arr)) {
         $arr = get_object_vars($this);
     }
     while (list($prop, $val) = each($arr)) {
         if ($prop != 'c') {
             if (is_array($val)) {
                 $val = json_encode($val);
             } else {
                 // Fixes an issue where an Array string is added to some values
                 $val = str_replace(',Array', '', $val);
             }
             $db->setQuery("\n                    UPDATE \n                        #__jreviews_config\n\t\t\t\t\tSET \n                        value= '" . $db->getEscaped($val) . "'\n\t\t\t\t\tWHERE \n                        id = '" . $db->getEscaped($prop) . "'");
             $db->query();
             $db->setQuery("SELECT \n                        count(*) \n                    FROM \n                        #__jreviews_config \n                    WHERE \n                        id = '" . $db->getEscaped($prop) . "'");
             $saved = $db->loadResult();
             if (!$saved) {
                 $db->setQuery("\n                        INSERT INTO\n                            #__jreviews_config (id, value) \n\t\t\t\t\t\tVALUES\n                            ('" . $db->getEscaped($prop) . "', '" . $db->getEscaped($val) . "')\n                    ");
                 if (!$db->query()) {
                     echo "<br/>" . $db->getErrorMsg();
                     exit;
                 }
             }
         }
     }
     if (defined('MVC_FRAMEWORK_ADMIN')) {
         // Forces clear cache when config settings are modified in the administration
         clearCache('', 'views');
         clearCache('', '__data');
     } else {
         // Push updates to the cached file
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = $this->load();
         S2Cache::write($cache_file, $Config);
     }
 }
Beispiel #16
0
 * 		'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
 *	));
 *
 * Xcache (http://xcache.lighttpd.net/)
 *
 * 	 Cache::config('default', array(
 *		'engine' => 'Xcache', //[required]
 *		'duration'=> 3600, //[optional]
 *		'probability'=> 100, //[optional]
 * 		'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
 *		'user' => 'user', //user from xcache.admin.user settings
 *      'password' => 'password', //plaintext password (xcache.admin.pass)
 *	));
 *
 *
 * Memcache (http://www.danga.com/memcached/)
 *
 * 	 Cache::config('default', array(
 *		'engine' => 'Memcache', //[required]
 *		'duration'=> 3600, //[optional]
 *		'probability'=> 100, //[optional]
 * 		'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
 * 		'servers' => array(
 * 			'127.0.0.1:11211' // localhost, default port 11211
 * 		), //[optional]
 * 		'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
 *	));
 *
 */
S2Cache::config('default', array('engine' => 'File', 'path' => S2Paths::get('jreviews', 'S2_CACHE') . '__data'));