/** * * @param SJB_PageConfig $page_config */ public static function getPage($page_config) { SJB_System::setPageTitle($page_config->getPageTitle()); SJB_System::setGlobalTemplateVariable('user_page_uri', $page_config->getPageUri()); SJB_System::setPageKeywords($page_config->getPageKeywords()); SJB_System::setPageDescription($page_config->getPageDescription()); if ($page_config->getMainContentFunction() == 'add_listing') { $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false); if ($passed_parameters_via_uri) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); if (isset($passed_parameters_via_uri[2])) { $page_config->setMainContentFunction('add_listing_step'); } } } $maincontent = SJB_System::executeFunction($page_config->getMainContentModule(), $page_config->getMainContentFunction(), $page_config->getParameters(), $page_config->getPageUri()); if ($page_config->hasRawOutput()) { return $maincontent; } $page_templates_set_name = SJB_System::getSystemSettings('PAGE_TEMPLATES_MODULE_NAME'); $template_supplier = new SJB_TemplateSupplier($page_templates_set_name); $tp = new SJB_TemplateProcessor($template_supplier); // assign 'highlight_templates' variable to main or index template if (SJB_Settings::getSettingByName('highlight_templates') == 1 && SJB_Request::getVar('admin_mode', false, 'COOKIE')) { $tp->assign('highlight_templates', true); } if ($errors = SJB_Error::getErrorContent()) { SJB_FlashMessages::getInstance()->addWarning($errors); } $tp->assign('MAIN_CONTENT', $maincontent); $tp->registerGlobalVariables(); $tp->assign('sjb_version', SJB_System::getSystemSettings('SJB_VERSION')); $template = $page_config->getPageTemplate(); $template_supplier->addContainerTemplate($template); if (SJB_Request::isAjax()) { $template = SJB_System::getSettingByName('default_page_template_by_http'); } elseif (SJB_FormBuilderManager::getIfBuilderModeIsSet()) { $template = 'index_b.tpl'; } else { if (empty($template)) { $template = SJB_Settings::getSettingByName('DEFAULT_PAGE_TEMPLATE'); } } return $tp->fetch($template); }
public function execute() { $template_processor = SJB_System::getTemplateProcessor(); $template_editor = new SJB_TemplateEditor(); $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : ""; if (!$template_editor->doesModuleTemplateExists(SJB_System::getSystemSettings('STARTUP_MODULE'), $template_name)) { $template_name = ''; } if (!empty($template_name)) { $menu_path = array(array('reference' => "?", 'name' => 'Page Templates'), array('name' => $template_name, 'reference' => "")); $template_processor->assign("navigation", $menu_path); $template_processor->assign("title", "Page Template: {$template_name}"); $template_processor->display('navigation_menu.tpl'); echo SJB_System::executeFunction("template_manager", "edit_template", array('module_name' => System::getSystemSettings('STARTUP_MODULE'))); } else { $menu_path = array(array('reference' => "", 'name' => 'Page Templates')); $template_processor->assign("navigation", $menu_path); $template_processor->assign("title", 'Page Templates'); $template_processor->display('navigation_menu.tpl'); echo SJB_System::executeFunction("template_manager", "page_template_list"); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $module_name = SJB_Request::getVar('module_name', "", 'GET'); $template_name = SJB_Request::getVar('template_name', "", 'GET'); // не работало с юзерской if (empty($template_name)) { $template_name = SJB_Request::getVar('template_name', ''); } if (empty($module_name)) { $module_name = SJB_Request::getVar('module_name', ''); } $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default'); $template_editor = new SJB_TemplateEditor(); $simple_view = SJB_Request::getVar('simple_view'); if (!$template_editor->doesModuleExists($module_name)) { $tp->assign('ERROR', "MODULE_DOES_NOT_EXIST"); } else { if (!$template_editor->doesModuleTemplateExists($module_name, $template_name)) { $tp->assign('ERROR', "TEMPLATE_DOES_NOT_EXIST"); } else { if (isset($_REQUEST['action'])) { $content = SJB_Request::getVar('template_content'); if ($content) { if (SJB_System::getSystemSettings("isDemo")) { $tp->assign('ERROR', 'NOT_ALLOWED_IN_DEMO'); } elseif (SJB_System::getIfTrialModeIsOn() && SJB_HelperFunctions::findSmartyRestrictedTagsInContent($tp, $content)) { $tp->assign('ERROR', 'Php tags are not allowed'); } else { $result = $template_editor->saveTemplate($template_name, $module_name, $theme, $content); // if ajax request to save if ($simple_view) { if ($result) { echo '<p class="message">Template saved successfully. </p>'; } else { echo "ERROR WHILE SAVE TEMPLATE"; } exit; } if ($_REQUEST['action'] == "save_template") { SJB_HelperFunctions::redirect("?module_name=" . $module_name); } } } } echo SJB_System::executeFunction('template_manager', 'add_template'); $modules = $template_editor->getModuleWithTemplatesList(); $tp->assign('module_name', $module_name); $tp->assign('template_name', $template_name); $tp->assign('theme', $theme); $tp->assign('display_name', $modules[$module_name]['display_name']); $tp->assign('template_display_name', $template_name); $path_to_template = SJB_TemplatePathManager::getAbsoluteTemplatePath($theme, $module_name, $template_name); if (!file_exists($path_to_template)) { $theme = SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR'); } if (false === ($template_content = $template_editor->loadTemplate($template_name, $module_name, $theme))) { $tp->assign('ERROR', "CANNOT_FETCH_TEMPLATE"); } else { if (!$template_editor->isTemplateWriteable($module_name, $theme, $template_name) && !SJB_System::getSystemSettings("isDemo")) { $tp->assign('ERROR', "TEMPLATE_IS_NOT_WRITEABLE"); } else { $tp->assign('template_content', $template_content); } } $list_modules = SJB_System::getModulesUserList(); $list_functions = array(); $list_params = array(); foreach ($list_modules as $module) { $functions = SJB_System::getFunctionsUserList($module); foreach ($functions as $keyF => $func) { $list_functions[$module][$keyF] = $func; $params = SJB_System::getParamsList($module, $func); if (isset($params[0])) { foreach ($params as $keyP => $param) { $list_params[$module][$func][$keyP] = $param; } } } } $tp->assign('LIST_MODULES', $list_modules); $tp->assign('LIST_FUNCTIONS', $list_functions); $tp->assign('LIST_PARAMS', $list_params); } } if ($simple_view) { $tp->display('edit_template_simple.tpl'); } else { header('X-XSS-Protection: 0'); $tp->display('edit_template.tpl'); } }
public function execute() { $errors = array(); $tp = SJB_System::getTemplateProcessor(); $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; // Category SID incoming as part of URL. $categoryId = SJB_Request::getVar("category_sid"); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $categoryId = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } if ($categoryId && $categoryId != 'category') { $article = false; if (is_null($categoryId)) { $errors['ITEM_SID_IS_EMPTY'] = 1; } else { $article = SJB_NewsManager::getActiveItemBySID($categoryId); } if (!$article) { $errors['ARTICLE_NOT_EXISTS'] = 1; echo SJB_System::executeFunction('static_content', 'show_static_content', array('pageid' => '404')); return; } $tp->assign('article', $article); $template = 'article_details.tpl'; } else { $categoryId = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : null; // other params in query string $searchText = SJB_Request::getVar('search_text', false); $current_page = SJB_Request::getVar('page', 1); $itemsPerPage = 10; $action = SJB_Request::getVar('action'); if ($action == 'search') { // COUNT FOR SEARCH ACTION $totalNews = SJB_NewsManager::getAllNewsCountBySearchText($searchText, $langId, true); } else { $totalNews = SJB_NewsManager::getAllNewsCount($categoryId, $langId, true); } $pages = ceil($totalNews / $itemsPerPage); if ($pages == 0) { $pages = 1; } if ($current_page > $pages) { $current_page = $pages; } if ($action == 'search') { // GET ARTICLES FOR SEARCH ACTION if ($totalNews == 0) { $articles = array(); } else { $articles = SJB_NewsManager::searchArticles($searchText, $langId, true); } } else { $articles = SJB_NewsManager::getNewsByPage($current_page, $itemsPerPage, $categoryId, $langId, true); } $tp->assign('searchText', $searchText); $tp->assign('current_page', $current_page); $tp->assign('pages', $pages); $tp->assign('articles', $articles); $categories = SJB_NewsManager::getCategories($langId); $countOfNotEmptyCategories = 0; foreach ($categories as $category) { if ($category['count'] > 0) { $countOfNotEmptyCategories++; } } $showCategoriesBlock = false; if ($countOfNotEmptyCategories > 1) { $showCategoriesBlock = true; } $tp->assign('show_categories_block', $showCategoriesBlock); $tp->assign('categories', $categories); $tp->assign('current_category_sid', $categoryId); $template = 'articles_list.tpl'; } $tp->display($template); }
function module($params) { $name = isset($params['name']) ? $params['name'] : ''; $function = isset($params['function']) ? $params['function'] : ''; unset($params['name']); unset($params['function']); if (empty($name) || empty($function)) { return '<!-- Either module or function is not specified in call to {module ..} -->'; } return SJB_System::executeFunction($name, $function, $params); }
private function runTaskScheduler() { // Deactivate Expired Listings & Send Notifications $listingsExpiredID = SJB_ListingManager::getExpiredListingsSID(); foreach ($listingsExpiredID as $listingExpiredID) { SJB_ListingManager::deactivateListingBySID($listingExpiredID, true); $listing = SJB_ListingManager::getObjectBySID($listingExpiredID); $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing); if (SJB_UserNotificationsManager::isUserNotifiedOnListingExpiration($listing->getUserSID())) { SJB_Notifications::sendUserListingExpiredLetter($listingInfo); } // notify admin SJB_AdminNotifications::sendAdminListingExpiredLetter($listingInfo); } $listingsDeactivatedID = array(); if (SJB_Settings::getSettingByName('automatically_delete_expired_listings')) { $listingsDeactivatedID = SJB_ListingManager::getDeactivatedListingsSID(); foreach ($listingsDeactivatedID as $listingID) { SJB_ListingManager::deleteListingBySID($listingID); } } SJB_ListingManager::unFeaturedListings(); SJB_ListingManager::unPriorityListings(); SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS)); /////////////////////////// Send remind notifications about expiration of LISTINGS // 1. get user sids and days count of 'remind listing notification' setting = 1 from user_notifications table // 2. foreach user: // - get listings with that expiration remind date // - check every listing sid in DB table of sended. If sended - remove from send list // - send notification with listings to user // - write listings sid in DB table of sended notifications $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnListingExpirationRemind(); foreach ($notificationData as $elem) { $userSID = $elem['user_sid']; $days = $elem['days']; $listingSIDs = SJB_ListingManager::getListingsIDByDaysLeftToExpired($userSID, $days); if (empty($listingSIDs)) { continue; } $listingsInfo = array(); // check listings remind sended foreach ($listingSIDs as $key => $sid) { if (SJB_ListingManager::isListingNotificationSended($sid)) { unset($listingSIDs[$key]); continue; } $info = SJB_ListingManager::getListingInfoBySID($sid); $listingsInfo[$sid] = $info; } if (!empty($listingsInfo)) { // now only unsended listings we have in array // send listing notification foreach ($listingSIDs as $sid) { SJB_Notifications::sendRemindListingExpirationLetter($userSID, $sid, $days); } // write listing id in DB table of sended notifications SJB_ListingManager::saveListingIDAsSendedNotificationsTable($listingSIDs); } } // Send Notifications for Expired Contracts $contractsExpiredID = SJB_ContractManager::getExpiredContractsID(); foreach ($contractsExpiredID as $contractExpiredID) { $contractInfo = SJB_ContractManager::getInfo($contractExpiredID); $productInfo = SJB_ProductsManager::getProductInfoBySID($contractInfo['product_sid']); $userInfo = SJB_UserManager::getUserInfoBySID($contractInfo['user_sid']); $serializedExtraInfo = unserialize($contractInfo['serialized_extra_info']); if (!empty($serializedExtraInfo['featured_profile']) && !empty($userInfo['featured'])) { $contracts = SJB_ContractManager::getAllContractsInfoByUserSID($userInfo['sid']); $isFeatured = 0; foreach ($contracts as $contract) { if ($contract['id'] != $contractExpiredID) { $serializedExtraInfo = unserialize($contract['serialized_extra_info']); if (!empty($serializedExtraInfo['featured'])) { $isFeatured = 1; } } } if (!$isFeatured) { SJB_UserManager::removeFromFeaturedBySID($userInfo['sid']); } } if (SJB_UserNotificationsManager::isUserNotifiedOnContractExpiration($contractInfo['user_sid'])) { SJB_Notifications::sendUserContractExpiredLetter($userInfo, $contractInfo, $productInfo); } // notify admin SJB_AdminNotifications::sendAdminUserContractExpiredLetter($userInfo['sid'], $contractInfo, $productInfo); SJB_ContractManager::deleteContract($contractExpiredID, $contractInfo['user_sid']); } //////////////////////// Send remind notifications about expiration of contracts // 1. get user sids and days count of 'remind subscription notification' setting = 1 from user_notifications table // 2. foreach user: // - get contracts with that expiration remind date // - check every contract sid in DB table of sended. If sended - remove from send list // - send notification with contracts to user // - write contract sid in DB table of sended contract notifications $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnSubscriptionExpirationRemind(); foreach ($notificationData as $elem) { $userSID = $elem['user_sid']; $days = $elem['days']; $contractSIDs = SJB_ContractManager::getContractsIDByDaysLeftToExpired($userSID, $days); if (empty($contractSIDs)) { continue; } $contractsInfo = array(); // check contracts sended foreach ($contractSIDs as $key => $sid) { if (SJB_ContractManager::isContractNotificationSended($sid)) { unset($contractSIDs[$key]); continue; } $info = SJB_ContractManager::getInfo($sid); $info['extra_info'] = !empty($info['serialized_extra_info']) ? unserialize($info['serialized_extra_info']) : ''; $contractsInfo[$sid] = $info; } if (!empty($contractsInfo)) { // now only unsended contracts we have in array // send contract notification foreach ($contractSIDs as $sid) { SJB_Notifications::sendRemindSubscriptionExpirationLetter($userSID, $contractsInfo[$sid], $days); } // write contract id in DB table of sended contract notifications SJB_ContractManager::saveContractIDAsSendedNotificationsTable($contractSIDs); } } // delete applications with no employer and job seeker $emptyApplications = SJB_DB::query('SELECT `id` FROM `applications` WHERE `show_js` = 0 AND `show_emp` = 0'); foreach ($emptyApplications as $application) { SJB_Applications::remove($application['id']); } // NEWS $expiredNews = SJB_NewsManager::getExpiredNews(); foreach ($expiredNews as $article) { SJB_NewsManager::deactivateItemBySID($article['sid']); } // LISTING XML IMPORT SJB_XmlImport::runImport(); // UPDATE PAGES WITH FUNCTION EQUAL BROWSE(e.g. /browse-by-city/) SJB_BrowseDBManager::rebuildBrowses(); //-------------------sitemap generator--------------------// SJB_System::executeFunction('miscellaneous', 'sitemap_generator'); // CLEAR `error_log` TABLE $errorLogLifetime = SJB_System::getSettingByName('error_log_lifetime'); $lifeTime = strtotime("-{$errorLogLifetime} days"); if ($lifeTime > 0) { SJB_DB::query('DELETE FROM `error_log` WHERE `date` < ?t', $lifeTime); } SJB_Settings::updateSetting('task_scheduler_last_executed_date', $this->currentDate); $this->tp->assign('expired_listings_id', $listingsExpiredID); $this->tp->assign('deactivated_listings_id', $listingsDeactivatedID); $this->tp->assign('expired_contracts_id', $contractsExpiredID); $this->tp->assign('notified_saved_searches_id', $this->notifiedSavedSearchesSID); $schedulerLog = $this->tp->fetch('task_scheduler_log.tpl'); SJB_HelperFunctions::writeCronLogFile('task_scheduler.log', $schedulerLog); SJB_DB::query('INSERT INTO `task_scheduler_log` (`last_executed_date`, `notifieds_sent`, `expired_listings`, `expired_contracts`, `log_text`) VALUES ( NOW(), ?n, ?n, ?n, ?s)', count($this->notifiedSavedSearchesSID), count($listingsExpiredID), count($contractsExpiredID), $schedulerLog); SJB_System::getModuleManager()->executeFunction('social', 'linkedin'); SJB_System::getModuleManager()->executeFunction('social', 'facebook'); SJB_System::getModuleManager()->executeFunction('classifieds', 'linkedin'); SJB_System::getModuleManager()->executeFunction('classifieds', 'facebook'); SJB_System::getModuleManager()->executeFunction('classifieds', 'twitter'); SJB_Event::dispatch('task_scheduler_run'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $template_editor = new SJB_TemplateEditor(); $module_name = SJB_Request::getVar('module_name', '', 'GET'); // if set simple_view - not shown navigation to user $simple_view = SJB_Request::getVar('simple_view', false); if (!$template_editor->doesModuleExists($module_name)) { $module_name = ''; } $template_name = SJB_Request::getVar('template_name', '', 'GET'); if (!$template_editor->doesModuleTemplateExists($module_name, $template_name)) { $template_name = ''; } $modules = $template_editor->getModuleWithTemplatesList(); global $error; $error = array(); $result = ''; $highlight_setting = SJB_Request::getVar('highlight_templates'); if (!is_null($highlight_setting)) { if (SJB_System::getSystemSettings("isDemo")) { $error[] = 'NOT_ALLOWED_IN_DEMO'; } else { SJB_Settings::updateSetting('highlight_templates', $highlight_setting); } } $tp->assign('highlight_templates', SJB_Settings::getSettingByName('highlight_templates')); $action = SJB_Request::getVar('action', ''); $form_submitted = SJB_Request::getVar('submit'); //Clear Smarty Cache $clear_smarty_cache = SJB_Request::getVar('clear_cache_submit'); if ($clear_smarty_cache) { $compiled_templates_dir = SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR'); $admin_theme = ThemeManager::getCurrentTheme(); $themes_list['user'] = $template_editor->getThemeList(); $themes_list['admin'][] = $admin_theme; foreach ($themes_list as $access_type => $themes) { foreach ($themes as $theme) { $destination = $compiled_templates_dir . $access_type . "/" . $theme; $result = $tp->deleteCacheBySpecifiedPath($destination); if (is_array($result)) { $error = $result; } } } } // actions if (!empty($action)) { $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default'); // TODO: !!!!если редактируется с юзерской части , то проверить есть ли тэмплэйт в теме , если нет , брать с _system switch ($action) { case 'delete': $template_editor->deleteTemplate($template_name, $module_name, $theme); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $module_name); break; case 'edit': case 'add': if (SJB_Request::getVar('templ_module') && SJB_Request::getVar('templ_name')) { $newTemplName = trim(SJB_Request::getVar('templ_name')); $newModuleName = SJB_Request::getVar('templ_module'); if (!$template_editor->isTemplateNameValid($newTemplName)) { $error[] = 'NOT_VALID_FILENAME_FORMAT'; } if (!$template_editor->doesModuleExists($newModuleName)) { $error[] = 'MODULE_ERROR'; } if (empty($error)) { if ('edit' == $action) { if ($template_editor->moveTemplate(SJB_Request::getVar('templ_name_or'), SJB_Request::getVar('templ_module_or'), $theme, $newModuleName, $newTemplName)) { if ($form_submitted == 'save_template') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $newModuleName); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $newModuleName . '&template_name=' . $newTemplName); exit; } else { $error[] = 'CANT_MOVE_FILE'; } } else { if ($template_editor->createTemplate($theme, $newModuleName, $newTemplName, $error)) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $newModuleName . '&template_name=' . $newTemplName); } $error[] = 'CANT_CREATE_FILE'; } } } break; default: break; } } // не работало в юзерской if (empty($template_name)) { $template_name = SJB_Request::getVar('template_name', ''); } if (empty($module_name)) { $module_name = SJB_Request::getVar('module_name', ''); } // edittemplate if (!empty($template_name) && !empty($module_name)) { $menu_path = array(array('reference' => '?', 'name' => 'Edit Templates'), array('reference' => "?module_name={$module_name}", 'name' => $modules[$module_name]['display_name']), array('name' => $template_name, 'reference' => '')); $tp->assign('navigation', $menu_path); $tp->assign('errors', $error); $tp->assign('title', 'Edit Templates: ' . $modules[$module_name]['display_name'] . ' / Template: ' . $template_name); $tp->assign('show_clear_cache_setting', false); $tp->assign('show_highlight_setting', false); if (!$simple_view) { $tp->display('navigation_menu.tpl'); } echo SJB_System::executeFunction('template_manager', 'edit_template'); } else { if (!empty($module_name)) { $menu_path = array(array('reference' => '?', 'name' => 'Edit Templates'), array('reference' => '', 'name' => $modules[$module_name]['display_name'])); $tp->assign('navigation', $menu_path); $tp->assign('title', 'Edit Templates'); $tp->assign('errors', $error); $tp->assign('show_clear_cache_setting', false); $tp->assign('show_highlight_setting', false); if (!$simple_view) { $tp->display('navigation_menu.tpl'); } echo SJB_System::executeFunction('template_manager', 'template_list'); } else { $menu_path = array(array('reference' => '', 'name' => 'Edit Templates')); $tp->assign('navigation', $menu_path); $tp->assign('title', 'Edit Templates'); $tp->assign('show_clear_cache_setting', true); $tp->assign('show_highlight_setting', true); $tp->assign('result', $result); $tp->assign('errors', $error); if (!$simple_view) { $tp->display('navigation_menu.tpl'); } echo SJB_System::executeFunction('template_manager', 'add_template'); echo SJB_System::executeFunction('template_manager', 'module_list'); } } }