Пример #1
0
 public function execute()
 {
     $errors = array();
     $template_processor = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $action = SJB_PhraseActionFactory::get($action_name, $_REQUEST, $template_processor);
         if ($action->canPerform()) {
             $action->perform();
             $template_processor->display('refresh_opener_and_close_popup.tpl');
             return;
         } else {
             $errors = $action->getErrors();
         }
     }
     $phrase_id = SJB_Request::getVar('phrase', null);
     $domain_id = SJB_Request::getVar('domain', null);
     $i18n = SJB_ObjectMother::createI18N();
     $langs = $i18n->getLanguagesData();
     $template_processor->assign('langs', $langs);
     $template_processor->assign('errors', $errors);
     if (!$i18n->phraseExists($phrase_id, $domain_id)) {
         $domains = $i18n->getDomainsData();
         $template_processor->assign('domains', $domains);
         $template_processor->assign('request_data', $_REQUEST);
         $template_processor->display('add_phrase.tpl');
     } else {
         $phrase_data = $i18n->getPhraseData($phrase_id, $domain_id);
         $template_processor->assign('phrase', $phrase_data);
         $template_processor->display('update_phrase.tpl');
     }
 }
Пример #2
0
 public function execute()
 {
     $errors = array();
     $params = array();
     $template_processor = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $params = $_REQUEST;
         $action = SJB_PhraseActionFactory::get($action_name, $params, $template_processor);
         if ($action->canPerform()) {
             $action->perform();
             SJB_WrappedFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-phrases/?action=remember_previous_state&result=' . $action->result);
         } else {
             $errors = $action->getErrors();
         }
     }
     $i18n = SJB_ObjectMother::createI18N();
     $domains = $i18n->getDomainsData();
     $langs = $i18n->getLanguagesData();
     $template_processor->assign('domains', $domains);
     $template_processor->assign('langs', $langs);
     $template_processor->assign('request_data', $_REQUEST);
     $template_processor->assign('errors', $errors);
     $template_processor->display('add_phrase.tpl');
 }
Пример #3
0
 public function execute()
 {
     $errors = array();
     $params = array();
     $lang_id = SJB_Request::getVar('languageId', null);
     $i18n = SJB_ObjectMother::createI18N();
     if ($i18n->languageExists($lang_id)) {
         $params = $i18n->getLanguageData($lang_id);
         $params['languageId'] = $lang_id;
         if (isset($_REQUEST['action'])) {
             $action_name = $_REQUEST['action'];
             $form_submitted = SJB_Request::getVar('submit');
             $params = array_merge($params, $_REQUEST);
             $action = SJB_LanguageActionFactory::get($action_name, $params);
             if ($action->canPerform()) {
                 $action->perform();
                 if ($form_submitted == 'save') {
                     SJB_WrappedFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-languages/');
                 }
             } else {
                 $errors = $action->getErrors();
             }
         }
     } else {
         $errors[] = 'LANGUAGE_DOES_NOT_EXIST';
     }
     $template_editor = SJB_ObjectMother::createTemplateEditor();
     $themes = $template_editor->getThemeList();
     $template_processor = SJB_System::getTemplateProcessor();
     $template_processor->assign('themes', $themes);
     $template_processor->assign('lang', $params);
     $template_processor->assign('errors', $errors);
     $template_processor->display('update_language.tpl');
 }
Пример #4
0
 function _format_value_with_signs_num()
 {
     $i18n = SJB_ObjectMother::createI18N();
     $value = $i18n->getInput('float', $this->property_info['value']);
     if (isset($this->property_info['signs_num']) && is_numeric($this->property_info['signs_num'])) {
         return sprintf("%0." . $this->property_info['signs_num'] . "f", $value);
     }
     return $value;
 }
Пример #5
0
 function getSQLValue()
 {
     $i18n = SJB_ObjectMother::createI18N();
     $value = $this->property_info['value']['value'];
     if ($i18n->isValidFloat($value)) {
         return $i18n->getInput('float', $this->property_info['value']['value']);
     }
     return $this->property_info['value']['value'];
 }
Пример #6
0
 public static function getDetails()
 {
     // GET LANGUAGES LIST
     $i18N = SJB_ObjectMother::createI18N();
     $frontEndLanguages = $i18N->getActiveFrontendLanguagesData();
     $languages = array();
     foreach ($frontEndLanguages as $lang) {
         $languages[] = array('id' => $lang['id'], 'caption' => $lang['caption']);
     }
     $details = array(array('id' => 'title', 'caption' => 'Title', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => 0), array('id' => 'language', 'caption' => 'Language', 'type' => 'list', 'length' => '30', 'is_required' => false, 'is_system' => true, 'order' => 1, 'list_values' => $languages), array('id' => 'brief', 'caption' => 'Brief Text', 'type' => 'text', 'length' => '1000', 'is_required' => true, 'is_system' => true, 'order' => 2), array('id' => 'text', 'caption' => 'Full Text', 'type' => 'text', 'length' => '64535', 'is_required' => false, 'is_system' => true, 'order' => 3), array('id' => 'keywords', 'caption' => 'Keywords', 'type' => 'string', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 4), array('id' => 'description', 'caption' => 'Description', 'type' => 'string', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 5), array('id' => 'link', 'caption' => 'Redirect To URL:', 'type' => 'string', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 6), array('id' => 'date', 'caption' => 'Publication Date', 'type' => 'date', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => 7), array('id' => 'expiration_date', 'caption' => 'Expiration Date', 'type' => 'date', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => 8), array('id' => 'image', 'caption' => 'Image', 'type' => 'picture', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 9, 'width' => 100, 'height' => 100), array('id' => 'category_id', 'caption' => 'Category', 'type' => 'id', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => 10), array('id' => 'active', 'caption' => 'Active', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 11));
     return $details;
 }
Пример #7
0
 public function execute()
 {
     $errors = array();
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $action = SJB_LanguageActionFactory::get($action_name, $_REQUEST);
         if ($action->canPerform()) {
             $action->perform();
         } else {
             $errors = $action->getErrors();
         }
     }
     $i18n = SJB_ObjectMother::createI18N();
     $langs_data = $i18n->getLanguagesData();
     $template_processor = SJB_System::getTemplateProcessor();
     $template_processor->assign('langs', $langs_data);
     $template_processor->assign('errors', $errors);
     $template_processor->display('languages.tpl');
 }
Пример #8
0
 public function execute()
 {
     $errors = array();
     $result = '';
     $paginator = new SJB_ManagePhrasesPagination();
     $template_processor = SJB_System::getTemplateProcessor();
     $foundPhrases = '';
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $paginator->setUniqueUrlParams($_REQUEST);
         $params = $_REQUEST;
         $action = SJB_PhraseActionFactory::get($action_name, $params, $template_processor);
         if ($action->canPerform()) {
             $action->perform();
             $result = isset($_REQUEST['result']) ? $_REQUEST['result'] : $action->result;
             $total = $this->getPhrasesCount();
             $paginator->setItemsCount($total);
             if ($paginator->itemsPerPage == 'all') {
                 $foundPhrases = self::$phrases;
             } else {
                 $foundPhrases = $this->getPhrasesByPage($paginator->currentPage, $paginator->itemsPerPage);
             }
         } else {
             $errors = $action->getErrors();
         }
     } else {
         $template_processor->assign('criteria', $_REQUEST);
     }
     $i18n = SJB_ObjectMother::createI18N();
     $domains = $i18n->getDomainsData();
     $languages = $i18n->getLanguagesData();
     $template_processor->assign('paginationInfo', $paginator->getPaginationInfo());
     $template_processor->assign('result', $result);
     $template_processor->assign('domains', $domains);
     $template_processor->assign('languages', $languages);
     $template_processor->assign('errors', $errors);
     $template_processor->assign('found_phrases', $foundPhrases);
     $template_processor->display('manage_phrases.tpl');
 }
Пример #9
0
 public function execute()
 {
     $errors = array();
     $phrase_data = array();
     $result = '';
     $phrase_id = isset($_REQUEST['phrase']) ? $_REQUEST['phrase'] : null;
     $domain_id = isset($_REQUEST['domain']) ? $_REQUEST['domain'] : null;
     $lang_id = isset($_REQUEST['current_lang']) ? $_REQUEST['current_lang'] : null;
     $i18n = SJB_ObjectMother::createI18N();
     $template_processor = SJB_System::getTemplateProcessor();
     if ($i18n->phraseExists($phrase_id, $domain_id)) {
         $phrase_data = $i18n->getPhraseData($phrase_id, $domain_id);
         if (isset($_REQUEST['action'])) {
             $action_name = $_REQUEST['action'];
             $params = $_REQUEST;
             $action = SJB_PhraseActionFactory::get($action_name, $params, $template_processor);
             if ($action->canPerform()) {
                 $action->perform();
                 $result = $action->result;
             } else {
                 $errors = $action->getErrors();
                 $phrase_data = array_merge($phrase_data, $_REQUEST);
             }
         }
     } else {
         $errors[] = 'PHRASE_NOT_EXISTS';
     }
     $domains = $i18n->getDomainsData();
     $langs = $i18n->getLanguagesData();
     $template_processor->assign('result', $result);
     $template_processor->assign('phrase', $phrase_data);
     $template_processor->assign('domains', $domains);
     $template_processor->assign('langs', $langs);
     $template_processor->assign('chosen_lang', $lang_id);
     $template_processor->assign('errors', $errors);
     $template_processor->display('update_phrase.tpl');
 }
Пример #10
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action_name', false);
     $action = $action ? $action : 'list';
     $template = 'manage_polls.tpl';
     $errors = array();
     switch ($action) {
         case 'new':
             $template = 'input_form_poll.tpl';
             $_REQUEST['start_date'] = date('Y-m-d');
             $field = new SJB_PollsManager($_REQUEST);
             $form = new SJB_Form($field);
             $form->registerTags($tp);
             $tp->assign('form_fields', $form->getFormFieldsInfo());
             break;
         case 'save':
             $sid = SJB_Request::getVar('sid');
             $_REQUEST['value'] = strip_tags(SJB_Request::getVar('value'));
             $_REQUEST['user_group_sid'] = SJB_Request::getInt('user_group_sid', 0);
             $field = new SJB_PollsManager($_REQUEST);
             if ($sid) {
                 $field->setSID($sid);
             }
             $form = new SJB_Form($field);
             if ($form->isDataValid($errors)) {
                 SJB_PollsManager::savePoll($field);
                 $_REQUEST['sid'] = $field->sid;
                 $save = SJB_Request::getVar('save', false);
                 $action = 'edit';
                 if ($save) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-polls/');
                     break;
                 }
             } else {
                 $action = 'new';
                 if ($sid) {
                     $action = 'edit';
                 }
                 $template = 'input_form_poll.tpl';
                 $field->setSID($sid);
                 $form->registerTags($tp);
                 $tp->assign('form_fields', $form->getFormFieldsInfo());
                 $tp->assign('errors', $errors);
                 $tp->assign('sid', $sid);
                 break;
             }
         case 'edit':
             $sid = SJB_Request::getVar('sid');
             $info = SJB_PollsManager::getPollInfoBySID($sid);
             $field = new SJB_PollsManager($info);
             $edit_form = new SJB_Form($field);
             $edit_form->registerTags($tp);
             $field->setSID($sid);
             $tp->assign('form_fields', $edit_form->getFormFieldsInfo());
             $tp->assign('sid', $sid);
             $tp->assign('action', 'edit');
             $template = 'input_form_poll.tpl';
             break;
         case 'edit_answer':
             $sid = SJB_Request::getVar('sid');
             $_REQUEST['field_sid'] = $sid;
             $event = SJB_Request::getVar('event');
             $pollInfo = SJB_PollsManager::getPollInfoBySID($sid);
             $edit_list_controller = new SJB_PollsEditListController($_REQUEST, $pollInfo);
             switch ($event) {
                 case 'add':
                     $item_sid = SJB_Request::getVar('item_sid');
                     if ($edit_list_controller->isValidValueSubmitted()) {
                         if ($item_sid) {
                             $pollItemManager = new SJB_PollsListItemManager();
                             $list_item = $pollItemManager->getListItemBySID($item_sid);
                             $list_item->setValue(trim($_REQUEST['list_item_value']));
                             $pollItemManager->saveListItem($list_item);
                         } else {
                             if (!$edit_list_controller->saveItem()) {
                                 $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS');
                             }
                         }
                     } else {
                         $tp->assign('error', 'LIST_VALUE_IS_EMPTY');
                     }
                     break;
                 case 'edit':
                     $item_sid = SJB_Request::getVar('item_sid');
                     $pollItemManager = new SJB_PollsListItemManager();
                     $list_item = $pollItemManager->getListItemBySID($item_sid);
                     $tp->assign('item_sid', $list_item->sid);
                     $tp->assign('item_value', $list_item->value);
                     $tp->assign('item_action', 'edit');
                     break;
                 case 'add_multiple':
                     if ($edit_list_controller->isValidMultiValueSubmitted()) {
                         if (!$edit_list_controller->saveItem(true)) {
                             $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS');
                         }
                     } else {
                         $tp->assign('error', 'LIST_VALUE_IS_EMPTY');
                     }
                     break;
                 case 'delete':
                     $item_sid = SJB_Request::getVar('item_sid');
                     if (is_array($item_sid)) {
                         foreach ($item_sid as $sid => $val) {
                             $edit_list_controller->deleteItem($sid);
                         }
                     } else {
                         $edit_list_controller->deleteItem();
                     }
                     break;
                 case 'move_up':
                     $edit_list_controller->moveUpItem();
                     break;
                 case 'move_down':
                     $edit_list_controller->moveDownItem();
                     break;
                 case 'save_order':
                     if ($item_order = SJB_Request::getVar('item_order', false)) {
                         $edit_list_controller->saveNewItemsOrder($item_order);
                     }
                     break;
                 case 'sort':
                     $edit_list_controller->sortItems(SJB_Request::getVar('field_sid'), SJB_Request::getVar('sorting_order'));
                     $tp->assign('sorting_order', SJB_Request::getVar('sorting_order'));
                     break;
             }
             $display_list_controller = new SJB_PollsDisplayListController($_REQUEST, $pollInfo);
             $display_list_controller->setTemplateProcessor($tp);
             $display_list_controller->display('edit_answer.tpl');
             break;
         case 'delete':
             $sid = SJB_Request::getVar('sid', false);
             $sids = SJB_Request::getVar('polls', false);
             if ($sid) {
                 SJB_PollsManager::deletePollBySID($sid);
             } else {
                 if ($sids) {
                     foreach ($sids as $sid => $val) {
                         SJB_PollsManager::deletePollBySID($sid);
                     }
                 } else {
                     $errors[] = 'NO_POLLS_SELECTED';
                 }
             }
             $action = 'list';
             break;
         case 'activate':
             $sids = SJB_Request::getVar('polls');
             if (is_array($sids)) {
                 foreach ($sids as $sid => $val) {
                     SJB_PollsManager::activatePollBySID($sid);
                 }
             } else {
                 $errors[] = 'NO_POLLS_SELECTED';
             }
             $action = 'list';
             break;
         case 'deactivate':
             $sids = SJB_Request::getVar('polls');
             if (is_array($sids)) {
                 foreach ($sids as $sid => $val) {
                     SJB_PollsManager::deactivatePollBySID($sid);
                 }
             } else {
                 $errors[] = 'NO_POLLS_SELECTED';
             }
             $action = 'list';
             break;
         case 'save_display_setting':
             $settings = SJB_Request::getVar('settings');
             SJB_Settings::updateSettings($settings);
             $action = 'list';
             break;
         case 'view_results':
             $sid = SJB_Request::getVar('sid', 0);
             $countVotes = SJB_PollsManager::getCountVotesBySID($sid);
             $pollResults = SJB_PollsManager::getPollResultsBySID($sid);
             $result = array();
             $i = 0;
             $colors = array('613978', 'aad434', 'f55c00', 'f9c635', 'f97c9e', '870000', '0ec300', '6f6f6f', '0400a5', '6eeffb', '000000', 'ff00ff');
             foreach ($pollResults as $poll) {
                 $result[$i]['vote'] = $countVotes > 0 ? round(100 / $countVotes * $poll['count'], 2) : 0;
                 $result[$i]['width'] = $countVotes > 0 ? round(300 / $countVotes * $poll['count'], 2) : 0;
                 $result[$i]['value'] = $poll['question'];
                 $result[$i]['color'] = $colors[$i];
                 $i++;
             }
             $pollInfo = SJB_PollsManager::getPollInfoBySID($sid);
             $tp->assign('pollInfo', $pollInfo);
             $tp->assign('result', $result);
             $tp->assign('width', count($pollResults) * 40 + (count($pollResults) - 1) * 3);
             $tp->assign('count_vote', $countVotes);
             $template = 'view_result.tpl';
             break;
     }
     if ($action == 'list') {
         $paginator = new SJB_PollsManagePagination();
         $pollsCount = 0;
         $pollsInfo = SJB_PollsManager::getPollsInfo($paginator->sortingField, $paginator->sortingOrder, ($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage, $pollsCount);
         $paginator->setItemsCount($pollsCount);
         $showPollsOnMainPage = SJB_Settings::getSettingByName('show_polls_on_main_page');
         $tp->assign('errors', $errors);
         $tp->assign('frontendLanguages', SJB_ObjectMother::createI18N()->getActiveFrontendLanguagesData());
         $tp->assign('pollsInfo', $pollsInfo);
         $tp->assign('show_polls_on_main_page', $showPollsOnMainPage);
         $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     }
     if ($action !== 'edit_answer') {
         $tp->assign('action', $action);
         $tp->assign('polls', 1);
         $tp->display($template);
     }
 }
Пример #11
0
 function getKeywordValue()
 {
     $i18n = SJB_ObjectMother::createI18N();
     return $i18n->getInput('integer', $this->property_info['value']);
 }
Пример #12
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $userInfo = SJB_Authorization::getCurrentUserInfo();
     if (empty($userInfo)) {
         $tp->assign("ERROR", "NOT_LOGIN");
         $tp->display("../miscellaneous/error.tpl");
         return;
     }
     $template = SJB_Request::getVar('template', 'my_invoices.tpl');
     $searchTemplate = SJB_Request::getVar('search_template', 'invoice_search_form.tpl');
     /***************************************************************/
     $_REQUEST['action'] = 'search';
     $_REQUEST['user_sid']['equal'] = $userInfo['sid'];
     if (!isset($_REQUEST['date'])) {
         $i18n = SJB_ObjectMother::createI18N();
         $_REQUEST['date']['not_less'] = $i18n->getDate(date('Y-m-d', time() - 30 * 24 * 60 * 60));
         $_REQUEST['date']['not_more'] = $i18n->getDate(date('Y-m-d'));
     }
     $invoice = new SJB_Invoice(array());
     $invoice->addProperty(array('id' => 'username', 'type' => 'string', 'value' => '', 'is_system' => true));
     $aliases = new SJB_PropertyAliases();
     $aliases->addAlias(array('id' => 'username', 'real_id' => 'user_sid', 'transform_function' => 'SJB_UserDBManager::getUserSIDsLikeSearchString'));
     $searchFormBuilder = new SJB_SearchFormBuilder($invoice);
     $criteriaSaver = new SJB_InvoiceCriteriaSaver();
     if (isset($_REQUEST['restore'])) {
         $_REQUEST = array_merge($_REQUEST, $criteriaSaver->getCriteria());
     }
     $criteria = $searchFormBuilder->extractCriteriaFromRequestData($_REQUEST, $invoice);
     $searchFormBuilder->setCriteria($criteria);
     $searchFormBuilder->registerTags($tp);
     $tp->display($searchTemplate);
     /********************** S O R T I N G *********************/
     $criteria = $searchFormBuilder->extractCriteriaFromRequestData($_REQUEST, $invoice);
     $searcher = new SJB_InvoiceSearcher();
     $foundInvoices = array();
     $foundInvoicesInfo = array();
     if (SJB_Request::getVar('action', '') == 'search') {
         $foundInvoices = $searcher->getObjectsByCriteria($criteria, $aliases);
         $criteriaSaver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
     } elseif (isset($_REQUEST['restore'])) {
         $foundInvoices = $criteriaSaver->getObjectsFromSession();
     }
     foreach ($foundInvoices as $id => $invoice) {
         $invoice->addProperty(array('id' => 'sid', 'type' => 'string', 'value' => $invoice->getSID()));
         $subUserSid = $invoice->getPropertyValue('subuser_sid');
         if ($subUserSid) {
             $payer = SJB_UserManager::getUserNameByUserSID($subUserSid);
         } else {
             $userSid = $invoice->getPropertyValue('user_sid');
             $payer = SJB_UserManager::getUserNameByUserSID($userSid);
         }
         $invoice->addProperty(array('id' => 'payer', 'type' => 'string', 'value' => $payer));
         $foundInvoices[$id] = $invoice;
         $foundInvoicesInfo[$invoice->getSID()] = SJB_InvoiceManager::getInvoiceInfoBySID($invoice->getSID());
     }
     $sortingField = SJB_Request::getVar('sorting_field', 'sid');
     $sortingOrder = SJB_Request::getVar('sorting_order', 'DESC');
     if ($invoice->propertyIsSet($sortingField)) {
         $sortArray = array();
         $sortedFoundInvoicesInfo = array();
         foreach ($foundInvoices as $id => $invoice) {
             $sortArray[$id] = $invoice->getPropertyValue($sortingField);
         }
         if ($sortingOrder == 'ASC') {
             asort($sortArray);
         } elseif ($sortingOrder == 'DESC') {
             arsort($sortArray);
         }
         foreach ($sortArray as $id => $value) {
             $sortedFoundInvoicesInfo[$id] = $foundInvoicesInfo[$id];
         }
     } else {
         $sortedFoundInvoicesInfo = $foundInvoicesInfo;
     }
     $formCollection = new SJB_FormCollection($foundInvoices);
     $formCollection->registerTags($tp);
     $subUsers = SJB_UserManager::getSubUsers($userInfo['sid']);
     $isSubUserExists = !empty($subUsers) ? true : false;
     $tp->assign('isSubUserExists', $isSubUserExists);
     $tp->assign('sorting_field', $sortingField);
     $tp->assign('sorting_order', $sortingOrder);
     $tp->assign('found_invoices', $sortedFoundInvoicesInfo);
     $tp->display($template);
 }
Пример #13
0
 function addDomain($name)
 {
     $i18n = SJB_ObjectMother::createI18N();
     $langs_data = $i18n->getLanguagesData();
     return $this->tr_admin->addPage($name, $langs_data);
 }
Пример #14
0
 public static function get($action, $params, $template_processor)
 {
     $i18n = SJB_ObjectMother::createI18N();
     $storage = SJB_InfoStorage::createTranslationFilterStorage();
     if (SJB_System::getSystemSettings("isDemo")) {
         $blockedActions = array("add_phrase", "update_phrase", "delete_phrase");
         if (in_array($action, $blockedActions)) {
             $phraseAction = new SJB_PhraseAction();
             return $phraseAction;
         }
     }
     switch ($action) {
         case "search_phrases":
             $searchPhraseAction = new SJB_SearchPhraseAction($i18n, $params, $template_processor);
             $storePhraseSearchCriteriaAction = new SJB_StorePhraseSearchCriteriaAction($storage, $params);
             $phraseAction = new SJB_SerialActionBatch();
             $phraseAction->addAction($searchPhraseAction);
             $phraseAction->addAction($storePhraseSearchCriteriaAction);
             $phraseAction->result = '';
             break;
         case "remember_previous_state":
             // Criteria are passed by reference to be accessible in the
             // RestorePhraseSearchCriteriaAction and the SearchPhraseAction.
             // So in the RestorePhraseSearchCriteriaAction it can be got from the storage
             // and in the SearchPhraseAction it can be used to search phrases.
             $criteria = null;
             $searchPhraseAction = new SJB_SearchPhraseAction($i18n, $criteria, $template_processor);
             $restorePhraseSearchCriteriaAction = new SJB_RestorePhraseSearchCriteriaAction($storage, $criteria);
             $phraseAction = new SJB_SerialActionBatch();
             $phraseAction->addAction($restorePhraseSearchCriteriaAction);
             $phraseAction->addAction($searchPhraseAction);
             $phraseAction->result = '';
             break;
         case "add_phrase":
             $phraseAction = new SJB_AddPhraseAction($i18n, $params);
             $phraseAction->result = 'added';
             break;
         case "update_phrase":
             $phraseAction = new SJB_UpdatePhraseAction($i18n, $params);
             $phraseAction->result = 'saved';
             break;
         case "delete_phrase":
             $phrase = isset($params['phrase']) ? $params['phrase'] : null;
             $domain = isset($params['domain']) ? $params['domain'] : null;
             // see remember_previous_state
             $criteria = null;
             $searchPhraseAction = new SJB_SearchPhraseAction($i18n, $criteria, $template_processor);
             $restorePhraseSearchCriteriaAction = new SJB_RestorePhraseSearchCriteriaAction($storage, $criteria);
             $deletePhraseAction = new SJB_DeletePhraseAction($i18n, $phrase, $domain);
             $phraseAction = new SJB_SerialActionBatch();
             $phraseAction->addAction($deletePhraseAction);
             $phraseAction->addAction($restorePhraseSearchCriteriaAction);
             $phraseAction->addAction($searchPhraseAction);
             $phraseAction->result = 'deleted';
             break;
         default:
             $phraseAction = new SJB_PhraseAction();
             break;
     }
     return $phraseAction;
 }
Пример #15
0
 public function execute()
 {
     $errors = array();
     $messages = array();
     $action = SJB_Request::getVar('action', false);
     $tp = SJB_System::getTemplateProcessor();
     $archiveCategory = SJB_NewsManager::getCategoryByName('Archive');
     $tp->assign('archive_category', $archiveCategory);
     /****************** ACTIONS ***************************/
     switch ($action) {
         case 'save_display_setting':
             // save setting 'show_news_on_main_page'
             $settings = SJB_Request::getVar('settings');
             SJB_Settings::updateSettings($settings);
             $messages[] = 'NEWS_SETTINGS_SUCCESSFULLY_SAVED';
             break;
         case 'add':
             $categoryName = SJB_Request::getVar('category_name');
             if (empty($categoryName)) {
                 $errors['Category Name'] = 'EMPTY_VALUE';
                 break;
             }
             $isExists = SJB_NewsManager::checkExistsCategoryName($categoryName);
             if ($isExists) {
                 $errors['Category Name'] = 'NOT_UNIQUE_VALUE';
                 break;
             }
             if (SJB_NewsManager::addCategory($categoryName)) {
                 $messages[] = 'NEWS_CATEGORY_SUCCESSFULLY_ADDED';
             } else {
                 $errors[] = 'NEWS_CATEGORY_NOT_SAVED';
             }
             break;
         case 'edit':
             $categoryId = SJB_Request::getVar('category_sid');
             $formSubmitted = SJB_Request::getVar('submit');
             if ($formSubmitted) {
                 $newCategoryName = SJB_Request::getVar('category_name');
                 if (!empty($newCategoryName)) {
                     $isExists = SJB_NewsManager::checkExistsCategoryName($newCategoryName);
                     if (!$isExists) {
                         if (SJB_NewsManager::updateCategory($categoryId, $newCategoryName)) {
                             $messages[] = 'NEWS_CATEGORY_SUCCESSFULLY_SAVED';
                         } else {
                             $errors[] = 'NEWS_CATEGORY_NOT_SAVED';
                         }
                     } else {
                         $errors['Category Name'] = 'NOT_UNIQUE_VALUE';
                     }
                 } else {
                     $errors['Category Name'] = 'EMPTY_VALUE';
                 }
                 if ($formSubmitted == 'save_category' && empty($errors)) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/news-categories/');
                 }
             }
             if (SJB_Request::getVar('newsAdded', false)) {
                 $messages[] = 'NEWS_SUCCESSFULLY_ADDED';
             }
             if (SJB_Request::getVar('newsDeleted', false)) {
                 $messages[] = 'NEWS_SUCCESSFULLY_DELETED';
             }
             if (SJB_Request::getVar('newsSaved', false)) {
                 $messages[] = 'NEWS_SUCCESSFULLY_SAVED';
             }
             $category = SJB_NewsManager::getCategoryBySid($categoryId);
             $paginator = new SJB_NewsPagination($categoryId, $category['name']);
             $paginator->setItemsCount(SJB_NewsManager::getAllNewsCount($categoryId));
             $articles = SJB_NewsManager::getArticlesByCategorySid($categoryId, $paginator->sortingField, $paginator->sortingOrder, $paginator->currentPage, $paginator->itemsPerPage);
             $i18N = SJB_ObjectMother::createI18N();
             $tp->assign('paginationInfo', $paginator->getPaginationInfo());
             $tp->assign('frontendLanguages', $i18N->getActiveFrontendLanguagesData());
             $tp->assign('messages', $messages);
             $tp->assign('errors', $errors);
             $tp->assign('category', $category);
             $tp->assign('articles', $articles);
             $tp->display('edit_category.tpl');
             break;
         case 'delete':
             $categorySID = SJB_Request::getVar('category_sid');
             if (!empty($categorySID)) {
                 if (SJB_NewsManager::deleteCategoryBySid($categorySID)) {
                     $messages[] = 'NEWS_CATEGORY_SUCCESSFULLY_DELETED';
                 } else {
                     $errors[] = 'NEWS_CATEGORY_NOT_DELETED';
                 }
             }
             break;
         case 'move_up':
             $categoryId = SJB_Request::getVar('category_sid');
             SJB_NewsManager::moveUpCategoryBySID($categoryId);
             break;
         case 'move_down':
             $categoryId = SJB_Request::getVar('category_sid');
             SJB_NewsManager::moveDownCategoryBySID($categoryId);
             break;
     }
     if ($action != 'edit') {
         $categories = SJB_NewsManager::getCategories();
         $showNewsOnMainPage = SJB_Settings::getSettingByName('show_news_on_main_page');
         // get number of news for categories
         foreach ($categories as $key => $category) {
             // remove archive from categories list
             if ($category['name'] == 'Archive') {
                 unset($categories[$key]);
                 continue;
             }
             $counter = SJB_NewsManager::getAllNewsCount($category['sid'], null);
             $categories[$key]['count'] = $counter;
         }
         $tp->assign('categories', $categories);
         $tp->assign('messages', $messages);
         $tp->assign('show_news_on_main_page', $showNewsOnMainPage);
         $tp->assign('number_news_on_main_page', SJB_Settings::getSettingByName('number_news_on_main_page'));
         $tp->assign('main_page_news_display_mode', SJB_Settings::getSettingByName('main_page_news_display_mode'));
         $tp->assign('errors', $errors);
         $tp->display('categories_list.tpl');
     }
 }
Пример #16
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     /********** A C T I O N S   W I T H   T R A N S A C T I O N S **********/
     $action = SJB_Request::getVar('action_name', SJB_Request::getVar('action', false));
     $transactions_sids = SJB_Request::getVar('transactions', false);
     if ($action && $transactions_sids) {
         $_REQUEST['restore'] = 1;
         if ($action == 'delete') {
             // DELETE
             foreach ($transactions_sids as $transaction_sid => $value) {
                 SJB_TransactionManager::deleteTransactionBySID($transaction_sid);
             }
         } else {
             unset($_REQUEST['restore']);
         }
     }
     /**********  D E F A U L T   V A L U E S   F O R   S E A R C H  **********/
     $_REQUEST['action'] = 'filter';
     $i18n = SJB_ObjectMother::createI18N();
     if (!isset($_REQUEST['date'])) {
         $_REQUEST['date']['not_less'] = $i18n->getDate(date('Y-m-d', time() - 30 * 24 * 60 * 60));
         $_REQUEST['date']['not_more'] = $i18n->getDate(date('Y-m-d', time() + 24 * 60 * 60));
     } else {
         if (!$i18n->isValidDate($_REQUEST['date']['not_less']) && !empty($_REQUEST['date']['not_less'])) {
             $errors[] = 'INVALID_PERIOD_FROM';
         }
         if (!$i18n->isValidDate($_REQUEST['date']['not_more']) && !empty($_REQUEST['date']['not_more'])) {
             $errors[] = 'INVALID_PERIOD_TO';
         }
     }
     /************************ S E A R C H   F O R M ***************************/
     $transaction = new SJB_Transaction();
     $transaction->addProperty(array('id' => 'username', 'type' => 'string', 'value' => '', 'is_system' => true));
     $aliases = new SJB_PropertyAliases();
     $aliases->addAlias(array('id' => 'username', 'real_id' => 'user_sid', 'transform_function' => 'SJB_UserManager::getUserSIDsLikeUsername'));
     $search_form_builder = new SJB_SearchFormBuilder($transaction);
     $criteria_saver = new SJB_TransactionCriteriaSaver();
     if (isset($_REQUEST['restore'])) {
         $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
     }
     $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $transaction);
     $search_form_builder->setCriteria($criteria);
     $search_form_builder->registerTags($tp);
     $tp->display('payment_form.tpl');
     /********************  S E A R C H  ************************/
     $paginator = new SJB_TransactionHistoryPagination();
     $searcher = new SJB_TransactionSearcher($paginator);
     if (SJB_Request::getVar('action', '') == 'filter') {
         $transactions = $searcher->getObjectsByCriteria($criteria, $aliases);
         if (empty($transactions) && $paginator->currentPage != 1) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/payments/?page=1');
         }
         $criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
     } elseif (isset($_REQUEST['restore'])) {
         $transactions = $criteria_saver->getObjectsFromSession();
     }
     $paginator->setItemsCount($searcher->getAffectedRows());
     $found_trans = array();
     $found_trans_sids = array();
     foreach ($transactions as $transaction) {
         $user_sid = $transaction->getPropertyValue('user_sid');
         $username = SJB_UserManager::getUserNameByUserSID($user_sid);
         $transaction->addProperty(array('id' => 'username', 'type' => 'string', 'value' => $username));
         $found_trans[$transaction->getSID()] = $transaction;
         $found_trans_sids[$transaction->getSID()] = $transaction->getSID();
     }
     $sorted_found_trans_sids = $found_trans_sids;
     $form_collection = new SJB_FormCollection($found_trans);
     $form_collection->registerTags($tp);
     $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     $tp->assign('errors', $errors);
     $tp->assign('found_transactions_sids', $sorted_found_trans_sids);
     $tp->display('payments.tpl');
 }