当前位置: 首页>>代码示例>>PHP>>正文


PHP Typecho_Plugin::export方法代码示例

本文整理汇总了PHP中Typecho_Plugin::export方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Plugin::export方法的具体用法?PHP Typecho_Plugin::export怎么用?PHP Typecho_Plugin::export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Typecho_Plugin的用法示例。


在下文中一共展示了Typecho_Plugin::export方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 列出插件目录 */
     $pluginDirs = $this->getPlugins();
     $this->parameter->setDefault(array('activated' => NULL));
     /** 获取已启用插件 */
     $plugins = Typecho_Plugin::export();
     $this->activatedPlugins = $plugins['activated'];
     if (!empty($pluginDirs)) {
         foreach ($pluginDirs as $key => $pluginDir) {
             $parts = $this->getPlugin($pluginDir, $key);
             if (empty($parts)) {
                 continue;
             }
             list($pluginName, $pluginFileName) = $parts;
             if (file_exists($pluginFileName)) {
                 $info = Typecho_Plugin::parseInfo($pluginFileName);
                 $info['name'] = $pluginName;
                 list($version, $build) = explode('/', Typecho_Common::VERSION);
                 $info['dependence'] = Typecho_Plugin::checkDependence($build, $info['dependence']);
                 /** 默认即插即用 */
                 $info['activated'] = true;
                 if ($info['activate'] || $info['deactivate'] || $info['config'] || $info['personalConfig']) {
                     $info['activated'] = isset($this->activatedPlugins[$pluginName]);
                     if (isset($this->activatedPlugins[$pluginName])) {
                         unset($this->activatedPlugins[$pluginName]);
                     }
                 }
                 if ($info['activated'] == $this->parameter->activated) {
                     $this->push($info);
                 }
             }
         }
     }
 }
开发者ID:hongweipeng,项目名称:typecho,代码行数:41,代码来源:List.php

示例2: config

 /**
  * 配置插件
  *
  * @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;
 }
开发者ID:r0ker,项目名称:hctf2015-all-problems,代码行数:33,代码来源:Config.php

示例3: 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));
 }
开发者ID:hongweipeng,项目名称:typecho,代码行数:34,代码来源:Helper.php

示例4: pluginExists

/**
 * 判断插件是否启用
 *
 * @param string $pluginName
 * @return bool
 */
function pluginExists($pluginName)
{
    static $_plugins;
    if (is_null($_plugins)) {
        $_plugins = Typecho_Plugin::export();
    }
    return isset($_plugins['activated'][$pluginName]);
}
开发者ID:jiangmuzi,项目名称:jianshu,代码行数:14,代码来源:functions.php

示例5: execute

 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 列出插件目录 */
     $pluginDirs = glob(__TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__ . '/*');
     $this->parameter->setDefault(array('activated' => NULL));
     /** 获取已启用插件 */
     $plugins = Typecho_Plugin::export();
     $this->activatedPlugins = $plugins['activated'];
     if (!empty($pluginDirs)) {
         foreach ($pluginDirs as $pluginDir) {
             if (is_dir($pluginDir)) {
                 /** 获取插件名称 */
                 $pluginName = basename($pluginDir);
                 /** 获取插件主文件 */
                 $pluginFileName = $pluginDir . '/Plugin.php';
             } else {
                 if (file_exists($pluginDir) && 'index.php' != basename($pluginDir)) {
                     $pluginFileName = $pluginDir;
                     $part = explode('.', basename($pluginDir));
                     if (2 == count($part) && 'php' == $part[1]) {
                         $pluginName = $part[0];
                     } else {
                         continue;
                     }
                 } else {
                     continue;
                 }
             }
             if (file_exists($pluginFileName)) {
                 $info = Typecho_Plugin::parseInfo($pluginFileName);
                 $info['name'] = $pluginName;
                 list($version, $build) = explode('/', Typecho_Common::VERSION);
                 $info['dependence'] = Typecho_Plugin::checkDependence($build, $info['dependence']);
                 /** 默认即插即用 */
                 $info['activated'] = true;
                 if ($info['activate'] || $info['deactivate'] || $info['config'] || $info['personalConfig']) {
                     $info['activated'] = isset($this->activatedPlugins[$pluginName]);
                     if (isset($this->activatedPlugins[$pluginName])) {
                         unset($this->activatedPlugins[$pluginName]);
                     }
                 }
                 if (!is_bool($this->parameter->activated) || $info['activated'] == $this->parameter->activated) {
                     $this->push($info);
                 }
             }
         }
     }
 }
开发者ID:menmenweiwei,项目名称:blog,代码行数:54,代码来源:List.php

示例6: _e

    <section class="widget">
		<h3 class="widget-title"><?php 
    _e('归档');
    ?>
</h3>
        <ul class="widget-list">
            <?php 
    $this->widget('Widget_Contents_Post_Date', 'type=month&format=F Y')->parse('<li><a href="{permalink}">{date}</a></li>');
    ?>
        </ul>
	</section>
    <?php 
}
?>
    <?php 
$all_plugins = Typecho_Plugin::export();
?>
    <?php 
if (array_key_exists('Links', $all_plugins['activated'])) {
    ?>
    <section class="widget">
        <h3 class="widget-title">Links</h3>
        <ul class="widget-list">
        <?php 
    Links_Plugin::output("SHOW_TEXT", 10);
    ?>
        </ul>
    </section>
    <?php 
}
?>
开发者ID:JokerQyou,项目名称:maupassant,代码行数:31,代码来源:sidebar.php

示例7: getActivePlugins

 private function getActivePlugins()
 {
     $activatedPlugins = Typecho_Plugin::export();
     return array_keys($activatedPlugins['activated']);
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:5,代码来源:Action.php

示例8: 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));
 }
开发者ID:raindali,项目名称:express,代码行数:40,代码来源:Profile.php

示例9: install

 public function install()
 {
     $version = $this->request->get('version');
     $plugin = $this->request->get('plugin');
     $require = $this->request->get('require');
     $require === '*' and $require = '';
     $pluginPath = __TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . '/' . $plugin . '/';
     $pluginBackupPath = __TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . '/_' . $plugin . '/';
     $activatedPlugins = Typecho_Plugin::export();
     $existed = false;
     $activated = false;
     $tempFile = __TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . '/.app_store/' . $plugin . '-' . $version . '.zip';
     try {
         //检查版本
         list(, $buildVersion) = explode('/', Typecho_Common::VERSION);
         if (!Typecho_Plugin::checkDependence($buildVersion, $require)) {
             throw new VersionNotMatchException('版本不匹配,无法安装.');
         }
         //查看插件是否已经存在
         //查看插件是否已经激活
         if (file_exists($pluginPath)) {
             $existed = true;
             if (file_exists($pluginPath . 'Plugin.php') and isset($activatedPlugins['activated'][$plugin])) {
                 $activated = true;
             }
         }
         //插件如果存在,则需要备份下,后面出错可以进行回滚
         if ($existed or $activated) {
             file_exists($pluginBackupPath) and delete_files($pluginBackupPath) and @rmdir($pluginBackupPath);
             @rename($pluginPath, $pluginBackupPath);
         }
         //下载新插件zip包
         $archive = http_get($this->server . 'archive/' . $plugin . '/' . str_replace(' ', '%20', $version));
         if (!$archive) {
             throw new DownloadErrorException('下载插件包出错!');
         }
         //保存文件
         $fp = fopen($tempFile, 'w');
         fwrite($fp, $archive);
         fclose($fp);
         //解压缩文件
         $unzip = new Unzip();
         //创建文件夹
         @mkdir($pluginPath);
         $extractedFiles = $unzip->extract($tempFile, $pluginPath);
         if ($extractedFiles === false) {
             throw new UnzipErrorException('解压缩出错!');
         }
         //OK,解压缩成功了
         //删除备份文件
         file_exists($pluginBackupPath) and delete_files($pluginBackupPath) and @rmdir($pluginBackupPath);
         //删除临时文件
         @unlink($tempFile);
         //报告首长, 安装顺利完成
         echo json_encode(array('status' => true, 'activated' => $activated));
     } catch (VersionNotMatchException $e) {
         $e->responseJson();
     } catch (DownloadErrorException $e) {
         //如果存在备份包,则进行回滚
         file_exists($pluginBackupPath) and @rename($pluginBackupPath, $pluginPath);
         $e->responseJson();
     } catch (UnzipErrorException $e) {
         //清理解锁压缩的废弃文件
         file_exists($pluginPath) and delete_files($pluginPath) and @rmdir($pluginPath);
         //如果存在备份包,则进行回滚
         file_exists($pluginBackupPath) and @rename($pluginBackupPath, $pluginPath);
         //删除临时文件
         @unlink($tempFile);
         $e->responseJson();
     } catch (Exception $e) {
         $error = new JsonableException($e->getMessage());
         $error->responseJson();
     }
 }
开发者ID:xau0at,项目名称:AppStore,代码行数:74,代码来源:Action.php

示例10: deactivate

 /**
  * 禁用插件
  *
  * @access public
  * @return void
  */
 public function deactivate($pluginName)
 {
     /** 获取已激活插件 */
     $plugins = Typecho_Plugin::export();
     $activatedPlugins = $plugins['activated'];
     $pluginFileExist = true;
     try {
         /** 获取插件入口 */
         list($pluginFileName, $className) = Typecho_Plugin::portal($pluginName, __TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__);
     } catch (Typecho_Plugin_Exception $e) {
         $pluginFileExist = false;
         if (!isset($activatedPlugins[$pluginName])) {
             throw $e;
         }
     }
     /** 判断实例化是否成功 */
     if (!isset($activatedPlugins[$pluginName])) {
         throw new Typecho_Widget_Exception(_t('无法禁用插件'), 500);
     }
     if ($pluginFileExist) {
         /** 载入插件 */
         require_once $pluginFileName;
         /** 判断实例化是否成功 */
         if (!isset($activatedPlugins[$pluginName]) || !class_exists($className) || !method_exists($className, 'deactivate')) {
             throw new Typecho_Widget_Exception(_t('无法禁用插件'), 500);
         }
         try {
             $result = call_user_func(array($className, 'deactivate'));
         } catch (Typecho_Plugin_Exception $e) {
             /** 截获异常 */
             $this->widget('Widget_Notice')->set($e->getMessage(), NULL, 'error');
             $this->response->goBack();
         }
         /** 设置高亮 */
         $this->widget('Widget_Notice')->highlight('plugin-' . $pluginName);
     }
     Typecho_Plugin::deactivate($pluginName);
     $this->update(array('value' => serialize(Typecho_Plugin::export())), $this->db->sql()->where('name = ?', 'plugins'));
     $this->delete($this->db->sql()->where('name = ?', 'plugin:' . $pluginName));
     $this->delete($this->db->sql()->where('name = ?', '_plugin:' . $pluginName));
     if (isset($result) && is_string($result)) {
         $this->widget('Widget_Notice')->set($result, NULL, 'notice');
     } else {
         $this->widget('Widget_Notice')->set(_t('插件已经被禁用'), NULL, 'success');
     }
     $this->response->goBack();
 }
开发者ID:raindali,项目名称:express,代码行数:53,代码来源:Edit.php


注:本文中的Typecho_Plugin::export方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。