本文整理汇总了PHP中Sanitize::getFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize::getFloat方法的具体用法?PHP Sanitize::getFloat怎么用?PHP Sanitize::getFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sanitize
的用法示例。
在下文中一共展示了Sanitize::getFloat方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getListingFavorites
function getListingFavorites($listing_id, $user_id, $passedArgs)
{
$conditions = array();
$avatar = Sanitize::getInt($passedArgs['module'], 'avatar', 1);
// Only show users with avatars
$count = Sanitize::getInt($passedArgs['module'], 'module_limit', 5);
$module_id = Sanitize::getInt($passedArgs, 'module_id');
$rand = Sanitize::getFloat($passedArgs, 'rand');
$fields = array('Community.' . $this->realKey . ' AS `User.user_id`', 'User.name AS `User.name`', 'User.username AS `User.username`');
if ($avatar) {
$conditions[] = 'Community.thumb <> "components/com_community/assets/default_thumb.jpg"';
}
if ($listing_id) {
$conditions[] = 'Community.' . $this->realKey . ' in (SELECT user_id FROM #__jreviews_favorites WHERE content_id = ' . $listing_id . ')';
}
$order = array('RAND(' . $rand . ')');
$joins = array('LEFT JOIN #__users AS User ON Community.' . $this->realKey . ' = User.id');
$profiles = $this->findAll(array('fields' => $fields, 'conditions' => $conditions, 'order' => $order, 'joins' => $joins));
if (Sanitize::getInt($passedArgs['module'], 'ajax_nav', 1)) {
$fields = array('count(Community.' . $this->realKey . ')');
$group = array('Community.' . $this->realKey);
$this->count = $this->findCount(array('fields' => $fields, 'conditions' => $conditions, 'group' => $group, 'joins' => $joins));
} else {
$this->count = Sanitize::getInt($passedArgs['module'], 'module_limit', 5);
}
return $this->addProfileInfo($profiles, 'User', 'user_id');
}
示例2: getListingFavorites
function getListingFavorites($listing_id, $user_id, $passedArgs)
{
$conditions = array();
$avatar = Sanitize::getInt($passedArgs['module'], 'avatar', 1);
// Only show users with avatars
$module_id = Sanitize::getInt($passedArgs, 'module_id');
$rand = Sanitize::getFloat($passedArgs, 'rand');
$limit = Sanitize::getInt($passedArgs['module'], 'module_total', 10);
$fields = array('Community.' . $this->realKey . ' AS `User.user_id`', 'User.name AS `User.name`', 'User.username AS `User.username`');
$avatar and $conditions[] = 'Community.thumb <> "components/com_community/assets/default_thumb.jpg" AND Community.thumb <> "components/com_community/assets/user_thumb.png" AND Community.thumb <> ""';
$listing_id and $conditions[] = 'Community.' . $this->realKey . ' in (SELECT user_id FROM #__jreviews_favorites WHERE content_id = ' . $listing_id . ')';
$order = array('RAND(' . $rand . ')');
$joins = array('LEFT JOIN #__users AS User ON Community.' . $this->realKey . ' = User.id');
$profiles = $this->findAll(array('fields' => $fields, 'conditions' => $conditions, 'order' => $order, 'joins' => $joins, 'limit' => $limit));
return $this->addProfileInfo($profiles, 'User', 'user_id');
}
示例3: getListingFavorites
function getListingFavorites($listing_id, $user_id, $passedArgs)
{
$avatar = Sanitize::getInt($passedArgs['module'], 'avatar', 1);
// Only show users with avatars
$module_id = Sanitize::getInt($passedArgs, 'module_id');
$rand = Sanitize::getFloat($passedArgs, 'rand');
$limit = Sanitize::getInt($passedArgs['module'], 'module_total', 10);
$fields = array('Community.id AS `User.user_id`', 'User.name AS `User.name`', 'User.username AS `User.username`');
$conditions = array('Community.approved = 1', 'Community.confirmed = 1');
$avatar and $conditions[] = 'Community.avatar IS NOT NULL';
$listing_id and $conditions[] = 'Community.id in (SELECT user_id FROM #__jreviews_favorites WHERE content_id = ' . $listing_id . ')';
$order = array('RAND(' . $rand . ')');
$joins = array('LEFT JOIN #__users AS User ON Community.id = User.id');
$profiles = $this->findAll(array('fields' => $fields, 'conditions' => $conditions, 'order' => $order, 'joins' => $joins, 'limit' => $limit));
return $this->addProfileInfo($profiles, 'User', 'user_id');
}
示例4: startup
function startup(&$controller)
{
$this->c =& $controller;
if (!$this->runPlugin($controller)) {
return false;
}
// Initialize vars
$center = array();
$address = '';
$lat = 0;
$lon = 0;
if (!isset($controller->Config)) {
$controller->Config = Configure::read('JreviewsSystem.Config');
}
if (!isset($controller->Access)) {
$controller->Config = Configure::read('JreviewsSystem.Access');
}
$this->max_radius = Sanitize::getInt($controller->Config, 'geomaps.max_radius', $this->max_radius);
$this->jr_lat = Sanitize::getString($controller->Config, 'geomaps.latitude');
$this->jr_lon = Sanitize::getString($controller->Config, 'geomaps.longitude');
if ($this->jr_lat == '' || $this->jr_lon == '') {
return false;
}
// Setup vars used in startup and other plugin methods
$this->google_url = Sanitize::getString($this->c->Config, 'geomaps.google_url', 'http://maps.google.com');
$this->google_api_key = trim(Sanitize::getString($controller->Config, 'geomaps.google_key'));
$this->google_api_url = $this->google_url . "/maps?file=api&v=2&async=2&key={$this->google_api_key}&sensor=false";
$search_method = Sanitize::getString($controller->Config, 'geomaps.search_method', 'address');
// address/disabled
$search_address_field = Sanitize::getString($controller->Config, 'geomaps.advsearch_input');
$default_radius = Sanitize::getString($controller->Config, 'geomaps.radius');
$this->distance_metric = array('mi' => __t("Miles", true), 'km' => __t("Km", true));
$this->distance_in = Sanitize::getString($controller->Config, 'geomaps.radius_metric', 'mi');
$this->jr_address1 = Sanitize::getString($controller->Config, 'geomaps.address1');
$this->jr_address2 = Sanitize::getString($controller->Config, 'geomaps.address2');
$this->jr_city = Sanitize::getString($controller->Config, 'geomaps.city');
$this->jr_state = Sanitize::getString($controller->Config, 'geomaps.state');
$this->jr_postal_code = Sanitize::getString($controller->Config, 'geomaps.postal_code');
$this->jr_country = Sanitize::getString($controller->Config, 'geomaps.country');
$this->country_def = Sanitize::getString($controller->Config, 'geomaps.default_country');
$this->gid = $controller->Access->gid;
$this->address_fields = array_filter(array('address1' => $this->jr_address1, 'address2' => $this->jr_address2, 'city' => $this->jr_city, 'state' => $this->jr_state, 'postal_code' => $this->jr_postal_code, 'country' => $this->jr_country));
$this->geo_fields = array('lat' => $this->jr_lat, 'lon' => $this->jr_lon);
$this->c->set(array('address_fields' => $this->address_fields, 'geo_fields' => $this->geo_fields));
/**
* Address search checks
*/
if (isset($controller->data['Field']['Listing'])) {
$address = Sanitize::getString($controller->data['Field']['Listing'], $search_address_field);
} else {
$address = Sanitize::getString($controller->params, $search_address_field);
$lat = Sanitize::getFloat($controller->params, $this->jr_lat);
$lon = Sanitize::getFloat($controller->params, $this->jr_lon);
}
/**
* Plugin does different things for different controller methods
*/
switch ($controller->name) {
case 'com_content':
$this->published = true;
$controller->Listing->cacheCallbacks[] = 'plgAfterAfterFind';
$controller->Listing->fields[] = "`Field`.{$this->jr_lat} AS `Geomaps.lat`";
$controller->Listing->fields[] = "`Field`.{$this->jr_lon} AS `Geomaps.lon`";
$controller->Listing->fields[] = "JreviewsCategory.marker_icon AS `Geomaps.icon`";
break;
case 'listings':
switch ($controller->action) {
// Load the geomaps js library
case 'create':
// Submit a new listing
// Submit a new listing
case 'edit':
// Edit a listing
$this->published = true;
$Html = new HtmlHelper();
$Html->app = 'jreviews';
$jsGlobals = 'var GeomapsGoogleApi = "' . $this->google_api_url . '";';
$jsGlobals .= 'var jr_lat = "' . $this->jr_lat . '";';
$jsGlobals .= 'var jr_lon = "' . $this->jr_lon . '";';
$jsGlobals .= 'var jr_country_def = "' . $this->country_def . '";';
$jsGlobals .= 'var geoAddressObj = {};';
foreach ($this->address_fields as $key => $field) {
$jsGlobals .= "geoAddressObj.{$key} = '{$field}';";
}
cmsFramework::addScript($controller->makeJS($jsGlobals), true);
$Html->js('geomaps', true);
if ($controller->action == 'edit') {
$mapit_field = Sanitize::getString($controller->Config, 'geomaps.mapit_field');
if ($mapit_field) {
$response = "jQuery(document).ready(function() { \r\n jQuery('#{$mapit_field}','#jr_listingForm').after('<span id=\"gm_geocode\">\r\n <input class=\"jrButton\" type=\"button\" onclick=\"geomaps.mapPopupSimple();\" value=\"" . __t("Map it", true) . "\" /> \r\n <input class=\"jrButton\" type=\"button\" onclick=\"geomaps.clearLatLng();\" value=\"" . __t("Clear LatLng", true) . "\" />\r\n </span>');\r\n });";
cmsFramework::addScript($controller->makeJS($response), true);
}
}
break;
// Add geomaps buttons after form is loaded
// Add geomaps buttons after form is loaded
case '_loadForm':
// New listing - Loads submit listing form after category selection
$this->published = true;
$mapit_field = Sanitize::getString($controller->Config, 'geomaps.mapit_field');
//.........这里部分代码省略.........
示例5: listings
function listings()
{
// Initialize variables
$id = Sanitize::getInt($this->params, 'id');
$option = Sanitize::getString($this->params, 'option');
$view = Sanitize::getString($this->params, 'view');
$menu_id = Sanitize::getString($this->params, 'Itemid');
// Read params
$cat_id = '';
$criteria_ids = '';
$in_detail_view = false;
$detail_view = 1;
$dir_id = Sanitize::getString($this->params, 'dir');
$section_id = Sanitize::getString($this->params, 'section');
$cat_id = Sanitize::getString($this->params, 'cat');
$extension = 'com_content';
$custom_where = null;
$custom_fields = array();
$click2search_auto = false;
$cache = 0;
$radius = 0;
$mode = 0;
if (isset($this->params['module'])) {
// Read module parameters
$click2search_auto = Sanitize::getBool($this->params['module'], 'click2search_auto', false);
$custom_where = Sanitize::getString($this->params['module'], 'custom_where');
$filter = Sanitize::getString($this->params['module'], 'filter');
$detail_view = Sanitize::getString($this->params['module'], 'detail_view', 1);
$dir_id = Sanitize::getString($this->params['module'], 'dir');
$section_id = Sanitize::getString($this->params['module'], 'section');
$cat_id = Sanitize::getString($this->params['module'], 'category');
$listing_id = Sanitize::getString($this->params['module'], 'listing');
$criteria_ids = Sanitize::getString($this->params['module'], 'criteria');
$limit_results = Sanitize::getInt($this->params['module'], 'limit_results');
$mode = Sanitize::getInt($this->params['module'], 'mode', 0);
$custom_fields = str_replace(" ", "", Sanitize::getString($this->Config, 'geomaps.infowindow_fields'));
$custom_fields = $custom_fields != '' ? explode(",", $custom_fields) : array();
/**
* 0 - Normal
* 1 - GeoTargeting
* 2 - Custom center and zoom
*/
$radius = Sanitize::getInt($this->params['module'], 'radius');
$cache = $mode == 1 ? 0 : Sanitize::getInt($this->params['module'], 'cache_map');
$custom_lat = Sanitize::getFloat($this->params['module'], 'custom_lat');
$custom_lon = Sanitize::getFloat($this->params['module'], 'custom_lon');
if ($mode == 2 && ($custom_lat == 0 || $custom_lon == 0)) {
echo __t("You selected the Custom Center mode, but did not specify the coordinates.");
return;
}
}
# Prevent sql injection
$token = Sanitize::getString($this->params, 'token');
$tokenMatch = 0 === strcmp($token, cmsFramework::formIntegrityToken($this->params, array('module', 'module_id', 'form', 'data'), false));
$filters = $listing_id != '' || $dir_id != '' || $section_id != '' || $cat_id != '';
if (!$filters && $id > 0 && 'article' == $view && 'com_content' == $option) {
$sql = "SELECT catid FROM #__content WHERE id = " . $id;
$this->_db->setQuery($sql);
$cat_id_host_page = $this->_db->loadResult();
if (!empty($cat_id_host_page) && $this->Category->isJreviewsCategory($cat_id_host_page)) {
$in_detail_view = true;
$cat_id = $cat_id_host_page;
}
}
$detail_view = $this->params['module']['detail_view'] = (int) ($detail_view && $in_detail_view);
# Custom WHERE
$tokenMatch and $custom_where and $conditions[] = $custom_where;
if ($click2search_auto && isset($this->params['tag'])) {
$field = 'jr_' . Sanitize::getString($this->params['tag'], 'field');
$value = Sanitize::getString($this->params['tag'], 'value');
$query = "SELECT Field.type FROM #__jreviews_fields AS Field WHERE Field.name = " . $this->quote($field);
$this->_db->setQuery($query);
$type = $this->_db->loadResult();
if (in_array($type, array('select', 'selectmultiple', 'checkboxes', 'radiobuttons'))) {
$conditions[] = "Field.{$field} LIKE " . $this->quoteLike('*' . $value . '*');
} else {
$conditions[] = "Field.{$field} = " . $this->quote($value);
}
}
# Category auto detect
if (isset($this->params['module']) && Sanitize::getInt($this->params['module'], 'cat_auto') && $extension == 'com_content') {
$ids = CommonController::_discoverIDs($this);
extract($ids);
}
$autodetect = compact('dir_id', 'section_id', 'cat_id');
// Check for cached version if cache enabled
if ($cache) {
$params = array();
foreach ($this->params as $key => $value) {
if ((!is_array($value) || $key == 'module') && !in_array($key, array('page', 'limit', 'order', 'Itemid'))) {
$params[$key] = $value;
}
}
$cache_key = array_merge($params, $autodetect, Sanitize::getVar($this->params, 'tag', array()));
$json_filename = 'geomaps_' . md5(serialize($cache_key)) . '.json';
$json_data = S2Cache::read($json_filename);
if ($json_data && $json_data != '') {
$this->set('json_data', $json_data);
S2Cache::write($json_filename, $json_data);
return $this->render('modules', 'geomaps');
//.........这里部分代码省略.........
示例6: index
//.........这里部分代码省略.........
unset($this->Listing->joins['ParentCategory']);
}
empty($cat_id) and !empty($section_id) and $conditions[] = 'Listing.sectionid IN (' . cleanIntegerCommaList($section_id) . ')';
empty($cat_id) and !empty($dir_id) and $conditions[] = 'JreviewsCategory.dirid IN (' . cleanIntegerCommaList($dir_id) . ')';
empty($cat_id) and !empty($criteria_id) and $conditions[] = 'JreviewsCategory.criteriaid IN (' . cleanIntegerCommaList($criteria_id) . ')';
} else {
if (Sanitize::getInt($this->params['module'], 'cat_auto') && method_exists($this->Listing, 'catUrlParam')) {
if ($cat_id = Sanitize::getInt($this->passedArgs, $this->Listing->catUrlParam())) {
$conditions[] = 'JreviewsCategory.id IN (' . cleanIntegerCommaList($cat_id) . ')';
}
} elseif ($cat_id) {
$conditions[] = 'JreviewsCategory.id IN (' . cleanIntegerCommaList($cat_id) . ')';
}
}
$listing_id and $conditions[] = "Listing.{$this->Listing->realKey} IN (" . cleanIntegerCommaList($listing_id) . ")";
switch ($sort) {
case 'random':
$order[] = 'RAND(' . $this->params['rand'] . ')';
break;
case 'featured':
$conditions[] = 'Field.featured = 1';
break;
case 'featuredrandom':
$conditions[] = 'Field.featured = 1';
$order[] = 'RAND(' . $this->params['rand'] . ')';
break;
case 'topratededitor':
// $conditions[] = 'Totals.editor_rating > 0';
$sort = 'editor_rating';
break;
// Editor rating sorting options dealt with in the Listing->processSorting method
}
# Custom WHERE
$tokenMatch and $custom_where and $conditions[] = $custom_where;
# Filtering options
$having = array();
// Listings submitted in the past x days
$entry_period = Sanitize::getInt($this->params['module'], 'filter_listing_period');
if ($entry_period > 0 && $this->Listing->dateKey) {
$conditions[] = "Listing.{$this->Listing->dateKey} >= DATE_SUB('" . _CURRENT_SERVER_TIME . "', INTERVAL {$entry_period} DAY)";
}
// Listings with reviews submitted in past x days
$review_period = Sanitize::getInt($this->params['module'], 'filter_review_period');
if ($review_period > 0) {
$conditions[] = "Review.created >= DATE_SUB(CURDATE(), INTERVAL {$review_period} DAY)";
$joins[] = 'LEFT JOIN #__jreviews_comments AS Review ON Listing.' . $this->Listing->realKey . ' = Review.pid';
}
// Listings with review count higher than
$filter_review_count = Sanitize::getInt($this->params['module'], 'filter_review_count');
$filter_review_count > 0 and $conditions[] = "Totals.user_rating_count >= " . $filter_review_count;
// Listings with avg rating higher than
$filter_avg_rating = Sanitize::getFloat($this->params['module'], 'filter_avg_rating');
$filter_avg_rating > 0 and $conditions[] = 'Totals.user_rating >= ' . $filter_avg_rating;
$this->Listing->group = array();
// Exlude listings without ratings from the results
$join_direction = in_array($sort, array('rating', 'rrating', 'topratededitor', 'reviews')) ? 'INNER' : 'LEFT';
$this->Listing->joins['Total'] = "{$join_direction} JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.{$this->Listing->realKey} AND Totals.extension = " . $this->quote($extension);
# Modify query for correct ordering. Change FIELDS, ORDER BY and HAVING BY directly in Listing Model variables
if ($tokenMatch and $custom_order) {
$this->Listing->order[] = $custom_order;
} elseif (empty($order) && $extension == 'com_content') {
$this->Listing->processSorting('module', $sort);
// Modifies Listing model order var directly
} elseif (empty($order) && ($order = $this->__processSorting($sort))) {
$order = array($order);
}
$fields = array('Totals.user_rating AS `Review.user_rating`', 'Totals.user_rating_count AS `Review.user_rating_count`', 'Totals.user_comment_count AS `Review.review_count`', 'Totals.editor_rating AS `Review.editor_rating`', 'Totals.editor_rating_count AS `Review.editor_rating_count`', 'Totals.editor_comment_count AS `Review.editor_review_count`');
$queryData = array('fields' => !isset($this->Listing->fields['editor_rating']) ? $fields : array(), 'joins' => $joins, 'conditions' => $conditions, 'limit' => $total, 'having' => $having);
isset($order) and !empty($order) and $queryData['order'] = $order;
// Trigger addFields for $listing results. Checked in Everywhere model
$this->Listing->addFields = true;
$listings = $this->Listing->findAll($queryData);
$count = count($listings);
} else {
$listings = array();
$count = 0;
}
unset($this->Listing);
# Send variables to view template
$this->set(array('autodetect_ids' => $ids, 'subclass' => 'listing', 'listings' => $listings, 'total' => $count, 'limit' => $limit));
$this->_completeModuleParamsArray();
$page = $this->ajaxRequest && empty($listings) ? '' : $this->render('modules', 'listings');
/* if($this->_user->id === 0 && $this->ajaxRequest)
{
$path = $this->here;
$this->here == '/' and $path = 'home';
$cache_fname = Inflector::slug($path) . '.php';
$now = time();
$cacheTime = is_numeric($this->cacheAction) ? $now + $this->cacheAction : strtotime($this->cacheAction, $now);
$fileHeader = '<!--cachetime:' . $cacheTime . '-->';
cache('views' . DS . $cache_fname, $fileHeader . $this->ajaxResponse($page,false), $this->cacheAction);
}*/
return $this->ajaxRequest ? $this->ajaxResponse($page, false) : $page;
}
示例7: listings
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);
//.........这里部分代码省略.........
示例8: save
function save(&$data, $location = 'listing', $isNew, &$validFields)
{
$msg = '';
$fieldLocation = inflector::camelize($location);
// Check if there are custom fields to save or exit
if (isset($data['Field']) && (!is_array($data['Field'][$fieldLocation]) || count($data['Field'][$fieldLocation]) == 1)) {
return $msg;
}
// Define field types that accept predefined options to store the reference values
$optionsArray = array("select", "selectmultiple", "checkboxes", "radiobuttons");
if (!empty($validFields)) {
foreach ($validFields as $validField) {
$fieldName = $validField['name'];
$inputValue = '';
if (Sanitize::getVar($data['Field'][$fieldLocation], $fieldName, '') != '' || $validField['type'] == 'code' && Sanitize::getVar($data['__raw']['Field'][$fieldLocation], $fieldName, '') != '') {
switch ($validField['type']) {
case 'selectmultiple':
case 'checkboxes':
//Checks for types with options
$multi_options = Sanitize::getVar($data['Field'][$fieldLocation], $fieldName, '');
$inputValue = '*' . implode('*', $multi_options) . '*';
break;
case 'select':
case 'radiobuttons':
//Checks for types with options
$inputValue = '*' . Sanitize::getString($data['Field'][$fieldLocation], $fieldName) . '*';
break;
case 'code':
// Affiliate code left unfiltered
$inputValue = Sanitize::getString($data['__raw']['Field'][$fieldLocation], $fieldName, '');
break;
case 'decimal':
$inputValue = Sanitize::getFloat($data['Field'][$fieldLocation], $fieldName);
break;
case 'integer':
$inputValue = Sanitize::getInt($data['Field'][$fieldLocation], $fieldName);
break;
case 'date':
if (Sanitize::getString($data['Field'][$fieldLocation], $fieldName) != '' && Sanitize::getString($data['Field'][$fieldLocation], $fieldName) != null) {
$inputValue = strftime(_CURRENT_SERVER_TIME_FORMAT, strtotime(Sanitize::getString($data['Field'][$fieldLocation], $fieldName)));
} else {
$inputValue = '';
}
break;
case 'textarea':
case 'text':
if (isset($validField['_params']['allow_html']) && $validField['_params']['allow_html'] == 1) {
$inputValue = Sanitize::stripScripts(Sanitize::getVar($data['__raw']['Field'][$fieldLocation], $fieldName));
$inputValue = stripslashes($inputValue);
} else {
$inputValue = Sanitize::getString($data['Field'][$fieldLocation], $fieldName, '');
}
break;
case 'website':
case 'email':
$inputValue = Sanitize::stripScripts(Sanitize::getVar($data['Field'][$fieldLocation], $fieldName));
break;
default:
$inputValue = Sanitize::getVar($data['Field'][$fieldLocation], $fieldName);
break;
}
# Modify form post arrays to current values
if ($inputValue === '' || $inputValue === '**') {
$inputValue = '';
}
$data['Field'][$fieldLocation][$fieldName] = $inputValue;
} else {
// To clear multiple choice fields
switch ($validField['type']) {
case 'decimal':
case 'integer':
$data['Field'][$fieldLocation][$fieldName] = null;
break;
default:
$data['Field'][$fieldLocation][$fieldName] = '';
break;
}
}
// Debug custom fields array
$msg .= "{$validField['name']}=>{$inputValue}" . "<br />";
}
}
# Need to check if jreviews_content or jreviews_reviews record exists to decide whether to insert or update the table
if ($location == 'review') {
App::import('Model', 'jreviews_review_field', 'jreviews');
$JreviewsReviewFieldModel = new JreviewsReviewFieldModel();
$recordExists = $JreviewsReviewFieldModel->findCount(array('conditions' => array('JreviewsReviewField.reviewid= ' . $data['Field']['Review']['reviewid'])));
} else {
App::import('Model', 'jreviews_content', 'jreviews');
$JreviewsContentModel = new JreviewsContentModel();
$recordExists = $JreviewsContentModel->findCount(array('conditions' => array('JreviewsContent.contentid = ' . $data['Listing']['id'])));
}
$dbAction = $recordExists ? 'update' : 'insert';
if ($location == 'review') {
$this->{$dbAction}('#__jreviews_review_fields', $fieldLocation, $data['Field'], 'reviewid');
} else {
if (Configure::read('PaidListings.enabled') && Sanitize::getInt($data, 'paid_category')) {
# PaidListings integration - saves all fields to jreviews_paid_listing_fields table and removes unpaid fields from jreviews_content table
$PaidListingField = RegisterClass::getInstance('PaidListingFieldModel');
$PaidListingField->save($data);
//.........这里部分代码省略.........
示例9: index
//.........这里部分代码省略.........
if ($extension != 'com_content' && in_array($sort, array('topratededitor', 'featuredrandom', 'rhits'))) {
echo "You have selected the {$sort} mode which is not supported for components other than com_content. Please read the tooltips in the module parameters for more info on allowed settings.";
return;
}
# Category auto detect
if (Sanitize::getInt($this->params['module'], 'cat_auto') && $extension == 'com_content') {
$ids = CommonController::_discoverIDs($this);
extract($ids);
}
# Set conditionals based on configuration parameters
if ($extension == 'com_content') {
// Only works for core articles
$conditions = array_merge($conditions, array('Listing.state = 1', '( Listing.publish_up = "' . NULL_DATE . '" OR DATE(Listing.publish_up) <= DATE("' . _CURRENT_SERVER_TIME . '") )', '( Listing.publish_down = "' . NULL_DATE . '" OR DATE(Listing.publish_down) >= DATE("' . _CURRENT_SERVER_TIME . '") )', 'Listing.access <= ' . $this->_user->gid));
// Remove unnecessary fields from model query
$this->Listing->modelUnbind(array('Listing.fulltext AS `Listing.description`', 'Listing.metakey AS `Listing.metakey`', 'Listing.metadesc AS `Listing.metadesc`', 'User.email AS `User.email`'));
$cat_id != '' and $conditions[] = 'Listing.catid IN (' . cleanIntegerCommaList($cat_id) . ')';
$cat_id == '' and $section_id != '' and $conditions[] = 'Listing.sectionid IN (' . cleanIntegerCommaList($section_id) . ')';
$cat_id == '' and $dir_id != '' and $conditions[] = 'JreviewsCategory.dirid IN (' . cleanIntegerCommaList($dir_id) . ')';
$cat_id == '' and $criteria_id != '' and $conditions[] = 'JreviewsCategory.criteriaid IN (' . cleanIntegerCommaList($criteria_id) . ')';
} else {
if (Sanitize::getInt($this->params['module'], 'cat_auto') && method_exists($this->Listing, 'catUrlParam')) {
if ($cat_id = Sanitize::getInt($this->passedArgs, $this->Listing->catUrlParam())) {
$conditions[] = 'JreviewsCategory.id IN (' . cleanIntegerCommaList($cat_id) . ')';
}
} elseif ($cat_id) {
$conditions[] = 'JreviewsCategory.id IN (' . cleanIntegerCommaList($cat_id) . ')';
}
}
$listing_id and $conditions[] = "Listing.{$this->Listing->realKey} IN (" . cleanIntegerCommaList($listing_id) . ")";
switch ($sort) {
case 'random':
$order[] = 'RAND(' . $this->params['rand'] . ')';
break;
case 'featuredrandom':
$conditions[] = 'featured > 0';
$order[] = 'RAND(' . $this->params['rand'] . ')';
break;
case 'topratededitor':
$conditions[] = 'Totals.editor_rating > 0';
break;
// Editor rating sorting options dealt with in the Listing->processSorting method
}
# Custom WHERE
$tokenMatch and $custom_where and $conditions[] = $custom_where;
# Filtering options
$having = array();
// Listings submitted in the past x days
$entry_period = Sanitize::getInt($this->params['module'], 'filter_listing_period');
if ($entry_period > 0 && $this->Listing->dateKey) {
$conditions[] = "Listing.{$this->Listing->dateKey} >= DATE_SUB('" . _CURRENT_SERVER_TIME . "', INTERVAL {$entry_period} DAY)";
}
// Listings with reviews submitted in past x days
$review_period = Sanitize::getInt($this->params['module'], 'filter_review_period');
if ($review_period > 0) {
$conditions[] = "Review.created >= DATE_SUB(CURDATE(), INTERVAL {$review_period} DAY)";
$joins[] = 'LEFT JOIN #__jreviews_comments AS Review ON Listing.' . $this->Listing->realKey . ' = Review.pid';
}
// Listings with review count higher than
$filter_review_count = Sanitize::getInt($this->params['module'], 'filter_review_count');
$filter_review_count > 0 and $conditions[] = "Totals.user_rating_count >= " . $filter_review_count;
// Listings with avg rating higher than
$filter_avg_rating = Sanitize::getFloat($this->params['module'], 'filter_avg_rating');
$filter_avg_rating > 0 and $conditions[] = 'Totals.user_rating >= ' . $filter_avg_rating;
$this->Listing->group = array();
// Exlude listings without ratings from the results
$join_direction = in_array($sort, array('rating', 'rrating', 'topratededitor', 'reviews')) ? 'INNER' : 'LEFT';
$this->Listing->joins['Total'] = "{$join_direction} JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.{$this->Listing->realKey} AND Totals.extension = " . $this->quote($extension);
# Modify query for correct ordering. Change FIELDS, ORDER BY and HAVING BY directly in Listing Model variables
if ($tokenMatch and $custom_order) {
$this->Listing->order[] = $custom_order;
} elseif (empty($order) && $extension == 'com_content') {
$this->Listing->processSorting($sort, '');
} elseif (empty($order) && ($order = $this->_processSorting($sort))) {
$order = array($order);
}
$queryData = array('fields' => array('Totals.user_rating AS `Review.user_rating`', 'Totals.user_rating_count AS `Review.user_rating_count`', 'Totals.user_comment_count AS `Review.review_count`', 'Totals.editor_rating AS `Review.editor_rating`', 'Totals.editor_rating_count AS `Review.editor_rating_count`', 'Totals.editor_comment_count AS `Review.editor_review_count`'), 'joins' => $joins, 'conditions' => $conditions, 'limit' => $this->module_limit, 'offset' => $this->module_offset, 'having' => $having);
isset($order) and !empty($order) and $queryData['order'] = $order;
// Trigger addFields for $listing results. Checked in Everywhere model
$this->Listing->addFields = true;
$listings = $this->Listing->findAll($queryData);
if (Sanitize::getInt($this->params['module'], 'ajax_nav', 1)) {
unset($queryData['joins']['Section'], $queryData['joins']['Category'], $queryData['joins']['Directory'], $queryData['joins']['Criteria'], $queryData['joins']['User'], $queryData['order']);
$count = $this->Listing->findCount($queryData, 'DISTINCT Listing.' . $this->Listing->realKey);
} else {
$count = $this->module_limit;
}
} else {
$listings = array();
$count = 0;
}
unset($this->Listing);
# Send variables to view template
$this->set(array('Access' => $this->Access, 'User' => $this->_user, 'subclass' => 'listing', 'listings' => $listings, 'total' => $count));
$page = $this->render('modules', 'listings');
if ($this->ajaxRequest) {
return $this->ajaxResponse($page, false);
} else {
return $page;
}
}