本文整理汇总了PHP中JSite::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JSite::getInstance方法的具体用法?PHP JSite::getInstance怎么用?PHP JSite::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSite
的用法示例。
在下文中一共展示了JSite::getInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Save
function Save($context, $article, $isNew)
{
if (is_null($context)) {
//joomla 1.5
if ($_REQUEST['state'] != '1') {
return;
}
if ($_REQUEST['details']['access'] != '0') {
return;
}
} else {
//joomla 2.5
if ($_REQUEST['jform']['state'] != '1') {
return;
}
if ($_REQUEST['jform']['access'] != '1') {
return;
}
if ($context == 'com_media.file') {
return;
}
//enabled "com_content.article" (backend) and "com_content.form" (frontend)
}
$app = JFactory::getApplication();
$fb_enable_autopublish = $this->params->get('fb_enable_autopublish');
$twitter_enable_autopublish = $this->params->get('twitter_enable_autopublish');
//Enable autopublish only on the articles or categories where are rendered the share buttons
$category_tobe_excluded = $this->params->get('category_tobe_excluded_buttons', '');
$content_tobe_excluded = $this->params->get('content_tobe_excluded_buttons', '');
$excludedContentList = @explode(",", $content_tobe_excluded);
if (isset($article->id)) {
if (in_array($article->id, $excludedContentList)) {
return true;
}
if (is_array($category_tobe_excluded)) {
if (in_array($article->catid, $category_tobe_excluded)) {
return true;
}
} else {
$excludedCatList = @explode(",", $category_tobe_excluded);
if (in_array($article->catid, $excludedCatList)) {
return true;
}
}
} else {
if (isset($app->input)) {
$id = $app->input->get('id');
} else {
$id = JRequest::getCmd('id');
}
if (is_array($category_tobe_excluded)) {
if (in_array($id, $category_tobe_excluded)) {
return true;
}
} else {
$excludedCatList = @explode(",", $category_tobe_excluded);
if (in_array($id, $excludedCatList)) {
return true;
}
}
}
//Enable autopublish only on "apply" action
if ($_REQUEST['task'] != 'apply') {
return true;
}
if (($fb_enable_autopublish || $twitter_enable_autopublish) && !extension_loaded('curl')) {
$this->show('Facebook or Twitter Autopublish is not possible because CURL extension is not loaded.', 'error');
return true;
}
//Facebook autopublish
if ($fb_enable_autopublish) {
if (!class_exists('Facebook', false)) {
require_once 'facebook' . DS . 'facebook.php';
}
$fb_app_id = $this->params->get('fb_app_id');
$fb_secret_key = $this->params->get('fb_secret_key');
if (method_exists($this->params, 'exists') && $this->params->exists('fb_extra_params')) {
$fb_extra_params = $this->params->get('fb_extra_params');
$fb_ids = $fb_extra_params->fb_ids;
$token = $fb_extra_params->fb_token;
} else {
$token = $this->params->get('fb_token');
$fb_ids = $this->params->get('fb_ids');
if ($fb_ids == '') {
$fb_ids = array();
}
if (!is_array($fb_ids)) {
$fb_ids = array($fb_ids);
}
}
if ($fb_app_id != '' && $fb_secret_key != '' && count($fb_ids) > 0 && $token != '') {
$title = $this->getTitle($article);
$caption = '';
$url = JUri::root() . ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid);
$router = JSite::getInstance('site')->getRouter('site');
$url = $router->build($url)->toString();
$url = str_replace('administrator/', '', $url);
$description = $this->getDescription($article, 'article');
if ($this->params->get('fb_autopublish_image', '1') == '1') {
//first image
//.........这里部分代码省略.........