Exemplo n.º 1
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');
 }
Exemplo n.º 2
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');
     }
 }
Exemplo n.º 3
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');
 }
Exemplo n.º 4
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');
 }