function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images /* Very hard to implement when the content types each have their own separate table with different columns for images */ $imagePath = ''; $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true); } return $results; }
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)); } }
function addFavorite($results) { $listing_ids = array_keys($results); if (!isset($this->Config)) { App::import('Component', 'config', 'jreviews'); $this->Config = ClassRegistry::getClass('ConfigComponent'); } if ($this->Config->favorites_enable) { # Get favoured count $query = "\n SELECT \n content_id AS listing_id, count(*) AS favored FROM #__jreviews_favorites AS Favorite\n\t\t\t WHERE \n Favorite.content_id IN (" . implode(',', $listing_ids) . ")\n\t\t\t GROUP BY \n listing_id\n "; $this->_db->setQuery($query); $favored = $this->_db->loadAssocList('listing_id'); # Check if in user's favorites list $User =& cmsFramework::getUser(); if ($User->id) { $query = "\n SELECT \n Favorite.user_id, Favorite.content_id AS listing_id\n\t\t\t\t FROM \n #__jreviews_favorites AS Favorite\n\t\t\t\t WHERE \n Favorite.content_id IN (" . implode(',', $listing_ids) . ")\n\t\t\t\t AND Favorite.user_id = " . $User->id; $this->_db->setQuery($query); $my_favorite = $this->_db->loadAssocList('listing_id'); } foreach ($results as $key => $result) { if (isset($favored[$result['Listing']['listing_id']]['favored'])) { $results[$key]['Favorite']['favored'] = $favored[$result['Listing']['listing_id']]['favored']; } else { $results[$key]['Favorite']['favored'] = 0; } if (isset($my_favorite[$result['Listing']['listing_id']]['user_id'])) { $results[$key]['Favorite']['my_favorite'] = 1; } else { $results[$key]['Favorite']['my_favorite'] = 0; } } } return $results; }
function afterSave($status) { if ($status) { // Update vote count in review table App::import('Model', 'review', 'jreviews'); $Review = ClassRegistry::getClass('ReviewModel'); $Review->updateVoteHelpfulCount($this->data['Vote']['review_id'], $this->data['Vote']['vote_yes']); } }
function __construct() { parent::__construct(); Configure::write('Community.profileUrl', $this->profileUrl); if (file_exists(PATH_ROOT . 'components' . _DS . 'com_kunena' . _DS . 'kunena.php')) { $this->community = true; $Menu = ClassRegistry::getClass('MenuModel'); $this->menu_id = $Menu->getComponentMenuId('com_kunena'); } }
function afterDelete($key, $values, $condition) { switch ($this->post['Discussion']['type']) { case 'review': App::import('Model', 'review', 'jreviews'); $Review = ClassRegistry::getClass('ReviewModel'); $Review->updatePostCount($this->post['Discussion']['review_id'], -1); break; } }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $images = $result['Listing']['images']; unset($results[$key]['Listing']['images']); $results[$key]['Listing']['images'] = array(); $upload_dir = ''; // You can hard set an upload directory here and comment out the code below. e.g. ('/uploads') //dynamically pull the directory information if (!defined('RES_GENERAL_UPLOAD')) { // initialyze resource Controller, this will set the RES_GENERAL_UPLOAD constant require_once '..' . DS . 'administrator' . DS . 'components' . DS . 'com_resource' . DS . 'controllers' . DS . 'config.php'; ResControllerConfig::initialyze(); } $upload_dir = RES_GENERAL_UPLOAD; if ($images != '') { if (@file_exists($upload_dir . DS . 'picture' . DS . $result['Listing']['user'] . DS . 'thumbnail_blog' . DS . $images)) { $imagePath = $upload_dir . DS . 'picture' . DS . $result['Listing']['user'] . DS . 'thumbnail_blog' . DS . $images; } else { if (@file_exists($upload_dir . DS . 'picture' . DS . $result['Listing']['user'] . DS . $images)) { $imagePath = $upload_dir . DS . 'picture' . DS . $result['Listing']['user'] . DS . $images; } } } else { // Put a noimage path here? $imagePath = $upload_dir . DS . 'na.jpg'; // remember to put an na.jpg in your standard upload folder! } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true); } return $results; }
function __construct() { parent::__construct(); Configure::write('Community.profileUrl', $this->profileUrl); if (file_exists(PATH_ROOT . 'components' . _DS . 'com_comprofiler' . _DS . 'comprofiler.php')) { $this->community = true; $Menu = ClassRegistry::getClass('MenuModel'); $this->menu_id = $Menu->getComponentMenuId('com_comprofiler', true); // 2nd parameter forces a LIKE '%com_comprofiler' query to find only the profile menu Configure::write('Community.register_url', sprintf($this->registerUrl, $this->menu_id)); } }
function __construct($app = 'jreviews') { parent::__construct(); if (!empty($this->helpers)) { $this->app = $app; App::import('Helper', $this->helpers, $this->app); foreach ($this->helpers as $helper) { $method_name = inflector::camelize($helper); $class_name = $method_name . 'Helper'; if (!isset($this->loaded[$method_name])) { $this->{$method_name} = ClassRegistry::getClass($class_name); $this->loaded[$method_name] =& ${$method_name}; } } } }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $imagePath = ''; $images = $this->getImage($result['Listing']['listing_id']); $results[$key]['Listing']['images'] = array(); if ($images != '') { if (@file_exists("media/com_hotproperty/images/thb/" . $images)) { $imagePath = "media/com_hotproperty/images/thb/" . $images; } elseif (@file_exists("components/com_hotproperty/img/thb/" . $images)) { // v0.9 $imagePath = "components/com_hotproperty/img/thb/" . $images; } } else { if (@file_exists('media/com_hotproperty/images/noimage_thb.png')) { // Put a noimage path here? $imagePath = "media/com_hotproperty/images/noimage_thb.png"; } elseif (@file_exists("components/com_hotproperty/img/thb/noimage.npg")) { // v0.9 $imagePath = "components/com_hotproperty/img/thb/noimage.npg"; } } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true); } return $results; }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); $imagePath = ''; # Find the thumbnail path $query = "\n SELECT \n jg_paththumbs \n FROM \n #__joomgallery_config\n LIMIT 1\n "; $this->_db->setQuery($query); $thumbnail_path = $this->_db->loadResult(); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; $result['Listing']['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($result); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $images = $result['Listing']['images']; unset($results[$key]['Listing']['images']); $results[$key]['Listing']['images'] = array(); if ($images != '') { if (file_exists($thumbnail_path . $result['Listing']['images_path'] . '/' . $images)) { $imagePath = $thumbnail_path . $result['Listing']['images_path'] . '/' . $images; } } else { // Put a noimage path here? $imagePath = ''; //"components/com_virtuemart/shop_image/product/" . $images; } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true); } return $results; }
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 afterFind($results) { if (empty($results) || defined('MVC_FRAMEWORK_ADMIN')) { # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); } return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; $result['Listing']['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($result); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $images = $result['Listing']['images']; unset($results[$key]['Listing']['images']); if ($images != '') { $imagePath = $images; } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true, 'skipthumb' => true); } return $results; }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $images = $result['Listing']['images']; unset($results[$key]['Listing']['images']); $results[$key]['Listing']['images'] = array(); if ($images != '') { if (@file_exists("components/com_virtuemart/shop_image/product/" . $images)) { $imagePath = "components/com_virtuemart/shop_image/product/" . $images; } else { $imagePath = "components/com_virtuemart/shop_image/product/" . $images; } } else { // Put a noimage path here? $imagePath = ''; //"components/com_virtuemart/shop_image/product/" . $images; } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true); } return $results; }
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'; } Configure::write('Community.register_url', sprintf($this->registerUrl, $this->menu_id)); } }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); # Reformat image and criteria info foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images // Gets the src of the first image in the html code for the blog post $images = preg_match('/<img.*?src=([\'"])([^"\\1]+)\\1/i', $result['Listing']['summary'], $matches); $results[$key]['images'] = array(); $results[$key]['Listing']['images'] = array(); if ($images != '') { if (@file_exists($matches[2])) { $imagePath = $matches[2]; } } else { // Put a noimage path here? $imagePath = ''; //"components/com_virtuemart/shop_image/product/" . $images; } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true); } return $results; }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; $result['Listing']['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($result); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $imagePath = ''; $images = $result['Listing']['images']; $results[$key]['Listing']['images'] = array(); if ($images != '') { $imagePath = $images; } else { // Put a noimage path here? $imagePath = WWW_ROOT . 'components/com_resman/images/no_image_small.png'; //$images; } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'skipthumb' => true, 'basepath' => true); } return $results; }
/** * Sets the correct view suffix * * @param mixed $categories */ public function setSuffix($options = array()) { switch ($this->c->action) { case 'search': $this->c->viewSuffix = Sanitize::getString($this->c->params, 'tmpl_suffix', $this->c->Config->search_tmpl_suffix); break; } # Find cat id if ($listing_id = Sanitize::getInt($options, 'listing_id')) { $query = "SELECT catid FROM #__content WHERE id = " . $listing_id; $this->c->_db->setQuery($query); $options['cat_id'] = $this->c->_db->loadResult(); } # Get cat and parent cat info if ($cat_id = Sanitize::getInt($options, 'cat_id')) { App::import('Model', 'category', 'jreviews'); $CategoryModel = ClassRegistry::getClass('CategoryModel'); $options['categories'] = $this->c->cmsVersion == CMS_JOOMLA15 ? $CategoryModel->findSectionCat($cat_id) : $CategoryModel->findParents($cat_id); } if (Sanitize::getVar($options, 'categories')) { # Iterate from parent to child and overwrite the suffix if not null foreach ($options['categories'] as $category) { $category['Category']['tmpl_suffix'] != '' and $this->c->viewSuffix = $category['Category']['tmpl_suffix']; } } # Module params, menu params and posted data override previous values if (Sanitize::getVar($this->c->params, 'module')) { $this->c->viewSuffix = Sanitize::getString($this->c->params['module'], 'tmpl_suffix'); } if ($suffix = Sanitize::getString($this->c->data, 'tmpl_suffix', Sanitize::getString($this->c->params, 'tmpl_suffix'))) { $suffix != '' and $this->c->viewSuffix = $suffix; } if (isset($this->c->Menu)) { # Nothing yet, so we load the menu params $menu_params = $this->c->Menu->getMenuParams(Sanitize::getInt($this->c->params, 'Itemid')); Sanitize::getVar($menu_params, 'tmpl_suffix') != '' and $this->c->viewSuffix = Sanitize::getVar($menu_params, 'tmpl_suffix'); } }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId('com_eventlist'); # Reformat image and criteria info foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $images = $result['Listing']['images']; unset($results[$key]['Listing']['images']); $results[$key]['Listing']['images'] = array(); if ($images != '' && @file_exists("images/eventlist/event/" . $images)) { $imagePath = "images/eventlist/event/" . $images; } else { // Put a noimage path here? $imagePath = ''; } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true); } return $results; }
function afterFind($results) { $Menu = ClassRegistry::getClass('MenuModel'); $results = $Menu->addMenuSection($results); return $results; }
function afterFilter() { if (!class_exists('AssetsHelper')) { App::import('Helper', 'assets', 'jreviews'); } $Assets = ClassRegistry::getClass('AssetsHelper'); // Need to override name and action because using $this->requestAction in theme files replaces the original values (i.e. related listings prevents detail page js/css from loading) $Assets->name = $this->name; $Assets->action = $this->action; $Assets->params = $this->params; $Assets->viewVars =& $this->viewVars; if (!isset($Assets->Access)) { if (!isset($this->Access)) { App::import('Component', 'access', 'jreviews'); $Access = new AccessComponent(); if (!isset($this->Config)) { $this->Config = Configure::read('JreviewsSystem.Config'); } $Access->init($this->Config); $Assets->Access =& $Access; } else { $Assets->Access =& $this->Access; } } if (!isset($Assets->Config)) { if (!isset($this->Config)) { $Assets->Config = Configure::read('JreviewsSystem.Config'); } else { $Assets->Config =& $this->Config; } } // Can't use this in ajax requests because it's output outside the json response and breaks it if (!$this->ajaxRequest) { if (!empty($this->assets)) { $Assets->assets = $this->assets; } $Assets->load(); } }
function rssListing($listing, $title = '', $attributes = array()) { $menu_id = ''; $section_id = ''; if (isset($listing['Listing']['slug'])) { $listing_slug = S2Router::sefUrlEncode($listing['Listing']['slug'], __t("and", true)); } else { $listing_slug = S2Router::sefUrlEncode($listing['Listing']['title'], __t("and", true)); } $listing_title = $listing['Listing']['title']; $listing_id = $listing['Listing']['listing_id']; $extension = $listing['Listing']['extension']; if ($extension == 'com_content') { if ($this->cmsVersion == CMS_JOOMLA15) { $section_id = $listing['Section']['section_id']; } $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getCategory(array('cat_id' => $listing['Category']['cat_id'], 'dir_id' => $listing['Directory']['dir_id'], 'section_id' => $section_id)); } $title = $title != '' ? $title : sprintf(__t("%s review feeds", true), $listing_title); $attributes = array_merge(array('class' => 'jr_feedReviews', 'title' => $title), $attributes); $url = sprintf($this->routes['rss_reviews_listing'], $listing_slug, $listing_id, $extension, $menu_id); return $this->Html->sefLink('', $url, $attributes); }
function myreviews($params) { if ($this->_user->id === 0) { $this->cacheAction = Configure::read('Cache.expires'); } $page = array(); // Set layout $this->layout = 'reviews'; $this->autoRender = false; // Triggers the afterFind in the Observer Model $this->EverywhereAfterFind = true; $user_id = Sanitize::getInt($this->params, 'user', $this->_user->id); if (!$user_id) { echo $this->render('elements', 'login'); return; } if (!$user_id) { $user_id = $this->_user->id; } $queryData = array('conditions' => array('Review.userid= ' . $user_id, 'Review.published = 1'), 'fields' => array('Review.mode AS `Review.extension`'), 'offset' => $this->offset, 'limit' => $this->limit, 'order' => array('Review.created DESC')); # Don't run it here because it's run in the Everywhere Observer Component $this->Review->runProcessRatings = false; $reviews = $this->Review->findAll($queryData); if (empty($reviews)) { return __t("No reviews were found.", true); } $count = $this->Review->findCount($queryData); $review = current($reviews); App::import('Helper', 'community', 'jreviews'); $Community = ClassRegistry::getClass('CommunityHelper'); $Community->Config =& $this->Config; $page['title'] = $page['description'] = sprintf(__t("Reviews written by %s", true), $Community->screenName($review, false)); $this->set(array('Access' => $this->Access, 'User' => $this->_user, 'reviews' => $reviews, 'pagination' => array('total' => $count, 'offset' => ($this->page - 1) * $this->limit), 'page' => $page)); return $this->render('reviews', 'reviews'); }
function compareCheckbox($listing) { App::import('Helper', 'routes', 'jreviews'); $Routes = ClassRegistry::getClass('RoutesHelper'); $listing_title = htmlspecialchars($listing['Listing']['title'], ENT_QUOTES, cmsFramework::getCharset()); $listing_id = $listing['Listing']['listing_id']; $listing_url = $Routes->content($listing['Listing']['title'], $listing, array('return_url' => true)); $checkbox = '<input type="checkbox" class="checkListing" name="' . $listing_title . '" id="listing' . $listing_id . '" value="' . $listing_id . '" /> <label class="lbCompare" for="listing' . $listing_id . '">' . __t("Compare", true) . '</label>'; $listing_type = '<span id="listingID' . $listing_id . '" class="listingType' . $listing['Criteria']['criteria_id'] . '" style="display:none;">' . $listing['Criteria']['title'] . '</span>'; $url = '<span class="listingUrl' . $listing_id . '" style="display:none;">' . $listing_url . '</span>'; return '<span class="compareListing jrButton">' . $checkbox . $listing_type . $url . '</span>'; }
/** * Dynamically replace the field tags with their labels/form field equivalents */ function afterFilter() { $output =& $this->output; $names = array(); $labels = array(); $select = array(); $cat_tag = false; $date_field = false; $cat_auto = Sanitize::getInt($this->params['module'], 'cat_auto'); $dir_id = $section_id = $cat_id = $criteria_id = ''; # Initialize FormHelper $Form = new FormHelper(); $CustomFields = new CustomFieldsHelper(); $CustomFields->Config =& $this->Config; # Process custom field tag attributes foreach ($this->fieldTags as $key => $value) { $var = explode('|', $value); if (!strstr($value, '_label')) { $names[$var[0]] = $value; } elseif (strstr($value, '_label')) { $labels[] = substr($value, 0, -6); } if ($value == 'category') { $cat_tag = true; /************************/ if (isset($var[1]) && $var[1] == 'm') { $category_select_type = ' multiple="multiple"'; } if (isset($var[2]) && (int) $var[2] > 0) { $category_select_size = ' size="' . $var[2] . '"'; } /************************/ } if (isset($var[1]) && strtolower($var[1]) == 'm') { $select[$var[0]] = 'selectmultiple'; } elseif (isset($var[1]) && strtolower($var[1]) == 's') { $select[$var[0]] = 'select'; } $select_size[$var[0]] = isset($var[2]) ? $var[2] : 5; # Check for category select list if ($var[0] == 'category') { if (isset($var[1]) && strtolower($var[1]) == 's') { $category_select_type = ' multiple="multiple"'; } if (isset($var[2]) && (int) $var[2] > 0) { $category_select_size = ' size="' . $var[2] . '"'; } } } # Get selected values from url $entry = array(); foreach ($this->params as $key => $value) { if (substr($key, 0, 3) == 'jr_') { $entry['Field']['pairs'][$key]['value'] = explode('_', $value); } // Add categories/sections } if (isset($this->params['tag'])) { $entry['Field']['pairs']['jr_' . $this->params['tag']['field']]['value'] = array($this->params['tag']['value']); } # Generate category list if tag found in view if ($cat_tag) { # Get module params before auto-detect $param_cat_id = Sanitize::getString($this->params['module'], 'cat_id'); $param_dir_id = Sanitize::getString($this->params['module'], 'dir_id'); $param_type_id = Sanitize::getString($this->params['module'], 'criteria_id'); # Category auto detect $ids = CommonController::_discoverIDs($this); if ($cat_auto) { extract($ids); } elseif ($this->cmsVersion != CMS_JOOMLA15) { isset($ids['cat_id']) and $cat_id = $ids['cat_id']; } if ($this->cmsVersion == CMS_JOOMLA15 && $section_id == '' && $cat_id != '') { $sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")"; $this->_db->setQuery($sql); $section_id = $this->_db->loadResult(); } $cat_id != '' and $this->params['module']['cat_id'] = $cat_id; $cat_id == '' and $section_id != '' and $this->params['module']['section_id'] = $section_id; $cat_id == '' and $criteria_id != '' and $this->params['module']['criteria_id'] = $criteria_id; if ($this->cmsVersion == CMS_JOOMLA15) { $categorySelect = $this->Category->categoryTree($this->_user->gid, $this->params); } else { $options = array('disabled' => false, 'cat_id' => !empty($param_cat_id) && !$cat_auto ? $param_cat_id : ($cat_auto ? $cat_id : ''), 'parent_id' => !empty($param_cat_id) && !$cat_auto ? $param_cat_id : ($cat_auto ? $cat_id : ''), 'dir_id' => !empty($param_dir_id) && !$cat_auto ? $param_dir_id : ($cat_auto ? $dir_id : ''), 'type_id' => !empty($param_type_id) && !$cat_auto ? $param_type_id : ($cat_auto ? $criteria_id : '')); if ($cat_auto && empty($options['cat_id'])) { $options['level'] = 1; } $categories = $this->Category->getCategoryList($options); // Now get the parent and sibling categories if ($cat_auto && isset($categories[$cat_id]) && count($categories) == 1) { $options['cat_id'] = $options['parent_id'] = $categories[$cat_id]->parent_id; $categories = $this->Category->getCategoryList($options); } $categorySelect = $Form->select('data[categories]', array_merge(array(array('value' => null, 'text' => '- ' . __t("Select Category", true) . ' -')), $categories), $cat_id, array('class' => 'jrSelect')); } $output = str_replace('{' . $names['category'] . '}', $categorySelect, $output); } $fields = $this->Field->getFieldsArrayFromNames(array_keys($names), 'listing', $entry); # Replace label tags and change field type based on view atttributes if ($fields) { foreach ($fields as $key => $group) { foreach ($group['Fields'] as $name => $field) { if (isset($select[$name])) { $fields[$key]['Fields'][$name]['type'] = $select[$name]; $fields[$key]['Fields'][$name]['properties']['size'] = $select_size[$name]; } elseif ($fields[$key]['Fields'][$name]['type'] == 'textarea') { $fields[$key]['Fields'][$name]['type'] = 'text'; } if (in_array($name, $labels)) { $output = str_replace('{' . $name . '_label}', $field['title'], $output); } if ($field['type'] == 'date') { $date_field = true; } } } $search = true; $location = 'listing'; $CustomFields->form_id = Sanitize::getInt($this->params, 'module_id'); $formFields = $CustomFields->getFormFields($fields, $location, $search, __t("Select", true)); # Replace input tags foreach ($names as $key => $name) { if (isset($formFields["data[Field][Listing][{$key}]"])) { $output = str_replace('{' . $names[$key] . '}', $formFields["data[Field][Listing][{$key}]"], $output); } } # Load js and css if ($date_field) { $Html = ClassRegistry::getClass('HtmlHelper'); $Html->app = 'jreviews'; $Libraries = ClassRegistry::getClass('LibrariesHelper'); $Html->js(arrayFilter(array('jq.ui.core', 'jq.ui.datepicker'), $Libraries->js())); $Html->css(arrayFilter(array('jq.ui.core'), $Libraries->css()), false); ?> <script type="text/javascript">jreviews.datepicker();</script> <?php } } return $output; }
/** * Used in map popup to update the listing's coordinates */ function saveGeocodePopup($data) { App::import('Model', 'jreviews_content'); $Field = ClassRegistry::getClass('JreviewsContentModel'); $data['JreviewsContent'] =& $data['Field']['Listing']; if (!$Field->store($data)) { return false; } return true; }
function afterFind($results) { if (empty($results)) { return $results; } # Add Menu ID info for each row (Itemid) $Menu = ClassRegistry::getClass('MenuModel'); $results = $Menu->addMenuDirectory($results); return $results; }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId($this->extension); foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; $result['Listing']['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($result); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $images = $result['Listing']['images']; unset($results[$key]['Listing']['images']); $results[$key]['Listing']['images'] = array(); if ($images != '') { // From bookmarks.html.php $urlkey = '##URL_HERE##'; // *** Prepare Image url (compute link) if (!(preg_match("/^http:\\/\\//", $images) || preg_match("/^https:\\/\\//", $images) || preg_match("/^func:\\/\\//", $images))) { // Internal image (not HTTP, HTTPS or FUNC) ? $imagePath = WWW_ROOT . 'images/stories/' . $images; // Internal image from Images/Stories } else { $imagePath = $images; // External image (use url) if (preg_match("/^func:\\/\\//", $imagePath)) { // Verify if there is a FUNC to process $func = substr($imagePath, 7); $func = '$picurl=' . str_replace($urlkey, "'" . $result['Listing']['bookmark_url'] . "'", $func); eval($func); // Compute function } else { if (preg_match('/' . $urlkey . '/', $imagePath)) { // is the URL Keyword present ? $imagePath = str_replace($urlkey, $result['Listing']['bookmark_url'], $imagePath); // replace the "URL Keyword" with the URL... } } } } else { // Put a noimage path here? $imagePath = ''; } $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true, 'skipthumb' => true); } return $results; }
function index() { $response = array(); if (Sanitize::getString($this->params, 'task') == 'upgrade') { // Where running the install script for upgrade we want a json object returned $this->autoLayout = false; $this->autoRender = false; } else { $this->autoLayout = true; $this->autoRender = true; } $this->name = 'install'; # Remove views folder in J1.5 if ($this->cmsVersion == CMS_JOOMLA15) { $Folder = ClassRegistry::getClass('Folder'); $target = PATH_ROOT . 'components' . DS . 'com_jreviews' . DS . 'views'; $Folder->rm($target); } # Create database tables // Start db upgrade logic $action = array(); $action['db_install'] = true; $tables = $this->_db->getTableList(); $dbprefix = cmsFramework::getConfig('dbprefix'); $old_build = 0; // Get current version number $jreviewsxml = $this->cmsVersion == CMS_JOOMLA15 ? 'jreviews.xml' : 'jreviewg.xml'; $xml = file(S2_CMS_ADMIN . $jreviewsxml); foreach ($xml as $xml_line) { if (strstr($xml_line, 'version')) { $new_version = trim(strip_tags($xml_line)); continue; } } $version_parts = explode('.', $new_version); $new_build = array_pop($version_parts); if (is_array($tables) && in_array($dbprefix . 'jreviews_categories', array_values($tables))) { // Tables exist so we check the current build and upgrade accordingly, otherwise it's a clean install and no upgrade is necessary $query = "SELECT value FROM #__jreviews_config WHERE id = 'version'"; $this->_db->setQuery($query); $old_version = trim(strip_tags($this->_db->loadResult())); if ($old_version != '') { $version_parts = explode('.', $old_version); $old_build = array_pop($version_parts); } if (Sanitize::getBool($this->params, 'sql')) { $old_build = 0; } // prx($old_build . '<br/>' . $new_build) ; if ($new_build > $old_build) { $i = $old_build + 1; for ($i = $old_build + 1; $i <= $new_build; $i++) { // Run sql updates $sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.sql'; if (file_exists($sql_file)) { $action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix) && $action['db_install']; } // Run php updates $php_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.php'; if (file_exists($php_file)) { include $php_file; } } } } else { // It's a clean install so we use the whole jReviews sql file $sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'jreviews.sql'; $action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix); } # Update component id in pre-existing jReviews menus if ($this->cmsVersion == CMS_JOOMLA16) { $query = "\n SELECT \n extension_id AS id\n FROM \n #__extensions \n WHERE \n element = '" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "' AND type = 'component'\n "; } else { $query = "\n SELECT \n id \n FROM \n #__components \n WHERE \n admin_menu_link = 'option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n "; } $this->_db->setQuery($query); if ($id = $this->_db->loadResult()) { if ($this->cmsVersion == CMS_JOOMLA16) { $query = "\n UPDATE \n `#__menu` \n SET \n component_id = {$id} \n WHERE \n type IN ('component','components') \n AND \n link LIKE 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "%'\n "; } else { $query = "\n UPDATE \n `#__menu` \n SET \n componentid = {$id} \n WHERE \n type IN ('component','components') \n AND \n link = 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n "; } $this->_db->setQuery($query); $this->_db->query(); } # Update version number in the database $this->Config->version = $new_version; $this->Config->store(); $action['plugin_install'] = $this->_installPlugin(); # Create image upload and thumbnail folders if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS)) { $Config = new JConfig(); if (isset($Config->ftp_enable) && $Config->ftp_enable) { // set up basic connection $conn_id = ftp_connect($Config->ftp_host, $Config->ftp_port); // login with username and password $login_result = ftp_login($conn_id, $Config->ftp_user, $Config->ftp_pass); ftp_chdir($conn_id, $Config->ftp_root); ftp_mkdir($conn_id, _JR_PATH_IMAGES . 'jreviews'); ftp_mkdir($conn_id, _JR_PATH_IMAGES . 'jreviews' . DS . 'tn'); ftp_close($conn_id); @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'index.html'); @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html'); } } if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS)) { $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS, 0755); if (!$result) { $action['thumbnail_dir'] = false; } else { @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'index.html'); $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn', 0755); if (!$result) { $action['thumbnail_dir'] = false; } else { @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html'); } } } if (!is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS)) { $result = mkdir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn', 0755); if (!$result) { $action['thumbnail_dir'] = false; } else { @copy(PATH_ROOT . _JR_PATH_IMAGES . 'index.html', PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS . 'index.html'); } } if (is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS) && is_dir(PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS . 'tn' . DS)) { $action['thumbnail_dir'] = true; } # Ensure that all field group names are slugs $query = "\n SELECT \n groupid, name\n FROM\n #__jreviews_groups\n "; $this->_db->setQuery($query); $groups = $this->_db->loadAssocList(); if (!empty($groups)) { foreach ($groups as $group) { if (strpos($group['name'], ' ') !== false) { $name = cmsFramework::StringTransliterate($group['name']) . $group['groupid']; $query = "\n UPDATE\n #__jreviews_groups\n SET \n name = " . $this->quote($name) . "\n WHERE\n groupid = " . $group['groupid']; $this->_db->setQuery($query); $this->_db->query(); } } } # Clear data and core caches clearCache('', '__data'); clearCache('', 'core'); //var_dump($action); if (Sanitize::getString($this->params, 'task') == 'upgrade') { $response = array('error' => false, 'html' => ''); // {"db_install":true,"plugin_install":true,"thumbnail_dir":true} if (!$action['db_install']) { $response['error'] = true; $response['html'] = '<div style="color:red>There was a problem upgrading the database</div>'; } if (!$action['plugin_install']) { $response['error'] = true; $response['html'] .= '<div style="color:red>There was a problem upgrading the JReviews plugin</div>'; } return json_encode($response); } $this->set(array('action' => $action)); }
function afterFind($results) { if (empty($results)) { return $results; } # Find Itemid for component $Menu = ClassRegistry::getClass('MenuModel'); $menu_id = $Menu->getComponentMenuId('com_community&view=frontpage'); if (!$menu_id) { $menu_id = $Menu->getComponentMenuId('com_community&view=profile'); } if (!$menu_id) { $menu_id = $Menu->getComponentMenuId('com_community'); } foreach ($results as $key => $result) { // Process component menu id $results[$key][$this->name]['menu_id'] = $menu_id; // Process listing url $results[$key][$this->name]['url'] = $this->listingUrl($results[$key]); // Process criteria if (isset($result['Criteria']['criteria']) && $result['Criteria']['criteria'] != '') { $results[$key]['Criteria']['criteria'] = explode("\n", $result['Criteria']['criteria']); } if (isset($result['Criteria']['tooltips']) && $result['Criteria']['tooltips'] != '') { $results[$key]['Criteria']['tooltips'] = explode("\n", $result['Criteria']['tooltips']); } if (isset($result['Criteria']['weights']) && $result['Criteria']['weights'] != '') { $results[$key]['Criteria']['weights'] = explode("\n", $result['Criteria']['weights']); } // Process images $images = $result['Listing']['images']; unset($results[$key]['Listing']['images']); $results[$key]['Listing']['images'] = array(); $imagePath = $images != '' ? $images : 'components/com_community/assets/user_thumb.png'; $results[$key]['Listing']['images'][] = array('path' => $imagePath, 'caption' => $results[$key]['Listing']['title'], 'basepath' => true, 'skipthumb' => $images != '' ? false : true); } return $results; }