Пример #1
0
 public function execute()
 {
     $breadcrumbs = new SJB_Breadcrumbs();
     $errors = array();
     if (isset($_REQUEST['action'])) {
         // проверим, задали element_id или нет
         if (!isset($_REQUEST['element_id'])) {
             // задаем текст ошибки и сбрасываем 'action', чтобы ничего не выполнялось
             $errors[] = "NOT_ID";
             $_REQUEST['action'] = '';
         } else {
             $element_id = $_REQUEST['element_id'];
         }
         switch ($_REQUEST['action']) {
             case 'add':
                 // если была отправка формы добавления элемента
                 if (isset($_REQUEST['addElement']) && $_REQUEST['addElement'] != '') {
                     $item_name = $_REQUEST['item_name'];
                     $item_uri = $_REQUEST['item_uri'];
                     $breadcrumbs->addElement($item_name, $item_uri, $element_id);
                     $site_url = SJB_System::getSystemSettings("SITE_URL");
                     SJB_HelperFunctions::redirect($site_url . "/manage-breadcrumbs/");
                 }
                 $parentElement = $breadcrumbs->getElement($element_id);
                 $tp = SJB_System::getTemplateProcessor();
                 $tp->assign("parentElement", $parentElement);
                 $tp->display("add_item.tpl");
                 break;
             case 'edit':
                 // если была отправка формы редактирования элемента
                 if (isset($_REQUEST['updateElement']) && $_REQUEST['updateElement'] != '') {
                     $item_name = $_REQUEST['item_name'];
                     $item_uri = $_REQUEST['item_uri'];
                     $breadcrumbs->updateElement($item_name, $item_uri, $element_id);
                     $site_url = SJB_System::getSystemSettings("SITE_URL");
                     SJB_HelperFunctions::redirect($site_url . "/manage-breadcrumbs/");
                 }
                 $editElement = $breadcrumbs->getElement($element_id);
                 $tp = SJB_System::getTemplateProcessor();
                 $tp->assign("editElement", $editElement);
                 $tp->display("edit_item.tpl");
                 break;
             case 'delete':
                 $breadcrumbs->deleteElement($element_id);
                 $site_url = SJB_System::getSystemSettings("SITE_URL");
                 SJB_HelperFunctions::redirect($site_url . "/manage-breadcrumbs/");
                 break;
             default:
                 break;
         }
     }
     $navStructure = $breadcrumbs->makeStructure();
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('ERRORS', $errors);
     $tp->assign("navStructure", $navStructure);
     $tp->display("manage_breadcrumbs.tpl");
 }
Пример #2
0
 public function execute()
 {
     $listing_type = new SJB_ListingType($_REQUEST);
     $add_listing_type_form = new SJB_Form($listing_type);
     $form_is_submitted = SJB_Request::getVar('action') == 'add';
     $errors = null;
     if ($form_is_submitted && $add_listing_type_form->isDataValid($errors)) {
         SJB_ListingTypeManager::saveListingType($listing_type);
         $this->createListingTypePage($listing_type);
         $listingTypeID = $listing_type->getID();
         if (in_array($listingTypeID, array('Job', 'Resume'))) {
             $title = $listing_type->getPropertyValue('name');
         } else {
             $title = $listing_type->getPropertyValue('name') . ' Listing';
         }
         $pageInfo = array('page_id' => 'Post' . $listingTypeID, 'page_name' => 'Post ' . $title);
         $page = new SJB_PostingPages($pageInfo, $listing_type->getSID());
         SJB_PostingPagesManager::savePage($page);
         SJB_PageManager::addPage(array('uri' => '/' . strtolower($listingTypeID) . '-preview/', 'module' => 'classifieds', 'function' => 'display_my_listing', 'template' => '', 'title' => $title . ' Preview', 'access_type' => 'user', 'parameters' => array('display_template' => 'display_listing.tpl'), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 1));
         SJB_PageManager::addPage(array('uri' => '/my-' . strtolower($listingTypeID) . '-details/', 'module' => 'classifieds', 'function' => 'display_my_listing', 'template' => '', 'title' => 'My ' . $title . ' Details', 'access_type' => 'user', 'parameters' => array('display_template' => 'display_listing.tpl'), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 1));
         SJB_PageManager::addPage(array('uri' => '/print-my-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'display_my_listing', 'template' => 'blank.tpl', 'title' => 'Print ' . $title, 'access_type' => 'user', 'parameters' => array('display_template' => 'print_listing.tpl', 'listing_type_id' => $listingTypeID), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 0));
         SJB_PageManager::addPage(array('uri' => '/print-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'display_listing', 'template' => 'blank.tpl', 'title' => 'Print ' . $title, 'access_type' => 'user', 'parameters' => array('display_template' => 'print_listing.tpl', 'listing_type_id' => $listingTypeID), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 0));
         SJB_PageManager::addPage(array('uri' => '/manage-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'manage_listing', 'template' => '', 'title' => 'Manage ' . $title, 'access_type' => 'user', 'parameters' => array(), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 1));
         SJB_PageManager::addPage(array('uri' => '/edit-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'edit_listing', 'template' => '', 'title' => 'Edit ' . $title, 'access_type' => 'user', 'parameters' => '', 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 0));
         $breadCrumbs = new SJB_Breadcrumbs();
         $parentId = $breadCrumbs->getElementByUri('/my-listings/');
         $uri = '/my-listings/' . $listingTypeID . '/';
         $breadCrumbs->addElement('My ' . $title . 's', $uri, $parentId);
         $newBreadcrumbId = $breadCrumbs->getElementByUri($uri);
         $breadCrumbs->addElement('My ' . $title . ' Preview', '/my-' . strtolower($listingTypeID) . '-details/', $newBreadcrumbId);
         $breadCrumbs->addElement('Edit ' . $title, '/edit-' . strtolower($listingTypeID) . '/', $newBreadcrumbId);
         $breadCrumbs->addElement('Manage ' . $title, '/manage-' . strtolower($listingTypeID) . '/', $newBreadcrumbId);
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/listing-types/");
     } else {
         $template_processor = SJB_System::getTemplateProcessor();
         $template_processor->assign("errors", $errors);
         $add_listing_type_form->registerTags($template_processor);
         $template_processor->assign("form_fields", $add_listing_type_form->getFormFieldsInfo());
         $template_processor->display("add_listing_type.tpl");
     }
 }