Пример #1
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');
 }
Пример #2
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');
 }
Пример #3
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     $info = self::installDb();
     //SNS帐号登录
     Helper::addRoute('oauth', '/oauth', 'TeConnect_Widget', 'oauth');
     Helper::addRoute('oauth_callback', '/oauth_callback', 'TeConnect_Widget', 'callback');
     return _t($info);
 }
Пример #4
0
 public static function activate()
 {
     $msg = Access_Plugin::install();
     Helper::addPanel(1, self::$panel, 'Access控制台', 'Access插件控制台', 'subscriber');
     Helper::addRoute("access_ipip", "/access/i/ipip", "Access_Action", 'ipip');
     Typecho_Plugin::factory('Widget_Archive')->header = array('Access_Plugin', 'start');
     return _t($msg);
 }
Пример #5
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     $msg = self::install();
     // Helper::addPanel(2, 'Notes/add-note.php', '写便签', '新建便签', 'administrator');
     Helper::addPanel(3, 'Notes/manage-notes.php', '便签', '管理便签', 'administrator');
     // Typecho_Plugin::factory('admin/menu.php')->navBar = array('HelloWorld_Plugin', 'render');
     Helper::addAction('notes-manage', 'Notes_Action');
     Helper::addRoute('share_note', '/share_note/[key]/', 'Notes_Action', 'shareNote');
     return _t($meg);
 }
Пример #6
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     $meg = self::install();
     Typecho_Plugin::factory('Widget_User')->___sinauthAuthorizeIcon = array('Sinauth_Plugin', 'authorizeIcon');
     Helper::addAction('sinauthAuthorize', 'Sinauth_AuthorizeAction');
     Helper::addRoute('sinauthAuthorize', '/sinauthAuthorize/', 'Sinauth_AuthorizeAction', 'action');
     Helper::addRoute('sinauthCallback', '/sinauthCallback/', 'Sinauth_AuthorizeAction', 'callback');
     Helper::addPanel(1, 'Sinauth/panel.php', 'Sinauth', 'Sinauth用户管理', 'administrator');
     return _t($meg . '。请进行<a href="options-plugin.php?config=' . self::$pluginName . '">初始化设置</a>');
 }
Пример #7
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     self::doTable();
     Helper::addAction("api", "API_Action");
     Typecho_Plugin::factory('admin/custom-fields.php')->before = array('API_Plugin', 'addParser');
     Typecho_Plugin::factory('Widget_Contents_Page_Edit')->finishPublish = array('API_Plugin', 'processContent');
     Typecho_Plugin::factory('Widget_Contents_Page_Edit')->finishSave = array('API_Plugin', 'processContent');
     Helper::addRoute("ChildApi", "/api/[arg1]/[arg2].json/", "API_Action", "detailAction");
     Helper::addRoute("MainApi", "/api/[type].json/", "API_Action", "action");
     return _t('开启网站API接口,访问路径为:' . "/api");
 }
Пример #8
0
 public static function activate()
 {
     $msg = self::install();
     //挂载发布文章和页面的接口
     Typecho_Plugin::factory('Widget_Contents_Post_Edit')->finishPublish = array('BaiduSubmit_Action', 'send');
     Typecho_Plugin::factory('Widget_Contents_Page_Edit')->finishPublish = array('BaiduSubmit_Action', 'send');
     //添加网站地图功能
     Helper::addRoute('baidu_sitemap', '/baidu_sitemap.xml', 'BaiduSubmit_Action', 'sitemap');
     Helper::addPanel(1, 'BaiduSubmit/Logs.php', '百度结构化日志', '百度结构化日志', 'administrator');
     Helper::addRoute('baidu_sitemap_advanced', __TYPECHO_ADMIN_DIR__ . 'baidu_sitemap/advanced', 'BaiduSubmit_Action', 'send_all');
     return $msg . '请进入设置填写接口调用地址';
 }
Пример #9
0
 public static function activate()
 {
     if (substr(trim(dirname(__FILE__), '/'), -8) != 'ymplayer') {
         throw new Typecho_Plugin_Exception('插件目录名必须为ymplayer');
     }
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array(__CLASS__, 'parse');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array(__CLASS__, 'parse');
     Typecho_Plugin::factory('Widget_Archive')->header = array(__CLASS__, 'insertStyle');
     Typecho_Plugin::factory('Widget_Archive')->footer = array(__CLASS__, 'insertScript');
     Typecho_Plugin::factory('admin/write-post.php')->bottom = array(__CLASS__, 'button');
     Typecho_Plugin::factory('admin/write-page.php')->bottom = array(__CLASS__, 'button');
     Helper::addRoute('ymplayer_ajax', '/ymplayer.json', 'ymplayer_Action', 'ajax');
 }
Пример #10
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     //检查是否有curl扩展
     if (!extension_loaded('curl')) {
         throw new Typecho_Plugin_Exception('缺少curl扩展支持.');
     }
     //创建下载临时目录
     $tempDir = __TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . self::$tempPath;
     !file_exists($tempDir) and !@mkdir($tempDir);
     //创建菜单和路由
     Helper::addPanel(1, 'AppStore/market.php', '应用商店', '应用商店', 'administrator');
     Helper::addRoute('app.store.market', __TYPECHO_ADMIN_DIR__ . 'app-store/market', 'AppStore_Action', 'market');
     Helper::addRoute('app.store.install', __TYPECHO_ADMIN_DIR__ . 'app-store/install', 'AppStore_Action', 'install');
 }
Пример #11
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     // 接口
     Typecho_Plugin::factory('接口')->navBar_20 = array('MyPlugin_Plugin', 'functionName');
     // 添加菜单
     Helper::addMenu('menuName');
     // 添加面板, 1 为菜单索引位置, administrator 为进入面板的权限
     Helper::addPanel(1, 'MyPlugin/panel.php', 'panelTitle', 'panelSubtitle', 'administrator');
     // 添加动作
     Helper::addAction('actionName', 'MyPlugin_ActionClassName');
     // 添加路由
     Helper::addRoute('routeName', '/myroute/route-path', 'MyPlugin_WidgetClassName', 'functionName');
     // 激活时返回的信息
     return _t('激活时返回的信息');
 }
Пример #12
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     $db = Typecho_Db::get();
     $golinks = $db->getPrefix() . 'golinks';
     $adapter = $db->getAdapterName();
     if ("Pdo_SQLite" === $adapter || "SQLite" === $adapter) {
         $db->query(" CREATE TABLE IF NOT EXISTS " . $golinks . " (\n               id INTEGER PRIMARY KEY, \n               key TEXT,\n               target TEXT,\n               count NUMERIC)");
     }
     if ("Pdo_Mysql" === $adapter || "Mysql" === $adapter) {
         $db->query("CREATE TABLE IF NOT EXISTS " . $golinks . " (\n                  `id` int(8) NOT NULL AUTO_INCREMENT,\n                  `key` varchar(32) NOT NULL,\n                  `target` varchar(10000) NOT NULL,\n                  `count` int(8) DEFAULT '0',\n                  PRIMARY KEY (`id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
     }
     Helper::addAction('golinks', 'GoLinks_Action');
     Helper::addRoute('go', '/go/[key]/', 'GoLinks_Action', 'golink');
     Helper::addPanel(2, 'GoLinks/panel.php', '链接转换', '链接转换管理', 'administrator');
     return '数据表 ' . $golinks . ' 创建成功, 插件已经成功激活!';
 }
Пример #13
0
 /**
  * 修改路由
  */
 public function edit()
 {
     $modified = false;
     if ($this->request->isPost()) {
         foreach ($this->_default as $key => $value) {
             if (array_key_exists($key, $this->_restore) && $this->request->__isSet($key) && $this->request->{$key} != $this->_default[$key]['url'] && $key != 'do') {
                 Helper::removeRoute($key);
                 Helper::addRoute($key, $this->request->{$key}, $this->_default[$key]['widget'], $this->_default[$key]['action']);
                 $modified = true;
             }
         }
     }
     if ($modified) {
         $this->widget('Widget_Notice')->set(_t("路由变更已经保存"), NULL, 'success');
     } else {
         $this->widget('Widget_Notice')->set(_t("路由未变更"), NULL, 'notice');
     }
 }
Пример #14
0
 /**
  * 激活duoshuo方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     try {
         Duoshuo_Plugin::duoshuoInstall();
         $err = '建立多说信息数据表,duoshuo启用成功';
     } catch (Typecho_Db_Exception $e) {
         $code = $e->getCode();
         if (1050 == $code || 1062 == $code || 1060 == $code) {
             $err = '多说信息数据表数据表已经存在,duoshuo启用成功';
         } else {
             return _t('多说实时同步duoshuo启用失败' . $code);
         }
     }
     Helper::addPanel(3, 'Duoshuo/manage-duoshuo.php', '多说评论', '多说评论管理', 'administrator');
     Helper::addAction('duoshuo-edit', 'Duoshuo_Action');
     Helper::addRoute('DuoShuoSync', '/DuoShuoSync', 'Duoshuo_Action', 'api');
     Typecho_Plugin::factory('Widget_Feedback')->comment = array('Duoshuo_Plugin', 'comments_deny');
     //关闭站内留言
     return _t($err);
 }
Пример #15
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     $tempDir = dirname(__FILE__) . self::$tempPath;
     $dataDir = dirname(__FILE__) . self::$dataPath;
     if (!file_exists($tempDir) and !@mkdir($tempDir)) {
         throw new Typecho_Plugin_Exception('无法创建临时目录.');
     }
     if (!self::testWrite($tempDir)) {
         throw new Typecho_Plugin_Exception('.tmp目录没有写入的权限');
     }
     if (!file_exists($dataDir) and !@mkdir($dataDir)) {
         throw new Typecho_Plugin_Exception('无法创建数据目录.');
     }
     if (!self::testWrite($dataDir)) {
         throw new Typecho_Plugin_Exception('data目录没有写入的权限');
     }
     Typecho_Plugin::factory('admin/menu.php')->navBar = array('TeStore_Plugin', 'render');
     Helper::addPanel(1, 'TeStore/market.php', 'TE应用商店', 'TE应用商店', 'administrator');
     Helper::addRoute('te-store_market', __TYPECHO_ADMIN_DIR__ . 'te-store/market', 'TeStore_Action', 'market');
     Helper::addRoute('te-store_install', __TYPECHO_ADMIN_DIR__ . 'te-store/install', 'TeStore_Action', 'install');
     Helper::addRoute('te-store_uninstall', __TYPECHO_ADMIN_DIR__ . 'te-store/uninstall', 'TeStore_Action', 'uninstall');
 }
Пример #16
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('admin/menu.php')->navBar = array('Update_Plugin', 'show');
     Helper::addRoute('update', '/update/[step]', 'Update_Action', NULL);
 }
Пример #17
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  *
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Helper::addRoute('passport_forgot', '/passport/forgot', 'Passport_Widget', 'doForgot');
     Helper::addRoute('passport_reset', '/passport/reset', 'Passport_Widget', 'doReset');
     return _t('请配置此插件的SMTP信息, 以使您的插件生效');
 }
Пример #18
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Helper::addPanel(1, "TEDbBak/MainView.php", _t("数据库备份"), _t("数据库备份"), 'administrator');
     Helper::addAction('kgsoft_dbbak', 'TEDbBak_Action');
     Helper::addRoute('forbiddenUrl', '/usr/plugins/TEDbBak/bak/[str:string]', 'TEDbBak_Action', 'forbid', 'index_page');
 }
Пример #19
0
 /**
  * v0_9r13_11_17  
  * 
  * @param mixed $db 
  * @param mixed $options 
  * @static
  * @access public
  * @return void
  */
 public static function v0_9r13_11_17($db, $options)
 {
     Helper::addRoute('archive', '/blog/', 'Widget_Archive', 'render', 'index');
     Helper::addRoute('archive_page', '/blog/[page:digital]/', 'Widget_Archive', 'render', 'index_page');
     $db->query($db->insert('table.options')->rows(array('name' => 'frontArchive', 'user' => 0, 'value' => 0)));
 }
Пример #20
0
 /**
  * 重设自定义链接
  */
 public function resetLink()
 {
     $link = $this->request->link;
     Helper::removeRoute('go');
     Helper::addRoute('go', $link, 'GoLinks_Action', 'golink');
     Typecho_Response::throwJson('success');
 }