Exemple #1
0
 public static function activate()
 {
     // 触发机制
     Typecho_Plugin::factory('index.php')->begin = array('TypechoXcache_Plugin', 'getCache');
     Typecho_Plugin::factory('index.php')->end = array('TypechoXcache_Plugin', 'setCache');
     Typecho_Plugin::factory('Widget_Feedback')->finishComment = array('TypechoXcache_Plugin', 'finish');
     Typecho_Plugin::factory('Widget_Contents_Post_Edit')->finishPublish = array('TypechoXcache_Plugin', 'clearCache');
     // $cache_dir = './usr/plugins/TypechoXcache/Cache/';
     // if (!file_exists($cache_dir)) {
     // 	if (mkdir($cache_dir, 0777) && chmod($cache_dir, 0777)) {
     // 		return ('建立缓存文件夹成功, 插件成功激活!');
     // 	} else {
     // 		throw new Typecho_Plugin_Exception('建立缓存文件夹失败, 请检查权限设置!');
     // 	}
     // } else {
     // 	// 这边 return 一个在顶部的提示
     // 	return ('缓存文件夹已存在, 插件成功激活!');
     // }
     // Typecho_Plugin::factory('admin/menu.php')->navBar = array('TypechoXcache_Plugin', 'render');
     if (!function_exists('xcache_count')) {
         throw new Typecho_Plugin_Exception('开启插件失败,缺少xcache环境!');
     } else {
         return '开启成功!';
     }
     // xcache_count();
 }
Exemple #2
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('admin/write-post.php')->bottom = array('XiaMiPlayer_Plugin', 'Insert');
     Typecho_Plugin::factory('admin/write-page.php')->bottom = array('XiaMiPlayer_Plugin', 'Insert');
     Typecho_Plugin::factory('Widget_Archive')->header = array('XiaMiPlayer_Plugin', 'header');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('XiaMiPlayer_Plugin', 'ParseXiaMi');
 }
Exemple #3
0
 /**
  * 入口函数,初始化路由器
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 对变量赋值 */
     $options = $this->widget('Widget_Options');
     /** 开始会话 */
     @session_start();
     /** 初始化charset */
     Typecho_Common::$charset = $options->charset;
     /** 初始化exception */
     Typecho_Common::$exceptionHandle = 'Widget_ExceptionHandle';
     /** 设置路径 */
     if (defined('__TYPECHO_PATHINFO_ENCODING__')) {
         $pathInfo = $this->request->getPathInfo(__TYPECHO_PATHINFO_ENCODING__, $options->charset);
     } else {
         $pathInfo = $this->request->getPathInfo();
     }
     Typecho_Router::setPathInfo($pathInfo);
     /** 初始化路由器 */
     Typecho_Router::setRoutes($options->routingTable);
     /** 初始化插件 */
     Typecho_Plugin::init($options->plugins);
     /** 初始化回执 */
     $this->response->setCharset($options->charset);
     $this->response->setContentType($options->contentType);
     /** 默认时区 */
     if (!ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
         @date_default_timezone_set('UTC');
     }
     /** 初始化时区 */
     Typecho_Date::setTimezoneOffset($options->timezone);
     /** 监听缓冲区 */
     ob_start();
 }
Exemple #4
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Archive')->header = array('CodeBox_Plugin', 'addheader');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('CodeBox_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('CodeBox_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Abstract_Comments')->contentEx = array('CodeBox_Plugin', 'parse');
 }
Exemple #5
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     if (false == Typecho_Http_Client::get()) {
         throw new Typecho_Plugin_Exception(_t('对不起, 您的主机不支持 php-curl 扩展而且没有打开 allow_url_fopen 功能, 无法正常使用此功能'));
     }
     Typecho_Plugin::factory('admin/menu.php')->navBar = array('Qiniu_Plugin', 'render');
 }
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('GithubCard_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('GithubCard_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Abstract_Comments')->contentEx = array('GithubCard_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Archive')->footer = array('GithubCard_Plugin', 'footer');
 }
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     //注入CSS
     Typecho_Plugin::factory('Widget_Archive')->header = array(__CLASS__, 'outputHeader');
     Typecho_Plugin::factory('Widget_Archive')->footer = array(__CLASS__, 'outputFooter');
     return _t('日历插件启动成功');
 }
Exemple #8
0
 public static function activate()
 {
     $meg = Robots_Plugin::install();
     Helper::addPanel(1, 'Robots/Logs.php', '蜘蛛日志', '查看蜘蛛日志', 'administrator');
     Typecho_Plugin::factory('Widget_Archive')->header = array('Robots_Plugin', 'isbot');
     return _t($meg);
 }
 public static function activate()
 {
     $msg = Access_Plugin::install();
     Helper::addPanel(1, self::$panel, 'Access控制台', 'Access插件控制台', 'subscriber');
     Typecho_Plugin::factory('Widget_Archive')->header = array('Access_Plugin', 'start');
     return _t($msg);
 }
Exemple #10
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Helper::addPanel(1, 'Xiami/panel.php', _t('虾米音乐同步预览'), _t('虾米音乐同步预览'), 'administrator');
     Typecho_Plugin::factory('Widget_Archive')->header = array('Xiami_Plugin', 'headerScript');
     Typecho_Plugin::factory('Widget_Archive')->footer = array('Xiami_Plugin', 'footerScript');
     return _t('请在插件设置里设置参数') . $error;
 }
Exemple #11
0
 /**
  * 强行删除某个插件
  *
  * @access public
  * @param string $pluginName 插件名称
  * @return void
  */
 public static function removePlugin($pluginName)
 {
     try {
         /** 获取插件入口 */
         list($pluginFileName, $className) = Typecho_Plugin::portal($pluginName, __TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__);
         /** 获取已启用插件 */
         $plugins = Typecho_Plugin::export();
         $activatedPlugins = $plugins['activated'];
         /** 载入插件 */
         require_once $pluginFileName;
         /** 判断实例化是否成功 */
         if (!isset($activatedPlugins[$pluginName]) || !class_exists($className) || !method_exists($className, 'deactivate')) {
             throw new Typecho_Widget_Exception(_t('无法禁用插件'), 500);
         }
         $result = call_user_func(array($className, 'deactivate'));
     } catch (Exception $e) {
         //nothing to do
     }
     $db = Typecho_Db::get();
     try {
         Typecho_Plugin::deactivate($pluginName);
         $db->query($db->update('table.options')->rows(array('value' => serialize(Typecho_Plugin::export())))->where('name = ?', 'plugins'));
     } catch (Typecho_Plugin_Exception $e) {
         //nothing to do
     }
     $db->query($db->delete('table.options')->where('name = ?', 'plugin:' . $pluginName));
 }
Exemple #12
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('TableOfContents_Plugin', 'replace');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('TableOfContents_Plugin', 'replace');
     Typecho_Plugin::factory('Widget_Archive')->header = array('TableOfContents_Plugin', 'header');
     Typecho_Plugin::factory('Widget_Archive')->footer = array('TableOfContents_Plugin', 'footer');
 }
Exemple #13
0
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('Prismjs_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Abstract_Comments')->contentEx = array('Prismjs_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Archive')->header = array('Prismjs_Plugin', 'header');
     Typecho_Plugin::factory('Widget_Archive')->footer = array('Prismjs_Plugin', 'footer');
 }
Exemple #14
0
 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     $themes = $this->getThemes();
     if ($themes) {
         $options = $this->widget('Widget_Options');
         $siteUrl = $options->siteUrl;
         $adminUrl = $options->adminUrl;
         $activated = 0;
         $result = array();
         foreach ($themes as $key => $theme) {
             $themeFile = $theme . '/index.php';
             if (file_exists($themeFile)) {
                 $info = Typecho_Plugin::parseInfo($themeFile);
                 $info['name'] = $this->getTheme($theme, $key);
                 if ($info['activated'] = $options->theme == $info['name']) {
                     $activated = $key;
                 }
                 $screen = glob($theme . '/screen*.{jpg,png,gif,bmp,jpeg,JPG,PNG,GIF,BMG,JPEG}', GLOB_BRACE);
                 if ($screen) {
                     $info['screen'] = $options->themeUrl(basename(current($screen)), $info['name']);
                 } else {
                     $info['screen'] = Typecho_Common::url('noscreen.png', $options->adminStaticUrl('img'));
                 }
                 $result[$key] = $info;
             }
         }
         $clone = $result[$activated];
         unset($result[$activated]);
         array_unshift($result, $clone);
         array_filter($result, array($this, 'push'));
     }
 }
Exemple #15
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     $db = Typecho_Db::get();
     $prefix = $db->getPrefix();
     // 查看数
     if (!array_key_exists('viewsNum', $db->fetchRow($db->select()->from('table.contents')))) {
         $db->query('ALTER TABLE `' . $prefix . 'contents` ADD `viewsNum` INT(10) DEFAULT 0;');
     }
     // 喜欢数
     if (!array_key_exists('likesNum', $db->fetchRow($db->select()->from('table.contents')))) {
         $db->query('ALTER TABLE `' . $prefix . 'contents` ADD `likesNum` INT(10) DEFAULT 0;');
     }
     //增加浏览数
     Typecho_Plugin::factory('Widget_Archive')->singleHandle = array('Jianshu_Plugin', 'viewCounter');
     //把新增的字段添加到查询中
     Typecho_Plugin::factory('Widget_Archive')->select = array('Jianshu_Plugin', 'selectHandle');
     //处理内容
     Typecho_Plugin::factory('Widget_Archive')->beforeRender = array('Jianshu_Plugin', 'beforeRender');
     //处理用户字段
     Typecho_Plugin::factory('Widget_Abstract_Users')->filter = array('Jianshu_Plugin', 'filterUser');
     //sitemap
     Helper::addRoute('sitemap', '/sitemap.xml', 'Jianshu_Action', 'sitemap');
     //工具提供的操作
     Helper::addAction('tools', 'Jianshu_Action');
 }
Exemple #16
0
 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     $themes = glob(__TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . '/*');
     if ($themes) {
         $options = $this->widget('Widget_Options');
         $siteUrl = $options->siteUrl;
         $adminUrl = $options->adminUrl;
         $activated = 0;
         $result = array();
         foreach ($themes as $key => $theme) {
             $themeFile = $theme . '/index.php';
             if (file_exists($themeFile)) {
                 $info = Typecho_Plugin::parseInfo($themeFile);
                 $info['name'] = basename($theme);
                 if ($info['activated'] = $options->theme == $info['name']) {
                     $activated = $key;
                 }
                 $screen = glob($theme . '/screen*.{jpg,png,gif,bmp,jpeg,JPG,PNG,GIF,BMG,JPEG}', GLOB_BRACE);
                 if ($screen) {
                     $info['screen'] = Typecho_Common::url(trim(__TYPECHO_THEME_DIR__, '/') . '/' . $info['name'] . '/' . basename(current($screen)), $siteUrl);
                 } else {
                     $info['screen'] = Typecho_Common::url('/images/noscreen.gif', $adminUrl);
                 }
                 $result[$key] = $info;
             }
         }
         $clone = $result[$activated];
         unset($result[$activated]);
         array_unshift($result, $clone);
         array_filter($result, array($this, 'push'));
     }
 }
Exemple #17
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Abstract_Contents')->filter = array('JWPlayer_Plugin', 'jwfilter');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('JWPlayer_Plugin', 'jwparse');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('JWPlayer_Plugin', 'jwparse');
     Typecho_Plugin::factory('Widget_Archive')->header = array('JWPlayer_Plugin', 'jwjs');
 }
 /**
  * 配置插件
  *
  * @access public
  * @return Typecho_Widget_Helper_Form
  * @throws Typecho_Widget_Exception
  */
 public function config()
 {
     /** 获取插件名称 */
     $pluginName = $this->request->filter('slug')->config;
     /** 获取已启用插件 */
     $plugins = Typecho_Plugin::export();
     $activatedPlugins = $plugins['activated'];
     /** 判断实例化是否成功 */
     if (!$this->info['config'] || !isset($activatedPlugins[$pluginName])) {
         throw new Typecho_Widget_Exception(_t('无法配置插件'), 500);
     }
     /** 载入插件 */
     require_once $this->_pluginFileName;
     $form = new Typecho_Widget_Helper_Form($this->security->getIndex('/action/plugins-edit?config=' . $pluginName), Typecho_Widget_Helper_Form::POST_METHOD);
     call_user_func(array($this->_className, 'config'), $form);
     $options = $this->options->plugin($pluginName);
     if (!empty($options)) {
         foreach ($options as $key => $val) {
             $form->getInput($key)->value($val);
         }
     }
     $submit = new Typecho_Widget_Helper_Form_Element_Submit(NULL, NULL, _t('保存设置'));
     $submit->input->setAttribute('class', 'btn primary');
     $form->addItem($submit);
     return $form;
 }
Exemple #19
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('admin/menu.php')->navBar = array('DevTool_Plugin', 'render');
     Helper::addPanel(1, 'DevTool/index.php', self::NAME, self::NAME, 'administrator');
     Helper::addRoute('dev-tool_index', __TYPECHO_ADMIN_DIR__ . 'dev-tool/index', 'DevTool_Action', 'index');
     Helper::addRoute('dev-tool_options', __TYPECHO_ADMIN_DIR__ . 'dev-tool/options', 'DevTool_Action', 'options');
     Helper::addRoute('dev-tool_post', __TYPECHO_ADMIN_DIR__ . 'dev-tool/post', 'DevTool_Action', 'post');
 }
Exemple #20
0
 /**
  * 激活插件方法,激活失败,直接抛出异常
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('QiniuCDN_Plugin', 'qiniucdn');
     //针对内容处理
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('QiniuCDN_Plugin', 'qiniucdn');
     //针对摘要处理
     return _t('QiniuCDN 启用成功');
 }
Exemple #21
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('admin/write-post.php')->richEditor = array('Ueditor_Plugin', 'render');
     Typecho_Plugin::factory('admin/write-page.php')->richEditor = array('Ueditor_Plugin', 'render');
     //去除段落
     Typecho_Plugin::factory('Widget_Contents_Post_Edit')->write = array('Ueditor_Plugin', 'filter');
     Typecho_Plugin::factory('Widget_Contents_Page_Edit')->write = array('Ueditor_Plugin', 'filter');
 }
Exemple #22
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('admin/write-post.php')->option = array('SyncPost_Plugin', 'render');
     Typecho_Plugin::factory('admin/write-page.php')->option = array('SyncPost_Plugin', 'render');
     Typecho_Plugin::factory('Widget_Contents_Post_Edit')->write = array('SyncPost_Plugin', 'postRender');
     Typecho_Plugin::factory('Widget_Contents_Page_Edit')->write = array('SyncPost_Plugin', 'postRender');
     Helper::addAction('SyncPost', 'SyncPost_Action');
 }
Exemple #23
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     //离线浏览器都是所见即所得模式
     Typecho_Plugin::factory('Widget_XmlRpc')->fromOfflineEditor = array('FlashMp3Player_Plugin', 'toCodeEditor');
     /** 前端输出处理接口 */
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('FlashMp3Player_Plugin', 'parse');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('FlashMp3Player_Plugin', 'parse');
 }
Exemple #24
0
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Upload')->uploadHandle = array('QiniuFile_Plugin', 'uploadHandle');
     Typecho_Plugin::factory('Widget_Upload')->modifyHandle = array('QiniuFile_Plugin', 'modifyHandle');
     Typecho_Plugin::factory('Widget_Upload')->deleteHandle = array('QiniuFile_Plugin', 'deleteHandle');
     Typecho_Plugin::factory('Widget_Upload')->attachmentHandle = array('QiniuFile_Plugin', 'attachmentHandle');
     return _t('插件已经激活,需先配置七牛的信息!');
 }
Exemple #25
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory("index.php")->begin = array(__CLASS__, "startTimer");
     Typecho_Plugin::factory("index.php")->end = array(__CLASS__, "finalize");
     Typecho_Plugin::factory("admin/footer.php")->end = array(__CLASS__, "finalize_admin");
     Typecho_Plugin::factory("Widget_Contents_Post_Edit")->finishPublish = array(__CLASS__, "writePost");
     Typecho_Plugin::factory("Widget_Feedback")->finishComment = array(__CLASS__, "finishComment");
 }
Exemple #26
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Archive')->header = array('Ukagaka_Plugin', 'header');
     Typecho_Plugin::factory('Widget_Archive')->footer = array('Ukagaka_Plugin', 'footer');
     $db = Typecho_Db::get();
     $db->query($db->insert('table.options')->rows(array('name' => 'Ukagaka_starttime', 'value' => time(), 'user' => 0)));
     Helper::addAction('Ukagaka', 'Ukagaka_Action');
 }
Exemple #27
0
/**
 * 判断插件是否启用
 *
 * @param string $pluginName
 * @return bool
 */
function pluginExists($pluginName)
{
    static $_plugins;
    if (is_null($_plugins)) {
        $_plugins = Typecho_Plugin::export();
    }
    return isset($_plugins['activated'][$pluginName]);
}
Exemple #28
0
 /**
  * activate
  *
  * @static
  * @access public
  * @return void
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Contents_Post_Edit')->insert = array('PostToQzone_Plugin', 'publish');
     if (!extension_loaded("sockets")) {
         throw new Typecho_Plugin_Exception(_t('对不起, 您的主机不支持socket扩展, 无法正常使用此功能'));
     }
     return _t('请配置您的qq号码以及密码,以便发布文章到Qzone');
 }
Exemple #29
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Upload')->uploadHandle = array('SCS_Plugin', 'uploadHandle');
     Typecho_Plugin::factory('Widget_Upload')->modifyHandle = array('SCS_Plugin', 'modifyHandle');
     Typecho_Plugin::factory('Widget_Upload')->deleteHandle = array('SCS_Plugin', 'deleteHandle');
     Typecho_Plugin::factory('Widget_Upload')->attachmentHandle = array('SCS_Plugin', 'attachmentHandle');
     return _t('请设置SCS的信息,以使插件正常使用!');
 }
Exemple #30
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Upload')->uploadHandle = ['BOSUpload_Plugin', 'uploadHandle'];
     Typecho_Plugin::factory('Widget_Upload')->modifyHandle = ['BOSUpload_Plugin', 'modifyHandle'];
     Typecho_Plugin::factory('Widget_Upload')->deleteHandle = ['BOSUpload_Plugin', 'deleteHandle'];
     Typecho_Plugin::factory('Widget_Upload')->attachmentHandle = ['BOSUpload_Plugin', 'attachmentHandle'];
     Typecho_Plugin::factory('Widget_Upload')->attachmentDataHandle = ['BOSUpload_Plugin', 'attachmentDataHandle'];
 }