Пример #1
0
 private function getArticle($article_id)
 {
     $params = array();
     $params = array('eq' => array('article_id' => $article_id));
     if (!$this->is_root) {
         $params['lt'] = array('category_id' => 5);
     }
     $article = Repository::findOneFromArticle($params);
     if ($article == false) {
         header("Location: /index/notfound");
         return;
     }
     $params['tags'] = SqlRepository::getTags($article_id);
     $params['title'] = $article->get_title();
     $params['indexs'] = json_decode($article->get_indexs());
     $params['contents'] = \TechlogTools::pre_treat_article($article->get_draft());
     $params['title_desc'] = $article->get_title_desc();
     $params['article_category_id'] = $article->get_category_id();
     if (StringOpt::spider_string($params['contents'], '"page-header"', '</div>') === null) {
         $params['contents'] = '<div class="page-header"><h1>' . $article->get_title() . '</h1></div>' . $params['contents'];
     }
     $article->set_access_count($article->get_access_count() + 1);
     Repository::persist($article);
     $params['inserttime'] = $article->get_inserttime() . '&nbsp;&nbsp;&nbsp;最后更新: ' . $article->get_updatetime() . '&nbsp;&nbsp;&nbsp;访问数量:' . ($article->get_access_count() + 1);
     return $params;
 }
Пример #2
0
        }
        $image_path = trim($image_path);
        if (!file_exists(WEB_PATH . '/resource/' . $image_path)) {
            LogOpt::set('exception', '文中目标图片不存在', 'image_path', $image_path);
            return;
        }
        $image_id = Repository::findImageIdFromImages(array('eq' => array('path' => $image_path)));
        if ($image_id == false) {
            $full_path = WEB_PATH . '/resource/' . $image_path;
            $image_id = TechlogTools::load_image($full_path, 'article');
            if ($image_id == false) {
                LogOpt::set('exception', '添加图片到数据库失败', 'image_path', $image_path);
                return;
            }
            LogOpt::set('info', '添加图片到数据库成功', 'image_id', $image_id, 'image_path', $image_path);
            $image_ids[] = $image_id;
        }
    }
    $article = Repository::findOneFromArticle(array('eq' => array('article_id' => $article_id)));
    foreach ($infos as $key => $value) {
        $func = 'set_' . $key;
        $article->{$func}($value);
    }
    $ret = Repository::persist($article);
    if ($ret == false) {
        LogOpt::set('exception', 'article 更新失败', 'article_id', $article_id);
        return;
    }
    LogOpt::set('info', 'article 更新成功', 'article_id', $ret);
    unlink($draft_file);
}
Пример #3
0
<?php

require_once __DIR__ . '/../app/register.php';
LogOpt::init('revise_article', true);
$options = getopt('i:');
if (!isset($options['i']) || !is_numeric($options['i'])) {
    echo 'usage: php revise_article.php -i article_id' . PHP_EOL;
    return;
}
$article = Repository::findOneFromArticle(array('eq' => array('article_id' => $options['i'])));
if ($article == false) {
    LogOpt::set('exception', 'cannot find the article', 'article_id', $options['i']);
    return;
}
$filename = DRAFT_PATH . '/draft' . $options['i'] . '.tpl';
file_put_contents($filename, $article->get_draft());
LogOpt::set('info', '已将文件加载至' . $filename, 'article_id', $options['i'], 'title', $article->get_title());