Пример #1
0
 function getTemplateSettings($section_id)
 {
     # Check for cached version
     $cache_prefix = 'section_model_themesettings';
     $cache_key = func_get_args();
     if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
         return $cache;
     }
     $fields = array('JreviewsSection.tmpl AS `Section.tmpl_list`', 'JreviewsSection.tmpl_suffix AS	`Section.tmpl_suffix`');
     $query = "SELECT " . implode(',', $fields) . "\n FROM #__sections AS Section" . "\n LEFT JOIN #__jreviews_sections AS JreviewsSection ON Section.id = JreviewsSection.sectionid" . "\n WHERE Section.id = " . $section_id;
     $this->_db->setQuery($query);
     $result = end($this->__reformatArray($this->_db->loadAssocList()));
     # Send to cache
     S2cacheWrite($cache_prefix, $cache_key, $result);
     return $result;
 }
 function getTemplateSettings($listing_id)
 {
     # Check for cached version
     $cache_prefix = 'everywhere_content_themesettings';
     $cache_key = func_get_args();
     if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
         return $cache;
     }
     $fields = array('JreviewsSection.tmpl AS `Section.tmpl_list`', 'JreviewsSection.tmpl_suffix AS	`Section.tmpl_suffix`', 'JreviewsCategory.tmpl AS `Category.tmpl_list`', 'JreviewsCategory.tmpl_suffix AS `Category.tmpl_suffix`');
     $query = "\n            SELECT \n                " . implode(',', $fields) . "\n\t\t    FROM \n                #__content AS Listing\n\t\t    INNER JOIN \n                #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.option = 'com_content'\n\t\t    LEFT JOIN \n                #__categories AS Category ON JreviewsCategory.id = Category.id \n\t\t    LEFT JOIN \n                #__sections AS Section ON Category.section = Section.id\n\t\t    LEFT JOIN \n                #__jreviews_sections AS JreviewsSection ON Section.id = JreviewsSection.sectionid\n\t\t    WHERE \n                Listing.id = " . $listing_id;
     $this->_db->setQuery($query);
     $result = end($this->__reformatArray($this->_db->loadAssocList()));
     # Send to cache
     S2cacheWrite($cache_prefix, $cache_key, $result);
     return $result;
 }
Пример #3
0
 /**
  * Joomla 1.5 only method
  * 
  * @param string $dir_id
  * @param mixed $module
  * @return string
  */
 function getTree($dir_id, $module = false)
 {
     // Clean $dir_id string
     $cleaned = array();
     $section_count = null;
     $bits = explode(',', $dir_id);
     foreach ($bits as $bit) {
         if (is_numeric($bit)) {
             $cleaned[] = $bit;
         }
     }
     $dir_id = implode(',', $cleaned);
     $Config = Configure::read('JreviewsSystem.Config');
     $Access = Configure::read('JreviewsSystem.Access');
     $aid = $Access->getAccessId();
     $module and $Config->dir_category_limit = '';
     // Ignore category limit setting in dir module
     # Check for cached version
     $cache_prefix = 'directory_mode_gettree';
     $cache_key = array(func_get_args(), $aid, cmsFramework::language());
     if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
         return $cache;
     }
     # First get list of sections for current dir
     $query = "\n            SELECT \n                Category.section AS `Section.section_id`,\n                JreviewsCategory.dirid AS `Directory.dir_id`\n            FROM \n                #__jreviews_categories AS JreviewsCategory                             \n            LEFT JOIN \n                #__jreviews_directories AS Directory ON Directory.id = JreviewsCategory.dirid\n            RIGHT JOIN \n                #__categories AS Category ON Category.id = JreviewsCategory.id\n            LEFT JOIN \n                #__sections AS Section ON Category.section = Section.id\n            WHERE \n                Section.published = 1\n                AND Section.access <= {$aid}" . ($dir_id ? " AND JreviewsCategory.dirid IN ({$dir_id}) " : '') . "\n            AND JreviewsCategory.`option` = 'com_content'\n            ORDER BY \n                Directory.`desc` ASC \n            ";
     $query = $this->_db->setQuery($query);
     $tmp_key = $this->primaryKey;
     $this->primaryKey = 'Section.section_id';
     $sections = $this->_db->loadObjectList();
     $sections = $this->__reformatArray($sections);
     $this->primaryKey = $tmp_key;
     $section_ids = array_keys($sections);
     // Get listing count for sections
     $Config->dir_section_num_entries = $Config->dir_cat_num_entries;
     if ($Config->dir_section_num_entries || $Config->dir_category_hide_empty) {
         $query = '
             SELECT  
                 Listing.sectionid AS `Section.section_id`, 
                 COUNT(Listing.id) AS `Section.listing_count` 
             FROM 
                 #__content AS Listing
             INNER JOIN
                 #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = Listing.catid AND JreviewsCategory.`option` = "com_content"
             WHERE 
                 Listing.sectionid IN (' . implode(',', $section_ids) . ')  
                 AND Listing.state = 1
                 AND Listing.access <= ' . $aid . '
                 AND ( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" ) 
                 AND ( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )
             GROUP BY Listing.sectionid
          ';
         $this->_db->setQuery($query);
         //prx($this->_db->getQuery());
         $tmp_key = $this->primaryKey;
         $this->primaryKey = 'Section.section_id';
         $section_count = $this->_db->loadObjectList();
         $section_count = $this->__reformatArray($section_count);
         $this->primaryKey = $tmp_key;
     }
     # If category limit is zero then don't query the categories
     if ($Config->dir_category_limit === '0') {
         $tmp_key = $this->primaryKey;
         $this->primaryKey = 'Category.cat_id';
         $query = '
             SELECT 
                 Directory.id AS `Directory.dir_id`,
                 Directory.`desc` AS `Directory.title`,
                 Directory.title AS `Directory.slug`,                    
                 Section.id AS `Section.section_id`,
                 Section.name  AS `Section.name`,
                 Section.title AS `Section.title`,
                 Section.image AS `Section.image`,
                 Section.published AS `Section.published`,
                 Section.access AS `Section.access`,
                 Section.alias AS `Section.slug`,   
                 Section.ordering AS `Section.ordering`   
             FROM
                 #__jreviews_categories AS JreviewsCategory 
             RIGHT JOIN    
                  #__categories AS Category USING(id)
             LEFT JOIN
                 #__sections AS Section ON Section.id = Category.section
             LEFT JOIN
                 #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id
             WHERE 
                 Category.published = 1
                 AND Section.access <= ' . $aid . '
                 AND Category.access <= ' . $aid . '
                 AND Category.section IN (' . implode(',', $section_ids) . ')         
                 AND JreviewsCategory.`option` = "com_content"                    
             GROUP BY
                 Category.section
             ORDER BY 
                 Directory.`desc` ASC 
         ';
         $this->_db->setQuery($query);
         $categories = $this->_db->loadObjectList();
     } else {
         $categories = array();
         $tmp_key = $this->primaryKey;
         $this->primaryKey = 'Category.cat_id';
         foreach ($sections as $section) {
             $section_id = $section['Section']['section_id'];
             $query = '
                 SELECT  
                     Directory.id AS `Directory.dir_id`,
                     Directory.`desc` AS `Directory.title`,
                     Directory.title AS `Directory.slug`,                    
                     Section.id AS `Section.section_id`,
                     Section.name  AS `Section.name`,
                     Section.title AS `Section.title`,
                     Section.image AS `Section.image`,
                     Section.published AS `Section.published`,
                     Section.access AS `Section.access`,
                     Section.alias AS `Section.slug`,   
                     Section.ordering AS `Section.ordering`,   
                     Category.id AS `Category.cat_id`,            
                     Category.title AS `Category.title`,
                     Category.image AS `Category.image`,
                     Category.published AS `Category.published`,
                     Category.access AS `Category.access`,
                     Category.alias AS `Category.slug`
                     ' . ($Config->dir_cat_num_entries || $Config->dir_category_hide_empty ? '
                         ,(SELECT 
                           count(*) 
                           FROM #__content AS Listing
                           RIGHT JOIN #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = Listing.catid AND JreviewsCategory.`option` = "com_content"
                           WHERE 
                                 Listing.sectionid = ' . $section_id . '
                                 AND Listing.catid = Category.id         
                                 AND Listing.state = 1 
                                 AND Listing.access <= ' . $aid . '
                                 AND ( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" ) 
                                 AND ( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )
                         ) AS `Category.listing_count` ' : '') . '
                 FROM
                     #__jreviews_categories AS JreviewsCategory 
                 RIGHT JOIN    
                      #__categories AS Category USING(id)
                 LEFT JOIN
                     #__sections AS Section ON Section.id = Category.section
                 LEFT JOIN
                     #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id
                 WHERE 
                     Category.published = 1
                     AND Section.access <= ' . $aid . '
                     AND Category.access <= ' . $aid . '
                     AND Category.section = ' . $section_id . '         
                     AND JreviewsCategory.`option` = "com_content"                    
                 ORDER BY 
                 ' . (!$Config->dir_category_order ? 'Category.ordering' : 'Category.title ASC') . '
                 ' . (!empty($Config->dir_category_limit) ? ' LIMIT ' . $Config->dir_category_limit : '') . '
             ';
             $this->_db->setQuery($query);
             $categories = array_merge($categories, $this->_db->loadObjectList());
         }
     }
     $categories = $this->__reformatArray($categories);
     $this->primaryKey = $tmp_key;
     App::import('Model', 'menu', 'jreviews');
     $Menu = ClassRegistry::getClass('MenuModel');
     $results = array();
     foreach ($categories as $key => $row) {
         $section_id = $row['Section']['section_id'];
         $section_title = $row['Section']['title'];
         isset($row['Category']) and $cat_id = $row['Category']['cat_id'];
         isset($row['Category']) and $cat_title = $row['Category']['title'];
         $dirKey = $row['Directory']['dir_id'] . ':' . $row['Directory']['slug'];
         $dir_id = $row['Directory']['dir_id'];
         if (!isset($rows[$dirKey]['Directory'])) {
             $results[$dirKey]['Directory']['title'] = $row['Directory']['title'];
             $results[$dirKey]['Directory']['slug'] = $row['Directory']['slug'];
             $results[$dirKey]['Directory']['dir_id'] = $row['Directory']['dir_id'];
             $results[$dirKey]['Directory']['menu_id'] = $Menu->getDir($dir_id);
         }
         // Section data
         $sectionKey = $section_id . ':' . $section_title;
         $results[$dirKey]['Sections'][$sectionKey]['section_id'] = $row['Section']['section_id'];
         $results[$dirKey]['Sections'][$sectionKey]['title'] = $row['Section']['title'];
         $results[$dirKey]['Sections'][$sectionKey]['slug'] = $row['Section']['slug'];
         $results[$dirKey]['Sections'][$sectionKey]['image'] = $row['Section']['image'];
         $results[$dirKey]['Sections'][$sectionKey]['image'] = $row['Section']['image'];
         $results[$dirKey]['Sections'][$sectionKey]['published'] = $row['Section']['published'];
         $results[$dirKey]['Sections'][$sectionKey]['access'] = $row['Section']['access'];
         $results[$dirKey]['Sections'][$sectionKey]['ordering'] = $row['Section']['ordering'];
         $results[$dirKey]['Sections'][$sectionKey]['menu_id'] = $Menu->getSection($section_id, $dir_id);
         $results[$dirKey]['Sections'][$sectionKey]['dir_id'] = $dir_id;
         if (!empty($section_count) && isset($section_count[$row['Section']['section_id']])) {
             $results[$dirKey]['Sections'][$sectionKey]['listing_count'] = $section_count[$row['Section']['section_id']]['Section']['listing_count'];
         } else {
             $results[$dirKey]['Sections'][$sectionKey]['listing_count'] = 0;
         }
         // Category data
         if (!empty($row['Category'])) {
             $catKey = $cat_id . ':' . $cat_title;
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['cat_id'] = $cat_id;
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['title'] = $row['Category']['title'];
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['slug'] = $row['Category']['slug'];
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['image'] = $row['Category']['image'];
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['published'] = $row['Category']['published'];
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['access'] = $row['Category']['access'];
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['menu_id'] = $Menu->getCategory($cat_id, $section_id, $dir_id);
             $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['dir_id'] = $dir_id;
             isset($row['Category']['listing_count']) and $results[$dirKey]['Sections'][$sectionKey]['Categories'][$catKey]['listing_count'] = $row['Category']['listing_count'];
         }
     }
     foreach ($results as $dir_id => $sections) {
         $sections['Sections'] =& $results[$dir_id]['Sections'];
         $section_sort = $Config->dir_section_order ? 'sort_sections_alpha' : 'sort_sections_ordering';
         uasort($sections['Sections'], array($this, $section_sort));
     }
     # Send to cache
     S2cacheWrite($cache_prefix, $cache_key, $results);
     return $results;
 }
Пример #4
0
 function getTemplateSettings($review_id)
 {
     # Check for cached version
     $cache_prefix = 'review_model_themesettings';
     $cache_key = func_get_args();
     if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
         return $cache;
     }
     $fields = array('JreviewsSection.tmpl AS `Section.tmpl_list`', 'JreviewsSection.tmpl_suffix AS    `Section.tmpl_suffix`', 'JreviewsCategory.tmpl AS `Category.tmpl_list`', 'JreviewsCategory.tmpl_suffix AS `Category.tmpl_suffix`');
     $query = "SELECT " . implode(',', $fields) . "\n FROM #__jreviews_comments AS Review" . "\n LEFT JOIN #__content AS Listing ON Review.pid = Listing.id" . "\n LEFT JOIN #__categories AS Category ON Listing.catid = Category.id" . "\n LEFT JOIN #__jreviews_categories AS JreviewsCategory ON Category.id = JreviewsCategory.id" . "\n LEFT JOIN #__sections AS Section ON Category.section = Section.id" . "\n LEFT JOIN #__jreviews_sections AS JreviewsSection ON Section.id = JreviewsSection.sectionid" . "\n WHERE JreviewsCategory.option = 'com_content' AND Review.id = " . $review_id;
     $this->_db->setQuery($query);
     $result = end($this->__reformatArray($this->_db->loadAssocList()));
     # Send to cache
     S2cacheWrite($cache_prefix, $cache_key, $result);
     return $result;
 }
Пример #5
0
 /**
  * Auxiliary function - used for custom coding
  * Creates an array of fields with field names as array keys and attributes and options using an array of field names as input
  */
 function getFields($names, $location = 'listing')
 {
     if (empty($names) || count($names) == 1 & $names[0] == 'category') {
         return array();
     }
     $rows = false;
     # Check for cached version
     $cache_prefix = 'field_model_names';
     $cache_key = func_get_args();
     if (isset($cache_key[2])) {
         unset($cache_key[2]);
     }
     // $entry not required to cache the results
     if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
         $rows = $cache;
     }
     if (false == $rows || $rows == '') {
         $location = $location == 'listing' ? 'content' : $location;
         foreach ($names as $name) {
             $quoted_names[] = "'" . $name . "'";
         }
         $quoted_names = implode(',', $quoted_names);
         //get field attributes only, no values
         $sql = "SELECT Field.fieldid AS `Field.id`, Field.name AS `Field.name`, Field.title AS `Field.title`," . "\n Field.type AS `Field.type`, Field.options AS `Field.params`,  Field.required AS `Field.required`, Field.access_view AS `Field.access_view`," . "\n `Group`.groupid AS `Group.group_id`, `Group`.title AS `Group.title`" . "\n FROM #__jreviews_fields AS Field" . "\n INNER JOIN #__jreviews_groups AS `Group` ON (`Group`.groupid = Field.groupid AND " . "\n `Group`.groupid AND `Group`.type =  '{$location}' )" . "\n WHERE Field.name IN ({$quoted_names}) AND Field.location = '{$location}'";
         $this->_db->setQuery($sql);
         $rows = $this->_db->loadObjectList();
         # Send to cache
         S2cacheWrite($cache_prefix, $cache_key, $rows);
     }
     if (!$rows || empty($rows)) {
         return;
     }
     //extract field ids from array
     $this->field_ids = $multi_field_ids = $this->_extractFieldIds($rows, array('select', 'selectmultiple', 'radiobuttons', 'checkboxes'));
     //get the field options for multiple choice fields
     $this->_getFieldOptions();
     // Reformat array and add field options to each multiple choice field
     foreach ($rows as $row) {
         $row = (array) $row;
         //FieldGroups array
         $fields[$row['Field.name']]['field_id'] = $row['Field.id'];
         $fields[$row['Field.name']]['name'] = $row['Field.name'];
         $fields[$row['Field.name']]['type'] = $row['Field.type'];
         $fields[$row['Field.name']]['title'] = $row['Field.title'];
         $fields[$row['Field.name']]['required'] = $row['Field.required'];
         $fields[$row['Field.name']]['properties']['access_view'] = $row['Field.access_view'];
         $params = explode("\n", $row['Field.params']);
         foreach ($params as $param) {
             $parts = explode("=", $param);
             // Need to use this approach because click2search field has equal signs in the value of the property
             $key = array_shift($parts);
             $value = implode('=', $parts);
             $fields[$row['Field.name']]['properties'][$key] = $value;
         }
         if (isset($this->field_options_alpha[$row['Field.id']])) {
             $ordering = isset($fields[$row['Field.name']]['Fields'][$row['Field.name']]['properties']['option_ordering']) && $fields[$row['Group.title']]['Fields'][$row['Field.name']]['properties']['option_ordering'] ? 'alpha' : 'ordering';
             $method = 'field_options_' . $ordering;
             $methodList = 'field_optionsList_' . $ordering;
             $fields[$row['Field.name']]['options'] = $this->{$method}[$row['Field.id']];
             $fields[$row['Field.name']]['optionList'] = $this->{$methodList}[$row['Field.id']];
         }
     }
     return $fields;
 }
Пример #6
0
 /**
  * J15 only method  
  * Advanced Search Module
  * Generate Section-Category tree array
  */
 function categoryTree($gid, $settings)
 {
     # Check for cached version
     $cache_prefix = 'category_model_categorytree';
     $cache_key = func_get_args();
     if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
         return $cache;
     }
     $Access = Configure::read('JreviewsSystem.Access');
     # Get module parameters
     $module_id = Sanitize::getInt($settings, 'module_id');
     $criteria_id = cleanIntegerCommaList(Sanitize::getString($settings['module'], 'criteria_id'));
     $dir_id = cleanIntegerCommaList(Sanitize::getString($settings['module'], 'dir_id'));
     $section_id = cleanIntegerCommaList(Sanitize::getString($settings['module'], 'section_id'));
     $category_id = cleanIntegerCommaList(Sanitize::getString($settings['module'], 'cat_id'));
     $cat_order_alpha = Sanitize::getInt($settings['module'], 'cat_order_alpha', 1);
     $section_title = Sanitize::getString($settings['module'], 'section_title', 1);
     $section_bg = Sanitize::getString($settings['module'], 'section_bg', '#CCCCCC');
     $category_bg = Sanitize::getString($settings['module'], 'category_bg', '#FFFFFF');
     $section_color = Sanitize::getString($settings['module'], 'section_color', '#000000');
     $category_color = Sanitize::getString($settings['module'], 'category_color', '#000000');
     $option_length = Sanitize::getInt($settings['module'], 'option_length', '');
     $cat_auto = Sanitize::getInt($settings['module'], 'cat_auto');
     # Selected categories and sections
     $selOption = explode('_', Sanitize::getString($settings, 'cat'));
     $cat_auto and is_numeric($category_id) and $selOption = array($category_id);
     $selSection = Sanitize::getString($settings, 'section');
     $cat_auto and is_numeric($section_id) and $selSection = $section_id;
     $order = array();
     $conditions = array();
     $order[] = $cat_order_alpha ? "Section.title ASC" : "Section.ordering ASC";
     $order[] = $cat_order_alpha ? "Category.title ASC" : "Category.ordering ASC";
     if (!$section_id && $dir_id) {
         $conditions[] = "JreviewCategory.dirid IN ({$dir_id})";
     }
     if (!$section_id && $criteria_id) {
         $conditions[] = "JreviewCategory.criteriaid IN ({$criteria_id})";
     }
     if ($section_id) {
         $conditions[] = "Category.section IN ({$section_id})";
     } elseif ($category_id) {
         $conditions[] = "Category.section IN (SELECT section FROM #__categories WHERE id IN ({$category_id}))";
     }
     $conditions[] = "Category.published = 1";
     $conditions[] = "Category.access <= '" . $Access->getAccessId() . "'";
     $conditions[] = "JreviewCategory.option = 'com_content'";
     if ($cat_auto && $section_id == '' && $category_id == '' && $criteria_id == '' && $dir_id == '') {
         array_pop($order);
         $query = "SELECT DISTINCT Category.section AS sectionid," . ($option_length > 0 ? "\n CONCAT(SUBSTR(Section.title,1," . $option_length . "),'...') AS section" : "\n Section.title AS section") . "\n FROM #__jreviews_categories AS JreviewCategory" . "\n LEFT JOIN #__categories AS Category ON Category.id = JreviewCategory.id" . "\n LEFT JOIN #__sections AS Section ON Category.section = Section.id" . "\n WHERE " . implode(" AND \n", $conditions) . "\n ORDER BY " . implode(",", $order);
     } else {
         $query = "SELECT Category.id AS catid, Category.section AS sectionid," . ($option_length > 0 ? "\n CONCAT(SUBSTR(Category.title,1," . $option_length . "),'...') AS category," : "\n Category.title AS category,") . ($option_length > 0 ? "\n CONCAT(SUBSTR(Section.title,1," . $option_length . "),'...') AS section" : "\n Section.title AS section") . "\n FROM #__jreviews_categories AS JreviewCategory" . "\n LEFT JOIN #__categories AS Category ON Category.id = JreviewCategory.id" . "\n LEFT JOIN #__sections AS Section ON Category.section = Section.id" . "\n WHERE " . implode(" AND \n", $conditions) . "\n ORDER BY " . implode(",", $order);
     }
     $this->_db->setQuery($query);
     $options = $this->_db->loadObjectList();
     $selSection > 0 and array_push($selOption, 's' . $selSection);
     // Start building section/category select list
     $categoryList = array();
     $categoryList[] = '<select name="data[categories]" class="jrSelect">';
     $categoryList[] = '<option value="">' . __t("Select Category", true) . '</option>';
     isset($options[0]) and $prevSection = $options[0]->sectionid;
     if ($options) {
         foreach ($options as $key => $option) {
             $selected = '';
             if ($option->sectionid == $prevSection && $key > 0 || !$section_title) {
                 // Add categories
                 if (in_array($option->catid, $selOption)) {
                     $selected = 'selected="selected"';
                 }
                 isset($option->catid) and $categoryList[] = '<option value="' . $option->catid . '" style="color:' . $category_color . ';background-color:' . $category_bg . '" ' . $selected . '>&nbsp;&nbsp;&nbsp;' . stripslashes($option->category) . '</option>';
             } else {
                 // Add section
                 in_array('s' . $option->sectionid, $selOption) and $selected = 'selected="selected"';
                 $categoryList[] = '<option value="s' . $option->sectionid . '" style="font-weight:bold;color:' . $section_color . ';background-color:' . $section_bg . ';" ' . $selected . '>' . stripslashes($option->section) . '</option>';
                 $selected = '';
                 if (isset($option->catid)) {
                     in_array($option->catid, $selOption) and $selected = 'selected="selected"';
                     $categoryList[] = '<option value="' . $option->catid . '" style="color:' . $category_color . ';background-color:' . $category_bg . '" ' . $selected . '>&nbsp;&nbsp;&nbsp;' . stripslashes($option->category) . '</option>';
                 }
             }
             $prevSection = $option->sectionid;
         }
     }
     $categoryList[] = '</select>';
     $categorySelect = implode("\n", $categoryList);
     # Send to cache
     S2cacheWrite($cache_prefix, $cache_key, $categorySelect);
     return $categorySelect;
 }
Пример #7
0
 function __construct()
 {
     parent::__construct();
     $menuList = array();
     switch (getCmsVersion()) {
         case CMS_JOOMLA15:
             $select = 'SELECT id,name,link AS menu_type,link,componentid,params,access,published';
             $type = "\n AND type = 'component'";
             $link = "\n AND ( \n                    link LIKE '%option=com_content&view=section%' OR\n                    link LIKE '%option=com_content&view=section&layout=blog%' OR\n                    link LIKE '%option=com_content&view=category\\%' OR\n                    link LIKE '%option=com_content&view=category&layout=blog%' OR\n                    link LIKE '%option=com_content&view=article%'                \n                )";
             break;
         case CMS_JOOMLA16:
             $select = "\n                    SELECT \n                        id, \n                        alias AS name,\n                        link AS menu_type,\n                        link,\n                        component_id AS componentid,\n                        params,\n                        access,\n                        published\n                ";
             $type = "\n AND type = 'component'";
             $link = "\n AND ( \n                    link LIKE '%option=com_content&view=section%' OR\n                    link LIKE '%option=com_content&view=section&layout=blog%' OR\n                    link LIKE '%option=com_content&view=category\\%' OR\n                    link LIKE '%option=com_content&view=category&layout=blog%' OR\n                    link LIKE '%option=com_content&view=article%'                \n                )";
             break;
     }
     // Get all com_content category/section menus and jReviews menus
     $sql = $select . "\n FROM #__menu" . "\n WHERE published = 1" . (getCmsVersion() == CMS_MAMBO46 ? "\n ORDER BY link ASC" : "\n ORDER BY link DESC");
     # Check for cached version
     $cache_prefix = 'menu_model';
     $cache_key = $sql;
     if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
         $menuList = $cache;
     }
     if (empty($menuList)) {
         // Mambo4.6, as opposed to Mambo4.5, does not allow using other components Itemids so jReviews
         // Sections and category lists cannot use the section/category table or blog list menu Itemids
         $this->_db->setQuery($sql);
         $menuList = $this->_db->loadObjectList();
         # Send to cache
         S2cacheWrite($cache_prefix, $cache_key, $menuList);
     }
     // Get itemid for each menu link and store it
     if (is_array($menuList)) {
         foreach ($menuList as $menu) {
             $this->menues[$menu->id] = $menu;
             $params = stringToArray($menu->params);
             $paramsArray = explode("\n", $menu->params);
             if (Sanitize::getVar($params, 'sef_name') != '') {
                 $m_name = Sanitize::getVar($params, 'sef_name');
             } else {
                 $m_name = $menu->name;
             }
             if (function_exists("sefEncode")) {
                 $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);
             # Fix for change in menu structure in J1.5
             if (getCmsVersion() == CMS_JOOMLA15) {
                 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);
                         //                                $this->set('jr_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);
                             //                                    $this->set('jr_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);
                         //                            $this->set('jr_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);
                             //                                    $this->set('jr_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->link == 'index.php?option=' . S2Paths::get('jreviews', 'S2_CMSCOMP')) {
                         // It's a jReviews menu
                         // Get a jReviews menu with public access to use in xajax requests
                         if ($menu->access == 0 && $menu->published == 1) {
                             $this->set('jreviews_public', $menu->id);
                         }
                         $menuParams = array();
                         foreach ($paramsArray as $parameter) {
                             $menuParams[current(explode('=', $parameter))] = end(explode('=', $parameter));
                         }
                         $this->set('jr_menu_action_' . $m_dir_id, $m_action);
                         $this->set('menu_params_' . $menu->id, $menuParams);
                         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;
             }
         }
     }
     //        prx($this->___menu_data);
 }