public function showAction() { $articleMapper = new ArticleMapper(); $categoryMapper = new CategoryMapper(); $articlesCats = $categoryMapper->getCategoryById($this->getRequest()->getParam('id')); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuArticle'), array('controller' => 'index', 'action' => 'index'))->add($this->getTranslator()->trans('menuCats'), array('action' => 'index'))->add($articlesCats->getName(), array('action' => 'show', 'id' => $articlesCats->getId())); $this->getView()->set('articles', $articleMapper->getArticlesByCats($this->getRequest()->getParam('id'), $this->locale)); }
public function showAction() { $articleMapper = new ArticleMapper(); $date = new \Ilch\Date('' . $this->getRequest()->getParam('year') . '-' . $this->getRequest()->getParam('month') . '-01'); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuArticle'), array('controller' => 'index', 'action' => 'index'))->add($this->getTranslator()->trans('menuArchives'), array('action' => 'index'))->add($date->format('F Y', true), array('action' => 'show', 'year' => $this->getRequest()->getParam('year'), 'month' => $this->getRequest()->getParam('month'))); $date = $this->getRequest()->getParam('year') . '-' . $this->getRequest()->getParam('month') . '-01'; $this->getView()->set('articles', $articleMapper->getArticlesByDate($date)); }
public function __construct(array $pluginData) { $request = $pluginData['request']; $router = $pluginData['router']; $articleMapper = new ArticleMapper(); $permas = $articleMapper->getArticlePermas(); $url = $router->getQuery(); if (isset($permas[$url])) { $request->setModuleName('article'); $request->setControllerName('index'); $request->setActionName('show'); $request->setParam('id', $permas[$url]['article_id']); $request->setParam('locale', $permas[$url]['locale']); } }
public function showAction() { $commentMapper = new CommentMapper(); if ($this->getRequest()->getPost('saveComment')) { $date = new \Ilch\Date(); $commentModel = new CommentModel(); if ($this->getRequest()->getPost('fkId')) { $commentModel->setKey('article/index/show/id/' . $this->getRequest()->getParam('id') . '/id_c/' . $this->getRequest()->getPost('fkId')); $commentModel->setFKId($this->getRequest()->getPost('fkId')); } else { $commentModel->setKey('article/index/show/id/' . $this->getRequest()->getParam('id')); } $commentModel->setText($this->getRequest()->getPost('article_comment_text')); $commentModel->setDateCreated($date); $commentModel->setUserId($this->getUser()->getId()); $commentMapper->save($commentModel); } if ($this->getRequest()->isPost() & $this->getRequest()->getParam('preview') == 'true') { $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuArticle'), array('action' => 'index'))->add($this->getTranslator()->trans('preview'), array('action' => 'index')); $title = $this->getRequest()->getPost('title'); $catId = $this->getRequest()->getPost('cats'); $content = $this->getRequest()->getPost('content'); $image = $this->getRequest()->getPost('image'); $articleModel = new ArticleModel(); $articleModel->setTitle($title); $articleModel->setCatId($catId); $articleModel->setContent($content); $articleModel->setArticleImage($image); $articleModel->setVisits(0); $this->getView()->set('article', $articleModel); } else { $articleMapper = new ArticleMapper(); $articleModel = new ArticleModel(); $categoryMapper = new CategoryMapper(); $article = $articleMapper->getArticleByIdLocale($this->getRequest()->getParam('id')); $articlesCats = $categoryMapper->getCategoryById($article->getCatId()); $comments = $commentMapper->getCommentsByKey('article/index/show/id/' . $this->getRequest()->getParam('id')); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuArticle'), array('action' => 'index'))->add($this->getTranslator()->trans('menuCats'), array('controller' => 'cats', 'action' => 'index'))->add($articlesCats->getName(), array('controller' => 'cats', 'action' => 'show', 'id' => $articlesCats->getId()))->add($article->getTitle(), array('action' => 'show', 'id' => $article->getId())); $articleModel->setId($article->getId()); $articleModel->setVisits($article->getVisits() + 1); $articleMapper->saveVisits($articleModel); $this->getLayout()->set('metaTitle', $article->getTitle()); $this->getLayout()->set('metaDescription', $article->getDescription()); $this->getView()->set('article', $article); $this->getView()->set('comments', $comments); } }
public function treatAction() { $articleMapper = new ArticleMapper(); $categoryMapper = new CategoryMapper(); if ($this->getRequest()->getParam('id')) { $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuArticle'), array('action' => 'index'))->add($this->getTranslator()->trans('edit'), array('action' => 'treat')); if ($this->getRequest()->getParam('locale') == '') { $locale = ''; } else { $locale = $this->getRequest()->getParam('locale'); } $this->getView()->set('article', $articleMapper->getArticleByIdLocale($this->getRequest()->getParam('id'), $locale)); } else { $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuArticle'), array('action' => 'index'))->add($this->getTranslator()->trans('add'), array('action' => 'treat')); } if ($this->getRequest()->isPost()) { $model = new ArticleModel(); if ($this->getRequest()->getParam('id')) { $model->setId($this->getRequest()->getParam('id')); } $model->setCatId($this->getRequest()->getPost('cats')); $model->setAuthorId($this->getUser()->getId()); $model->setDescription($this->getRequest()->getPost('description')); $model->setTitle($this->getRequest()->getPost('title')); $model->setContent($this->getRequest()->getPost('content')); $model->setArticleImage($this->getRequest()->getPost('image')); $model->setArticleImageSource($this->getRequest()->getPost('imageSource')); $model->setPerma($this->getRequest()->getPost('permaLink')); if ($this->getRequest()->getPost('language') != '') { $model->setLocale($this->getRequest()->getPost('language')); } else { $model->setLocale(''); } $articleMapper->save($model); $this->redirect(array('action' => 'index')); } $this->getView()->set('cats', $categoryMapper->getCategories()); $this->getView()->set('contentLanguage', $this->getConfig()->get('content_language')); $this->getView()->set('languages', $this->getTranslator()->getLocaleList()); $this->getView()->set('multilingual', (bool) $this->getConfig()->get('multilingual_acp')); }
/** * Shows a table with all groups. */ public function indexAction() { $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuAccess'), array('action' => 'index')); $postData = $this->getRequest()->getPost(); $groupMapper = new GroupMapper(); $groups = $groupMapper->getGroupList(); $this->getView()->set('activeGroupId', 0); $this->getView()->set('activeGroup', null); foreach ($groups as $key => $group) { if ($group->getId() == 1) { unset($groups[$key]); } } $this->getView()->set('groups', $groups); if (isset($postData['groupId'])) { $groupId = (int) $postData['groupId']; $_SESSION['user']['accessGroup'] = $groupId; } elseif (isset($_SESSION['user']['accessGroup'])) { $groupId = (int) $_SESSION['user']['accessGroup']; } else { $groupId = 0; } if ($groupId) { $groupAccessList = $groupMapper->getGroupAccessList($groupId); $activeGroup = $groupMapper->getGroupById($groupId); $this->getView()->set('groupAccessList', $groupAccessList); $this->getView()->set('activeGroupId', $groupId); $this->getView()->set('activeGroup', $activeGroup); } $moduleMapper = new ModuleMapper(); $modules = $moduleMapper->getModules(); $pageMapper = new PageMapper(); $pages = $pageMapper->getPageList(); $articleMapper = new ArticleMapper(); $articles = $articleMapper->getArticles(); $boxMapper = new BoxMapper(); $boxes = $boxMapper->getBoxList($this->getTranslator()->getLocale()); $accessTypes = array('module' => $modules, 'page' => $pages, 'article' => $articles, 'box' => $boxes); $this->getView()->set('accessTypes', $accessTypes); }
public function render() { $articleMapper = new ArticleMapper(); $this->getView()->set('archive', $articleMapper->getArticleDateList(10)); }
public function render() { $articleMapper = new ArticleMapper(); $this->getView()->set('articles', $articleMapper->getArticleList('', 5)); }