/**
  * Fill an array with the data of Articles, which is ready to paste in a ComaLate-Template
  * @access public
  * @param integer Maximum The maximum count of Articles, which should be loaded, if it is -1 all Articles will be loaded
  * @param boolean ParserDate Should the timsamp of each article parsed to a hunam-readable value?
  * @param boolean DisplayAutor Put the author into the array? if it's 'false' the value of the config is decisive if not the name will be shown
  * @return array A ComaLate ready Array
  */
 function FillArray($Maximum = 6, $ParserDate = true, $DisplayAuthor = false)
 {
     $entries = array();
     $sql = "SELECT *\n\t\t\t\tFROM " . DB_PREFIX . "articles\n\t\t\t\tORDER BY article_date DESC\n\t\t\t\tLIMIT 0, {$Maximum}";
     // if $Maximum is -1 then show all entries
     if ($Maximum == -1) {
         $sql = "SELECT *\n\t\t\t\t\tFROM " . DB_PREFIX . "news\n\t\t\t\t\tORDER BY date DESC";
     }
     $entriesResult = $this->_SqlConnection->SqlQuery($sql);
     $displayAuthor = false;
     if ($this->_Config->Get('news_display_author', 1) == 1) {
         $displayAuthor = true;
     }
     if ($DisplayAuthor) {
         $displayAuthor = true;
     }
     $dateFormat = '';
     // get the date-format-string if the date should be human-readable
     if ($ParserDate) {
         $dateFormat = $this->_Config->Get('news_date_format', 'd.m.Y');
         $dateFormat .= ' ' . $this->_Config->Get('news_time_format', 'H:i:s');
     }
     // paste all entries into the array
     while ($entrie = mysql_fetch_object($entriesResult)) {
         $newsAuthor = '';
         // set the author if it should be so
         if ($displayAuthor) {
             $newsAuthor = $this->_ComaLib->GetUserByID($entrie->userid);
         }
         $entries[] = array('NEWS_DATE' => $ParserDate ? date($dateFormat, $entrie->date) : $entrie->date, 'NEWS_TEXT' => nl2br($entrie->text), 'NEWS_AUTHOR' => $newsAuthor, 'NEWS_TITLE' => $entrie->title, 'NEWS_ID' => $entrie->id);
     }
     return $entries;
 }
Exemplo n.º 2
0
 /**
  * @access public
  * @param integer MaxCount
  * @param boolean ConvertTimestamp
  * @param boolean ConvertUsername
  * @param boolean HideOld If this is true, all Events behind <param>Older</param> will be ignored
  * @param timestamp Older
  * @return array
  */
 function FillArray($MaxCount = 6, $Start = 0, $ConvertTimestamp = true, $ConvertUsername = true, $HideOlder = true, $Older = -1)
 {
     // get some config-values
     $dateDayFormat = $this->_Config->Get('dates_day_format', 'd.m.Y');
     $dateTimeFormat = $this->_Config->Get('datex_time_format', 'H:i');
     $dateFormat = $dateDayFormat . ' ' . $dateTimeFormat;
     $datesArray = array();
     if ($HideOlder && $Older == -1) {
         $Older = mktime() - 86400;
     }
     //24*60*60
     $sqlHide = '';
     if ($HideOlder) {
         $sqlHide = " WHERE date_date > {$Older} ";
     }
     if (!is_numeric($MaxCount)) {
         $MaxCount = 6;
     }
     $sql = "SELECT date_id, date_date, date_topic, date_creator, date_location, date_topic_html\n \t\t\t\tFROM " . DB_PREFIX . "dates\n \t\t\t\t{$sqlHide}\n \t\t\t\tORDER BY date_date ASC\n \t\t\t\tLIMIT {$Start}, {$MaxCount}";
     if ($MaxCount < 0) {
         $sql = "SELECT date_id, date_date, date_topic, date_creator, date_location, date_topic_html\n \t\t\t\tFROM " . DB_PREFIX . "dates\n \t\t\t\t{$sqlHide}\n \t\t\t\tORDER BY date_date ASC";
     }
     $datesResult = $this->_SqlConnection->SqlQuery($sql);
     while ($dateEntry = mysql_fetch_object($datesResult)) {
         // Convert the text from the database to html
         //	$Text = $dateEntry->date_topic;
         $datesArray[] = array('EVENT_ID' => $dateEntry->date_id, 'EVENT_DATE' => $ConvertTimestamp ? date($dateFormat, $dateEntry->date_date) : $dateEntry->date_date, 'EVENT_TOPIC' => $dateEntry->date_topic, 'EVENT_TOPIC_HTML' => $dateEntry->date_topic_html, 'EVENT_LOCATION' => $dateEntry->date_location, 'EVENT_CREATOR' => $ConvertTimestamp ? $this->_ComaLib->GetUserByID($dateEntry->date_creator) : $dateEntry->date_creator);
     }
     return $datesArray;
 }
Exemplo n.º 3
0
 /**
  * Shows a dialog, which makes it possible to confirm the deleting of a file or to delete the file if it's confirmed
  * @access private
  */
 function _deletePage()
 {
     // get the fileID of the file
     $fileID = GetPostOrGet('file_id');
     // try to get the confirmation
     $confirmation = GetPostOrGet('confirmation');
     // is the fileID something numeric? if not, stop the
     if (!is_numeric($fileID)) {
         return $this->_homePage();
     }
     // try to get the file-information from database
     $sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\tWHERE file_id = {$fileID}\r\n\t\t\t\tLIMIT 1";
     $fileResult = $this->_SqlConnection->SqlQuery($sql);
     if ($file = mysql_fetch_object($fileResult)) {
         // the confirmation is given: delete this file!
         if ($confirmation == 1) {
             // delete the database-entry
             $sql = "DELETE FROM " . DB_PREFIX . "files\r\n\t\t\t\t\t\tWHERE file_id = {$fileID}\r\n\t\t\t\t\t\tLIMIT 1";
             $this->_SqlConnection->SqlQuery($sql);
             // delete the file
             unlink($file->file_path);
         } else {
             // ask for the confirmation
             $out = sprintf($this->_AdminLang['do_you_really_want_to_delete_the_file_%filename%_irrevocablly'], utf8_encode($file->file_name)) . "<br />\r\n";
             $out .= sprintf($this->_AdminLang['this_file_was_uploaded_on_%date%_at%_%time%_oclock_by_%username%'], date('d.m.Y', $file->file_date), date('H:i:s', $file->file_date), $this->_ComaLib->GetUserByID($file->file_creator)) . "<br />\r\n";
             $out .= "<a href=\"admin.php?page=files&amp;action=delete&amp;file_id={$fileID}&amp;confirmation=1\" title=\"" . sprintf($this->_AdminLang['delete_file_%file%'], utf8_encode($file->file_name)) . "\"  class=\"button\">{$this->_AdminLang['yes']}</a>\r\n\t\t\t\t\t<a href=\"admin.php?page=files\" title=\"" . sprintf($this->_AdminLang['dont_delete_file_%file%'], utf8_encode($file->file_name)) . "\" class=\"button\">{$this->_AdminLang['no']}</a>";
             return $out;
         }
     }
     return $this->_homePage();
 }