本文整理汇总了PHP中Typecho_Plugin类的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Plugin类的具体用法?PHP Typecho_Plugin怎么用?PHP Typecho_Plugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Typecho_Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
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();
}
示例2: activate
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @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');
}
示例3: execute
/**
* 入口函数,初始化路由器
*
* @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();
}
示例4: activate
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @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');
}
示例5: activate
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @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');
}
示例6: activate
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @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');
}
示例7: activate
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @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('日历插件启动成功');
}
示例8: activate
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);
}
示例9: activate
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);
}
示例10: removePlugin
/**
* 强行删除某个插件
*
* @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));
}
示例11: activate
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @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');
}
示例12: activate
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');
}
示例13: execute
/**
* 执行函数
*
* @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'));
}
}
示例14: activate
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @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');
}
示例15: execute
/**
* 执行函数
*
* @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'));
}
}