本文整理汇总了PHP中Repository::findOneFromArticle方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::findOneFromArticle方法的具体用法?PHP Repository::findOneFromArticle怎么用?PHP Repository::findOneFromArticle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::findOneFromArticle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArticle
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() . ' 最后更新: ' . $article->get_updatetime() . ' 访问数量:' . ($article->get_access_count() + 1);
return $params;
}
示例2: trim
}
$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: getopt
<?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());