本文整理汇总了PHP中ArticleModel类的典型用法代码示例。如果您正苦于以下问题:PHP ArticleModel类的具体用法?PHP ArticleModel怎么用?PHP ArticleModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArticleModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
//var_dump($_SESSION['qq']);
$articleId = $_GET['articleId'];
$article = new ArticleModel();
$content = $article->getArticleById($articleId);
$collect = new CollectModel();
$comment = new CommentModel();
$commentNum = $comment->getCommentCountByArticleId($articleId);
$content['commentNum'] = $commentNum;
if ($this->isLogin()) {
if ($collect->getCollects($article, $_SESSION['qq']['userId'])) {
$this->assign('collects', '已收藏');
} else {
$collectNum = $collect->getCollectCountByuserId($article);
$this->assign('collectNum', $collectNum);
$this->assign('collects', '收藏');
}
}
$this->assign('article', $content);
//评论查询
$comments = $comment->getComment($articleId);
$user = new UserModel();
$arr = array();
foreach ($comments as $key => $val) {
$val[$key]['user'] = $user->getUserById($val['userId']);
}
$this->assign('comments', $comments);
$this->display();
}
示例2: delete
public function delete($id)
{
var_dump(__METHOD__);
$config = $this->getConfig();
$model = new ArticleModel($config);
$ret = $model->delete($id);
var_dump($ret);
}
示例3: actionView
public function actionView($id)
{
$articleModel = new ArticleModel();
$article = $articleModel->get($id);
if ($article === false) {
throw new Http404();
}
$templateEngine = new TemplateEngine();
return $templateEngine->render('articles/view.html', $article);
}
示例4: indexAction
public function indexAction()
{
/*
$tBMO = new BannerModel;
$tImgUrl = Yaf_Registry::get("config")->web->url->img;
$tDatas = $tBMO->field('aid,concat(\''.$tImgUrl.'\',img) img')->order(' id asc ')->fList();
Tool_Fnc::ajaxMsg('',1,$tDatas);
*/
$tAMO = new ArticleModel();
$tImgUrl = Yaf_Registry::get("config")->web->url->img;
$tDatas = $tAMO->field('id aid,concat(\'' . $tImgUrl . '\',head_img) img')->where(' cate_id = 18')->order('id asc')->fList();
Tool_Fnc::ajaxMsg('', 1, $tDatas);
}
示例5: add
/**
* 添加新的子菜单,但是要选择是 哪种类型(Article,Category,Section).
* 从组件中找出存在的组建
*/
function add()
{
//查找出子菜单,并且显示分配在左侧菜单中
$menus = new MenuModel();
$menu_list = $menus->select();
$this->assign('menulist', $menu_list);
//导入分页类
import("ORG.Util.Page");
//查询组件,相当于哪几种类型
$component = new ComponentModel();
$where = array('enabled' => 1);
$list = $component->where($where)->select();
$this->assign('comlist', $list);
//得到类型
$link = strtolower($_REQUEST['link']);
//查询数据,如果默认为空,则显示文章列表
if (empty($link) || $link == 'article') {
$art = new ArticleModel();
$count = $art->count();
$page = new Page($count, C("PAGESIZE"));
//完成分页
$show = $page->show();
//查询分页数据
$list = $art->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
} else {
if ($link == 'category') {
$cat = new CategoryModel();
$count = $cat->count();
$page = new Page($count, C("PAGESIZE"));
//完成分页
$show = $page->show();
//查询分页数据
$list = $cat->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
} else {
$sec = new SectionModel();
$count = $sec->count();
$page = new Page($count, C("PAGESIZE"));
//完成分页
$show = $page->show();
//查询分页数据
$list = $sec->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
}
}
$this->assign('show', $show);
$this->assign('list', $list);
$this->assign('link', $link);
$this->display();
}
示例6: indexAction
public function indexAction()
{
header('content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
echo json_encode(ArticleModel::showLastArticles($this->pdo));
}
示例7: generate
/**
* Parse the template
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
// create new backend template
$objTemplate = new \BackendTemplate('be_include');
// get the article
$objArticle = \ArticleModel::findByPk($this->articleAlias);
if ($objArticle === null) {
return parent::generate();
}
// get the parent pages
$objPages = \PageModel::findParentsById($objArticle->pid);
if ($objPages === null) {
return parent::generate();
}
// get the page titles
$arrPageTitles = array_reverse($objPages->fetchEach('title'));
// set breadcrumb to original element
$objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN));
// get include breadcrumbs
$includes = \IncludeInfoHelper::getIncludes('articleAlias', $this->articleAlias, $this->id);
// set include breadcrumbs
if (count($includes) > 1) {
$objTemplate->includes = $includes;
}
// add CSS
$GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS;
// return info + content
return $objTemplate->parse() . parent::generate();
}
// return content only
return parent::generate();
}
示例8: indexAction
public function indexAction()
{
header('content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
$valid = true;
$errors = [];
$id = htmlentities($_POST['article']);
$user = $_SESSION['auth']['username'];
$comment = trim(htmlentities($_POST['comment']));
$timestamp = time();
if (!ArticleModel::exists($this->pdo, $id)) {
$errors['article'] = '<span class="errors">Cet article n\'existe pas</span>';
$valid = false;
} elseif (!isset($comment) || empty($comment)) {
$errors['comment'] = '<span class="errors">Non saisi</span>';
$valid = false;
} elseif (strlen($comment) > 200) {
$errors['comment'] = '<span class="errors">200 caractères max</span>';
$valid = false;
}
$errors['valid'] = $valid;
if ($valid) {
CommentModel::create($this->pdo, $id, $user, $comment, $timestamp);
}
echo json_encode($errors);
}
示例9: indexAction
public function indexAction()
{
header('content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
$valid = true;
$errors = [];
if (ArticleModel::exists($this->pdo, htmlentities($_POST['id']))) {
$id = htmlentities($_POST['id']);
} else {
return json_encode($errors['id'] = '<span class="errors">Cet article n\'existe pas</span>');
}
$title = trim(ucfirst(strtolower(htmlentities($_POST['title']))));
$content = trim(htmlentities($_POST['content']));
if (!isset($title) || empty($title)) {
$errors['title'] = '<span class="errors">Non saisi</span>';
$valid = false;
} elseif (strlen($title) > 51) {
$errors['title'] = '<span class="errors">Trop long</span>';
$valid = false;
}
if (!isset($content) || empty($content)) {
$errors['content'] = '<span class="errors">Non saisi</span>';
$valid = false;
}
$errors['valid'] = $valid;
if ($valid) {
$errors['edit'] = ArticleModel::edit($this->pdo, $id, $title, $content, $_SESSION['auth']['username']);
}
echo json_encode($errors);
}
示例10: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
if (!strlen($this->inColumn)) {
$this->inColumn = 'main';
}
$intCount = 0;
$articles = array();
$id = $objPage->id;
$this->Template->request = \Environment::get('request');
// Show the articles of a different page
if ($this->defineRoot && $this->rootPage > 0) {
if (($objTarget = $this->objModel->getRelated('rootPage')) !== null) {
$id = $objTarget->id;
/** @var \PageModel $objTarget */
$this->Template->request = $objTarget->getFrontendUrl();
}
}
// Get published articles
$objArticles = \ArticleModel::findPublishedByPidAndColumn($id, $this->inColumn);
if ($objArticles === null) {
return;
}
while ($objArticles->next()) {
// Skip first article
if (++$intCount <= intval($this->skipFirst)) {
continue;
}
$cssID = deserialize($objArticles->cssID, true);
$alias = $objArticles->alias ?: $objArticles->title;
$articles[] = array('link' => $objArticles->title, 'title' => specialchars($objArticles->title), 'id' => $cssID[0] ?: standardize($alias), 'articleId' => $objArticles->id);
}
$this->Template->articles = $articles;
}
示例11: checkLog
public function checkLog($ptable, $tstamp, $item)
{
switch ($ptable) {
case 'tl_article':
$objArticle = \ArticleModel::findById($item['pid']);
$objPage = \PageModel::findById($objArticle->pid);
$item['page'] = $objPage->title;
$item['showUrl'] = $this->generateFrontendUrl($objPage->row(), '');
break;
case 'tl_news':
$objNews = \NewsModel::findById($item['pid']);
$objArchive = \NewsArchiveModel::findById($objNews->pid);
$objPage = \PageModel::findById($objArchive->jumpTo);
$item['page'] = $objNews->headline;
$item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objNews->alias != '' ? $objNews->alias : $objNews->id)));
break;
case 'tl_calendar':
break;
case 'tl_faq':
$objFAQ = \FaqModel::findById($item['id']);
$objCategory = \FaqCategoryModel::findById($item['pid']);
$objPage = \PageModel::findById($objCategory->jumpTo);
$item['htmlElement'] = '<div class="ce_faq"><h1>' . $objFAQ->question . '</h1>' . $objFAQ->answer . '</div>';
$item['page'] = $objCategory->title;
$item['title'] = $objFAQ->question;
$item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objFAQ->alias != '' ? $objFAQ->alias : $objFAQ->id)));
break;
}
return $item;
}
示例12: compile
protected function compile()
{
$objContentStart = \Database::getInstance()->prepare("SELECT * FROM tl_content WHERE pid=? AND type=? ORDER BY sorting")->limit(1)->execute($this->pid, 'formhybridStart');
if ($objContentStart->numRows === 0) {
return;
}
$objModule = \ModuleModel::findByPk($objContentStart->formhybridModule);
if ($objModule === null) {
return;
}
$objModule->refresh();
$strClass = \Module::findClass($objModule->type);
// Return if the class does not exist
if (!class_exists($strClass)) {
static::log('Module class "' . $strClass . '" (module "' . $objModule->type . '") does not exist', __METHOD__, TL_ERROR);
return '';
}
$objArticle = \ArticleModel::findByPk($this->pid);
if ($objArticle === null) {
return;
}
global $objPage;
$objModule = new $strClass($objModule, $objArticle->inColumn);
$objModule->renderStop = true;
$objModule->startModule = $_SESSION[FormSession::FORMHYBRID_FORMSESSION_START_KEY][$objPage->id . '_' . $objModule->formHybridDataContainer];
$this->Template->content = $objModule->generate();
}
示例13: generate
/**
* Do not display the module if there are no articles
*
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['articlenav'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = '' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
/** @var \PageModel $objPage */
global $objPage;
$this->objArticles = \ArticleModel::findPublishedWithTeaserByPidAndColumn($objPage->id, $this->strColumn);
// Return if there are no articles
if ($this->objArticles === null) {
return '';
}
// Redirect to the first article if no article is selected
if (!\Input::get('articles')) {
if (!$this->loadFirst) {
return '';
}
/** @var \ArticleModel $objArticle */
$objArticle = $this->objArticles->current();
$strAlias = $objArticle->alias != '' && !\Config::get('disableAlias') ? $objArticle->alias : $objArticle->id;
$this->redirect($this->generateFrontendUrl($objPage->row(), '/articles/' . $strAlias));
}
return parent::generate();
}
示例14: generate
/**
* Do not display the module if there are no articles
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ARTICLE NAVIGATION ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
global $objPage;
$this->objArticles = \ArticleModel::findPublishedWithTeaserByPidAndColumn($objPage->id, $this->strColumn);
// Return if there are no articles
if ($this->objArticles === null) {
return '';
}
// Redirect to the first article if no article is selected
if (!\Input::get('articles')) {
if (!$this->loadFirst) {
return '';
}
$strAlias = $this->objArticles->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $this->objArticles->alias : $this->objArticles->id;
$this->redirect($this->addToUrl('articles=' . $strAlias));
}
return parent::generate();
}
示例15: index
public function index()
{
//header('content-type:text/html;charset=utf-8');
$userId = $_SESSION['qq']['userId'];
$collect = new CollectModel();
//查询收藏
$user_collect = $collect->getCollectByuserId($userId);
$article = new ArticleModel();
$arr = array();
foreach ($user_collect as $v) {
//根据收藏的文章id查询文章
$a = $article->getArticleById($v['articleId']);
//取出admin的昵称
$a['adminName'] = $this->getAdmin($a['adminId']);
$arr[] = $a;
}
$comment = new CommentModel();
$commentAlbum = $comment->getCommentByAlbum($userId);
$album = new AlbumModel();
$articles = array();
$albums = array();
foreach ($commentAlbum as $v) {
if ($v['albumId'] != null) {
$c = $album->getAlbumById($v['albumId']);
$c['adminName'] = $this->getAdmin($v['adminId']);
$albums[] = $c;
}
}
$commentArticle = $comment->getCommentByArticle($userId);
foreach ($commentArticle as $v) {
if ($v['articleId'] != null) {
$a = $article->getArticleById($v['articleId']);
$a['adminName'] = $this->getAdmin($v['adminId']);
$articles[] = $a;
}
}
var_dump($albums);
$this->assign('user', $_SESSION['qq']['userName']);
//评论过的相册
$this->assign('albums', $albums);
//评论过的文章
$this->assign('articles', $articles);
//收藏
$this->assign('user_collect', $arr);
$this->display();
}