30 $this->_oConfig->init($this->_oDb);
31 $this->_oTemplate->setModule($this);
33 $sClassPrefix = $this->_oConfig->getClassPrefix();
35 $sClassName = $sClassPrefix .
'Privacy';
36 $this->_oPrivacy = class_exists($sClassName) ?
new $sClassName($this) :
null;
38 $sClassName = $sClassPrefix .
'Data';
39 $this->_oTextData = class_exists($sClassName) ?
new $sClassName($this) :
null;
43 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'uri',
'uri' => $sUri));
44 if(
empty($aEntry) || !is_array($aEntry))
45 $this->_oTemplate->displayPageNotFound();
47 $sModuleUri = $this->_oConfig->getUri();
48 $oView =
new ChWsbViews($this->_oConfig->getViewsSystemName(), $aEntry[
'id']);
51 $this->_oTemplate->setPageTitle($aEntry[
'caption']);
52 $GLOBALS[
'oTopMenu']->setCustomSubHeader($aEntry[
'caption']);
53 $GLOBALS[
'oTopMenu']->setCustomSubHeaderUrl(CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aEntry[
'uri']);
54 $GLOBALS[
'oTopMenu']->setCustomBreadcrumbs(array(
55 _t(
'_' . $sModuleUri .
'_top_menu_item') => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'index/',
56 $aEntry[
'caption'] =>
'')
58 return $this->_oTemplate->displayList(array(
59 'sample_type' =>
'view',
60 'viewer_type' => $this->_oTextData->getViewerType(),
61 'uri' => $aEntry[
'uri']
66 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'uri',
'uri' => $sUri));
67 if(!$this->_oConfig->isCommentsEnabled() || !$this->_isCommentsAllowed($aEntry))
70 $sModuleUri = $this->_oConfig->getUri();
72 return MsgBox(
_t(
'_' . $sModuleUri .
'_msg_no_results'));
74 $this->_oTemplate->addCss(array(
'cmts.css'));
75 $oComments = $this->_createObjectCmts($aEntry[
'id']);
76 return $oComments->getCommentsFirst(
'comment');
80 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'uri',
'uri' => $sUri));
81 if(!$this->_oConfig->isVotesEnabled() || !$this->_isVotesAllowed($aEntry))
84 $sModuleUri = $this->_oConfig->getUri();
86 return MsgBox(
_t(
'_' . $sModuleUri .
'_msg_no_results'));
88 $oVotes = $this->_createObjectVoting($aEntry[
'id']);
89 return $oVotes->getBigVoting();
93 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'uri',
'uri' => $sUri));
94 if(
empty($aEntry) || !is_array($aEntry))
97 return array($this->_oTemplate->displayBlockInfo($aEntry));
101 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'uri',
'uri' => $sUri));
103 $sModuleUri = $this->_oConfig->getUri();
104 $sModuleBaseUri = $this->_oConfig->getBaseUri();
106 return MsgBox(
_t(
'_' . $sModuleUri .
'_msg_no_results'));
108 $sModuleUri = $this->_oConfig->getUri();
110 $aButton =
$oSubscription->getButton($this->
getUserId(), $this->_oConfig->getSubscriptionsSystemName(),
'', $aEntry[
'id']);
112 $aReplacement[
'sbs_' . $sModuleUri .
'_title'] = $aButton[
'title'];
113 $aReplacement[
'sbs_' . $sModuleUri .
'_script'] = $aButton[
'script'];
115 $aReplacement[
'del_' . $sModuleUri .
'_title'] =
'';
116 if($this->_isDeleteAllowed()) {
117 $this->_oTemplate->addJsTranslation(array(
'_' . $sModuleUri .
'_msg_success_delete',
'_' . $sModuleUri .
'_msg_failed_delete'));
119 $aReplacement[
'del_' . $sModuleUri .
'_title'] =
_t(
'_' . $sModuleUri .
'_actions_delete');
120 $aReplacement[
'del_' . $sModuleUri .
'_script'] = $this->_oConfig->getJsObject() .
'.deleteEntry(' . $aEntry[
'id'] .
')';
123 $aReplacement[
'share_' . $sModuleUri .
'_title'] =
'';
125 $aReplacement[
'share_' . $sModuleUri .
'_title'] =
_t(
'_Share');
126 $aReplacement[
'share_' . $sModuleUri .
'_script'] =
"showPopupAnyHtml('" . $sModuleBaseUri .
"share_popup/" . $aEntry[
'id'] .
"')";
129 return $oSubscription->getData() .
$GLOBALS[
'oFunctions']->genObjectsActions($aReplacement, $this->_oConfig->getActionsViewSystemName());
133 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'uri',
'uri' => $sUri));
137 $sUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aEntry[
'uri'];
142 return array(
$s, array(), array(),
false);
146 $sClassName = $this->_oConfig->getClassPrefix() .
'Calendar';
147 return new $sClassName($iYear, $iMonth, $this->_oDb, $this->_oConfig);
152 $sClassName = $this->_oConfig->getClassPrefix() .
'SearchResult';
153 return new $sClassName($this);
160 $sClassName = $this->_oConfig->getClassPrefix() .
'SearchResult';
161 $oSearchResult =
new $sClassName($this);
162 foreach($aRestrictions
as $sKey => $mixedValue)
163 if(is_array($mixedValue))
164 $oSearchResult->aCurrent[
'restriction'][$sKey] = $mixedValue;
165 else if(is_string($mixedValue))
166 $oSearchResult->aCurrent[
'restriction'][$sKey][
'value'] = $mixedValue;
167 $oSearchResult->aCurrent[
'paginate'][
'forcePage'] =
$iPage;
168 $oSearchResult->aCurrent[
'paginate'][
'perPage'] =
$iPerPage;
169 $sCode = $oSearchResult->displayResultBlock();
173 'page_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . $sUri .
'{page}/{per_page}',
174 'count' => $oSearchResult->aCurrent[
'paginate'][
'totalNum'],
178 $sCode .= $oPaginate->getPaginate();
189 $sCategoryDisplay =
$GLOBALS[
'MySQL']->unescape($sCategory);
201 $sTagDisplay =
$GLOBALS[
'MySQL']->unescape($sTag);
209 $iYear = (int)$iYear;
210 $iMonth = (int)$iMonth;
217 'calendar-min' => array(
'value' =>
"UNIX_TIMESTAMP('" . $iYear .
"-" . $iMonth .
"-" . $iDay .
" 00:00:00')",
'field' =>
'when',
'operator' =>
'>=',
'no_quote_value' =>
true),
218 'calendar-max' => array(
'value' =>
"UNIX_TIMESTAMP('" . $iYear .
"-" . $iMonth .
"-" . $iDay .
" 23:59:59')",
'field' =>
'when',
'operator' =>
'<=',
'no_quote_value' =>
true),
220 'calendar/' . $iYear .
'/' . $iMonth .
'/' . $iDay .
'/',
231 $sUri = $this->_oConfig->getUri();
233 $iId = (int)$this->_oDb->getOne(
"SELECT `ID` FROM `sys_options_cats` WHERE `name`='" . ucwords(str_replace(
'_',
' ', $sUri)) .
"'");
235 return MsgBox(
'_' . $sUri .
'_msg_no_results');
240 if($mixedResult !==
true && !
empty($mixedResult))
247 $sUri = $this->_oConfig->getUri();
249 $iId = (int)$this->_oDb->getOne(
"SELECT `ID` FROM `sys_options_cats` WHERE `name`='" . ucwords(str_replace(
'_',
' ', $sUri)) .
"'");
251 return MsgBox(
_t(
'_' . $sUri .
'_msg_no_results'));
263 'include_css' => $this->_oTemplate->addCss(array(
'post.css'),
true),
264 'post_form' => $this->_oTextData->getPostForm()
266 return $this->_oTemplate->parseHtmlByName(
'post.html', $aVariables);
270 if(is_string($mixed))
271 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'uri',
'uri' => $mixed));
272 else if(is_int($mixed))
273 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'id',
'id' => $mixed));
276 'include_css' => $this->_oTemplate->addCss(array(
'post.css'),
true),
277 'post_form' => $this->_oTextData->getEditForm($aEntry)
279 return $this->_oTemplate->parseHtmlByName(
'post.html', $aVariables);
284 $iPerPage = $this->_oConfig->getPerPage();
286 return $this->_oTemplate->displayAdminBlock(array(
287 'sample_type' =>
'admin',
288 'viewer_type' => $this->_oTextData->getViewerType(),
291 'admin_panel' =>
true,
292 'filter_value' => $sFilterValue,
293 'search_result_object' => $this->getSearchResult()
299 $iPerPage = $this->_oConfig->getIndexNumber();
306 $iPerPage = $this->_oConfig->getMemberNumber();
313 $iPerPage = $this->_oConfig->getPerPage();
315 return $this->_oTemplate->displayBlock(array(
316 'sample_type' =>
'archive',
317 'viewer_type' => $this->_oTextData->getViewerType(),
320 'show_empty' => $bShowEmpty
326 $iPerPage = $this->_oConfig->getIndexNumber();
333 $iPerPage = $this->_oConfig->getMemberNumber();
340 $iPerPage = $this->_oConfig->getPerPage();
342 return $this->_oTemplate->displayBlock(array(
343 'sample_type' =>
'featured',
344 'viewer_type' => $this->_oTextData->getViewerType(),
347 'show_empty' => $bShowEmpty
353 $iPerPage = $this->_oConfig->getPerPage();
355 return $this->_oTemplate->displayBlock(array(
356 'sample_type' =>
'top_rated',
357 'viewer_type' => $this->_oTextData->getViewerType(),
364 $sUri = $this->_oConfig->getUri();
365 $oCategories =
new ChTemplCategoriesModule(array(
'type' => $this->_oConfig->getCategoriesSystemName()),
_t(
'_categ_users'), CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'category');
367 return $oCategories->getBlockCode_Common($iBlockId,
true);
371 $sUri = $this->_oConfig->getUri();
372 $oTags =
new ChTemplTagsModule(array(
'type' => $this->_oConfig->getTagsSystemName(),
'orderby' =>
'popular'),
_t(
'_' . $sUri .
'_bcaption_all_tags'), CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'tags');
374 $aResult = $oTags->getBlockCode_All($iBlockId);
379 $isMiniMode = isset($aParams[
'mini_mode']) && $aParams[
'mini_mode'] ===
true;
380 $sDynamicUrl = isset($aParams[
'dynamic_url']) ? $aParams[
'dynamic_url'] : CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'index/';
382 $aDateParams = array();
385 $aDateParams = explode(
'/', $sDate);
388 $oCalendar = $this->_createObjectCalendar((
int)$aDateParams[0], (
int)$aDateParams[1]);
389 $oCalendar->setBlockId($iBlockID);
390 $oCalendar->setDynamicUrl($sDynamicUrl);
392 return $oCalendar->display($isMiniMode);
397 $iPerPage = $this->_oConfig->getPerPage();
399 return $this->_oTemplate->displayBlock(array(
400 'sample_type' =>
'popular',
401 'viewer_type' => $this->_oTextData->getViewerType(),
408 $sUnit = str_replace(
'ch_',
'', $sUnit);
412 $aItem = $this->_oDb->getEntries(array(
'sample_type' =>
'id',
'id' => $iObjectId));
416 'Subscription' =>
_t(
'_' . $sUnit .
'_sbs_' .
$sAction, $aItem[
'caption']),
417 'ViewLink' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aItem[
'uri']
427 $iLength = $iLength != 0 ? $iLength : (int)$this->_oConfig->getRssLength();
429 $aEntries = $this->_oDb->getEntries(array(
431 'viewer_type' => $this->_oTextData->getViewerType(),
437 $sRssViewUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/';
438 foreach($aEntries
as $aEntry) {
439 if(
empty($aEntry[
'caption']))
continue;
441 $aRssData[$aEntry[
'id']] = array(
442 'UnitID' => $aEntry[
'id'],
443 'OwnerID' => $aEntry[
'id'],
444 'UnitTitle' => $aEntry[
'caption'],
445 'UnitLink' => $sRssViewUrl . $aEntry[
'uri'],
446 'UnitDesc' => $aEntry[
'content'],
447 'UnitDateTimeUTS' => $aEntry[
'when_uts'],
453 $oRss->SetRssHeader();
455 return $oRss->GenRssByData($aRssData,
_t(
'_news_rss_caption'), $this->_oConfig->getBaseUri() .
'act_rss/');
457 return $oRss->GenRssByData($aRssData,
_t(
'_news_rss_caption'), $this->_oConfig->getBaseUri() .
'act_rss/' . $iLength .
'/' .
$sType .
'/');
465 $iPerPage = $this->_oConfig->getPerPage();
467 return $this->_oTemplate->displayList(array(
468 'sample_type' => $sSampleType,
469 'sample_params' => isset($_POST[
'params']) ? unserialize(urldecode($_POST[
'params'])) :
'',
470 'viewer_type' => $this->_oTextData->getViewerType(),
478 $iId = (int)$_POST[
'id'];
484 $iId = (int)$_POST[
'id'];
490 $iId = (int)$_POST[
'id'];
496 header(
'Content-type:text/html;charset=utf-8');
498 $sUri = $this->_oConfig->getUri();
499 $aEntry = $this->_oDb->getEntries(array(
'sample_type' =>
'id',
'id' => (
int)$iEntry));
501 echo
MsgBox(
_t(
'_' . $sUri .
'_msg_no_results'));
505 $sEntryUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'view/' . $aEntry[
'uri'];
507 require_once (CH_DIRECTORY_PATH_INC .
"shared_sites.inc.php");
513 $sUri = $this->_oConfig->getUri();
517 'page' =>
_t(
'_' . $sUri .
'_pcaption_archive'),
518 'block' =>
_t(
'_' . $sUri .
'_bcaption_archive')
524 $this->_oTemplate->getPageCode($aParams);
528 $sUri = $this->_oConfig->getUri();
532 'page' =>
_t(
'_' . $sUri .
'_pcaption_popular'),
533 'block' =>
_t(
'_' . $sUri .
'_bcaption_popular')
539 $this->_oTemplate->getPageCode($aParams);
543 $sUri = $this->_oConfig->getUri();
547 'page' =>
_t(
'_' . $sUri .
'_pcaption_top_rated'),
548 'block' =>
_t(
'_' . $sUri .
'_bcaption_top_rated')
554 $this->_oTemplate->getPageCode($aParams);
558 $sUri = $this->_oConfig->getUri();
560 $iArgs = func_num_args();
561 if($iArgs == 1 && is_string($iYear))
568 $oCalendar = $this->
getCalendar((
int)$iYear, (
int)$iMonth);
578 $sBlockTitle = !$iDay
579 ?
_t(
'_' . $sUri .
'_bcaption_calendar')
580 :
_t(
'_' . $sUri .
'_bcaption_calendar_browse') .
': ' .
getLocaleDate(
584 ?
_t(
'_' . $sUri .
'_pcaption_calendar')
590 'block' => $sBlockTitle,
596 $this->_oTemplate->getPageCode($aParams);
600 $sUri = $this->_oConfig->getUri();
601 $oCategories =
new ChTemplCategoriesModule(array(
'type' => $this->_oConfig->getCategoriesSystemName()),
_t(
'_categ_users'), CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'categories');
605 'css' => array(
'view.css'),
607 'page' =>
_t(
'_' . $sUri .
'_pcaption_categories')
610 'page_main_code' => $oCategories->getCode()
613 $this->_oTemplate->getPageCode($aParams);
617 $sUri = $this->_oConfig->getUri();
618 $sBaseUri = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri();
621 if(!
empty($sCategory))
625 'css' => array(
'view.css'),
627 'page' =>
_t(
'_' . $sUri .
'_pcaption_category', $sCategoryDisplay),
628 'block' =>
_t(
'_' . $sUri .
'_bcaption_category', $sCategoryDisplay)
630 'breadcrumb' => array(
631 _t(
'_' . $sUri .
'_top_menu_item') => $sBaseUri .
'home/',
632 _t(
'_' . $sUri .
'_categories_top_menu_sitem') => $sBaseUri .
'categories/',
633 $sCategoryDisplay =>
''
639 $this->_oTemplate->getPageCode($aParams);
643 $sUri = $this->_oConfig->getUri();
644 $oTags =
new ChTemplTagsModule(array(
'type' => $this->_oConfig->getTagsSystemName(),
'orderby' =>
'popular'),
_t(
'_' . $sUri .
'_bcaption_all_tags'), CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'tags');
648 'css' => array(
'view.css'),
650 'page' =>
_t(
'_' . $sUri .
'_pcaption_tags')
653 'page_main_code' => $oTags->getCode()
656 $this->_oTemplate->getPageCode($aParams);
660 $sUri = $this->_oConfig->getUri();
661 $sBaseUri = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri();
668 'css' => array(
'view.css'),
670 'page' =>
_t(
'_' . $sUri .
'_pcaption_tag', $sTagDisplay),
671 'block' =>
_t(
'_' . $sUri .
'_bcaption_tag', $sTagDisplay)
673 'breadcrumb' => array(
674 _t(
'_' . $sUri .
'_top_menu_item') => $sBaseUri .
'home/',
675 _t(
'_' . $sUri .
'_tags_top_menu_sitem') => $sBaseUri .
'tags/',
682 $this->_oTemplate->getPageCode($aParams);
686 $sUri = $this->_oConfig->getUri();
690 'page' =>
_t(
'_' . $sUri .
'_pcaption_featured'),
691 'block' =>
_t(
'_' . $sUri .
'_bcaption_featured')
697 $this->_oTemplate->getPageCode($aParams);
705 $sUri = $this->_oConfig->getUri();
706 $oPage =
ch_instance($this->_oConfig->getClassPrefix() .
'PageMain', array($this), $this->_aModule);
710 'css' => array(
'view.css',
'cmts.css'),
712 'page' =>
_t(
'_' . $sUri .
'_pcaption_home')
715 'page_main_code' =>
$oPage->getCode()
718 $this->_oTemplate->getPageCode($aParams);
722 $sUri = $this->_oConfig->getUri();
727 'js' => array(
'main.js'),
728 'css' => array(
'view.css',
'cmts.css'),
730 'page_main_code' => $this->_oTemplate->getViewJs(
true) .
$oPage->getCode()
733 $this->_oTemplate->getPageCode($aParams);
738 require_once(CH_DIRECTORY_PATH_INC .
'admin_design.inc.php');
740 $sUri = $this->_oConfig->getUri();
751 if(isset($_POST[
'save']) && isset($_POST[
'cat'])) {
755 if(isset($_POST[$sUri .
'-publish']))
757 else if(isset($_POST[$sUri .
'-unpublish']))
759 else if(isset($_POST[$sUri .
'-featured']))
761 else if(isset($_POST[$sUri .
'-unfeatured']))
763 else if(isset($_POST[$sUri .
'-delete']))
771 else if(isset($_POST[
'id']))
778 if(isset(
$_GET[$sUri .
'-filter']))
787 'page' =>
_t(
'_' . $sUri .
'_pcaption_admin')
793 $this->_oTemplate->getPageCodeAdmin($aParams);
801 $sUri = $this->_oConfig->getUri();
810 $oMobileTemplate->pageStart();
815 'sample_type' =>
'archive',
816 'sample_params' =>
'',
817 'viewer_type' => $this->_oTextData->getViewerType(),
820 'filter_value' =>
'',
822 $iTotalCount = $this->_oDb->getCount($aParams);
823 $aEntries = $iTotalCount ? $this->_oDb->getEntries($aParams) : array();
825 if (
empty($aEntries)) {
826 $oMobileTemplate->displayNoData(
$sCaption);
830 foreach ($aEntries
as $aEntry) {
833 'url' =>
ch_js_string(CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'mobile_entry/' . $aEntry[
'id']),
835 echo $oMobileTemplate->parseHtmlByName(
'mobile_row.html',
$aVars);
840 'page_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'mobile_latest_entries/{page}',
841 'count' => $iTotalCount,
845 echo $oPaginate->getMobilePaginate();
847 $oMobileTemplate->pageCode(
$sCaption,
false);
857 $oMobileTemplate->pageStart();
860 'sample_type' =>
'id',
863 $aEntry = $this->_oDb->getEntries($aParams);
865 if (
empty($aEntry)) {
866 $oMobileTemplate->displayPageNotFound();
870 echo
'<h1>' . $aEntry[
'caption'] .
'</h1>';
872 echo $aEntry[
'content'];
874 $oMobileTemplate->pageCode($aEntry[
'caption']);
885 if(is_int($aIds) || is_string($aIds))
886 $aIds = array((
int)$aIds);
888 $bResult = $this->_oDb->updateEntry($aIds, array(
'featured' => ($bPositive ? 1 : 0)));
905 if(is_int($aIds) || is_string($aIds))
906 $aIds = array((
int)$aIds);
918 $oTags->reparseObjTags($this->_oConfig->getTagsSystemName(),
$iId);
923 $oCategories->reparseObjTags($this->_oConfig->getCategoriesSystemName(),
$iId);
931 if(!$this->_isDeleteAllowed(
true))
934 if(is_int($aIds) || is_string($aIds))
935 $aIds = array((
int)$aIds);
937 $bResult = $this->_oDb->deleteEntries($aIds);
950 $oTags->reparseObjTags($this->_oConfig->getTagsSystemName(),
$iId);
954 $oCategories->reparseObjTags($this->_oConfig->getCategoriesSystemName(),
$iId);
958 $oSubscription->unsubscribe(array(
'type' =>
'object_id',
'unit' => $this->_oConfig->getSubscriptionsSystemName(),
'object_id' =>
$iId));