本文整理汇总了PHP中Sanitize::getString方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize::getString方法的具体用法?PHP Sanitize::getString怎么用?PHP Sanitize::getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sanitize
的用法示例。
在下文中一共展示了Sanitize::getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id'));
$this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix');
$cache_file = 'modules_totals_' . $module_id . '_' . md5(serialize($this->params['module']));
$page = $this->cached($cache_file);
if ($page) {
return $page;
}
// Initialize variables
$extension = Sanitize::getString($this->params['module'], 'extension');
// Automagically load and initialize Everywhere Model
App::import('Model', 'everywhere_' . $extension, 'jreviews');
$class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
$conditions_reviews = array('Review.published = 1');
$extension == 'com_content' and $conditions_listings = array('Listing.state = 1');
$extension != '' and $conditions_reviews[] = "Review.mode = " . $this->quote($extension);
if (class_exists($class_name)) {
$this->Listing = new $class_name();
$this->Listing->_user = $this->_user;
$listings = $this->Listing->findCount(array('conditions' => $conditions_listings), 'DISTINCT Listing.' . $this->Listing->realKey);
$reviews = $this->Review->findCount(array('conditions' => $conditions_reviews), 'DISTINCT Review.id');
}
# Send variables to view template
$this->set(array('listing_count' => isset($listings) ? $listings : 0, 'review_count' => isset($reviews) ? $reviews : 0));
$page = $this->render('modules', 'totals');
# Save cached version
$this->cacheView('modules', 'totals', $cache_file, $page);
return $page;
}
示例2: google
function google($address)
{
$this->_API['google'] = str_replace('{google_url}', Sanitize::getString($this->Config, 'geomaps.google_url', 'http://maps.google.com'), $this->_API['google']);
$geoData = false;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, sprintf($this->_API['google'], urlencode($address)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = trim(curl_exec($curl));
// Process JSON
if (!empty($response)) {
$data = json_decode($response);
if ($data->status == "OK" && is_array($data->results) && ($result = $data->results[0])) {
$status = 200;
$elev = 0;
$lat = $result->geometry->location->lat;
$lon = $result->geometry->location->lng;
if (!is_numeric($lat) || !is_numeric($lon)) {
$status = 'error';
}
$geoData = array('status' => $status, 'lon' => $lon, 'lat' => $lat, 'elev' => $elev);
}
}
curl_close($curl);
return $geoData;
}
示例3: google
function google($address)
{
$this->_API['google'] = str_replace('{google_url}', Sanitize::getString($this->Config, 'geomaps.google_url', 'http://maps.google.com'), $this->_API['google']);
$geoData = false;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, sprintf($this->_API['google'], urlencode($address)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = trim(curl_exec($curl));
// Process CSV
if ($response != '' && $response != 620 && count(explode(',', $response)) > 3) {
// Split pieces of data by the comma that separates them
list($status, $elev, $lat, $lon) = explode(",", $response);
if (!is_numeric($lat) || !is_numeric($lon)) {
$status = 'error';
}
$geoData = array('status' => $status, 'lon' => $lon, 'lat' => $lat, 'elev' => $elev);
// More complete data can be found via XML
// Create SimpleXML object from XML Content
// $xmlObject = simplexml_load_string($xmlContent);
// $localObject = $xmlObject->Response;
// prx($localObject);
}
curl_close($curl);
return $geoData;
}
示例4: findChildOptions
function findChildOptions()
{
$response = array();
$childField = Sanitize::getString($this->data, 'childField');
$childSelected = Sanitize::getString($this->data, 'childSelected');
$parentValue = Sanitize::getString($this->data, 'parentValue');
$module_id = Sanitize::getInt($this->data, 'module_id');
if ($parentValue == '') {
$ret = '<option value="">' . __t("Select", true, true) . '</option>';
$response[] = "jQuery(\"#{$childField}{$module_id}\").html('{$ret}').attr('disabled','disabled');";
return implode(' ', $response);
}
$query = " \r\n SELECT \r\n FieldOption.optionid, FieldOption.text, FieldOption.value\r\n FROM #__jreviews_fieldoptions AS FieldOption\r\n INNER JOIN #__jreviews_fields AS Field ON FieldOption.fieldid = Field.fieldid AND Field.name = '" . $childField . "'\r\n WHERE FieldOption.value LIKE '" . $parentValue . "-%'\r\n ";
$this->_db->setQuery($query);
$options = $this->_db->loadAssocList();
$ret = '<option value="">' . __t("Select", true, true) . '</option>';
foreach ($options as $option) {
if ($childSelected != '' && $option['value'] == $childSelected) {
$ret .= '<option selected="selected" value="' . $option['value'] . '">' . $option['text'] . '</option>';
} else {
$ret .= '<option value="' . $option['value'] . '">' . $option['text'] . '</option>';
}
}
$response[] = "jQuery(\"#{$childField}{$module_id}\").html('{$ret}').removeAttr('disabled');";
return implode(' ', $response);
}
示例5: addPagination
function addPagination($page, $limit)
{
if (cmsFramework::isAdmin()) {
$url = rtrim($this->base_url, '/') . ($page > 1 ? '/' . 'page' . _PARAM_CHAR . $page . '/limit' . _PARAM_CHAR . $limit . '/' : '');
} else {
$order = Sanitize::getString($this->params, 'order');
$default_limit = Sanitize::getInt($this->params, 'default_limit');
$url_params = $this->passedArgs;
unset($url_params['page'], $url_params['Itemid'], $url_params['option'], $url_params['view']);
if ($page == 1 && $this->limit == $default_limit && ($order == '' || $order == Sanitize::getString($this->params, 'default_order')) && empty($url_params)) {
preg_match('/^index.php\\?option=com_jreviews&Itemid=[0-9]+/i', $this->base_url, $matches);
$url = $matches[0];
} else {
$url = $this->base_url;
$page > 1 and $url = rtrim($url, '/') . '/' . 'page' . _PARAM_CHAR . $page . '/';
if ($this->limit != $default_limit) {
$url = rtrim($url, '/') . '/limit' . _PARAM_CHAR . $limit . '/';
}
}
// Remove menu segment from url if page 1 and it' a menu
if ($page == 1 && preg_match('/^(index.php\\?option=com_jreviews&Itemid=[0-9]+)(&url=menu\\/)$/i', $url, $matches)) {
$url = $matches[1];
}
$url = cmsFramework::route($url);
}
return $url;
}
示例6: index
function index($params)
{
$this->action = 'directory';
// Set view file
# Read module params
$dir_id = cleanIntegerCommaList(Sanitize::getString($this->params['module'], 'dir_ids'));
$conditions = array();
$order = array();
$cat_id = '';
$section_id = '';
$directories = $this->Directory->getTree($dir_id, true);
if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) {
$menuParams = $this->Menu->getMenuParams($menu_id);
}
# Category auto detect
$ids = CommonController::_discoverIDs($this);
extract($ids);
if ($cat_id != '' && $section_id == '') {
$cat_id = cleanIntegerCommaList($cat_id);
$sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")";
$this->_db->setQuery($sql);
$section_id = $this->_db->loadResult();
}
$this->set(array('directories' => $directories, 'cat_id' => is_numeric($cat_id) && $cat_id > 0 ? $cat_id : false, 'section_id' => $section_id));
return $this->render('modules', 'directories');
}
示例7: saveFeed
function saveFeed($filename = "", $view)
{
if (Sanitize::getString($this->params, 'action') != 'xml') {
return false;
}
$type = '.' . Sanitize::getString($this->params, 'type', 'rss2');
$App =& App::getInstance();
if (!isset($App->jreviewsPaths['Theme'][$this->c->viewTheme][$this->layout][$view . $type . '.thtml']) && !isset($App->jreviewsPaths['Theme']['default'][$this->layout][$view . $type . '.thtml'])) {
return false;
}
$this->c->autoLayout = false;
$this->c->autoRender = false;
$rss = array('title' => $this->c->Config->rss_title, 'link' => WWW_ROOT, 'description' => $this->c->Config->rss_description, 'image_url' => WWW_ROOT . "images/stories/" . $this->c->Config->rss_image, 'image_link' => WWW_ROOT);
$this->c->set(array('encoding' => $this->encoding, 'rss' => $rss));
$feedFile = fopen($filename, "w+");
if ($feedFile) {
$feed = $this->c->render($this->layout, $view . $type);
fputs($feedFile, $feed);
fclose($feedFile);
echo $feed;
die;
} else {
echo "<br /><b>Error creating feed file, please check write permissions.</b><br />";
die;
}
}
示例8: index
function index($params)
{
$this->action = 'directory';
// Trigger assets helper method
if ($this->_user->id === 0) {
$this->cacheAction = Configure::read('Cache.expires');
}
$page = array('title' => '', 'show_title' => 0);
$conditions = array();
$order = array();
if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) {
$menuParams = $this->Menu->getMenuParams($menu_id);
$page['title'] = Sanitize::getString($menuParams, 'title');
$page['show_title'] = Sanitize::getString($menuParams, 'dirtitle', 0);
}
$override_keys = array('dir_show_alphaindex', 'dir_cat_images', 'dir_columns', 'dir_cat_num_entries', 'dir_category_hide_empty', 'dir_category_levels', 'dir_cat_format');
if (Sanitize::getBool($menuParams, 'dir_overrides')) {
$overrides = array_intersect_key($menuParams, array_flip($override_keys));
$this->Config->override($overrides);
}
if ($this->cmsVersion == CMS_JOOMLA15) {
$directories = $this->Directory->getTree(Sanitize::getString($this->params, 'dir'));
} else {
$directories = $this->Category->findTree(array('level' => $this->Config->dir_cat_format === 0 ? 2 : $this->Config->dir_category_levels, 'menu_id' => true, 'dir_id' => Sanitize::getString($this->params, 'dir'), 'pad_char' => ''));
}
$this->set(array('page' => $page, 'directories' => $directories));
return $this->render('directories', 'directory');
}
示例9: _addOption
function _addOption()
{
$this->autoRender = false;
$this->autoLayout = false;
$response = array();
$option = $this->data['FieldOption']['text'] = Sanitize::getString($this->data, 'text');
$value = $this->data['FieldOption']['value'] = Sanitize::stripAll($this->data, 'text');
$fieldid = $this->data['FieldOption']['fieldid'] = Sanitize::getInt($this->data, 'field_id');
$fieldName = Sanitize::getString($this->data, 'name');
// Begin validation
if ($value == '') {
$validation = __t("The field is empty.", true);
$response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\"> " . $validation . "</span>');";
return $this->ajaxResponse($response);
}
// Save
$result = $this->FieldOption->save($this->data);
switch ($result) {
case 'success':
// Begin update display
$option = $this->data['FieldOption']['text'];
$value = $this->data['FieldOption']['value'];
$response = "\n jQuery('#{$fieldName}').addOption('{$value}','" . addslashes($option) . "');\n jQuery('#jr_fieldOption{$fieldid}').val(''); \n jQuery('#submitButton{$fieldid}').removeAttr('disabled');\n ";
return $this->ajaxResponse($response);
case 'duplicate':
$validation = sprintf(__t("%s already exists", true), $value);
break;
case 'db_error':
$validation = s2Messages::submitErrorGeneric();
break;
}
$response[] = "jQuery('#{$fieldName}').selectOptions('" . addslashes($option) . "');";
$response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\"> " . $validation . "</span>');";
return $this->ajaxResponse($response);
}
示例10: index
function index($params)
{
/* if($this->_user->id === 0)
{
$this->cacheAction = Configure::read('Cache.expires');
}*/
$this->action = 'directory';
// Set view file
# Read module params
$dir_id = isset($this->params['module']) ? cleanIntegerCommaList(Sanitize::getString($this->params['module'], 'dir_ids')) : '';
$conditions = array();
$order = array();
$cat_id = '';
$section_id = '';
if ($this->cmsVersion == CMS_JOOMLA15) {
$directories = $this->Directory->getTree($dir_id, true);
} else {
$directories = $this->Category->findTree(array('level' => $this->Config->dir_category_levels, 'menu_id' => true, 'dir_id' => $dir_id, 'pad_char' => ''));
}
if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) {
$menuParams = $this->Menu->getMenuParams($menu_id);
}
# Category auto detect
$ids = CommonController::_discoverIDs($this);
extract($ids);
if ($this->cmsVersion == CMS_JOOMLA15 && ($cat_id != '' && $section_id == '')) {
$cat_id = cleanIntegerCommaList($cat_id);
$sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")";
$this->_db->setQuery($sql);
$section_id = $this->_db->loadResult();
}
$this->set(array('directories' => $directories, 'dir_id' => $dir_id, 'cat_id' => is_numeric($cat_id) && $cat_id > 0 ? $cat_id : false, 'section_id' => $section_id));
return $this->render('modules', 'directories');
}
示例11: beforeFilter
function beforeFilter()
{
parent::beforeFilter();
$this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix');
# Set Theme
$this->viewTheme = $this->Config->template;
$this->viewImages = S2Paths::get('jreviews', 'S2_THEMES_URL') . $this->viewTheme . _DS . 'theme_images' . _DS;
}
示例12: index
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;
}
}
示例13: _loadValues
function _loadValues()
{
$field_id = Sanitize::getString($this->data, 'field_id');
$valueq = Sanitize::getString($this->data, 'value');
if ($field_id != '') {
$field_options = $this->FieldOption->getControlList($field_id, $valueq);
return json_encode($field_options);
}
}
示例14: reviews
function reviews()
{
$access = $this->cmsVersion == CMS_JOOMLA15 ? $this->Access->getAccessId() : $this->Access->getAccessLevels();
$feed_filename = PATH_ROOT . 'cache' . DS . 'jreviewsfeed_' . md5($access . $this->here) . '.xml';
$this->Feeds->useCached($feed_filename, 'reviews');
$extension = Sanitize::getString($this->params, 'extension', 'com_content');
$cat_id = Sanitize::getInt($this->params, 'cat');
$section_id = Sanitize::getInt($this->params, 'section');
$dir_id = Sanitize::getInt($this->params, 'dir');
$listing_id = Sanitize::getInt($this->params, 'id');
$this->encoding = cmsFramework::getCharset();
$feedPage = null;
$this->EverywhereAfterFind = true;
// Triggers the afterFind in the Observer Model
$this->limit = $this->Config->rss_limit;
$rss = array('title' => $this->Config->rss_title, 'link' => WWW_ROOT, 'description' => $this->Config->rss_description, 'image_url' => WWW_ROOT . "images/stories/" . $this->Config->rss_image, 'image_link' => WWW_ROOT);
$queryData = array('conditions' => array('Review.published = 1', "Review.mode = '{$extension}'"), 'fields' => array('Review.mode AS `Review.extension`'), 'limit' => $this->limit, 'order' => array('Review.created DESC'));
if ($extension == 'com_content') {
$queryData['conditions'][] = 'Listing.state = 1';
$queryData['conditions'][] = '( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )';
$queryData['conditions'][] = '( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )';
# Shows only links users can access
if ($this->cmsVersion == CMS_JOOMLA15) {
$access_id = $this->Access->getAccessId();
$queryData['conditions'][] = 'Listing.access <= ' . $access_id;
$queryData['conditions'][] = 'Category.access <= ' . $access_id;
} else {
$cat_id > 0 and $cat_id = array_keys($this->Category->getChildren($cat_id));
$access_id = $this->Access->getAccessLevels();
$queryData['conditions'][] = 'Listing.access IN ( ' . $access_id . ')';
$queryData['conditions'][] = 'Category.access IN ( ' . $access_id . ')';
}
}
if (!empty($cat_id) && $extension == 'com_content') {
// Category feeds only supported for core content
$queryData['conditions'][] = 'JreviewsCategory.id IN (' . $this->quote($cat_id) . ')';
$feedPage = 'category';
} elseif ($section_id > 0 && $extension == 'com_content') {
$queryData['conditions'][] = 'Listing.sectionid= ' . $section_id;
$feedPage = 'section';
} elseif ($dir_id > 0 && $extension == 'com_content') {
$queryData['conditions'][] = 'JreviewsCategory.dirid= ' . $dir_id;
$feedPage = 'directory';
} elseif ($extension != 'com_content') {
unset($this->Review->joins['listings'], $this->Review->joins['jreviews_categories'], $this->Review->joins['listings']);
$feedPage = 'everywhere';
}
if ($listing_id > 0) {
$queryData['conditions'][] = 'Review.pid = ' . $listing_id;
$feedPage = 'listing';
}
# Don't run it here because it's run in the Everywhere Observer Component
$this->Review->runProcessRatings = false;
$reviews = $this->Review->findAll($queryData);
$this->set(array('feedPage' => $feedPage, 'encoding' => $this->encoding, 'rss' => $rss, 'reviews' => $reviews));
return $this->Feeds->saveFeed($feed_filename, 'reviews');
}
示例15: startup
function startup(&$controller)
{
if (!isset($controller->Config) || $controller->ajaxRequest || Sanitize::getString($controller->params, 'action') == 'xml') {
return;
}
$this->c =& $controller;
$this->cacheCleaner();
$this->rebuildRankTable();
}