Ignore:
Timestamp:
Jan 18, 2012, 7:44:38 AM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Aktuality převedeny na systémový modul.
Location:
trunk/Modules/News
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Modules/News/News.php

    r348 r350  
    11<?php
     2
     3include_once('NewsPage.php');
    24
    35function CategoryItemCompare($Item1, $Item2)
     
    79}
    810
    9 class News extends OldModule
    10 {
    11   var $Dependencies = array('User', 'Log');
    12   var $NewsCountPerCategory = 3;
    13   var $UploadedFilesFolder = 'aktuality/uploads/';
    14  
     11class News extends Model
     12{
     13  function __construct($Database, $System)
     14  {
     15    parent::__construct($Database, $System);
     16    $this->Name = 'News';
     17    $this->AddPropertyString('Title');
     18    $this->AddPropertyText('Content');
     19    $this->AddPropertyDateTime('Date');
     20    $this->AddPropertyDateTime('TargetDate');
     21    $this->AddPropertyString('Author');
     22    $this->AddPropertyString('IP');
     23    $this->AddPropertyOneToMany('Category', 'NewsCategory');
     24    $this->AddPropertyString('Enclosure');
     25    $this->AddPropertyOneToMany('User', 'User');
     26    $this->AddPropertyString('Link');
     27  }
     28
    1529  function ModifyContent($Content)
    1630  {
     
    4054    return($Result);
    4155  }
     56}
     57
     58class NewsCategory extends Model
     59{
     60  function __construct($Database, $System)
     61  {
     62    parent::__construct($Database, $System);
     63    $this->Name = 'NewsCategory';
     64    $this->AddPropertyString('Caption');
     65    $this->AddPropertyInteger('Permission');
     66    $this->AddPropertyInteger('Sequence');
     67    $this->AddPropertyInteger('Group');
     68    $this->AddPropertyString('RSS');
     69  }
     70}
     71
     72class ModuleNews extends Module
     73{
     74  var $NewsCountPerCategory = 3;
     75  var $UploadedFilesFolder = 'aktuality/uploads/';
     76
     77  function __construct($Database, $System)
     78  {
     79    parent::__construct($Database, $System);
     80    $this->Name = 'News';
     81    $this->Version = '1.0';
     82    $this->Creator = 'Chronos';
     83    $this->License = 'GNU/GPL';
     84    $this->Description = 'News and news groups management';
     85    $this->Dependencies = array('User', 'Log');
     86    $this->Models = array('News', 'NewsCategory');
     87  }
     88 
     89  function Install()
     90  {
     91    parent::Install();
     92  }
     93
     94  function UnInstall()
     95  {
     96    parent::UnInstall();
     97  } 
     98 
     99  function Init()
     100  {
     101    $this->System->Pages['aktuality'] = 'NewsPage';
     102  }
    42103 
    43104  function ShowNews($Category, $ItemCount, $DaysAgo)
     
    50111    $Row = $DbResult->fetch_array();
    51112    $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption'];     
    52     $Output .= '<div class="Action"><a href="aktuality/index.php?category='.$Category.'">Zobrazit</a>';
     113    $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>';
    53114    if($this->System->Models['User']->CheckPermission('News', 'Insert', 'Group', $Category))
    54       $Output .= ' <a href="aktuality/index.php?action=add&amp;category='.$Category.'">Přidat</a>';
     115      $Output .= ' <a href="aktuality/?action=add&amp;category='.$Category.'">Přidat</a>';
    55116    $Output .= '</div></div><div class="Content">';
    56117    $DbResult = $Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `News`.`Date`) ORDER BY `News`.`Date` DESC LIMIT 0,'.$ItemCount);
     
    67128        if($Row['Name'] == '') $Author = $Row['Author'];
    68129          else $Author = $Row['Name'];
    69         $Output .= '<tr><td onclick="window.location=\'aktuality/index.php?action=view&amp;id='.$Row['Id'].'\'" onmouseover="zobraz('."'new".$Category.$Index."'".')" style="cursor: pointer; margin: 0px;"><table class="NewsItemFrame"><tr><td style="font-size: '.$FontSize.'pt"><strong>'.$Row['Title'].'</strong></td><td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>';
     130        $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&amp;id='.$Row['Id'].'\'" onmouseover="zobraz('."'new".$Category.$Index."'".')" style="cursor: pointer; margin: 0px;"><table class="NewsItemFrame"><tr><td style="font-size: '.$FontSize.'pt"><strong>'.$Row['Title'].'</strong></td><td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>';
    70131        $Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->ModifyContent($Row['Content']);
    71132        if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
     
    143204    $Output .= '</tr></table>';
    144205
    145     $Output .= '<a href="aktuality/subscription.php"><img class="RSSIcon" src="images/rss20.png" alt="Aktuality přes RSS" /></a>  <a href="aktuality/subscription.php">Automatické sledování novinek</a>';
     206    $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>';
    146207    $Output .= '</div>';
    147208    return($Output);
     
    197258    setcookie('NewsSetting', $_COOKIE['NewsSetting'], time() + 60 * 60 * 24 * 365);
    198259  }
     260 
    199261}
    200262
Note: See TracChangeset for help on using the changeset viewer.