Exemplo n.º 1
0
 private function _getForm()
 {
     $view = new AView($this->registry, 0);
     $view->batchAssign($this->language->getASet('tool/rl_manager'));
     $view->assign('error_warning', $this->error['warning']);
     $view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->data = array();
     $this->data['error'] = $this->error;
     $rm = new AResourceManager();
     if (isset($this->request->get['rl_type'])) {
         $type_data = $rm->getResourceTypeByName($this->request->get['rl_type']);
     }
     $fields = array('type_id', 'type_name', 'default_directory', 'default_icon', 'file_types', 'access_type');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
         } elseif (isset($type_data)) {
             $this->data[$f] = $type_data[$f];
         } else {
             $this->data[$f] = '';
         }
     }
     if (!isset($this->data['type_id'])) {
         return null;
     } else {
         $this->data['action'] = $this->html->getSecureURL('r/tool/rl_manager/save', '&rl_type=' . $this->data['type_name']);
         $this->data['heading_title'] = $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['type_name'] . ' ' . $this->language->get('text_rl_type');
         $form = new AForm('ST');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: '));
     $form->setForm(array('form_name' => 'rl_typeFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'rl_typeFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'rl_typeFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true"  class="aform form-horizontal"')) . ($this->data['form']['fields']['type_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'type_id', 'value' => $this->data['type_id'])));
     $this->data['form']['fields']['type_name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'type_name', 'value' => $this->data['type_name'], 'style' => 'tiny-field', 'attr' => 'readonly'));
     $this->data['form']['fields']['default_icon'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'default_icon', 'value' => $this->data['default_icon'], 'style' => 'small-field'));
     $this->data['form']['fields']['default_directory'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'default_directory', 'value' => $this->data['default_directory'], 'style' => 'small-field', 'attr' => 'readonly'));
     $this->data['form']['fields']['file_types'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'file_types', 'value' => $this->data['file_types'], 'style' => 'small-field'));
     $this->data['button_save'] = $this->language->get('button_save');
     $this->data['button_close'] = $this->language->get('button_close');
     $this->data['button_save_and_close'] = $this->language->get('button_save_and_close');
     $view->assign('help_url', $this->gen_help_url('resource_library_types'));
     $view->batchAssign($this->data);
     $this->data['response'] = $view->fetch('responses/tool/rl_types_form.tpl');
     $this->response->setOutput($this->data['response']);
 }
 private function _common()
 {
     $rm = new AResourceManager();
     if ($this->request->get['mode'] == 'single') {
         $this->data['types'] = array($rm->getResourceTypeByName($this->request->get['type']));
     } else {
         $this->data['types'] = isset($this->session->data['rl_types']) ? $this->session->data['rl_types'] : $rm->getResourceTypes();
     }
     $this->data['type'] = $this->request->get['type'];
     if (($this->data['type'] == 'undefined' || empty($this->data['type'])) && $this->request->post_or_get('resource_id')) {
         $info = $rm->getResource($this->request->post_or_get('resource_id'), $this->language->getContentLanguageID());
         $this->data['type'] = $info['type_name'];
     } elseif ($this->data['type'] == 'undefined' || empty($this->data['type'])) {
         $this->data['type'] = is_array($this->data['types']) ? (string) $this->data['types'][0] : $this->data['types'];
     }
     $this->data['object_name'] = $this->data['name'] = (string) $this->request->get['object_name'];
     $this->data['object_id'] = $this->request->get['object_id'];
     $this->data['object_title'] = $this->request->get['object_title'];
     if ($this->data['object_title']) {
         $this->data['object_title'] = mb_substr($this->data['object_title'], 0, 60);
     } else {
         $this->data['object_title'] = mb_substr($this->_getObjectTitle($this->data['object_name'], $this->data['object_id']), 0, 60);
     }
     //search form
     $form = new AForm('HS');
     $this->data['search_form'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'rlsearchform', 'action' => ''));
     $this->data['search_field_input'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'search', 'value' => $this->request->get['keyword'], 'placeholder' => $this->language->get('text_search'), 'icon' => 'icon-search'));
     $rm->setType($this->data['type']);
     $options = array();
     foreach ($this->data['types'] as $type) {
         $options[$type['type_name']] = $type['type_name'];
     }
     $this->data['rl_types'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'rl_types', 'placeholder' => $this->language->get('text_type'), 'options' => $options, 'value' => $this->data['type']));
     $this->data['languages'] = array();
     $result = $this->language->getAvailableLanguages();
     foreach ($result as $lang) {
         $this->data['languages'][$lang['language_id']] = $lang;
         $languages[$lang['language_id']] = $lang['name'];
     }
     $this->data['language'] = $this->html->buildSelectbox(array('id' => 'language_id', 'name' => 'language_id', 'options' => $languages, 'value' => $language_id));
 }
Exemplo n.º 3
0
 /**
  * @return null | void
  */
 public function add()
 {
     if (!$this->user->canModify('common/resource_library')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true));
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if ($this->request->is_POST()) {
         return $this->add_code();
     }
     $this->data['languages'] = array();
     $result = $this->language->getAvailableLanguages();
     foreach ($result as $lang) {
         $this->data['languages'][$lang['language_id']] = $lang;
     }
     $rm = new AResourceManager();
     if ($this->request->get['mode'] == 'single') {
         $this->data['types'] = array($rm->getResourceTypeByName($this->request->get['type']));
     } else {
         $this->data['types'] = $this->session->data['rl_types'] ? $this->session->data['rl_types'] : $rm->getResourceTypes();
     }
     if (!$this->data['types']) {
         $error = new AError('');
         return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => 'Incorrect resource library type list!', 'reset_value' => true));
     }
     $this->data['type'] = $this->request->get['type'];
     $this->data['wrapper_id'] = $this->request->get['wrapper_id'] ? $this->request->get['wrapper_id'] : false;
     $this->data['field_id'] = $this->request->get['field_id'] ? $this->request->get['field_id'] : false;
     $this->data['language_id'] = $this->config->get('storefront_language_id');
     $this->data['image_width'] = $this->config->get('config_image_grid_width');
     $this->data['image_height'] = $this->config->get('config_image_grid_height');
     $params = '&mode=' . $this->request->get['mode'] . '&type=' . $this->request->get['type'] . '&object_name=' . $this->request->get['object_name'] . '&object_id=' . $this->request->get['object_id'];
     $this->data['rl_add_code'] = $this->html->getSecureURL('common/resource_library/add_code', $params);
     $this->data['rl_get_info'] = $this->html->getSecureURL('common/resource_library/get_resource_details');
     $this->data['rl_upload'] = $this->html->getSecureURL('common/resource_library/upload', $params);
     if ((int) ini_get('post_max_size') <= 2) {
         // because 2Mb is default value for php
         $this->data['attention'] = sprintf($this->language->get('error_file size'), ini_get('post_max_size'));
     }
     $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
     $this->view->assign('help_url', $this->gen_help_url('global_attributes_listing'));
     $this->_buildForm();
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/common/resource_library_add.tpl');
 }