Changeset 873 for trunk/Modules/News/News.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/News.php
r790 r873 5 5 function CategoryItemCompare($Item1, $Item2) 6 6 { 7 if ($Item1['Index'] == $Item2['Index']) return (0);7 if ($Item1['Index'] == $Item2['Index']) return (0); 8 8 return ($Item1['Index'] > $Item2['Index']) ? -1 : 1; 9 9 } … … 81 81 )); 82 82 83 if ($this->System->ModuleManager->ModulePresent('Search'))83 if ($this->System->ModuleManager->ModulePresent('Search')) 84 84 { 85 85 $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content')); … … 95 95 $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption']; 96 96 $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>'; 97 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))97 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category)) 98 98 $Output .= ' <a href="aktuality/?action=add&category='.$Category.'">Přidat</a>'; 99 99 $Output .= '</div></div><div class="Content">'; … … 102 102 $Index = 0; 103 103 $FontSize = 12; 104 if ($DbResult->num_rows > 0)104 if ($DbResult->num_rows > 0) 105 105 { 106 106 $Output .= '<table class="NewsTable">'; 107 while ($Row = $DbResult->fetch_array())108 { 109 if ($Row['Name'] == '') $Author = $Row['Author'];107 while ($Row = $DbResult->fetch_array()) 108 { 109 if ($Row['Name'] == '') $Author = $Row['Author']; 110 110 else $Author = $Row['Name']; 111 111 $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&id='.$Row['Id']. … … 114 114 '<td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>'; 115 115 $Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->ModifyContent($Row['Content']); 116 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';117 118 if ($Row['Enclosure'] != '')116 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 117 118 if ($Row['Enclosure'] != '') 119 119 { 120 120 $Output .= '<br />Přílohy: '; 121 121 $Enclosures = explode(';', $Row['Enclosure']); 122 foreach ($Enclosures as $Enclosure)122 foreach ($Enclosures as $Enclosure) 123 123 { 124 if (file_exists($this->UploadedFilesFolder.$Enclosure))124 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 125 125 $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 126 126 } … … 133 133 } 134 134 $Output .= '</div></div>'; 135 return ($Output);135 return ($Output); 136 136 } 137 137 … … 142 142 $I = 1; 143 143 $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY Sequence'); 144 while ($NewsCategory = $DbResult->fetch_array())144 while ($NewsCategory = $DbResult->fetch_array()) 145 145 { 146 146 $this->NewsSetting[] = array('CategoryId' => $NewsCategory['Id'], 'Index' => $I, 'Enabled' => 1, … … 149 149 } 150 150 // Merge defaults with user setting 151 if (array_key_exists('NewsSetting', $_COOKIE))151 if (array_key_exists('NewsSetting', $_COOKIE)) 152 152 { 153 153 $NewsSettingCookie = unserialize($_COOKIE['NewsSetting']); 154 foreach ($this->NewsSetting as $Index => $this->NewSetting)155 { 156 if (array_key_exists($Index, $NewsSettingCookie))154 foreach ($this->NewsSetting as $Index => $this->NewSetting) 155 { 156 if (array_key_exists($Index, $NewsSettingCookie)) 157 157 $this->NewsSetting[$Index] = array_merge($this->NewSetting, $NewsSettingCookie[$Index]); 158 158 } … … 166 166 $this->LoadSettingsFromCookies(); 167 167 168 if (array_key_exists('Action', $_GET))168 if (array_key_exists('Action', $_GET)) 169 169 { 170 170 // Show news customize menu 171 if ($_GET['Action'] == 'CustomizeNews')171 if ($_GET['Action'] == 'CustomizeNews') 172 172 { 173 173 $Output .= $this->ShowCustomizeMenu(); … … 179 179 $ColumnCount = 2; 180 180 $Output .= '<table style="width: 100%"><tr>'; 181 for ($Column = 1; $Column <= $ColumnCount; $Column++)181 for ($Column = 1; $Column <= $ColumnCount; $Column++) 182 182 { 183 183 $Output .= '<td style="vertical-align: top; width: '.round(100 / $ColumnCount).'%;">'; 184 foreach ($this->NewsSetting as $SettingItem)185 if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column))184 foreach ($this->NewsSetting as $SettingItem) 185 if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column)) 186 186 $Output .= $this->ShowNews($SettingItem['CategoryId'], $SettingItem['ItemCount'], $SettingItem['DaysAgo']); 187 187 $Output .= '</td>'; … … 191 191 $Output .= '<a href="aktuality/subscription"><img class="RSSIcon" src="images/rss20.png" alt="Aktuality přes RSS" /></a> <a href="aktuality/subscription">Automatické sledování novinek</a>'; 192 192 $Output .= '</div>'; 193 return ($Output);193 return ($Output); 194 194 } 195 195 … … 200 200 $Output .= '<tr><th>Kategorie</th><th>Pozice</th><th>Zobrazit</th><th>Max. počet</th><th>Posledních dnů</th><th>Sloupec</th></tr>'; 201 201 $I = 0; 202 foreach ($this->NewsSetting as $SettingItem)202 foreach ($this->NewsSetting as $SettingItem) 203 203 { 204 204 $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$SettingItem['CategoryId']); 205 205 $NewsCategory = $DbResult->fetch_array(); 206 206 $Output .= '<tr><td>'.$NewsCategory['Caption'].'</td><td align="center"><input type="text" size="2" name="NewsCategoryIndex'.$I.'" value="'.$SettingItem['Index'].'" /></td><td align="center"><input type="checkbox" name="NewsCategoryEnabled'.$I.'"'; 207 if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"';207 if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"'; 208 208 $Output .= ' /></td>'. 209 209 '<td align="center"><input type="text" size="2" name="NewsCategoryCount'.$I.'" value="'.$SettingItem['ItemCount'].'" />'. … … 214 214 } 215 215 $Output .= '</table><input type="hidden" name="NewsCategoryCount" value="'.count($this->NewsSetting).'" /><input type="submit" value="Uložit" /></form></td></tr></table><br>'; 216 return ($Output);216 return ($Output); 217 217 } 218 218 … … 221 221 $Checkbox = array('' => 0, 'on' => 1); 222 222 $Setting = array(); 223 for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++)224 { 225 if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0;226 if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0;227 if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1;228 if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = '';223 for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++) 224 { 225 if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0; 226 if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0; 227 if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1; 228 if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = ''; 229 229 $Setting[] = array('CategoryId' => $_POST['NewsCategoryId'.$I], 'Enabled' => $Checkbox[$_POST['NewsCategoryEnabled'.$I]], 'ItemCount' => ($_POST['NewsCategoryCount'.$I]*1), 'DaysAgo' => ($_POST['NewsCategoryDaysAgo'.$I]*1), 'Index' => ($_POST['NewsCategoryIndex'.$I]*1), 230 230 'Group' => $_POST['NewsColumn'.$I]); … … 234 234 $Setting = array_reverse($Setting); 235 235 // Normalize indexes 236 foreach ($Setting as $Index => $Item)236 foreach ($Setting as $Index => $Item) 237 237 $Setting[$Index]['Index'] = $Index + 1; 238 238 … … 248 248 // Make HTML link from URL 249 249 $I = 0; 250 while (strpos($Content, 'http://') !== false)250 while (strpos($Content, 'http://') !== false) 251 251 { 252 252 $I = strpos($Content, 'http://'); 253 if (($I > 0) and ($Content{$I - 1} != '"'))253 if (($I > 0) and ($Content{$I - 1} != '"')) 254 254 { 255 255 $Result .= substr($Content, 0, $I); 256 256 $Content = substr($Content, $I); 257 if (strpos($Content, ' ') !== false)257 if (strpos($Content, ' ') !== false) 258 258 $URL = substr($Content, 0, strpos($Content, ' ')); 259 259 else $URL = substr($Content, 0); … … 267 267 } 268 268 $Result .= $Content; 269 return ($Result);269 return ($Result); 270 270 } 271 271 }
Note:
See TracChangeset
for help on using the changeset viewer.