Cheetah
ChGroupsTemplate.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbTwigTemplate');
9 
10 /*
11  * Groups module View
12  */
14 {
15  var $_iPageIndex = 500;
16 
20  function __construct(&$oConfig, &$oDb)
21  {
22  parent::__construct($oConfig, $oDb);
23  }
24 
25  function unit ($aData, $sTemplateName, &$oVotingView, $isShort = false)
26  {
27  if (null == $this->_oMain)
28  $this->_oMain = ChWsbModule::getInstance('ChGroupsModule');
29 
30  if (!$this->_oMain->isAllowedView ($aData)) {
31  $aVars = array ('extra_css_class' => 'ch_groups_unit');
32  return $this->parseHtmlByName('twig_unit_private', $aVars);
33  }
34 
35  $sImage = '';
36  if ($aData['thumb']) {
37  $a = array ('ID' => $aData['author_id'], 'Avatar' => $aData['thumb']);
38  $aImage = ChWsbService::call('photos', 'get_image', array($a, 'browse'), 'Search');
39  $sImage = $aImage['no_image'] ? '' : $aImage['file'];
40  }
41 
42  $aVars = array (
43  'id' => $aData['id'],
44  'thumb_url' => $sImage ? $sImage : $this->getImageUrl('no-image-thumb.png'),
45  'group_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aData['uri'],
46  'group_title' => $aData['title'],
47  'created' => defineTimeInterval($aData['created']),
48  'fans_count' => $aData['fans_count'],
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' => getNickName($aData['author_id']),
55  'author_url' => $aData['author_id'] ? getProfileLink($aData['author_id']) : 'javascript:void(0);',
56  'created' => defineTimeInterval($aData['created']),
57  'rate' => $oVotingView ? $oVotingView->getJustVotingElement(0, $aData['id'], $aData['rate']) : '&#160;',
58  ),
59  ),
60  );
61 
62  return $this->parseHtmlByName($sTemplateName, $aVars);
63  }
64 
65  // ======================= ppage compose block functions
66 
67  function blockDesc (&$aDataEntry)
68  {
69  $aVars = array (
70  'description' => $aDataEntry['desc'],
71  );
72  return $this->parseHtmlByName('block_description', $aVars);
73  }
74 
75  function blockFields (&$aDataEntry)
76  {
77  $sRet = '<table class="ch_groups_fields">';
78  ch_groups_import ('FormAdd');
79  $oForm = new ChGroupsFormAdd ($GLOBALS['oChGroupsModule'], getLoggedId());
80  foreach ($oForm->aInputs as $k => $a) {
81  if (!isset($a['display']) || !$aDataEntry[$k]) continue;
82  $sRet .= '<tr><td class="ch_groups_field_name ch-def-font-grayed ch-def-padding-sec-right" valign="top">' . $a['caption'] . '</td><td class="ch_groups_field_value">';
83  if (is_string($a['display']) && is_callable(array($this, $a['display'])))
84  $sRet .= call_user_func_array(array($this, $a['display']), array($aDataEntry[$k]));
85  else if (0 === strcasecmp($k, 'country'))
86  $sRet .= _t($GLOBALS['aPreValues']['Country'][$aDataEntry[$k]]['LKey']);
87  else
88  $sRet .= $aDataEntry[$k];
89  $sRet .= '</td></tr>';
90  }
91  $sRet .= '</table>';
92  return $sRet;
93  }
94 }
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
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChGroupsTemplate
Definition: ChGroupsTemplate.php:14
ChGroupsTemplate\unit
unit($aData, $sTemplateName, &$oVotingView, $isShort=false)
Definition: ChGroupsTemplate.php:25
php
ch_groups_import
ch_groups_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChGroupsModule.php:8
ChGroupsTemplate\__construct
__construct(&$oConfig, &$oDb)
Definition: ChGroupsTemplate.php:20
$oForm
$oForm
Definition: host_tools.php:42
ChWsbTemplate\getImageUrl
getImageUrl($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:595
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
$oDb
global $oDb
Definition: db.inc.php:39
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
ChGroupsTemplate\blockFields
blockFields(&$aDataEntry)
Definition: ChGroupsTemplate.php:75
$aVars
$aVars
Definition: license.php:101
ChGroupsFormAdd
Definition: ChGroupsFormAdd.php:12
ChGroupsTemplate\blockDesc
blockDesc(&$aDataEntry)
Definition: ChGroupsTemplate.php:67
ChWsbTwigTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTwigTemplate.php:42
ChGroupsTemplate\$_iPageIndex
$_iPageIndex
Definition: ChGroupsTemplate.php:15
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10