Ejemplo n.º 1
0
 /**
  * Fetches number of events per month
  *
  * @access  public
  * @param   int     $user   User ID
  * @return  array   Query result
  */
 function GetYearEvents($user = null, $shared = null, $foreign = null, $year)
 {
     $table = Jaws_ORM::getInstance()->table('ec_events as events');
     $jdate = Jaws_Date::getInstance();
     $eventsByMonth = array();
     for ($m = 1; $m <= 12; $m++) {
         $table->reset();
         $table->select('events.id');
         $table->join('ec_recurrences as recs', 'events.id', 'recs.event');
         $table->join('ec_users', 'events.id', 'ec_users.event');
         if ($user !== null) {
             $table->where('ec_users.user', $user)->and();
         }
         if ($shared === true) {
             $table->where('shared', true)->and();
             $table->where('events.user', $user)->and();
         }
         if ($foreign === true) {
             $table->where('ec_users.owner', $user, '<>')->and();
         }
         $daysInMonth = $jdate->monthDays($year, $m);
         $start = $jdate->ToBaseDate($year, $m, 1);
         $start = $GLOBALS['app']->UserTime2UTC($start['timestamp']);
         $stop = $jdate->ToBaseDate($year, $m, $daysInMonth, 23, 59, 59);
         $stop = $GLOBALS['app']->UserTime2UTC($stop['timestamp']);
         $table->where('recs.start_time', $stop, '<')->and();
         $table->where('recs.stop_time', $start, '>');
         $table->groupBy('events.id');
         $eventsByMonth[$m] = count($table->fetchAll());
     }
     return $eventsByMonth;
 }
Ejemplo n.º 2
0
 /**
  * Prepares list of online users for datagrid
  *
  * @access  public
  * @return  array   Grid data
  */
 function GetOnlineUsers()
 {
     $filters = jaws()->request->fetch(array('active', 'logged', 'session_type', 'offset'), 'post');
     $filters['active'] = $filters['active'] == '-1' ? null : (bool) $filters['active'];
     $filters['logged'] = $filters['logged'] == '-1' ? null : (bool) $filters['logged'];
     $filters['type'] = $filters['session_type'] == '-1' ? null : $filters['session_type'];
     $filters['offset'] = (int) $filters['offset'];
     $sessions = $GLOBALS['app']->Session->GetSessions($filters['active'], $filters['logged'], $filters['type'], 50, $filters['offset']);
     if (Jaws_Error::IsError($sessions)) {
         return array();
     }
     $retData = array();
     $objDate = Jaws_Date::getInstance();
     foreach ($sessions as $session) {
         $usrData = array();
         $usrData['__KEY__'] = $session['sid'];
         if (empty($session['username'])) {
             $usrData['username'] = _t('USERS_ONLINE_ANONY');
         } else {
             $uProfile =& Piwi::CreateWidget('Link', $session['username'], $this->gadget->urlMap('Profile', array('user' => $session['username'])));
             $usrData['username'] = $uProfile->Get();
         }
         $usrData['nickname'] = $session['nickname'];
         $usrData['superadmin'] = $session['superadmin'] ? _t('GLOBAL_YES') : _t('GLOBAL_NO');
         $usrData['ip'] = "<abbr title='{$session['agent']}'>" . long2ip($session['ip']) . "</abbr>";
         $usrData['type'] = $session['type'];
         if ($session['online']) {
             $usrData['last_activetime'] = "<label class='lastactive' title='" . _t('USERS_ONLINE_ACTIVE') . "'>" . $objDate->Format($session['updatetime'], 'Y-m-d H:i') . "</label>";
         } else {
             $usrData['last_activetime'] = "<s class='lastactive' title='" . _t('USERS_ONLINE_INACTIVE') . "'>" . $objDate->Format($session['updatetime'], 'Y-m-d H:i') . "</s>";
         }
         $retData[] = $usrData;
     }
     return $retData;
 }
Ejemplo n.º 3
0
Archivo: Tags.php Proyecto: uda/jaws
 /**
  * Fetches files having specific tag
  *
  * @access  public
  * @param   string  $action     Action name
  * @param   array   $references Array of References
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($action, $references)
 {
     if (empty($action) || !is_array($references) || empty($references)) {
         return false;
     }
     $table = Jaws_ORM::getInstance()->table('directory');
     $table->select('id:integer', 'title', 'description', 'update_time');
     $result = $table->where('hidden', false)->and()->where('id', $references, 'in')->fetchAll();
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $files = array();
     foreach ($result as $r) {
         $file = array();
         $file['title'] = $r['title'];
         $file['url'] = $this->gadget->urlMap('Directory', array('id' => $r['id']));
         $file['outer'] = false;
         $file['image'] = 'gadgets/Directory/Resources/images/logo.png';
         $file['snippet'] = $r['description'];
         $file['date'] = $date->ToISO($r['update_time']);
         $files[$r['id']] = $file;
     }
     return $files;
 }
Ejemplo n.º 4
0
 /**
  * Returns an array with the results of a tag content
  *
  * @access  public
  * @param   string  $action     Action name
  * @param   array   $references Array of References
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($action, $references)
 {
     if (empty($action) || !is_array($references) || empty($references)) {
         return false;
     }
     $table = Jaws_ORM::getInstance()->table('linkdump_links');
     $table->select('id:integer', 'title', 'description', 'updatetime');
     $result = $table->where('id', $references, 'in')->fetchAll();
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $links = array();
     foreach ($result as $r) {
         $link = array();
         $link['title'] = $r['title'];
         $link['url'] = $this->gadget->urlMap('Link', array('id' => $r['id']));
         $link['outer'] = true;
         $link['image'] = 'gadgets/LinkDump/Resources/images/logo.png';
         $link['snippet'] = $r['description'];
         $link['date'] = $date->ToISO($r['updatetime']);
         $links[$r['id']] = $link;
     }
     return $links;
 }
Ejemplo n.º 5
0
 /**
  * Get activities count
  *
  * @access  public
  * @param   array   $filters
  * @return bool True or error
  */
 function GetActivitiesCount($filters = null)
 {
     $saTable = Jaws_ORM::getInstance()->table('activities')->select('count(id):integer');
     if (!empty($filters) && count($filters) > 0) {
         // from_date
         if (isset($filters['from_date']) && !empty($filters['from_date'])) {
             if (!is_numeric($filters['from_date'])) {
                 $objDate = Jaws_Date::getInstance();
                 $filters['from_date'] = $GLOBALS['app']->UserTime2UTC((int) $objDate->ToBaseDate(preg_split('/[- :]/', $filters['from_date']), 'U'));
             }
             $saTable->and()->where('date', $filters['from_date'], '>=');
         }
         // to_date
         if (isset($filters['to_date']) && !empty($filters['to_date'])) {
             if (!is_numeric($filters['to_date'])) {
                 $objDate = Jaws_Date::getInstance();
                 $filters['to_date'] = $GLOBALS['app']->UserTime2UTC((int) $objDate->ToBaseDate(preg_split('/[- :]/', $filters['to_date']), 'U'));
             }
             $saTable->and()->where('date', $filters['to_date'], '<=');
         }
         // gadget
         if (isset($filters['gadget']) && !empty($filters['gadget'])) {
             $saTable->and()->where('gadget', $filters['gadget']);
         }
         // domain
         if ($filters['domain'] != '-1') {
             $saTable->and()->where('domain', $filters['domain']);
         }
         // sync
         if (isset($filters['sync'])) {
             $saTable->and()->where('sync', (bool) $filters['sync']);
         }
     }
     return $saTable->fetchOne();
 }
Ejemplo n.º 6
0
 /**
  * Shows existing trackbacks for a given entry
  *
  * @access  public
  * @param   int     $id     entry id
  * @return  string  XHTML template content
  */
 function ShowTrackbacks($id)
 {
     if ($this->gadget->registry->fetch('trackback') == 'true') {
         $model = $this->gadget->model->load('Trackbacks');
         $trackbacks = $model->GetTrackbacks($id);
         $tpl = $this->gadget->template->load('Trackbacks.html');
         $tpl->SetBlock('trackbacks');
         $tburi = $this->gadget->urlMap('Trackback', array('id' => $id), true);
         $tpl->SetVariable('TrackbackURI', $tburi);
         if (!Jaws_Error::IsError($trackbacks)) {
             $date = Jaws_Date::getInstance();
             foreach ($trackbacks as $tb) {
                 $tpl->SetBlock('trackbacks/item');
                 $tpl->SetVariablesArray($tb);
                 $tpl->SetVariable('createtime-iso', $tb['createtime']);
                 $tpl->SetVariable('createtime', $date->Format($tb['createtime']));
                 $tpl->SetVariable('createtime-monthname', $date->Format($tb['createtime'], 'MN'));
                 $tpl->SetVariable('createtime-monthabbr', $date->Format($tb['createtime'], 'M'));
                 $tpl->SetVariable('createtime-month', $date->Format($tb['createtime'], 'm'));
                 $tpl->SetVariable('createtime-dayname', $date->Format($tb['createtime'], 'DN'));
                 $tpl->SetVariable('createtime-dayabbr', $date->Format($tb['createtime'], 'D'));
                 $tpl->SetVariable('createtime-day', $date->Format($tb['createtime'], 'd'));
                 $tpl->SetVariable('createtime-year', $date->Format($tb['createtime'], 'Y'));
                 $tpl->SetVariable('createtime-time', $date->Format($tb['createtime'], 'g:ia'));
                 $tpl->ParseBlock('trackbacks/item');
             }
         }
         $tpl->ParseBlock('trackbacks');
         return $tpl->Get();
     }
 }
Ejemplo n.º 7
0
 /**
  * Updates the quote
  *
  * @access  public
  * @param   int     $id         Quote ID
  * @param   string  $title
  * @param   string  $quotation
  * @param   int     $gid        Group ID
  * @param   string  $start_time
  * @param   string  $stop_time
  * @param   bool    $show_title
  * @param   bool    $published
  * @return  mixed   True on Success or Jaws_Error on failure
  */
 function UpdateQuote($id, $title, $quotation, $gid, $start_time, $stop_time, $show_title, $published)
 {
     $date = Jaws_Date::getInstance();
     $params['title'] = $title;
     $params['quotation'] = $quotation;
     $params['gid'] = $gid;
     $params['start_time'] = null;
     $params['stop_time'] = null;
     if (!empty($start_time)) {
         $start_time = $date->ToBaseDate(preg_split('/[- :]/', $start_time), 'Y-m-d H:i:s');
         $params['start_time'] = $GLOBALS['app']->UserTime2UTC($start_time, 'Y-m-d H:i:s');
     }
     if (!empty($stop_time)) {
         $stop_time = $date->ToBaseDate(preg_split('/[- :]/', $stop_time), 'Y-m-d H:i:s');
         $params['stop_time'] = $GLOBALS['app']->UserTime2UTC($stop_time, 'Y-m-d H:i:s');
     }
     $params['updatetime'] = Jaws_DB::getInstance()->date();
     $params['show_title'] = (bool) $show_title;
     $params['published'] = (bool) $published;
     $quotesTable = Jaws_ORM::getInstance()->table('quotes');
     $result = $quotesTable->update($params)->where('id', (int) $id)->exec();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('QUOTES_QUOTE_NOT_UPDATED'), RESPONSE_ERROR);
         return new Jaws_Error(_t('QUOTES_QUOTE_NOT_UPDATED'));
     }
     $GLOBALS['app']->Session->PushLastResponse(_t('QUOTES_QUOTE_UPDATED'), RESPONSE_NOTICE);
     return true;
 }
Ejemplo n.º 8
0
 /**
  * Returns an array with the results of a tag content
  *
  * @access  public
  * @param   string  $action     Action name
  * @param   array   $references Array of References
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($action, $references)
 {
     if (empty($action) || !is_array($references) || empty($references)) {
         return false;
     }
     $sptTable = Jaws_ORM::getInstance()->table('static_pages_translation');
     $sptTable->select('page_id:integer', 'group_id', 'title', 'content', 'language', 'fast_url', 'static_pages_translation.updated');
     $sptTable->join('static_pages', 'static_pages.page_id', 'static_pages_translation.base_id');
     $result = $sptTable->where('translation_id', $references, 'in')->fetchAll();
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $pages = array();
     foreach ($result as $p) {
         if (!$this->gadget->GetPermission('AccessGroup', $p['group_id'])) {
             continue;
         }
         $page = array();
         $page['title'] = $p['title'];
         $url = $this->gadget->urlMap('Page', array('pid' => empty($p['fast_url']) ? $p['page_id'] : $p['fast_url'], 'language' => $p['language']));
         $page['url'] = $url;
         $page['image'] = 'gadgets/StaticPage/Resources/images/logo.png';
         $page['snippet'] = $p['content'];
         $page['date'] = $date->ToISO($p['updated']);
         $pages[$p['page_id']] = $page;
     }
     return $pages;
 }
Ejemplo n.º 9
0
 /**
  * Displays an index of gallerie.
  *
  * @access  public
  * @return  string XHTML template content
  */
 function Album()
 {
     $tpl = $this->gadget->template->load('Albums.html');
     $tpl->SetBlock('albums');
     $tpl->SetVariable('title', _t('PHOO_ALBUMS'));
     $model = $this->gadget->model->load('Albums');
     $albums = $model->GetAlbumList();
     if (!Jaws_Error::IsError($albums)) {
         $date = Jaws_Date::getInstance();
         foreach ($albums as $album) {
             if (!isset($album['qty'])) {
                 continue;
             }
             $tpl->SetBlock('albums/item');
             $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $album['thumb']);
             if (!Jaws_Error::IsError($imgData)) {
                 $tpl->SetVariable('width', $imgData[0]);
                 $tpl->SetVariable('height', $imgData[1]);
             }
             $url = $this->gadget->urlMap('ViewAlbum', array('id' => $album['id']));
             $tpl->SetVariable('url', $url);
             $tpl->SetVariable('name', $album['name']);
             $tpl->SetVariable('filename', $album['filename']);
             $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $album['thumb']));
             $tpl->SetVariable('howmany', _t('PHOO_NUM_PHOTOS_ALBUM', $album['qty']));
             $tpl->SetVariable('description', $this->gadget->ParseText($album['description']));
             $tpl->SetVariable('createtime', $date->Format($album['createtime']));
             $tpl->ParseBlock('albums/item');
         }
     }
     $tpl->ParseBlock('albums');
     return $tpl->Get();
 }
Ejemplo n.º 10
0
 /**
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function LoginHistory($limit = 5)
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return false;
     }
     $logModel = Jaws_Gadget::getInstance('Logs')->model->load('Logs');
     $logs = $logModel->GetLogs(array('gadget' => 'Users', 'action' => 'Login', 'user' => $GLOBALS['app']->Session->GetAttribute('user')), $limit);
     if (Jaws_Error::IsError($logs) || empty($logs)) {
         return false;
     }
     $tpl = $this->gadget->template->load('LoginHistory.html');
     $tpl->SetBlock('history');
     $date = Jaws_Date::getInstance();
     $tpl->SetVariable('title', _t('LOGS_LOGIN_HISTORY'));
     foreach ($logs as $log) {
         $tpl->SetBlock('history/' . $log['status']);
         $tpl->SetVariable('ip', long2ip($log['ip']));
         $tpl->SetVariable('agent', $log['agent']);
         $tpl->SetVariable('status_title', _t('GLOBAL_HTTP_ERROR_TITLE_' . $log['status']));
         $tpl->SetVariable('date', $date->Format($log['insert_time'], 'd MN Y H:i'));
         $tpl->ParseBlock('history/' . $log['status']);
     }
     $tpl->ParseBlock('history');
     return $tpl->Get();
 }
Ejemplo n.º 11
0
 /**
  * Look for a term and prints it
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ViewTerm()
 {
     $term = jaws()->request->fetch('term', 'get');
     $term = Jaws_XSS::defilter($term);
     $model = $this->gadget->model->load('Term');
     $term = $model->GetTerm($term);
     if (!Jaws_Error::IsError($term) && isset($term['term'])) {
         $this->SetTitle($term['term']);
         $tpl = $this->gadget->template->load('ViewTerm.html');
         $tpl->SetBlock('definition');
         $tpl->SetVariable('title', $this->gadget->title);
         $date = Jaws_Date::getInstance();
         $tpl->SetBlock('definition/term');
         $tpl->SetVariable('term', $term['term']);
         $tid = empty($term['fast_url']) ? $term['id'] : $term['fast_url'];
         $tpl->SetVariable('url', $this->gadget->urlMap('ViewTerm', array('term' => $tid)));
         $tpl->SetVariable('description', $this->gadget->ParseText($term['description']));
         $tpl->SetVariable('created_in', _t('GLOBAL_CREATETIME'));
         $tpl->SetVariable('updated_in', _t('GLOBAL_UPDATETIME'));
         $tpl->SetVariable('createtime', $date->Format($term['createtime']));
         $tpl->SetVariable('updatetime', $date->Format($term['updatetime']));
         $tpl->ParseBlock('definition/term');
         $tpl->ParseBlock('definition');
     } else {
         return Jaws_HTTPError::Get(404);
     }
     return $tpl->Get();
 }
Ejemplo n.º 12
0
Archivo: Search.php Proyecto: uda/jaws
 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql   Prepared search(WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
            [id], [title], [description], [user_filename], [update_time]
         FROM [[directory]]
         WHERE
             [hidden] = {hidden}
         ';
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY id desc';
     $params = array();
     $params['hidden'] = false;
     $types = array('text', 'text', 'text', 'integer');
     $result = Jaws_DB::getInstance()->queryAll($sql, $params, $types);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $files = array();
     foreach ($result as $p) {
         $file = array();
         $file['title'] = $p['title'];
         $file['url'] = $this->gadget->urlMap('Directory', array('id' => $p['id']));
         $file['image'] = 'gadgets/Directory/Resources/images/logo.png';
         $file['snippet'] = $p['description'];
         $file['date'] = $p['update_time'];
         $stamp = $p['update_time'];
         $files[$stamp] = $file;
     }
     return $files;
 }
Ejemplo n.º 13
0
 /**
  * Returns an array with the results of a tag content
  *
  * @access  public
  * @param   string  $action     Action name
  * @param   array   $references Array of References
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($action, $references)
 {
     if (empty($action) || !is_array($references) || empty($references)) {
         return false;
     }
     $table = Jaws_ORM::getInstance()->table('blog');
     $table->select('id:integer', 'fast_url', 'title', 'summary', 'text', 'updatetime');
     $result = $table->where('id', $references, 'in')->fetchAll();
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $posts = array();
     foreach ($result as $r) {
         $post = array();
         $post['title'] = $r['title'];
         $post['url'] = $this->gadget->urlMap('SingleView', array('id' => $r['fast_url']));
         $post['outer'] = false;
         $post['image'] = 'gadgets/Blog/Resources/images/logo.png';
         $post['snippet'] = $r['summary'];
         $post['date'] = $date->ToISO($r['updatetime']);
         $posts[$r['id']] = $post;
     }
     return $posts;
 }
Ejemplo n.º 14
0
 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql  Prepared search (WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     // TODO: must be converted to Jaws_ORM
     $sql = '
         SELECT
             [id], [title], [contents], [updatetime]
         FROM [[blocks]]
         ';
     $sql .= ' WHERE ' . $pSql;
     $sql .= ' ORDER BY [createtime] desc';
     $result = Jaws_DB::getInstance()->queryAll($sql);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $blocks = array();
     foreach ($result as $r) {
         $block = array();
         $block['title'] = $r['title'];
         $block['url'] = $this->gadget->urlMap('Block', array('id' => $r['id']));
         $block['image'] = 'gadgets/Blocks/Resources/images/logo.png';
         $block['snippet'] = $r['contents'];
         $block['date'] = $date->ToISO($r['updatetime']);
         $blocks[] = $block;
     }
     return $blocks;
 }
Ejemplo n.º 15
0
 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql  Prepared search (WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
             [id], [title], [url], [description], [updatetime]
         FROM [[linkdump_links]]
         ';
     $sql .= ' WHERE ' . $pSql;
     $sql .= ' ORDER BY [createtime] desc';
     $result = Jaws_DB::getInstance()->queryAll($sql);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $links = array();
     foreach ($result as $r) {
         $link = array();
         $link['title'] = $r['title'];
         $link['url'] = $this->gadget->urlMap('Link', array('id' => $r['id']));
         $link['outer'] = true;
         $link['image'] = 'gadgets/LinkDump/Resources/images/logo.png';
         $link['snippet'] = $r['description'];
         $link['date'] = $date->ToISO($r['updatetime']);
         $links[] = $link;
     }
     return $links;
 }
Ejemplo n.º 16
0
 /**
  * Gets the start date
  *
  * @access  public
  * @return  string  Start date(taken from registry)
  */
 function GetStartDate()
 {
     $date = Jaws_Date::getInstance();
     $model = $this->gadget->model->load('Visitors');
     $start = $model->GetStartDate();
     return $date->Format($start);
 }
Ejemplo n.º 17
0
 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql   Prepared search (WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $params = array('active' => true);
     $sql = '
         SELECT
             [category],
             [question],
             [answer],
             [faq_position],
             [updatetime]
         FROM [[faq]]
         WHERE [published] = {active}
         ';
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY [createtime] desc';
     $result = Jaws_DB::getInstance()->queryAll($sql, $params);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $questions = array();
     $date = Jaws_Date::getInstance();
     foreach ($result as $r) {
         $question = array();
         $question['title'] = $r['question'];
         $question['url'] = $this->gadget->urlMap('ViewCategory', array('id' => $r['category'])) . '#Question' . $r['faq_position'];
         $question['image'] = 'gadgets/Faq/Resources/images/logo.png';
         $question['snippet'] = $r['answer'];
         $question['date'] = $date->ToISO($r['updatetime']);
         $questions[] = $question;
     }
     return $questions;
 }
Ejemplo n.º 18
0
 /**
  * Displays a random image from the gallery listed as a Moblog
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Moblog($aid)
 {
     $tpl = $this->gadget->template->load('Moblog.html');
     $tpl->SetBlock('moblog');
     $tpl->SetVariable('title', _t('PHOO_ACTIONS_MOBLOG'));
     $model = $this->gadget->model->load('Moblog');
     $moblog = $model->GetMoblog($aid);
     if (!Jaws_Error::IsError($moblog)) {
         $objDate = Jaws_Date::getInstance();
         include_once JAWS_PATH . 'include/Jaws/Image.php';
         foreach ($moblog as $mb) {
             $imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $mb['thumb']);
             if (Jaws_Error::IsError($imgData)) {
                 continue;
             }
             $tpl->SetBlock('moblog/item');
             $tpl->SetVariable('url', $this->gadget->urlMap('ViewImage', array('id' => $mb['id'], 'albumid' => $mb['phoo_album_id'])));
             $tpl->SetVariable('name', $mb['name']);
             $tpl->SetVariable('img_desc', $mb['stripped_description']);
             $tpl->SetVariable('filename', $mb['filename']);
             $tpl->SetVariable('width', $imgData[0]);
             $tpl->SetVariable('height', $imgData[1]);
             $tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $mb['thumb']));
             $tpl->SetVariable('createtime', $objDate->Format($mb['createtime']));
             $tpl->ParseBlock('moblog/item');
         }
     }
     $tpl->ParseBlock('moblog');
     return $tpl->Get();
 }
Ejemplo n.º 19
0
Archivo: Poll.php Proyecto: uda/jaws
 /**
  * Updates the title of a poll
  *
  * @access  public
  * @param   int     $pid            Poll's ID
  * @param   string  $title          Poll's title
  * @param   int     $gid            group ID
  * @param   string  $start_time     start date time
  * @param   string  $stop_time      stop date time
  * @param   string  $type
  * @param   string  $restriction
  * @param   string  $result_view
  * @param   bool    $published
  * @return  mixed   True if the poll was updated and Jaws_Error on error
  */
 function UpdatePoll($pid, $title, $gid, $start_time, $stop_time, $type, $restriction, $result_view, $published)
 {
     $date = Jaws_Date::getInstance();
     $pollData = array();
     $pollData['title'] = $title;
     $pollData['group'] = $gid;
     $pollData['start_time'] = null;
     $pollData['stop_time'] = null;
     if (!empty($start_time)) {
         $start_time = $date->ToBaseDate(preg_split('/[- :]/', $start_time), 'Y-m-d H:i:s');
         $pollData['start_time'] = $GLOBALS['app']->UserTime2UTC($start_time);
     }
     if (!empty($stop_time)) {
         $stop_time = $date->ToBaseDate(preg_split('/[- :]/', $stop_time), 'Y-m-d H:i:s');
         $pollData['stop_time'] = $GLOBALS['app']->UserTime2UTC($stop_time);
     }
     $pollData['type'] = $type;
     $pollData['restriction'] = $restriction;
     $pollData['result_view'] = $result_view;
     $pollData['published'] = $published;
     $table = Jaws_ORM::getInstance()->table('poll');
     $result = $table->update($pollData)->where('id', (int) $pid)->exec();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse($result->GetMessage(), RESPONSE_ERROR);
         return new Jaws_Error(_t('POLL_ERROR_POLL_NOT_UPDATED'));
     }
     $GLOBALS['app']->Session->PushLastResponse(_t('POLL_POLLS_UPDATED'), RESPONSE_NOTICE);
     return true;
 }
Ejemplo n.º 20
0
 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql  Prepared search (WHERE) SQL
  * @return  mixed   An array of entries that matches a certain pattern or False on error
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
             [id], [term], [description], [createtime]
         FROM [[glossary]]
         ';
     $sql .= ' WHERE ' . $pSql;
     $sql .= " ORDER BY [createtime] desc";
     $result = Jaws_DB::getInstance()->queryAll($sql);
     if (Jaws_Error::IsError($result)) {
         return false;
     }
     $date = Jaws_Date::getInstance();
     $entries = array();
     foreach ($result as $r) {
         $entry = array();
         $entry['title'] = $r['term'];
         $entry['url'] = $this->gadget->urlMap('ViewTerm', array('term' => $r['id']));
         $entry['image'] = 'gadgets/Glossary/Resources/images/logo.png';
         $entry['snippet'] = $r['description'];
         $entry['date'] = $date->ToISO($r['createtime']);
         $stamp = str_replace(array('-', ':', ' '), '', $r['createtime']);
         $entries[$stamp] = $entry;
     }
     return $entries;
 }
Ejemplo n.º 21
0
 /**
  * Returns an array of the search results
  *
  * @access  public
  * @param   string  $pSql  Prepared search(WHERE) SQL
  * @return  array   Array of entries match a certain pattern
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
             [id], [title], [quotation], [updatetime]
         FROM [[quotes]]
         WHERE [published] = {published}
         ';
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY [id] desc';
     $params = array();
     $params['published'] = true;
     $result = Jaws_DB::getInstance()->queryAll($sql, $params);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $quotations = array();
     foreach ($result as $r) {
         $quotation = array();
         $quotation['title'] = $r['title'];
         $quotation['url'] = $this->gadget->urlMap('ViewQuote', array('id' => $r['id']));
         $quotation['image'] = 'gadgets/Quotes/Resources/images/logo.png';
         $quotation['snippet'] = $r['quotation'];
         $quotation['date'] = $date->ToISO($r['updatetime']);
         $quotations[] = $quotation;
     }
     return $quotations;
 }
Ejemplo n.º 22
0
 /**
  * Update a banner
  *
  * @access   public
  * @param    int     $bid         banner ID
  * @param    string  $title       banner title
  * @param    string  $url
  * @param    int     $gid         group ID
  * @param    string  $banner
  * @param    string  $template
  * @param    int     $views_limit
  * @param    int     $clicks_limit
  * @param    string  $start_time
  * @param    string  $stop_time
  * @param    bool    $random
  * @param    bool    $published
  * @return   bool    True on Success, False on Failure
  */
 function UpdateBanner($bid, $title, $url, $gid, $banner, $template, $views_limit, $clicks_limit, $start_time, $stop_time, $random, $published)
 {
     $date = Jaws_Date::getInstance();
     $bData['title'] = $title;
     $bData['url'] = $url;
     $bData['gid'] = empty($gid) || !is_numeric($gid) ? 0 : $gid;
     $bData['banner'] = $banner;
     $bData['template'] = $template;
     $bData['views_limitation'] = empty($views_limit) || !is_numeric($views_limit) ? 0 : $views_limit;
     $bData['clicks_limitation'] = empty($clicks_limit) || !is_numeric($clicks_limit) ? 0 : $clicks_limit;
     $bData['start_time'] = null;
     $bData['stop_time'] = null;
     if (!empty($start_time)) {
         $start_time = $date->ToBaseDate(preg_split('/[- :]/', $start_time), 'Y-m-d H:i:s');
         $bData['start_time'] = $GLOBALS['app']->UserTime2UTC($start_time, 'Y-m-d H:i:s');
     }
     if (!empty($stop_time)) {
         $stop_time = $date->ToBaseDate(preg_split('/[- :]/', $stop_time), 'Y-m-d H:i:s');
         $bData['stop_time'] = $GLOBALS['app']->UserTime2UTC($stop_time, 'Y-m-d H:i:s');
     }
     $bData['updatetime'] = Jaws_DB::getInstance()->date();
     $bData['random'] = $random;
     $bData['published'] = (bool) $published;
     $bannersTable = Jaws_ORM::getInstance()->table('banners');
     $res = $bannersTable->update($bData)->where('id', $bid)->exec();
     if (Jaws_Error::IsError($res)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
         return false;
     }
     $GLOBALS['app']->Session->PushLastResponse(_t('BANNER_BANNERS_UPDATED', $title), RESPONSE_NOTICE);
     return true;
 }
Ejemplo n.º 23
0
 /**
  * Prepares data for pages grid
  *
  * @access  public
  * @param   int     $group      Group ID
  * @param   mixed   $status     Status of the page(s) (1/0 or Y/N)
  * @param   string  $search     Keywords(title/description) of the pages we are looking for
  * @param   int     $orderBy    Order by
  * @param   int     $limit      Data limit
  * @return  array   Grid data
  */
 function GetPages($group, $status, $search, $orderBy, $limit)
 {
     $pModel = $this->gadget->model->loadAdmin('Page');
     $tModel = $this->gadget->model->load('Translation');
     $pages = $pModel->SearchPages($group, $status, $search, $orderBy, $limit);
     if (Jaws_Error::IsError($pages)) {
         return array();
     }
     $data = array();
     $edit_url = BASE_SCRIPT . '?gadget=StaticPage&amp;action=EditPage&amp;id=';
     $add_turl = BASE_SCRIPT . '?gadget=StaticPage&amp;action=AddNewTranslation&amp;page=';
     $edit_turl = BASE_SCRIPT . '?gadget=StaticPage&amp;action=EditTranslation&amp;id=';
     $date = Jaws_Date::getInstance();
     foreach ($pages as $page) {
         $pageData = array();
         $pageData['title'] = '<a href="' . $edit_url . $page['page_id'] . '">' . $page['title'] . '</a>';
         $param = array('pid' => !empty($page['fast_url']) ? $page['fast_url'] : $page['page_id']);
         $furl = $this->gadget->urlMap('Page', $param);
         $pageData['furl'] = '<a href="' . $furl . '">' . $page['fast_url'] . '</a>';
         $pageData['group'] = $page['gtitle'];
         $pageData['trans'] = '';
         $pageTranslation = $tModel->GetTranslationsOfPage($page['page_id']);
         if (is_array($pageTranslation)) {
             $transString = '';
             $counter = 0;
             foreach ($pageTranslation as $trans) {
                 if ($trans['language'] == $page['base_language']) {
                     continue;
                 }
                 $transString .= '<small><a href="' . $edit_turl . $trans['translation_id'] . '">' . $trans['language'] . '</a></small>, ';
                 if ($counter % 4 == 0 && $counter != 0) {
                     $transString .= '<br />';
                 }
                 $counter++;
             }
             $pageData['trans'] .= substr($transString, 0, -2) . '&nbsp;';
         }
         $pageData['trans'] .= '<small>[<a href="' . $add_turl . $page['page_id'] . '">' . _t('STATICPAGE_ADD_LANGUAGE') . '</a>]</small>';
         if ($page['published'] === true) {
             $pageData['published'] = _t('STATICPAGE_PUBLISHED');
         } else {
             $pageData['published'] = _t('STATICPAGE_DRAFT');
         }
         $pageData['date'] = $date->Format($page['updated'], 'Y-m-d H:i:s');
         $actions = '';
         if ($this->gadget->GetPermission('EditPage')) {
             $link =& Piwi::CreateWidget('Link', _t('GLOBAL_EDIT'), $edit_url . $page['page_id'], STOCK_EDIT);
             $actions .= $link->Get() . '&nbsp;';
         }
         if ($this->gadget->GetPermission('DeletePage')) {
             $link =& Piwi::CreateWidget('Link', _t('GLOBAL_DELETE'), "javascript:deletePage('{$page['page_id']}');", STOCK_DELETE);
             $actions .= $link->Get() . '&nbsp;';
         }
         $pageData['actions'] = $actions;
         $pageData['__KEY__'] = $page['page_id'];
         $data[] = $pageData;
     }
     return $data;
 }
Ejemplo n.º 24
0
 /**
  * Get entries
  *
  * @access  public
  * @param   int     $cat            Category ID
  * @param   array   $conditions     Array with extra conditions
  * @param   int     $extralimit     Integer which limits number of results
  * @param   int     $extraoffset    Integer which sets an offset to skip results
  * @return  array   Returns an array of entries and Jaws_Error on error
  */
 function GetEntries($cat = null, $conditions = null, $extralimit = null, $extraoffset = null)
 {
     $now = Jaws_DB::getInstance()->date();
     $blogTable = Jaws_ORM::getInstance()->table('blog');
     $blogTable->select('blog.id:integer', 'username', 'email', 'nickname', 'blog.title', 'blog.fast_url', 'summary', 'text', 'blog.publishtime', 'blog.updatetime', 'comments:integer', 'clicks:integer', 'allow_comments:boolean', 'image');
     $blogTable->join('users', 'blog.user_id', 'users.id', 'left');
     if (!is_null($cat)) {
         $blogTable->join('blog_entrycat', 'blog.id', 'blog_entrycat.entry_id', 'left');
         if (empty($cat)) {
             $blogTable->where('blog_entrycat.category_id', null, 'is null');
         } else {
             $blogTable->where('blog_entrycat.category_id', (int) $cat);
         }
     }
     $blogTable->and()->where('published', true)->and()->where('blog.publishtime', $now, '<=');
     if (!is_null($conditions)) {
         foreach ($conditions as $condition) {
             $blogTable->and()->where($condition[0], $condition[1], $condition[2]);
         }
     }
     if (is_null($extralimit)) {
         $extralimit = $this->gadget->registry->fetch('last_entries_limit');
     }
     $result = $blogTable->limit($extralimit, $extraoffset)->orderBy('blog.publishtime desc')->fetchAll();
     if (Jaws_Error::IsError($result)) {
         return new Jaws_Error(_t('BLOG_ERROR_GETTING_ENTRIES'));
     }
     $entries = array();
     $ids = array();
     //Only load Jaws_Gravatar if we really have entries
     if (count($result) > 0) {
         $date = Jaws_Date::getInstance();
     }
     foreach ($result as $r) {
         $r['avatar_source'] = Jaws_Gravatar::GetGravatar($r['email']);
         $r['categories'] = array();
         $entries[$r['id']] = $r;
         $ids[] = $r['id'];
     }
     $result = null;
     $model = $this->gadget->model->load('Categories');
     $categories = $model->GetCategoriesInEntries($ids);
     foreach ($categories as $cat) {
         $entries[$cat['entry_id']]['categories'][] = array('id' => $cat['id'], 'name' => $cat['name'], 'fast_url' => $cat['fast_url']);
     }
     $categories = null;
     foreach ($entries as $key => $entry) {
         if (empty($entry['categories'])) {
             $entries[$key]['categories'][] = array('id' => 0, 'name' => _t('BLOG_UNCATEGORIZED'), 'fast_url' => '');
         } else {
             foreach ($entry['categories'] as $cat) {
                 if (!$this->gadget->GetPermission('CategoryAccess', $cat['id'])) {
                     unset($entries[$key]);
                 }
             }
         }
     }
     return $entries;
 }
Ejemplo n.º 25
0
 /**
  * Get user's preferences of this gadget
  *
  * @access  public
  * @return  array   Formatted array for using in Users Preferences action
  */
 function Execute()
 {
     $result = array();
     $result['unit'] = array('title' => _t('WEATHER_UNIT'), 'values' => array('metric' => _t('WEATHER_UNIT_METRIC'), 'imperial' => _t('WEATHER_UNIT_IMPERIAL')));
     $now = time();
     $objDate = Jaws_Date::getInstance();
     $result['date_format'] = array('title' => _t('WEATHER_DATE_FORMAT'), 'values' => array('DN' => $objDate->Format($now, 'DN'), 'd MN' => $objDate->Format($now, 'd MN'), 'DN d MN' => $objDate->Format($now, 'DN d MN')));
     return $result;
 }
Ejemplo n.º 26
0
 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql   Prepared search (WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $params = array('published' => true);
     $sql = '
         SELECT
             [id],
             [title],
             [fast_url],
             [summary],
             [text],
             [categories],
             [createtime],
             [updatetime]
         FROM [[blog]]
         WHERE
             [published] = {published}
           AND
             [createtime] <= {now}
         ';
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY [createtime] desc';
     $params['now'] = Jaws_DB::getInstance()->date();
     $params['published'] = true;
     $result = Jaws_DB::getInstance()->queryAll($sql, $params);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $entries = array();
     foreach ($result as $key => $r) {
         $permission = true;
         foreach (explode(",", $r['categories']) as $cat) {
             if (!$this->gadget->GetPermission('CategoryAccess', $cat)) {
                 $permission = false;
             }
         }
         if (!$permission) {
             continue;
         }
         $entry = array();
         $entry['title'] = $r['title'];
         if (empty($r['fast_url'])) {
             $url = $this->gadget->urlMap('SingleView', array('id' => $r['id']));
         } else {
             $url = $this->gadget->urlMap('SingleView', array('id' => $r['fast_url']));
         }
         $entry['url'] = $url;
         //FIXME: Will be great if we can get the first image in "text"
         $entry['image'] = 'gadgets/Blog/Resources/images/logo.png';
         $entry['snippet'] = empty($r['summary']) ? $r['text'] : $r['summary'];
         $entry['date'] = $date->ToISO($r['createtime']);
         $stamp = str_replace(array('-', ':', ' '), '', $r['createtime']);
         $entries[$stamp] = $entry;
     }
     return $entries;
 }
Ejemplo n.º 27
0
 /**
  * Get the min date from phoo_image
  *
  * @access  public
  * @return  mixed    Date formatted as MM/DD/YYYY or false on error
  */
 function GetMinDate()
 {
     $table = Jaws_ORM::getInstance()->table('phoo_image');
     $min = $table->select('min(createtime)')->fetchOne();
     if (Jaws_Error::IsError($min)) {
         return false;
     }
     $objDate = Jaws_Date::getInstance();
     return $objDate->Format($min, 'm/d/Y');
 }
Ejemplo n.º 28
0
 /**
  * Displays the server time
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Display()
 {
     $tpl = $this->gadget->template->load('ServerTime.html');
     $tpl->SetBlock('servertime');
     $objDate = Jaws_Date::getInstance();
     $strDate = $objDate->Format(time(), $this->gadget->registry->fetch('date_format'));
     $tpl->SetVariable('title', _t('SERVERTIME_ACTION_TITLE'));
     $tpl->SetVariable('ServerDateTime', $this->gadget->ParseText($strDate));
     $tpl->ParseBlock('servertime');
     return $tpl->Get();
 }
Ejemplo n.º 29
0
 /**
  * Displays a form for adding new images.
  *
  * @access  public
  * @return  string   XHTML template content
  */
 function UploadPhotos()
 {
     $this->gadget->CheckPermission('AddPhotos');
     $this->AjaxMe('script.js');
     $album = jaws()->request->fetch('album', 'get');
     $model = $this->gadget->model->load('Albums');
     $tpl = $this->gadget->template->loadAdmin('UploadPhotos.html');
     $tpl->SetBlock('upload');
     $tpl->SetVariable('menubar', $this->MenuBar('UploadPhotos'));
     include_once JAWS_PATH . 'include/Jaws/Widgets/FieldSet.php';
     $phooFieldset = new Jaws_Widgets_FieldSet(_t('PHOO_UPLOAD_PHOTOS'));
     $phooFieldset->SetDirection('vertical');
     $phooFieldset->SetId('phoo_fieldset');
     $phooForm =& Piwi::CreateWidget('Form', BASE_SCRIPT . '?gadget=Phoo', 'post', 'multipart/form-data');
     $phooForm->Add(Piwi::CreateWidget('HiddenEntry', 'MAX_FILE_SIZE', '15000000'));
     $phooForm->Add(Piwi::CreateWidget('HiddenEntry', 'gadget', 'Phoo'));
     $phooForm->Add(Piwi::CreateWidget('HiddenEntry', 'action', 'UploadPhotosStep2'));
     $albumcombo =& Piwi::CreateWidget('Combo', 'album', _t('PHOO_ALBUM'));
     $albums = $model->GetAlbums('name', 'ASC');
     if (!Jaws_Error::IsError($albums) && !empty($albums)) {
         $date = Jaws_Date::getInstance();
         foreach ($albums as $a) {
             // FIXME: Ugly hack to add title to albumcombo
             $o =& Piwi::CreateWidget('ComboOption', $a['id'], $a['name']);
             $o->SetTitle(_t('PHOO_NUM_PHOTOS_ALBUM', $a['howmany']) . ' / ' . _t('PHOO_ALBUM_CREATION_DATE', $date->Format($a['createtime'])));
             $albumcombo->_options[$a['id']] = $o;
         }
     }
     $albumcombo->SetDefault((int) $album);
     $phooFieldset->Add($albumcombo);
     for ($i = 1; $i <= 5; $i++) {
         $imageEntry =& Piwi::CreateWidget('FileEntry', 'photo' . $i);
         $imageEntry->SetTitle(_t('PHOO_PHOTO') . ' ' . $i);
         $phooFieldset->Add($imageEntry);
     }
     $addEntryButton =& Piwi::CreateWidget('Button', 'addEntryButton', _t('PHOO_ADD_ANOTHER_PHOTO'), STOCK_ADD);
     $addEntryButton->AddEvent(ON_CLICK, "addEntry('" . _t('PHOO_PHOTO') . "');");
     $addEntryUrl = '<span id="phoo_addentry6"><div><a href="#" onclick="addEntry(\'' . _t('PHOO_PHOTO') . '\');">' . _t('PHOO_ADD_ANOTHER_PHOTO') . '</a></div></span>';
     $addEntryArea = '<span id="phoo_addentry6"><div>' . $addEntryButton->Get() . '</div></span>';
     $addEntry =& Piwi::CreateWidget('StaticEntry', $addEntryArea);
     $phooFieldset->Add($addEntry);
     $buttonbox =& Piwi::CreateWidget('HBox');
     $buttonbox->SetStyle(_t('GLOBAL_LANG_DIRECTION') == 'rtl' ? 'float: left;' : 'float: right;');
     //hig style
     $submit =& Piwi::CreateWidget('Button', 'uploadphotos', _t('PHOO_UPLOAD_PHOTOS'), STOCK_SAVE);
     $submit->SetSubmit();
     $buttonbox->Add($submit);
     $phooForm->Add($phooFieldset);
     $phooForm->Add($buttonbox);
     $tpl->SetVariable('form', $phooForm->Get());
     $tpl->ParseBlock('upload');
     return $tpl->Get();
 }
Ejemplo n.º 30
0
 /**
  * Displays list of recent updated topics ordered by date
  *
  * @access  public
  * @param   mixed   $gid Group ID
  * @return  string  XHTML content
  */
 function RecentTopics($gid = '', $recent_limit = 5)
 {
     $gModel = $this->gadget->model->load('Groups');
     $group = $gModel->GetGroup($gid);
     if (Jaws_Error::IsError($group) || empty($group)) {
         $group = array();
         $group['id'] = 0;
         $group['title'] = _t('FORUMS_GROUPS_ALL');
     }
     $tpl = $this->gadget->template->load('RecentTopics.html');
     $tModel = $this->gadget->model->load('Topics');
     $topics = $tModel->GetRecentTopics($group['id'], $recent_limit);
     if (!Jaws_Error::IsError($topics)) {
         // date format
         $date_format = $this->gadget->registry->fetch('date_format');
         $date_format = empty($date_format) ? 'DN d MN Y' : $date_format;
         // posts per page
         $posts_limit = $this->gadget->registry->fetch('posts_limit');
         $posts_limit = empty($posts_limit) ? 10 : (int) $posts_limit;
         $max_size = 128;
         $objDate = Jaws_Date::getInstance();
         $tpl->SetBlock('recenttopics');
         // title
         $tpl->SetVariable('action_title', _t('FORUMS_LAYOUT_RECENT_POSTS'));
         $tpl->SetVariable('group_title', $group['title']);
         foreach ($topics as $topic) {
             $tpl->SetBlock('recenttopics/topic');
             // topic subject/link
             $tpl->SetVariable('lbl_topic', $topic['subject']);
             $tpl->SetVariable('url_topic', $this->gadget->urlMap('Posts', array('fid' => $topic['fid'], 'tid' => $topic['id'])));
             // post author
             $tpl->SetVariable('lastpost_date', $objDate->Format($topic['last_post_time'], $date_format));
             $tpl->SetVariable('lastpost_date_iso', $objDate->ToISO((int) $topic['last_post_time']));
             $tpl->SetVariable('message', Jaws_UTF8::substr(strip_tags($this->gadget->ParseText($topic['message'], 'Forums', 'index')), 0, $max_size) . ' ...');
             $tpl->SetVariable('lbl_postedby', _t('FORUMS_POSTEDBY'));
             $tpl->SetVariable('username', $topic['username']);
             $tpl->SetVariable('nickname', $topic['nickname']);
             // user's profile
             $tpl->SetVariable('url_user', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $topic['username'])));
             // post url
             $url_params = array('fid' => $topic['fid'], 'tid' => $topic['id']);
             $last_post_page = floor(($topic['replies'] - 1) / $posts_limit) + 1;
             if ($last_post_page > 1) {
                 $url_params['page'] = $last_post_page;
             }
             $tpl->SetVariable('lastpost_url', $this->gadget->urlMap('Posts', $url_params));
             $tpl->ParseBlock('recenttopics/topic');
         }
         $tpl->ParseBlock('recenttopics');
     }
     return $tpl->Get();
 }