本文整理汇总了PHP中Typecho_Plugin::portal方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Plugin::portal方法的具体用法?PHP Typecho_Plugin::portal怎么用?PHP Typecho_Plugin::portal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typecho_Plugin
的用法示例。
在下文中一共展示了Typecho_Plugin::portal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: execute
/**
* 绑定动作
*
* @access public
* @return unknown
*/
public function execute()
{
$this->user->pass('administrator');
if (!isset($this->request->config)) {
throw new Typecho_Widget_Exception(_t('插件不存在'), 404);
}
/** 获取插件入口 */
list($this->_pluginFileName, $this->_className) = Typecho_Plugin::portal($this->request->config, __TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__);
$this->info = Typecho_Plugin::parseInfo($this->_pluginFileName);
}
示例3: execute
/**
* 绑定动作
*
* @access public
*/
public function execute()
{
$this->user->pass('administrator');
$config = $this->request->filter('slug')->config;
if (empty($config)) {
throw new Typecho_Widget_Exception(_t('插件不存在'), 404);
}
/** 获取插件入口 */
list($this->_pluginFileName, $this->_className) = Typecho_Plugin::portal($config, $this->options->pluginDir($config));
$this->info = Typecho_Plugin::parseInfo($this->_pluginFileName);
}
示例4: updatePersonal
/**
* 更新个人设置
*
* @access public
* @return void
*/
public function updatePersonal()
{
/** 获取插件名称 */
$pluginName = $this->request->plugin;
/** 获取已激活插件 */
$plugins = Typecho_Plugin::export();
$activatedPlugins = $plugins['activated'];
/** 获取插件入口 */
list($pluginFileName, $className) = Typecho_Plugin::portal($this->request->plugin, __TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__);
$info = Typecho_Plugin::parseInfo($pluginFileName);
if (!$info['personalConfig'] || !isset($activatedPlugins[$pluginName])) {
throw new Typecho_Widget_Exception(_t('无法配置插件'), 500);
}
$form = $this->personalForm($pluginName, $className, $pluginFileName, $group);
$this->user->pass($group);
/** 验证表单 */
if ($form->validate()) {
$this->response->goBack();
}
$settings = $form->getAllRequest();
unset($settings['do'], $settings['plugin']);
$name = '_plugin:' . $pluginName;
if (!$this->personalConfigHandle($className, $settings)) {
if ($this->db->fetchObject($this->db->select(array('COUNT(*)' => 'num'))->from('table.options')->where('name = ? AND user = ?', $name, $this->user->uid))->num > 0) {
$this->widget('Widget_Abstract_Options')->update(array('value' => serialize($settings)), $this->db->sql()->where('name = ? AND user = ?', $name, $this->user->uid));
} else {
$this->widget('Widget_Abstract_Options')->insert(array('name' => $name, 'value' => serialize($settings), 'user' => $this->user->uid));
}
}
/** 提示信息 */
$this->widget('Widget_Notice')->set(_t("%s 设置已经保存", $info['title']), NULL, 'success');
/** 转向原页 */
$this->response->redirect(Typecho_Common::url('profile.php', $this->options->adminUrl));
}
示例5: configHandle
/**
* 用自有函数处理配置信息
*
* @access public
* @param string $pluginName 插件名称
* @param array $settings 配置值
* @param boolean $isInit 是否为初始化
* @return boolean
*/
public function configHandle($pluginName, array $settings, $isInit)
{
/** 获取插件入口 */
list($pluginFileName, $className) = Typecho_Plugin::portal($pluginName, __TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__);
if (method_exists($className, 'configHandle')) {
call_user_func(array($className, 'configHandle'), $settings, $isInit);
return true;
}
return false;
}
示例6: configHandle
/**
* 用自有函数处理配置信息
*
* @access public
* @param string $pluginName 插件名称
* @param array $settings 配置值
* @param boolean $isInit 是否为初始化
* @return boolean
*/
public function configHandle($pluginName, array $settings, $isInit)
{
/** 获取插件入口 */
list($pluginFileName, $className) = Typecho_Plugin::portal($pluginName, $this->options->pluginDir($pluginName));
if (method_exists($className, 'configHandle')) {
call_user_func(array($className, 'configHandle'), $settings, $isInit);
return true;
}
return false;
}