Changeset 828 for trunk


Ignore:
Timestamp:
Mar 20, 2015, 10:22:50 PM (10 years ago)
Author:
chronos
Message:
  • Added: Single news items can be now shown as separate page. So they can cached by search engines also with date information. Also they can be accessed directly from News RSS channel.
Location:
trunk
Files:
3 edited

Legend:

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

    r816 r828  
    2828  function ShowBox()
    2929  {
    30     $Output = '<strong>'.T('System changes').':</strong><div class="NewsBox">';
    31     $DbResult = $this->Database->query('SELECT `News`.`Time`, `User`.`Name`, `News`.`Text`,`News`.`Title`'.
     30    $Output = '<strong><a href="'.$this->System->Link('/news/').'">'.T('News').':</a></strong><div class="NewsBox">';
     31    $DbResult = $this->Database->query('SELECT `News`.`Time`, `User`.`Name`, `News`.`Text`,`News`.`Title`, `News`.`Id` '.
    3232      ' FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10');
    3333    while($DbRow = $DbResult->fetch_assoc())
    34       $Output .= '<div><strong>'.$DbRow['Title'].' ('.HumanDate($DbRow['Time']).')</strong> <br />'.$DbRow['Text'].' ('.$DbRow['Name'].')</div>';
    35     $Output .= '<a href="'.$this->System->Link('/news/').'">'.T('All news').'</a>';
     34    {
     35      $Output .= '<h4><a href="'.$this->System->Link('/news/?a=item&amp;i='.$DbRow['Id']).'">'.$DbRow['Title'].'</a> ('.HumanDate($DbRow['Time']).')</h4>'.
     36        ' <div>'.$DbRow['Text'].' ('.$DbRow['Name'].')</div>';
     37    }
    3638    $Output .= '</div>';
    3739    return($Output);
     
    7072      else $Action = '';
    7173    if($Action == 'add2') $Output = $this->SaveNew();
    72     if($Action == 'add') $Output = $this->ShowAddForm();
     74    else if($Action == 'add') $Output = $this->ShowAddForm();
     75    else if($Action == 'item') $Output = $this->ShowItem();
    7376    else $Output = $this->ShowList();
    7477    return($Output);
     
    8588      $Output .= ' <a href="?a=add">'.T('Add').'</a>';
    8689    $Output .= '<div class="shoutbox">';
    87     $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, '.
     90    $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '.
    8891        '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']);
    8992    while($Line = $DbResult->fetch_assoc())
    90       $Output .= '<div><strong>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</strong><br/> '.$Line['Text'].' ('.$Line['User'].')</div>';
     93    {
     94      $Output .= '<h4><a href="?a=item&amp;i='.$Line['Id'].'">'.$Line['Title'].'</a> ('.HumanDate($Line['Time']).')</h4><div>'.$Line['Text'].' ('.$Line['User'].')</div>';
     95    }
    9196    $Output .= '</div>'.$PageList['Output'];
     97    return($Output);
     98  }
     99
     100  function ShowItem()
     101  {
     102    if(array_key_exists('i', $_GET))
     103    {
     104      $Output = '<h3>'.T('News').'</h3>';
     105      $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '.
     106        '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id` = '.($_GET['i'] * 1));
     107      if($DbResult->num_rows == 1)
     108      {
     109        $Line = $DbResult->fetch_assoc();
     110        $Output .= '<h4>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</h4><div>'.$Line['Text'].' ('.$Line['User'].')</div>';
     111      } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
     112    } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
     113    $Output .= '<br/><a href="'.$this->System->Link('/news/').'">'.T('All news').'</a>';
    92114    return($Output);
    93115  }
     
    129151    $Items = array();
    130152    $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`News`.`Time`) AS `UnixTime`, '.
    131       '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text` '.
     153      '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text`, `News`.`Id` '.
    132154      'FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10');
    133155    while($DbRow = $DbResult->fetch_assoc())
     
    136158     (
    137159       'Title' => $DbRow['Title'],
    138        'Link' =>  'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/news/'),
     160       'Link' =>  'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/news/?a=item&amp;i='.$DbRow['Id']),
    139161       'Description' => $DbRow['Text'].' ('.$DbRow['Name'].')',
    140162       'Time' => $DbRow['UnixTime'],
  • trunk/includes/Version.php

    r827 r828  
    66// and system will need database update.
    77
    8 $Revision = 827; // Subversion revision
     8$Revision = 828; // Subversion revision
    99$DatabaseRevision = 811; // Database structure revision
    10 $ReleaseTime = '2015-03-08';
     10$ReleaseTime = '2015-03-20';
  • trunk/style/style.css

    r825 r828  
    272272  border-bottom-width: 1px;
    273273  border-bottom-color: #e0e0e0;
    274   padding: 5px;
     274  padding: 0px;
     275}
     276
     277.shoutbox h4
     278{
     279  text-align: left;
     280  margin: 5px 0px 0px 0px;
    275281}
    276282
     
    355361}
    356362
     363.NewsBox h4
     364{
     365  text-align: left;
     366  margin: 5px 0px 0px 0px;
     367}
     368
    357369.Home
    358370{
     
    557569  width: 25%;
    558570}
     571
     572.Form
     573{
     574  margin-left: auto;
     575  margin-right: auto;
     576}
     577
     578.Form tr .Left
     579{
     580  text-align: right;
     581  font-weight: normal;
     582}
Note: See TracChangeset for help on using the changeset viewer.