public static function _getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new ilShopTopics();
     }
     return self::$instance;
 }
 public function showTopicsSortingTable()
 {
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     include_once 'Services/Payment/classes/class.ilShopPersonalSettingsTopicsTableGUI.php';
     $table_gui = new ilShopPersonalSettingsTopicsTableGUI($this, 'showTopicsSortingTable');
     $table_gui->setTitle($this->lng->txt('pay_manual_sorting_of_topics'));
     ilShopTopics::_getInstance()->enableCustomSorting(true);
     ilShopTopics::_getInstance()->setSortingType(ilShopTopics::TOPICS_SORT_MANUALLY);
     ilShopTopics::_getInstance()->setSortingDirection('ASC');
     ilShopTopics::_getInstance()->read();
     $table_gui->parseRecords(ilShopTopics::_getInstance()->getTopics());
     $table_gui->addCommandButton('saveSorting', $this->lng->txt('pay_save_sorting'));
     $this->tpl->setVariable('TABLE', $table_gui->getHTML());
 }
 public function showTopics()
 {
     $oContainerTpl = new ilTemplate('tpl.shop_container.html', true, true, 'Services/Payment');
     include_once './Services/Payment/classes/class.ilShopTopic.php';
     include_once './Services/Payment/classes/class.ilShopTopics.php';
     $results = $this->result;
     ilShopTopics::_getInstance()->setIdFilter(false);
     ilShopTopics::_getInstance()->read();
     $html = '';
     if (count($topics = ilShopTopics::_getInstance()->getTopics())) {
         foreach ($topics as $oTopic) {
             $html .= $this->renderItems($oContainerTpl, $results, array('id' => $oTopic->getId(), 'title' => $oTopic->getTitle()));
         }
         $html .= $this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
     } else {
         $html .= $this->renderItems($oContainerTpl, $results, array('id' => 0, 'title' => $this->lng->txt('payment_no_topic')));
     }
     return $html;
 }
 public function editDetailsObject($a_show_confirm = false)
 {
     global $ilToolbar;
     if (!(int) $_GET['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         return $this->objectsObject();
     }
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']);
     $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
     $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
     $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
     if ($tmp_obj) {
         $tmp_object['title'] = $tmp_obj->getTitle();
         $tmp_object['type'] = $tmp_obj->getType();
     } else {
         $tmp_object['title'] = $this->lng->txt('object_not_found');
         $tmp_object['type'] = '';
     }
     if ($a_show_confirm) {
         include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
         $oConfirmationGUI = new ilConfirmationGUI();
         // set confirm/cancel commands
         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performObjectDelete"));
         $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_object"));
         $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "objects");
         $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performObjectDelete");
         $oConfirmationGUI->addItem('', $tmp_object['title'], $tmp_object['title']);
         $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
         return true;
     }
     $oForm = new ilPropertyFormGUI();
     $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
     $oForm->setTitle($tmp_object['title']);
     // repository path
     $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path'));
     $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId()));
     $oForm->addItem($oPathGUI);
     // number of purchasers
     $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
     $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
     $oForm->addItem($oPurchasersGUI);
     // vendors
     $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
     $oVendorsGUI->setOptions($this->__getVendors());
     $oVendorsGUI->setValue($this->pobject->getVendorId());
     $oForm->addItem($oVendorsGUI);
     // status
     $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status');
     $oStatusGUI->setOptions($this->__getStatus());
     $oStatusGUI->setValue($this->pobject->getStatus());
     $oForm->addItem($oStatusGUI);
     // pay methods
     $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
     $oPayMethodsGUI->setOptions(ilPayMethods::getPayMethodsOptions('not_specified'));
     $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
     $oForm->addItem($oPayMethodsGUI);
     // topics
     include_once './Services/Payment/classes/class.ilShopTopics.php';
     ilShopTopics::_getInstance()->read();
     if (is_array($topics = ilShopTopics::_getInstance()->getTopics()) && count($topics)) {
         $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id');
         ilShopTopics::_getInstance()->read();
         $topic_options = array();
         $topic_options[''] = $this->lng->txt('please_choose');
         foreach ($topics as $oTopic) {
             $topic_options[$oTopic->getId()] = $oTopic->getTitle();
         }
         $oTopicsGUI->setOptions($topic_options);
         $oTopicsGUI->setValue($this->pobject->getTopicId());
         $oForm->addItem($oTopicsGUI);
     }
     // vats
     $oShopVatsList = new ilShopVatsList();
     $oShopVatsList->read();
     if ($oShopVatsList->hasItems()) {
         $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id');
         $vats_options = array();
         foreach ($oShopVatsList as $oVAT) {
             $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()) . ' -> ' . $oVAT->getTitle();
         }
         $oVatsGUI->setOptions($vats_options);
         $oVatsGUI->setValue($this->pobject->getVatId());
         $oForm->addItem($oVatsGUI);
     } else {
         $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate'));
         $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned'));
         $oForm->addItem($oVatsGUI);
     }
     $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
     $oFile = new ilFileDataShop($this->pobject->getPobjectId());
     if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) {
         $oThumbnail->setImage($webpath_file);
     }
     $oForm->addItem($oThumbnail);
     // buttons
     $oForm->addCommandButton('updateDetails', $this->lng->txt('save'));
     $oForm->addCommandButton('deleteObject', $this->lng->txt('delete'));
     $this->tpl->setVariable('FORM', $oForm->getHTML());
     return true;
 }
Exemple #5
0
 public function showTopicsFilter($a_count_result = 0)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('show_topics_filter');
     ilShopTopics::_getInstance()->setIdFilter(false);
     ilShopTopics::_getInstance()->read();
     if (count(ilShopTopics::_getInstance()->getTopics())) {
         $this->tpl->setVariable('PAGE_CONTENT', $this->getPageHTML());
         $this->tpl->setVariable('SORTING_FORM_ACTION', $this->ctrl->getFormAction($this, 'setFilter'));
         $this->tpl->setVariable('SET_FILTER_VAL', $this->lng->txt('pay_update_view'));
         $this->tpl->setCurrentBlock('topics_option');
         $this->tpl->setVariable('SORT_TOPICS', $this->lng->txt('topic'));
         $this->tpl->setVariable('FILTER_TOPIC_ID', 'no_selection');
         $this->tpl->setVariable('FILTER_TOPIC_TEXT', '------------');
         if ($_POST['cmd'] == 'firstpage') {
             $this->tpl->setVariable('FILTER_TOPIC_SELECTED', 'selected');
         }
         $this->tpl->parseCurrentBlock('topics_option');
         $this->tpl->setVariable('FILTER_TOPIC_ID', 'all');
         $this->tpl->setVariable('FILTER_TOPIC_TEXT', $this->lng->txt('all'));
         if ($_POST['filter_topic_id'] == 'all') {
             $this->tpl->setVariable('FILTER_TOPIC_SELECTED', 'selected');
         }
         $this->tpl->parseCurrentBlock('topics_option');
         $oTopics = array();
         $oTopics = ilShopTopics::_getInstance()->getTopics();
         foreach ($oTopics as $oTopic) {
             $this->tpl->setVariable('FILTER_TOPIC_ID', $oTopic->getId());
             $this->tpl->setVariable('FILTER_TOPIC_TEXT', $oTopic->getTitle());
             if ($_POST['filter_topic_id'] == $oTopic->getId()) {
                 $this->tpl->setVariable('FILTER_TOPIC_SELECTED', 'selected');
             }
             $this->tpl->parseCurrentBlock('topics_option');
         }
     }
     if ($a_count_result) {
         $objects = (bool) $this->settings->get('objects_allow_custom_sorting');
         if ($objects) {
             // sorting form
             $allow_objects_option = array('title' => $this->lng->txt('title'), 'author' => $this->lng->txt('author'), 'price' => $this->lng->txt('price_a'));
             $this->tpl->setCurrentBlock('order_field');
             $this->tpl->setVariable('SORT_BY_TEXT', $this->lng->txt('sort_by'));
             foreach ($allow_objects_option as $key => $value) {
                 $this->tpl->setVariable('ORDER_FIELD_VALUE', $key);
                 $this->tpl->setVariable('ORDER_FIELD_TEXT', $value);
                 if ($_POST['order_field'] == $key) {
                     $this->tpl->setVariable('ORDER_FIELD_SELECTED', 'selected');
                 }
                 $this->tpl->parseCurrentBlock('order_field');
             }
         }
         $topics = (bool) $this->settings->get('topics_allow_custom_sorting');
         if ($topics) {
             // sorting form
             $allow_topics_option = array(ilShopTopics::TOPICS_SORT_BY_TITLE => $this->lng->txt('sort_topics_by_title'), ilShopTopics::TOPICS_SORT_BY_CREATEDATE => $this->lng->txt('sort_topics_by_date'));
             if (ANONYMOUS_USER_ID != $ilUser->getId()) {
                 $allow_topics_option[ilShopTopics::TOPICS_SORT_MANUALLY] = $this->lng->txt('sort_topics_manually');
             }
         }
     }
 }
 public function initFilter()
 {
     global $lng, $ilUser;
     $o_filter = new ilSelectInputGUI();
     $filter_option = array('title' => $lng->txt('title'), 'author' => $lng->txt('author'), 'metadata' => $lng->txt('meta_data'));
     $o_filter->setTitle($lng->txt('search_in'));
     $o_filter->setOptions($filter_option);
     $o_filter->setValue($_SESSION['content_filter']['sel_filter_type']);
     $o_filter->setPostVar('sel_filter_type');
     $this->addFilterItem($o_filter);
     $o_filter->readFromSession();
     $this->filter["sel_filter_type"] = $o_filter->getValue();
     $o_filter_by = new ilTextInputGUI($lng->txt('filter_by'));
     $o_filter_by->setValue($_SESSION['content_filter']['filter_text']);
     $o_filter_by->setPostVar('filter_text');
     $this->addFilterItem($o_filter_by);
     $o_filter_by->readFromSession();
     $this->filter["filter_text"] = $o_filter_by->getValue();
     if ($this->settings->get('enable_topics')) {
         ilShopTopics::_getInstance()->setIdFilter(false);
         ilShopTopics::_getInstance()->read();
         $topic_option = array();
         if (count(ilShopTopics::_getInstance()->getTopics())) {
             $topic_option[''] = $lng->txt('please_select');
             foreach (ilShopTopics::_getInstance()->getTopics() as $oTopic) {
                 $topic_option[$oTopic->getId()] = $oTopic->getTitle();
             }
         } else {
             $topic_option[''] = $lng->txt('no_topics_yet');
         }
         $o_topic = new ilSelectInputGUI();
         $o_topic->setTitle($lng->txt('topic'));
         $o_topic->setOptions($topic_option);
         $o_topic->setValue($_SESSION['content_filter']['filter_topic_id']);
         $o_topic->setPostVar('filter_topic_id');
         $this->addFilterItem($o_topic);
         $o_topic->readFromSession();
         $this->filter["filter_topic_id"] = $o_topic->getValue();
         if ((bool) $this->settings->get('objects_allow_custom_sorting')) {
             // sorting form
             $allow_objects_option = array('title' => $lng->txt('title'), 'author' => $lng->txt('author'), 'price' => $lng->txt('price_a'));
             $o_allow_objects = new ilSelectInputGUI();
             $o_allow_objects->setTitle($lng->txt('sort_by'));
             $o_allow_objects->setOptions($allow_objects_option);
             $o_allow_objects->setValue($this->getSortField());
             $o_allow_objects->setPostVar('order_field');
             //objects_sorting_type
             $this->addFilterItem($o_allow_objects);
             $o_allow_objects->readFromSession();
             $this->filter["order_field"] = $o_allow_objects->getValue();
             $direction_option = array('asc' => $lng->txt('sort_asc'), 'desc' => $lng->txt('sort_desc'));
             $o_object_direction = new ilSelectInputGUI();
             $o_object_direction->setOptions($direction_option);
             $o_object_direction->setValue($this->getSortDirection());
             $o_object_direction->setPostVar('order_direction');
             //objects_sorting_direction
             $this->addFilterItem($o_object_direction);
             $o_object_direction->readFromSession();
             $this->filter["order_direction"] = $o_object_direction->getValue();
         }
         if ((bool) $this->settings->get('topics_allow_custom_sorting')) {
             // sorting form
             $allow_topics_option = array(ilShopTopics::TOPICS_SORT_BY_TITLE => $lng->txt('sort_topics_by_title'), ilShopTopics::TOPICS_SORT_BY_CREATEDATE => $lng->txt('sort_topics_by_date'));
             if (ANONYMOUS_USER_ID != $ilUser->getId()) {
                 $allow_topics_option[ilShopTopics::TOPICS_SORT_MANUALLY] = $lng->txt('sort_topics_manually');
             }
             $o_allow_topics = new ilSelectInputGUI();
             $o_allow_topics->setTitle($lng->txt('sort_topics_by'));
             $o_allow_topics->setOptions($allow_topics_option);
             $o_allow_topics->setValue($this->getSortingTypeTopics());
             $o_allow_topics->setPostVar('topics_sorting_type');
             $this->addFilterItem($o_allow_topics);
             $o_allow_topics->readFromSession();
             $this->filter["topics_sorting_type"] = $o_allow_topics->getValue();
             $direction_option = array('asc' => $lng->txt('sort_asc'), 'desc' => $lng->txt('sort_desc'));
             $o_topics_direction = new ilSelectInputGUI();
             $o_topics_direction->setOptions($direction_option);
             $o_topics_direction->setValue($this->getSortingDirectionTopics());
             $o_topics_direction->setPostVar('topics_sorting_direction');
             //objects_sorting_type
             $this->addFilterItem($o_topics_direction);
             $o_topics_direction->readFromSession();
             $this->filter["topics_sorting_direction"] = $o_topics_direction->getValue();
         }
     }
 }
 private function searchObjects($query_parser)
 {
     // create new search result object and assign the sorted topics
     $oSearchResult = ilShopSearchResult::_getInstance(SHOP_ADVANCED_SEARCH);
     if ((bool) $this->settings->get('topics_allow_custom_sorting')) {
         ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
         ilShopTopics::_getInstance()->enableCustomSorting(true);
         ilShopTopics::_getInstance()->setSortingType((int) $this->getSortingTypeTopics());
         ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->getSortingDirectionTopics()));
         ilShopTopics::_getInstance()->read();
     } else {
         ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
         ilShopTopics::_getInstance()->enableCustomSorting(false);
         ilShopTopics::_getInstance()->setSortingType((int) $this->settings->get('topics_sorting_type'));
         ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->settings->get('topics_sorting_direction')));
         ilShopTopics::_getInstance()->read();
     }
     $oSearchResult->setTopics(ilShopTopics::_getInstance()->getTopics());
     $oSearchResult->setResultPageNumber((int) $_GET['page_number']);
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     $res = null;
     $obj_search = ilObjectSearchFactory::_getShopObjectSearchInstance($query_parser);
     $obj_search->setFilterShopTopicId((int) $this->getTopicId());
     $obj_search->setFilter($this->getFilter());
     $obj_search->setCustomSearchResultObject($oSearchResult);
     $res = $obj_search->performSearch();
     $meta_search_c = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_c->setMode('contribute');
     $meta_search_c->setFilter($this->getFilter());
     $meta_search_c->setFilterShopTopicId((int) $this->getTopicId());
     $meta_search_c->setCustomSearchResultObject($oSearchResult);
     $res->mergeEntries($meta_search_c->performSearch());
     $meta_search_t = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_t->setMode('title');
     $meta_search_t->setFilter($this->getFilter());
     $meta_search_t->setCustomSearchResultObject($oSearchResult);
     $meta_search_t->setFilterShopTopicId((int) $this->getTopicId());
     $res->mergeEntries($meta_search_t->performSearch());
     $meta_search_k = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_k->setMode('keyword');
     $meta_search_k->setFilter($this->getFilter());
     $meta_search_k->setCustomSearchResultObject($oSearchResult);
     $meta_search_k->setFilterShopTopicId((int) $this->getTopicId());
     $res->mergeEntries($meta_search_k->performSearch());
     return $res;
 }
 public function initFilter()
 {
     global $lng, $ilUser;
     // search term
     $search_term = new ilTextInputGUI($lng->txt('search_search_term'), 'search_string');
     $search_term->setValue($_SESSION['shop_advanced_search']['string']);
     $search_term->setPostVar('search_string');
     $this->addFilterItem($search_term);
     $search_term->readFromSession();
     $this->filter["search_string"] = $search_term->getValue();
     // search combination
     $radio_grp = new ilRadioGroupInputGUI('', 'search_combination');
     $radio_or = new ilRadioOption($lng->txt('search_any_word'), 'or');
     $radio_and = new ilRadioOption($lng->txt('search_all_words'), 'and');
     $radio_grp->addOption($radio_or);
     $radio_grp->addOption($radio_and);
     $radio_grp->setValue($_POST['search_combination']);
     $this->addFilterItem($radio_grp);
     $radio_grp->readFromSession();
     $this->filter['search_combination'] = $radio_grp->getValue();
     // search objects
     $object_types = new ilCheckboxGroupInputGUI($lng->txt('obj_type'), 'search_details');
     $cb_crs = new ilCheckboxInputGUI($lng->txt('courses'), 'search_details["crs"]');
     $cb_crs->setValue('crs');
     $cb_lms = new ilCheckboxInputGUI($lng->txt('learning_resources'), 'search_details["lms"]');
     $cb_lms->setValue('lms');
     $cb_tst = new ilCheckboxInputGUI($lng->txt('tests'), 'search_details["tst"]');
     $cb_tst->setValue('tst');
     $cb_fil = new ilCheckboxInputGUI($lng->txt('objs_file'), 'search_details["fil"]');
     $cb_fil->setValue('fil');
     $object_types->addOption($cb_crs);
     $object_types->addOption($cb_lms);
     $object_types->addOption($cb_tst);
     $object_types->addOption($cb_fil);
     $object_types->setValue($_SESSION['shop_advanced_search']['details']);
     $this->addFilterItem($object_types);
     $object_types->readFromSession();
     $this->filter['search_details'] = $object_types->getValue();
     // search topics
     ilShopTopics::_getInstance()->setIdFilter(false);
     ilShopTopics::_getInstance()->read();
     $topic_option = array();
     if (count(ilShopTopics::_getInstance()->getTopics())) {
         $topic_option[''] = $lng->txt('please_select');
         foreach (ilShopTopics::_getInstance()->getTopics() as $oTopic) {
             $topic_option[(string) $oTopic->getId()] = $oTopic->getTitle();
         }
     } else {
         $topic_option[''] = $lng->txt('no_topics_yet');
     }
     $o_topic = new ilSelectInputGUI();
     $o_topic->setTitle($lng->txt('topic'));
     $o_topic->setOptions($topic_option);
     $o_topic->setValue($_SESSION['shop_advanced_search']['topic']);
     $o_topic->setPostVar('search_topic');
     $this->addFilterItem($o_topic);
     $o_topic->readFromSession();
     $this->filter["search_topic"] = $o_topic->getValue();
     if ((bool) $this->settings->get('objects_allow_custom_sorting')) {
         // sorting form
         $allow_objects_option = array('title' => $lng->txt('title'), 'author' => $lng->txt('author'), 'price' => $lng->txt('price_a'));
         $o_allow_objects = new ilSelectInputGUI();
         $o_allow_objects->setTitle($lng->txt('sort_by'));
         $o_allow_objects->setOptions($allow_objects_option);
         $o_allow_objects->setValue($this->getSortField());
         $o_allow_objects->setPostVar('order_field');
         //objects_sorting_type
         $this->addFilterItem($o_allow_objects);
         $o_allow_objects->readFromSession();
         $this->filter["order_field"] = $o_allow_objects->getValue();
         $direction_option = array('asc' => $lng->txt('sort_asc'), 'desc' => $lng->txt('sort_desc'));
         $o_object_direction = new ilSelectInputGUI();
         $o_object_direction->setOptions($direction_option);
         $o_object_direction->setValue($this->getSortDirection());
         $o_object_direction->setPostVar('order_direction');
         //objects_sorting_direction
         $this->addFilterItem($o_object_direction);
         $o_object_direction->readFromSession();
         $this->filter["order_direction"] = $o_object_direction->getValue();
     }
     if ((bool) $this->settings->get('topics_allow_custom_sorting')) {
         // sorting form
         $allow_topics_option = array(ilShopTopics::TOPICS_SORT_BY_TITLE => $lng->txt('sort_topics_by_title'), ilShopTopics::TOPICS_SORT_BY_CREATEDATE => $lng->txt('sort_topics_by_date'));
         if (ANONYMOUS_USER_ID != $ilUser->getId()) {
             $allow_topics_option[ilShopTopics::TOPICS_SORT_MANUALLY] = $lng->txt('sort_topics_manually');
         }
         $o_allow_topics = new ilSelectInputGUI();
         $o_allow_topics->setTitle($lng->txt('sort_topics_by'));
         $o_allow_topics->setOptions($allow_topics_option);
         $o_allow_topics->setValue($this->getSortingTypeTopics());
         $o_allow_topics->setPostVar('topics_sorting_type');
         $this->addFilterItem($o_allow_topics);
         $o_allow_topics->readFromSession();
         $this->filter["topics_sorting_type"] = $o_allow_topics->getValue();
         $direction_option = array('asc' => $lng->txt('sort_asc'), 'desc' => $lng->txt('sort_desc'));
         $o_topics_direction = new ilSelectInputGUI();
         $o_topics_direction->setOptions($direction_option);
         $o_topics_direction->setValue($this->getSortingDirectionTopics());
         $o_topics_direction->setPostVar('topics_sorting_direction');
         //objects_sorting_type
         $this->addFilterItem($o_topics_direction);
         $o_topics_direction->readFromSession();
         $this->filter["topics_sorting_direction"] = $o_topics_direction->getValue();
     }
 }
 public function editDetails($a_show_confirm = false)
 {
     /** 
      * @var $ilToolbar ilToolbarGUI 
      */
     global $ilToolbar;
     include_once './Services/Payment/classes/class.ilPaymentSettings.php';
     /** @var $genSet ilPaymentSettings */
     $genSet = ilPaymentSettings::_getInstance();
     if (!(int) $_GET['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         return $this->showObjects();
     }
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']);
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     /** @var $tmp_obj ilObject */
     $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
     if (is_object($tmp_obj)) {
         $trash = '';
         if (ilObject::_isInTrash($this->pobject->getRefId())) {
             $trash = ' (' . $this->lng->txt('object_deleted') . ')';
         }
         $tmp_object['title'] = $tmp_obj->getTitle() . '' . $trash;
         $tmp_object['type'] = $tmp_obj->getType();
     } else {
         $tmp_object['title'] = $this->lng->txt('object_not_found');
         $tmp_object['type'] = false;
     }
     if ($a_show_confirm) {
         include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
         $oConfirmationGUI = new ilConfirmationGUI();
         // set confirm/cancel commands
         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performDelete"));
         $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_object"));
         $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editDetails");
         $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDelete");
         $oConfirmationGUI->addItem('', $tmp_object['title'], $tmp_object['title']);
         $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
         return true;
     }
     $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
     $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
     $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit'));
     include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $oForm = new ilPropertyFormGUI();
     $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
     $oForm->setTitle($tmp_object['title']);
     if ($tmp_object['type']) {
         $oForm->setTitleIcon(ilUtil::getImagePath('icon_' . $tmp_object['type'] . '_b.png'));
     }
     // repository path
     $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path'));
     $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId()));
     $oForm->addItem($oPathGUI);
     switch ($tmp_object['type']) {
         case 'exc':
             $exc_subtype_option = array();
             $check_subtypes = ilPaymentObject::_checkExcSubtype($this->pobject->getRefId());
             if (!in_array('download', $check_subtypes) || $this->pobject->getSubtype() == 'download') {
                 $exc_subtype_option['download'] = $this->lng->txt('download');
             }
             if (!in_array('upload', $check_subtypes) || $this->pobject->getSubtype() == 'upload') {
                 $exc_subtype_option['upload'] = $this->lng->txt('upload');
             }
             $oExcSubtype = new ilSelectInputGUI($this->lng->txt('select_subtype'), 'exc_subtype');
             $oExcSubtype->setOptions($exc_subtype_option);
             $oExcSubtype->setValue($this->pobject->getSubtype());
             $oForm->addItem($oExcSubtype);
             break;
         default:
             break;
     }
     // number of purchasers
     $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
     $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
     $oForm->addItem($oPurchasersGUI);
     // vendors
     $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
     $oVendorsGUI->setOptions($this->__getVendors());
     $oVendorsGUI->setValue($this->pobject->getVendorId());
     $oForm->addItem($oVendorsGUI);
     // status
     $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status');
     $oStatusGUI->setOptions($this->__getStatus());
     $oStatusGUI->setValue($this->pobject->getStatus());
     $oForm->addItem($oStatusGUI);
     // pay methods
     $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
     $PMoptions = ilPaymethods::getPayMethodsOptions('not_specified');
     $oPayMethodsGUI->setOptions($PMoptions);
     $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
     $oForm->addItem($oPayMethodsGUI);
     // topics
     /** @var $shopTopicsObj ilShopTopics */
     $shopTopicsObj = ilShopTopics::_getInstance();
     $shopTopicsObj->read();
     if (is_array($topics = $shopTopicsObj->getTopics()) && count($topics)) {
         $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id');
         include_once 'Services/Payment/classes/class.ilShopTopics.php';
         /** @var $shopTopicsObj ilShopTopics */
         $shopTopicsObj = ilShopTopics::_getInstance();
         $shopTopicsObj->read();
         $topic_options = array();
         $topic_options[''] = $this->lng->txt('please_choose');
         /** @var $oTopic ilShopTopic */
         foreach ($topics as $oTopic) {
             $topic_options[$oTopic->getId()] = $oTopic->getTitle();
         }
         $oTopicsGUI->setOptions($topic_options);
         $oTopicsGUI->setValue($this->pobject->getTopicId());
         $oForm->addItem($oTopicsGUI);
     }
     // vats
     $oShopVatsList = new ilShopVatsList();
     $oShopVatsList->read();
     if ($oShopVatsList->hasItems()) {
         $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id');
         $vats_options = array();
         /** @var $oVAT ilShopVats */
         foreach ($oShopVatsList as $oVAT) {
             $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()) . ' -> ' . $oVAT->getTitle();
         }
         $oVatsGUI->setOptions($vats_options);
         $oVatsGUI->setValue($this->pobject->getVatId());
         $oForm->addItem($oVatsGUI);
     } else {
         $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate'));
         $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned'));
         $oForm->addItem($oVatsGUI);
     }
     $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
     $oFile = new ilFileDataShop($this->pobject->getPobjectId());
     if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) {
         $oThumbnail->setImage($webpath_file);
     }
     $oForm->addItem($oThumbnail);
     if ($genSet->get('use_shop_specials')) {
         // special object
         $oSpecial = new ilCheckboxInputGUI($this->lng->txt('special'), 'is_special');
         $oSpecial->setChecked((int) $this->pobject->getSpecial());
         $oSpecial->setInfo($this->lng->txt('special_info'));
         $oForm->addItem($oSpecial);
     }
     // buttons
     $oForm->addCommandButton('updateDetails', $this->lng->txt('save'));
     $oForm->addCommandButton('deleteObject', $this->lng->txt('delete'));
     $this->tpl->setVariable('FORM', $oForm->getHTML());
     return true;
 }
 public function showTopicsList()
 {
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     if ($this->ask_for_deletion) {
         include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
         $c_gui = new ilConfirmationGUI();
         $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteTopic'));
         $c_gui->setHeaderText($this->lng->txt('sure_delete_topics'));
         $c_gui->setCancel($this->lng->txt('cancel'), 'showTopicsList');
         $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteTopic');
         foreach ($_POST['topic_id'] as $topic_id) {
             $c_gui->addItem('topic_id[]', $topic_id, ilShopTopic::_lookupTitle($topic_id));
         }
         $this->tpl->setVariable('CONFIRMATION', $c_gui->getHTML());
         return true;
     }
     include_once 'Services/Payment/classes/class.ilShopTopicsTableGUI.php';
     $table_gui = new ilShopTopicsTableGUI($this, 'showTopicsList');
     $table_gui->setTitle($this->lng->txt('topics'));
     ilShopTopics::_getInstance()->setSortingType(ilShopTopics::TOPICS_SORT_MANUALLY);
     ilShopTopics::_getInstance()->setSortingDirection('ASC');
     ilShopTopics::_getInstance()->read();
     $table_gui->parseRecords(ilShopTopics::_getInstance()->getTopics());
     $table_gui->addCommandButton('showTopicForm', $this->lng->txt('add'));
     $table_gui->addCommandButton('saveSorting', $this->lng->txt('pay_save_sorting'));
     $this->tpl->setVariable('TABLE', $table_gui->getHTML());
     return true;
 }
 public function showForm($result = null)
 {
     global $ilUser;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.shop_advanced_search.html', 'Services/Payment');
     $this->tpl->setVariable('TBL_TITLE', $this->lng->txt('advanced_search'));
     $this->tpl->setVariable('SEARCH_ACTION', $this->ctrl->getFormAction($this));
     $this->tpl->setVariable('TXT_SEARCHTERM', $this->lng->txt('search_search_term'));
     $this->tpl->setVariable('TXT_AND', $this->lng->txt('search_all_words'));
     $this->tpl->setVariable('TXT_OR', $this->lng->txt('search_any_word'));
     $this->tpl->setVariable('TXT_OBJECT_TYPE', $this->lng->txt('obj_type'));
     $this->tpl->setVariable('TXT_TOPIC', $this->lng->txt('topic'));
     $this->tpl->setVariable('BTN_SEARCH', $this->lng->txt('search'));
     $this->tpl->setVariable('FORM_SEARCH_STR', ilUtil::prepareFormOutput($this->getString(), true));
     if ($this->getCombination() == self::SEARCH_AND) {
         $this->tpl->setVariable('AND_CHECKED', 'checked="checked"');
     } else {
         $this->tpl->setVariable('OR_CHECKED', 'checked="checked"');
     }
     $this->tpl->setVariable('CRS', $this->lng->txt('courses'));
     $this->tpl->setVariable('LMS', $this->lng->txt('learning_resources'));
     $this->tpl->setVariable('TST', $this->lng->txt('tests'));
     $this->tpl->setVariable('FIL', $this->lng->txt('objs_file'));
     $details = $this->getDetails();
     $this->tpl->setVariable('CHECK_CRS', ilUtil::formCheckbox($details['crs'] ? 1 : 0, 'search[details][crs]', 1));
     $this->tpl->setVariable('CHECK_LMS', ilUtil::formCheckbox($details['lms'] ? 1 : 0, 'search[details][lms]', 1));
     $this->tpl->setVariable('CHECK_TST', ilUtil::formCheckbox($details['tst'] ? 1 : 0, 'search[details][tst]', 1));
     $this->tpl->setVariable('CHECK_FIL', ilUtil::formCheckbox($details['fil'] ? 1 : 0, 'search[details][fil]', 1));
     $selectable_topics = array();
     $selectable_topics[''] = $this->lng->txt('search_any');
     ilShopTopics::_getInstance()->setIdFilter(false);
     ilShopTopics::_getInstance()->read();
     foreach (ilShopTopics::_getInstance()->getTopics() as $oTopic) {
         $selectable_topics[$oTopic->getId()] = $oTopic->getTitle();
     }
     $this->tpl->setVariable('SELECT_TOPIC', ilUtil::formSelect(array($this->getTopicId()), 'search[topic]', $selectable_topics, false, true));
     // show results
     if (count($result->getResults())) {
         include_once 'Services/Payment/classes/class.ilShopResultPresentationGUI.php';
         $search_result_presentation = new ilShopResultPresentationGUI($result);
         $this->tpl->setVariable('RESULTS', $search_result_presentation->showResults());
         $objects = (bool) $this->oGeneralSettings->get('objects_allow_custom_sorting');
         $topics = (bool) $this->oGeneralSettings->get('topics_allow_custom_sorting');
         if ($objects) {
             $this->tpl->setCurrentBlock('objects_sort_block');
             $order_fields = array('title' => $this->lng->txt('title'), 'author' => $this->lng->txt('author'), 'price' => $this->lng->txt('price_a'));
             foreach ($order_fields as $key => $value) {
                 $this->tpl->setCurrentBlock('order_field');
                 $this->tpl->setVariable('ORDER_FIELD_VALUE', $key);
                 $this->tpl->setVariable('ORDER_FIELD_TEXT', $value);
                 if (strcmp(trim($this->getSortField()), $key) == 0) {
                     $this->tpl->setVariable('ORDER_FIELD_SELECTED', ' selected="selected"');
                 }
                 $this->tpl->parseCurrentBlock();
             }
             $this->tpl->setVariable('SORT_BY_TEXT', $this->lng->txt('sort_by'));
             $this->tpl->setVariable('ASCENDING_TEXT', $this->lng->txt('sort_asc'));
             $this->tpl->setVariable('DESCENDING_TEXT', $this->lng->txt('sort_desc'));
             $this->tpl->setVariable('ORDER_DIRECTION_' . strtoupper(trim($this->getSortDirection())) . '_SELECTED', " selected=\"selected\"");
             $this->tpl->parseCurrentBlock();
         }
         if ($topics) {
             $this->tpl->setCurrentBlock('topics_sort_block');
             $this->tpl->setVariable('SORT_TOPICS_BY_TEXT', $this->lng->txt('sort_topics_by'));
             $this->tpl->setVariable('SORTING_TYPE_BY_TITLE', ilShopTopics::TOPICS_SORT_BY_TITLE);
             $this->tpl->setVariable('SORTING_TYPE_BY_TITLE_TEXT', $this->lng->txt('sort_topics_by_title'));
             if ($this->getSortingTypeTopics() == ilShopTopics::TOPICS_SORT_BY_TITLE) {
                 $this->tpl->setVariable('SORTING_TYPE_BY_TITLE_SELECTED', ' selected="selected"');
             }
             $this->tpl->setVariable('SORTING_TYPE_BY_DATE', ilShopTopics::TOPICS_SORT_BY_CREATEDATE);
             $this->tpl->setVariable('SORTING_TYPE_BY_DATE_TEXT', $this->lng->txt('sort_topics_by_date'));
             if ($this->getSortingTypeTopics() == ilShopTopics::TOPICS_SORT_BY_CREATEDATE) {
                 $this->tpl->setVariable('SORTING_TYPE_BY_DATE_SELECTED', ' selected="selected"');
             }
             if (ANONYMOUS_USER_ID != $ilUser->getId()) {
                 $this->tpl->setCurrentBlock('sort_manually');
                 $this->tpl->setVariable('SORTING_TYPE_MANUALLY', ilShopTopics::TOPICS_SORT_MANUALLY);
                 $this->tpl->setVariable('SORTING_TYPE_MANUALLY_TEXT', $this->lng->txt('sort_topics_manually'));
                 if ($this->getSortingTypeTopics() == ilShopTopics::TOPICS_SORT_MANUALLY) {
                     $this->tpl->setVariable('SORTING_TYPE_MANUALLY_SELECTED', ' selected="selected"');
                 }
                 $this->tpl->parseCurrentBlock();
             }
             $this->tpl->setVariable('SORTING_DIRECTION_ASCENDING_TEXT', $this->lng->txt('sort_asc'));
             $this->tpl->setVariable('SORTING_DIRECTION_DESCENDING_TEXT', $this->lng->txt('sort_desc'));
             if (in_array(strtoupper($this->getSortingDirectionTopics()), array('ASC', 'DESC'))) {
                 $this->tpl->setVariable('SORTING_DIRECTION_' . strtoupper($this->getSortingDirectionTopics()) . '_SELECTED', ' selected="selected"');
             } else {
                 $this->tpl->setVariable('SORTING_DIRECTION_' . strtoupper(ilShopTopics::DEFAULT_SORTING_DIRECTION) . '_SELECTED', ' selected="selected"');
             }
             $this->tpl->parseCurrentBlock();
         }
         if ($objects || $topics) {
             $this->tpl->setCurrentBlock('sort_button');
             $this->tpl->setVariable('SORTING_FORM_ACTION', $this->ctrl->getFormAction($this, 'setSorting'));
             $this->tpl->setVariable('CMD_SORT', 'setSorting');
             $this->tpl->setVariable('SORT_TEXT', $this->lng->txt('sort'));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('sorting');
         $this->tpl->parseCurrentBlock();
     }
     $this->addPager($result, 'shop_advanced_search_maxpage');
     return true;
 }