Ejemplo n.º 1
0
 public function listAction()
 {
     $request = $this->getRequest();
     $perPage = 20;
     $pageIndex = (int) $request->getParam('page_index');
     if (null == $pageIndex || '' == $pageIndex || $pageIndex < 0) {
         $pageIndex = 1;
     }
     $start = ($pageIndex - 1) * $perPage;
     $this->view->pageIndex = $pageIndex;
     $webs = Modules_News_Services_Web::find(array(), $start, $perPage);
     $numWebs = Modules_News_Services_Web::count(array());
     $this->view->webs = $webs;
     // Pager
     require_once LIB_DIR . DS . 'PEAR' . DS . 'Pager' . DS . 'Sliding.php';
     $pagerPath = $this->view->url('news_web_list');
     $pagerOptions = array('mode' => 'Sliding', 'append' => false, 'perPage' => $perPage, 'delta' => 5, 'urlVar' => 'page', 'path' => $pagerPath, 'fileName' => 'page-%d', 'separator' => '', 'nextImg' => '<small class="icon arrow_right"></small>', 'prevImg' => '<small class="icon arrow_left"></small>', 'altNext' => '', 'altPrev' => '', 'altPage' => '', 'totalItems' => $numWebs, 'currentPage' => $pageIndex, 'urlSeparator' => '/', 'spacesBeforeSeparator' => 0, 'spacesAfterSeparator' => 0, 'curPageSpanPre' => '<a href="javascript: void();" class="current">', 'curPageSpanPost' => '</a>');
     $pager = new Pager_Sliding($pagerOptions);
     $this->view->pager = $pager;
 }
Ejemplo n.º 2
0
 /**
  * Edit news article
  */
 public function editAction()
 {
     $request = $this->getRequest();
     $this->view->lang = $request->getParam('lang');
     $articleId = $request->getParam('article_id');
     $article = Modules_News_Services_Article::getById($articleId);
     $configs = Gio_Core_Config_Xml::getConfig('web');
     $this->view->frontendTemplate = $configs->template;
     $this->view->frontendSkin = $configs->skin;
     if (null == $article) {
         Modules_Core_Services_Exception::error('DATA_NOT_FOUND');
     }
     $this->view->categories = Modules_News_Services_Article::getCategoryIds($article);
     $this->view->articleData = $article;
     /**
      * Get source item
      */
     $this->view->sourceArticle = Modules_News_Services_Article::getSource($article);
     /**
      * Web source
      */
     $webSource = Modules_News_Services_Web::getAllWebs();
     $this->view->webSource = $webSource;
     if ($request->isPost()) {
         $user = Gio_Core_Session::getUser();
         $articleData = $request->getPost('article');
         $articleData = Modules_News_Services_Article::validate($articleData);
         if (isset($articleData['messages_error']) && $articleData['messages_error']) {
             $this->view->errorMessages = $articleData['messages'];
             $this->view->articleData = $articleData;
             return;
         }
         $hotArticle = isset($articleData['article_hot']) && $articleData['article_hot'] == 1 ? 1 : 0;
         $photoArticle = isset($articleData['article_photo']) && $articleData['article_photo'] == 1 ? 1 : 0;
         $videoArticle = isset($articleData['article_video']) && $articleData['article_video'] == 1 ? 1 : 0;
         $article = array('article_id' => $articleId, 'title' => $this->view->STRING->escape($articleData['title']), 'slug' => $this->view->STRING->escape($articleData['slug']), 'description' => $articleData['description'], 'content' => $articleData['content'], 'status' => $articleData['status'] == 'active' ? 'active' : 'inactive', 'category_id' => $articleData['category_id'], 'web_id' => $articleData['web_id'], 'link_source' => $this->view->STRING->escape($articleData['link_source']), 'image_url_data' => $articleData['image_url_data'], 'image_url' => $this->view->STRING->escape($articleData['image_url']), 'article_hot' => $hotArticle, 'article_photo' => $photoArticle, 'article_video' => $videoArticle, 'language' => $articleData['language'], 'author' => $this->view->STRING->escape($articleData['author']));
         $sourceItem = isset($articleData['source_item']) ? $articleData['source_item'] : null;
         $categories = $request->getPost('categories');
         Modules_News_Services_Article::update($article, $categories, $sourceItem);
         Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('article_edit_success'));
         $this->redirect($this->view->url('news_article_edit', $article));
     }
 }