/** * 获取文章内容 * * @access protected * @return string */ protected function ___content() { if ($this->hidden) { return $this->text; } $content = $this->pluginHandle(__CLASS__)->trigger($plugged)->content($this->text, $this); if (!$plugged) { $content = $this->isMarkdown ? MarkdownExtraExtended::defaultTransform($content) : Typecho_Common::cutParagraph($content); } return $this->pluginHandle(__CLASS__)->contentEx($content, $this); }
/** * 同步文章到新浪微博 * * @access public * @param $content $class * @return status */ public static function TsinaSync($content, $class) { //获取插件的配置 $config = self::getWeiboSyncCfg(); //如果不是文章编辑(对象$class属于Widget_Abstract_Contents,是否等于对象的值Widget_Contents_Post_Edit,它继承Widget_Abstract_Contents对象),则直接返回内容 if (!is_a($class, 'Widget_Contents_Post_Edit')) { return $content; } if ($config->sina_mode == '1') { if (!$class->request->is("do=publish") || $class->request->is("do=publish") && !$class->have()) { return $content; } } else { if (!$class->request->is("do=publish") || $class->request->is("do=publish") && !empty($class->request->cid)) { return $content; } } $format = $config->sina_format ? $config->sina_format : '我在TypeCodes上发表了一篇文章《{title}》,链接地址{link}'; $title = $content['title']; $link = self::SinaShortUrl($content['permalink']); //如果插件配置中出现了{more}标签,即需要提取文章的摘要信息 if (strpos($format, '{more}') !== false) { if (strpos($content['text'], '<!--more-->') !== false) { $more_t = explode('<!--more-->', $content['text']); list($more) = $more_t; $more = Typecho_Common::fixHtml(Typecho_Common::cutParagraph($more)); $more = Typecho_Common::subStr(strip_tags($more), 0, 60, '...'); } else { $more = $content['text']; $more = Typecho_Common::fixHtml(Typecho_Common::cutParagraph($more)); $more = Typecho_Common::subStr(strip_tags($more), 0, 60, '...'); } } else { $more = ""; } $search = array('{title}', '{link}', '{more}'); $replace = array($title, $link, $more); $format = str_replace($search, $replace, $format); $post_img = ''; if ($config->sina_imgflag) { $content_substr = mb_substr($content['text'], 0, 900, 'utf-8'); if (preg_match('/!\\[[^\\]]*]\\((https):\\/\\/[^\\)]*\\.(png|jpg)(.*)\\)/i', $content_substr, $img_match)) { if (preg_match('/(https:\\/\\/)[^>]*?\\.(png|jpg)/i', $img_match[0], $img_match_retult)) { $post_img = $img_match_retult[0]; } } } self::PostWeibo($format, $post_img); return $content; }
/** * 获取文章内容 * * @access protected * @return string */ protected function ___content() { $content = $this->pluginHandle(__CLASS__)->trigger($plugged)->content($this->text, $this); if (!$plugged) { $content = Typecho_Common::cutParagraph($content); } return $this->pluginHandle(__CLASS__)->contentEx($content, $this); }
/** * 获取当前评论内容 * * @access protected * @return string */ protected function ___content() { $text = $this->parentContent['hidden'] ? _t('内容被隐藏') : $this->text; $text = $this->pluginHandle(__CLASS__)->trigger($plugged)->content($text, $this); if (!$plugged) { $text = Typecho_Common::cutParagraph($text); } return $this->pluginHandle(__CLASS__)->contentEx($text, $this); }
/** * 获取当前评论内容 * * @access protected * @return string */ protected function ___content() { $text = $this->parentContent['hidden'] ? _t('内容被隐藏') : $this->text; $text = $this->pluginHandle(__CLASS__)->trigger($plugged)->content($text, $this); if (!$plugged) { $text = $this->options->commentsMarkdown ? MarkdownExtraExtended::defaultTransform($text) : Typecho_Common::cutParagraph($text); } $text = $this->pluginHandle(__CLASS__)->contentEx($text, $this); return Typecho_Common::stripTags($text, '<p><br>' . $this->options->commentsHTMLTagAllowed); }
/** * 稿件预览 * * @access public * @return void */ public function preview() { $cid = $this->request->filter('int')->cid; $resource = $this->_db->query($this->_db->select('text')->from('table.contribute')->where('cid = ?', $cid)->limit(1)); $result = $this->_db->fetchRow($resource); $content = $result['text']; $isMarkdown = strpos($content, '<!--markdown-->'); if (false !== $isMarkdown) { $content = str_replace('<!--markdown-->', '', $content); $content = MarkdownExtraExtended::defaultTransform($content); } else { $content = Typecho_Common::cutParagraph($content); } echo $content; }