本文整理汇总了PHP中cmsFramework::locale方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsFramework::locale方法的具体用法?PHP cmsFramework::locale怎么用?PHP cmsFramework::locale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsFramework
的用法示例。
在下文中一共展示了cmsFramework::locale方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onDisplay
function onDisplay(&$field, $showImage = true, $value = false, $return = false)
{
if (empty($field)) {
return null;
}
$values = array();
$option = $value ? 'value' : 'text';
foreach ($field[$option] as $key => $text) {
switch ($field['type']) {
case 'banner':
$text = '{FIELDTEXT}';
$field['properties']['output_format'] = Sanitize::getString($field, 'description');
$field['description'] == '';
break;
case 'date':
$format = Sanitize::getString($field['properties'], 'date_format');
$text = $this->Time->nice($text, $format, 0);
break;
case 'integer':
$text = Sanitize::getInt($field['properties'], 'curr_format') ? number_format($text, 0, __l('DECIMAL_SEPARATOR', true), __l('THOUSANDS_SEPARATOR', true)) : $text;
break;
case 'decimal':
$text = Sanitize::getInt($field['properties'], 'curr_format') ? number_format($text, 2, __l('DECIMAL_SEPARATOR', true), __l('THOUSANDS_SEPARATOR', true)) : round($text, 2);
break;
case 'email':
break;
case 'website':
$text = S2ampReplace($text);
!strstr($text, '://') and $text = 'http://' . $text;
break;
case 'code':
$text = stripslashes($text);
break;
case 'textarea':
case 'text':
if (!Sanitize::getBool($field['properties'], 'allow_html')) {
$text = nl2br($text);
}
break;
case 'selectmultiple':
case 'checkboxes':
case 'select':
case 'radiobuttons':
$imgSrc = '';
if ($showImage && isset($field['image'][$key]) && $field['image'][$key] != '') {
if ($imgSrc = $this->locateThemeFile('theme_images', cmsFramework::locale() . '.' . $field['image'][$key], '', true)) {
$imgSrc = pathToUrl($imgSrc, true);
} elseif ($imgSrc = $this->locateThemeFile('theme_images', $field['image'][$key], '', true)) {
$imgSrc = pathToUrl($imgSrc, true);
}
if ($imgSrc != '') {
$text = '<img src="' . $imgSrc . '" title="' . $text . '" alt="' . $text . '" border="0" />';
}
}
break;
default:
$text = stripslashes($text);
break;
}
$values[] = $text;
$this->output[] = $text;
}
if ($return) {
return $values;
}
}
示例2: array
/**
* Return a static instance of the I18n class
*
* @return object I18n
* @access public
*/
function &getInstance()
{
static $instance = array();
if (!$instance) {
$instance[0] = new I18n();
$instance[0]->l10n = new L10n();
$language = low(cmsFramework::locale());
Configure::write('Config.language', $language);
}
return $instance[0];
}
示例3: send
function send($assets, $inline = false)
{
# Load javascript libraries
$findjQuery = false;
$this->Html->app = $this->app;
unset($this->viewVars);
/**
* Send cachable scripts to the head tag from controllers and components by adding it to the head array
*/
if (!empty($this->assets['head-top'])) {
foreach ($this->assets['head-top'] as $head) {
cmsFramework::addScript($head);
}
}
// Incorporate controller set assets before sending
if (!empty($this->assets['js'])) {
$assets['js'] = array_merge($assets['js'], $this->assets['js']);
}
if (!empty($this->assets['css'])) {
$assets['css'] = array_merge($assets['css'], $this->assets['css']);
}
$assets['css'][] = 'custom_styles';
cmsFramework::isRTL() and $assets['css'][] = 'rtl';
# Load CSS stylesheets
if (isset($assets['css']) && !empty($assets['css'])) {
$findjQueryUI = array_search('jq.ui.core', $assets['css']);
if ($findjQueryUI !== false) {
if (defined('J_JQUERYUI_LOADED')) {
unset($assets['css'][array_search('jq.ui.core', $assets['css'])]);
} else {
define('J_JQUERYUI_LOADED', 1);
}
}
$this->Html->css(arrayFilter($assets['css'], $this->Libraries->css()), $inline);
}
// For CB
// Check is done against constants defined in those applications
if (isset($assets['js']) && !empty($assets['js'])) {
$findjQuery = array_search('jquery', $assets['js']);
$findjQueryUI = array_search('jq.ui.core', $assets['js']);
if ($findjQuery !== false) {
if (defined('J_JQUERY_LOADED') || JFactory::getApplication()->get('jquery')) {
unset($assets['js'][$findjQuery]);
} else {
define('J_JQUERY_LOADED', 1);
// JFactory::getApplication()->set('jquery', true); This was for Warp, but it loads too late. jQuery must be manually disabled in the configuration
// define( 'C_ASSET_JQUERY', 1 );
}
}
if ($findjQueryUI != false) {
$locale = cmsFramework::locale();
$assets['js'][] = 'jquery/i18n/jquery.ui.datepicker-' . $locale;
}
}
if (isset($assets['js']) && !empty($assets['js'])) {
$this->Html->js(arrayFilter($assets['js'], $this->Libraries->js()), $inline);
}
# Set jQuery defaults
if ($findjQuery && isset($assets['js']['jreviews'])) {
?>
<script type="text/javascript">
/* <![CDATA[ */
jreviews.ajax_init();
/* ]]> */
</script>
<?php
}
if (isset($this->Config) && Sanitize::getBool($this->Config, 'ie6pngfix')) {
$App =& App::getInstance($this->app);
$AppPaths = $App->{$this->app . 'Paths'};
$jsUrl = isset($AppPaths['Javascript']['jquery/jquery.pngfix.pack.js']) ? $AppPaths['Javascript']['jquery/jquery.pngfix.pack.js'] : false;
if ($jsUrl) {
cmsFramework::addScript('<!--[if lte IE 6]><script type="text/javascript" src="' . $jsUrl . '"></script><script type="text/javascript">jQuery(document).ready(function(){jQuery(document).pngFix();});</script><![endif]-->');
}
unset($App, $AppPaths);
}
/**
* Send cachable scripts to the head tag from controllers and components by adding it to the head array
*/
if (!empty($this->assets['head'])) {
foreach ($this->assets['head'] as $head) {
cmsFramework::addScript($head);
}
}
}
示例4: __construct
function __construct()
{
parent::__construct();
# Check for cached version
$cache_file = 'jreviews_menu_' . cmsFramework::locale() . '_' . md5(cmsFramework::getConfig('secret'));
if ($cache = S2Cache::read($cache_file)) {
$this->___menu_data = $cache['___menu_data'];
return;
}
$menuList = array();
switch ($this->cmsVersion) {
case CMS_JOOMLA15:
$select = "\n SELECT \n id,\n name,\n link AS menu_type,\n link,\n componentid,\n params,\n access,\n published\n ";
break;
case CMS_JOOMLA16:
$select = "\n SELECT \n id, \n title AS name,\n link AS menu_type,\n link,\n component_id AS componentid,\n params,\n access,\n published\n ";
break;
}
// Get all com_content category/section menus and JReviews menus
$sql = $select . "\n FROM #__menu\n WHERE published = 1\n ORDER BY link DESC\n ";
$this->_db->setQuery($sql);
$menuList = $this->_db->loadObjectList();
// Get itemid for each menu link and store it
if (!empty($menuList)) {
foreach ($menuList as $menu) {
$params = stringToArray($menu->params);
$m_name = Sanitize::getVar($params, 'sef_name') != '' ? Sanitize::getVar($params, 'sef_name') : $menu->name;
function_exists("sefEncode") and $m_name = sefEncode($m_name);
$m_action = Sanitize::getVar($params, 'action');
$m_dir_id = str_replace(",", "-", Sanitize::getVar($params, 'dirid'));
$m_cat_id = str_replace(",", "-", Sanitize::getVar($params, 'catid'));
$m_section_id = str_replace(",", "-", Sanitize::getVar($params, 'sectionid'));
$m_criteria_id = str_replace(",", "-", Sanitize::getVar($params, 'criteriaid'));
// Create a variable to get Menu Name from Itemid
$this->set('jr_itemid_' . $menu->id, $m_name);
$this->set('jr_menu_' . $m_name, $menu->id);
if (strpos($menu->menu_type, 'option=com_content&view=section&id=') || strpos($menu->menu_type, 'option=com_content&view=section&layout=blog&id=')) {
$menu->componentid = end(explode('id=', $menu->menu_type));
$menu->menu_type = 'content_section';
} elseif (strpos($menu->menu_type, 'option=com_content&view=category&id=') || strpos($menu->menu_type, 'option=com_content&view=category&layout=blog&id=')) {
$menu->componentid = end(explode('id=', $menu->menu_type));
$menu->menu_type = 'content_category';
} elseif (strpos($menu->menu_type, 'option=com_content&view=article&id=') || strpos($menu->menu_type, 'option=com_content&task=view&id=')) {
$menu->componentid = end(explode('id=', $menu->menu_type));
$menu->menu_type = 'content_item_link';
}
switch ($menu->menu_type) {
case 'content_section':
case 'content_blog_section':
if ($menu->componentid) {
// Only one section id
$this->set('core_section_menu_id_' . $menu->componentid, $menu->id);
} else {
$section_ids = explode(",", Sanitize::getVar($params, 'sectionid'));
$this->set('jr_manyIds_' . $menu->id, 1);
foreach ($section_ids as $section_id) {
$this->set('core_section_menu_id_' . $section_id, $menu->id);
}
}
break;
case 'content_category':
case 'content_blog_category':
if ($menu->componentid) {
// Only one category id
$this->set('core_category_menu_id_' . $menu->componentid, $menu->id);
} else {
$cat_ids = explode(",", Sanitize::getVar($params, 'categoryid'));
$this->set('jr_manyIds_' . $menu->id, 1);
foreach ($cat_ids as $cat_id) {
$this->set('core_category_menu_id_' . $cat_id, $menu->id);
}
}
break;
case 'content_item_link':
$this->set('core_content_menu_id_' . $menu->componentid, $menu->id);
break;
default:
if ($menu->componentid > 0 && strstr($menu->link, 'index.php?option=' . S2Paths::get('jreviews', 'S2_CMSCOMP'))) {
// It's a JReviews menu
$access = $this->cmsVersion == CMS_JOOMLA15 ? 0 : 1;
// Get a JReviews menu with public access to use in ajax requests
if ($menu->access == $access && $menu->published == 1) {
$this->set('jreviews_public', $menu->id);
}
$this->set('jr_menu_action_' . $m_dir_id, $m_action);
$this->set('menu_params_' . $menu->id, $params);
switch ($m_action) {
case '0':
// Directory menu
$this->set('jr_directory_menu_id_' . $m_dir_id, $menu->id);
break;
case '1':
// Section menu
$this->set('jr_section_menu_id_' . $m_section_id, $menu->id);
break;
case '2':
// Category menu
$this->set('jr_category_menu_id_' . $m_cat_id, $menu->id);
break;
case '10':
//.........这里部分代码省略.........
示例5: getUrlLanguageCode
/**
* Get url language code
*/
function getUrlLanguageCode()
{
if (class_exists('JLanguageHelper')) {
$lang = JLanguageHelper::getLanguages('lang_code');
return isset($lang[cmsFramework::locale()]) ? $lang[cmsFramework::locale()]->sef : '';
}
}
示例6: getParentCatIds
function getParentCatIds($cat_id)
{
# Check for cached version
$cache_file = 'jreviews_menu_cat_' . cmsFramework::locale() . '_' . cmsFramework::getCustomToken($cat_id);
if (Configure::read('Cache.query') && ($cache = S2Cache::read($cache_file))) {
return $cache['___menu_cat'];
}
$query = "\n (\n SELECT \n ParentCategory.id AS cat_id,\n ParentCategory.lft AS lft\n FROM \n #__categories AS Category, \n #__categories AS ParentCategory\n INNER JOIN\n #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = ParentCategory.id\n WHERE \n (\n ParentCategory.id = " . (int) $cat_id . " AND ParentCategory.published = 1\n )\n )\n UNION\n (\n SELECT \n ParentCategory.id AS cat_id,\n ParentCategory.lft AS lft\n FROM\n #__categories AS Category,\n #__categories AS ParentCategory\n INNER JOIN\n #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = ParentCategory.id\n WHERE\n ( \n Category.published = 1\n AND Category.lft BETWEEN ParentCategory.lft AND ParentCategory.rgt\n AND Category.id = " . (int) $cat_id . "\n AND ParentCategory.parent_id > 0\n )\n ORDER BY \n Category.lft\n )\n ";
$rows = $this->query($query, 'loadObjectList');
$last = array_shift($rows);
array_push($rows, $last);
Configure::read('Cache.query') and S2Cache::write($cache_file, array('___menu_cat' => $rows));
return $rows;
}
示例7: startup
function startup(&$controller)
{
$this->c =& $controller;
// 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->search_autocomplete = Sanitize::getBool($controller->Config, 'geomaps.search_autocomplete', 1);
$this->google_api_url = $this->google_url . "/maps/api/js?v=3&async=2&sensor=false&key={$this->google_api_key}";
$this->google_api_url .= '&language=' . substr(cmsFramework::locale(), 0, 2);
if ($this->search_autocomplete) {
$this->google_api_url .= '&libraries=places';
}
$controller->set('google_api_url', $this->google_api_url);
if (!$this->runPlugin($controller)) {
return false;
}
if (!Configure::read('Geomaps.header')) {
Configure::write('Geomaps.header', true);
$language_js = '<script type="text/javascript">
/* <![CDATA[ */
var GeomapsGoogleApi = "' . $this->google_api_url . '",
GeomapsOnload = new Array(),
GeomapsLanguage = {
submit : "' . __t("Submit", true) . '",
streeview_unavailable : "' . __t("Street view not available for this address.", true, true) . '",
cannot_geocode : "' . __t("Address could not be geocoded. Modify the address and click on the Geocode Address button to try again.", true) . '",
drag_marker : "' . __t("Drag the marker to fine-tune the geographic location on the map.", true) . '",
directions_bad_address : "' . __t("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.", true) . '",
directions_request_error : "' . __t("The was an error processing the request.", true) . '",
enter_location : "' . __t("Enter a location", true) . '"
};
/* ]]> */
</script>';
if (defined('MVC_FRAMEWORK_ADMIN') && !$controller->ajaxRequest) {
cmsFramework::addScript($language_js);
} else {
$controller->assets['head-top'][] = $language_js;
}
}
// 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;
}
$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
*/
$jsGlobals = 'var geoSearchAutocomplete = "' . $this->search_autocomplete . '";';
$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}';";
}
switch ($controller->name) {
case 'com_content':
$this->published = true;
$controller->Listing->cacheCallbacks[] = 'plgAfterAfterFind';
//.........这里部分代码省略.........
示例8: getFields
/**
* Auxiliary function - used for custom coding
* Creates an array of fields with field names as array keys and attributes and options using an array of field names as input
* Used in in geomaps module
*/
function getFields($names, $location = 'listing', $optionValues = null)
{
if (empty($names) || count($names) == 1 & $names[0] == 'category') {
return array();
}
$rows = false;
# Check for cached version
$cache_prefix = 'field_model_names';
$cache_key = func_get_args();
$cache_key['locale'] = cmsFramework::locale();
if (isset($cache_key[2])) {
unset($cache_key[2]);
}
// $entry not required to cache the results
if ($cache = S2cacheRead($cache_prefix, $cache_key)) {
$rows = $cache;
}
if (false == $rows || $rows == '') {
$location = $location == 'listing' ? 'content' : $location;
//get field attributes only, no values
$sql = "\n SELECT \n Field.fieldid AS `Field.id`, Field.name AS `Field.name`, Field.title AS `Field.title`,\n Field.type AS `Field.type`, Field.options AS `Field.params`, Field.required AS `Field.required`, \n Field.access_view AS `Field.access_view`, `Group`.groupid AS `Group.group_id`, `Group`.title AS `Group.title`\n FROM \n #__jreviews_fields AS Field\n INNER JOIN \n #__jreviews_groups AS `Group` ON (`Group`.groupid = Field.groupid AND `Group`.groupid AND `Group`.type = '{$location}' ) \n WHERE \n Field.name IN (" . $this->Quote($names) . ") AND Field.location = " . $this->Quote($location);
$this->_db->setQuery($sql);
$rows = $this->_db->loadObjectList();
# Send to cache
S2cacheWrite($cache_prefix, $cache_key, $rows);
}
if (!$rows || empty($rows)) {
return;
}
//extract field ids from array
$this->field_ids = $multi_field_ids = $this->_extractFieldIds($rows, array('select', 'selectmultiple', 'radiobuttons', 'checkboxes'));
//get the field options for multiple choice fields
$this->_getFieldOptions($optionValues);
// Reformat array and add field options to each multiple choice field
foreach ($rows as $row) {
$row = (array) $row;
//FieldGroups array
$fields[$row['Field.name']]['field_id'] = $row['Field.id'];
$fields[$row['Field.name']]['name'] = $row['Field.name'];
$fields[$row['Field.name']]['type'] = $row['Field.type'];
$fields[$row['Field.name']]['title'] = $row['Field.title'];
$fields[$row['Field.name']]['required'] = $row['Field.required'];
$fields[$row['Field.name']]['properties']['access_view'] = $row['Field.access_view'];
$params = explode("\n", $row['Field.params']);
foreach ($params as $param) {
$parts = explode("=", $param);
// Need to use this approach because click2search field has equal signs in the value of the property
$key = array_shift($parts);
$value = implode('=', $parts);
$fields[$row['Field.name']]['properties'][$key] = $value;
}
if (isset($this->field_options_alpha[$row['Field.id']])) {
$ordering = isset($fields[$row['Field.name']]['Fields'][$row['Field.name']]['properties']['option_ordering']) && $fields[$row['Group.title']]['Fields'][$row['Field.name']]['properties']['option_ordering'] ? 'alpha' : 'ordering';
$method = 'field_options_' . $ordering;
$methodList = 'field_optionsList_' . $ordering;
$fields[$row['Field.name']]['options'] = $this->{$method}[$row['Field.id']];
$fields[$row['Field.name']]['optionList'] = $this->{$methodList}[$row['Field.id']];
}
}
return $fields;
}