本文整理匯總了PHP中Typecho_Plugin::parseInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP Typecho_Plugin::parseInfo方法的具體用法?PHP Typecho_Plugin::parseInfo怎麽用?PHP Typecho_Plugin::parseInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Typecho_Plugin
的用法示例。
在下文中一共展示了Typecho_Plugin::parseInfo方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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'));
}
}
示例2: 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'));
}
}
示例3: market
/**
* 應用商店主頁
*
*/
public function market()
{
//獲取插件列表
$result = json_decode(http_get($this->server . 'packages.json'));
if ($result) {
//導出已激活插件
$activatedPlugins = Typecho_Plugin::export();
foreach ($result->packages as &$_package) {
$pluginPath = __TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . '/' . $_package->name . '/';
$pluginEntry = $pluginPath . 'Plugin.php';
$_package->existed = 0;
if (file_exists($pluginEntry)) {
$_package->existed = 1;
$pluginMeta = Typecho_Plugin::parseInfo($pluginEntry);
foreach ($_package->versions as &$_version) {
$_version->activated = 0;
$_version->description = strip_tags($_version->description);
$_version->author = strip_tags($_version->author);
if ($_version->version == $pluginMeta['version'] and isset($activatedPlugins['activated'][$_package->name])) {
$_version->activated = 1;
}
}
} else {
foreach ($_package->versions as &$_version) {
$_version->description = strip_tags($_version->description);
$_version->author = strip_tags($_version->author);
$_version->activated = 0;
}
}
}
}
include 'views/market.php';
}
示例4: 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);
}
示例5: 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);
}
示例6: activate
/**
* 激活插件
*
* @access public
* @return void
*/
public function activate($pluginName)
{
/** 獲取插件入口 */
list($pluginFileName, $className) = Typecho_Plugin::portal($pluginName, __TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_PLUGIN_DIR__);
$info = Typecho_Plugin::parseInfo($pluginFileName);
/** 檢測依賴信息 */
list($version, $build) = explode('/', Typecho_Common::VERSION);
if (Typecho_Plugin::checkDependence($build, $info['dependence'])) {
/** 獲取已激活插件 */
$plugins = Typecho_Plugin::export();
$activatedPlugins = $plugins['activated'];
/** 載入插件 */
require_once $pluginFileName;
/** 判斷實例化是否成功 */
if (isset($activatedPlugins[$pluginName]) || !class_exists($className) || !method_exists($className, 'activate')) {
throw new Typecho_Widget_Exception(_t('無法激活插件'), 500);
}
try {
$result = call_user_func(array($className, 'activate'));
Typecho_Plugin::activate($pluginName);
$this->update(array('value' => serialize(Typecho_Plugin::export())), $this->db->sql()->where('name = ?', 'plugins'));
} catch (Typecho_Plugin_Exception $e) {
/** 截獲異常 */
$this->widget('Widget_Notice')->set($e->getMessage(), NULL, 'error');
$this->response->goBack();
}
$form = new Typecho_Widget_Helper_Form();
call_user_func(array($className, 'config'), $form);
$personalForm = new Typecho_Widget_Helper_Form();
call_user_func(array($className, 'personalConfig'), $personalForm);
$options = $form->getValues();
$personalOptions = $personalForm->getValues();
if ($options && !$this->configHandle($pluginName, $options, true)) {
self::configPlugin($pluginName, $options);
}
if ($personalOptions && !$this->personalConfigHandle($className, $personalOptions)) {
self::configPlugin($pluginName, $personalOptions, true);
}
} else {
$result = _t('<a href="%s">%s</a> 無法在此版本的typecho下正常工作', $info['link'], $info['title']);
}
/** 設置高亮 */
$this->widget('Widget_Notice')->highlight('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();
}
示例7: 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);
}
}
}
}
}
示例8: getTemplates
/**
* 獲取當前所有自定義模板
*
* @access public
* @return array
*/
public function getTemplates()
{
$files = glob(__TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_THEME_DIR__ . '/' . $this->options->theme . '/*.php');
$result = array();
foreach ($files as $file) {
$info = Typecho_Plugin::parseInfo($file);
$file = basename($file);
if ('index.php' != $file && 'custom' == $info['title']) {
$result[$file] = $info['description'];
}
}
return $result;
}
示例9: getTemplates
/**
* 獲取當前所有自定義模板
*
* @access public
* @return array
*/
public function getTemplates()
{
$files = glob($this->options->themeFile($this->options->theme . '/category', '*.php'));
$result = array();
foreach ($files as $file) {
$info = Typecho_Plugin::parseInfo($file);
$file = basename($file);
if ('index.php' != $file && 'custom' == $info['title']) {
$result[$file] = $info['description'];
}
}
return $result;
}
示例10: 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));
}
示例11: form
/**
* 輸出表單結構
*
* @access public
* @return Typecho_Widget_Helper_Form
*/
public function form()
{
/** 構建表格 */
$form = new Typecho_Widget_Helper_Form($this->security->getIndex('/action/options-reading'), Typecho_Widget_Helper_Form::POST_METHOD);
/** 文章日期格式 */
$postDateFormat = new Typecho_Widget_Helper_Form_Element_Text('postDateFormat', NULL, $this->options->postDateFormat, _t('文章日期格式'), _t('此格式用於指定顯示在文章歸檔中的日期默認顯示格式.') . '<br />' . _t('在某些主題中這個格式可能不會生效, 因為主題作者可以自定義日期格式.') . '<br />' . _t('請參考 <a href="http://www.php.net/manual/zh/function.date.php">PHP 日期格式寫法</a>.'));
$postDateFormat->input->setAttribute('class', 'w-40 mono');
$form->addInput($postDateFormat->addRule('xssCheck', _t('請不要在日期格式中使用特殊字符')));
//首頁顯示
$frontPageParts = explode(':', $this->options->frontPage);
$frontPageType = $frontPageParts[0];
$frontPageValue = count($frontPageParts) > 1 ? $frontPageParts[1] : '';
$frontPageOptions = array('recent' => _t('顯示最新發布的文章'));
$frontPattern = '</label></span><span class="multiline front-archive%class%">' . '<input type="checkbox" id="frontArchive" name="frontArchive" value="1"' . ($this->options->frontArchive && 'recent' != $frontPageType ? ' checked' : '') . ' />
<label for="frontArchive">' . _t('同時將文章列表頁路徑更改為 %s', '<input type="text" name="archivePattern" class="w-20 mono" value="' . htmlspecialchars($this->decodeRule($this->options->routingTable['archive']['url'])) . '" />') . '</label>';
// 頁麵列表
$pages = $this->db->fetchAll($this->db->select('cid', 'title')->from('table.contents')->where('type = ?', 'page')->where('status = ?', 'publish')->where('created < ?', $this->options->gmtTime));
if (!empty($pages)) {
$pagesSelect = '<select name="frontPagePage" id="frontPage-frontPagePage">';
foreach ($pages as $page) {
$selected = '';
if ('page' == $frontPageType && $page['cid'] == $frontPageValue) {
$selected = ' selected="true"';
}
$pagesSelect .= '<option value="' . $page['cid'] . '"' . $selected . '>' . $page['title'] . '</option>';
}
$pagesSelect .= '</select>';
$frontPageOptions['page'] = _t('使用 %s 頁麵作為首頁', '</label>' . $pagesSelect . '<label for="frontPage-frontPagePage">');
$selectedFrontPageType = 'page';
}
// 自定義文件列表
$files = glob($this->options->themeFile($this->options->theme, '*.php'));
$filesSelect = '';
foreach ($files as $file) {
$info = Typecho_Plugin::parseInfo($file);
$file = basename($file);
if ('index.php' != $file && 'index' == $info['title']) {
$selected = '';
if ('file' == $frontPageType && $file == $frontPageValue) {
$selected = ' selected="true"';
}
$filesSelect .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>';
}
}
if (!empty($filesSelect)) {
$frontPageOptions['file'] = _t('直接調用 %s 模板文件', '</label><select name="frontPageFile" id="frontPage-frontPageFile">' . $filesSelect . '</select><label for="frontPage-frontPageFile">');
$selectedFrontPageType = 'file';
}
if (isset($frontPageOptions[$frontPageType]) && 'recent' != $frontPageType && isset($selectedFrontPageType)) {
$selectedFrontPageType = $frontPageType;
$frontPattern = str_replace('%class%', '', $frontPattern);
}
if (isset($selectedFrontPageType)) {
$frontPattern = str_replace('%class%', ' hidden', $frontPattern);
$frontPageOptions[$selectedFrontPageType] .= $frontPattern;
}
$frontPage = new Typecho_Widget_Helper_Form_Element_Radio('frontPage', $frontPageOptions, $frontPageType, _t('站點首頁'));
$form->addInput($frontPage->multiMode());
/** 文章列表數目 */
$postsListSize = new Typecho_Widget_Helper_Form_Element_Text('postsListSize', NULL, $this->options->postsListSize, _t('文章列表數目'), _t('此數目用於指定顯示在側邊欄中的文章列表數目.'));
$postsListSize->input->setAttribute('class', 'w-20');
$form->addInput($postsListSize->addRule('isInteger', _t('請填入一個數字')));
/** 每頁文章數目 */
$pageSize = new Typecho_Widget_Helper_Form_Element_Text('pageSize', NULL, $this->options->pageSize, _t('每頁文章數目'), _t('此數目用於指定文章歸檔輸出時每頁顯示的文章數目.'));
$pageSize->input->setAttribute('class', 'w-20');
$form->addInput($pageSize->addRule('isInteger', _t('請填入一個數字')));
/** FEED全文輸出 */
$feedFullText = new Typecho_Widget_Helper_Form_Element_Radio('feedFullText', array('0' => _t('僅輸出摘要'), '1' => _t('全文輸出')), $this->options->feedFullText, _t('聚合全文輸出'), _t('如果你不希望在聚合中輸出文章全文,請使用僅輸出摘要選項.') . '<br />' . _t('摘要的文字取決於你在文章中使用分隔符的位置.'));
$form->addInput($feedFullText);
/** 提交按鈕 */
$submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存設置'));
$submit->input->setAttribute('class', 'btn primary');
$form->addItem($submit);
return $form;
}
示例12: form
/**
* 輸出表單結構
*
* @access public
* @return Typecho_Widget_Helper_Form
*/
public function form()
{
/** 構建表格 */
$form = new Typecho_Widget_Helper_Form(Typecho_Common::url('/action/options-reading', $this->options->index), Typecho_Widget_Helper_Form::POST_METHOD);
/** 文章日期格式 */
$postDateFormat = new Typecho_Widget_Helper_Form_Element_Text('postDateFormat', NULL, $this->options->postDateFormat, _t('文章日期格式'), _t('此格式用於指定顯示在文章歸檔中的日期默認顯示格式.<br />
在某些主題中這個格式可能不會生效, 因為主題作者可以自定義日期格式.<br />
請參考<a href="http://cn.php.net/manual/zh/function.date.php">PHP日期格式寫法</a>.'));
$form->addInput($postDateFormat);
//首頁顯示
$frontPageParts = explode(':', $this->options->frontPage);
$frontPageType = $frontPageParts[0];
$frontPageValue = count($frontPageParts) > 1 ? $frontPageParts[1] : '';
$frontPageOptions = array('recent' => _t('顯示最新發布的文章'));
// 頁麵列表
$pages = $this->db->fetchAll($this->db->select('cid', 'title')->from('table.contents')->where('type = ?', 'page')->where('status = ?', 'publish')->where('created < ?', $this->options->gmtTime));
if (!empty($pages)) {
$pagesSelect = '<select name="frontPagePage" id="frontPage-frontPagePage">';
foreach ($pages as $page) {
$selected = '';
if ('page' == $frontPageType && $page['cid'] == $frontPageValue) {
$selected = ' selected="true"';
}
$pagesSelect .= '<option value="' . $page['cid'] . '"' . $selected . '>' . $page['title'] . '</option>';
}
$pagesSelect .= '</select>';
$frontPageOptions['page'] = _t('使用 %s 頁麵作為首頁', '</label>' . $pagesSelect . '<label for="frontPage-frontPagePage">');
}
// 自定義文件列表
$files = glob(__TYPECHO_ROOT_DIR__ . '/' . __TYPECHO_THEME_DIR__ . '/' . $this->options->theme . '/*.php');
$filesSelect = '';
foreach ($files as $file) {
$info = Typecho_Plugin::parseInfo($file);
$file = basename($file);
if ('index.php' != $file && 'index' == $info['title']) {
$selected = '';
if ('file' == $frontPageType && $file == $frontPageValue) {
$selected = ' selected="true"';
}
$filesSelect .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>';
}
}
if (!empty($filesSelect)) {
$frontPageOptions['file'] = _t('直接調用 %s 模板文件', '</label><select name="frontPageFile" id="frontPage-frontPageFile">' . $filesSelect . '</select><label for="frontPage-frontPageFile">');
}
$frontPage = new Typecho_Widget_Helper_Form_Element_Radio('frontPage', $frontPageOptions, $frontPageType, _t('站點首頁'));
$form->addInput($frontPage->multiMode());
/** 文章列表數目 */
$postsListSize = new Typecho_Widget_Helper_Form_Element_Text('postsListSize', NULL, $this->options->postsListSize, _t('文章列表數目'), _t('此數目用於指定顯示在側邊攔中的文章列表數目.'));
$postsListSize->input->setAttribute('class', 'mini');
$form->addInput($postsListSize->addRule('isInteger', _t('請填入一個數字')));
/** 每頁文章數目 */
$pageSize = new Typecho_Widget_Helper_Form_Element_Text('pageSize', NULL, $this->options->pageSize, _t('每頁文章數目'), _t('此數目用於指定文章歸檔輸出時每頁顯示的文章數目.'));
$pageSize->input->setAttribute('class', 'mini');
$form->addInput($pageSize->addRule('isInteger', _t('請填入一個數字')));
/** FEED全文輸出 */
$feedFullText = new Typecho_Widget_Helper_Form_Element_Radio('feedFullText', array('0' => _t('僅輸出摘要'), '1' => _t('全文輸出')), $this->options->feedFullText, _t('聚合全文輸出'), _t('如果你不希望在聚合中輸出文章全文,請使用僅輸出摘要選項.<br />
摘要的文字取決於你在文章中使用分隔符的位置.'));
$form->addInput($feedFullText);
/** 提交按鈕 */
$submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存設置'));
$form->addItem($submit);
return $form;
}
示例13: 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);
}
}
}
}
}