📄 serendipity_plugin_templatedropdown.php
字号:
<?php # $Id: serendipity_plugin_templatedropdown.php,v 1.1 2004/03/03 08:18:00 garvinhicking Exp $/*******************************************************汉化作者:youngong(http://youngong.blogbus.com) **官方主页:http://www.s9y.corg **我的信箱:youngong@163.com **如果有问题,欢迎和作者及汉化作者联系。 ********************************************************/switch ($serendipity['lang']) { case 'de': @define('PLUGIN_TEMPLATEDROPDOWN_NAME', 'Template dropdown'); @define('PLUGIN_TEMPLATEDROPDOWN_DESC', 'Zeigt eine Box um Templates zu 鋘dern'); @define('PLUGIN_TEMPLATEDROPDOWN_SUBMIT', 'Submit-Button?'); @define('PLUGIN_TEMPLATEDROPDOWN_SUBMIT_DESC', 'Einen Submit-Button anzeigen?'); break; case 'cn': @define('PLUGIN_TEMPLATEDROPDOWN_NAME', '模板选择下拉菜单'); @define('PLUGIN_TEMPLATEDROPDOWN_DESC', '显示一个更换模板的菜单'); @define('PLUGIN_TEMPLATEDROPDOWN_SUBMIT', '发送按钮?'); @define('PLUGIN_TEMPLATEDROPDOWN_SUBMIT_DESC', '显示提交按钮吗?'); break; case 'en': default: @define('PLUGIN_TEMPLATEDROPDOWN_NAME', 'Template dropdown'); @define('PLUGIN_TEMPLATEDROPDOWN_DESC', 'Show a box to change templates'); @define('PLUGIN_TEMPLATEDROPDOWN_SUBMIT', 'Submit button?'); @define('PLUGIN_TEMPLATEDROPDOWN_SUBMIT_DESC', 'Show a submit button?'); break;}class serendipity_plugin_templatedropdown extends serendipity_plugin { function introspect(&$propbag) { $propbag->add('name', PLUGIN_TEMPLATEDROPDOWN_NAME); $propbag->add('description', PLUGIN_TEMPLATEDROPDOWN_DESC); $propbag->add('configuration', array('title', 'show_submit')); // Register (multiple) dependencies. KEY is the name of the depending plugin. VALUE is a mode of either 'remove' or 'keep'. // If the mode 'remove' is set, removing the plugin results in a removal of the depending plugin. 'Keep' meens to // not touch the depending plugin. $this->dependencies = array('serendipity_event_templatechooser' => 'remove'); } function introspect_config_item($name, &$propbag) { switch($name) { case 'title': $propbag->add('type', 'string'); $propbag->add('name', TITLE); $propbag->add('description', TITLE); break; case 'show_submit': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_TEMPLATEDROPDOWN_SUBMIT); $propbag->add('description', PLUGIN_TEMPLATEDROPDOWN_SUBMIT_DESC); break; default: return false; } return true; } function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $title); // All that URL getting humpty-dumpty is necessary to allow a user to change the template in the // articles view. POSTing data to that page only works with mod_rewrite and not the ErrorDocument // redirection, so we need to generate the ErrorDocument-URI here. $uri = parse_url($_SERVER['REQUEST_URI']); $qst = ''; if (!empty($uri['query'])) { $qst = '&' . str_replace('&', '&', $uri['query']); } $uri['path'] = str_replace($serendipity['serendipityHTTPPath'], '', $uri['path']); $url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?' . $uri['path'] . $qst; $url = str_replace($serendipity['indexFile'] . '&', '', $url); // Kill possible looped repitions which could occur echo '<form id="theme_chooser" action="' . $url . '" method="post">'; echo '<select name="user_template" onchange="document.getElementById(\'theme_chooser\').submit();">'; foreach (serendipity_fetchTemplates() as $template) { $templateInfo = serendipity_fetchTemplateInfo($template); echo '<option value="' . $template . '" ' . (serendipity_get_config_var('template', 'default') == $template ? 'selected="selected"' : '') . '>' . $templateInfo['name'] . '</option>'; } echo '</select>'; if ($this->get_config('show_submit', $title) == 'true') { echo '<input type="submit" name="submit" value="' . GO . '" size="4" />'; } echo '</form>'; }}/* vim: set sts=4 ts=4 expandtab : */?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -