本文整理汇总了PHP中cmsFramework::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsFramework::getConfig方法的具体用法?PHP cmsFramework::getConfig怎么用?PHP cmsFramework::getConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsFramework
的用法示例。
在下文中一共展示了cmsFramework::getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
parent::__construct();
Configure::write('Community.profileUrl', $this->profileUrl);
if (file_exists(PATH_ROOT . 'components' . _DS . 'com_community' . _DS . 'community.php')) {
$this->community = true;
$Menu = ClassRegistry::getClass('MenuModel');
$this->menu_id = $Menu->getComponentMenuId('com_community&view=frontpage');
if (!$this->menu_id) {
$this->menu_id = $Menu->getComponentMenuId('com_community&view=profile');
}
if (!$this->menu_id) {
$this->menu_id = $Menu->getComponentMenuId('com_community');
}
// For JomSocial <= 2.1
if (!file_exists(PATH_ROOT . 'components/com_community/assets/user_thumb.png')) {
$this->default_thumb = 'components/com_community/assets/default_thumb.jpg';
}
$cache_key = 'jomsocial_config_' . md5(cmsFramework::getConfig('secret'));
$JSConfig = S2Cache::read($cache_key);
if (false == $JSConfig) {
// Read the JomSocial configuration to determine the storage location for avatars
$JSConfig = json_decode($this->query("SELECT params FROM #__community_config WHERE name = 'config'", 'loadResult'), true);
$JSConfigForJReviews = array('user_avatar_storage' => $JSConfig['user_avatar_storage'], 'storages3bucket' => $JSConfig['storages3bucket']);
S2Cache::write($cache_key, $JSConfigForJReviews);
}
$this->avatar_storage = $JSConfig['user_avatar_storage'];
$this->s3_bucket = $JSConfig['storages3bucket'];
Configure::write('Community.register_url', sprintf($this->registerUrl, $this->menu_id));
}
}
示例2: array
function &getInstance()
{
static $instance = array();
if (!isset($instance[0]) || !$instance[0]) {
$instance[0] = new sef_jreviews();
require dirname(__FILE__) . DS . 'jreviews' . DS . 'framework.php';
App::import('Model', 'Menu', 'jreviews');
$instance[0]->__Menu = ClassRegistry::getClass('MenuModel');
// Read url param style setting from JReviews config cache file
$cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
$Config = S2Cache::read($cache_file);
$instance[0]->joomla_style_params = is_object($Config) and isset($Config->url_param_joomla) ? $Config->url_param_joomla : false;
$version = new JVersion();
$instance[0]->cmsVersion = $version->RELEASE;
}
return $instance[0];
}
示例3: onProfileDisplay
function onProfileDisplay()
{
if (!file_exists($this->_path . DS . 'admin.jreviews.php')) {
return JText::_('jReviews is not installed. Please contact site administrator.');
} else {
$user = CFactory::getActiveProfile();
$userId = $user->id;
$cacheSetting = $this->params->get('cache', 1) ? JApplication::getCfg('caching') : 0;
# Load CSS stylesheets -- done here because when cache is on css is not loaded
if ($cacheSetting) {
# MVC initalization script
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
require 'components' . DS . 'com_jreviews' . DS . 'jreviews' . DS . 'framework.php';
$cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
$Config =& S2Cache::read($cache_file);
if (!is_object($Config)) {
//Create config file
$eParams['data']['controller'] = 'common';
$eParams['data']['action'] = 'index';
$Dispatcher = new S2Dispatcher('jreviews', false, true);
$Dispatcher->dispatch($eParams);
$Config =& S2Cache::read($cache_file);
unset($Dispatcher);
}
App::import('Helper', 'html');
$Html =& RegisterClass::getInstance('HtmlHelper');
$Html->viewTheme = $Config->template;
$Html->app = 'jreviews';
$Html->startup();
App::import('Helper', 'libraries', 'jreviews');
$Libraries =& RegisterClass::getInstance('LibrariesHelper');
$Html->css(array('theme', 'plugins', 'paginator'));
$Html->js(array('jreviews', 'jquery' => 'jquery', 'jq.scrollable'), $Libraries->js());
}
$cache =& JFactory::getCache('plgCommunityJreviews_myfavorites');
$cache->setCaching($cacheSetting);
$callback = array('plgCommunityJreviews_myfavorites', '_getPage');
$contents = $cache->call($callback, $userId, $this->params, $cacheSetting);
return $contents;
}
}
示例4: plgAfterSave
function plgAfterSave(&$model)
{
if (!isset($model->data['Email']) || !Sanitize::getInt($model->data['Email'], 'send')) {
return false;
}
# Read cms mail config settings
$configSendmailPath = cmsFramework::getConfig('sendmail');
$configSmtpAuth = cmsFramework::getConfig('smtpauth');
$configSmtpUser = cmsFramework::getConfig('smtpuser');
$configSmtpPass = cmsFramework::getConfig('smtppass');
$configSmtpHost = cmsFramework::getConfig('smtphost');
$configSmtpSecure = cmsFramework::getConfig('smtpsecure');
$configSmtpPort = cmsFramework::getConfig('smtpport');
$configMailFrom = cmsFramework::getConfig('mailfrom');
$configFromName = cmsFramework::getConfig('fromname');
$configMailer = cmsFramework::getConfig('mailer');
if (!class_exists('PHPMailer')) {
App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer');
}
$mail = new PHPMailer();
$mail->CharSet = cmsFramework::getCharset();
$mail->SetLanguage('en', S2_VENDORS . 'PHPMailer' . DS . 'language' . DS);
$mail->Mailer = $configMailer;
// Mailer used mail,sendmail,smtp
switch ($configMailer) {
case 'smtp':
$mail->Host = $configSmtpHost;
$mail->SMTPAuth = $configSmtpAuth;
$mail->Username = $configSmtpUser;
$mail->Password = $configSmtpPass;
$mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : '';
$mail->Port = $configSmtpPort;
break;
case 'sendmail':
$mail->Sendmail = $configSendmailPath;
break;
default:
break;
}
$mail->isHTML(true);
$mail->From = $configMailFrom;
$mail->FromName = $configFromName;
$mail->AddReplyTo($configMailFrom, $configFromName);
// $model->data[$this->notifyModel->name]['key'] = $value;
$model->data['Email']['body'] = urldecode($model->data['__raw']['Email']['body']);
// Send html email
# In this observer model we just use the existing data to send the email notification
switch ($this->notifyModel->name) {
// Notification for claims moderation
case 'Claim':
if ($model->data['Email']['subject'] != '') {
$subject = $model->data['Email']['subject'];
$subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
$subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
} else {
switch ($model->data['Claim']['approved']) {
case 1:
$subject = __a("Your claim has been approved", true);
break;
case -1:
$subject = __a("Your claim has been rejected", true);
break;
case 0:
$subject = __a("Your claim has been reviewed, but still pending moderation", true);
break;
}
}
// Get permalink
$listing_id = $model->data['Listing']['id'];
$listing = $this->controller->Listing->findRow(array('conditions' => 'Listing.id = ' . $listing_id), array('afterFind'));
$permalink = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
$message = $model->data['Email']['body'];
$message = str_ireplace('{name}', $model->data['Email']['name'], $message);
$message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
$message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
if ($message != '') {
$mail->Subject = $subject;
// Convert line breaks to br tags if html code not found on the message body
$mail->Body = nl2br($message);
$mail->AddAddress($model->data['Email']['email']);
if (!$mail->Send()) {
appLogMessage(array("Admin claim moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
}
}
break;
# Notification for discussion post moderation
# Notification for discussion post moderation
case 'Discussion':
if ($model->data['Email']['subject'] != '') {
$subject = $model->data['Email']['subject'];
$subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
$subject = str_ireplace('{review_title}', $model->data['Email']['review_title'], $subject);
} else {
switch ($model->data['Discussion']['approved']) {
case 1:
$subject = __a("Your comment has been approved", true);
break;
case -1:
$subject = __a("Your comment has been rejected", true);
break;
//.........这里部分代码省略.........
示例5: unset
S2Paths::set($s2_app, 'S2_JS_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_OVERRIDES') . 'js' . DS);
S2Paths::set($s2_app, 'S2_VIEWS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_APP_URL_OVERRIDES') . 'views' . _DS);
S2Paths::set($s2_app, 'S2_THEMES_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'themes' . _DS);
S2Paths::set($s2_app, 'S2_IMAGES_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'images' . _DS);
S2Paths::set($s2_app, 'S2_CSS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'css' . _DS);
S2Paths::set($s2_app, 'S2_JS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'js' . _DS);
S2Paths::set($s2_app, 'S2_ADMIN_VIEWS_OVERRIDES', S2Paths::get($s2_app, 'S2_APP_OVERRIDES') . 'views' . DS . 'admin' . DS);
S2Paths::set($s2_app, 'S2_ADMIN_HELPERS_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_OVERRIDES') . 'helpers' . DS);
S2Paths::set($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'admin' . _DS);
S2Paths::set($s2_app, 'S2_CSS_ADMIN_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES') . 'css' . _DS);
S2Paths::set($s2_app, 'S2_JS_ADMIN_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES') . 'js' . _DS);
# Set default theme
if (defined('MVC_FRAMEWORK_ADMIN')) {
$db = cmsFramework::getDB();
$tables = $db->getTableList();
$dbprefix = cmsFramework::getConfig('dbprefix');
if (in_array($dbprefix . 'jreviews_config', $tables)) {
$db->setQuery("SELECT value FROM #__jreviews_config WHERE id = 'fallback_theme'");
$fallback_theme = $db->loadResult();
S2Paths::set($s2_app, 'S2_FALLBACK_THEME', $fallback_theme != '' ? $fallback_theme : 'default');
}
unset($db);
}
# Create the file registry
$Configure =& Configure::getInstance($s2_app);
$s2App =& App::getInstance($s2_app);
require_once dirname(__FILE__) . DS . 'config' . DS . 'core.php';
# Set app variable in I18n class
$import = App::import('Lib', 'I18n');
if (!$import) {
$clear = clearCache('', 'core');
示例6: create_j16
function create_j16()
{
$this->name = 'categories';
$this->autoRender = true;
$sectionid = Sanitize::getInt($this->params, 'sectionid', '');
$limit = Sanitize::getInt($this->params, 'limit', cmsFramework::getConfig('list_limit'));
$limitstart = Sanitize::getInt($this->params, 'limitstart', '');
$this->set(array('sectionid' => $sectionid, 'limit' => $limit, 'limitstart' => $limitstart, 'criterias' => $this->Criteria->getSelectList(), 'directories' => $this->Directory->getSelectList(), 'review_categories' => $this->Category->getReviewCategoryIds(), 'categories' => $this->Category->getNonReviewCategories()));
}
示例7: getAjaxUri
/**
* Returns the request uri for ajax requests for each application
*
* @param string $app
* @return ajax request uri
*/
function getAjaxUri($app = 'jreviews')
{
$lang = cmsFramework::getUrlLanguageCode();
$language = Sanitize::getString($_REQUEST, 'language');
$core_sef = cmsFramework::getConfig('sef') && !function_exists('sefEncode') && !class_exists('shRouter');
$ie = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false;
$lang_segment = $ie && $core_sef && $language != '' && $lang != '';
if (defined('MVC_FRAMEWORK_ADMIN')) {
$ajaxUri = WWW_ROOT . 'administrator' . _DS . 'index.php?option=' . S2Paths::get($app, 'S2_CMSCOMP') . '&format=raw&tmpl=component';
} else {
$ajaxUri = WWW_ROOT . ($lang_segment ? $lang . _DS : '') . 'index.php?option=' . S2Paths::get($app, 'S2_CMSCOMP') . '&format=raw&tmpl=component' . ($lang != '' ? '&lang=' . $lang : '');
}
if (defined('MVC_FRAMEWORK_ADMIN')) {
return str_replace('&', '&', $ajaxUri);
}
return $ajaxUri;
}
示例8: load
function load()
{
$Model = new MyModel();
$Config = new stdClass();
$Model->_db->setQuery("SELECT id, value FROM #__jreviews_config");
$rows = $Model->_db->loadObjectList();
if ($rows) {
foreach ($rows as $row) {
$prop = $row->id;
$length = strlen($row->value) - 1;
if (substr($row->value, 0, 1) == '[' && substr($row->value, $length, 1) == ']') {
$row->value = json_decode($row->value);
} else {
$row->value = stripcslashes($row->value);
}
$Config->{$prop} = $row->value;
}
}
$Config->rss_title = @$Config->rss_title != '' ? $Config->rss_title : $Model->makeSafe(cmsFramework::getConfig('sitename'));
$Config->rss_description = @$Config->rss_description != '' ? $Config->rss_description : $Model->makeSafe(cmsFramework::getConfig('MetaDesc'));
# Get current version number
include_once PATH_ROOT . 'components' . DS . 'com_jreviews' . DS . 'jreviews.info.php';
if (isset($package_info)) {
$version = $package_info['jreviews']['version'];
$Config->version = $version;
}
return $Config;
}
示例9: store
function store($arr = null)
{
$db = cmsFramework::getDB();
if (is_null($arr)) {
$arr = get_object_vars($this);
}
while (list($prop, $val) = each($arr)) {
if ($prop != 'c') {
if (is_array($val)) {
$val = json_encode($val);
} else {
// Fixes an issue where an Array string is added to some values
$val = str_replace(',Array', '', $val);
}
$db->setQuery("\n UPDATE \n #__jreviews_config\n\t\t\t\t\tSET \n value= '" . $db->getEscaped($val) . "'\n\t\t\t\t\tWHERE \n id = '" . $db->getEscaped($prop) . "'");
$db->query();
$db->setQuery("SELECT \n count(*) \n FROM \n #__jreviews_config \n WHERE \n id = '" . $db->getEscaped($prop) . "'");
$saved = $db->loadResult();
if (!$saved) {
$db->setQuery("\n INSERT INTO\n #__jreviews_config (id, value) \n\t\t\t\t\t\tVALUES\n ('" . $db->getEscaped($prop) . "', '" . $db->getEscaped($val) . "')\n ");
if (!$db->query()) {
echo "<br/>" . $db->getErrorMsg();
exit;
}
}
}
}
if (defined('MVC_FRAMEWORK_ADMIN')) {
// Forces clear cache when config settings are modified in the administration
clearCache('', 'views');
clearCache('', '__data');
} else {
// Push updates to the cached file
$cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
$Config = $this->load();
S2Cache::write($cache_file, $Config);
}
}
示例10: _postVote
function _postVote()
{
# Check if FB integration for reviews is enabled
$facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_reviews');
if (!$facebook_integration) {
return;
}
$review_id = Sanitize::getInt($this->params, 'id');
# First check - review id
if (!$review_id) {
return;
}
# Stop form data tampering
$formToken = cmsFramework::getCustomToken($review_id);
if (!cmsFramework::isAdmin() && !$this->__validateToken($formToken)) {
return s2Messages::accessDenied();
}
$facebook = $this->_getFBClass();
$uid = $facebook->getUser();
if ($uid) {
try {
//get user id
// $user = $facebook->api('/me');
$fql = "SELECT publish_stream FROM permissions WHERE uid = " . $uid;
$param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
$fqlResult = $facebook->api($param);
if (!$fqlResult[0]['publish_stream']) {
return false;
} else {
$review = $this->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)), array());
$this->Everywhere->loadListingModel($this, $review['Review']['extension']);
$listing = $this->Listing->findRow(array('conditions' => array('Listing.' . $this->Listing->realKey . ' = ' . $review['Review']['listing_id'])), array('afterFind'));
$listing_url = $this->makeUrl($listing['Listing']['url']);
$review['Review']['comments'] = strip_tags($review['Review']['comments']);
if ($this->Config->facebook_posts_trim >= 0 && $review['Review']['comments'] != '') {
App::import('Helper', 'text', 'jreviews');
$Text = ClassRegistry::getClass('TextHelper');
$message = $this->Config->facebook_posts_trim == '' ? $review['Review']['comments'] : $Text->truncateWords($review['Review']['comments'], $this->Config->facebook_posts_trim);
$review['Review']['comments'] = $message;
}
# Publish stream permission granted so we can post on the user's wall!
# Begin building the stream $fbArray
$fbArray = array();
$fbArray['method'] = 'stream.publish';
$fbArray['message'] = sprintf($this->activities['vote helpful'], $listing['Listing']['title']);
$fbArray['attachment'] = array('name' => $listing['Listing']['title'], 'href' => $listing_url, 'description' => $review['Review']['comments']);
$fbArray['attachment']['properties'][__t("Website", true)] = array('text' => cmsFramework::getConfig('sitename'), 'href' => WWW_ROOT);
$review['Rating']['average_rating'] > 0 and $fbArray['attachment']['properties'][__t("Rating", true)] = sprintf(__t("%s stars", true), round($review['Rating']['average_rating'], 1));
isset($listing['Listing']['images'][0]) and $fbArray['attachment']['media'] = array(array('type' => 'image', 'src' => WWW_ROOT . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path'], 'href' => $listing_url));
$fbArray['attachment'] = json_encode($fbArray['attachment']);
$fbArray['action_links'] = json_encode(array(array('text' => __t("Read review", true), 'href' => $listing_url)));
$fbArray['comments_xid'] = $listing['Listing']['listing_id'];
if ($this->Config->facebook_optout) {
$fbArray['display'] = Configure::read('System.isMobile') ? 'touch' : 'popup';
return json_encode($fbArray);
}
$fb_update = $facebook->api($fbArray);
return true;
}
} catch (Exception $o) {
// Error reading permissions
return false;
}
}
return false;
}
示例11: __loadBootstrap
/**
* Loads app/config/bootstrap.php.
* If the alternative paths are set in this file
* they will be added to the paths vars.
*
* @param boolean $boot Load application bootstrap (if true)
* @return void
* @access private
*/
function __loadBootstrap($app)
{
S2Cache::config('_s2framework_core_', array('duration' => 86400, 'engine' => 'File', 'path' => S2Paths::get($app, 'S2_CACHE') . 'core'));
$fallback_theme = S2Paths::get($app, 'S2_FALLBACK_THEME', 'default');
$path_root_replace = PATH_ROOT != DS ? PATH_ROOT : '';
$cache_key = $app . '_paths_' . md5(WWW_ROOT . PATH_ROOT . cmsFramework::getConfig('secret'));
if (!($fileArray = S2Cache::read($cache_key, '_s2framework_core_'))) {
$configPath = S2Paths::get($app, 'S2_APP_CONFIG');
if (@(!(include $configPath . 'paths.php'))) {
trigger_error(sprintf(__t("Can't find application paths file. Please create %spaths.php, and make sure it is readable by PHP.", true), $configPath), E_USER_ERROR);
}
$this->basePaths = $basePaths;
$fileArray = $this->buildPaths($relativePaths);
$Folder = new Folder();
$items = array();
// Build the Theme file array
foreach ($basePaths as $basePath) {
if (false === strstr($basePath, 's2framework')) {
// Front end theme folder
$Folder->path = $basePath . $themePath;
$baseRelPath = ltrim(str_replace($path_root_replace, '', $basePath), DS);
list($dirs) = $Folder->read(true);
if (!empty($dirs)) {
foreach ($dirs as $theme) {
$tree = $Folder->tree($basePath . $themePath . DS . $theme);
if (is_array($tree) && !empty($tree)) {
if (strstr($basePath, 'com_jreviews_addons')) {
$items['Theme'][$theme]['.info']['location'] = 'addon';
} elseif (strstr($basePath, 'com_jreviews')) {
$items['Theme'][$theme]['.info']['location'] = 'jreviews';
} elseif (strstr($basePath, 'jreviews_overrides')) {
$items['Theme'][$theme]['.info']['location'] = 'overrides';
}
$themeRelPath = $baseRelPath . $themePath . DS . $theme . DS;
$items['Theme'][$theme]['.info']['path'] = $themeRelPath;
// Read theme info xml file
$infoFile = $basePath . $themePath . DS . $theme . DS . 'themeInfo.xml';
if (file_exists($infoFile)) {
$xml = simplexml_load_file($infoFile);
$items['Theme'][$theme]['.info']['name'] = Sanitize::getString($xml->settings, 'name');
$items['Theme'][$theme]['.info']['title'] = Sanitize::getString($xml->settings, 'title');
$items['Theme'][$theme]['.info']['configuration'] = Sanitize::getString($xml->settings, 'configuration', 1);
$items['Theme'][$theme]['.info']['fallback'] = Sanitize::getString($xml->settings, 'fallback', 0);
$items['Theme'][$theme]['.info']['addon'] = Sanitize::getString($xml->settings, 'addon', 0);
$items['Theme'][$theme]['.info']['mobile'] = Sanitize::getString($xml->settings, 'mobile', 0);
$items['Theme'][$theme]['.info']['description'] = Sanitize::getString($xml, 'description');
} else {
// Support for themes without xml file
$items['Theme'][$theme]['.info']['name'] = $theme;
$items['Theme'][$theme]['.info']['title'] = $theme;
$items['Theme'][$theme]['.info']['configuration'] = '1';
$items['Theme'][$theme]['.info']['fallback'] = '0';
$items['Theme'][$theme]['.info']['addon'] = $items['Theme'][$theme]['.info']['location'] == (string) 'addon' ? 1 : 0;
$items['Theme'][$theme]['.info']['mobile'] = '0';
$items['Theme'][$theme]['.info']['description'] = 'themeInfo.xml file is missing for this theme.';
}
foreach ($tree[1] as $file) {
// Get the theme name and folder to build an array
$path = strtolower(str_replace($basePath . $themePath . DS, '', $file));
if (count(explode(DS, $path)) > 2) {
# Adds file to theme folder array
extract(pathinfo($path));
$theme_folder = str_replace($theme . DS, '', $dirname);
$theme_file_path = ltrim(str_replace($path_root_replace, '', $file), DS);
$theme_folder_parts = explode(DS, $theme_folder);
$theme_folder = array_shift($theme_folder_parts);
if ($theme_folder == 'theme_images' && !empty($theme_folder_parts)) {
// Adds support for theme images in sub-folders
$basename = implode(DS, $theme_folder_parts) . DS . $basename;
} elseif (!empty($theme_folder_parts)) {
$basename = array_shift($theme_folder_parts) . DS . $basename;
}
// Exclude images from theme_css folder
if (strstr($theme_folder, 'theme_css') && $extension != 'css') {
continue;
}
$items['Theme'][$theme][$theme_folder][$basename] = $basename;
// $theme_file_path;
# Add any extra files to the default theme.
# This makes the system think files from different themes are in the default folder without forcing users to move files around
// In Component folder we use full relative path because we don't know which theme has been selected
if ($items['Theme'][$theme]['.info']['location'] == "jreviews") {
$items['Theme'][$theme][$theme_folder][$basename] = $theme_file_path;
}
// For any non-default folder, add missing files to default folder with full relative path
if ($items['Theme'][$theme]['.info']['location'] != "jreviews" && !isset($items['Theme'][$fallback_theme][$theme_folder][$basename])) {
$items['Theme'][$fallback_theme][$theme_folder][$basename] = $theme_file_path;
}
}
}
}
//.........这里部分代码省略.........
示例12: index
function index()
{
$response = array();
if (Sanitize::getString($this->params, 'task') == 'upgrade') {
// Where running the install script for upgrade we want a json object returned
$this->autoLayout = false;
$this->autoRender = false;
} else {
$this->autoLayout = true;
$this->autoRender = true;
}
$this->name = 'install';
# Create database tables
// Start db upgrade logic
$action = array();
$action['db_install'] = true;
$tables = $this->_db->getTableList();
$dbprefix = cmsFramework::getConfig('dbprefix');
$old_build = 0;
if (is_array($tables) && in_array($dbprefix . 'jreviews_categories', array_values($tables))) {
// Tables exist so we check the current build and upgrade accordingly, otherwise it's a clean install and no upgrade is necessary
$query = "SELECT value FROM #__jreviews_config WHERE id = 'version'";
$this->_db->setQuery($query);
$old_version = trim(strip_tags($this->_db->loadResult()));
if ($old_version != '') {
$version_parts = explode('.', $old_version);
$old_build = array_pop($version_parts);
}
// Get current version number
$xml = file(S2_CMS_ADMIN . 'jreviews.xml');
foreach ($xml as $xml_line) {
if (strstr($xml_line, 'version')) {
$new_version = trim(strip_tags($xml_line));
continue;
}
}
$version_parts = explode('.', $new_version);
$new_build = array_pop($version_parts);
if (Sanitize::getBool($this->params, 'sql')) {
$old_build = 0;
}
// prx($old_build . '<br/>' . $new_build) ;
if ($new_build > $old_build) {
$i = $old_build + 1;
for ($i = $old_build + 1; $i <= $new_build; $i++) {
// Run sql updates
$sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.sql';
if (file_exists($sql_file)) {
$action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix) && $action['db_install'];
}
// Run php updates
$php_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'upgrade_build' . $i . '.php';
if (file_exists($php_file)) {
include $php_file;
}
}
}
} else {
// It's a clean install so we use the whole jReviews sql file
$sql_file = S2Paths::get('jreviews', 'S2_APP') . 'upgrades' . DS . 'jreviews.sql';
$action['db_install'] = $this->__parseMysqlDump($sql_file, $dbprefix);
}
# Update component id in pre-existing jReviews menus
if (getCmsVersion() == CMS_JOOMLA16) {
$query = "\n SELECT \n extension_id AS id\n FROM \n #__extensions \n WHERE \n element = '" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "' AND type = 'component'\n ";
} else {
$query = "\n SELECT \n id \n FROM \n #__components \n WHERE \n admin_menu_link = 'option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n ";
}
$this->_db->setQuery($query);
if ($id = $this->_db->loadResult()) {
if (getCmsVersion() == CMS_JOOMLA16) {
$query = "\n UPDATE \n `#__menu` \n SET \n component_id = {$id} \n WHERE \n type IN ('component','components') \n AND \n link = 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n ";
} else {
$query = "\n UPDATE \n `#__menu` \n SET \n componentid = {$id} \n WHERE \n type IN ('component','components') \n AND \n link = 'index.php?option=" . S2Paths::get('jreviews', 'S2_CMSCOMP') . "'\n ";
}
$this->_db->setQuery($query);
$this->_db->query();
}
$result = false;
// Install jReviews plugin
$package = PATH_ROOT . 'administrator' . DS . 'components' . DS . 'com_jreviews' . DS . 'jreviews.plugin.s2';
if (getCmsVersion() == CMS_JOOMLA16) {
@mkdir(PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews');
$target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews';
} else {
$target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content';
}
$target_file = $target . DS . 'jreviews.php';
$first_pass = false;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.archive');
jimport('joomla.filesystem.path');
$adapter =& JArchive::getAdapter('zip');
$result = $adapter->extract($package, $target);
if ($result) {
$this->Config->version = $new_version;
$this->Config->store();
}
if (getCmsVersion() == CMS_JOOMLA15 && !file_exists($target_file)) {
//.........这里部分代码省略.........
示例13: getCategory
function getCategory()
{
$core = null;
$jr = null;
# Process parameters whether passed individually or as an array
$params = func_get_args();
$keys = array('cat_id', 'section_id', 'dir_id', 'listing');
if (count($params) > 1) {
// Individual parameters
while ($params) {
${array_shift($keys)} = array_shift($params);
}
} else {
extract(array_shift($params));
}
// Process article urls using Joomla core menus
if (!empty($listing)) {
$core = $this->get('core_content_menu_id_' . $listing, '');
if ($core != '') {
return $core;
}
$core = $this->cmsVersion == CMS_JOOMLA15 ? $this->get('core_category_menu_id_' . $cat_id, $this->getSection($section_id, $dir_id, $listing)) : $this->get('core_category_menu_id_' . $cat_id);
if ($core != '') {
return $core;
}
if ($this->cmsVersion == CMS_JOOMLA16) {
$parent_cat_ids = $this->get('parent_cat_ids_' . $cat_id);
if (!$parent_cat_ids) {
$parent_cat_ids = $this->getParentCatIds($cat_id);
$this->set('parent_cat_ids_' . $cat_id, $parent_cat_ids);
}
# Loop through parent categories to find the correct Itemid
foreach ($parent_cat_ids as $pcat_id) {
$tmp = $this->get('core_category_menu_id_' . $pcat_id->cat_id);
if ($tmp) {
$this->set('core_category_menu_id_' . $pcat_id->cat_id, $tmp);
$core = $tmp;
}
}
if ($core) {
return $core;
}
}
if (cmsFramework::getConfig('sef') == 1) {
// There's a problem with core sef urls having Itemids from non-core menus, so we make sure the JReviews menu ids are not used
return false;
}
}
// Process JReviews category urls using JReviews menus
if ($this->cmsVersion == CMS_JOOMLA15) {
return $this->get('jr_category_menu_id_' . $cat_id, $this->getSection($section_id, $dir_id));
}
$parent_cat_ids = $this->get('parent_cat_ids_' . $cat_id);
if (!$parent_cat_ids) {
$parent_cat_ids = $this->getParentCatIds($cat_id);
$this->set('parent_cat_ids_' . $cat_id, $parent_cat_ids);
}
# Loop through parent jr categories to find the correct Itemid
foreach ($parent_cat_ids as $pcat_id) {
$tmp = $this->get('jr_category_menu_id_' . $pcat_id->cat_id);
if ($tmp) {
$this->set('jr_category_menu_id_' . $pcat_id->cat_id, $tmp);
$jr = $tmp;
}
}
if ($jr) {
return $jr;
}
return $this->getDir($dir_id);
}
示例14: facebookOpenGraph
/**
* Facebook Open Graph implementation
*
* @param mixed $listing
* @param mixed $meta
*/
function facebookOpenGraph(&$listing, $meta)
{
// http://developers.facebook.com/docs/opengraph/
$option = Sanitize::getString($_REQUEST, 'option', '');
$view = Sanitize::getString($_REQUEST, 'view', '');
$id = Sanitize::getInt($_REQUEST, 'id');
// Make sure this is a Joomla article page
if (!($option == 'com_content' && $view == 'article' && $id)) {
return;
}
$Config = Configure::read('JreviewsSystem.Config');
if (empty($Config)) {
$cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
$Config = S2Cache::read($cache_file);
}
$facebook_xfbml = Sanitize::getBool($Config, 'facebook_opengraph') && Sanitize::getBool($Config, 'facebook_appid');
// Make sure FB is enabled and we have an FB App Id
if (!$facebook_xfbml) {
return;
}
extract($meta);
$title == '' and $title = $listing['Listing']['title'];
$description == '' and $description = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'summary'));
$image = isset($listing['Listing']['images'][0]) ? cmsFramework::makeAbsUrl(_DS . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path']) : null;
if (!$image) {
$img_src = '/<img[^>]+src[\\s=\'"]+([^"\'>\\s]+(jpg)+)/is';
preg_match($img_src, $listing['Listing']['summary'], $matches);
if (isset($matches[1])) {
$image = $matches[1];
}
}
$url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true, 'ampreplace' => true));
$fields = $listing['Field']['pairs'];
// You can add other Open Graph meta tags by adding the attribute, custom field pair to the array below
$tags = array('title' => $title, 'url' => $url, 'image' => $image, 'site_name' => cmsFramework::getConfig('sitename'), 'description' => $description, 'type' => Sanitize::getString($listing['ListingType']['config'], 'facebook_opengraph_type'), 'latitude' => Sanitize::getString($Config, 'geomaps.latitude'), 'longitude' => Sanitize::getString($Config, 'geomaps.longitude'), 'street-address' => Sanitize::getString($Config, 'geomaps.address1'), 'locality' => Sanitize::getString($Config, 'geomaps.city'), 'region' => Sanitize::getString($Config, 'geomaps.state'), 'postal-code' => Sanitize::getString($Config, 'geomaps.postal_code'), 'country-name' => Sanitize::getString($Config, 'geomaps.country', Sanitize::getString($Config, 'geomaps.default_country')));
cmsFramework::addScript('<meta property="fb:app_id" content="' . Sanitize::getString($Config, 'facebook_appid') . '"/>');
Sanitize::getString($Config, 'facebook_admins') != '' and cmsFramework::addScript('<meta property="fb:admins" content="' . str_replace(' ', '', $Config->facebook_admins) . '"/>');
// cmsFramework::addScript('<meta property="fb:admins" content="YOUR-ADMIN-ID"/>'); // It's app_id or this, not both
# Loop through the tags array to add the additional FB meta tags
foreach ($tags as $attr => $fname) {
$content = '';
if (substr($fname, 0, 3) == 'jr_') {
// It's a custom field
$content = isset($fields[$fname]) ? htmlspecialchars($fields[$fname]['text'][0], ENT_QUOTES, 'utf-8') : '';
} elseif ($fname != '') {
// It's a static text, not a custom field
$content = htmlspecialchars($fname);
}
$content != '' and cmsFramework::addScript('<meta property="og:' . $attr . '" content="' . $content . '"/>');
}
}
示例15: route
function route($link, $xhtml = true, $ssl = null)
{
$menu_alias = '';
if (false === strpos($link, 'index.php') && false === strpos($link, 'index2.php')) {
$link = 'index.php?' . $link;
}
// Check core sef
$sef = cmsFramework::getConfig('sef');
$sef_rewrite = cmsFramework::getConfig('sef_rewrite');
if (false === strpos($link, 'option=com_jreviews') && !$sef) {
$url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
if (false === strpos($url, 'http')) {
$parsedUrl = parse_url(WWW_ROOT);
$port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
$url = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . $url;
}
return $url;
} elseif (false === strpos($link, 'option=com_jreviews')) {
$url = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
return $url;
}
// Fixes component menu urls with pagination and ordering parameters when core sef is enabled.
$link = str_replace('//', '/', $link);
if ($sef) {
$mod_rewrite = cmsFramework::getConfig('sef_rewrite');
// Mod Rewrite is not enabled
if (!$mod_rewrite) {
preg_match('/Itemid=([0-9]+)/', $link, $matches);
if (isset($matches[1]) && is_numeric($matches[1])) {
$link2 = 'index.php?option=com_jreviews&Itemid=' . $matches[1];
$menu_alias = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link2, $xhtml, $ssl) : JRoute::_($link2, $xhtml, $ssl);
strstr($menu_alias, 'index.php') and $menu_alias = str_replace('.html', '/', substr($menu_alias, strpos($menu_alias, 'index.php' . _DS) + 10));
$menu_alias .= '/';
$menu_alias = '/' . ltrim(array_shift(explode('?', $menu_alias)), '/');
}
}
// Core sef doesn't know how to deal with colons, so we convert them to something else and then replace them again.
$link = $nonsef_link = str_replace(_PARAM_CHAR, '*@*', $link);
$sefUrl = cmsFramework::isAdmin() ? cmsFramework::siteRoute($link, $xhtml, $ssl) : JRoute::_($link, $xhtml, $ssl);
$sefUrl = str_replace('%2A%40%2A', _PARAM_CHAR, $sefUrl);
$sefUrl = str_replace('*@*', _PARAM_CHAR, $sefUrl);
// For non sef links
if (!class_exists('shRouter')) {
// Get rid of duplicate menu alias segments added by the JRoute function
if (strstr($sefUrl, 'order:') || strstr($sefUrl, 'page:') || strstr($sefUrl, 'limit:')) {
$sefUrl = str_replace(array('/format:html/', '.html'), '/', $sefUrl);
}
// Get rid of duplicate menu alias segments added by the JRoute function
if ($menu_alias != '' && $menu_alias != '/' && !$mod_rewrite) {
$sefUrl = str_replace($menu_alias, '--menuAlias--', $sefUrl, $count);
$sefUrl = str_replace(str_repeat('--menuAlias--', $count), $menu_alias, $sefUrl);
}
}
$link = $sefUrl;
// If it's not a JReviews menu url remove the suffix
$nonsef_link = str_replace('&', '&', $nonsef_link);
if (substr($nonsef_link, -5) == '.thtml' && !preg_match('/^index.php\\?option=com_jreviews&Itemid=([0-9]+)$/i', $nonsef_link)) {
$link = str_replace('.html', '', $sefUrl);
}
}
if (false !== strpos($link, 'http')) {
return $link;
} else {
$parsedUrl = parse_url(WWW_ROOT);
$port = isset($parsedUrl['port']) && $parsedUrl['port'] != '' ? ':' . $parsedUrl['port'] : '';
$www_root = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port . ($sef ? _DS : $parsedUrl['path']);
return $www_root . ltrim($link, _DS);
}
}