本文整理汇总了PHP中Repository::findTitleFromArticle方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::findTitleFromArticle方法的具体用法?PHP Repository::findTitleFromArticle怎么用?PHP Repository::findTitleFromArticle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::findTitleFromArticle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listAction
public function listAction()
{
$notes = SqlRepository::getBooknotes();
$booknotes = array();
foreach ($notes as $note) {
$infos = array();
$infos['idx_href'] = '/article/list/' . $note->get_index_article_id();
$infos['image_path'] = Repository::findPathFromImages(array('eq' => array('image_id' => $note->get_image_id())));
$title = Repository::findTitleFromArticle(array('eq' => array('article_id' => $note->get_index_article_id())));
$infos['title'] = mb_substr($title, 0, 35);
$infos['descs'] = mb_substr($note->get_descs(), 0, 35);
$booknotes[] = $infos;
}
$params = array('infos' => $booknotes, 'title' => '读书笔记', 'category_id' => 2);
$this->display(__METHOD__, $params);
}
示例2: scandir
<?php
require_once __DIR__ . '/../app/register.php';
LogOpt::init('contents_loader', true);
$draft_files = scandir(DRAFT_PATH);
foreach ($draft_files as $draft) {
if ($draft[0] == '.') {
continue;
}
$article_id = StringOpt::spider_string($draft, 'draft', '.tpl');
if (empty($article_id)) {
continue;
}
$title = Repository::findTitleFromArticle(array('eq' => array('article_id' => $article_id)));
if ($title == false) {
LogOpt::set('exception', '草稿原文不存在', 'article_id', $article_id);
continue;
}
echo '是否加载该草稿到日志原文?《' . $title . '》' . '(arctile_id:' . $article_id . ') [y/N]';
$sure = fgets(STDIN);
if (trim($sure[0]) != 'Y' && trim($sure[0]) != 'y') {
continue;
}
$draft_file = DRAFT_PATH . '/draft' . $article_id . '.tpl';
$infos = array();
$infos['draft'] = file_get_contents($draft_file);
$contents = TechlogTools::pre_treat_article($infos['draft']);
$indexs = json_encode(TechlogTools::get_index($contents));
if ($indexs != null) {
$infos['indexs'] = $indexs;
}
示例3: pre_treat_article
//.........这里部分代码省略.........
$image_info = $image_info['3'];
$width = StringOpt::spider_string($image_info, 'width="', '"');
$width = intval(trim($width));
$contents .= '<p style="text-indent:0em;">' . '<a target="_blank" alt="' . $width . '" href="' . $path . '">' . $line . '</a></p><p> </p>';
} else {
if (substr($line, 0, 5) == '<code') {
$mode = StringOpt::spider_string($line, 'mode="', '"');
if (empty($mode)) {
$mode = 'c_cpp';
}
$code = '';
$code_line = 0;
$is_php = false;
if ($mode === 'php' && $lines[$index + 1] != '<?php') {
$is_php = true;
}
while (1) {
$index++;
if ($index >= count($lines)) {
break;
}
$line = $lines[$index];
if (trim($line) === '</code>') {
break;
}
$code_wrap = 0;
for ($idx = 0; $idx < strlen($line); ++$idx) {
if ($line[$idx] == "\t") {
$code_wrap += 4;
continue;
}
$value = ord($line[$idx]);
if ($value > 127) {
$code_wrap++;
if ($value >= 192 && $value <= 223) {
$idx++;
} elseif ($value >= 224 && $value <= 239) {
$idx = $idx + 2;
} elseif ($value >= 240 && $value <= 247) {
$idx = $idx + 3;
}
}
$code_wrap++;
}
$code_line += floor($code_wrap / 80) + 1;
$code .= self::str_trans($line, false) . PHP_EOL;
}
if ($is_php) {
$code = '<?php' . PHP_EOL . $code . '?>';
$code_line += 2;
}
if ($code_line > 30) {
$code_line = 30;
}
$contents .= '<div id="editor_' . $code_id . '"' . ' style="position: relative;' . ' width: 765px;' . ' height: ' . $code_line . 'px">' . trim($code) . '</div><p> </p>';
$codes[] = array('id' => 'editor_' . $code_id++, 'mode' => $mode);
continue;
} else {
if (substr($line, 0, 4) === '<h1>') {
$contents .= '<div class="page-header"><h1 id="' . $code_id++ . '">' . self::str_trans(substr($line, 4)) . '</h1></div>';
} else {
if (substr($line, 0, 4) === '<h3>') {
$contents .= '<p><h3>' . self::str_trans(substr($line, 4)) . '</h3></p>';
} else {
if (substr($line, 0, 2) == '<a') {
$id = StringOpt::spider_string($line, 'id="', '"');
$title = Repository::findTitleFromArticle(array('eq' => array('article_id' => $id)));
if (!$title) {
$title = 'ERROR:加载失败';
}
$contents .= '<p><a target="_blank" href="/article/list/' . $id . '">' . $title . '</a></p>';
} else {
$line = self::str_trans($line);
if ($font != '') {
$line = '<span style="font-family:' . $font . ';">' . $line . '</span>';
}
$contents .= '<p>' . $line . '</p>';
}
}
}
}
}
}
}
}
}
}
}
}
if (!empty($codes)) {
$js_arr = array();
foreach ($codes as $code) {
$js_arr[] = '{"id":"' . $code['id'] . '","mode":"' . $code['mode'] . '"}';
}
$contents .= '<script>var CODE_DIVS=[';
$contents .= implode(',', $js_arr);
$contents .= '];</script>';
}
return $contents;
}