AdminController.php
00001 <?php
00009 class News_AdminController extends Dsao_Controller_Action
00010 {
00011 public function preDispatch()
00012 {
00013 $this->_setDefaultModelClass('News_Index')
00014 ->getHelper('History')->setAddToHistory();
00015 }
00016
00017
00027 public function indexAction()
00028 {
00029 }
00030
00038 public function deleteAction()
00039 {
00040 if ($this->getUri()->confirm)
00041 {
00042 if ($this->_getModel()->deleteNews($this->getUri()->id))
00043 {
00044 $this->getLog()->info('news_delete_info');
00045 }
00046 else
00047 {
00048 $this->getLog()->err('news_delete_error');
00049 }
00050 }
00051 else
00052 {
00053 $this->getView()->addTemplate('confirm')
00054 ->assign('newsId', $this->getUri()->id);
00055
00056 $this->getLog()->info('news_delete_confirm_info');
00057 }
00058 }
00059
00060
00068 public function createAction()
00069 {
00070
00071 $author = $this->getRequest()->getPost('author');
00072 if (isset($author))
00073 {
00074 if($this->getRequest()->isPost())
00075 {
00076 if($this->_getModel()->createNews($this->getRequest()->getPost()))
00077 {
00078 $this->getView()->addTemplate(false);
00079 $this->getLog()->info('news_create_ok');
00080 }
00081 else
00082 {
00083 $this->getLog()->err('news_create_error');
00084 }
00085 }
00086 }
00087 else
00088 {
00089 $this->getView()->addTemplate();
00090 }
00091 }
00092
00101 public function updateAction()
00102 {
00103
00104 $id = $this->getUri()->id;
00105
00106
00107 $this->getView()->assign('news', $this->_getModel()->loadNews($id));
00108
00109
00110 $lastEditedBy = $this->getRequest()->getPost('lastEditedBy');
00111 if (isset($lastEditedBy))
00112 {
00113 $data = $this->getRequest()->getPost();
00114
00115 if(isset($data))
00116 {
00117 $data['id'] = $this->getUri()->id;
00118
00119 if($this->_getModel()->updateNews($data))
00120 {
00121 $this->getLog()->info('news_update_ok');
00122 $this->getView()->addTemplate(false);
00123 }
00124 else
00125 {
00126 $this->getLog()->err('news_update_error');
00127 }
00128 }
00129 }
00130 else
00131 {
00132 $this->getView()->addTemplate('update');
00133 }
00134 }
00135 }