| [ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 if (!isset($gCms)) exit; 3 $detailpage = ''; 4 /* This code seems like it was copied here from action.default.php Seems unneeded. Commenting out. - Elijah Lofgren 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 28 if (!$this->CheckPermission('Modify News')) 29 { 30 echo $this->ShowErrors($this->Lang('needpermission', array('Modify News'))); 31 return; 32 } 33 34 if (isset($params['cancel'])) 35 { 36 $this->Redirect($id, 'defaultadmin', $returnid); 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 = 'published'; 52 if (isset($params['status'])) 53 { 54 $status = $params['status']; 55 } 56 57 $usedcategory = $this->GetPreference('default_category', ''); 58 if (isset($params['category'])) 59 { 60 $usedcategory = $params['category']; 61 } 62 63 $postdate = time(); 64 if (isset($params['postdate_Month'])) 65 { 66 $postdate = mktime($params['postdate_Hour'], $params['postdate_Minute'], $params['postdate_Second'], $params['postdate_Month'], $params['postdate_Day'], $params['postdate_Year']); 67 } 68 69 $useexp = 0; 70 if (isset($params['useexp'])) 71 { 72 $useexp = 1; 73 } 74 75 $userid = get_userid(); 76 77 $startdate = time(); 78 if (isset($params['startdate_Month'])) 79 { 80 $startdate = mktime($params['startdate_Hour'], $params['startdate_Minute'], $params['startdate_Second'], $params['startdate_Month'], $params['startdate_Day'], $params['startdate_Year']); 81 } 82 $enddate = strtotime('+6 months', time()); 83 if (isset($params['enddate_Month'])) 84 { 85 $enddate = mktime($params['enddate_Hour'], $params['enddate_Minute'], $params['enddate_Second'], $params['enddate_Month'], $params['enddate_Day'], $params['enddate_Year']); 86 } 87 88 $title = ''; 89 if (isset($params['title'])) 90 { 91 $title = $params['title']; 92 if ($title != '') 93 { 94 if ($content != '') 95 { 96 $articleid = $db->GenID(cms_db_prefix()."module_news_seq"); 97 $query = 'INSERT INTO '.cms_db_prefix().'module_news (news_id, news_category_id, news_title, news_data, summary, status, news_date, start_time, end_time, create_date, modified_date,author_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)'; 98 if ($useexp == 1) 99 { 100 $db->Execute($query, array($articleid, $usedcategory, $title, $content, $summary, $status, trim($db->DBTimeStamp($postdate), "'"), trim($db->DBTimeStamp($startdate), "'"), trim($db->DBTimeStamp($enddate), "'"), trim($db->DBTimeStamp(time()), "'"), trim($db->DBTimeStamp(time()), "'"), $userid)); 101 } 102 else 103 { 104 $db->Execute($query, array($articleid, $usedcategory, $title, $content, $summary, $status, trim($db->DBTimeStamp($postdate), "'"), trim($db->DBTimeStamp($startdate), "'"), NULL, trim($db->DBTimeStamp(time()), "'"), trim($db->DBTimeStamp(time()), "'"), $userid)); 105 } 106 107 //Update search index 108 $module =& $this->GetModuleInstance('Search'); 109 if ($module != FALSE) 110 { 111 $module->AddWords($this->GetName(), $articleid, 'article', $content . ' ' . $summary . ' ' . $title . ' ' . $title, $useexp == 1 ? $enddate : NULL); 112 } 113 114 #foreach ($usedcategories as $onecategory) 115 #{ 116 # $query = 'INSERT INTO '.cms_db_prefix().'module_news_article_categories (news_category_id, news_id) VALUES (?,?)'; 117 # $db->Execute($query, array($usedcategory, $articleid)); 118 #} 119 120 @$this->SendEvent('NewsArticleAdded', array('news_id' => $articleid, 'category_id' => $usedcategory, 'title' => $title, 'content' => $content, 'summary' => $summary, 'status' => $status, 'start_time' => $startdate, 'end_time' => $enddate, 'useexp' => $useexp)); 121 122 $params = array('tab_message'=> 'articleadded', 'active_tab' => 'articles'); 123 $this->Redirect($id, 'defaultadmin', $returnid, $params); 124 } 125 else 126 { 127 echo $this->ShowErrors($this->Lang('nocontentgiven')); 128 } 129 } 130 else 131 { 132 echo $this->ShowErrors($this->Lang('notitlegiven')); 133 } 134 } 135 136 $statusdropdown = array(); 137 $statusdropdown['Draft'] = 'draft'; 138 $statusdropdown['Published'] = 'published'; 139 140 $categorylist = array(); 141 $query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY hierarchy"; 142 $dbresult = $db->Execute($query); 143 144 while ($dbresult && $row = $dbresult->FetchRow()) 145 { 146 $categorylist[$row['long_name']] = $row['news_category_id']; 147 } 148 149 #Display template 150 $this->smarty->assign('authortext', ''); 151 $this->smarty->assign('inputauthor', ''); 152 $this->smarty->assign('hidden', ''); 153 $this->smarty->assign('startform', $this->CreateFormStart($id, 'addarticle', $returnid)); 154 $this->smarty->assign('endform', $this->CreateFormEnd()); 155 $this->smarty->assign('titletext', $this->Lang('title')); 156 $this->smarty->assign('inputtitle', $this->CreateInputText($id, 'title', $title, 30, 255)); 157 $this->smarty->assign('inputcontent', $this->CreateTextArea(true, $id, $content, 'content')); 158 $this->smarty->assign('inputsummary', $this->CreateTextArea(true, $id, $summary, 'summary', '', '', '', '', '80', '3')); 159 $this->smarty->assign_by_ref('postdate', $postdate); 160 $this->smarty->assign('postdateprefix', $id.'postdate_'); 161 $this->smarty->assign('inputexp', $this->CreateInputCheckbox($id, 'useexp', '1', $useexp, 'class="pagecheckbox"')); 162 $this->smarty->assign_by_ref('startdate', $startdate); 163 $this->smarty->assign('startdateprefix', $id.'startdate_'); 164 $this->smarty->assign_by_ref('enddate', $enddate); 165 $this->smarty->assign('enddateprefix', $id.'enddate_'); 166 $this->smarty->assign('status', $this->CreateInputDropdown($id, 'status', $statusdropdown, -1, $status)); 167 $this->smarty->assign('inputcategory', $this->CreateInputDropdown($id, 'category', $categorylist, -1, $usedcategory)); 168 $this->smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', lang('submit'))); 169 $this->smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', lang('cancel'))); 170 171 $this->smarty->assign('titletext', $this->Lang('title')); 172 $this->smarty->assign('categorytext', $this->Lang('category')); 173 $this->smarty->assign('summarytext', $this->Lang('summary')); 174 $this->smarty->assign('contenttext', $this->Lang('content')); 175 $this->smarty->assign('postdatetext', $this->Lang('postdate')); 176 $this->smarty->assign('statustext', lang('status')); 177 $this->smarty->assign('useexpirationtext', $this->Lang('useexpiration')); 178 $this->smarty->assign('startdatetext', $this->Lang('startdate')); 179 $this->smarty->assign('enddatetext', $this->Lang('enddate')); 180 181 echo $this->ProcessTemplate('editarticle.tpl'); 182 ?>
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 |