本文整理匯總了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;
}