• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ArticleModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ArticleModel的典型用法代码示例。如果您正苦于以下问题:PHP ArticleModel类的具体用法?PHP ArticleModel怎么用?PHP ArticleModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ArticleModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:30,代码来源:ArticleCtrl.class.php


示例2: delete

 public function delete($id)
 {
     var_dump(__METHOD__);
     $config = $this->getConfig();
     $model = new ArticleModel($config);
     $ret = $model->delete($id);
     var_dump($ret);
 }
开发者ID:kxopa,项目名称:slimvc,代码行数:8,代码来源:ArticleController.php


示例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);
 }
开发者ID:rrgraute,项目名称:php_mvc-ws-cli-memdb,代码行数:10,代码来源:ArticlesController.php


示例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);
 }
开发者ID:tanqinwang,项目名称:test_own,代码行数:13,代码来源:Banner.php


示例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();
 }
开发者ID:omusico,项目名称:AndyCMS,代码行数:52,代码来源:MenuItemAction.class.php


示例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));
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:7,代码来源:LoadController.php


示例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();
 }
开发者ID:fritzmg,项目名称:contao-be-include-info,代码行数:37,代码来源:ContentArticleExtended.php


示例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);
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:27,代码来源:CommentController.php


示例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);
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:31,代码来源:EditArticleController.php


示例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;
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:38,代码来源:ModuleArticleList.php


示例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;
 }
开发者ID:contao-dot-kitchen,项目名称:content_log,代码行数:30,代码来源:ClassContentLog.php


示例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();
 }
开发者ID:heimrichhannot,项目名称:contao-formhybrid,代码行数:27,代码来源:ContentFormHybridStop.php


示例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&amp;table=tl_module&amp;act=edit&amp;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();
 }
开发者ID:rheintechnology,项目名称:core,代码行数:36,代码来源:ModuleArticlenav.php


示例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&amp;table=tl_module&amp;act=edit&amp;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();
 }
开发者ID:rburch,项目名称:core,代码行数:31,代码来源:ModuleArticlenav.php


示例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();
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:46,代码来源:UserCtrl.class.php


示例16: detailAction

 public function detailAction()
 {
     $p = $_REQUEST;
     $pAid = empty($p['aid']) ? 0 : intval($p['aid']);
     if (empty($pAid)) {
         echo 'error aid';
         exit;
     }
     $tMO = new ArticleModel();
     $tImgUrl = Yaf_Registry::get("config")->web->url->img;
     $tRow = $tMO->field('id aid, concat(\'' . $tImgUrl . '\', head_img)  head_img,content,(view+initview) viewtotal,title,description,created,source')->where(' id = ' . $pAid)->fRow();
     if (empty($tRow['aid'])) {
         die('该文章不存在');
     }
     $tData = array('id' => $pAid, 'view' => $tRow['viewtotal'] + 1);
     $tMO->update($tData);
     $this->assign('tRow', $tRow);
 }
开发者ID:tanqinwang,项目名称:test_own,代码行数:18,代码来源:Article.php


示例17: detail

 public function detail()
 {
     $aid = ggp('aid:i');
     $detail = ArticleModel::I()->find($aid);
     $sort = D('Sort')->find($detail['sort_id']);
     $this->a('$sort', $sort);
     $this->a('$detail', $detail);
     $this->d();
 }
开发者ID:huping112004,项目名称:taobaoke,代码行数:9,代码来源:ArticleAction.class.php


示例18: publishAction

 /**
  * 发布
  * @return bool
  */
 public function publishAction()
 {
     if (!$this->getRequest()->isPost()) {
         $this->responseJson(401, '请求方式不正确');
     }
     //$username = $this->getRequest()->getParam('username','');
     //$password = $this->getRequest()->getParam('password','');
     $title = $_POST['title'];
     $content = $_POST['content'];
     if (empty($title) && empty($content)) {
         $this->responseJson(401, '文章title或内容不能为空');
     }
     $article = new ArticleModel();
     $ret = $article->addArticle($title, $content);
     if ($ret[0]) {
         $this->responseJson(200, $ret[1]);
     } else {
         $this->responseJson(401, $ret[1]);
     }
     return false;
 }
开发者ID:ruansheng,项目名称:RsBlog,代码行数:25,代码来源:Article.php


示例19: deleteAction

 public function deleteAction()
 {
     if (!isset($_POST['id_article'])) {
         return json_encode(["error" => "article_id missing"]);
     }
     $article_id = $_POST['id_article'];
     $result = ArticleModel::getArticle($this->pdo, $article_id);
     if ($result['id_user'] != $_SESSION['id_user']) {
         return json_encode(['error' => 'utilisateur']);
     }
     ArticleModel::delete($this->pdo, $article_id);
     return json_encode(["message" => "delete", "article_id" => $article_id]);
 }
开发者ID:tritonjoyeux,项目名称:Blog,代码行数:13,代码来源:ArticleController.php


示例20: indexAction

 public function indexAction()
 {
     if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
         header('Location : /');
         exit;
     } else {
         $article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
     }
     if (ArticleModel::exists($this->pdo, $article_id)) {
         include '../app/views/article.php';
         return;
     }
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:13,代码来源:ArticleController.php



注:本文中的ArticleModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ArticlePeer类代码示例发布时间:2022-05-23
下一篇:
PHP ArticleMailTemplate类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap