Cheetah
ChSitesTemplate.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbModuleTemplate');
9 ch_import('ChWsbCategories');
10 
12 {
13  var $_iPageIndex = 600;
14  var $_aCss = array ();
15  var $_aJs = array ();
16  var $_bObStarted = 0;
17 
21  function __construct(&$oConfig, &$oDb)
22  {
23  parent::__construct($oConfig, $oDb);
24  }
25 
26  function unit($aData, $sTemplateName, &$oVotingView, $sThumbSize = 'browse')
27  {
28  if (null == $this->_oMain)
29  $this->_oMain = ChWsbModule::getInstance('ChSitesModule');
30 
31  if (!$this->_oMain->isAllowedView($aData))
32  return $this->parseHtmlByName('browse_unit_private.html', array());
33 
34  $aResult = $this->_getUnit($aData, $sThumbSize);
35  $aResult['rate'] = $oVotingView->getJustVotingElement(0, $aData['id'], $aData['rate']);
36 
37  return $this->parseHtmlByName($sTemplateName . '.html', $aResult);
38  }
39 
40  function blockHon($aData)
41  {
42  $oVoting = new ChTemplVotingView('ch_sites', $aData['id']);
43  $aResult = $this->_getUnit($aData, 'file');
44  $aResult['rate'] = $oVoting->getBigVoting();
45  $aResult['next_url'] = $_SERVER['REQUEST_URI'];
46 
47  return $this->parseHtmlByName('block_hon.html', $aResult);
48  }
49 
50  function blockInformation($aSite)
51  {
52  $this->addCss(array('block_info.css'));
53  $aResult = array(
54  'author_unit' => get_member_thumbnail($aSite['ownerid'], 'none', true),
55  'date' => getLocaleDate($aSite['date'], CH_WSB_LOCALE_DATE_SHORT),
56  'date_ago' => defineTimeInterval($aSite['date'], false),
57  'cats' => $this->parseCategories($aSite['categories']),
58  'tags' => $this->parseTags($aSite['tags']),
59  'fields' => '',
60  );
61 
62  $this->_checkOwner($aSite, $aResult);
63 
64  return $this->parseHtmlByName('entry_view_block_info.html', $aResult);
65  }
66 
67  function addCssAdmin ($sName)
68  {
69  $sClassPrefix = 'ch_sites_css';
70  $GLOBALS['oAdmTemplate']->addLocation($sClassPrefix, $this->_oConfig->getHomePath(), $this->_oConfig->getHomeUrl());
71  $GLOBALS['oAdmTemplate']->addCss($sName);
72  $GLOBALS['oAdmTemplate']->removeLocation($sClassPrefix);
73  }
74 
75  function addJsAdmin ($sName)
76  {
77  $GLOBALS['oAdmTemplate']->addJs($sName);
78  }
79 
80  function pageCode($sTitle, $isDesignBox = true, $isWrap = true, $isSubActions = true)
81  {
82 
83  global $_page;
85 
86  if (null == $this->_oMain)
87  $this->_oMain = ChWsbModule::getInstance('ChSitesModule');
88 
89  $_page['name_index'] = $isDesignBox ? 0 : $this->_iPageIndex;
90 
91  $_page['header'] = $sTitle ? $sTitle : $GLOBALS['site']['title'];
92  $_page['header_text'] = $sTitle;
93 
94  if ($isWrap) {
95  $aVars = array (
96  'content' => $this->pageEnd(),
97  );
98  $_page_cont[$_page['name_index']]['page_main_code'] = $this->parseHtmlByName('default_padding.html', $aVars);
99  } else
100  $_page_cont[$_page['name_index']]['page_main_code'] = $this->pageEnd();
101 
102  if ($isSubActions) {
103  $aVars = array ('BaseUri' => $this->_oConfig->getBaseUri(), 'isAllowedAdd' => ($this->_oMain->isAllowedAdd() ? 1 : 0));
104  $GLOBALS['oTopMenu']->setCustomSubActions($aVars, 'ch_sites_title', false);
105  }
106 
107  PageCode($this);
108  }
109 
110  function adminBlock($sContent, $sTitle, $aMenu = array())
111  {
113  }
114 
116  {
117  global $_page;
119 
120  $_page['name_index'] = 9;
121 
122  $_page['header'] = $sTitle ? $sTitle : $GLOBALS['site']['title'];
123  $_page['header_text'] = $sTitle;
124 
125  $_page_cont[$_page['name_index']]['page_main_code'] = $this->pageEnd();
126 
127  PageCodeAdmin();
128  }
129 
130  function pageStart()
131  {
132  if (0 == $this->_bObStarted) {
133  ob_start();
134  $this->_bObStarted = 1;
135  }
136  }
137 
138  function pageEnd($isGetContent = true)
139  {
140  if (1 == $this->_bObStarted) {
141  $sRet = '';
142  if ($isGetContent)
143  $sRet = ob_get_clean();
144  else
145  ob_end_clean();
146  $this->_bObStarted = 0;
147  return $sRet;
148  }
149  }
150 
151  function parseTags($s)
152  {
153  return $this->_parseAnything($s, ',', CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'browse/tag/');
154  }
155 
156  function parseCategories($s)
157  {
158  return $this->_parseAnything($s, CATEGORIES_DIVIDER, CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'browse/category/');
159  }
160 
161  function _parseAnything($s, $sDiv, $sLinkStart, $sClassName = '')
162  {
163  $sRet = '';
164  $a = explode ($sDiv, $s);
165  $sClass = $sClassName ? 'class="'.$sClassName.'"' : '';
166 
167  foreach ($a as $sName)
168  $sRet .= '<a '.$sClass.' href="' . $sLinkStart . urlencode(title2uri($sName)) . '">'.$sName.'</a>&#160';
169 
170  return $sRet;
171  }
172 
173  function _getDomain($sUrl)
174  {
175  $aParts = parse_url($sUrl);
176  $sHost = $aParts['host'];
177  if (in_array("www", explode(".", $sHost))) {
178  $aJustDomain = explode("www.", $sHost);
179  return $aJustDomain[1];
180  } else
181  return $sHost;
182  }
183 
184  function _checkOwner($aData, &$aResult)
185  {
186  if ($aData['ownerid']) {
187  $aOwner = getProfileInfo($aData['ownerid']);
188  $aResult['owner_url'] = getProfileLink($aOwner['ID']);
189  $aResult['owner'] = getNickName($aOwner['ID']);
190  } else {
191  $aResult['owner_url'] = 'javascript: void(0)';
192  $aResult['owner'] = _t('_ch_sites_admin');
193  }
194  }
195 
196  function _getUnit($aData, $sThumbSize = 'browse')
197  {
198  if (null == $this->_oMain)
199  $this->_oMain = ChWsbModule::getInstance('ChSitesModule');
200 
201  $sUrl = strncasecmp($aData['url'], 'http://', 7) !== 0 && strncasecmp($aData['url'], 'https://', 8) !== 0 ? 'http://' . $aData['url'] : $aData['url'];
202 
203  $aFile = ChWsbService::call('photos', 'get_photo_array', array($aData['photo'], $sThumbSize), 'Search');
204  $sImage = $aFile['no_image'] ? '' : $aFile['file'];
205 
206  // BEGIN STW INTEGRATION
207  if (getParam('ch_sites_account_type') != 'No Automated Screenshots') {
208  if ($sImage == '') {
209  $aSTWOptions = array(
210  );
211 
212  ch_sites_import('STW');
213  $sThumbHTML = getThumbnailHTML($sUrl, $aSTWOptions, false, 'ch-def-shadow ch-def-round-corners');
214  }
215  }
216  // END STW INTEGRATION
217 
218  $sSiteLink = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aData['entryUri'];
219 
220  $aResult = array(
221  'id' => $aData['id'],
222  'url' => $sUrl,
223  'url_title' => $this->_getDomain($sUrl),
224  'title' => $aData['title'],
225  'site_url' => $sSiteLink,
226  'description' => $this->_oMain->_formatSnippetText($aData),
227  // BEGIN STW INTEGRATION
228  'ch_if:is_image' => array(
229  'condition' => $sThumbHTML == false,
230  'content' => array('site_link' => $sSiteLink, 'image' => $sImage ? $sImage : $this->getImageUrl('no-image-thumb.png'))
231  ),
232  'ch_if:is_thumbhtml' => array(
233  'condition' => $sThumbHTML != '',
234  'content' => array('site_link' => $sSiteLink, 'thumbhtml' => $sThumbHTML)
235  ),
236  // END STW INTEGRATION
237  'comments' => $aData['commentsCount'] . ' ' . _t('_ch_sites_unit_comments'),
238  'date' => defineTimeInterval($aData['date']),
239  'owner_str' => _t('_ch_sites_unit_from') . ' ',
240  'cats_str' => _t('_Categories') . ':',
241  'cats' => $this->parseCategories($aData['categories']),
242  'tags_str' => _t('_Tags') . ':',
243  'tags' => $this->parseTags($aData['tags'])
244  );
245 
246  $this->_checkOwner($aData, $aResult);
247 
248  return $aResult;
249  }
250 
251  function displayAccessDeniedExt($sTitle, $isAjaxMode = false)
252  {
253  $this->_showDisplay($sTitle, _t('_ch_sites_msg_access_denied'), $isAjaxMode);
254  }
255 
256  function displayNoDataExt($sTitle, $isAjaxMode = false)
257  {
258  $this->_showDisplay($sTitle, _t('_Empty'), $isAjaxMode);
259  }
260 
261  function displayPendingApproval($sTitle, $isAjaxMode = false)
262  {
263  $this->_showDisplay($sTitle, _t('_ch_sites_msg_pending_approval'), $isAjaxMode);
264  }
265 
266  function displayPageNotFoundExt($sTitle, $isAjaxMode = false)
267  {
268  header("HTTP/1.0 404 Not Found");
269  $this->_showDisplay($sTitle, _t('_ch_sites_msg_page_not_found'), $isAjaxMode);
270  }
271 
272  function _showDisplay($sTitle, $sText, $isAjaxMode = false)
273  {
274  if (!$isAjaxMode) {
275  $this->pageStart();
276  echo MsgBox($sText);
277  $this->pageCode ($sTitle, true, false);
278  } else
279  echo MsgBox($sText);
280  }
281 }
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
ChSitesTemplate\$_bObStarted
$_bObStarted
Definition: ChSitesTemplate.php:16
ChSitesTemplate\displayNoDataExt
displayNoDataExt($sTitle, $isAjaxMode=false)
Definition: ChSitesTemplate.php:256
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChSitesTemplate\_parseAnything
_parseAnything($s, $sDiv, $sLinkStart, $sClassName='')
Definition: ChSitesTemplate.php:161
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
defineTimeInterval
defineTimeInterval($iTime, $bAutoDateConvert=true, $bShort=false)
Definition: utils.inc.php:831
ChSitesTemplate\displayAccessDeniedExt
displayAccessDeniedExt($sTitle, $isAjaxMode=false)
Definition: ChSitesTemplate.php:251
ChSitesTemplate\$_iPageIndex
$_iPageIndex
Definition: ChSitesTemplate.php:13
$_page
$_page['name_index']
Definition: about_us.php:13
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
$_page_cont
$_page_cont[$_ni]['page_main_code']
Definition: about_us.php:24
ChWsbTemplate\addCss
addCss($mixedFiles, $bDynamic=false)
Definition: ChWsbTemplate.php:1114
ChSitesTemplate\parseCategories
parseCategories($s)
Definition: ChSitesTemplate.php:156
ChSitesTemplate\_getDomain
_getDomain($sUrl)
Definition: ChSitesTemplate.php:173
ChSitesTemplate\displayPendingApproval
displayPendingApproval($sTitle, $isAjaxMode=false)
Definition: ChSitesTemplate.php:261
$sUrl
$sUrl
Definition: cart.php:15
php
ChSitesTemplate\blockHon
blockHon($aData)
Definition: ChSitesTemplate.php:40
ChSitesTemplate\displayPageNotFoundExt
displayPageNotFoundExt($sTitle, $isAjaxMode=false)
Definition: ChSitesTemplate.php:266
ChSitesTemplate\parseTags
parseTags($s)
Definition: ChSitesTemplate.php:151
ChSitesTemplate\pageCode
pageCode($sTitle, $isDesignBox=true, $isWrap=true, $isSubActions=true)
Definition: ChSitesTemplate.php:80
ChSitesTemplate\adminBlock
adminBlock($sContent, $sTitle, $aMenu=array())
Definition: ChSitesTemplate.php:110
ChSitesTemplate\unit
unit($aData, $sTemplateName, &$oVotingView, $sThumbSize='browse')
Definition: ChSitesTemplate.php:26
CATEGORIES_DIVIDER
const CATEGORIES_DIVIDER
Definition: ChWsbCategories.php:10
ChSitesTemplate\_showDisplay
_showDisplay($sTitle, $sText, $isAjaxMode=false)
Definition: ChSitesTemplate.php:272
ChSitesTemplate\blockInformation
blockInformation($aSite)
Definition: ChSitesTemplate.php:50
DesignBoxAdmin
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
Definition: admin_design.inc.php:50
ChSitesTemplate\_getUnit
_getUnit($aData, $sThumbSize='browse')
Definition: ChSitesTemplate.php:196
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChWsbTemplate\getImageUrl
getImageUrl($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:595
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
$sTitle
$sTitle
Definition: actions.inc.php:13
ChSitesTemplate\$_aCss
$_aCss
Definition: ChSitesTemplate.php:14
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
title2uri
title2uri($sValue)
Definition: utils.inc.php:42
ChSitesTemplate\pageCodeAdmin
pageCodeAdmin($sTitle)
Definition: ChSitesTemplate.php:115
$oDb
global $oDb
Definition: db.inc.php:39
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
PageCodeAdmin
PageCodeAdmin($oTemplate=null)
Definition: admin_design.inc.php:45
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
PageCode
PageCode($oTemplate=null)
Definition: design.inc.php:91
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
ChSitesTemplate\addCssAdmin
addCssAdmin($sName)
Definition: ChSitesTemplate.php:67
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
$aMenu
$aMenu
Definition: categories.php:257
$aVars
$aVars
Definition: license.php:101
ch_sites_import
ch_sites_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChSitesModule.php:8
$s
$s
Definition: embed.php:13
ChSitesTemplate
Definition: ChSitesTemplate.php:12
getThumbnailHTML
getThumbnailHTML($sUrl, $aOptions, $sAttribAlt=false, $sAttribClass=false, $sAttribStyle=false)
Definition: ChSitesSTW.php:34
ChSitesTemplate\$_aJs
$_aJs
Definition: ChSitesTemplate.php:15
ChWsbModuleTemplate
Definition: ChWsbModuleTemplate.php:11
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
ChSitesTemplate\addJsAdmin
addJsAdmin($sName)
Definition: ChSitesTemplate.php:75
ChSitesTemplate\pageEnd
pageEnd($isGetContent=true)
Definition: ChSitesTemplate.php:138
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
ChSitesTemplate\__construct
__construct(&$oConfig, &$oDb)
Definition: ChSitesTemplate.php:21
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChWsbTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:660
ChSitesTemplate\pageStart
pageStart()
Definition: ChSitesTemplate.php:130
ChTemplVotingView
Definition: ChTemplVotingView.php:14
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChSitesTemplate\_checkOwner
_checkOwner($aData, &$aResult)
Definition: ChSitesTemplate.php:184