当前位置: 首页>>代码示例>>PHP>>正文


PHP JSite::getInstance方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:jbelborja,项目名称:lavid3,代码行数:101,代码来源:fb_tw_plus1.php


注:本文中的JSite::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。