remUser = $interface->getUser(); /*********************Configuration*********************/ // Type of module - popular, downloads, newest $this->modtype = $this->remos_get_module_parm($params,'modtype','newest'); // Type of output - list of files or RSS link $this->listtype = $this->remos_get_module_parm($params,'listtype','list'); // Set to 1 to show container, set to 0 to omit $this->showcat = $this->remos_get_module_parm($params,'showcat',0); // Set to 1 to show the file thumbnail (if any), set to 0 to not show thumbnail $this->showthumb = $this->remos_get_module_parm($params,'showthumb',0); // Set to 1 to show the file version (if any), set to 0 to not show version $this->showversion = $this->remos_get_module_parm($params,'showversion',0); // Set to non zero pixel size to show file icon, 0 to not show $this->iconsize = $this->remos_get_module_parm($params,'iconsize',16); // Set to non zero pixel size to show date icon, 0 to not show $this->diconsize = $this->remos_get_module_parm($params,'diconsize',16); // Set to 1 to show the date, set to 0 to not show date $this->showdate = $this->remos_get_module_parm($params,'showdate',0); // Set to 1 to show the number of downloads, set to 0 to not show downloads $this->showdownloads = $this->remos_get_module_parm($params,'showdownloads',0); // Max number of entries to show $this->max = $this->remos_get_module_parm($params,'max',5 ); // Max number of description characters, 0 for no description $this->maxchars = $this->remos_get_module_parm($params,'maxchars',100); // Date format for display, 'none' if no display required $this->date_format = $this->remos_get_module_parm($params,'dateformat','%b.%g'); // Category from which to select files $this->category = $this->remos_get_module_parm($params,'category', 0); // if (!$this->category) $this->showcat = 0; // Maximum number of days to consider where log file is used $this->days = $this->remos_get_module_parm($params, 'days', 30); $this->max = max($this->max,1); /*******************************************************/ if ($this->listtype == 'list') { switch ($this->modtype) { case 'random': $files = remositoryFile::randomFiles ($this->category, $this->max, $this->remUser); break; case 'popular': $files = remositoryFile::popularLoggedFiles ($this->category, $this->max, $this->days, $this->remUser); break; case 'download': $files = remositoryFile::popularDownloadedFiles ($this->category, $this->max, $this->remUser); break; case 'newest': default: $files = remositoryFile::newestFiles ($this->category, $this->max, $this->remUser); } foreach ($files as $file) $this->displayFile($file); } else $this->displayRSS(); $content = $this->html; } private function displayFile ($file) { $repository = remositoryRepository::getInstance(); if ($this->showcat) $caturl = $repository->RemositoryFunctionURL('select', $file->containerid); if ($this->iconsize) { if ($file->icon) $icon = $file->icon; else $icon = 'generic.png'; $iconurl = $repository->RemositoryImageURL('file_icons/'.$icon, $this->iconsize, $this->iconsize); } else $iconurl = ''; if ($this->showthumb) $thumbnails = new remositoryThumbnails($file); if (strtolower($this->date_format) != 'none') { if ($this->diconsize) $dateurl = $repository->RemositoryImageURL('calendar.gif', $this->diconsize, $this->diconsize); else $dateurl = ''; $time = strtotime($file->filedate); if ($repository->Set_date_locale) setlocale(LC_TIME, $repository->Set_date_locale); $datetext = strftime($this->date_format, $time); } if ($this->maxchars) { if (strlen($file->smalldesc) > $this->maxchars-3) $desc = substr($file->smalldesc,0,$this->maxchars-3).'...'; else $desc = $file->smalldesc; } $link = $repository->RemositoryFunctionURL('fileinfo', $file->id); $ampencode = '/(&(?!(#[0-9]{1,5};))(?!([0-9a-zA-Z]{1,10};)))/'; $link = preg_replace($ampencode, '&', $link); $this->html .= "\n
"; if ($this->showversion) $this->html .= "\n
$iconurl$link$file->filetitle $file->fileversion
"; else $this->html .= "\n
$iconurl$link$file->filetitle
"; if ($this->showcat) $this->html .= "\n\t
($caturl$file->name)
"; if ($this->showthumb) $this->html .= "\n\t".$thumbnails->displayOneThumbnail(); if ($this->showdate AND strtolower($this->date_format) != 'none') $this->html .= "\n\t
".$dateurl.$datetext.'
'; if ($this->showdownloads) $this->html .= "\n\t".'Downloads: '.$file->downloads; if ($this->maxchars) $this->html .= "\n\t

$desc

"; $this->html .= "\n
"; } private function displayRSS () { $interface = remositoryInterface::getInstance(); $database = $interface->getDB(); $repository = remositoryRepository::getInstance(); $url = "index.php?option=com_remository&func=rss&no_html=1&rtype=$this->modtype&max=$this->max&days=$this->days&Itemid="; if (isset($GLOBALS['remosef_itemids']['com_remository'])) $Itemid = $GLOBALS['remosef_itemids']['com_remository']; else { $database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_remository'"); $GLOBALS['remosef_itemids']['com_remository'] = $Itemid = $database->loadResult(); } $url .= intval($Itemid); if ($this->category) $url .= "&id=".$this->category; $sefurl = $interface->sefRelToAbs($url); $sefurl = preg_replace('/(&)([^#]|$)/','&$2', $sefurl); if ($this->showcat) { $caturl = $repository->RemositoryFunctionURL('select', $this->category); $database->setQuery("SELECT name FROM #__downloads_containers WHERE id=$this->category"); $catname = $database->loadResult(); } $this->html .= "\n
"; if ($this->showcat) $this->html .= "\n\t

$caturl$catname

"; $this->html .= "\n\t"; $rssimage = $repository->RemositoryImageURL('feed-icon-32x32.gif').' RSS'; $rssimage = str_replace('img', 'img style="border:0"', $rssimage); $this->html .= $rssimage; $this->html .= "\n
"; } }