[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 if (!isset($gCms)) exit; 3 4 $detailpage = ''; 5 if (isset($params['detailpage'])) 6 { 7 $manager =& $gCms->GetHierarchyManager(); 8 $node =& $manager->sureGetNodeByAlias($params['detailpage']); 9 if (isset($node)) 10 { 11 $content =& $node->GetContent(); 12 if (isset($content)) 13 { 14 $detailpage = $content->Id(); 15 } 16 } 17 else 18 { 19 $node =& $manager->sureGetNodeById($params['detailpage']); 20 if (isset($node)) 21 { 22 $detailpage = $params['detailpage']; 23 } 24 } 25 } 26 27 if (isset($params['cancel'])) 28 { 29 $this->Redirect($id, 'defaultadmin', $returnid); 30 } 31 32 $articleid = ''; 33 if (isset($params['articleid'])) 34 { 35 $articleid = $params['articleid']; 36 } 37 38 39 $content = ''; 40 if (isset($params['content'])) 41 { 42 $content = $params['content']; 43 } 44 45 $summary = ''; 46 if (isset($params['summary'])) 47 { 48 $summary = $params['summary']; 49 } 50 51 $status = 'draft'; 52 if (isset($params['status'])) 53 { 54 $status = $params['status']; 55 } 56 57 $usedcategory = ''; 58 if (isset($params['category'])) 59 { 60 $usedcategory = $params['category']; 61 } 62 63 $author_id = '-1'; 64 if (isset($params['author_id'])) 65 { 66 $author_id = $params['author_id']; 67 } 68 69 $postdate = time(); 70 if (isset($params['postdate_Month'])) 71 { 72 $postdate = mktime($params['postdate_Hour'], $params['postdate_Minute'], $params['postdate_Second'], $params['postdate_Month'], $params['postdate_Day'], $params['postdate_Year']); 73 } 74 75 $useexp = 0; 76 if (isset($params['useexp'])) 77 { 78 $useexp = 1; 79 } 80 81 $startdate = time(); 82 if (isset($params['startdate_Month'])) 83 { 84 $startdate = mktime($params['startdate_Hour'], $params['startdate_Minute'], $params['startdate_Second'], $params['startdate_Month'], $params['startdate_Day'], $params['startdate_Year']); 85 } 86 87 $enddate = strtotime('+6 months', time()); 88 if (isset($params['enddate_Month'])) 89 { 90 $enddate = mktime($params['enddate_Hour'], $params['enddate_Minute'], $params['enddate_Second'], $params['enddate_Month'], $params['enddate_Day'], $params['enddate_Year']); 91 } 92 93 $title = ''; 94 if (isset($params['title'])) 95 { 96 $title = $params['title']; 97 if ($title != '') 98 { 99 if ($content != '') 100 { 101 $query = 'UPDATE '.cms_db_prefix().'module_news SET news_title=?, news_data=?, summary=?, status=?, news_date=?, news_category_id=?, start_time=?, end_time=?, modified_date=? WHERE news_id = ?'; 102 if ($useexp == 1) 103 { 104 $db->Execute($query, array($title, $content, $summary, $status, trim($db->DBTimeStamp($postdate), "'"), $usedcategory, trim($db->DBTimeStamp($startdate), "'"), trim($db->DBTimeStamp($enddate), "'"), trim($db->DBTimeStamp(time()), "'"), $articleid)); 105 } 106 else 107 { 108 $db->Execute($query, 109 array($title, $content, 110 $summary, $status, 111 trim($db->DBTimeStamp($postdate), "'"), 112 $usedcategory, 113 trim($db->DBTimeStamp($startdate), "'"), 114 NULL, 115 trim($db->DBTimeStamp(time()), "'"), 116 $articleid) 117 ); 118 } 119 120 //Update search index 121 $module =& $this->GetModuleInstance('Search'); 122 if ($module != FALSE) 123 { 124 $module->AddWords($this->GetName(), $articleid, 'article', $content . ' ' . $summary . ' ' . $title . ' ' . $title, ($useexp == 1 ? $enddate : NULL) ); 125 } 126 127 @$this->SendEvent('NewsArticleEdited', array('news_id' => $articleid, 'category_id' => $usedcategory, 'title' => $title, 'content' => $content, 'summary' => $summary, 'status' => $status, 'start_time' => $startdate, 'end_time' => $enddate, 'useexp' => $useexp)); 128 129 $params = array('tab_message'=> 'articleupdated', 'active_tab' => 'articles'); 130 $this->Redirect($id, 'defaultadmin', $returnid, $params); 131 } 132 else 133 { 134 echo $this->ShowErrors($this->Lang('nocontentgiven')); 135 } 136 } 137 else 138 { 139 echo $this->ShowErrors($this->Lang('notitlegiven')); 140 } 141 } 142 else 143 { 144 $query = 'SELECT * FROM '.cms_db_prefix().'module_news WHERE news_id = ?'; 145 $row = $db->GetRow($query, array($articleid)); 146 147 if ($row) 148 { 149 $title = $row['news_title']; 150 $content = $row['news_data']; 151 $summary = $row['summary']; 152 $status = $row['status']; 153 $usedcategory = $row['news_category_id']; 154 $postdate = $db->UnixTimeStamp($row['news_date']); 155 $startdate = $db->UnixTimeStamp($row['start_time']); 156 $author_id = $row['author_id']; 157 if (isset($row['end_time'])) 158 { 159 $useexp = 1; 160 $enddate = $db->UnixTimeStamp($row['end_time']); 161 } 162 else 163 { 164 $useexp = 0; 165 } 166 } 167 } 168 169 $statusdropdown = array(); 170 $statusdropdown['Draft'] = 'draft'; 171 $statusdropdown['Published'] = 'published'; 172 173 $categorylist = array(); 174 $query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY hierarchy"; 175 $dbresult = $db->Execute($query); 176 177 while ($dbresult && $row = $dbresult->FetchRow()) 178 { 179 $categorylist[$row['long_name']] = $row['news_category_id']; 180 } 181 182 #Display template 183 $this->smarty->assign('startform', $this->CreateFormStart($id, 'editarticle', $returnid)); 184 $this->smarty->assign('endform', $this->CreateFormEnd()); 185 186 global $gCms; 187 $userops =& $gCms->GetUserOperations(); 188 $theuser =& $userops->LoadUserById( $author_id ); 189 $this->smarty->assign('authortext', $this->Lang('author')); 190 $this->smarty->assign('inputauthor', $theuser->username ); 191 192 $this->smarty->assign('titletext', $this->Lang('title')); 193 $this->smarty->assign('inputtitle', $this->CreateInputText($id, 'title', $title, 30, 255)); 194 $this->smarty->assign('inputcontent', $this->CreateTextArea(true, $id, $content, 'content')); 195 $this->smarty->assign('inputsummary', $this->CreateTextArea(true, $id, $summary, 'summary', '', '', '', '', '80', '3')); 196 $this->smarty->assign('inputexp', $this->CreateInputCheckbox($id, 'useexp', '1', $useexp, 'class="pagecheckbox"')); 197 $this->smarty->assign_by_ref('postdate', $postdate); 198 $this->smarty->assign('postdateprefix', $id.'postdate_'); 199 $this->smarty->assign_by_ref('startdate', $startdate); 200 $this->smarty->assign('startdateprefix', $id.'startdate_'); 201 $this->smarty->assign_by_ref('enddate', $enddate); 202 $this->smarty->assign('enddateprefix', $id.'enddate_'); 203 $this->smarty->assign('status', $this->CreateInputDropdown($id, 'status', $statusdropdown, -1, $status)); 204 $this->smarty->assign('inputcategory', $this->CreateInputDropdown($id, 'category', $categorylist, -1, $usedcategory)); 205 $this->smarty->assign('hidden', $this->CreateInputHidden($id, 'articleid', $articleid).$this->CreateInputHidden($id, 'author_id', $author_id)); 206 $this->smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', lang('submit'))); 207 $this->smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', lang('cancel'))); 208 209 $this->smarty->assign('titletext', $this->Lang('title')); 210 $this->smarty->assign('categorytext', $this->Lang('category')); 211 $this->smarty->assign('summarytext', $this->Lang('summary')); 212 $this->smarty->assign('contenttext', $this->Lang('content')); 213 $this->smarty->assign('postdatetext', $this->Lang('postdate')); 214 $this->smarty->assign('statustext', lang('status')); 215 $this->smarty->assign('useexpirationtext', $this->Lang('useexpiration')); 216 $this->smarty->assign('startdatetext', $this->Lang('startdate')); 217 $this->smarty->assign('enddatetext', $this->Lang('enddate')); 218 219 echo $this->ProcessTemplate('editarticle.tpl'); 220 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |