Cheetah
ChCRSSModule.php
Go to the documentation of this file.
1 <?php
2 
8 require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbModule.php');
9 
54 {
55  // Variables
57 
58  // Constructor
60  {
61  parent::__construct($aModule);
62  }
63 
71  function serviceGenCustomRssBlock($iID)
72  {
73  return $this->GenCustomRssBlock($iID);
74  }
75 
76  function GenCustomRssBlock($iID)
77  {
78  global $site;
79 
80  if (getParam('enable_crss_module') != 'on')
81  return;
82 
83  $this->_iProfileID = $iID;
84  $iVisitorID = getLoggedId();
85 
86  $bAjaxMode = (false !== ch_get('mode') && ch_get('mode') == 'ajax');
87  $bAjaxMode2 = (false !== ch_get('mode') && ch_get('mode') == 'ajax2');
88 
89  $sHomeUrl = $this->_oConfig->getHomeUrl();
90 
91  $sManagingForm = $sRssContent = '';
92 
93  //Generation of managing form
94  if ($iVisitorID>0 && $iVisitorID == $this->_iProfileID) {
95  $sAddC = _t('_Submit');
96  $sEditC = _t('_Edit');
97  $sAddNewURLC = _t('_Enter new URL');
98  $sURLC = _t('_URL');
99  $sDescriptionC = _t('_Description');
100  $sQuantityC = _t('_crss_Quantity');
101 
102  $sAction = ch_get('action');
103 
104  if (0 === strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') && isset($sAction) && $sAction != '') {
105  $sNewUrl = process_db_input(ch_get('rss_url'), CH_TAGS_STRIP);
106  $sNewDesc = process_db_input(ch_get('rss_desc'), CH_TAGS_STRIP);
107  $iOldID = (int)ch_get('rss_id');
108  $iQuantity = (int)ch_get('rss_quantity');
109 
110  switch ($sAction) {
111  case 'add_rss':
112  $this->_oDb->insertProfileRSS($this->_iProfileID, $sNewUrl, $sNewDesc, $iQuantity);
113  break;
114  case 'ren_rss':
115  $this->_oDb->updateProfileRSS($this->_iProfileID, $sNewUrl, $iOldID);
116  break;
117  case 'del_rss':
118  $this->_oDb->deleteProfileRSS($this->_iProfileID, $iOldID);
119  break;
120  }
121  }
122 
123  $sRSSList = '';
124 
125  $aMemberRSS = $this->_oDb->getProfileRSS($this->_iProfileID);
126 
127  if(count($aMemberRSS)==0) {
128  $sRSSList = '<tr><td>' . MsgBox(_t('_Empty')) . '</td></tr>';
129  } else {
130  foreach($aMemberRSS as $sKey => $aRSSInfo) {
131  $iRssID = (int)$aRSSInfo['ID'];
132  $sRssUrl = process_line_output($aRSSInfo['RSSUrl']);
133  $sRssDesc = process_line_output($aRSSInfo['Description']);
134  $sRssStatus = process_line_output($aRSSInfo['Status']);
135  $iRssQuantity = (int)$aRSSInfo['Quantity'];
136 
137  $aFormVariables = array (
138  'rss_url' => $sRssUrl,
139  'rss_description' => $sRssDesc,
140  'rss_status' => $sRssStatus,
141  'enter_new_url' => $sAddNewURLC,
142  'rss_url_js' => $sRssUrl,
143  'php_self' => ch_html_attribute($_SERVER['PHP_SELF']),
144  'rss_id' => $iRssID,
145  'owner_id' => $this->_iProfileID,
146  'rss_quantity' => $iRssQuantity,
147  );
148  $sRSSList .= $this->_oTemplate->parseHtmlByTemplateName('crss_unit', $aFormVariables);
149  }
150  }
151 
152  $sFormOnsubmitCode = <<<EOF
153 sLink1 = '{$sHomeUrl}crss.php?ID={$this->_iProfileID}&action=add_rss&rss_url=' + encodeUriComponent($('form#adding_custom_rss_form input[name=rss_url]').val()) + '&rss_desc=' + encodeUriComponent($('form#adding_custom_rss_form input[name=rss_desc]').val()) + '&rss_quantity=' + encodeUriComponent($('form#adding_custom_rss_form input[name=rss_quantity]').val()) + '&mode=ajax';
154 getHtmlData('custom_rss_lists_div', sLink1, '', 'post');
155 return false;
156 EOF;
157 
158  //adding form
159  $aForm = array(
160  'form_attrs' => array(
161  'name' => 'adding_custom_rss_form',
162  'action' => getProfileLink($iVisitorID),
163  'method' => 'post',
164  'onsubmit' => $sFormOnsubmitCode,
165  ),
166  'inputs' => array(
167  'header1' => array(
168  'type' => 'block_header',
169  'caption' => _t('_crss_add_new'),
170  ),
171  'rss_url' => array(
172  'type' => 'text',
173  'name' => 'rss_url',
174  'maxlength' => 255,
175  'caption' => $sURLC,
176  ),
177  'rss_quantity' => array(
178  'type' => 'text',
179  'name' => 'rss_quantity',
180  'maxlength' => 4,
181  'caption' => $sQuantityC,
182  ),
183  'rss_desc' => array(
184  'type' => 'text',
185  'name' => 'rss_desc',
186  'maxlength' => 255,
187  'caption' => $sDescriptionC,
188  ),
189  'hidden_id' => array(
190  'type' => 'hidden',
191  'name' => 'ID',
192  'value' => $this->_iProfileID,
193  ),
194  'hidden_action' => array(
195  'type' => 'hidden',
196  'name' => 'action',
197  'value' => 'add_rss',
198  ),
199  'add_button' => array(
200  'type' => 'submit',
201  'name' => 'submit',
202  'caption' => '',
203  'value' => $sAddC,
204  ),
205  ),
206  );
207 
209  $sAddingForm = $oForm->getCode();
210  }
211 
212  $sLoadingC = _t('_loading ...');
213 
214  //Generation of Active RSS`s
215  unset($aMemberRSS);
216  $sActiveRSSList = $sRssAggr = '';
217  if ($this->_iProfileID>0) {
218 
219  //view RSS of current member
220  $aMemberRSS = $this->_oDb->getActiveProfileRSS($this->_iProfileID);
221 
222  if(count($aMemberRSS)==0) {
223  $sRssContent = MsgBox(_t('_Empty'));
224  } else {
225  foreach($aMemberRSS as $sKey => $aRSSInfo) {
226  $iRssID = (int)$aRSSInfo['ID'];
227  $iRssQuantity = (int)$aRSSInfo['Quantity'];
228  $sRssUrl = process_line_output($aRSSInfo['RSSUrl']);
229 
230  $sActiveRSSList .= "<div class='RSSAggrCont_" . $iRssID . "' rssnum='" . $iRssQuantity . "'>" . $GLOBALS['oFunctions']->loadingBoxInline() . "</div>";
231  $sRssAggr .= "$('div.RSSAggrCont_" . $iRssID . "').dolRSSFeed('" . $sHomeUrl . "get_rss_feed.php?ID=" . $iRssID . "');";
232  }
233 
234  $sRssContent = $sActiveRSSList;
235  }
236  }
237 
238  $sTableExRssContent = $sRSSList;
239 
240  if ($bAjaxMode) {
241  echo $sTableExRssContent;
242  exit;
243  }
244 
245  $aFormVariables = array (
246  'member_rss_list' => $sRssContent,
247  'member_rss_js_aggr' => $sRssAggr,
248  );
249  $sReadyRssContent = $this->_oTemplate->parseHtmlByTemplateName('member_rss_list_loaded', $aFormVariables);
250 
251  if ($bAjaxMode2) {
252  echo $sReadyRssContent;
253  exit;
254  }
255 
256  $aFormVariables = array (
257  'view_css' => $this->_oTemplate->getCssUrl('view.css'),
258  'main_js_url' => $sHomeUrl . 'js/main.js',
259  'table_existed_rss_list' => $sTableExRssContent,
260  'form_adding' => $sAddingForm,
261  'member_rss_list_loaded' => $sReadyRssContent,
262  );
263  $sBlockContent = $this->_oTemplate->parseHtmlByTemplateName('view', $aFormVariables);
264 
265  //Action to showing managing form
266  $sPreferSpeed = $this->_oConfig->getAnimationSpeed();
267  $sActions = ChWsbPageView::getBlockCaptionMenu(time(), array(
268  'crss_t1' => array('href' => ch_html_attribute($_SERVER['PHP_SELF']), 'title' => $sEditC, 'onclick' => "ShowHideEditCRSSForm('{$sPreferSpeed}'); return false;")
269  ));
270  return DesignBoxContent(_t('_crss_Custom_Feeds'), $sBlockContent, 1, $sActions);
271  }
272 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChCRSSModule\__construct
__construct($aModule)
Definition: ChCRSSModule.php:59
$bAjaxMode
$bAjaxMode
Definition: categories.php:21
ChTemplFormView
Definition: ChTemplFormView.php:11
ChCRSSModule
Definition: ChCRSSModule.php:54
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
$aModule
$aModule
Definition: classifieds.php:21
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
ChWsbPageView\getBlockCaptionMenu
static getBlockCaptionMenu( $iBlockID, $aLinks)
Definition: ChWsbPageView.php:586
$sHomeUrl
$sHomeUrl
Definition: header.inc.php:41
php
ChCRSSModule\$_iProfileID
$_iProfileID
Definition: ChCRSSModule.php:56
ChCRSSModule\GenCustomRssBlock
GenCustomRssBlock($iID)
Definition: ChCRSSModule.php:76
ch_html_attribute
ch_html_attribute($mixedInput)
Definition: utils.inc.php:1324
ChCRSSModule\serviceGenCustomRssBlock
serviceGenCustomRssBlock($iID)
Definition: ChCRSSModule.php:71
$oForm
$oForm
Definition: host_tools.php:42
exit
exit
Definition: cart.php:21
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
$site
$site['ver']
Definition: version.inc.php:8
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChWsbModule
Definition: ChWsbModule.php:41
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
process_line_output
process_line_output($text, $maxwordlen=100)
Definition: utils.inc.php:328
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
$aForm
$aForm
Definition: forgot.php:43
$sAction
$sAction
Definition: categories.php:274
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10