Cheetah
ChEventsTemplate.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import ('ChWsbTwigTemplate');
9 
10 /*
11  * Events module View
12  */
14 {
18  function __construct(&$oConfig, &$oDb)
19  {
20  parent::__construct($oConfig, $oDb);
21  $this->_iPageIndex = 300;
22  }
23 
24  function unit ($aData, $sTemplateName, &$oVotingView, $isShort = false)
25  {
26  if (null == $this->_oMain)
27  $this->_oMain = ChWsbModule::getInstance('ChEventsModule');
28 
29  if (!$this->_oMain->isAllowedView ($aData)) {
30  $aVars = array ();
31  return $this->parseHtmlByName('twig_unit_private', $aVars);
32  }
33 
34  $sImage = '';
35  if ($aData['PrimPhoto']) {
36  $a = array ('ID' => $aData['ResponsibleID'], 'Avatar' => $aData['PrimPhoto']);
37  $aImage = ChWsbService::call('photos', 'get_image', array($a, 'browse'), 'Search');
38  $sImage = $aImage['no_image'] ? '' : $aImage['file'];
39  }
40 
41  $aVars = array (
42  'id' => $aData['ID'],
43  'thumb_url' => $sImage ? $sImage : $this->getImageUrl('no-image-thumb.png'),
44  'event_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aData['EntryUri'],
45  'event_title' => $aData['Title'],
46  'event_start' => $this->_oMain->_formatDateInBrowse($aData),
47  'spacer' => getTemplateIcon('spacer.gif'),
48  'participants' => $aData['FansCount'],
49  'country_city' => $this->_oMain->_formatLocation($aData),
50  'snippet_text' => $this->_oMain->_formatSnippetText($aData),
51  'ch_if:full' => array (
52  'condition' => !$isShort,
53  'content' => array (
54  'author' => $aData['ResponsibleID'] ? getNickName($aData['ResponsibleID']) : _t('_ch_events_admin'),
55  'author_url' => $aData['ResponsibleID'] ? getProfileLink($aData['ResponsibleID']) : 'javascript:void(0);',
56  'rate' => $oVotingView ? $oVotingView->getJustVotingElement(0, $aData['ID'], $aData['Rate']) : '&#160;',
57  ),
58  ),
59  );
60 
61  $aVars = array_merge ($aVars, $aData);
62  return $this->parseHtmlByName($sTemplateName, $aVars);
63  }
64 
65  // ======================= ppage compose block functions
66 
67  function blockInfo (&$aEvent)
68  {
69  if (null == $this->_oMain)
70  $this->_oMain = ChWsbModule::getInstance('ChEventsModule');
71 
72  $aAuthor = getProfileInfo($aEvent['ResponsibleID']);
73 
74  $aVars = array (
75  'author_unit' => $GLOBALS['oFunctions']->getMemberThumbnail($aAuthor['ID'], 'none', true),
76  'date' => getLocaleDate($aEvent['Date'], CH_WSB_LOCALE_DATE_SHORT),
77  'date_ago' => defineTimeInterval($aEvent['Date'], false),
78  'cats' => $this->parseCategories($aEvent['Categories']),
79  'tags' => $this->parseTags($aEvent['Tags']),
80  'location' => $this->_oMain->_formatLocation($aEvent, true, true),
81  'fields' => $this->blockFields($aEvent),
82  'author_username' => $aAuthor ? $aAuthor['NickName'] : _t('_ch_events_admin'),
83  'author_url' => $aAuthor ? getProfileLink($aAuthor['ID']) : 'javascript:void(0)',
84  );
85  return $this->parseHtmlByName('block_info', $aVars);
86  }
87 
88  function blockDesc (&$aEvent)
89  {
90  $aVars = array (
91  'description' => $aEvent['Description'],
92  );
93  return $this->parseHtmlByName('block_description', $aVars);
94  }
95 
96  function blockFields (&$aEvent)
97  {
98  $sRet = '<table class="ch_events_fields">';
99  ch_events_import ('FormAdd');
100  $oForm = new ChEventsFormAdd ($GLOBALS['oChEventsModule'], $this->_iProfileId);
101  foreach ($oForm->aInputs as $k => $a) {
102  if (!isset($a['display'])) continue;
103  $sRet .= '<tr><td class="ch_events_field_name ch-def-font-grayed ch-def-padding-sec-right" valign="top">' . $a['caption'] . '</td><td class="ch_events_field_value">';
104  if (is_string($a['display']) && is_callable(array($this, $a['display'])))
105  $sRet .= call_user_func_array(array($this, $a['display']), array($aEvent[$k]));
106  else
107  $sRet .= $aEvent[$k];
108  $sRet .= '</td></tr>';
109  }
110  $sRet .= '</table>';
111  return $sRet;
112  }
113 
114  // ======================= output display filters functions
115 
116  function filterDateUTC ($sTimestamp)
117  {
118  return gmdate(getLocaleFormat(CH_WSB_LOCALE_DATE), $sTimestamp);
119  }
120 }
CH_WSB_LOCALE_DATE
const CH_WSB_LOCALE_DATE
Definition: utils.inc.php:16
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ChWsbTwigTemplate
Definition: ChWsbTwigTemplate.php:14
defineTimeInterval
defineTimeInterval($iTime, $bAutoDateConvert=true, $bShort=false)
Definition: utils.inc.php:831
ChEventsTemplate\filterDateUTC
filterDateUTC($sTimestamp)
Definition: ChEventsTemplate.php:116
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChWsbTwigTemplate\parseTags
parseTags($s)
Definition: ChWsbTwigTemplate.php:119
ChEventsTemplate\blockFields
blockFields(&$aEvent)
Definition: ChEventsTemplate.php:96
php
ChEventsTemplate\unit
unit($aData, $sTemplateName, &$oVotingView, $isShort=false)
Definition: ChEventsTemplate.php:24
ChWsbTwigTemplate\parseCategories
parseCategories($s)
Definition: ChWsbTwigTemplate.php:124
$oForm
$oForm
Definition: host_tools.php:42
ChEventsTemplate\blockDesc
blockDesc(&$aEvent)
Definition: ChEventsTemplate.php:88
ChWsbTemplate\getImageUrl
getImageUrl($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:595
getTemplateIcon
getTemplateIcon($sFileName)
Definition: design.inc.php:193
ChEventsTemplate
Definition: ChEventsTemplate.php:14
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
$oDb
global $oDb
Definition: db.inc.php:39
ch_events_import
ch_events_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChEventsModule.php:8
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
ChEventsTemplate\__construct
__construct(&$oConfig, &$oDb)
Definition: ChEventsTemplate.php:18
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
$aVars
$aVars
Definition: license.php:101
ChEventsFormAdd
Definition: ChEventsFormAdd.php:12
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
getLocaleFormat
getLocaleFormat($iCode=CH_WSB_LOCALE_DATE_SHORT, $iType=CH_WSB_LOCALE_PHP)
Definition: utils.inc.php:89
ChWsbTwigTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTwigTemplate.php:42
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChEventsTemplate\blockInfo
blockInfo(&$aEvent)
Definition: ChEventsTemplate.php:67
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10