コード例 #1
0
ファイル: DocumentsController.php プロジェクト: posiadacz/wsm
 public function indexAction()
 {
     $title = $this->getType() == '2' ? 'Materiały dla członków spółdzielni' : 'Dokumenty do pobrania';
     if ($this->isArchive) {
         $title .= ' - Archiwum';
     }
     $this->setTitle($title);
     $this->setUrl('dokumenty.html');
     $dbService = new Wsm_Db_Documents();
     $this->addToView('list', $dbService->getList($this->getType(), null, $this->isArchive));
     $this->addToView('type', $this->getType());
     $hasArchive = $dbService->hasArchive($this->getType());
     $this->addToView('showArchiveLink', !$this->isArchive && $hasArchive);
 }
コード例 #2
0
ファイル: DocumentsController.php プロジェクト: posiadacz/wsm
 public function moveAction()
 {
     if ($this->has('id') && $this->has('order')) {
         try {
             $id = $this->get('id');
             $isOrderUp = $this->get('order') == 'up';
             $db = new Wsm_Db_Documents();
             $doc = $db->get($id);
             $category = $doc->getCategory();
             $list = $db->getList($this->type, $category);
             $size = count($list);
             foreach ($list as $key => $d) {
                 if ($d->getId() == $doc->getId()) {
                     if ($isOrderUp) {
                         if ($key != 0) {
                             $list[$key] = $list[$key - 1];
                             $list[$key - 1] = $d;
                         }
                     } else {
                         if ($key < $size - 1) {
                             $list[$key] = $list[$key + 1];
                             $list[$key + 1] = $d;
                         }
                     }
                     break;
                 }
             }
             $j = 0;
             foreach ($list as $d) {
                 $d->setOrder($j++);
                 $db->save($d);
             }
             $this->redirect($this->getBaseUrl() . '&msg=saved#id-' . $doc->getId(), true);
         } catch (Exception $e) {
         }
     }
     $this->redirect($this->getBaseUrl() . '&msg=save_error', true);
 }