function smartyImageResize($params, &$smarty) { $path = @$params['path']; $name = @$params['name']; $height = @$params['height']; $width = @$params['width']; $customPath = @$params['customPath']; $method = isset($params['method']) ? $params['method'] : PstImage::METHOD_RESIZE; if ($customPath) { return PstImage::cacheResizeCustomPath($path, $name, $height, $width, $method); } else { return PstImage::cacheResize($path, $name, $height, $width, $method); } }
/** * function render form of your module configuration * @return string */ public function renderPstConfiForm() { // $fields_form = array( // 'form' => array( // 'legend' => array( // 'title' => $this->l('Settings') . ' ' . $this->displayName, // 'icon' => 'icon-cogs' // ), // 'input' => array(), // 'submit' => array( // 'title' => $this->l('Save') // ) // ) // ); $field_types = $this->getPstFieldTypes(); $fieldset_list = array(); $is_multi_lang = false; foreach ($this->getPstConfig() as $key => $fieldset_data) { $fieldset = array('tinymce' => true, 'legend' => array('title' => $fieldset_data['label'], 'icon' => 'icon-cogs'), 'input' => array()); foreach ($fieldset_data['fields'] as $field_name => $data) { if (!isset($data['type'])) { throw new PrestaShopException('Type is not define : ' . $data['type']); } if (!isset($field_types[$data['type']])) { throw new PrestaShopException('Type is unknow : ' . $data['type']); } $type_option = $field_types[$data['type']]; $field = array('type' => $type_option['form_type'], 'name' => strtolower($field_name), 'class' => 't'); if (isset($type_option['is_bool']) && $type_option['is_bool']) { $field['is_bool'] = true; $field['values'] = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))); } if (isset($type_option['rte']) && $type_option['rte']) { $field['autoload_rte'] = true; $field['rows'] = 5; $field['cols'] = 40; $field['hint'] = $this->l('Invalid characters:') . ' <>;=#{}'; } if (isset($type_option['is_multi_lang']) && $type_option['is_multi_lang']) { $field['lang'] = true; $is_multi_lang = true; } if (isset($data['required']) && $data['required']) { $field['required'] = true; } if (isset($data['desc']) && !empty($data['desc'])) { $field['desc'] = $this->l($data['desc']); } if (isset($data['label']) && !empty($data['label'])) { $field['label'] = $this->l($data['label']); } $fieldset['input'][] = $field; switch ($data['type']) { case 'image': case 'image_ml': foreach (Language::getLanguages() as $lang) { $iso_code = $lang['iso_code']; $ext = 'jpg'; $image = file_exists(_PS_IMG_DIR_ . '/' . $this->module_name . '/config/' . strtolower($field_name) . '/' . $iso_code . '.jpg'); if (!$image) { $ext = 'png'; $image = file_exists(_PS_IMG_DIR_ . '/' . $this->module_name . '/config/' . strtolower($field_name) . '/' . $iso_code . '.png'); } $image_size = $image_url = false; if ($image) { $image_url = PstImage::cacheResizeCustomPath('/img/' . $this->module_name . '/config/' . strtolower($field_name) . '/', $iso_code . '.' . $ext, 150, 150); $image_url = $image ? '<img src="' . $image_url . '" />' : false; $image_size = filesize(_PS_IMG_DIR_ . '/' . $this->module_name . '/config/' . strtolower($field_name) . '/' . $iso_code . '.' . $ext) / 1000; } $fieldset['input'][] = array('type' => 'file', 'label' => $this->l($data['label']) . ' ' . $iso_code . ':', 'name' => $field_name . '_' . $iso_code, 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&token=' . $this->token . '&forcedeleteImage=1&name=' . $field_name); } break; } } $fieldset_list[] = array('form' => $fieldset); } $this->lang = $is_multi_lang; $helper = new HelperForm(); $fieldset_list[count($fieldset_list) - 1]['form']['submit'] = array('name' => $helper->submit_action, 'title' => $this->l('Save')); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $this->fields_form = array(); $helper->identifier = $this->identifier; $helper->submit_action = 'submitPstModuleConfig'; // $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); return $helper->generateForm($fieldset_list); }