コード例 #1
0
 function index()
 {
     $Session = RegisterClass::getInstance('MvcSession');
     $module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id'));
     if (!isset($this->params['module'])) {
         $this->params['module'] = array();
     }
     // For direct calls to the controller
     if ($this->ajaxRequest) {
         $this->params = $Session->get('module_params' . $module_id, null, S2Paths::get('jreviews', 'S2_CMSCOMP'));
     } else {
         srand((double) microtime() * 1000000);
         $this->params['rand'] = rand();
         $Session->set('module_rand' . $module_id, $this->params['rand'], S2Paths::get('jreviews', 'S2_CMSCOMP'));
         $Session->set('module_params' . $module_id, $this->params, S2Paths::get('jreviews', 'S2_CMSCOMP'));
     }
     $this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix');
     // Read the module parameters
     $img_width = Sanitize::getInt($this->params['module'], 'img_width', 50);
     $random_mode = Sanitize::getString($this->params['module'], 'random_mode', 'Random Users');
     $favorites_mode = Sanitize::getString($this->params['module'], 'favorites_mode', 'Other users interested in {title}');
     // Pagination
     $this->Community->limit = $this->module_limit;
     $this->Community->offset = $this->module_offset;
     # Get url params for current controller/action
     $url = Sanitize::getString($_REQUEST, 'url');
     $route['url']['url'] = $url;
     $route['data'] = array();
     $route = S2Router::parse($route, true, 'jreviews');
     # Check if page is listing detail
     $detail = Sanitize::getString($route['url'], 'extension', 'com_content') == 'com_content' && isset($route['data']) && Sanitize::getString($route['data'], 'controller') == 'listings' && Sanitize::getString($route['data'], 'action') == 'detail' ? true : false;
     # Initialize variables
     $listing_id = $detail ? Sanitize::getInt($route, 'id') : Sanitize::getInt($this->params, 'id');
     $option = Sanitize::getString($this->params, 'option');
     $view = Sanitize::getString($this->params, 'view');
     $task = Sanitize::getString($this->params, 'task');
     $listing_title = '';
     # Article auto-detect - only for com_content
     if ($detail || 'com_content' == $option && ('article' == $view || 'view' == $task)) {
         $query = "SELECT Listing.id, Listing.title FROM #__content AS Listing WHERE Listing.id = " . $listing_id;
         $this->_db->setQuery($query);
         $listing = current($this->_db->loadObjectList());
         $listing_title = $listing->title;
     } else {
         $listing_id = null;
     }
     $profiles = $this->Community->getListingFavorites($listing_id, $this->_user->id, $this->params);
     $total = $this->Community->count;
     unset($this->Community->count);
     $this->set(array('profiles' => $profiles, 'listing_title' => $listing_title, 'total' => $total));
     $page = $this->render('modules', 'favorite_cbusers');
     if ($this->ajaxRequest) {
         return $this->ajaxResponse($page, false);
     } else {
         return $page;
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: atikahmed/joomla-probid
 * or contact sales@reviewsforjoomla.com
**/
defined('_VALID_MOS') || defined('_JEXEC') or die('Direct Access to this location is not allowed.');
# MVC initalization script
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
require dirname(__FILE__) . DS . 'framework.php';
global $Itemid;
$url = Sanitize::getString($_REQUEST, 'url');
$menu_id = Sanitize::getInt($_REQUEST, 'Itemid', $Itemid);
$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'))) {
コード例 #3
0
ファイル: common_controller.php プロジェクト: bizanto/Hooked
 /**
  * Category auto-detect
  */
 function _discoverIDs(&$controller)
 {
     // Initialize variables
     $id = Sanitize::getInt($controller->params, 'id');
     $cat_id = Sanitize::getInt($controller->params, 'catid');
     $option = Sanitize::getString($controller->params, 'option');
     $view = Sanitize::getString($controller->params, 'view');
     $task = Sanitize::getString($controller->params, 'task');
     switch ($option) {
         case 'com_jreviews':
             # Get url params for current controller/action
             $url = Sanitize::getString($controller->passedArgs, 'url');
             $route['url']['url'] = $url;
             $route = S2Router::parse($route, true, 'jreviews');
             isset($route['data']['action']) and $route['data']['action'] == 'search' and $route = $route['url'];
             $dir_id = Sanitize::getString($route, 'dir');
             $section_id = Sanitize::getString($route, 'section');
             $cat_id = Sanitize::getString($route, 'cat');
             $criteria_id = Sanitize::getString($route, 'criteria');
             if ($cat_id != '') {
                 if ($cat_id[0] == 's') {
                     $section_id = CommonController::makeModParamsUsable(str_replace('s', '', $cat_id));
                     $cat_id = '';
                     break;
                 }
                 $cat_id = CommonController::makeModParamsUsable($cat_id);
             } elseif ($section_id != '') {
                 $section_id = CommonController::makeModParamsUsable($section_id);
             } elseif ($criteria_id != '') {
                 $criteria_id = CommonController::makeModParamsUsable($criteria_id);
             } elseif ($dir_id != '') {
                 $dir_id = CommonController::makeModParamsUsable($dir_id);
             } else {
                 //Discover the params from the menu_id
                 $menu_id = Sanitize::getString($controller->params, 'Itemid');
                 $params = $controller->Menu->getMenuParams($menu_id);
                 $dir_id = cleanIntegerCommaList(Sanitize::getString($params, 'dirid'));
                 $cat_id = cleanIntegerCommaList(Sanitize::getString($params, 'catid'));
                 $section_id = cleanIntegerCommaList(Sanitize::getString($params, 'sectionid'));
             }
             break;
         case 'com_content':
             if ('article' == $view || 'view' == $task) {
                 // If cat id was not available in url then we need to query it, otherwise it was already read above
                 if (!$cat_id) {
                     $query = "\r\n                                SELECT \r\n                                    catid \r\n                                FROM \r\n                                    #__content\r\n                                WHERE \r\n                                    id = " . $id;
                     $this->_db->setQuery($query);
                     $cat_id = $this->_db->loadResult();
                 }
             } elseif ($view == "section") {
                 $section_id = $id;
             } elseif ($view == "category") {
                 $cat_id = $id;
             }
             break;
         default:
             $cat_id = null;
             // Catid not detected because the page is neither content nor jreviews
             break;
     }
     $ids = array();
     isset($dir_id) and !empty($dir_id) and $ids['dir_id'] = $dir_id;
     isset($section_id) and !empty($section_id) and $ids['section_id'] = $section_id;
     isset($cat_id) and !empty($cat_id) and $ids['cat_id'] = $cat_id;
     isset($criteria_id) and !empty($criteria_id) and $ids['criteria_id'] = $criteria_id;
     return $ids;
 }
コード例 #4
0
ファイル: router.php プロジェクト: atikahmed/joomla-probid
 function sefUrlEncode($text, $level = 0, $and_replace = 'and')
 {
     $_this =& S2Router::getInstance();
     if (isset($_this->__translit[$text])) {
         return $_this->__translit[$text];
     }
     $text = str_replace(array('-', '&'), array(' ', $and_replace), $text);
     $translitText = cmsFramework::UrlTransliterate(trim($text));
     $_this->__translit[$text] = $translitText;
     return $translitText;
 }
コード例 #5
0
 function index()
 {
     $module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id'));
     if (!isset($this->params['module'])) {
         $this->params['module'] = array();
     }
     // For direct calls to the controller
     $listing_type_id = Sanitize::getInt($this->params, 'listingtype', false);
     # Find the correct set of params to use
     if ($this->ajaxRequest && $listing_type_id) {
         $listingType = $this->Criteria->getCriteria(array('criteria_id' => $listing_type_id));
         if (isset($listingType['ListingType']['config']['userfavorites'])) {
             $userfavoritesParams = $listingType['ListingType']['config']['userfavorites'];
             $userfavoritesParams['criteria'] = implode(',', Sanitize::getVar($userfavoritesParams, 'criteria', array()));
             $this->params['module'] = array_merge($this->params['module'], $userfavoritesParams);
         }
     } elseif ($this->ajaxRequest && empty($this->params['module']) && $module_id) {
         $query = "SELECT params FROM #__modules WHERE id = " . $module_id;
         $this->_db->setQuery($query);
         $this->params['module'] = stringToArray($this->_db->loadResult());
     }
     # Get cached vesion
     /*        if($this->_user->id === 0) 
             {    
                 $page = $this->cached($this->here);
                 if($page) {
                     return $this->ajaxRequest ? $this->ajaxResponse($page,false) : $page;
                 } 
             }  */
     srand((double) microtime() * 1000000);
     $this->params['rand'] = rand();
     isset($this->params['module']) and $this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix');
     // Read the module parameters
     $img_width = Sanitize::getInt($this->params['module'], 'img_width', 50);
     $random_mode = Sanitize::getString($this->params['module'], 'random_mode', 'Random Users');
     $favorites_mode = Sanitize::getString($this->params['module'], 'favorites_mode', 'Other users interested in {title}');
     $limit = Sanitize::getInt($this->params['module'], 'module_limit', 5);
     $total = min(50, Sanitize::getInt($this->params['module'], 'module_total', 10));
     # Get url params for current controller/action
     if (!$this->ajaxRequest) {
         $url = Sanitize::getString($_REQUEST, 'url');
         $route['url']['url'] = $url;
         $route['data'] = array();
         $route = S2Router::parse($route, true, 'jreviews');
         # Check if page is listing detail
         $detail = Sanitize::getString($route['url'], 'extension', 'com_content') == 'com_content' && isset($route['data']) && Sanitize::getString($route['data'], 'controller') == 'listings' && Sanitize::getString($route['data'], 'action') == 'detail' ? true : false;
         # Initialize variables
         $listing_id = $detail ? Sanitize::getInt($route, 'id') : Sanitize::getInt($this->params, 'id');
         $option = Sanitize::getString($this->params, 'option');
         $view = Sanitize::getString($this->params, 'view');
         $task = Sanitize::getString($this->params, 'task');
         $listing_title = '';
     } else {
         $detail = true;
         $listing_id = Sanitize::getInt($this->params, 'id');
     }
     # Article auto-detect - only for com_content
     if ($detail || 'com_content' == $option && ('article' == $view || 'view' == $task)) {
         $query = "SELECT Listing.id, Listing.title FROM #__content AS Listing WHERE Listing.id = " . $listing_id;
         $this->_db->setQuery($query);
         $listing = current($this->_db->loadObjectList());
         $listing_title = $listing->title;
     } else {
         $listing_id = null;
     }
     $profiles = $this->Community->getListingFavorites($listing_id, $this->_user->id, $this->params);
     $total = count($profiles);
     $this->set(array('profiles' => $profiles, 'listing_title' => $listing_title, 'limit' => $limit, 'total' => $total));
     $this->_completeModuleParamsArray();
     $page = $this->ajaxRequest && empty($profiles) ? '' : $this->render('modules', 'favorite_users');
     # Save cached version
     /*        if($this->_user->id ===0) {    
                 $this->cacheView('modules','userfavorites',$this->here, $page);
             }      */
     return $this->ajaxRequest ? $this->ajaxResponse($page, false) : $page;
 }
コード例 #6
0
 function listings()
 {
     // Initialize variables
     $id = Sanitize::getInt($this->params, 'id');
     $option = Sanitize::getString($this->params, 'option');
     $view = Sanitize::getString($this->params, 'view');
     $task = Sanitize::getString($this->params, 'task');
     $menu_id = Sanitize::getString($this->params, 'Itemid');
     // Read params
     $cat_id = '';
     $criteria_ids = '';
     $detail_view = 1;
     $dir_id = Sanitize::getString($this->params, 'dir');
     $section_id = Sanitize::getString($this->params, 'section');
     $cat_id = Sanitize::getString($this->params, 'cat');
     $extension = 'com_content';
     $custom_where = null;
     $custom_fields = array();
     $click2search_auto = false;
     $cache = 0;
     $radius = 0;
     $mode = 0;
     $fishingmap = 0;
     $this->set('listing_id', $id);
     $extracoords = array();
     if (isset($this->params['module'])) {
         // Read module parameters
         $click2search_auto = Sanitize::getBool($this->params['module'], 'click2search_auto', false);
         $custom_where = Sanitize::getString($this->params['module'], 'custom_where');
         $filter = Sanitize::getString($this->params['module'], 'filter');
         $detail_view = Sanitize::getString($this->params['module'], 'detail_view', 1);
         $dir_id = Sanitize::getString($this->params['module'], 'dir');
         $section_id = Sanitize::getString($this->params['module'], 'section');
         $cat_id = Sanitize::getString($this->params['module'], 'category');
         $listing_id = Sanitize::getString($this->params['module'], 'listing');
         $criteria_ids = Sanitize::getString($this->params['module'], 'criteria');
         $custom_fields = Sanitize::getString($this->params['module'], 'custom_fields', '');
         $custom_fields = $custom_fields != '' ? explode(',', str_replace(' ', '', $custom_fields)) : array();
         $limit_results = Sanitize::getInt($this->params['module'], 'limit_results');
         $mode = Sanitize::getInt($this->params['module'], 'mode', 0);
         /**
          * 0 - Normal
          * 1 - GeoTargeting
          * 2 - Custom center and zoom
          */
         $radius = Sanitize::getInt($this->params['module'], 'radius');
         $cache = $mode == 1 ? 0 : Sanitize::getInt($this->params['module'], 'cache_map');
         $custom_lat = Sanitize::getFloat($this->params['module'], 'custom_lat');
         $custom_lon = Sanitize::getFloat($this->params['module'], 'custom_lon');
         if ($mode == 2 && ($custom_lat == 0 || $custom_lon == 0)) {
             echo __t("You selected the Custom Center mode, but did not specify the coordinates.");
             return;
         }
         // Added for Hooked
         $extracoords = $this->params['module']['extracoords'];
         //$extracoords = "";
         $fishingmap = Sanitize::getInt($this->params['module'], 'fishingmap', 0);
     }
     $in_detail_view = $id > 0 && ('article' == $view || 'view' == $task) && 'com_content' == $option;
     $detail_view = $this->params['module']['detail_view'] = $detail_view && $in_detail_view;
     # Custom WHERE
     if ($custom_where) {
         $conditions[] = $custom_where;
     }
     if ($click2search_auto && isset($this->params['tag'])) {
         $field = 'jr_' . Sanitize::getString($this->params['tag'], 'field');
         $value = Sanitize::getString($this->params['tag'], 'value');
         $query = "SELECT Field.type FROM #__jreviews_fields AS Field WHERE Field.name = " . $this->quote($field);
         $this->_db->setQuery($query);
         $type = $this->_db->loadResult();
         if (in_array($type, array('select', 'selectmultiple', 'checkboxes', 'radiobuttons'))) {
             $conditions[] = "Field.{$field} LIKE " . $this->quoteLike('*' . $value . '*');
         } else {
             $conditions[] = "Field.{$field} = " . $this->quote($value);
         }
     }
     # Category auto detect
     if (isset($this->params['module']) && Sanitize::getInt($this->params['module'], 'cat_auto') && $extension == 'com_content') {
         // Only works for core articles
         switch ($option) {
             case 'com_jreviews':
                 # Get url params for current controller/action
                 $url = Sanitize::getString($this->passedArgs, 'url');
                 $route['url']['url'] = $url;
                 $route = S2Router::parse($route);
                 //                    $route = $route['url'];
                 $dir_id = Sanitize::getString($route, 'dir');
                 $section_id = Sanitize::getString($route, 'section');
                 $cat_id = Sanitize::getString($route, 'cat');
                 $criteria_ids = Sanitize::getString($route, 'criteria');
                 if ($cat_id != '') {
                     $category_ids = $this->makeParamsUsable($cat_id);
                     $category_ids = explode(",", $category_ids);
                     $this->cleanArray($category_ids);
                     $cat_id = implode(",", $category_ids);
                 } elseif ($section_id != '') {
                     $cat_id = $this->sectionToCat($section_id);
                 } elseif ($criteria_ids != '') {
                     // check criteriaids {
                     $criteriaids_url = $this->makeParamsUsable($criteria_ids);
                     $cat_id = $this->criteriaToCat($criteria_ids);
                 } else {
                     //Discover the params from the menu_id
                     $params = $this->Menu->getMenuParams($menu_id);
                     $dir_id = Sanitize::getString($params, 'dirid');
                     $cat_id = Sanitize::getString($params, 'catid');
                     $section_id = Sanitize::getString($params, 'sectionid');
                 }
                 break;
             case 'com_content':
                 if ('article' == $view || 'view' == $task) {
                     $sql = "SELECT catid FROM #__content WHERE id = " . $id;
                     $this->_db->setQuery($sql);
                     $cat_id = $this->_db->loadResult();
                 } elseif ($view == "section") {
                     $cat_id = $this->sectionToCat($id);
                 } elseif ($view == "category") {
                     $cat_id = $id;
                 }
                 break;
             default:
                 //                    $cat_id = null; // Catid not detected because the page is neither content nor jreviews
                 break;
         }
     }
     $autodetect = compact('dir_id', 'section_id', 'cat_id');
     // Check for cached version if cache enabled
     if ($cache) {
         $params = array();
         foreach ($this->params as $key => $value) {
             if ((!is_array($value) || $key == 'module') && !in_array($key, array('page', 'limit', 'order', 'Itemid'))) {
                 $params[$key] = $value;
             }
         }
         $cache_key = array_merge($params, $autodetect, Sanitize::getVar($this->params, 'tag', array()));
         $json_filename = 'geomaps_' . md5(serialize($cache_key)) . '.json';
         $json_data = S2Cache::read($json_filename);
         if ($json_data && $json_data != '') {
             $this->set('json_data', $json_data);
             S2Cache::write($json_filename, $json_data);
             return $this->render('modules', 'geomaps');
         }
     }
     $this->Listing->fields = array('Listing.id AS `Listing.listing_id`', 'Listing.title AS `Listing.title`', 'Listing.images AS `Listing.images`', 'CASE WHEN CHAR_LENGTH(Listing.alias) THEN Listing.alias ELSE "" END AS `Listing.slug`', 'Category.id AS `Listing.cat_id`', 'CASE WHEN CHAR_LENGTH(Category.alias) THEN Category.alias ELSE Category.title END AS `Category.slug`', 'Listing.sectionid AS `Listing.section_id`', 'JreviewsCategory.criteriaid AS `Criteria.criteria_id`', 'JreviewsCategory.dirid AS `Directory.dir_id`', 'Field.featured AS `Listing.featured`', 'Totals.user_rating AS `Review.user_rating`', 'Totals.user_rating_count AS `Review.user_rating_count`', 'Totals.editor_rating AS `Review.editor_rating`', 'Totals.editor_rating_count AS `Review.editor_rating_count`', "Field.{$this->jr_lat} `Geomaps.lat`", "Field.{$this->jr_lon} `Geomaps.lon`", 'JreviewsCategory.marker_icon AS `Geomaps.icon`');
     if ($fishingmap) {
         $this->Listing->fields[] = 'GROUP_CONCAT(Related.id2) AS `Listing.relations`';
     }
     // Geo Targeting OR Custom Center modes
     if ($mode == 1 || $mode == 2) {
         if ($mode == 1) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, 'http://www.geoplugin.net/php.gp?ip=' . s2GetIpAddress());
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
             $geoData = unserialize(curl_exec($ch));
             curl_close($ch);
             if (!empty($geoData) && $geoData['geoplugin_latitude'] != '' && $geoData['geoplugin_longitude'] != '') {
                 $center = array('lon' => $geoData['geoplugin_longitude'], 'lat' => $geoData['geoplugin_latitude']);
             }
             $this->set('geoLocation', $geoData);
         }
         if ($mode == 2) {
             $center = array('lon' => $custom_lon, 'lat' => $custom_lat);
         }
         if (!empty($center) && $radius > 0) {
             $distanceIn = Sanitize::getString($this->Config, 'geomaps.radius_metric', 'mi');
             $degreeDistance = $distanceIn == 'mi' ? 69.172 : 40076 / 360;
             // Send center coordinates to theme
             $this->set('GeomapsCenter', $center);
             $lat_range = $radius / $degreeDistance;
             $lon_range = $radius / abs(cos($center['lat'] * pi() / 180) * $degreeDistance);
             $min_lat = $center['lat'] - $lat_range;
             $max_lat = $center['lat'] + $lat_range;
             $min_lon = $center['lon'] - $lon_range;
             $max_lon = $center['lon'] + $lon_range;
             $squareArea = "`Field`.{$this->jr_lat} BETWEEN {$min_lat} AND {$max_lat} AND `Field`.{$this->jr_lon} BETWEEN {$min_lon} AND {$max_lon}";
             // Added for Hooked
             if ($extracoords) {
                 $squareArea = "((" . $squareArea . ")";
                 foreach ($extracoords as $extra) {
                     $e_lat = $extra->y;
                     $e_lon = $extra->x;
                     $lon_range = $radius / abs(cos($e_lat * pi() / 180) * $degreeDistance);
                     $min_lat = $e_lat - $lat_range;
                     $max_lat = $e_lat + $lat_range;
                     $min_lon = $e_lon - $lon_range;
                     $max_lon = $e_lon + $lon_range;
                     $squareArea .= " OR (`Field`.{$this->jr_lat} BETWEEN {$min_lat} AND {$max_lat} AND `Field`.{$this->jr_lon} BETWEEN {$min_lon} AND {$max_lon})";
                 }
                 $squareArea .= ")";
             }
             $conditions[] = $squareArea;
         }
     }
     // Create marker_icons array
     $marker_icons = array();
     $icon_fields = array();
     $field_images = array();
     $query = "SELECT DISTINCT marker_icon FROM #__jreviews_categories WHERE marker_icon != ''";
     $this->_db->setQuery($query);
     $icon_rows = $this->_db->loadAssocList();
     foreach ($icon_rows as $icons) {
         $icon = (array) json_decode($icons['marker_icon']);
         if ($icon['field'] != '') {
             $icon_fields[$icon['field']] = "'" . $icon['field'] . "'";
         }
     }
     if (!empty($icon_fields)) {
         foreach ($icon_fields as $field_key => $field) {
             $this->Listing->fields[] = "Field.{$field_key} AS `Field.{$field_key}`";
         }
     }
     if (!empty($custom_fields)) {
         foreach ($custom_fields as $field) {
             $this->Listing->fields[] = "Field.{$field} AS `Field.{$field}`";
         }
     }
     $this->Listing->joins = array("LEFT JOIN #__categories AS Category ON Listing.catid = Category.id", "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_content'", "LEFT JOIN #__jreviews_content AS `Field` ON Field.contentid = Listing.id", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_content'", "LEFT JOIN #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id");
     if ($fishingmap) {
         $this->Listing->joins[] = "LEFT JOIN #__relate_listings AS Related ON Related.id1 = Listing.id";
     }
     // Don't regroup the results by model name keys to save time
     $this->Listing->primaryKey = false;
     # Set conditionals based on configuration parameters
     if ($detail_view) {
         $conditions[] = 'Listing.id = ' . $id;
     }
     if ($dir_id) {
         $conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
     }
     if ($section_id) {
         $conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
     }
     if ($cat_id) {
         $conditions[] = 'Listing.catid IN (' . $cat_id . ')';
     }
     if ($listing_id) {
         $conditions[] = 'Listing.id IN (' . $listing_id . ')';
     }
     if ($filter == 'featured' && !$detail_view) {
         $conditions[] = 'Field.featured = 1';
     }
     $conditions[] = "Field.{$this->jr_lat} <> ''";
     $conditions[] = "Field.{$this->jr_lon} <> ''";
     $conditions[] = 'Listing.state = 1';
     if ($fishingmap) {
         $this->Listing->group = array('Listing.id');
     }
     // Paid Listings - add plan cat id
     isset($this->PaidListings) and $this->PaidListings->applyBeforeFindListingChanges($this->Listing);
     $listings = $this->Listing->findAll(array('conditions' => $conditions, 'limit' => $limit_results), array());
     $custom_fields = array_filter(array_merge($custom_fields, array_keys($icon_fields)));
     $fields = $this->Field->getFields($custom_fields);
     $json_data = $this->Geomaps->makeJsonObject($listings, $fields, $this->params['module']);
     $this->set('json_data', $json_data);
     if ($cache) {
         S2Cache::write($json_filename, $json_data);
     }
     return $this->render('modules', 'geomaps');
 }
コード例 #7
0
ファイル: routes.php プロジェクト: atikahmed/joomla-probid
 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);
 }
コード例 #8
0
 function _save()
 {
     /*******************************************************************
      * This method is processed inside an iframe
      * To access any of the DOM elements via jQuery it's necessary to prepend
      * all jQuery calls with $parentFrame (i.e. $parentFrame.jQuery)
      ********************************************************************/
     $this->autoRender = false;
     $this->autoLayout = false;
     $response = array();
     $parentFrame = 'window.parent';
     $validation = '';
     $listing_id = Sanitize::getInt($this->data['Listing'], 'id', 0);
     $isNew = $this->Listing->isNew = $listing_id == 0 ? true : false;
     $this->data['email'] = Sanitize::getString($this->data, 'email');
     $this->data['name'] = Sanitize::getString($this->data, 'name');
     $this->data['categoryid_hidden'] = Sanitize::getInt($this->data['Listing'], 'categoryid_hidden');
     $cat_id = Sanitize::getVar($this->data['Listing'], 'catid');
     $this->data['Listing']['catid'] = is_array($cat_id) ? (int) array_pop(array_filter($cat_id)) : (int) $cat_id;
     /*J16*/
     $this->data['Listing']['title'] = Sanitize::getString($this->data['Listing'], 'title', '');
     $this->data['Listing']['created_by_alias'] = Sanitize::getString($this->data, 'name', '');
     if ($this->cmsVersion == CMS_JOOMLA15) {
         $this->data['sectionid_hidden'] = Sanitize::getInt($this->data['Listing'], 'sectionid_hidden');
         $this->data['Listing']['sectionid'] = Sanitize::getInt($this->data['Listing'], 'sectionid');
     } else {
         $this->data['Listing']['language'] = '*';
         $this->data['Listing']['access'] = 1;
     }
     $category_id = $this->data['Listing']['catid'] ? $this->data['Listing']['catid'] : $this->data['categoryid_hidden'];
     # Get criteria info
     $criteria = $this->Criteria->findRow(array('conditions' => array('Criteria.id = 
             (SELECT criteriaid FROM #__jreviews_categories WHERE id = ' . (int) $category_id . ' AND `option` = "com_content")
         ')));
     if (!$criteria) {
         $validation = __t("The category selected is invalid.", true, true);
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
         $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
     }
     $this->data['Criteria']['id'] = $criteria['Criteria']['criteria_id'];
     # Override global configuration
     isset($criteria['ListingType']) and $this->Config->override($criteria['ListingType']['config']);
     # Perform access checks
     if ($isNew && !$this->Access->canAddListing()) {
         return $this->makeJS("{$parentFrame}.s2Alert('" . __t("You are not allowed to submit listings in this category.", true, true) . "')");
     } elseif (!$isNew) {
         $query = "SELECT created_by FROM #__content WHERE id = " . $listing_id;
         $this->_db->setQuery($query);
         $listing_owner = $this->_db->loadResult();
         if (!$this->Access->canEditListing($listing_owner)) {
             return $this->makeJS("{$parentFrame}.s2Alert('" . s2Messages::accessDenied() . "')");
         }
     }
     # Load the notifications observer model component and initialize it.
     # Done here so it only loads on save and not for all controlller actions.
     $this->components = array('security', 'notifications');
     $this->__initComponents();
     if ($this->invalidToken == true) {
         return $this->makeJS("{$parentFrame}.s2Alert('" . s2Messages::invalidToken() . "')");
     }
     # Override configuration
     $category = $this->Category->findRow(array('conditions' => array('Category.id = ' . $this->data['Listing']['catid'])));
     $this->Config->override($category['ListingType']['config']);
     if ($this->Access->loadWysiwygEditor()) {
         $this->data['Listing']['introtext'] = Sanitize::stripScripts(Sanitize::stripWhitespace(Sanitize::getVar($this->data['__raw']['Listing'], 'introtext')));
         $this->data['Listing']['fulltext'] = Sanitize::stripScripts(Sanitize::stripWhitespace(Sanitize::getVar($this->data['__raw']['Listing'], 'fulltext')));
         $this->data['Listing']['introtext'] = html_entity_decode($this->data['Listing']['introtext'], ENT_QUOTES, cmsFramework::getCharset());
         $this->data['Listing']['fulltext'] = html_entity_decode($this->data['Listing']['fulltext'], ENT_QUOTES, cmsFramework::getCharset());
     } else {
         $this->data['Listing']['introtext'] = Sanitize::stripAll($this->data['Listing'], 'introtext', '');
         if (isset($this->data['Listing']['fulltext'])) {
             $this->data['Listing']['fulltext'] = Sanitize::stripAll($this->data['Listing'], 'fulltext', '');
         } else {
             $this->data['Listing']['fulltext'] = '';
         }
     }
     $this->data['Listing']['introtext'] = str_replace('<br>', '<br />', $this->data['Listing']['introtext']);
     $this->data['Listing']['fulltext'] = str_replace('<br>', '<br />', $this->data['Listing']['fulltext']);
     if ($this->Access->canAddMeta()) {
         $this->data['Listing']['metadesc'] = Sanitize::getString($this->data['Listing'], 'metadesc');
         $this->data['Listing']['metakey'] = Sanitize::getString($this->data['Listing'], 'metakey');
     }
     // Title alias handling
     $slug = '';
     $alias = Sanitize::getString($this->data['Listing'], 'alias');
     if ($isNew && $alias == '') {
         $slug = S2Router::sefUrlEncode($this->data['Listing']['title']);
         if (trim(str_replace('-', '', $slug)) == '') {
             $slug = date("Y-m-d-H-i-s");
         }
     } elseif ($alias != '') {
         // Alias filled in so we convert it to a valid alias
         $slug = S2Router::sefUrlEncode($alias);
         if (trim(str_replace('-', '', $slug)) == '') {
             $slug = date("Y-m-d-H-i-s");
         }
     }
     $slug != '' and $this->data['Listing']['alias'] = $slug;
     # Check for duplicates
     switch ($this->Config->content_title_duplicates) {
         case 'category':
             // Checks for duplicates in the same category
             $query = "\r\n                        SELECT \r\n                            count(*) \r\n                        FROM \r\n                            #__content AS Listing WHERE Listing.title = " . $this->_db->Quote($this->data['Listing']['title']) . "\r\n                            AND Listing.state >= 0 \r\n                            AND Listing.catid = " . $this->data['Listing']['catid'] . (!$isNew ? " AND Listing.id <> " . $listing_id : '');
             $this->_db->setQuery($query);
             $titleExists = $this->_db->loadResult();
             break;
         case 'no':
             // Checks for duplicates all over the place
             $query = "\r\n                        SELECT \r\n                            count(*) \r\n                        FROM \r\n                            #__content AS Listing\r\n                        WHERE \r\n                            Listing.title = " . $this->_db->Quote($this->data['Listing']['title']) . "\r\n                           AND Listing.state >= 0\r\n                           " . (!$isNew ? " AND Listing.id <> " . $listing_id : '');
             $this->_db->setQuery($query);
             $titleExists = $this->_db->loadResult();
             break;
         case 'yes':
             // Duplicates are allowed, no checking necessary
             $titleExists = false;
             break;
     }
     if ($titleExists && $this->data['Listing']['title'] != '') {
         // if listing exists
         $validation = '<span>' . __t("A listing with that title already exists.", true, true) . "</span>";
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
         $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
     }
     // Review form display check logic used several times below
     $revFormSetting = $this->Config->content_show_reviewform;
     if ($revFormSetting == 'noteditors' && !$this->Config->author_review) {
         $revFormSetting = 'all';
     }
     $revFormEnabled = !isset($this->data['review_optional']) && $this->Access->canAddReview() && $isNew && ($revFormSetting == 'all' && ($this->Config->author_review || $this->Config->user_reviews) || $revFormSetting == 'authors' && $this->Access->isJreviewsEditor($this->_user->id) || $revFormSetting == 'noteditors' && !$this->Access->isJreviewsEditor($this->_user->id));
     // Validation of content default input fields
     if ($this->cmsVersion == CMS_JOOMLA15) {
         if (!$this->data['Listing']['catid'] || !$this->data['Listing']['sectionid']) {
             $this->Listing->validateSetError("sec_cat", __t("You need to select both a section and a category.", true));
         }
     } else {
         !$this->data['Listing']['catid'] and $this->Listing->validateSetError("sec_cat", __t("You need to select a category.", true));
     }
     // Validate only if it's a new listing
     if ($isNew) {
         if (!$this->_user->id) {
             $this->Listing->validateInput($this->data['name'], "name", "text", __t("You must fill in your name.", true), $this->Config->content_name == "required" ? 1 : 0);
             $this->Listing->validateInput($this->data['email'], "email", "email", __t("You must fill in a valid email address.", true), $this->Config->content_email == "required" ? 1 : 0);
             $this->data['name'] = Sanitize::getString($this->data, 'name', '');
             $this->data['email'] = Sanitize::getString($this->data, 'email', '');
         } else {
             $this->data['name'] = $this->_user->name;
             $this->data['email'] = $this->_user->email;
         }
     }
     $this->Listing->validateInput($this->data['Listing']['title'], "title", "text", __t("You must fill in a title for the new listing.", true, true), 1);
     # Validate listing custom fields
     $listing_valid_fields =& $this->Field->validate($this->data, 'listing', $this->Access);
     $this->Listing->validateErrors = array_merge($this->Listing->validateErrors, $this->Field->validateErrors);
     $this->Listing->validateInput($this->data['Listing']['introtext'], "introtext", "text", __t("You must fill in a summary for the new listing.", true, true), $this->Config->content_summary == "required" ? 1 : 0);
     $this->Listing->validateInput($this->data['Listing']['fulltext'], "fulltext", "text", __t("You must fill in a description for the new listing.", true, true), $this->Config->content_description == "required" ? 1 : 0);
     # Validate review custom fields
     if ($revFormEnabled && $criteria['Criteria']['state']) {
         // Review inputs
         $this->data['Review']['userid'] = $this->_user->id;
         $this->data['Review']['email'] = $this->data['email'];
         $this->data['Review']['name'] = $this->data['name'];
         $this->data['Review']['username'] = Sanitize::getString($this->data, 'name', '');
         $this->data['Review']['title'] = Sanitize::getString($this->data['Review'], 'title');
         $this->data['Review']['location'] = Sanitize::getString($this->data['Review'], 'location');
         // deprecated
         $this->data['Review']['comments'] = Sanitize::getString($this->data['Review'], 'comments');
         // Review standard fields
         $this->Listing->validateInput($this->data['Review']['title'], "rev_title", "text", __t("You must fill in a title for the review.", true, true), $this->Config->reviewform_title == 'required' ? true : false);
         if ($criteria['Criteria']['state'] == 1) {
             $criteria_qty = $criteria['Criteria']['quantity'];
             $ratingErr = 0;
             if (!isset($this->data['Rating'])) {
                 $ratingErr = $criteria_qty;
             } else {
                 for ($i = 0; $i < $criteria_qty; $i++) {
                     if (!isset($this->data['Rating']['ratings'][$i]) || (empty($this->data['Rating']['ratings'][$i]) || $this->data['Rating']['ratings'][$i] == 'undefined' || (double) $this->data['Rating']['ratings'][$i] > $this->Config->rating_scale)) {
                         $ratingErr++;
                     }
                 }
             }
             $this->Listing->validateInput('', "rating", "text", sprintf(__t("You are missing a rating in %s criteria.", true, true), $ratingErr), $ratingErr);
         }
         // Review custom fields
         $this->Field->validateErrors = array();
         // Clear any previous validation errors
         $review_valid_fields = $this->Field->validate($this->data, 'review', $this->Access);
         $this->Listing->validateErrors = array_merge($this->Listing->validateErrors, $this->Field->validateErrors);
         $this->Listing->validateInput($this->data['Review']['comments'], "comments", "text", __t("You must fill in your comment.", true, true), $this->Config->reviewform_comment == 'required' ? true : false);
     }
     // if ($revFormEnabled && $criteria['Criteria']['state'])
     # Validate image fields
     $this->Uploads->validateImages();
     # Validate Captcha security code
     if ($isNew && $this->Access->showCaptcha()) {
         if (!isset($this->data['Captcha']['code'])) {
             $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true, true));
         } elseif ($this->data['Captcha']['code'] == '') {
             $this->Listing->validateInput($this->data['Captcha']['code'], "code", "text", __t("You must fill in the security code.", true), 1);
         } else {
             if (!$this->Captcha->checkCode($this->data['Captcha']['code'], $this->ipaddress)) {
                 $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true, true));
             }
         }
     }
     # Get all validation messages
     $validation = $this->Listing->validateGetError() . $this->Uploads->getMsg();
     # Validation failed
     if ($validation != '') {
         $response[] = "var parentForm = {$parentFrame}.jQuery('#jr_listingForm');";
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "parentForm.find('.button').removeAttr('disabled');";
         // Transform textareas into wysiwyg editors
         if ($this->Access->loadWysiwygEditor()) {
             App::import('Helper', 'Editor', 'jreviews');
             $Editor = new EditorHelper();
             $response[] = $parentFrame . '.' . $Editor->transform(true);
         }
         // Replace captcha with new instance
         if ($this->Access->in_groups($this->Config->security_image)) {
             $captcha = $this->Captcha->displayCode();
             $response[] = "{$parentFrame}.jQuery('#captcha').attr('src','{$captcha['src']}');";
             $response[] = "{$parentFrame}.jQuery('#jr_captchaCode').val('');";
         }
         $response[] = "parentForm.find('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
         // Can't use ajaxResponse b/c we are in an iframe
     }
     # Validation passed, continue...
     if ($isNew) {
         $this->data['Listing']['created'] = _CURRENT_SERVER_TIME;
         //gmdate('Y-m-d H:i:s');
         $this->data['Listing']['publish_up'] = _CURRENT_SERVER_TIME;
         //gmdate('Y-m-d H:i:s');
         $this->data['Listing']['created_by'] = $this->_user->id;
         $this->data['Listing']['publish_down'] = NULL_DATE;
         $this->data['Field']['Listing']['email'] = $this->data['email'];
         // If visitor, assign name field to content Alias
         if (!$this->_user->id) {
             $this->data['Listing']['created_by_alias'] = $this->data['name'];
         }
         // Check moderation settings
         $this->data['Listing']['state'] = (int) (!$this->Access->moderateListing());
         // If listing moderation is enabled, then the review is also moderated
         if (!$this->data['Listing']['state']) {
             $this->Config->moderation_reviews = $this->Config->moderation_editor_reviews = $this->Config->moderation_item;
         }
     } else {
         if ($this->Config->moderation_item_edit) {
             $this->data['Listing']['state'] = (int) (!$this->Access->moderateListing());
         }
         $this->data['Listing']['modified'] = _CURRENT_SERVER_TIME;
         //gmdate('Y-m-d H:i:s');
         $this->data['Listing']['modified_by'] = $this->_user->id;
         $query = 'SELECT images FROM #__content WHERE id = ' . $this->data['Listing']['id'];
         $this->_db->setQuery($query);
         $this->data['Listing']['images'] = $this->_db->loadResult();
         // Check total number of images
         if (!$this->Uploads->checkImageCount($this->data['Listing']['images'])) {
             $validation .= '<span>' . sprintf(__t("The total number of images is limited to %s", true, true), $this->Config->content_images) . '</span><br />';
             $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
             $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
             $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
             return $this->makeJS($response);
         }
     }
     // Process images and update data array
     if ($this->Uploads->success) {
         $imageUploadPath = PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS;
         $this->Uploads->uploadImages($this->data['Listing']['id'], $imageUploadPath);
         if ($isNew) {
             // New item
             $currImages = $this->Uploads->images;
         } elseif ($this->data['Listing']['images'] != '') {
             // Editing and there are existing images
             $currImages = array_merge(explode("\n", $this->data['Listing']['images']), $this->Uploads->images);
         } else {
             // Editing and there are no existing images
             $currImages = $this->Uploads->images;
         }
         $this->data['Listing']['images'] = implode("\n", $currImages);
     }
     # Save listing
     $savedListing = $this->Listing->store($this->data);
     $listing_id = $this->data['Listing']['id'];
     if (!$savedListing) {
         $validation .= __t("The was a problem saving the listing", true, true);
     }
     // Error on listing save
     if ($validation != '') {
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
         $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
     }
     # Save listing custom fields
     $this->data['Field']['Listing']['contentid'] = $this->data['Listing']['id'];
     $this->Field->save($this->data, 'listing', $isNew, $listing_valid_fields);
     # Begin insert review in table
     if ($revFormEnabled && $criteria['Criteria']['state']) {
         // Get reviewer type, for now editor reviews don't work in Everywhere components
         $this->data['Review']['author'] = (int) $this->Access->isJreviewsEditor($this->_user->id);
         $this->data['Review']['mode'] = 'com_content';
         $this->data['Review']['pid'] = (int) $this->data['Listing']['id'];
         // Force plugin loading on Review model
         $this->_initPlugins('Review');
         $this->Review->isNew = true;
         $savedReview = $this->Review->save($this->data, $this->Access, $review_valid_fields);
     }
     # Before render callback
     if ($isNew && isset($this->Listing->plgBeforeRenderListingSaveTrigger)) {
         $plgBeforeRenderListingSave = $this->Listing->plgBeforeRenderListingSave();
         switch ($plgBeforeRenderListingSave) {
             case '0':
                 $this->data['Listing']['state'] = 1;
                 break;
             case '1':
                 $this->data['Listing']['state'] = 0;
                 break;
             case '':
                 break;
             default:
                 return $plgBeforeRenderListingSave;
                 break;
         }
     }
     # Moderation disabled
     if (!isset($this->data['Listing']['state']) || $this->data['Listing']['state']) {
         $fields = array('Criteria.criteria AS `Criteria.criteria`', 'Criteria.tooltips AS `Criteria.tooltips`');
         $listing = $this->Listing->findRow(array('fields' => $fields, 'conditions' => array('Listing.id = ' . $listing_id)), array('afterFind'));
         # Facebook wall integration
         $fb_checkbox = Sanitize::getBool($this->data, 'fb_publish');
         $facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_listings') && $fb_checkbox;
         $token = cmsFramework::getCustomToken($listing_id);
         $facebook_integration and $response[] = $parentFrame . '.jQuery.get(' . $parentFrame . '.s2AjaxUri+' . $parentFrame . '.jreviews.ajax_params()+\'&url=facebook/_postListing/id:' . $listing_id . '&' . $token . '=1\');
             ';
         $url = cmsFramework::route($listing['Listing']['url']);
         $update_text = $isNew ? __t("Thank you for your submission.", true, true) : __t("The listing was successfully saved.", true, true);
         //JOEYG CODE
         //THE FOLLOWING GETS THE LISTING TYPE FROM THE DB FOR THE NEWLY SAVED LISTING
         //IF THE TYPE IS BUSINESS PROFILE OR PROJECT LISTING THEN DISPLAY THE after_submit.thtml file
         //ELSE DISPLAY NORMAL MESSAGE
         //IF WE ONLY WANT TO ADD THE after_submit.thtml if the listing is new then add
         if ($isNew) {
             $query = "SELECT `listing_type` FROM `jos_vpbd_content_criteria` WHERE `jos_vpbd_content_criteria`.`listing_id` = " . $this->data['Listing']['id'];
             $this->_db->setQuery($query);
             $jg_listing_type = $this->_db->loadResult();
             if ($jg_listing_type == 2 || $jg_listing_type == 7) {
                 $update_html = $this->render('listings', 'after_submit');
             } else {
                 $update_html = "<a href=\"{$url}\">" . __t("Click here to view your listing", true) . "</a>";
             }
             //ends if/else
         } else {
             //not new
             $update_html = "<a href=\"{$url}\">" . __t("Click here to view your listing", true) . "</a>";
         }
         //ends if($isNew)
         //ENDS JOEYG ALTER CODE
         $jsonObject = json_encode(compact('target_id', 'update_text', 'update_html'));
         $response[] = '
                 var $parentForm = ' . $parentFrame . '.jQuery(\'#jr_listingForm\');
                 $parentForm.scrollTo({duration:400,offset:-100});
                 $parentForm.s2ShowUpdate(' . $jsonObject . ');                                                       
             ';
         return $this->makeJS($response);
     }
     # Moderation enabled
     $update_text = __t("Thank you for your submission. It will be published once it is verified.", true);
     $update_html = '<div id=\\"s2Msgjr_listingForm\\" class=\\"jr_postUpdate\\">' . $update_text . '</div>';
     $response[] = '
         var $parentForm = ' . $parentFrame . '.jQuery(\'#jr_listingForm\');
         $parentForm.scrollTo({duration:400,offset:-100},function(){
             $parentForm.fadeOut(250,function(){$parentForm.html("' . $update_html . '").show();});
         });
     ';
     return $this->makeJS($response);
 }
コード例 #9
0
ファイル: routes.php プロジェクト: bizanto/Hooked
// RSS Directory
S2Router::connect('/_d[0-9].*[.]rss/', array('controller' => 'feeds', 'action' => 'reviews'), array('dir', '/_d([0-9]+)/'));
// RSS Section
S2Router::connect('/_s[0-9].*[.]rss/', array('controller' => 'feeds', 'action' => 'reviews'), array('section', '/_s([0-9]+)/'));
// RSS Category
S2Router::connect('/_c[0-9].*[.]rss/', array('controller' => 'feeds', 'action' => 'reviews'), array('cat', '/_c([0-9]+)/'));
// RSS Listing
S2Router::connect('/_l[0-9]+_com_[0-9a-z_]*[.]rss/', array('controller' => 'feeds', 'action' => 'reviews'), array('id', '/_l([0-9]+)/'), array('extension', '/(com_[0-9a-z_]*)/'));
// Directory
S2Router::connect('/_d[0-9]+/', array('controller' => 'directories', 'action' => 'index'), array('dir', '/_d([0-9]+)/'), array('Itemid', '/_m([0-9]+)/'));
// Section list
S2Router::connect('/_s[0-9]+_/', array('controller' => 'categories', 'action' => 'section'), array('section', '/_s([0-9]+)/'), array('Itemid', '/_m([0-9]+)/'));
S2Router::connect('/_s[0-9]/', array('controller' => 'categories', 'action' => 'section'), array('section', '/_s([0-9]+)/'));
// Category list
S2Router::connect('/_c[0-9]+_/', array('controller' => 'categories', 'action' => 'category'), array('cat', '/_c([0-9]+)/'), array('Itemid', '/_m([0-9]+)/'));
S2Router::connect('/_c[0-9]/', array('controller' => 'categories', 'action' => 'category'), array('cat', '/_c([0-9]+)/'));
// Listing
S2Router::connect('/_l[0-9]+/', array('controller' => 'listings', 'action' => 'detail'), array('id', '/_l([0-9]+)/'), array('Itemid', '/_m([0-9]+)/'));
// My Listings
S2Router::connect('/^my-listings\\//', array('controller' => 'categories', 'action' => 'mylistings'));
// My Reviews
S2Router::connect('/^my-reviews\\//', array('controller' => 'reviews', 'action' => 'myreviews'));
// Favorites
S2Router::connect('/^favorites\\//', array('controller' => 'categories', 'action' => 'favorites'));
// Search Results
S2Router::connect('/^search-results/', array('controller' => 'categories', 'action' => 'search'), array('Itemid', '/_m([0-9]+)/'));
// Reviewers
S2Router::connect('/^reviewers/', array('controller' => 'reviews', 'action' => 'rankings'));
// Errors
S2Router::connect('/^404$/', array('controller' => 'errors', 'action' => 'error404'));
コード例 #10
0
ファイル: dispatcher.php プロジェクト: bizanto/Hooked
 /**
  * Returns array of GET and POST parameters. GET parameters are taken from given URL.
  *
  * @param string $fromUrl URL to mine for parameter information.
  * @return array Parameters found in POST and GET.
  * @access public
  */
 function parseParams($fromUrl = '')
 {
     $params = array();
     $params['data'] = array();
     isset($_COOKIE) and ini_get('magic_quotes_gpc') == 1 and $_COOKIE = s2_stripslashes_deep($_COOKIE);
     if (isset($_POST)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             if (function_exists('s2_stripslashes_deep')) {
                 $params['form'] = s2_stripslashes_deep($_POST);
             } else {
                 $params['form'] = stripslashes_deep($_POST);
             }
         } else {
             $params['form'] = $_POST;
         }
         if (isset($params['form']['_method'])) {
             if (isset($_SERVER) && !empty($_SERVER)) {
                 $_SERVER['REQUEST_METHOD'] = $params['form']['_method'];
             } else {
                 $_ENV['REQUEST_METHOD'] = $params['form']['_method'];
             }
             unset($params['form']['_method']);
         }
     }
     if (isset($params['form']['data'])) {
         $params['data'] = Sanitize::stripEscape($params['form']['data']);
         unset($params['form']['data']);
     }
     if (isset($_GET)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $url = s2_stripslashes_deep($_GET);
         } else {
             $url = $_GET;
         }
         if (isset($params['url'])) {
             $params['url'] = array_merge($params['url'], $url);
         } else {
             $params['url'] = $url;
         }
     }
     foreach ($_FILES as $name => $data) {
         if ($name != 'data') {
             $params['form'][$name] = $data;
         }
     }
     if (isset($_FILES['data'])) {
         foreach ($_FILES['data'] as $key => $data) {
             foreach ($data as $model => $fields) {
                 foreach ($fields as $field => $value) {
                     $params['data'][$model][$field][$key] = $value;
                 }
             }
         }
     }
     if (isset($params['data']['controller'])) {
         $params['controller'] = Sanitize::getString($params['data'], 'controller');
         $params['action'] = Sanitize::getString($params['data'], 'action');
     }
     $Router =& S2Router::getInstance();
     $Router->app = $this->app;
     $params = S2Router::parse($params);
     foreach ($params['url'] as $key => $value) {
         if ($key != 'url') {
             $params[$key] = $value;
         }
     }
     return $params;
 }
コード例 #11
0
ファイル: router.php プロジェクト: bizanto/Hooked
 function sefUrlEncode($text, $level = 0, $and_replace = 'and')
 {
     $_this =& S2Router::getInstance();
     if (isset($_this->__translit[$text])) {
         return $_this->__translit[$text];
     }
     $translitText = str_replace(array('-', '&'), array(' ', $and_replace), $text);
     switch ($level) {
         case 0:
         case 1:
             $translitText = htmlentities(utf8_decode($translitText));
             $translitText = preg_replace(array('/&szlig;/', '/&(..)lig;/', '/&([aouAOU])uml;/', '/&(.)[^;]*;/'), array('ss', "\$1", "\$1" . 'e', "\$1"), $translitText);
             // remove any duplicate whitespace, and ensure characters are alphanumeric
             $translitText = preg_replace(array('/\\s+/'), array('-'), $translitText);
             $translitText = preg_replace(array('/[^A-Za-z0-9\\-]/'), array(''), $translitText);
             break;
         case 2:
             App::import('Lib', 'utf8_to_ascii', $this->app);
             $translitText = utf8_to_ascii($translitText, '');
             break;
     }
     $_this->__translit[$text] = $translitText;
     return $translitText;
 }
コード例 #12
0
ファイル: routes.php プロジェクト: bizanto/Hooked
 function rssListing($listing, $title = '', $attributes = array())
 {
     if (isset($listing['Listing']['slug'])) {
         $listing_slug = S2Router::sefUrlEncode($listing['Listing']['slug'], $this->Config->transliterate_urls, __t("and", true));
     } else {
         $listing_slug = S2Router::sefUrlEncode($listing['Listing']['title'], $this->Config->transliterate_urls, __t("and", true));
     }
     $listing_title = $listing['Listing']['title'];
     $listing_id = $listing['Listing']['listing_id'];
     $extension = $listing['Listing']['extension'];
     $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);
     return $this->Html->sefLink('', $url, $attributes);
 }