/** * 构造函数,初始化组件 * * @access public * @param mixed $request request对象 * @param mixed $response response对象 * @param mixed $params 参数列表 */ public function __construct($request, $response, $params = NULL) { //设置函数内部对象 $this->request = $request; $this->response = $response; $this->parameter = new Typecho_Config(); if (!empty($params)) { $this->parameter->setDefault($params); } }
/** * 列出评论 * * @access private * @param mixed $singleCommentOptions 单个评论自定义选项 * @return void */ public function listComments($singleCommentOptions = NULL) { //初始化一些变量 $this->_singleCommentOptions = Typecho_Config::factory($singleCommentOptions); $this->_singleCommentOptions->setDefault(array('before' => '<ol class="comment-list">', 'after' => '</ol>', 'beforeAuthor' => '', 'afterAuthor' => '', 'beforeDate' => '', 'afterDate' => '', 'dateFormat' => $this->options->commentDateFormat, 'replyWord' => '<button type="button" id="reply-button" class="btn btn-danger btn-xs mdi-content-reply reply-button"><div class="ripple-wrapper"></div></button>', 'commentStatus' => _t('您的评论正等待审核!'), 'avatarSize' => 32, 'defaultAvatar' => NULL)); $this->pluginHandle()->trigger($plugged)->listComments($this->_singleCommentOptions, $this); if (!$plugged) { if ($this->have()) { echo $this->_singleCommentOptions->before; while ($this->next()) { $this->threadedCommentsCallback(); } echo $this->_singleCommentOptions->after; } } }
/** * treeViewCategories * * @param $categoryOptions 输出选项 * @access public * @return void */ public function listCategories($categoryOptions = NULL) { //初始化一些变量 $this->_categoryOptions = Typecho_Config::factory($categoryOptions); $this->_categoryOptions->setDefault(array('wrapTag' => 'ul', 'wrapClass' => '', 'itemTag' => 'li', 'itemClass' => '', 'showCount' => false, 'showFeed' => false, 'countTemplate' => '(%d)', 'feedTemplate' => '<a href="%s">RSS</a>')); // 插件插件接口 $this->pluginHandle()->trigger($plugged)->listCategories($this->_categoryOptions, $this); if (!$plugged) { $this->stack = $this->getCategories($this->_top); if ($this->have()) { echo '<' . $this->_categoryOptions->wrapTag . (empty($this->_categoryOptions->wrapClass) ? '' : ' class="' . $this->_categoryOptions->wrapClass . '"') . '>'; while ($this->next()) { $this->treeViewCategoriesCallback(); } echo '</' . $this->_categoryOptions->wrapTag . '>'; } $this->stack = $this->_map; } }
/** * 列出回响 * * @access private * @param mixed $singlePingOptions 单个回响自定义选项 * @return void */ public function listPings($singlePingOptions = NULL) { if ($this->have()) { //初始化一些变量 $parsedSinglePingOptions = Typecho_Config::factory($singlePingOptions); $parsedSinglePingOptions->setDefault(array('before' => '<ol class="ping-list">', 'after' => '</ol>', 'beforeTitle' => '', 'afterTitle' => '', 'beforeDate' => '', 'afterDate' => '', 'dateFormat' => $this->options->commentDateFormat)); echo $parsedSinglePingOptions->before; while ($this->next()) { $this->singlePingCallback($parsedSinglePingOptions); } echo $parsedSinglePingOptions->after; } }
/** * 列出评论 * * @access private * @param mixed $singleCommentOptions 单个评论自定义选项 * @return void */ public function listComments($singleCommentOptions = NULL) { //初始化一些变量 $this->_singleCommentOptions = Typecho_Config::factory($singleCommentOptions); $this->_singleCommentOptions->setDefault(array('before' => '', 'after' => '', 'beforeAuthor' => '', 'afterAuthor' => '', 'beforeDate' => '', 'afterDate' => '', 'dateFormat' => $this->options->commentDateFormat, 'replyWord' => _t('<i class="fa fa-reply"></i>'), 'commentStatus' => _t('回复待审核'), 'avatarSize' => 32, 'defaultAvatar' => NULL)); $this->pluginHandle()->trigger($plugged)->listComments($this->_singleCommentOptions, $this); if (!$plugged) { if ($this->have()) { echo $this->_singleCommentOptions->before; while ($this->next()) { $this->threadedCommentsCallback(); } echo $this->_singleCommentOptions->after; } } }
/** * 为多数据库提供支持 * * @access public * @param Typecho_Db $db 数据库实例 * @param integer $op 数据库操作 * @return void */ public function addServer($config, $op) { $this->_config[] = Typecho_Config::factory($config); $key = count($this->_config) - 1; /** 将连接放入池中 */ switch ($op) { case self::READ: case self::WRITE: $this->_pool[$op][] = $key; break; default: $this->_pool[self::READ][] = $key; $this->_pool[self::WRITE][] = $key; break; } }
/** * 标签云 * @params string 配置字符串 * @format string 格式化输出 * @return void */ public static function tagCloud($params = null, $format = '<a href="{permalink}" style="{fontsize};{color};" title="{count}篇文章">{name}</a>') { Typecho_Widget::widget('Widget_Metas_Tag_Cloud', $params)->to($tags); $list = $counts = array(); while ($tags->next()) { $list[] = array('mid' => $tags->mid, 'name' => $tags->name, 'permalink' => $tags->permalink, 'count' => $tags->count); $counts[] = $tags->count; } if (empty($counts)) { echo '暂无标签'; return; } $min_count = min($counts); $spread = max($counts) - $min_count; $params = new Typecho_Config($params); $params->setDefault(array('smallest' => 8, 'largest' => 22, 'unit' => 'pt')); if ($spread <= 0) { $spread = 1; } $font_spread = $params->largest - $params->smallest; if ($font_spread < 0) { $font_spread = 1; } $font_step = $font_spread / $spread; $html = ''; foreach ($list as $tag) { $color = 'color:#' . self::randColor(); $fontsize = 'font-size:' . ($params->smallest + ($tag['count'] - $min_count) * $font_step) . $params->unit; $html .= str_replace(array('{name}', '{permalink}', '{count}', '{fontsize}', '{color}'), array($tag['name'], $tag['permalink'], $tag['count'], $fontsize, $color), $format); } echo $html; }
/** * 列出评论 * * @access private * @param mixed $singleCommentOptions 单个评论自定义选项 * @return void */ public function listComments($singleCommentOptions = NULL) { if ($this->have()) { //初始化一些变量 $parsedSingleCommentOptions = Typecho_Config::factory($singleCommentOptions); $parsedSingleCommentOptions->setDefault(array('before' => '<ol class="comment-list">', 'after' => '</ol>', 'beforeAuthor' => '', 'afterAuthor' => '', 'beforeDate' => '', 'afterDate' => '', 'dateFormat' => $this->options->commentDateFormat, 'replyWord' => _t('回复'), 'commentStatus' => _t('您的评论正等待审核!'), 'avatarSize' => 32, 'defaultAvatar' => NULL)); echo $parsedSingleCommentOptions->before; while ($this->next()) { $this->threadedCommentsCallback($parsedSingleCommentOptions); } echo $parsedSingleCommentOptions->after; } }
public function listNodes($nodeOptions = NULL) { $this->_nodeOptions = Typecho_Config::factory($nodeOptions); $this->_nodeOptions->setDefault(array('node' => '<a href="{permalink}">{name}</a>', 'cate' => '', 'cateBefore' => '', 'cateAfter' => '', 'isBefore' => 0)); $this->stack = $this->getCategories($this->_top); if ($this->have()) { while ($this->next()) { $this->treeViewNodesCallback(); } } $this->stack = $this->_map; }