Cheetah
ChShoutBoxTemplate.php
Go to the documentation of this file.
1 <?php
2 
8  ch_import('ChWsbModuleTemplate');
9 
11  {
15  function __construct( &$oConfig, &$oDb )
16  {
17  parent::__construct($oConfig, $oDb);
18  }
19 
25  function pageCodeAdminStart()
26  {
27  ob_start();
28  }
29 
38  function adminBlock ($sContent, $sTitle, $aMenu = array())
39  {
41  }
42 
50  {
51  global $_page;
53 
54  $_page['name_index'] = 9;
55 
56  $_page['header'] = $sTitle ? $sTitle : $GLOBALS['site']['title'];
57  $_page['header_text'] = $sTitle;
58 
59  $_page_cont[$_page['name_index']]['page_main_code'] = ob_get_clean();
60 
61  PageCodeAdmin();
62  }
63 
72  function getProcessedMessages($aMessages = array(), $bDeleteAllowed = false, $bBlockAllowed = false)
73  {
75 
76  if(!$aMessages) {
77  return;
78  }
79 
80  $sOutputCode = '';
81  $aLanguageKeys = array(
82  'by' => _t('_ch_shoutbox_by'),
83  'visitor' => _t('_Visitor'),
84  'delete' => _t('_ch_shoutbox_delete_message'),
85  'sure' => _t('_Are_you_sure'),
86  'block' => _t('_ch_shoutbox_block_ip'),
87  );
88 
89  foreach($aMessages as $iKey => $aItems) {
90  $sMemberIcon = '';
91  $aProfileInfo = $aItems['OwnerID'] > 0
92  ? getProfileInfo($aItems['OwnerID'])
93  : array();
94 
95  // define some profile's data;
96  if($aProfileInfo) {
97  $sNickName = getNickName($aProfileInfo['ID']);
98  $sLink = getProfileLink($aItems['OwnerID']);
99  $sMemberIcon = $oFunctions -> getMemberIcon($aItems['OwnerID']);
100  } else {
101  $sLink = 'javascript:void(0)';
102  $sNickName = $aLanguageKeys['visitor'];
103  }
104 
105  $aKeys = array
106  (
107  'owner_icon' => $sMemberIcon,
108  'message' => htmlentities(WordWrapStr(html_entity_decode($aItems['Message'], ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8', false),
109  'by' => $aLanguageKeys['by'],
110  'owner_nick' => $sNickName,
111  'date' => defineTimeInterval($aItems['DateTS'], true, true),
112  'owner_link' => $sLink,
113 
114  'ch_if:delete_allowed' => array (
115  'condition' => $bDeleteAllowed,
116  'content' => array (
117  'delete_cpt' => ch_html_attribute($aLanguageKeys['delete']),
118  'sure_cpt' => ch_js_string($aLanguageKeys['sure']),
119  'message_id' => $aItems['ID'],
120  ),
121  ),
122  'ch_if:block_allowed' => array (
123  'condition' => $bBlockAllowed,
124  'content' => array (
125  'block_cpt' => ch_html_attribute($aLanguageKeys['block']),
126  'sure_cpt' => ch_js_string($aLanguageKeys['sure']),
127  'message_id' => $aItems['ID'],
128  ),
129  ),
130  );
131 
132  $sTemplateName = $aProfileInfo
133  ? 'message.html'
134  : 'visitor_message.html';
135 
136  $sOutputCode .= $this -> parseHtmlByName($sTemplateName, $aKeys);
137  }
138 
139  return $sOutputCode;
140  }
141 
150  function getShoutboxWindow($sObject, $iHandler, $sModulePath, $iLastMessageId = 0, $sMessagesList = '')
151  {
152  $this -> addJS(array(
153  'emoji-picker/js/jquery.emojipicker.js',
154  'emoji-picker/js/jquery.emojipicker.tw.js',
155  'shoutbox.js',
156  ));
157  $this -> addCss(array(
158  'plugins/emoji-picker/css/|jquery.emojipicker.css',
159  'shoutbox.css',
160  ));
161 
162  $this -> addCssAsync('plugins/emoji-picker/css|jquery.emojipicker.tw.css'); // it's toooooooo big, so include it separately
163 
164  $sShoutboxWrapperClass = "ch_shoutbox_{$sObject}_{$iHandler}";
165  $aForm = array (
166  'params'=> array('remove_form' => true),
167 
168  'inputs' => array (
169  'messages' => array(
170  'type' => 'custom',
171  'content' => '<div class="shoutbox_wrapper ' . $sShoutboxWrapperClass . '">' . $sMessagesList . '</div>',
172  'colspan' => true,
173  ),
174 
175  'message' => array(
176  'type' => 'text',
177  'name' => 'message',
178  'colspan' => true,
179  'attrs' => array(
180  'onkeypress' => "if(typeof oShoutBox != 'undefined') return oShoutBox.sendMessage(event, this);",
181  'id' => 'shoutbox_msg_field',
182  ),
183  ),
184  ),
185  );
186 
187  $aKeys = array('options' => json_encode(array(
188  'object' => $sObject,
189  'handler' => (int)$iHandler,
190  'message_empty_message' => _t('_ch_shoutbox_enter_message'),
191  'module_path' => $sModulePath,
192  'update_time' => $this -> _oConfig -> iUpdateTime,
193  'last_message_id' => $iLastMessageId,
194  'wait_cpt' => _t('_ch_shoutbox_wait'),
195  )));
196 
197  $sOutputCode = $this -> parseHtmlByName('shoutbox_init.html', $aKeys);
198 
200  return $oForm -> getCode() . $sOutputCode;
201  }
202  }
ChShoutBoxTemplate\__construct
__construct(&$oConfig, &$oDb)
Definition: ChShoutBoxTemplate.php:15
WordWrapStr
WordWrapStr($sString, $iWidth=25, $sWrapCharacter='&shy;')
Definition: utils.inc.php:155
ChShoutBoxTemplate
Definition: ChShoutBoxTemplate.php:11
ChShoutBoxTemplate\adminBlock
adminBlock($sContent, $sTitle, $aMenu=array())
Definition: ChShoutBoxTemplate.php:38
ChTemplFormView
Definition: ChTemplFormView.php:11
$sModulePath
$sModulePath
Definition: ChSoundsUploader.php:21
ch_js_string
ch_js_string($mixedInput, $iQuoteType=CH_ESCAPE_STR_AUTO)
Definition: utils.inc.php:1294
defineTimeInterval
defineTimeInterval($iTime, $bAutoDateConvert=true, $bShort=false)
Definition: utils.inc.php:831
$_page
$_page['name_index']
Definition: about_us.php:13
ChShoutBoxTemplate\getProcessedMessages
getProcessedMessages($aMessages=array(), $bDeleteAllowed=false, $bBlockAllowed=false)
Definition: ChShoutBoxTemplate.php:72
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$_page_cont
$_page_cont[$_ni]['page_main_code']
Definition: about_us.php:24
ChWsbTemplate\addCss
addCss($mixedFiles, $bDynamic=false)
Definition: ChWsbTemplate.php:1114
php
ChWsbTemplate\addCssAsync
addCssAsync($mixedFiles)
Definition: ChWsbTemplate.php:1123
ChShoutBoxTemplate\pageCodeAdminStart
pageCodeAdminStart()
Definition: ChShoutBoxTemplate.php:25
ChShoutBoxTemplate\pageCodeAdmin
pageCodeAdmin($sTitle)
Definition: ChShoutBoxTemplate.php:49
ch_html_attribute
ch_html_attribute($mixedInput)
Definition: utils.inc.php:1324
$oFunctions
$oFunctions
Definition: ChTemplFunctions.php:20
$oForm
$oForm
Definition: host_tools.php:42
ChShoutBoxTemplate\getShoutboxWindow
getShoutboxWindow($sObject, $iHandler, $sModulePath, $iLastMessageId=0, $sMessagesList='')
Definition: ChShoutBoxTemplate.php:150
DesignBoxAdmin
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
Definition: admin_design.inc.php:50
ChWsbTemplate\getCode
getCode()
Definition: ChWsbTemplate.php:376
$sTitle
$sTitle
Definition: actions.inc.php:13
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
$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
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
$aMenu
$aMenu
Definition: categories.php:257
$aProfileInfo
$aProfileInfo
Definition: short_profile_info.php:23
ChWsbModuleTemplate
Definition: ChWsbModuleTemplate.php:11
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
$aForm
$aForm
Definition: forgot.php:43
$sMessagesList
$sMessagesList
Definition: mail.php:49
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChWsbTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:660
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10