コード例 #1
0
 function _installfix()
 {
     // Load fields model
     App::import('Model', 'field', 'jreviews');
     $FieldModel = new FieldModel();
     $task = Sanitize::getString($this->data, 'task');
     $msg = '';
     $mambot_error = 0;
     switch ($task) {
         case 'fix_install_jreviews':
             if (!$this->_installPlugin()) {
                 $msg = "There was a problem updating the database or copying the plugin files. Make sure the Joomla plugins/content folder is writable.";
             }
             break;
         case 'fix_content_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_content'));
             $columns = array_keys($rows['#__jreviews_content']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'content'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'content');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the content fields";
             }
             break;
         case 'fix_review_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_review_fields'));
             $columns = array_keys($rows['#__jreviews_review_fields']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'review'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'review');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the review fields";
             }
             break;
         default:
             break;
     }
     cmsFramework::redirect("index.php?option=com_jreviews", $msg);
 }
コード例 #2
0
ファイル: index.php プロジェクト: atikahmed/joomla-probid
$menu_id = $menu_id == 99999999 ? null : $menu_id;
$menu_params = array();
# Check if this is a custom route
$route['url']['url'] = $url;
$route = S2Router::parse($route, false, 'jreviews');
/*******************************************************************
 *                         ADMIN ROUTING
 ******************************************************************/
if (defined('MVC_FRAMEWORK_ADMIN')) {
    // Ensure user has access to this function
    switch (getCmsVersion()) {
        case 'CMS_JOOMLA15':
            $User =& cmsFramework::getUser();
            $Acl =& cmsFramework::getACL();
            if ($Acl->acl_check('administration', 'manage', 'users', $User->usertype, 'components', S2Paths::get('jreviews', 'S2_CMSCOMP'))) {
                cmsFramework::redirect('index.php', JText::_('ALERTNOTAUTH'));
            }
            break;
        case 'CMS_JOOMLA16':
            if (!JFactory::getUser()->authorise('core.manage', S2Paths::get('jreviews', 'S2_CMSCOMP'))) {
                return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
            }
            break;
        default:
            die('Not authorized');
            break;
    }
    // Controller routing
    $act = Sanitize::getString($_REQUEST, 'act');
    if ($act == 'license') {
        $_GET['url'] = 'license';
コード例 #3
0
 function _process()
 {
     $urlSeparator = "_";
     $simple_search = Sanitize::getInt($this->data, 'simple_search');
     $keywords = Sanitize::getVar($this->data, 'keywords');
     $criteria = isset($this->data['Search']) ? Sanitize::getInt($this->data['Search'], 'criteria_id') : null;
     $dir = str_replace(array(',', ' '), array($urlSeparator, ''), Sanitize::getString($this->data, 'dir'));
     $cat = str_replace(array(',', ' '), array($urlSeparator, ''), Sanitize::getString($this->data, 'cat'));
     $section = str_replace(array(',', ' '), array($urlSeparator, ''), Sanitize::getString($this->data, 'section'));
     /*J15*/
     $order = Sanitize::getVar($this->data, 'order');
     $query_type = Sanitize::getVar($this->data, 'search_query_type');
     $scope = Sanitize::getVar($this->data, 'contentoptions');
     $author = Sanitize::getString($this->data, 'author');
     $categories = Sanitize::getVar($this->data, 'categories');
     $menu_id = Sanitize::getInt($this->data, 'menu_id');
     $tmpl_suffix = Sanitize::getString($this->data, 'tmpl_suffix');
     $illegal_chars = array('#', '/', '?', ':', urldecode('%E3%80%80'));
     // Last one is japanese double space
     $sort = '';
     # Load Routes helper
     App::import('Helper', 'routes', 'jreviews');
     $Routes = new RoutesHelper();
     // Replace ampersands with temp string to be replaced back as urlencoded ampersand further below
     $keywords = str_replace(array_keys($this->KeywordReplacementMask), array_values($this->KeywordReplacementMask), $keywords);
     # Get the Itemid
     $menu_id_param = $menu_id > 0 ? $menu_id : '';
     $url_params = '';
     # SIMPLE SEARCH
     if ($simple_search) {
         # Build the query string
         if (trim($keywords) != '') {
             $url_params .= (cmsFramework::mosCmsSef() ? '' : '/') . 'keywords' . _PARAM_CHAR . str_replace(' ', '+', urlencode(str_replace($illegal_chars, ' ', $keywords)));
         }
         !empty($dir) and $url_params .= "/dir" . _PARAM_CHAR . $dir;
         !empty($section) and $url_params .= "/cat" . _PARAM_CHAR . 's' . $section;
         /*J15*/
         !empty($cat) and $url_params .= "/cat" . _PARAM_CHAR . $cat;
         !empty($tmpl_suffix) and $url_params .= '/tmpl_suffix' . _PARAM_CHAR . $tmpl_suffix;
         !empty($order) and $sort = '/order' . _PARAM_CHAR . $order;
         # Checks if need to keep the Itemid on the result page
         if ($this->Config->search_itemid && $menu_id) {
             $url = $Routes->search_results($menu_id_param, '');
         } else {
             $url = $Routes->search_results(null, '');
         }
         $url = cmsFramework::route($url . $url_params . $sort);
         $url = str_replace(array_keys($this->KeywordReplacementUrl), array_values($this->KeywordReplacementUrl), $url);
         cmsFramework::redirect($url);
         exit;
     }
     # ADVANCED SEARCH
     $url_params = array();
     $criteria_param = $criteria ? (cmsFramework::mosCmsSef() ? '' : '/') . 'criteria:' . $criteria : '';
     // Search query type
     !empty($query_type) and $url_params[] = "query" . _PARAM_CHAR . $query_type;
     !empty($dir) != '' and $url_params[] = "dir" . _PARAM_CHAR . $dir;
     // Listing and reviews
     if ($keywords) {
         if ($scope) {
             $url_params[] = "scope" . _PARAM_CHAR . urlencode(implode($urlSeparator, $scope));
         }
         $url_params[] = "keywords" . _PARAM_CHAR . urlencode(str_replace($illegal_chars, ' ', $keywords));
     }
     // Author
     !empty($author) and $url_params[] = "author" . _PARAM_CHAR . urlencode($author);
     // Categories
     if (is_array($categories)) {
         // Remove empty values from array
         foreach ($categories as $index => $value) {
             if (empty($value)) {
                 unset($categories[$index]);
             }
         }
         if (!empty($categories)) {
             $cat = urlencode(implode($urlSeparator, $categories));
             !empty($cat) and $url_params[] = "cat" . _PARAM_CHAR . $cat;
         }
     } elseif ($categories != '') {
         // Single select category list
         !empty($categories) and $url_params[] = "cat" . _PARAM_CHAR . $categories;
     }
     // First pass to process numeric values, need to merge operator and operand into one parameter
     if (isset($this->data['Field'])) {
         foreach ($this->data['Field']['Listing'] as $key => $value) {
             if (substr($key, -9, 9) == '_operator') {
                 $operand = substr($key, 0, -9);
                 if (is_array($this->data['Field']['Listing'][$operand]) && is_numeric($this->data['Field']['Listing'][$operand][0]) || is_numeric($this->data['Field']['Listing'][$operand])) {
                     $this->data['Field']['Listing'][$operand] = $value . $urlSeparator . trim(implode('_', $this->data['Field']['Listing'][$operand]));
                 } elseif (is_array($this->data['Field']['Listing'][$operand]) && trim($this->data['Field']['Listing'][$operand][0]) != '' || !is_array($this->data['Field']['Listing'][$operand]) && trim($this->data['Field']['Listing'][$operand]) != '') {
                     // Assume it's a date field
                     $this->data['Field']['Listing'][$operand] = $value . $urlSeparator . "date_" . implode('_', $this->data['Field']['Listing'][$operand]);
                 } else {
                     $this->data['Field']['Listing'][$operand] = '';
                 }
                 // Remove trailing separator char
                 $this->data['Field']['Listing'][$operand] = rtrim($this->data['Field']['Listing'][$operand], $urlSeparator);
             }
         }
         // Second pass to process everything
         foreach ($this->data['Field']['Listing'] as $key => $value) {
             $key_parts = explode("_", $key);
             $imploded_value = '';
             if (substr($key, 0, 3) == "jr_" && substr($key, -9, 9) != '_operator' && @$key_parts[2] != 'reset') {
                 // multiple option field
                 if (is_array($value)) {
                     if (is_array($value[0]) && !empty($value[0])) {
                         $imploded_value = implode($urlSeparator, $value[0]);
                     } elseif (!is_array($value[0]) && implode('', $value) != '') {
                         $imploded_value = implode($urlSeparator, $value);
                     }
                     if ($key != '' && $imploded_value != '') {
                         $url_params[] = "{$key}" . _PARAM_CHAR . urlencode(trim($imploded_value));
                     }
                     // single option field
                 } elseif (!is_array($value) && trim($value) != '') {
                     $url_params[] = "{$key}" . _PARAM_CHAR . urlencode(trim($value));
                 }
             }
         }
     }
     // End isset $this->Data['Field']
     !empty($tmpl_suffix) and $url_params[] = 'tmpl_suffix' . _PARAM_CHAR . $tmpl_suffix;
     $url_params[] = "order" . _PARAM_CHAR . ($order ? $order : $this->Config->list_order_default);
     # Remove empty values from array
     foreach ($url_params as $index => $value) {
         if (empty($value)) {
             unset($url_params[$index]);
         }
     }
     $url_params = (cmsFramework::mosCmsSef() ? '' : '/') . implode('/', $url_params);
     # Uncomment this line and comment the one below to keep the Itemid on the result page
     if ($this->Config->search_itemid && $menu_id) {
         $url = $Routes->search_results($menu_id_param, '');
     } else {
         $url = $Routes->search_results(null, '');
     }
     // Params outside route function because it messes up the urlencoding
     $url = cmsFramework::route($url . $criteria_param . $url_params);
     $url = str_replace(array_keys($this->KeywordReplacementUrl), array_values($this->KeywordReplacementUrl), $url);
     cmsFramework::redirect($url);
 }
コード例 #4
0
 function listings()
 {
     if (Sanitize::getString($this->params, 'action') == 'xml') {
         $access = $this->cmsVersion == CMS_JOOMLA15 ? $this->Access->getAccessId() : $this->Access->getAccessLevels();
         $feed_filename = PATH_ROOT . 'cache' . DS . 'jreviewsfeed_' . md5($access . $this->here) . '.xml';
         $this->Feeds->useCached($feed_filename, 'listings');
     }
     $this->name = 'categories';
     // Required for assets helper
     if ($this->_user->id === 0 && ($this->action != 'search' || $this->action == 'search' && Sanitize::getVar($this->params, 'tag') != '')) {
         $this->cacheAction = Configure::read('Cache.expires');
     }
     $this->autoRender = false;
     $action = Sanitize::paranoid($this->action);
     $dir_id = str_replace(array('_', ' '), array(',', ''), Sanitize::getString($this->params, 'dir'));
     $section_id = Sanitize::getString($this->params, 'section');
     $cat_id = Sanitize::getString($this->params, 'cat');
     $criteria_id = Sanitize::getString($this->params, 'criteria');
     $user_id = Sanitize::getInt($this->params, 'user', $this->_user->id);
     $index = Sanitize::getString($this->params, 'index');
     $sort = Sanitize::getString($this->params, 'order');
     if ($sort == '' && in_array($this->action, array('category', 'section', 'alphaindex', 'search', 'custom'))) {
         $sort = Sanitize::getString($this->Config, 'list_order_field');
     }
     $sort == '' and $sort = Sanitize::getString($this->Config, 'list_order_default');
     $menu_id = Sanitize::getInt($this->params, 'menu', Sanitize::getString($this->params, 'Itemid'));
     // Avoid running the listing query if in section page and listings disabled
     $query_listings = $this->action != 'section' || $this->action == 'section' && $this->Config->list_show_sectionlist;
     $total_special = Sanitize::getInt($this->data, 'total_special');
     if (!in_array($this->action, array('section', 'category')) && $total_special > 0) {
         $total_special <= $this->limit and $this->limit = $total_special;
     }
     $listings = array();
     $parent_categories = array();
     $count = 0;
     $conditions = array();
     $joins = array();
     if ($action == 'category') {
         // Find directory and section id
         if ($this->cmsVersion == CMS_JOOMLA15 && ($category = $this->Category->findRow(array('conditions' => array('Category.id = ' . $cat_id))))) {
             $dir_id = $this->params['dir'] = $category['Category']['dir_id'];
             $section_id = $this->params['section'] = $category['Category']['section_id'];
         } elseif ($parent_categories = $this->Category->findParents($cat_id)) {
             $category = end($parent_categories);
             // This is the current category
             if (!$category['Category']['published'] || !$this->Access->isAuthorized($category['Category']['access'])) {
                 echo $this->render('elements', 'login');
                 return;
             }
             $dir_id = $this->params['dir'] = $category['Directory']['dir_id'];
             $categories = $this->Category->findTree(array('cat_id' => $cat_id));
         }
         # Override global configuration
         isset($category['ListingType']) and $this->Config->override($category['ListingType']['config']);
         $sort = Sanitize::getString($this->params, 'order', Sanitize::getString($this->Config, 'list_order_field'));
         $sort == '' and $sort = Sanitize::getString($this->Config, 'list_order_default');
     }
     # Remove unnecessary fields from model query
     $this->Listing->modelUnbind('Listing.fulltext AS `Listing.description`');
     # Get section and category database information
     if ($this->cmsVersion == CMS_JOOMLA15 && in_array($action, array('section', 'category'))) {
         $fields = array();
         # Get all categories for page
         if ($this->Config->dir_cat_num_entries || $this->Config->dir_category_hide_empty) {
             $fields = array(' 
                         (SELECT 
                           count(*) 
                           FROM #__content AS Listing
                           INNER 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 <= ' . $this->Access->getAccessId() . '
                                 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`                    
                     ');
         }
         $categories = $this->Category->findAll(array('fields' => $fields, 'conditions' => array('Category.section = ' . (int) $section_id, 'Category.published = 1'), 'order' => $this->Config->dir_category_order ? 'Category.title ASC' : 'Category.ordering ASC'));
         $category_tmp = current($categories);
         $dir_id = $category_tmp['Category']['dir_id'];
         $section = $this->Section->findRow(array('fields' => array((int) $dir_id . ' AS `Section.dir_id`'), 'conditions' => array('Section.id = ' . (int) $section_id)));
         # Fake the parent_categories array based on section and category
         isset($section) and $parent_categories[]['Category'] = $section['Section'];
         isset($category) and $parent_categories[]['Category'] = $category['Category'];
     }
     # Set the theme layout and suffix
     $this->Theming->setSuffix(array('categories' => $parent_categories));
     $this->Theming->setLayout(array('categories' => $parent_categories));
     if (isset($section) && !empty($section) && (!$this->Access->isAuthorized($section['Section']['access']) || !$section['Section']['published']) || $this->action == 'category' && isset($category) && !empty($category) && (!$this->Access->isAuthorized($category['Category']['access']) || !$category['Category']['published'])) {
         echo $this->render('elements', 'login');
         return;
     }
     # Get listings
     # Modify and perform database query based on lisPage type
     if ($action == 'section' && $this->Config->list_show_sectionlist || $action != 'section') {
         // Build where statement
         switch ($action) {
             case 'alphaindex':
                 //                    $index = isset($index{0}) ? $index{0} : '';
                 $conditions[] = $index == '0' ? 'Listing.title REGEXP "^[0-9]"' : 'Listing.title LIKE ' . $this->quote($index . '%');
                 break;
         }
         $section_id = cleanIntegerCommaList($section_id);
         $cat_id = cleanIntegerCommaList($cat_id);
         $dir_id = cleanIntegerCommaList($dir_id);
         $criteria_id = cleanIntegerCommaList($criteria_id);
         if (!empty($cat_id)) {
             if ($this->cmsVersion == CMS_JOOMLA15 || $this->cmsVersion != CMS_JOOMLA15 && !$this->Config->list_show_child_listings) {
                 if ($this->cmsVersion != CMS_JOOMLA15) {
                     $conditions[] = 'ParentCategory.id IN (' . $cat_id . ')';
                 }
                 $conditions[] = 'Category.id IN (' . $cat_id . ')';
                 // Exclude listings from child categories
             } else {
                 $conditions[] = 'ParentCategory.id IN (' . $cat_id . ')';
             }
         } else {
             unset($this->Listing->joins['ParentCategory']);
         }
         empty($cat_id) and !empty($section_id) and $conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
         empty($cat_id) and !empty($dir_id) and $conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
         empty($cat_id) and !empty($criteria_id) and $conditions[] = 'JreviewsCategory.criteriaid IN (' . $criteria_id . ')';
         if ($this->action == 'mylistings' && $user_id == $this->_user->id || $this->Access->isPublisher()) {
             $conditions[] = 'Listing.state >= 0';
         } else {
             $conditions[] = 'Listing.state = 1';
             $conditions[] = '( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )';
             $conditions[] = '( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )';
         }
         # Shows only links users can access
         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() . ')';
         }
         $queryData = array('joins' => $joins, 'conditions' => $conditions, 'limit' => $this->limit, 'offset' => $this->offset);
         # Modify query for correct ordering. Change FIELDS, ORDER BY and HAVING BY directly in Listing Model variables
         if ($this->action != 'custom' || $this->action == 'custom' && empty($this->Listing->order)) {
             $this->Listing->processSorting($action, $sort);
         }
         // This is used in Listings model to know whether this is a list page to remove the plugin tags
         $this->Listing->controller = 'categories';
         // Check if review scope checked in advancd search
         $scope = explode('_', Sanitize::getString($this->params, 'scope'));
         if ($this->action == 'search' && in_array('reviews', $scope)) {
             $queryData['joins'][] = "LEFT JOIN #__jreviews_comments AS Review ON Listing.id = Review.pid AND Review.published = 1 AND Review.mode = 'com_content'";
             $queryData['group'][] = "Listing.id";
             // Group By required due to one to many relationship between listings => reviews table
         }
         $query_listings and $listings = $this->Listing->findAll($queryData);
         # If only one result then redirect to it
         if ($this->Config->search_one_result && count($listings) == 1 && $this->action == 'search' && $this->page == 1) {
             $listing = array_shift($listings);
             $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
             cmsFramework::redirect($url);
         }
         # Get the listing count
         if (in_array($action, array('section', 'category'))) {
             unset($queryData['joins']);
             $this->Listing->joins = array("INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_content'", 'Category' => "LEFT JOIN #__categories AS Category ON JreviewsCategory.id = 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", "LEFT JOIN #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id");
         } elseif ($action != 'favorites') {
             unset($queryData['joins']);
             $this->Listing->joins = array("INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_content'", 'Category' => "LEFT JOIN #__categories AS Category ON JreviewsCategory.id = 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", "LEFT JOIN #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id");
             if ($this->action == 'search' && in_array('reviews', $scope)) {
                 $queryData['joins'][] = "LEFT JOIN #__jreviews_comments AS Review ON Listing.id = Review.pid AND Review.published = 1 AND Review.mode = 'com_content'";
             }
         }
         if ($this->cmsVersion == CMS_JOOMLA15 || empty($cat_id)) {
             unset($this->Listing->joins['ParentCategory']);
             // Exclude listings from child categories
         }
         // Need to add user table join for author searches
         if (isset($this->params['author'])) {
             $queryData['joins'][] = "LEFT JOIN #__users AS User ON User.id = Listing.created_by";
         }
         if ($query_listings && !isset($this->Listing->count)) {
             $count = $this->Listing->findCount($queryData, $this->action == 'search' && in_array('reviews', $scope) ? 'DISTINCT Listing.id' : '*');
         } else {
             $count = $this->Listing->count;
         }
         if ($total_special > 0 && $total_special < $count) {
             $count = Sanitize::getInt($this->data, 'total_special');
         }
     }
     # Get directory info for breadcrumb if dir id is a url parameter
     $directory = array();
     if (is_numeric($dir_id)) {
         $directory = $this->Directory->findRow(array('fields' => array('Directory.id AS `Directory.dir_id`', 'Directory.title AS `Directory.slug`', 'Directory.desc AS `Directory.title`'), 'conditions' => array('Directory.id = ' . $dir_id)));
     }
     /******************************************************************
      * Process page title and description
      *******************************************************************/
     $name_choice = $this->Config->name_choice == 'alias' ? 'username' : 'name';
     $page['show_title'] = 1;
     $page['show_description'] = 1;
     switch ($action) {
         case 'section':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page = $section['Section'];
             $page['title'] = trim(Sanitize::getString($menuParams, 'title')) != '' ? Sanitize::getString($menuParams, 'title') : $section['Section']['title'];
             $page['show_title'] = Sanitize::getInt($this->data, 'dirtitle', 1);
             $page['show_description'] = 1;
             break;
         case 'category':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page = $category['Category'];
             $page['title'] = trim(Sanitize::getString($menuParams, 'title')) != '' ? Sanitize::getString($menuParams, 'title') : $category['Category']['title'];
             $page['show_title'] = Sanitize::getInt($this->data, 'dirtitle', 1);
             $page['show_description'] = 1;
             Sanitize::getString($category['Category'], 'metadesc') == '' and $page['metadesc'] = Sanitize::htmlClean($category['Category']['description']);
             # Check if this is a listing submit category or disable listing submissions
             if (Sanitize::getInt($category['Category'], 'criteria_id') == 0) {
                 $this->Config->list_show_addnew = 0;
             }
             break;
         case 'custom':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page['top_description'] = Sanitize::getString($menuParams, 'custom_description');
             $page['top_description'] = str_replace('\\n', '', $page['top_description']);
             $page['show_description'] = $page['top_description'] != '';
             $page['show_title'] = Sanitize::getInt($menuParams, 'dirtitle');
             $page['title'] = Sanitize::getString($menuParams, 'title');
             if (!$page['title']) {
                 $page['title'] = $this->Menu->getMenuName($menu_id);
             }
             break;
         case 'alphaindex':
             $title = isset($directory['Directory']) ? Sanitize::getString($directory['Directory'], 'title', '') : '';
             $page['title'] = $title != '' ? $title . ' - ' . ($index == '0' ? '0-9' : $index) : ($index == '0' ? '0-9' : $index);
             break;
         case 'mylistings':
             if ($user_id > 0) {
                 $user_name = $this->User->findOne(array('fields' => array('User.' . $name_choice . ' AS `User.name`'), 'conditions' => array('User.id = ' . $user_id)));
             } elseif ($this->_user->id > 0) {
                 $user_name = $this->_user->{$name_choice};
             }
             $page['title'] = sprintf(__t("Listings by %s", true), $user_name);
             break;
         case 'favorites':
             // Not running from CB Plugin so we change the page title
             if (!isset($this->Config->in_cb)) {
                 if ($user_id > 0) {
                     $user_name = $this->User->findOne(array('fields' => array('User.' . $name_choice . ' AS `User.name`'), 'conditions' => array('User.id = ' . $user_id)));
                 } elseif ($this->_user->id > 0) {
                     $user_name = $this->_user->{$name_choice};
                 }
                 $page['title'] = sprintf(__t("Favorites by %s", true), $user_name);
             }
             break;
         case 'list':
         case 'search':
             $this->__seo_fields($page);
             break;
         case 'featured':
         case 'latest':
         case 'mostreviews':
         case 'popular':
         case 'toprated':
         case 'topratededitor':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page['show_title'] = Sanitize::getInt($menuParams, 'dirtitle');
             $page['title'] = Sanitize::getString($menuParams, 'title');
             if (!$page['title'] && isset($this->Menu->menues[$menu_id])) {
                 $page['title'] = $this->Menu->menues[$menu_id]->name;
             }
             break;
         default:
             $page['title'] = $this->Menu->getMenuName($menu_id);
             break;
     }
     // If empty unset the keys so they don't overwrite the ones set via menu
     if (trim(strip_tags(Sanitize::getString($page, 'description'))) == '') {
         unset($page['description']);
     }
     if (trim(strip_tags(Sanitize::getString($page, 'keywords'))) == '') {
         unset($page['keywords']);
     }
     /******************************************************************
      * Generate SEO titles for re-ordered pages (most reviews, top user rated, etc.)
      *******************************************************************/
     # Category ids to be used for ordering list
     $cat_ids = array();
     if (in_array($action, array('search', 'category'))) {
         $cat_ids = $cat_id;
     } elseif (!empty($categories)) {
         $cat_ids = implode(',', array_keys($categories));
     }
     $field_order_array = $this->Field->getOrderList($cat_ids, 'listing', $this->action, array('section', 'category', 'search', 'alphaindex'));
     isset($page['title']) and $page['title_seo'] = $page['title'];
     if (($this->action != 'search' || Sanitize::getVar($this->params, 'tag')) && isset($this->params['order']) && $sort != '') {
         App::import('helper', 'jreviews', 'jreviews');
         $ordering_options = JreviewsHelper::orderingOptions();
         $tmp_order = str_replace('rjr', 'jr', $sort);
         if (isset($ordering_options[$sort])) {
             $page['title_seo'] .= ' ' . sprintf(__t("ordered by %s", true), mb_strtolower($ordering_options[$sort], 'UTF-8'));
         } elseif (isset($field_order_array[$tmp_order])) {
             if ($sort[0] == 'r') {
                 $page['title_seo'] .= ' ' . sprintf(__t("ordered by %s desc", true), mb_strtolower($field_order_array[$tmp_order]['text'], 'UTF-8'));
             } else {
                 $page['title_seo'] .= ' ' . sprintf(__t("ordered by %s", true), mb_strtolower($field_order_array[$sort]['text'], 'UTF-8'));
             }
         }
     }
     $this->params['order'] = $sort;
     // This is the param read in the views so we need to update it
     /******************************************************************
      * Set view (theme) vars 
      *******************************************************************/
     $this->set(array('Config' => $this->Config, 'Access' => $this->Access, 'User' => $this->_user, 'subclass' => 'listing', 'page' => $page, 'directory' => $directory, 'section' => isset($section) ? $section : array(), 'category' => isset($category) ? $category : array(), 'categories' => isset($categories) ? $categories : array(), 'parent_categories' => $parent_categories, 'listings' => $listings, 'pagination' => array('total' => $count)));
     $query_listings and $this->set('order_list', $field_order_array);
     /******************************************************************
      * RSS Feed: caches and displays feed when xml action param is present
      *******************************************************************/
     if (Sanitize::getString($this->params, 'action') == 'xml') {
         $this->Feeds->saveFeed($feed_filename, 'listings');
     }
     echo $this->render('listings', 'listings_' . $this->tmpl_list);
 }
コード例 #5
0
 /**
  * Dynamic Listing Model Loading for jReviewsEverywhere extensions
  * Detects which extension is being used to load the correct Listing model
  *
  * @param object $controller
  * @param string $extension
  */
 function loadListingModel(&$controller, $extension = null)
 {
     if (in_array($controller->name, array('admin/reviews', 'reviews')) && $controller->action == '_save') {
         $extension = Sanitize::getString($controller->data['Review'], 'mode');
         !$extension and isset($controller->data['Listing']) and $extension = Sanitize::getString($controller->data['Listing'], 'extension');
     } else {
         $extension = $extension ? $extension : Sanitize::getString($controller->params, 'extension', Sanitize::getString($controller->data, 'extension'));
     }
     if (!$extension && isset($controller->params['module'])) {
         // Final check for module parameter
         $extension = Sanitize::getString($controller->params['module'], 'extension');
     }
     $extension == '' and $controller->name != 'facebook' and $controller->name != 'reviews' and $controller->name != 'community_reviews' and $controller->name != 'module_reviews' and $controller->name != 'discussions' and $controller->name != 'admin/reviews' and $controller->name != 'admin/admin_owner_replies' and $controller->name != 'admin/admin_reports' and $controller->name != 'admin/admin_discussions' and $extension = 'com_content';
     // Check if in listing detail page and it's a 3rd party component to dynamically load it's Listing model
     if ($extension) {
         $name = $this->name . '_' . $extension;
         App::import('Model', $name, 'jreviews');
         $class_name = inflector::camelize($this->name . '_' . $extension) . 'Model';
         if ($extension != '' && class_exists($class_name)) {
             $controller->Listing = new $class_name($controller->params);
             if (isset($controller->Review) && $controller->action != '_save') {
                 unset($controller->Review->joins['listings'], $controller->Review->joins['jreviews_categories'], $controller->Review->joins['criteria']);
                 $controller->Review->joins = array_merge($controller->Review->joins, $controller->Listing->joinsReviews);
             }
         } else {
             // Extension used in url doesn't have a plugin so we redirect to 404 error page
             $controller->autoLayout = false;
             $controller->autoRender = true;
             cmsFramework::redirect(cmsFramework::route('index.php?option=com_jreviews&url=404'));
         }
     }
 }
コード例 #6
0
ファイル: install_controller.php プロジェクト: bizanto/Hooked
 function _installfix()
 {
     // Load fields model
     App::import('Model', 'field', 'jreviews');
     $FieldModel = new FieldModel();
     $task = Sanitize::getString($this->data, 'task');
     $msg = '';
     $mambot_error = 0;
     switch ($task) {
         case 'fix_install_jreviews':
             $query = "SELECT id,published FROM #__" . _PLUGIN_DIR_NAME . " WHERE element = 'jreviews' AND folder = 'content'";
             $this->_db->setQuery($query);
             $jReviewsMambot = $this->_db->loadObjectList();
             if (!$jReviewsMambot || empty($jReviewsMambot)) {
                 // Install in DB
                 $this->_db->setQuery("INSERT INTO #__" . _PLUGIN_DIR_NAME . " (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES ('jReviews Comment Plugin', 'jreviews', 'content', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '');");
                 $this->_db->query();
             } else {
                 // Publish
                 $jReviewsMambot = $jReviewsMambot[0];
                 if (!$jReviewsMambot->published) {
                     $this->_db->setQuery("UPDATE #__" . _PLUGIN_DIR_NAME . " SET published = '1' WHERE id='{$jReviewsMambot->id}'");
                     $this->_db->query();
                 }
             }
             if (!file_exists(PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews.php')) {
                 $package = PATH_ROOT . 'administrator' . DS . 'components' . DS . 'com_jreviews' . DS . 'jreviews.plugin.s2';
                 $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content';
                 $target_file = $target . DS . 'jreviews.php';
                 if (getCmsVersion() == CMS_JOOMLA15) {
                     jimport('joomla.filesystem.file');
                     jimport('joomla.filesystem.folder');
                     jimport('joomla.filesystem.archive');
                     jimport('joomla.filesystem.path');
                     $adapter =& JArchive::getAdapter('zip');
                     $result = $adapter->extract($package, $target);
                 }
                 if (!file_exists($target_file)) {
                     require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
                     require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
                     $extract = new PclZip($package);
                     if (substr(PHP_OS, 0, 3) == 'WIN') {
                         if (!defined('OS_WINDOWS')) {
                             define('OS_WINDOWS', 1);
                         }
                     } else {
                         if (!defined('OS_WINDOWS')) {
                             define('OS_WINDOWS', 0);
                         }
                     }
                     $result = $extract->extract(PCLZIP_OPT_PATH, $target);
                 }
                 if (!$result) {
                     $mambot_error = true;
                 } else {
                     $mambot_error = false;
                 }
             }
             if ($mambot_error) {
                 $msg = "It was not possible to copy the mambot/plugin files. Make sure the /" . _PLUGIN_DIR_NAME . "/content folder is writable and try again.";
             }
             break;
         case 'fix_content_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_content'));
             $columns = array_keys($rows['#__jreviews_content']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'content'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'content');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the content fields";
             }
             break;
         case 'fix_review_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_review_fields'));
             $columns = array_keys($rows['#__jreviews_review_fields']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'review'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'review');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the review fields";
             }
             break;
         default:
             break;
     }
     cmsFramework::redirect("index.php?option=com_jreviews", $msg);
 }