/***************************************************************************
* Dolphin Smart Community Builder
* -------------------
* begin : Mon Mar 23 2006
* copyright : (C) 2007 BoonEx Group
* website : http://www.boonex.com
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the
* License, or any later version.
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/
bx_import('BxDolModuleTemplate');
bx_import('BxDolCategories');
bx_import('BxTemplVotingView');
class BxDolFilesTemplate extends BxDolModuleTemplate {
/**
* Constructor
*/
function BxDolFilesTemplate (&$oConfig, &$oDb) {
parent::BxDolModuleTemplate($oConfig, $oDb);
}
/**
* @deprecated
*/
function init (&$oDb) {
$this->_oDb = &$oDb;
}
// function of output
function pageCode ($aPage = array(), $aPageCont = array(), $aCss = array(), $aJs = array(), $bAdminMode = false, $isSubActions = true) {
if (!empty($aPage)) {
foreach ($aPage as $sKey => $sValue)
$GLOBALS['_page'][$sKey] = $sValue;
}
if (!empty($aPageCont)) {
foreach ($aPageCont as $sKey => $sValue)
$GLOBALS['_page_cont'][$aPage['name_index']][$sKey] = $sValue;
}
if (!empty($aCss))
$this->addCss($aCss);
if (!empty($aJs))
$this->addJs($aJs);
if ($isSubActions) {
$aVars = array ('BaseUri' => $this->_oConfig->getBaseUri());
$GLOBALS['oTopMenu']->setCustomSubActions($aVars, $this->_oConfig->getMainPrefix() . '_title', false);
}
if (!$bAdminMode)
PageCode($this);
else
PageCodeAdmin();
}
function getFileInfo ($aInfo) {
if (empty($aInfo))
return '';
$aMediaInfo = array();
$aMediaInfo['memberPic'] = get_member_thumbnail($aInfo['medProfId'], 'none', false);
$aMediaInfo['memberUrl'] = getProfileLink($aInfo['medProfId']);
$aMediaInfo['memberNick'] = $aInfo['NickName'];
$aMediaInfo['dateIcon'] = $this->getIconUrl('clock.png');
$aMediaInfo['dateInfo'] = getLocaleDate($aInfo['medDate'], BX_DOL_LOCALE_DATE_SHORT);
$aMediaInfo['dateInfoAgo'] = defineTimeInterval($aInfo['medDate']);
return $this->parseHtmlByName('media_info.html', $aMediaInfo);
}
function getBasicFileInfoForm (&$aInfo, $sUrlPref = '') {
$aForm = array(
'title' => array(
'type' => 'value',
'value' => $aInfo['medTitle'],
'caption' => _t('_Title'),
),
'album' => array(
'type' => 'value',
'value' => '' . $aInfo['albumCaption'] . '',
'caption' => _t('_sys_album'),
),
'desc' => array(
'type' => 'value',
'value' => process_text_withlinks_output($aInfo['medDesc']),
'caption' => _t('_Description'),
),
'category' => array(
'type' => 'value',
'value' => getLinkSet($aInfo['Categories'], $sUrlPref . 'browse/category/', CATEGORIES_DIVIDER),
'caption' => _t('_Category'),
),
'tags' => array(
'type' => 'value',
'value' => getLinkSet($aInfo['medTags'], $sUrlPref . 'browse/tag/'),
'caption' => _t('_Tags'),
),
);
return $aForm;
}
function getCompleteFileInfoForm (&$aInfo, $sUrlPref = '') {
return $this->getBasicFileInfoForm($aInfo, $sUrlPref);
}
function getFileInfoMain (&$aInfo) {
$sUrlPref = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
$aForm = array(
'form_attrs' => array('id' => $this->_oConfig->getMainPrefix() . '_upload_form'),
'params'=> array('remove_form'=>true),
'inputs' => $this->getCompleteFileInfoForm($aInfo, $sUrlPref)
);
$oForm = new BxTemplFormView($aForm);
return $oForm->getCode();
}
function getRate ($iFile) {
$iFile = (int)$iFile;
$sCode = '
' . _t('_rating not enabled') . '
';
$oVotingView = new BxTemplVotingView($this->_oConfig->getMainPrefix(), $iFile);
if ($oVotingView->isEnabled())
$sCode = $oVotingView->getBigVoting ();
return $sCode;
}
function getFilePic ($iFile) {
$aIdent = array('fileId' => (int)$iFile);
return $this->_oDb->getFileInfo($aIdent, true, array('medID', 'Type'));
}
function getFilesBox ($aCode, $sWrapperId = '') {
if (!is_array($aCode))
return '';
else {
ob_start();
?>