Exemplo n.º 1
0
 public static function install()
 {
     $configLink = '<a href="' . Helper::options()->adminUrl . 'options-plugin.php?config=Access' . '">请设置</a>';
     if (substr(trim(dirname(__FILE__), '/'), -6) != 'Access') {
         throw new Typecho_Plugin_Exception('插件目录名必须为Access');
     }
     $installDb = Typecho_Db::get();
     $type = explode('_', $installDb->getAdapterName());
     $type = array_pop($type);
     $prefix = $installDb->getPrefix();
     $scripts = "CREATE TABLE `typecho_access` (\r\n  `id` int(10) unsigned NOT NULL auto_increment,\r\n  `ua` varchar(255) default NULL,\r\n  `url` varchar(64) default NULL,\r\n  `ip` varchar(16) default NULL,\r\n  `referer` varchar(255) default NULL,\r\n  `referer_domain` varchar(100) default NULL,\r\n  `date` int(10) unsigned default '0',\r\n  PRIMARY KEY  (`id`)\r\n) ENGINE=MYISAM  DEFAULT CHARSET=%charset%;";
     $scripts = str_replace('typecho_', $prefix, $scripts);
     $scripts = str_replace('%charset%', 'utf8', $scripts);
     $scripts = explode(';', $scripts);
     try {
         foreach ($scripts as $script) {
             $script = trim($script);
             if ($script) {
                 $installDb->query($script, Typecho_Db::WRITE);
             }
         }
         return '成功创建数据表,插件启用成功,' . $configLink;
     } catch (Typecho_Db_Exception $e) {
         $code = $e->getCode();
         if ('Mysql' == $type && $code == (1050 || '42S01')) {
             $script = 'SELECT * from `' . $prefix . 'access`';
             $installDb->query($script, Typecho_Db::READ);
             return '数据表已存在,插件启用成功,' . $configLink;
         } else {
             throw new Typecho_Plugin_Exception('数据表建立失败,插件启用失败。错误号:' . $code);
         }
     }
 }
Exemplo n.º 2
0
    public static function show()
    {
        $curl = curl_init(Helper::options()->index . "/action/ajax?do=checkVersion");
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        $version = json_decode(curl_exec($curl), true);
        curl_close($curl);
        if (!$version['avaliable']) {
            $url = Helper::options()->index . "/update/zero";
            ?>
            <script>
            window.onload = function() {
                document.querySelector(".update-check strong") && (document.querySelector(".update-check strong").innerHTML += '<a href="<?php 
            echo $url;
            ?>
" class="update message error" style="margin-left:15px;">升级到新版!</a>');
            }
            </script>
            <style>
            .update-check a.update {
                padding:5px 10px;
            }
            .update-check a.update:hover {
                color:#8A1F11!important;
                text-decoration:underline;
            }
            </style>
            <?php 
        }
    }
Exemplo n.º 3
0
 /**
  * 插件实现方法
  * 
  * @access public
  * @return void
  */
 public static function render($post)
 {
     $options = Helper::options();
     $js = Typecho_Common::url('TinyMCE/tiny_mce/tiny_mce.js', $options->pluginUrl);
     $langs = Typecho_Common::url('extending.php?panel=TinyMCE/tiny_mce/langs.php', $options->adminUrl);
     echo "<script type=\"text/javascript\" src=\"{$js}\"></script>\n<script type=\"text/javascript\" src=\"{$langs}\"></script>\n<script type=\"text/javascript\">\n    var insertImageToEditor = function (title, url, link) {\n        tinyMCE.activeEditor.execCommand('mceInsertContent', false,\n        '<a href=\"' + link + '\" title=\"' + title + '\"><img src=\"' + url + '\" alt=\"' + title + '\" /></a>');\n        new Fx.Scroll(window).toElement(\$(document).getElement('.mceEditor'));\n    };\n    \n    var insertLinkToEditor = function (title, url, link) {\n        tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href=\"' + url + '\" title=\"' + title + '\">' + title + '</a>');\n        new Fx.Scroll(window).toElement(\$(document).getElement('.mceEditor'));\n    };\n\n    //自动保存\n    var autoSave;\n    \n    tinyMCE.init({\n    // General options\n    mode : 'exact',\n    elements : 'text',\n    theme : 'advanced',\n    skin : 'typecho',\n    plugins : 'safari,morebreak,inlinepopups,media,coder',\n    extended_valid_elements : 'code[*],pre[*],script[*],iframe[*]',\n    \n    init_instance_callback : function(ed) {\n        \n        ed.setContent(\"" . str_replace(array("\n", "\r"), array("\\n", ""), addslashes($post->content)) . "\");\n        " . ($options->autoSave ? "autoSave = new Typecho.autoSave(\$('text').getParent('form').getProperty('action'), {\n            time: 60,\n            getContentHandle: tinyMCE.activeEditor.getContent.bind(ed),\n            messageElement: 'auto-save-message',\n            leaveMessage: '" . _t('您的内容尚未保存, 是否离开此页面?') . "',\n            form: \$('text').getParent('form')\n        });" : "") . "\n    },\n    \n    onchange_callback: function (inst) {\n        if ('undefined' != typeof(autoSave)) {\n            autoSave.onContentChange();\n        }\n    },\n    \n    save_callback: function (element_id, html, body) {\n        if ('undefined' != typeof(autoSave)) {\n            autoSave.saveRev = autoSave.rev;\n        }\n        \n        return html;\n    },\n    \n    // Theme options\n    theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,blockquote,|,link,unlink,image,media,|,forecolor,backcolor,|,morebreak,code',\n    theme_advanced_buttons2 : '',\n    theme_advanced_buttons3 : '',\n    theme_advanced_toolbar_location : 'top',\n    theme_advanced_toolbar_align : 'left',\n    convert_urls : false,\n    language : 'typecho'\n});\n</script>";
 }
Exemplo n.º 4
0
    public static function Change()
    {
        $options = Helper::options();
        $cssUrl = Typecho_Common::url('LREditor/lr.css', $options->pluginUrl);
        $jsUrl = Typecho_Common::url('LREditor/prettify.js', $options->pluginUrl);
        echo '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" />';
        echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
        ?>

 		<script>
            function prettify() {
                $("pre").addClass("prettyprint");
                prettyPrint();
            }
 			$(function() {
 				setInterval("$('#wmd-preview').css('height', (parseInt($('#text').height()) - 5)+'px');", 500);
                setInterval("prettify()", 10);

 				//Typecho.editorResize('wmd-preview', '<?php 
        $options->index('/action/ajax?do=editorResize');
        ?>
');
 				//$('#wmd-preview').remove();
 				//$('textarea').after('<div id="wmd-preview"></div>');
 			});
 		</script>
 		<?php 
    }
Exemplo n.º 5
0
 /**
  * 底部脚本
  *
  * @access public
  * @param unknown $footlink
  * @return unknown
  */
 public static function footlink($links)
 {
     $settings = Helper::options()->plugin('Prism');
     $url = Helper::options()->pluginUrl . '/Prism/';
     $links = '<script type="text/javascript" src="' . $url . 'js/prism.js"></script>';
     echo $links;
 }
Exemplo n.º 6
0
 /**
  * 输出尾部js
  * 
  * @access public
  * @param unknown $footer
  * @return unknown
  */
 public static function footer()
 {
     $jsUrl = Helper::options()->pluginUrl . '/LaTex/latex.js';
     echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
     $mark = Typecho_Widget::widget('Widget_Options')->plugin('LaTex')->mark;
     echo '<script type="text/javascript">latex.parse("' . $mark . '");</script>';
 }
Exemplo n.º 7
0
 /**
  * 插件实现方法
  * 
  * @access public
  * @return void
  */
 public static function render()
 {
     $options = Helper::options();
     echo '<a href="';
     $options->adminUrl('extending.php?panel=DevTool%2Findex.php');
     echo '">' . self::NAME . '</a>';
 }
Exemplo n.º 8
0
 /**
  * 输出尾部js
  * 
  * @access public
  * @param unknown $header
  * @return unknown
  */
 public static function footer()
 {
     $jsUrl = Helper::options()->pluginUrl . '/GoogleCodePrettify/src/prettify.js';
     echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
     echo '<script type="text/javascript">window.onload = function () {
         prettyPrint();
     }</script>';
 }
Exemplo n.º 9
0
 public static function insertScript()
 {
     if (self::$flag) {
         echo "\n<script type=\"text/javascript\">\nvar ymplayer_params = " . json_encode(array('url' => Helper::options()->index . '/ymplayer.json', 'song_id' => self::$song_id)) . ";\n</script>";
         echo "\n<script src=\"" . Helper::options()->pluginUrl . "/ymplayer/dist/ymplayer.min.js\"></script>";
         echo "\n<script src=\"" . Helper::options()->pluginUrl . "/ymplayer/init.js\"></script>";
     }
 }
Exemplo n.º 10
0
 public static function footer()
 {
     if (Helper::options()->plugin('Prismjs')->showln) {
         echo "<script>var pres = document.getElementsByTagName('pre');\n                for (var i = 0; i < pres.length; i++)\n                    if (pres[i].getElementsByTagName('code').length > 0)\n                        pres[i].className  = 'line-numbers';\n                </script>";
     }
     $jsUrl = Helper::options()->pluginUrl . '/Prismjs/prism.js';
     echo '<script src="' . $jsUrl . '"></script>';
 }
Exemplo n.º 11
0
 public static function footer()
 {
     if (Helper::options()->plugin('GithubWidgetUser')->jq_import) {
         echo '<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>';
     }
     $jsUrl = Helper::options()->pluginUrl . '/GithubWidgetUser/jquery-github-user-widget.js';
     echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
 }
Exemplo n.º 12
0
 /**
  *  是否已经获取到了token,未获取则显示获取token的图标,否则显示当前登录账号
  *
  * @access public
  * @param 
  * @return string
  */
 public static function SinaAuth()
 {
     self::getPubFile();
     $sina_auth = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
     $authurl = $sina_auth->getAuthorizeURL(WB_CALLBACK_URL, 'code');
     $img_path = Helper::options()->pluginUrl . '/WeiboSync/weibo.png';
     echo $sina_profile = '<ul class="typecho-option"><li><a href="' . $authurl . '"><img src="' . $img_path . '"></a>&nbsp;&nbsp;<b>点击左边图标获取微博Access_token信息</b></li></ul>';
 }
Exemplo n.º 13
0
 public function action()
 {
     /** 验证合法性 */
     if (!isset($_SERVER['HTTP_GOOGLE_CODE_PROJECT_HOSTING_HOOK_HMAC'])) {
         return;
     }
     $googleSecretInfo = $_SERVER['HTTP_GOOGLE_CODE_PROJECT_HOSTING_HOOK_HMAC'];
     $revisionData = file_get_contents('php://input');
     if (empty($revisionData)) {
         return;
     }
     $secretVerify = hash_hmac("md5", $revisionData, Helper::options()->plugin('GoogleCodeSVN')->secretKey);
     if ($googleSecretInfo != $secretVerify) {
         return;
     }
     $data = Typecho_Json::decode($revisionData);
     if (!$data) {
         return;
     }
     /** 登录用户 */
     $master = $this->db->fetchRow($this->db->select()->from('table.users')->where('group = ?', 'administrator')->order('uid', Typecho_Db::SORT_ASC)->limit(1));
     if (empty($master)) {
         return false;
     } else {
         if (!$this->user->simpleLogin($master['uid'])) {
             return false;
         }
     }
     if (isset($data->revisions) && is_array($data->revisions)) {
         foreach ($data->revisions as $revision) {
             if (!empty($revision->added)) {
                 foreach ($revision->added as $file) {
                     $input = $this->parseFileName($file, $data->repository_path);
                     if ($input) {
                         $this->widget('Widget_Contents_Post_Edit', NULL, $input, false)->action();
                     }
                 }
             }
             if (!empty($revision->modified)) {
                 foreach ($revision->modified as $file) {
                     $input = $this->parseFileName($file, $data->repository_path);
                     if ($input) {
                         $this->widget('Widget_Contents_Post_Edit', NULL, $input, false)->action();
                     }
                 }
             }
             if (!empty($revision->removed)) {
                 foreach ($revision->removed as $file) {
                     $input = $this->parseFileName($file, $data->repository_path);
                     if ($input && isset($input['cid'])) {
                         $postId = $input['cid'];
                         $this->widget('Widget_Contents_Post_Edit', NULL, "cid={$postId}", false)->deletePost();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 14
0
 /**
  * 插件实现方法
  * 
  * @access public
  * @return void
  */
 public static function render($post)
 {
     $options = Helper::options();
     $plugin_options = Typecho_Widget::widget('Widget_Options')->plugin('KEditor');
     $newlineTag = $plugin_options->newlineTag;
     $themesTab = $plugin_options->themesTab;
     $editor_path = Typecho_Common::url('KEditor/editor', $options->pluginUrl);
     echo "\n<script type=\"text/javascript\" charset=\"utf-8\" src=\"{$editor_path}/kindeditor.js\"></script> \n<script type=\"text/javascript\">\n    KE.show({\n\t\tresizeMode : 1,\n\t    themesPath : '{$themesTab}',\n\t\tlangPath : 'zh_CN',\n\t    newlineTag : '{$newlineTag}',\n        id : 'text'\n    });\n\t\$('btn-save').addEvent('mouseover', function (e) {\n\t\tKE.util.setData('text'); \n\t});\n\t\$('btn-submit').addEvent('mouseover', function (e) {\n\t\tKE.util.setData('text'); \n\t});\n    function insertHtml(id, html) {\n        KE.util.focus(id);\n        KE.util.selection(id);\n        KE.util.insertHtml(id, html);\n    }\n    /** 附件插入实现 */\n    var insertImageToEditor = function (title, url, link) {\n        insertHtml('text', '<a href=\"' + link + '\" title=\"' + title + '\"><img src=\"' + url + '\" alt=\"' + title + '\" /></a>');\n    };\n    var insertLinkToEditor = function (title, url, link) {\n        insertHtml('text', '<a href=\"' + url + '\" title=\"' + title + '\">' + title + '</a>');\n    };\n</script>";
 }
Exemplo n.º 15
0
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     $this->_db = Typecho_Db::get();
     $this->_dir = '.' . __TYPECHO_PLUGIN_DIR__ . '/CommentToMail/';
     $this->_set = Helper::options()->plugin('CommentToMail');
     require_once $this->_dir . 'class.phpmailer.php';
     $this->mail = new PHPMailer();
 }
Exemplo n.º 16
0
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     $this->db = Typecho_Db::get();
     $this->options = Helper::options();
     //$this->pluginRootUrl = Typecho_Common::url('Api/', $this->options->pluginUrl);
     require_once 'Twig/Autoloader.php';
     Twig_Autoloader::register();
 }
Exemplo n.º 17
0
 /**
  * 输出头部css
  * 
  * @access public
  * @param unknown $header
  * @return unknown
  */
 public static function header()
 {
     $config = Helper::options()->plugin('GoogleCodePrettify');
     $type = $config->type ? $config->type : 'desert';
     $custom = $config->custom;
     $cssUrl = Helper::options()->pluginUrl . '/GoogleCodePrettify/src/' . $type . '.css';
     echo '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" />';
     if ($custom != '') {
         echo "<style type=\"text/css\">{$custom}</style>";
     }
 }
Exemplo n.º 18
0
 public static function uninstall()
 {
     //删除路由
     Helper::removeRoute('baidu_sitemap');
     Helper::removeRoute('baidu_sitemap_advanced');
     Helper::removePanel(1, 'BaiduSubmit/Logs.php');
     //获取配置,是否删除数据表
     if (Helper::options()->plugin('BaiduSubmit')->delete == 1) {
         return self::remove_table();
     }
 }
function url_target_replace($content)
{
    preg_match_all('/href="(.*?)"/', $content, $matches);
    if ($matches) {
        foreach ($matches[1] as $val) {
            if (strpos($val, Helper::options()->siteUrl) === false) {
                $content = str_replace("href=\"{$val}\"", "target=\"_blank\" href=\"" . $val . "\"", $content);
            }
        }
    }
    return $content;
}
Exemplo n.º 20
0
function gravatar_url($mail, $size, $echo = true)
{
    $rating = Helper::options()->commentsAvatarRating;
    $Request = new Typecho_Request();
    $default = null;
    $url = Typecho_Common::gravatarUrl($mail, $size, $rating, $default, $Request->isSecure());
    if ($echo) {
        echo $url;
    } else {
        return $url;
    }
}
Exemplo n.º 21
0
    /**
     * 插件实现方法
     * 
     * @access public
     * @return void
     */
    public static function render()
    {
        $options = Helper::options();
        $cssUrl = Typecho_Common::url('EditorLR/lr.css', $options->pluginUrl);
        $jsUrl = Typecho_Common::url('EditorLR/prettify.js', $options->pluginUrl);
        $lrjs = Typecho_Common::url('EditorLR/lr.js', $options->pluginUrl);
        echo <<<HTML
            <link rel="stylesheet" type="text/css" href="{$cssUrl}" />
            <script type="text/javascript" src="{$jsUrl}"></script>
            <script type="text/javascript" src="{$lrjs}"></script>
HTML;
    }
Exemplo n.º 22
0
    public static function render()
    {
        $jsUrl = Helper::options()->pluginUrl . '/LaTex/latex.js';
        echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
        $mark = Typecho_Widget::widget('Widget_Options')->plugin('LaTex')->mark;
        //echo '<script type="text/javascript">setTimeout(function(){latex.parse("'. $mark. '");alert("333");},400);</script>';
        $html = <<<HTML
        <script type="text/javascript">
            setInterval(function() {
                latex.parse("{$mark}");
            }, 50);
        </script>
HTML;
        echo $html;
    }
Exemplo n.º 23
0
 public function action()
 {
     /** 防止跨站 */
     $referer = $this->request->getReferer();
     if (empty($referer)) {
         exit;
     }
     $refererPart = parse_url($referer);
     $currentPart = parse_url(Helper::options()->siteUrl);
     if ($refererPart['host'] != $currentPart['host'] || 0 !== strpos($refererPart['path'], $currentPart['path'])) {
         exit;
     }
     require_once 'Captcha/securimage/securimage.php';
     $img = new securimage();
     $dir = dirname(__FILE__) . '/securimage/';
     $options = Typecho_Widget::widget('Widget_Options');
     $fontsArray = array('04b03.ttf', 'AHGBold.ttf', 'atkinsoutlinemedium-regular.ttf', 'decorative-stylisticblackout-regular.ttf', 'okrienhmk.ttf', 'ttstepha.ttf', 'vtckomixationhand.ttf');
     $fontsKey = array_rand($fontsArray);
     $fontsFile = $dir . 'fonts/' . $fontsArray[$fontsKey];
     //验证码字体
     $fontsFile = $dir . 'fonts/' . $options->plugin('Captcha')->ttf_file;
     $img->ttf_file = $fontsFile;
     //验证码背景
     if ($options->plugin('Captcha')->is_background) {
         $img->background_directory = $dir . '/backgrounds/';
     }
     //背景颜色
     $img->image_bg_color = new Securimage_Color($options->plugin('Captcha')->image_bg_color);
     //验证码颜色
     $img->text_color = new Securimage_Color($options->plugin('Captcha')->text_color);
     //自定义验证码
     $img->use_wordlist = $options->plugin('Captcha')->use_wordlist;
     $img->wordlist = explode("\n", $options->plugin('Captcha')->wordlist);
     $img->wordlist_file = $dir . 'words/words.txt';
     //干扰线颜色
     $img->line_color = new Securimage_Color($options->plugin('Captcha')->line_color);
     //干扰线、扭曲度
     $img->num_lines = $options->plugin('Captcha')->num_lines;
     $img->perturbation = $options->plugin('Captcha')->perturbation;
     //签名内容、颜色、字体
     $img->signature_color = new Securimage_Color($options->plugin('Captcha')->signature_color);
     $img->image_signature = $options->plugin('Captcha')->image_signature;
     $img->signature_font = $dir . 'fonts/' . $options->plugin('Captcha')->signature_font;
     //高度宽度
     $img->image_height = $options->plugin('Captcha')->image_height;
     $img->image_width = $options->plugin('Captcha')->image_width;
     $img->show('');
 }
Exemplo n.º 24
0
    /**
     * 插件实现方法
     * 
     * @access public
     * @return void
     */
    public static function render($post)
    {
        $options = Helper::options();
        // $plugin_options = $options->plugin('CodeMirror');
        $pluginRoot = Typecho_Common::url('CodeMirror/static', $options->pluginUrl);
        //调用编辑器
        echo <<<CODE
        <link rel="stylesheet" href="{$pluginRoot}/codemirror.css">
        <script type="text/javascript" src="{$pluginRoot}/codemirror.js"></script>
        <script>
            var editor = CodeMirror.fromTextArea(document.getElementById('content'), {
                lineNumbers: true
            });
        </script>
CODE;
    }
Exemplo n.º 25
0
    public static function Change()
    {
        $options = Helper::options();
        $jsUrl = Typecho_Common::url('Editor/editor.js', $options->pluginUrl);
        $cssUrl = Typecho_Common::url('Editor/editor.css', $options->pluginUrl);
        ?>
    	<link rel="stylesheet" href="<?php 
        echo $cssUrl;
        ?>
" />
    	<script type="text/javascript" src="http://lab.lepture.com/editor/marked.js"></script>
		<script type="text/javascript" src="<?php 
        echo $jsUrl;
        ?>
"></script>
		<script>var editor = new Editor();editor.render();</script>
    	<?php 
    }
Exemplo n.º 26
0
function themeConfig($form)
{
    $siteUrl = Helper::options()->siteUrl;
    $next_name = new Typecho_Widget_Helper_Form_Element_Text('next_name', NULL, '', _t('侧边栏显示的昵称'), _t('显示在头像下方'));
    $next_name->input->setAttribute('class', 'w-100 mono');
    $form->addInput($next_name);
    $next_gravatar = new Typecho_Widget_Helper_Form_Element_Text('next_gravatar', NULL, '', _t('侧边栏头像'), _t('填写Gravatar头像的邮箱地址'));
    $next_gravatar->input->setAttribute('class', 'w-100 mono');
    $form->addInput($next_gravatar->addRule('email', '请填写一个邮箱地址'));
    $next_tips = new Typecho_Widget_Helper_Form_Element_Text('next_tips', NULL, '一个高端大气上档次的网站', _t('站点描述'), _t('将显示在侧边栏的昵称下方'));
    $form->addInput($next_tips);
    $next_cdn = new Typecho_Widget_Helper_Form_Element_Text('next_cdn', NULL, $siteUrl, _t('cdn镜像地址'), _t('静态文件cdn镜像加速地址,加速js和css,如七牛,又拍云等<br>格式参考:' . $siteUrl . '<br>不用请留空或者保持默认'));
    $form->addInput($next_cdn);
    $sidebar = new Typecho_Widget_Helper_Form_Element_Radio('sidebar', array(_t('始终自动弹出'), _t('文章中有目录时弹出'), _t('不自动弹出')), 1, _t('侧边栏自动弹出设置'));
    $form->addInput($sidebar);
    $search_form = new Typecho_Widget_Helper_Form_Element_Checkbox('search_form', array('ShowSearch' => _t('显示搜索框'), 'ShowFeed' => _t('显示RSS订阅')), array('ShowSearch', 'ShowFeed'), _t('其他设置'));
    $form->addInput($search_form->multiMode());
}
Exemplo n.º 27
0
 /**
  * 插件实现方法
  * 
  * @access public
  * @return void
  */
 public static function parse($text, $widget, $lastResult)
 {
     $text = empty($lastResult) ? $text : $lastResult;
     $settings = Helper::options()->plugin('Textile2');
     if ($settings->version == 'Textile') {
         $textile = new Textile();
     } else {
         $textile = new MTLikeTextile();
     }
     $textile->options['head_offset'] = $settings->headerOffset;
     $textile->options['char_encoding'] = $settings->encoding;
     $textile->options['input_encoding'] = $settings->inputEncoding;
     $textile->options['do_quotes'] = $settings->filters && in_array('EducateQuotes', $settings->filters);
     $textile->options['smarty_mode'] = $settings->filters && in_array('SmartyPants', $settings->filters);
     $textile->options['trim_spaces'] = $settings->parsing && in_array('ClearLines', $settings->parsing);
     $textile->options['preserve_spaces'] = $settings->parsing && in_array('PreserveSpaces', $settings->parsing);
     return $textile->process($text);
 }
Exemplo n.º 28
0
function themeConfig($form)
{
    $siteUrl = Helper::options()->siteUrl;
    $next_name = new Typecho_Widget_Helper_Form_Element_Text('next_name', NULL, '', _t('侧边栏显示的昵称'));
    $next_name->input->setAttribute('class', 'w-100 mono');
    $form->addInput($next_name);
    $next_gravatar = new Typecho_Widget_Helper_Form_Element_Text('next_gravatar', NULL, '', _t('侧边栏头像'), _t('填写Gravatar头像的邮箱地址'));
    $next_gravatar->input->setAttribute('class', 'w-100 mono');
    $form->addInput($next_gravatar->addRule('email', '请填写一个邮箱地址'));
    $next_tips = new Typecho_Widget_Helper_Form_Element_Text('next_tips', NULL, '一个高端大气上档次的网站', _t('站点描述'), _t('将显示在侧边栏的昵称下方'));
    $form->addInput($next_tips);
    $next_cdn = new Typecho_Widget_Helper_Form_Element_Text('next_cdn', NULL, $siteUrl, _t('cdn镜像地址'), _t('静态文件cdn镜像加速地址,加速js和css,如七牛,又拍云等<br>格式参考:' . $siteUrl . '<br>不用请留空或者保持默认'));
    $form->addInput($next_cdn);
    $sidebarFlinks = new Typecho_Widget_Helper_Form_Element_Radio('sidebarFlinks', array('show' => _t('显示'), 'hide' => _t('不显示')), 'hide', _t('侧边栏友链设置'), _t('安装了 Hanny 的Links插件才可显示'));
    $form->addInput($sidebarFlinks);
    $sidebarNav = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarNav', array('main' => _t('首页'), 'archive' => _t('归档'), 'categories' => _t('分类'), 'tags' => _t('标签'), 'search' => _t('搜索')), array('main', 'archive', 'tags', 'search'), _t('侧边导航栏设置'));
    $form->addInput($sidebarNav->multiMode());
    $sidebarOthers = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarOthers', array('ShowFeed' => _t('显示RSS订阅')), array('ShowFeed'), _t('其他设置'));
    $form->addInput($sidebarOthers->multiMode());
}
Exemplo n.º 29
0
 /**
  * 关键词与标签替换
  * 
  * @access public
  * @param string $content
  * @return string
  */
 public static function kwparse($content, $widget, $lastResult)
 {
     $content = empty($lastResult) ? $content : $lastResult;
     $db = Typecho_Db::get();
     $settings = Helper::options()->plugin('Keywords');
     $limit = $settings->limits;
     $tagselect = $db->select()->from('table.metas')->where('type=?', 'tag');
     $tagdata = $db->fetchAll($tagselect, array($widget->widget('Widget_Abstract_Metas'), 'filter'));
     $wlsets = explode("\n", $settings->keywords);
     if (!empty($settings->keywords) && true == strchr($settings->keywords, '|')) {
         foreach ($wlsets as $wlset) {
             $wlarray = explode("|", $wlset);
             $content = preg_replace('/(?!<[^>]*)(' . $wlarray[0] . ')(?![^<]*>)/i', '<a href="' . $wlarray[1] . '" target="_blank" title="' . $wlarray[0] . '">' . $wlarray[0] . '</a>', $content, $limit);
         }
     }
     if ($tagdata && $settings->tagslink) {
         foreach ($tagdata as $tag) {
             $content = preg_replace('/(?!<[^>]*)(' . $tag['name'] . ')(?![^<]*>)/i', '<a href="' . $tag['permalink'] . '" target="_blank" title="' . $tag['name'] . '">' . $tag['name'] . '</a>', $content, $limit);
         }
     }
     return $content;
 }
Exemplo n.º 30
0
 public static function run($archive, $select)
 {
     $db = Typecho_Db::get();
     $prefix = $db->getPrefix();
     $options = Helper::options();
     $domain = $_SERVER['HTTP_HOST'];
     $row = $db->fetchRow($db->select()->from($prefix . 'domaintheme')->where('domain = ?', $domain)->limit(1));
     if ($row) {
         $options->theme = is_dir($options->themeFile($row['theme'])) ? $row['theme'] : 'default';
         $themeDir = rtrim($options->themeFile($options->theme), '/') . '/';
         $archive->setThemeDir($themeDir);
         $options->siteUrl = (Typecho_Request::isSecure() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];
         if ($row['user']) {
             $themeOptions = json_decode($row['user'], true);
             if (is_array($themeOptions)) {
                 foreach ($themeOptions as $key => $value) {
                     $options->push(array('name' => $key, 'value' => $value));
                 }
             }
         }
     }
 }