Ejemplo n.º 1
0
 public function editAction()
 {
     $request = $this->getRequest();
     $webId = $request->getParam('web_id');
     $web = Modules_News_Services_Web::getById($webId);
     if (null == $web) {
         Modules_Core_Services_Exception::error('DATA_NOT_FOUND');
     }
     $this->view->webData = $web;
     if ($request->isPost()) {
         $webData = $request->getPost('web');
         $webData = Modules_News_Services_Web::validate($webData);
         if (isset($webData['messages_error']) && $webData['messages_error']) {
             $this->view->errorMessages = $webData['messages'];
             $webData['web_id'] = $web['web_id'];
             $this->view->webData = $webData;
             return;
         }
         $web['name'] = $this->view->STRING->escape($webData['name']);
         $web['screen_name'] = $this->view->STRING->escape($webData['screen_name']);
         $web['status'] = $webData['status'];
         Modules_News_Services_Web::update($web);
         Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('web_actions_edit_success'));
         $this->redirect($this->view->url('news_web_edit', $web));
     }
 }
Ejemplo n.º 2
0
 public function listAction()
 {
     $request = $this->getRequest();
     $webId = $request->getParam('web_id');
     $web = Modules_News_Services_Web::getById($webId);
     if (null == $web) {
         Modules_Core_Services_Exception::error('DATA_NOT_FOUND');
     }
     $this->view->web = $web;
     $perPage = 20;
     $pageIndex = (int) $request->getParam('page_index');
     if (null == $pageIndex || '' == $pageIndex || $pageIndex < 0) {
         $pageIndex = 1;
     }
     $start = ($pageIndex - 1) * $perPage;
     $this->view->pageIndex = $pageIndex;
     $condition = array('web_id' => $webId);
     $crons = Modules_News_Services_Cron::find($start, $perPage, $condition);
     $numCrons = Modules_News_Services_Cron::count($condition);
     $this->view->crons = $crons;
     // Pager
     require_once LIB_DIR . DS . 'PEAR' . DS . 'Pager' . DS . 'Sliding.php';
     $pagerPath = $this->view->url('news_cron_list', array('web_id' => $webId));
     $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' => $numCrons, '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;
 }