public function renderForm() { // loads current warehouse if (!($obj = $this->loadObject(true))) { return; } $image = _PS_SUPP_IMG_DIR_ . $obj->id . '.jpg'; $image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $tmp_addr = new Address(); $res = $tmp_addr->getFieldsRequiredDatabase(); $required_fields = array(); foreach ($res as $row) { $required_fields[(int) $row['id_required_field']] = $row['field_name']; } $this->fields_form = array('legend' => array('title' => $this->l('Suppliers'), 'icon' => 'icon-truck'), 'input' => array(array('type' => 'hidden', 'name' => 'id_address'), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => true, 'col' => 4, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), in_array('company', $required_fields) ? array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company', 'display' => in_array('company', $required_fields), 'required' => in_array('company', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Company name for this supplier')) : null, array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'hint' => array($this->l('Invalid characters:') . ' <>;=#{}', $this->l('Will appear in the list of suppliers.')), 'autoload_rte' => 'rte'), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone', 'required' => in_array('phone', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Phone number for this supplier')), array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'required' => in_array('phone_mobile', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Mobile phone number for this supplier.')), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address', 'maxlength' => 128, 'col' => 6, 'required' => true), array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'required' => in_array('address2', $required_fields), 'col' => 6, 'maxlength' => 128), array('type' => 'text', 'label' => $this->l('Zip/postal code'), 'name' => 'postcode', 'required' => in_array('postcode', $required_fields), 'maxlength' => 12, 'col' => 2), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'maxlength' => 32, 'col' => 4, 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'col' => 4, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id, false), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'col' => 4, 'options' => array('id' => 'id_state', 'query' => array(), 'name' => 'name')), array('type' => 'file', 'label' => $this->l('Logo'), 'name' => 'logo', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Upload a supplier logo from your computer.')), array('type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'col' => 6, 'hint' => array($this->l('To add "tags" click in the field, write something and then press "Enter".'), $this->l('Forbidden characters:') . ' <>;=#{}')), array('type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'))); // loads current address for this supplier - if possible $address = null; if (isset($obj->id)) { $id_address = Address::getAddressIdBySupplierId($obj->id); if ($id_address > 0) { $address = new Address((int) $id_address); } } // force specific fields values (address) if ($address != null) { $this->fields_value = array('id_address' => $address->id, 'phone' => $address->phone, 'phone_mobile' => $address->phone_mobile, 'address' => $address->address1, 'address2' => $address->address2, 'postcode' => $address->postcode, 'city' => $address->city, 'id_country' => $address->id_country, 'id_state' => $address->id_state); } else { $this->fields_value = array('id_address' => 0, 'id_country' => Configuration::get('PS_COUNTRY_DEFAULT')); } if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso'); } return parent::renderForm(); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_DELIVERY')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier)); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
public function renderForm() { if (!($obj = $this->loadObject(true))) { return; } $image = _PS_STORE_IMG_DIR_ . $obj->id . '.jpg'; $image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $tmp_addr = new Address(); $res = $tmp_addr->getFieldsRequiredDatabase(); $required_fields = array(); foreach ($res as $row) { $required_fields[(int) $row['id_required_field']] = $row['field_name']; } $this->fields_form = array('legend' => array('title' => $this->l('Stores'), 'icon' => 'icon-home'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => false, 'hint' => array($this->l('Store name (e.g. City Center Mall Store).'), $this->l('Allowed characters: letters, spaces and %s'))), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'required' => true), array('type' => 'text', 'label' => $this->l('Address (2)'), 'name' => 'address2'), array('type' => 'text', 'label' => $this->l('Zip/postal Code'), 'name' => 'postcode', 'required' => in_array('postcode', $required_fields)), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => true, 'options' => array('id' => 'id_state', 'name' => 'name', 'query' => null)), array('type' => 'latitude', 'label' => $this->l('Latitude / Longitude'), 'name' => 'latitude', 'required' => true, 'maxlength' => 12, 'hint' => $this->l('Store coordinates (e.g. 45.265469/-47.226478).')), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone'), array('type' => 'text', 'label' => $this->l('Fax'), 'name' => 'fax'), array('type' => 'text', 'label' => $this->l('Email address'), 'name' => 'email'), array('type' => 'textarea', 'label' => $this->l('Note'), 'name' => 'note', 'cols' => 42, 'rows' => 4), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Whether or not to display this store.')), array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Storefront picture.'))), 'hours' => array(), 'submit' => array('title' => $this->l('Save'))); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso'); } $days = array(); $days[1] = $this->l('Monday'); $days[2] = $this->l('Tuesday'); $days[3] = $this->l('Wednesday'); $days[4] = $this->l('Thursday'); $days[5] = $this->l('Friday'); $days[6] = $this->l('Saturday'); $days[7] = $this->l('Sunday'); $hours = $this->getFieldValue($obj, 'hours'); if (!empty($hours)) { $hours_unserialized = Tools::unSerialize($hours); } $this->fields_value = array('latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'), 'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'), 'days' => $days, 'hours' => isset($hours_unserialized) ? $hours_unserialized : false); return parent::renderForm(); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $invoice_address = new Address((int) $this->order->id_address_invoice); $country = new Country((int) $invoice_address->id_country); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_INVOICE')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $data = array('order' => $this->order, 'order_details' => $order_details, 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer); if (Tools::getValue('debug')) { die(json_encode($data)); } $this->smarty->assign($data); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); }
public function renderForm() { // loads current warehouse if (!($obj = $this->loadObject(true))) { return; } $this->fields_form = array('legend' => array('title' => $this->l('Suppliers'), 'image' => '../img/admin/suppliers.gif'), 'input' => array(array('type' => 'hidden', 'name' => 'id_address'), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'size' => 40, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'cols' => 60, 'rows' => 10, 'lang' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Will appear in the supplier list')), array('type' => 'text', 'label' => $this->l('Phone:'), 'name' => 'phone', 'size' => 15, 'maxlength' => 16, 'desc' => $this->l('Phone number for this supplier')), array('type' => 'text', 'label' => $this->l('Address:'), 'name' => 'address', 'size' => 100, 'maxlength' => 128, 'required' => true), array('type' => 'text', 'label' => $this->l('Address:') . ' (2)', 'name' => 'address2', 'size' => 100, 'maxlength' => 128), array('type' => 'text', 'label' => $this->l('Postal Code/Zip Code:'), 'name' => 'postcode', 'size' => 10, 'maxlength' => 12, 'required' => true), array('type' => 'text', 'label' => $this->l('City:'), 'name' => 'city', 'size' => 20, 'maxlength' => 32, 'required' => true), array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id, false), 'id' => 'id_country', 'name' => 'name'), 'desc' => $this->l('Country where the state, region or city is located')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'options' => array('id' => 'id_state', 'query' => array(), 'name' => 'name')), array('type' => 'file', 'label' => $this->l('Logo:'), 'name' => 'logo', 'display_image' => true, 'desc' => $this->l('Upload a supplier logo from your computer')), array('type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description:'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords:'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}', 'desc' => $this->l('To add "tags" click in the field, write something and then press "Enter"')), array('type' => 'radio', 'label' => $this->l('Enable:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button')); // loads current address for this supplier - if possible $address = null; if (isset($obj->id)) { $id_address = Address::getAddressIdBySupplierId($obj->id); if ($id_address > 0) { $address = new Address((int) $id_address); } } // force specific fields values (address) if ($address != null) { $this->fields_value = array('id_address' => $address->id, 'phone' => $address->phone, 'address' => $address->address1, 'address2' => $address->address2, 'postcode' => $address->postcode, 'city' => $address->city, 'id_country' => $address->id_country, 'id_state' => $address->id_state); } else { $this->fields_value = array('id_address' => 0, 'id_country' => Configuration::get('PS_COUNTRY_DEFAULT')); } if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso'); } // set logo image $image = ImageManager::thumbnail(_PS_SUPP_IMG_DIR_ . '/' . $this->object->id . '.jpg', $this->table . '_' . (int) $this->object->id . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value['image'] = $image ? $image : false; $this->fields_value['size'] = $image ? filesize(_PS_SUPP_IMG_DIR_ . '/' . $this->object->id . '.jpg') / 1000 : false; return parent::renderForm(); }
/** * Returns the template's HTML content * * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_DELIVERY')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $path = _PS_PROD_IMG_DIR_ . $order_detail['image']->getExistingImgPath() . '.jpg'; $order_detail['image_tag'] = preg_replace('/\\.*' . preg_quote(__PS_BASE_URI__, '/') . '/', _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, ImageManager::thumbnail($path, $name, 45, 'jpg', false), 1); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier, 'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY'))); $tpls = array('style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab'))); $this->smarty->assign($tpls); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
public function renderForm() { /** @var Shop $obj */ if (!($obj = $this->loadObject(true))) { return; } $image = _PS_CITY_IMG_DIR_ . $obj->id . '.jpg'; $image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $this->fields_form = array('legend' => array('title' => $this->l('Città'), 'icon' => 'icon-globe'), 'input' => array(array('type' => 'text', 'label' => $this->l('Nome'), 'name' => 'name', 'maxlength' => 255, 'lang' => true, 'required' => true, 'hint' => $this->l('Indica il nome della città.')), array('type' => 'text', 'label' => $this->l('Codice ISTAT'), 'name' => 'iso_code', 'maxlength' => 255, 'required' => true, 'class' => 'uppercase', 'hint' => $this->l('Inserisci il codice alfanumerico ISTAT.')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) Context::getContext()->country->id, 'options' => array('query' => Country::getCountries(Context::getContext()->language->id, false, true), 'id' => 'id_country', 'name' => 'name'), 'hint' => $this->l('Nazione della città.')), array('type' => 'text', 'label' => $this->l('Link rewrite'), 'name' => 'link_rewrite', 'maxlength' => 255, 'lang' => true, 'required' => true, 'havingFilter' => 'url', 'hint' => $this->l('URL della città.')), array('type' => 'file', 'label' => $this->l('Immagine'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Storefront picture.')), array('type' => 'text', 'label' => $this->l('Legend'), 'name' => 'legend', 'maxlength' => 255, 'lang' => true, 'required' => true, 'hint' => $this->l("Didascalia dell'immagine"))), 'submit' => array('title' => $this->l('Save'))); return parent::renderForm(); }
public function ajaxProcessuploadThumbnailImages() { $category = new Category((int) Tools::getValue('id_category')); if (isset($_FILES['thumbnail'])) { //Get total of image already present in directory $files = scandir(_PS_CAT_IMG_DIR_); $assigned_keys = array(); $allowed_keys = array(0, 1, 2); foreach ($files as $file) { $matches = array(); if (preg_match('/' . $category->id . '-([0-9])?_thumb.jpg/i', $file, $matches) === 1) { $assigned_keys[] = (int) $matches[1]; } } $available_keys = array_diff($allowed_keys, $assigned_keys); $helper = new HelperImageUploader('thumbnail'); $files = $helper->process(); $total_errors = array(); if (count($available_keys) < count($files)) { $total_errors[] = sprintf(Tools::displayError('You cannot upload more than %s files'), count($available_keys)); die; } foreach ($files as $key => &$file) { $id = array_shift($available_keys); $errors = array(); // Evaluate the memory required to resize the image: if it's too much, you can't resize it. if (!ImageManager::checkImageMemoryLimit($file['save_path'])) { $errors[] = Tools::displayError('Due to memory limit restrictions, this image cannot be loaded. Please increase your memory_limit value via your server\'s configuration settings. '); } // Copy new image if (empty($errors) && !ImageManager::resize($file['save_path'], _PS_CAT_IMG_DIR_ . (int) Tools::getValue('id_category') . '-' . $id . '_thumb.jpg')) { $errors[] = Tools::displayError('An error occurred while uploading the image.'); } if (count($errors)) { $total_errors = array_merge($total_errors, $errors); } unlink($file['save_path']); //Necesary to prevent hacking unset($file['save_path']); //Add image preview and delete url $file['image'] = ImageManager::thumbnail(_PS_CAT_IMG_DIR_ . (int) $category->id . '-' . $id . '_thumb.jpg', $this->context->controller->table . '_' . (int) $category->id . '-' . $id . '_thumb.jpg', 100, 'jpg', true, true); $file['delete_url'] = Context::getContext()->link->getAdminLink('AdminBlockCategories') . '&deleteThumb=' . $id . '&id_category=' . (int) $category->id . '&updatecategory'; } if (count($total_errors)) { $this->context->controller->errors = array_merge($this->context->controller->errors, $total_errors); } else { Tools::clearSmartyCache(); } die(Tools::jsonEncode(array('thumbnail' => $files))); } }
/** * Old legacy way to generate a thumbnail. * * Use it upon a new Image management system is available. * * @param $imageId * @param string $imageType * @param string $tableName * @param string $imageDir * @return string The HTML < img > tag */ public function getThumbnailForListing($imageId, $imageType = 'jpg', $tableName = 'product', $imageDir = 'p') { if ($tableName == 'product') { $image = new \Image($imageId); $path_to_image = _PS_IMG_DIR_ . $imageDir . '/' . $image->getExistingImgPath() . '.' . $imageType; } else { $path_to_image = _PS_IMG_DIR_ . $imageDir . '/' . $imageId . '.' . $imageType; } $thumbPath = \ImageManager::thumbnail($path_to_image, $tableName . '_mini_' . $imageId . '.' . $imageType, 45, $imageType); // because legacy uses relative path to reach a directory under root directory... $replacement = 'src="' . $this->legacyContext->getRootUrl(); $thumbPath = preg_replace('/src="(\\.\\.\\/)+/', $replacement, $thumbPath); return $thumbPath; }
public function renderForm() { $this->toolbar_btn['save-and-stay'] = array('href' => '#', 'desc' => $this->l('Save and stay')); $defaultLanguage = $this->default_form_language; $this->initToolbar(); if (!$this->loadObject(true)) { return; } $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Photo'), 'image' => '../img/admin/tab-categories.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Title:'), 'name' => 'name', 'required' => true, 'lang' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta Title:'), 'name' => 'meta_title', 'lang' => true, 'class' => '', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta Keword:'), 'name' => 'meta_keywords', 'lang' => true, 'class' => '', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'textarea', 'label' => $this->l('Meta Description :'), 'name' => 'meta_description', 'autoload_rte' => true, 'rows' => 10, 'cols' => 100, 'lang' => true, 'desc' => $this->l('Will be displayed in top of category page')), array('type' => 'textarea', 'label' => $this->l('Description :'), 'name' => 'description', 'autoload_rte' => true, 'rows' => 10, 'cols' => 100, 'lang' => true, 'desc' => $this->l('Will be displayed in top of category page')), array('type' => 'file', 'label' => $this->l('Image :'), 'name' => 'image', 'required' => true), array('type' => 'text', 'label' => $this->l('Youtube:'), 'name' => 'youtube_id', 'class' => '', 'required' => FALSE), array('type' => 'text', 'label' => $this->l('Friendly URL:'), 'name' => 'link_rewrite', 'lang' => true, 'required' => true, 'hint' => $this->l('Only letters and the minus (-) character are allowed.'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Position :'), 'size' => 3, 'name' => 'position'); $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Status :'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))); if (!($news = $this->loadObject(true))) { return; } $image = ImageManager::thumbnail(_PS_PSNEWS_IMG_DIR_ . '/' . $news->id_news . '.jpg', $this->table . '_' . (int) $news->id_news . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_PS_PSNEWS_IMG_DIR_ . '/' . $news->id_news . '.jpg') / 1000 : false); $this->tpl_form_vars = array('active' => $this->object->active, 'PS_ALLOW_ACCENTED_CHARS_URL', (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')); return parent::renderForm(); }
public function createCover($img = null, $object = null) { if (!isset($img)) { die('AdminSimpleBlogCategoryController@createCover: No image to process'); } $categoryImgX = Configuration::get('PH_CATEGORY_IMAGE_X'); $categoryImgY = Configuration::get('PH_CATEGORY_IMAGE_Y'); if (isset($object) && Validate::isLoadedObject($object)) { $fileTmpLoc = $img; $origPath = _PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/' . $object->id . '.' . $object->cover; $tmp_location = _PS_TMP_IMG_DIR_ . 'ph_simpleblog_cat_' . $object->id . '.' . $object->cover; if (file_exists($tmp_location)) { @unlink($tmp_location); } try { $orig = PhpThumbFactory::create($fileTmpLoc); } catch (Exception $e) { echo $e; } $orig->adaptiveResize($categoryImgX, $categoryImgY); return $orig->save($origPath) && ImageManager::thumbnail(_PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/' . $object->id . '.' . $object->cover, 'ph_simpleblog_cat_' . $object->id . '.' . $object->cover, 350, $object->cover); } }
public function getTableMostViewed($date_from, $date_to) { $header = array(array('id' => 'image', 'title' => $this->l('Image'), 'class' => 'text-center'), array('id' => 'product', 'title' => $this->l('Product'), 'class' => 'text-center'), array('id' => 'views', 'title' => $this->l('Views'), 'class' => 'text-center'), array('id' => 'added_to_cart', 'title' => $this->l('Added to cart'), 'class' => 'text-center'), array('id' => 'purchased', 'title' => $this->l('Purchased'), 'class' => 'text-center'), array('id' => 'rate', 'title' => $this->l('Percentage'), 'class' => 'text-center')); if (Configuration::get('PS_STATSDATA_PAGESVIEWS')) { $products = $this->getTotalViewed($date_from, $date_to, (int) Configuration::get('DASHPRODUCT_NBR_SHOW_MOST_VIEWED')); $body = array(); if (is_array($products) && count($products)) { foreach ($products as $product) { $product_obj = new Product((int) $product['id_object'], true, $this->context->language->id); if (!Validate::isLoadedObject($product_obj)) { continue; } $img = ''; if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { $image = new Image($row_image['id_image']); $path_to_image = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; $img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $product_obj->id . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType); } $tr = array(); $tr[] = array('id' => 'product', 'value' => $img, 'class' => 'text-center'); $tr[] = array('id' => 'product', 'value' => Tools::htmlentitiesUTF8($product_obj->name) . '<br/>' . Tools::displayPrice(Product::getPriceStatic((int) $product_obj->id)), 'class' => 'text-center'); $tr[] = array('id' => 'views', 'value' => $product['counter'], 'class' => 'text-center'); $added_cart = $this->getTotalProductAddedCart($date_from, $date_to, (int) $product_obj->id); $tr[] = array('id' => 'added_to_cart', 'value' => $added_cart, 'class' => 'text-center'); $purchased = $this->getTotalProductPurchased($date_from, $date_to, (int) $product_obj->id); $tr[] = array('id' => 'purchased', 'value' => $this->getTotalProductPurchased($date_from, $date_to, (int) $product_obj->id), 'class' => 'text-center'); $tr[] = array('id' => 'rate', 'value' => $product['counter'] ? round(100 * $purchased / $product['counter'], 1) . '%' : '-', 'class' => 'text-center'); $body[] = $tr; } } } else { $body = '<div class="alert alert-info">' . $this->l('You must enable the "Save global page views" option from the "Data mining for statistics" module in order to display the most viewed products, or use the Google Analytics module.') . '</div>'; } return array('header' => $header, 'body' => $body); }
public function renderForm() { $this->post_format_fields = smartblog::$post_meta_fields; if (!($obj = $this->loadObject(true))) { return; } $shops = false; if (Shop::isFeatureActive()) { $shops = Shop::getShops(); } if ($shops) { foreach ($shops as $key => $shop) { if (!$obj->isAssociatedToShop($shop['id_shop'])) { unset($shops[$key]); } } } $languages = Language::getLanguages(false); //Added From Old /* * ************* featured image ****************** */ $featured_image = _MODULE_SMARTBLOG_DIR_ . $obj->id . '.jpg'; $image_url = ImageManager::thumbnail($featured_image, $this->table . '_' . pSQL(Tools::getvalue('id_smart_blog_post')) . '.jpg', 200, 'jpg', true, true); $image_size = file_exists($featured_image) ? filesize($featured_image) / 1000 : false; /* * ************* featured image ****************** */ // image gallary $id_smart_blog_post = (int) Tools::getValue('id_smart_blog_post'); $images = SmartBlogGallaryImage::getImages($this->context->language->id, $id_smart_blog_post); foreach ($images as $k => $image) { $images[$k] = new SmartBlogGallaryImage($image['id_smart_blog_gallary_images']); } //start sdsimage type $image_uploader = new HelperImageUploader('file'); $image_uploader->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminSmartBlogAjax') . '&ajax=1&id_smart_blog_post=' . (int) Tools::getvalue('id_smart_blog_post') . '&action=addGallaryImage'); // test code $root = BlogCategory::getRootCategory(); $default_category = $root['id_smart_blog_category']; if (!Tools::isSubmit('id_smart_blog_post')) { $selected_cat = BlogCategory::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); } else { if (Tools::isSubmit('categoryBox')) { $selected_cat = BlogCategory::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); } else { $selected_cat = BlogCategory::getPostCategoriesFull((int) Tools::getValue('id_smart_blog_post'), $this->default_form_language); } } $categories = array(); foreach ($selected_cat as $key => $category) { $categories[] = $key; } $tree = new SmartBlogHelperTreeCategories('smartblog-associated-categories-tree', 'Associated categories'); $tree->setTemplate('tree_associated_categories.tpl')->setHeaderTemplate('tree_associated_header.tpl')->setRootCategory((int) $root['id_category'])->setUseCheckBox(true)->setUseSearch(false)->setSelectedCategories($categories); // end test code $temp_employees = Employee::getEmployees(); $employees = array(); foreach ($temp_employees as $employee) { $employee['fullname'] = $employee['firstname'] . ' ' . $employee['lastname']; $employee['id_select'] = $employee['id_employee']; $employees[] = $employee; } $this->fields_form = array('legend' => array('title' => $this->l('Blog Post')), 'input' => array(array('type' => 'text', 'label' => $this->l('Blog Title'), 'name' => 'meta_title', 'id' => 'name', 'class' => 'copyMeta2friendlyURL', 'size' => 60, 'required' => true, 'desc' => $this->l('Enter Your Blog Post Title'), 'lang' => true), array('type' => 'select', 'label' => $this->l('Author'), 'name' => 'id_author', 'options' => array('query' => $employees, 'id' => 'id_select', 'name' => 'fullname')), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'content', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'desc' => $this->l('Enter Your Post Description')), array('type' => 'file', 'label' => $this->l('Featured Image:'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&' . $this->identifier . '=' . pSQL(Tools::getvalue('id_smart_blog_post')) . '&token=' . $this->token . '&deleteImage=1', 'hint' => $this->l('Upload a feature image from your computer.')), array('type' => 'html', 'label' => $this->l('Blog Categories'), 'name' => 'id_category_big', 'required' => true, 'html_content' => $tree->render(), 'desc' => $this->l('Select Your Parent Category')), array('type' => 'text', 'label' => $this->l('Meta Keyword'), 'name' => 'meta_keyword', 'lang' => true, 'size' => 60, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Keyword. Separated by comma(,)')), array('type' => 'textarea', 'label' => $this->l('Short Description'), 'name' => 'short_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => true, 'desc' => $this->l('Enter Your Post Short Description')), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => false, 'desc' => $this->l('Enetr Your Post Slug. Use In SEO Friendly URL')), array('type' => 'tags', 'label' => $this->l('Tag'), 'name' => 'tags', 'size' => 60, 'lang' => true, 'required' => false, 'hint' => array($this->l('To add "tags" click in the field, write something, and then press "Enter."'), $this->l('Invalid characters:') . ' <>;=#{}')), array('type' => 'switch', 'label' => $this->l('Comment Status'), 'name' => 'comment_status', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('You Can Enable or Disable Your Comments')), array('label' => $this->l('Published Date'), 'name' => 'created', 'title' => $this->l('Published date'), 'type' => 'datetime'), array('type' => 'associations', 'label' => $this->l('Related Product(s)'), 'name' => 'associations', 'size' => 60, 'lang' => true, 'required' => false), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Is Featured?'), 'name' => 'is_featured', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'gallary' => array('images' => array('count' => count($images), 'max_image_size' => $this->max_image_size / 1024 / 1024, 'table' => $this->table, 'images' => $images, 'id_smart_blog_post' => (int) Tools::getValue('id_smart_blog_post'), 'object' => $this->object, 'image_uploader' => $image_uploader->render()))); $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Post Format'), 'name' => 'post_type', 'required' => true, 'values' => array(array('id' => 'post_type_default', 'value' => '', 'label' => '<i class="icon-home"></i> ' . $this->l('None')), array('id' => 'post_type_gallery', 'value' => 'gallery', 'label' => '<i class="icon-picture"></i> ' . $this->l('Gallery')), array('id' => 'post_type_audio', 'value' => 'audio', 'label' => '<i class="icon-music"></i> ' . $this->l('Audio')), array('id' => 'post_type_video', 'value' => 'video', 'label' => '<i class="icon-film"></i> ' . $this->l('Video')), array('id' => 'post_type_quote', 'value' => 'quote', 'label' => '<i class="icon-quote-left"></i> ' . $this->l('Quote')), array('id' => 'post_type_link', 'value' => 'link', 'label' => '<i class="icon-link"></i> ' . $this->l('Link')))); $this->fields_form['input'][] = array('type' => 'html', 'label' => $this->l('Post Format Fields'), 'name' => 'post_format_fields', 'html_content' => $this->AdminMetaFields(), 'desc' => $this->l('Set exclusive fields for the post format')); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso'); } if (!($SmartBlogPost = $this->loadObject(true))) { return; } $this->fields_form['submit'] = array('title' => $this->l('Save')); $image = ImageManager::thumbnail(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg', $this->table . '_' . (int) $SmartBlogPost->id_smart_blog_post . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg') / 1000 : false); if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) { foreach (Language::getLanguages(false) as $lang) { $this->fields_value['tags'][(int) $lang['id_lang']] = SmartBlogPost::getProductTagsBylang((int) Tools::getvalue('id_smart_blog_post'), (int) $lang['id_lang']); } } $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); // related product using Accessories block $accessories = SmartBlogPost::getAccessoriesLight($this->context->language->id, $SmartBlogPost->id_smart_blog_post); if ($post_accessories = Tools::getValue('inputAccessories')) { $post_accessories_tab = explode('-', $post_accessories); foreach ($post_accessories_tab as $accessory_id) { if (!$this->haveThisAccessory($accessory_id, $accessories) && ($accessory = Product::getAccessoryById($accessory_id))) { $accessories[] = $accessory; } } } $this->tpl_form_vars['accessories'] = $accessories; /* image gallary */ $this->tpl_form_vars['images'] = $images; $this->tpl_form_vars['image_uploader'] = $image_uploader->render(); $this->tpl_form_vars['max_image_size'] = $this->max_image_size / 1024 / 1024; $this->tpl_form_vars['languages'] = $languages; $this->tpl_form_vars['iso_lang'] = $languages[0]['iso_code']; $this->tpl_form_vars['imageType'] = 'home-small'; $this->tpl_form_vars['id_smart_blog_post'] = (int) Tools::getValue('id_smart_blog_post'); $this->tpl_form_vars['default_language'] = (int) Configuration::get('PS_LANG_DEFAULT'); $this->tpl_form_vars['table'] = $this->table; $this->tpl_form_vars['token'] = Tools::getAdminTokenLite('AdminBlogPost'); $this->tpl_form_vars['gallary_path'] = _MODULE_DIR_ . 'smartblog/gallary/'; // $this->tpl_form_vars['token_book'] = Tools::getAdminTokenLite('AdminBook'); return parent::renderForm(); }
public function renderForm() { $img_desc = ''; $img_desc .= $this->l('Upload a Feature Image from your computer.<br/>N.B : Only jpg image is allowed'); if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) { $img_desc .= '<br/><img style="height:auto;width:300px;clear:both;border:1px solid black;" alt="" src="' . __PS_BASE_URI__ . 'modules/smartblog/images/' . Tools::getvalue('id_smart_blog_post') . '.jpg" /><br />'; } if (!($obj = $this->loadObject(true))) { return; } $image = _MODULE_SMARTBLOG_DIR_ . $obj->id . '.jpg'; $image_url = ImageManager::thumbnail($image, $this->table . '_' . Tools::getvalue('id_smart_blog_post') . '.jpg', 200, 'jpg', true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $this->fields_form = array('legend' => array('title' => $this->l('Blog Post')), 'input' => array(array('type' => 'hidden', 'name' => 'post_type', 'default_value' => 0), array('type' => 'text', 'label' => $this->l('Blog Title'), 'name' => 'meta_title', 'id' => 'name', 'class' => 'copyMeta2friendlyURL', 'size' => 60, 'required' => true, 'desc' => $this->l('Enter Your Blog Post Title'), 'lang' => true), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'content', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'required' => true, 'hint' => array($this->l('Enter Your Post Description'), $this->l('Invalid characters:') . ' <>;=#{}')), array('type' => 'file', 'label' => $this->l('Feature Image:'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&' . $this->identifier . '=' . Tools::getvalue('id_smart_blog_post') . '&token=' . $this->token . '&deleteImage=1', 'hint' => $this->l('Upload a feature image from your computer.')), array('type' => 'select', 'label' => $this->l('Blog Category'), 'name' => 'id_category', 'options' => array('query' => BlogCategory::getCategory(), 'id' => 'id_smart_blog_category', 'name' => 'meta_title'), 'desc' => $this->l('Select Your Parent Category')), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => array($this->l('To add "tags" click in the field, write something, and then press "Enter."'), $this->l('Invalid characters:') . ' <>;=#{}')), array('type' => 'textarea', 'label' => $this->l('Short Description'), 'name' => 'short_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => true, 'hint' => array($this->l('Enter Your Post Short Description'))), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => false, 'hint' => $this->l('Only letters and the hyphen (-) character are allowed.')), array('type' => 'tags', 'label' => $this->l('Tag'), 'name' => 'tags', 'size' => 60, 'lang' => true, 'required' => false, 'hint' => array($this->l('To add "tags" click in the field, write something, and then press "Enter."'), $this->l('Invalid characters:') . ' <>;=#{}')), array('type' => 'radio', 'label' => $this->l('Comment Status'), 'name' => 'comment_status', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('You Can Enable or Disable Your Comments')), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Is Featured?'), 'name' => 'is_featured', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'is_featured', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'is_featured', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso'); } if (!($SmartBlogPost = $this->loadObject(true))) { return; } $this->fields_form['submit'] = array('title' => $this->l('Save '), 'class' => 'button'); $image = ImageManager::thumbnail(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg', $this->table . '_' . (int) $SmartBlogPost->id_smart_blog_post . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg') / 1000 : false); if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) { foreach (Language::getLanguages(false) as $lang) { $this->fields_value['tags'][(int) $lang['id_lang']] = SmartBlogPost::getProductTagsBylang((int) Tools::getvalue('id_smart_blog_post'), (int) $lang['id_lang']); } } $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); return parent::renderForm(); }
public function renderForm() { $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Images'), 'image' => '../img/admin/cog.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Slideshow:'), 'name' => 'id_opartslideshow_slideshow', 'cast' => 'intval', 'options' => array('query' => $this->getSlideshows(), 'name' => 'name', 'id' => 'key')), array('type' => 'file', 'label' => 'image', 'name' => 'image_file', 'display_image' => true), array('type' => 'text', 'lang' => true, 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 40), array('type' => 'text', 'lang' => true, 'label' => $this->l('Url:'), 'name' => 'targeturl', 'size' => 255), array('type' => 'text', 'lang' => true, 'label' => $this->l('Description:'), 'name' => 'description', 'size' => 255), array('type' => 'text', 'label' => $this->l('Filename:'), 'name' => 'filename', 'size' => 50, 'readonly' => true), array('type' => 'select', 'label' => $this->l('Statut:'), 'name' => 'active', 'cast' => 'intval', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('disable')), array('key' => 1, 'name' => $this->l('enable'))), 'name' => 'name', 'id' => 'key'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); if (!($obj = $this->loadObject(true))) { return; } $filename = $obj->filename; $image = ImageManager::thumbnail($this->imgDir . $filename, $this->table . '_' . $filename, 350, $this->imageType, false); if (file_exists($this->imgDir . $filename)) { $this->fields_value['image'] = $image ? $image : false; $this->fields_value['size'] = $image ? filesize($this->imgDir . $filename) / 1000 : false; } return parent::renderForm(); }
public function createFeatured($img = null, $object = null) { if (!isset($img)) { die('AdminSimpleBlogPostsController@createFeatured: No image to process'); } if (isset($object) && Validate::isLoadedObject($object)) { $fileTmpLoc = $img; $origPath = _PS_MODULE_DIR_ . 'ph_simpleblog/featured/' . $object->id . '.' . $object->featured; $this->deleteFeatured($object->id, true); try { $orig = PhpThumbFactory::create($fileTmpLoc); } catch (Exception $e) { echo $e; } return $orig->save($origPath) && $tmp_featured_location && ImageManager::thumbnail(_PS_MODULE_DIR_ . 'ph_simpleblog/featured/' . $object->id . '.' . $object->featured, 'ph_simpleblog_featured_' . $object->id . '.' . $object->featured, 350, $object->featured); } }
public function renderForm() { $this->fields_form = array('legend' => array('title' => $this->l('Stores'), 'image' => '../img/admin/home.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'size' => 33, 'required' => false, 'hint' => sprintf($this->l('Allowed characters: letters, spaces and %s'), '().-'), 'desc' => $this->l('Store name (e.g. Citycentre Mall Store)')), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'size' => 33, 'required' => true), array('type' => 'text', 'label' => $this->l('Address (2)'), 'name' => 'address2', 'size' => 33), array('type' => 'text', 'label' => $this->l('Postal Code/Zip Code'), 'name' => 'postcode', 'size' => 6, 'required' => true), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'size' => 33, 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => true, 'options' => array('id' => 'id_state', 'name' => 'name', 'query' => null)), array('type' => 'latitude', 'label' => $this->l('Latitude / Longitude'), 'name' => 'latitude', 'required' => true, 'size' => 11, 'maxlength' => 12, 'desc' => $this->l('Store coordinates (e.g. 45.265469/-47.226478)')), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone', 'size' => 33), array('type' => 'text', 'label' => $this->l('Fax'), 'name' => 'fax', 'size' => 33), array('type' => 'text', 'label' => $this->l('E-mail address'), 'name' => 'email', 'size' => 33), array('type' => 'textarea', 'label' => $this->l('Note'), 'name' => 'note', 'cols' => 42, 'rows' => 4), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Whether or not to display this store'))), 'rightCols' => array('input' => array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'desc' => $this->l('Storefront picture'))), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button')); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso'); } if (!($obj = $this->loadObject(true))) { return; } $image = ImageManager::thumbnail(_PS_STORE_IMG_DIR_ . '/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true); $days = array(); $days[1] = $this->l('Monday'); $days[2] = $this->l('Tuesday'); $days[3] = $this->l('Wednesday'); $days[4] = $this->l('Thursday'); $days[5] = $this->l('Friday'); $days[6] = $this->l('Saturday'); $days[7] = $this->l('Sunday'); $hours = $this->getFieldValue($obj, 'hours'); if (!empty($hours)) { $hours_unserialized = Tools::unSerialize($hours); } $this->fields_value = array('latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'), 'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'), 'image' => $image ? $image : false, 'size' => $image ? filesize(_PS_STORE_IMG_DIR_ . '/' . $obj->id . '.jpg') / 1000 : false, 'days' => $days, 'hours' => isset($hours_unserialized) ? $hours_unserialized : false); return parent::renderForm(); }
public function displayListContent() { if ($this->position_identifier) { $id_category = (int) Tools::getValue('id_' . ($this->is_cms ? 'cms_' : '') . 'category', '1'); } else { $id_category = Category::getRootCategory()->id; } if (isset($this->fields_list['position'])) { $positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list); sort($positions); } // key_to_get is used to display the correct product category or cms category after a position change $identifier = in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : ''; if ($identifier) { $key_to_get = 'id_' . ($this->is_cms ? 'cms_' : '') . 'category' . $identifier; } foreach ($this->_list as $index => $tr) { $id = $tr[$this->identifier]; $name = isset($tr['name']) ? $tr['name'] : null; if ($this->shopLinkType) { $this->_list[$index]['short_shop_name'] = Tools::strlen($tr['shop_name']) > 15 ? Tools::substr($tr['shop_name'], 0, 15) . '...' : $tr['shop_name']; } // Check all available actions to add to the current list row foreach ($this->actions as $action) { //Check if the action is available for the current row if (!array_key_exists($action, $this->list_skip_actions) || !in_array($id, $this->list_skip_actions[$action])) { $method_name = 'display' . ucfirst($action) . 'Link'; if (method_exists($this->context->controller, $method_name)) { $this->_list[$index][$action] = $this->context->controller->{$method_name}($this->token, $id, $name); } elseif (method_exists($this, $method_name)) { $this->_list[$index][$action] = $this->{$method_name}($this->token, $id, $name); } } } // @todo skip action for bulk actions // $this->_list[$index]['has_bulk_actions'] = true; foreach ($this->fields_list as $key => $params) { $tmp = explode('!', $key); $key = isset($tmp[1]) ? $tmp[1] : $tmp[0]; if (isset($params['active'])) { // If method is defined in calling controller, use it instead of the Helper method if (method_exists($this->context->controller, 'displayEnableLink')) { $calling_obj = $this->context->controller; } else { $calling_obj = $this; } $this->_list[$index][$key] = $calling_obj->displayEnableLink($this->token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product')); } elseif (isset($params['activeVisu'])) { $this->_list[$index][$key] = (bool) $tr[$key]; } elseif (isset($params['position'])) { $this->_list[$index][$key] = array('position' => $tr[$key], 'position_url_down' => $this->currentIndex . (isset($key_to_get) ? '&' . $key_to_get . '=' . (int) $id_category : '') . '&' . $this->position_identifier . '=' . $id . '&way=1&position=' . ((int) $tr['position'] + 1) . '&token=' . $this->token, 'position_url_up' => $this->currentIndex . (isset($key_to_get) ? '&' . $key_to_get . '=' . (int) $id_category : '') . '&' . $this->position_identifier . '=' . $id . '&way=0&position=' . ((int) $tr['position'] - 1) . '&token=' . $this->token); } elseif (isset($params['image'])) { // item_id is the product id in a product image context, else it is the image id. $item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id; if ($params['image'] != 'p' || Configuration::get('PS_LEGACY_IMAGES')) { $path_to_image = _PS_IMG_DIR_ . $params['image'] . '/' . $item_id . (isset($tr['id_image']) ? '-' . (int) $tr['id_image'] : '') . '.' . $this->imageType; } else { $path_to_image = _PS_IMG_DIR_ . $params['image'] . '/' . Image::getImgFolderStatic($tr['id_image']) . (int) $tr['id_image'] . '.' . $this->imageType; } $this->_list[$index][$key] = ImageManager::thumbnail($path_to_image, $this->table . '_mini_' . $item_id . '.' . $this->imageType, 45, $this->imageType); } elseif (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default']))) { if (isset($params['icon'][$tr[$key]]) && is_array($params['icon'][$tr[$key]])) { $this->_list[$index][$key] = array('src' => $params['icon'][$tr[$key]]['src'], 'alt' => $params['icon'][$tr[$key]]['alt']); } else { $this->_list[$index][$key] = array('src' => isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'], 'alt' => isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default']); } } elseif (isset($params['type']) && $params['type'] == 'float') { $this->_list[$index][$key] = rtrim(rtrim($tr[$key], '0'), '.'); } elseif (isset($params['type']) && $params['type'] == 'price') { $currency = isset($params['currency']) && $params['currency'] ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency; $this->_list[$index][$key] = Tools::displayPrice($tr[$key], $currency, false); } elseif (isset($params['type']) && $params['type'] == 'date') { $this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id); } elseif (isset($params['type']) && $params['type'] == 'datetime') { $this->_list[$index][$key] = Tools::displayDate($tr[$key], $this->context->language->id, true); } elseif (isset($tr[$key])) { $echo = $tr[$key]; if (isset($params['callback'])) { $callback_obj = isset($params['callback_object']) ? $params['callback_object'] : $this->context->controller; $this->_list[$index][$key] = call_user_func_array(array($callback_obj, $params['callback']), array($echo, $tr)); } else { $this->_list[$index][$key] = $echo; } } } } $this->content_tpl->assign(array_merge($this->tpl_vars, array('shop_link_type' => $this->shopLinkType, 'name' => isset($name) ? $name : null, 'position_identifier' => $this->position_identifier, 'identifier' => $this->identifier, 'table' => $this->table, 'token' => $this->token, 'color_on_bg' => $this->colorOnBackground, 'id_category' => $id_category, 'bulk_actions' => $this->bulk_actions, 'positions' => isset($positions) ? $positions : null, 'order_by' => $this->orderBy, 'order_way' => $this->orderWay, 'is_cms' => $this->is_cms, 'fields_display' => $this->fields_list, 'list' => $this->_list, 'actions' => $this->actions, 'no_link' => $this->no_link, 'current_index' => $this->currentIndex, 'view' => in_array('view', $this->actions), 'edit' => in_array('edit', $this->actions), 'has_actions' => !empty($this->actions), 'has_bulk_actions' => !empty($this->bulk_actions), 'list_skip_actions' => $this->list_skip_actions, 'row_hover' => $this->row_hover))); return $this->content_tpl->fetch(); }
public function renderForm() { $this->initToolbar(); $obj = $this->loadObject(true); $id_shop = Context::getContext()->shop->id; $selected_categories = array(isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop) ? (int) $obj->id_parent : (int) Tools::getValue('id_parent', Category::getRootCategory()->id)); $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP')); $default = new Group(Configuration::get('PS_CUSTOMER_GROUP')); $unidentified_group_information = sprintf($this->l('%s - All people without a valid customer account.'), '<b>' . $unidentified->name[$this->context->language->id] . '</b>'); $guest_group_information = sprintf($this->l('%s - Customer who placed an order with the guest checkout.'), '<b>' . $guest->name[$this->context->language->id] . '</b>'); $default_group_information = sprintf($this->l('%s - All people who have created an account on this site.'), '<b>' . $default->name[$this->context->language->id] . '</b>'); if (!($obj = $this->loadObject(true))) { return; } $image = _PS_CAT_IMG_DIR_ . $obj->id . '.jpg'; $image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Category'), 'icon' => 'icon-tags'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'lang' => true, 'required' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'switch', 'label' => $this->l('Displayed'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'categories', 'label' => $this->l('Parent category'), 'name' => 'id_parent', 'tree' => array('id' => 'categories-tree', 'selected_categories' => $selected_categories, 'disabled_categories' => !Tools::isSubmit('add' . $this->table) ? array($this->_category->id) : null)), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'autoload_rte' => true, 'lang' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'file', 'label' => $this->l('Image'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&' . $this->identifier . '=' . $this->_category->id . '&token=' . $this->token . '&deleteImage=1', 'hint' => $this->l('Upload a category logo from your computer.')), array('type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('To add "tags," click in the field, write something, and then press "Enter."') . ' ' . $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Friendly URL'), 'name' => 'link_rewrite', 'lang' => true, 'required' => true, 'hint' => $this->l('Only letters, numbers, underscore (_) and the minus (-) character are allowed.')), array('type' => 'group', 'label' => $this->l('Group access'), 'name' => 'groupBox', 'values' => Group::getGroups(Context::getContext()->language->id), 'info_introduction' => $this->l('You now have three default customer groups.'), 'unidentified' => $unidentified_group_information, 'guest' => $guest_group_information, 'customer' => $default_group_information, 'hint' => $this->l('Mark all of the customer groups which you would like to have access to this category.'))), 'submit' => array('title' => $this->l('Save'), 'name' => 'submitAdd' . $this->table . ($this->_category->is_root_category && !Tools::isSubmit('add' . $this->table) && !Tools::isSubmit('add' . $this->table . 'root') ? '' : 'AndBackToParent'))); $this->tpl_form_vars['shared_category'] = Validate::isLoadedObject($obj) && $obj->hasMultishopEntries(); $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); $this->tpl_form_vars['displayBackOfficeCategory'] = Hook::exec('displayBackOfficeCategory'); // Display this field only if multistore option is enabled if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && Tools::isSubmit('add' . $this->table . 'root')) { $this->fields_form['input'][] = array('type' => 'switch', 'label' => $this->l('Root Category'), 'name' => 'is_root_category', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'is_root_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'is_root_off', 'value' => 0, 'label' => $this->l('No')))); unset($this->fields_form['input'][2], $this->fields_form['input'][3]); } // Display this field only if multistore option is enabled AND there are several stores configured if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso'); } // remove category tree and radio button "is_root_category" if this category has the root category as parent category to avoid any conflict if ($this->_category->id_parent == Category::getTopCategory()->id && Tools::isSubmit('updatecategory')) { foreach ($this->fields_form['input'] as $k => $input) { if (in_array($input['name'], array('id_parent', 'is_root_category'))) { unset($this->fields_form['input'][$k]); } } } if (!($obj = $this->loadObject(true))) { return; } $image = ImageManager::thumbnail(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg') / 1000 : false); // Added values of object Group $category_groups_ids = $obj->getGroups(); $groups = Group::getGroups($this->context->language->id); // if empty $carrier_groups_ids : object creation : we set the default groups if (empty($category_groups_ids)) { $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP')); $category_groups_ids = array_merge($category_groups_ids, $preselected); } foreach ($groups as $group) { $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $category_groups_ids)); } $this->fields_value['is_root_category'] = (bool) Tools::isSubmit('add' . $this->table . 'root'); return parent::renderForm(); }
public function renderForm() { $img_desc = ''; $img_desc .= $this->l('Upload a Feature Image from your computer.<br/>N.B : Only jpg image is allowed'); if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) { $img_desc .= '<br/><img style="height:auto;width:300px;clear:both;border:1px solid black;" alt="" src="' . __PS_BASE_URI__ . 'modules/smartblog/images/' . Tools::getvalue('id_smart_blog_post') . '.jpg" /><br />'; } $this->fields_form = array('legend' => array('title' => $this->l('Blog Post')), 'input' => array(array('type' => 'hidden', 'name' => 'post_type', 'default_value' => 0), array('type' => 'text', 'label' => $this->l('Blog Title'), 'name' => 'meta_title', 'size' => 60, 'required' => true, 'desc' => $this->l('Enter Your Blog Post Title'), 'lang' => true), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'content', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'required' => true, 'desc' => $this->l('Enter Your Post Description')), array('type' => 'file', 'label' => $this->l('Feature Image:'), 'name' => 'image', 'display_image' => false, 'desc' => $img_desc), array('type' => 'select', 'label' => $this->l('Blog Category'), 'name' => 'id_category', 'options' => array('query' => BlogCategory::getCategory(), 'id' => 'id_smart_blog_category', 'name' => 'meta_title'), 'desc' => $this->l('Select Your Parent Category')), array('type' => 'text', 'label' => $this->l('Meta Keyword'), 'name' => 'meta_keyword', 'lang' => true, 'size' => 60, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Keyword. Separated by comma(,)')), array('type' => 'textarea', 'label' => $this->l('Short Description'), 'name' => 'short_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => true, 'desc' => $this->l('Enter Your Post Short Description')), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => false, 'desc' => $this->l('Enetr Your Post Slug. Use In SEO Friendly URL')), array('type' => 'text', 'label' => $this->l('Tag'), 'name' => 'tags', 'size' => 60, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Tag. Separated by comma(,)')), array('type' => 'radio', 'label' => $this->l('Comment Status'), 'name' => 'comment_status', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('You Can Enable or Disable Your Comments')), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Is Featured?'), 'name' => 'is_featured', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'is_featured', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'is_featured', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso'); } if (!($SmartBlogPost = $this->loadObject(true))) { return; } $this->fields_form['submit'] = array('title' => $this->l('Save '), 'class' => 'button'); $image = ImageManager::thumbnail(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg', $this->table . '_' . (int) $SmartBlogPost->id_smart_blog_post . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg') / 1000 : false); if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) { foreach (Language::getLanguages(false) as $lang) { $this->fields_value['tags'][(int) $lang['id_lang']] = SmartBlogPost::getProductTagsBylang((int) Tools::getvalue('id_smart_blog_post'), (int) $lang['id_lang']); } } return parent::renderForm(); }
public function displayListContent($token = null) { /* Display results in a table * * align : determine value alignment * prefix : displayed before value * suffix : displayed after value * image : object image * icon : icon determined by values * active : allow to toggle status */ $id_category = 1; // default categ $irow = 0; if ($this->_list && isset($this->fieldsDisplay['position'])) { $positions = array_map(create_function('$elem', 'return (int)$elem[\'position\'];'), $this->_list); sort($positions); } if ($this->_list) { $isCms = false; if (preg_match('/cms/Ui', $this->identifier)) { $isCms = true; } $keyToGet = 'id_' . ($isCms ? 'cms_' : '') . 'category' . (in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : ''); foreach ($this->_list as $tr) { $id = $tr[$this->identifier]; echo '<tr' . (array_key_exists($this->identifier, $this->identifiersDnd) ? ' id="tr_' . (($id_category = (int) Tools::getValue('id_' . ($isCms ? 'cms_' : '') . 'category', '1')) ? $id_category : '') . '_' . $id . '_' . $tr['position'] . '"' : '') . ($irow++ % 2 ? ' class="alt_row"' : '') . ' ' . (isset($tr['color']) && $this->colorOnBackground ? 'style="background-color: ' . $tr['color'] . '"' : '') . '> <td class="center">'; if ($this->delete && (!isset($this->_listSkipDelete) || !in_array($id, $this->_listSkipDelete))) { echo '<input type="checkbox" name="' . $this->table . 'Box[]" value="' . $id . '" class="noborder" />'; } echo '</td>'; foreach ($this->fieldsDisplay as $key => $params) { $tmp = explode('!', $key); $key = isset($tmp[1]) ? $tmp[1] : $tmp[0]; echo ' <td ' . (isset($params['position']) ? ' id="td_' . (isset($id_category) && $id_category ? $id_category : 0) . '_' . $id . '"' : '') . ' class="' . (!isset($this->noLink) || !$this->noLink ? 'pointer' : '') . (isset($params['position']) && $this->_orderBy == 'position' ? ' dragHandle' : '') . (isset($params['align']) ? ' ' . $params['align'] : '') . '" '; if (!isset($params['position']) && (!isset($this->noLink) || !$this->noLink)) { echo ' onclick="document.location = \'' . self::$currentIndex . '&' . $this->identifier . '=' . $id . ($this->view ? '&view' : '&update') . $this->table . '&token=' . ($token != null ? $token : $this->token) . '\'">' . (isset($params['prefix']) ? $params['prefix'] : ''); } else { echo '>'; } if (isset($params['active']) && isset($tr[$key])) { $this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product')); } elseif (isset($params['activeVisu']) && isset($tr[$key])) { echo '<img src="../img/admin/' . ($tr[$key] ? 'enabled.gif' : 'disabled.gif') . '" alt="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" title="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" />'; } elseif (isset($params['position'])) { if ($this->_orderBy == 'position' && $this->_orderWay != 'DESC') { echo '<a' . (!($tr[$key] != $positions[count($positions) - 1]) ? ' style="display: none;"' : '') . ' href="' . self::$currentIndex . '&' . $keyToGet . '=' . (int) $id_category . '&' . $this->identifiersDnd[$this->identifier] . '=' . $id . ' &way=1&position=' . (int) ($tr['position'] + 1) . '&token=' . ($token != null ? $token : $this->token) . '"> <img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'down' : 'up') . '.gif" alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a>'; echo '<a' . (!($tr[$key] != $positions[0]) ? ' style="display: none;"' : '') . ' href="' . self::$currentIndex . '&' . $keyToGet . '=' . (int) $id_category . '&' . $this->identifiersDnd[$this->identifier] . '=' . $id . ' &way=0&position=' . (int) ($tr['position'] - 1) . '&token=' . ($token != null ? $token : $this->token) . '"> <img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'up' : 'down') . '.gif" alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a>'; } else { echo (int) ($tr[$key] + 1); } } elseif (isset($params['image'])) { // item_id is the product id in a product image context, else it is the image id. $item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id; // If it's a product image if (isset($tr['id_image'])) { $image = new Image((int) $tr['id_image']); $path_to_image = _PS_IMG_DIR_ . $params['image'] . '/' . $image->getExistingImgPath() . '.' . $this->imageType; } else { $path_to_image = _PS_IMG_DIR_ . $params['image'] . '/' . $item_id . (isset($tr['id_image']) ? '-' . (int) $tr['id_image'] : '') . '.' . $this->imageType; } echo ImageManager::thumbnail($path_to_image, $this->table . '_mini_' . $item_id . '.' . $this->imageType, 45, $this->imageType); } elseif (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default']))) { echo '<img src="../img/admin/' . (isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'] . '" alt="' . $tr[$key]) . '" title="' . $tr[$key] . '" />'; } elseif (isset($params['price'])) { echo Tools::displayPrice($tr[$key], isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency, false); } elseif (isset($params['float'])) { echo rtrim(rtrim($tr[$key], '0'), '.'); } elseif (isset($params['type']) && $params['type'] == 'date') { echo Tools::displayDate($tr[$key]); } elseif (isset($params['type']) && $params['type'] == 'datetime') { echo Tools::displayDate($tr[$key], null, true); } elseif (isset($tr[$key])) { if ($key == 'price') { $echo = round($tr[$key], 2); } elseif (isset($params['maxlength']) && Tools::strlen($tr[$key]) > $params['maxlength']) { $echo = '<span title="' . $tr[$key] . '">' . Tools::substr($tr[$key], 0, $params['maxlength']) . '...</span>'; } else { $echo = $tr[$key]; } echo isset($params['callback']) ? call_user_func_array(array(isset($params['callback_object']) ? $params['callback_object'] : $this->className, $params['callback']), array($echo, $tr)) : $echo; } else { echo '--'; } echo (isset($params['suffix']) ? $params['suffix'] : '') . '</td>'; } if ($this->shopLinkType) { $name = Tools::strlen($tr['shop_name']) > 15 ? Tools::substr($tr['shop_name'], 0, 15) . '...' : $tr['shop_name']; echo '<td class="center" ' . ($name != $tr['shop_name'] ? 'title="' . $tr['shop_name'] . '"' : '') . '>' . $name . '</td>'; } if ($this->edit || $this->delete || $this->view && $this->view !== 'noActionColumn') { echo '<td class="center" style="white-space: nowrap;">'; if ($this->view) { $this->_displayViewLink($token, $id); } if ($this->edit) { $this->_displayEditLink($token, $id); } if ($this->delete && (!isset($this->_listSkipDelete) || !in_array($id, $this->_listSkipDelete))) { $this->_displayDeleteLink($token, $id); } if ($this->duplicate) { $this->_displayDuplicate($token, $id); } echo '</td>'; } echo '</tr>'; } } }
/** * Assign smarty variables for the header */ public function initHeader() { // Multishop $is_multishop = Shop::isFeatureActive(); // Quick access $quick_access = QuickAccess::getQuickAccesses($this->context->language->id); foreach ($quick_access as $index => $quick) { if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP) { $url = $this->context->shop->getBaseURL(); if (!$url) { unset($quick_access[$index]); continue; } $quick_access[$index]['link'] = $url; } else { preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $admin_tab); if (isset($admin_tab[1])) { if (strpos($admin_tab[1], '&')) { $admin_tab[1] = substr($admin_tab[1], 0, strpos($admin_tab[1], '&')); } $token = Tools::getAdminToken($admin_tab[1] . (int) Tab::getIdFromClassName($admin_tab[1]) . (int) $this->context->employee->id); $quick_access[$index]['link'] .= '&token=' . $token; } } } // Tab list $tabs = Tab::getTabs($this->context->language->id, 0); $current_id = Tab::getCurrentParentId(); foreach ($tabs as $index => $tab) { if (!checkTabRights($tab['id_tab']) || $tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0 || $tab['class_name'] == 'AdminCarrierWizard') { unset($tabs[$index]); continue; } $img_cache_url = 'themes/' . $this->context->employee->bo_theme . '/img/t/' . $tab['class_name'] . '.png'; $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . $img_cache_url); // retrocompatibility : change png to gif if icon not exists if (!$img_exists_cache) { $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . str_replace('.png', '.gif', $img_cache_url)); } if ($img_exists_cache) { $path_img = $img = $img_exists_cache; } else { $path_img = _PS_IMG_DIR_ . 't/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../img/t/' . $tab['class_name'] . '.png'; } if (trim($tab['module']) != '') { $path_img = _PS_MODULE_DIR_ . $tab['module'] . '/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../modules/' . $tab['module'] . '/' . $tab['class_name'] . '.png'; } // retrocompatibility if (!file_exists($path_img)) { $img = str_replace('png', 'gif', $img); } // tab[class_name] does not contains the "Controller" suffix $tabs[$index]['current'] = $tab['class_name'] . 'Controller' == get_class($this) || $current_id == $tab['id_tab']; $tabs[$index]['img'] = $img; $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']); $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']); foreach ($sub_tabs as $index2 => $sub_tab) { // class_name is the name of the class controller if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool) $sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard') { $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']); $sub_tabs[$index2]['current'] = $sub_tab['class_name'] . 'Controller' == get_class($this); } else { unset($sub_tabs[$index2]); } } $tabs[$index]['sub_tabs'] = $sub_tabs; } if (Validate::isLoadedObject($this->context->employee)) { $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name'); /* Hooks are volontary out the initialize array (need those variables already assigned) */ $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color; $this->context->smarty->assign(array('autorefresh_notifications' => Configuration::get('PS_ADMINREFRESH_NOTIFICATION'), 'help_box' => Configuration::get('PS_HELPBOX'), 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', 'bo_width' => (int) $this->context->employee->bo_width, 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && $accesses['AdminOrders']['view'], 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && $accesses['AdminCustomers']['view'], 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && $accesses['AdminCustomerThreads']['view'], 'first_name' => Tools::substr($this->context->employee->firstname, 0, 1), 'last_name' => Tools::safeOutput($this->context->employee->lastname), 'employee' => $this->context->employee, 'search_type' => Tools::getValue('bo_search_type'), 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), 'quick_access' => $quick_access, 'multi_shop' => Shop::isFeatureActive(), 'shop_list' => Helper::renderShopList(), 'shop' => $this->context->shop, 'shop_group' => new ShopGroup((int) Shop::getContextShopGroupID()), 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'is_multishop' => $is_multishop, 'multishop_context' => $this->multishop_context, 'default_tab_link' => $this->context->link->getAdminLink(Tab::getClassNameById((int) Context::getContext()->employee->default_tab)), 'employee_avatar' => ImageManager::thumbnail($this->context->employee->getImage(), 'employee' . '_' . (int) $this->context->employee->id . '.' . $this->imageType, 150, $this->imageType, true, true), 'collapse_menu' => isset($this->context->cookie->collapse_menu) ? (int) $this->context->cookie->collapse_menu : 0)); } else { $this->context->smarty->assign('default_tab_link', $this->context->link->getAdminLink('AdminDashboard')); } $this->context->smarty->assign(array('img_dir' => _PS_IMG_, 'iso' => $this->context->language->iso_code, 'class_name' => $this->className, 'iso_user' => $this->context->language->iso_code, 'country_iso_code' => $this->context->country->iso_code, 'version' => _PS_VERSION_, 'lang_iso' => $this->context->language->iso_code, 'link' => $this->context->link, 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'base_url' => $this->context->shop->getBaseURL(), 'tab' => isset($tab) ? $tab : null, 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_ . '/../install'), 'pic_dir' => _THEME_PROD_PIC_DIR_, 'controller_name' => htmlentities(Tools::getValue('controller')), 'currentIndex' => self::$currentIndex, 'bootstrap' => $this->bootstrap, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'))); }
/** * @deprecated 1.5.0 */ function cacheImage($image, $cacheImage, $size, $imageType = 'jpg', $disableCache = false) { Tools::displayAsDeprecated(); return ImageManager::thumbnail($image, $cacheImage, $size, $imageType, $disableCache); }
public function hookDisplayBackOfficeCategory($params) { $category = new Category((int) Tools::getValue('id_category')); $files = array(); if ($category->level_depth < 1) { return; } for ($i = 0; $i < 3; $i++) { if (file_exists(_PS_CAT_IMG_DIR_ . (int) $category->id . '-' . $i . '_thumb.jpg')) { $files[$i]['type'] = HelperImageUploader::TYPE_IMAGE; $files[$i]['image'] = ImageManager::thumbnail(_PS_CAT_IMG_DIR_ . (int) $category->id . '-' . $i . '_thumb.jpg', $this->context->controller->table . '_' . (int) $category->id . '-' . $i . '_thumb.jpg', 100, 'jpg', true, true); $files[$i]['delete_url'] = Context::getContext()->link->getAdminLink('AdminBlockCategories') . '&deleteThumb=' . $i . '&id_category=' . (int) $category->id; } } $helper = new HelperImageUploader(); $helper->setMultiple(true)->setUseAjax(true)->setName('thumbnail')->setFiles($files)->setMaxFiles(3)->setUrl(Context::getContext()->link->getAdminLink('AdminBlockCategories') . '&ajax=1&id_category=' . $category->id . '&action=uploadThumbnailImages'); $this->smarty->assign('helper', $helper->render()); return $this->display(__FILE__, 'views/blockcategories_admin.tpl'); }
public function renderForm() { if (!($manufacturer = $this->loadObject(true))) { return; } $image = _PS_MANU_IMG_DIR_ . $manufacturer->id . '.jpg'; $image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $manufacturer->id . '.' . $this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Manufacturers'), 'icon' => 'icon-certificate'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'col' => 4, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'textarea', 'label' => $this->l('Short description'), 'name' => 'short_description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'autoload_rte' => 'rte', 'col' => 6, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'col' => 6, 'autoload_rte' => 'rte', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'file', 'label' => $this->l('Logo'), 'name' => 'logo', 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'display_image' => true, 'col' => 6, 'hint' => $this->l('Upload a manufacturer logo from your computer.')), array('type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'col' => 6, 'hint' => array($this->l('Forbidden characters:') . ' <>;=#{}', $this->l('To add "tags," click inside the field, write something, and then press "Enter."'))), array('type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))))); if (!($manufacturer = $this->loadObject(true))) { return; } if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso'); } $this->fields_form['submit'] = array('title' => $this->l('Save')); foreach ($this->_languages as $language) { $this->fields_value['short_description_' . $language['id_lang']] = htmlentities(stripslashes($this->getFieldValue($manufacturer, 'short_description', $language['id_lang'])), ENT_COMPAT, 'UTF-8'); $this->fields_value['description_' . $language['id_lang']] = htmlentities(stripslashes($this->getFieldValue($manufacturer, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8'); } return parent::renderForm(); }
protected function getProducts($order) { $products = $order->getProducts(); foreach ($products as &$product) { if ($product['image'] != null) { $name = 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg'; // generate image cache, only for back office $product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $product['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg'); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $product['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $product['image_size'] = false; } } } return $products; }
public function renderView() { if (!($cart = $this->loadObject(true))) { return; } $customer = new Customer($cart->id_customer); $currency = new Currency($cart->id_currency); $this->context->cart = $cart; $this->context->currency = $currency; $this->context->customer = $customer; $this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->id); $products = $cart->getProducts(); $customized_datas = Product::getAllCustomizedDatas((int) $cart->id); Product::addCustomizationPrice($products, $customized_datas); $summary = $cart->getSummaryDetails(); /* Display order information */ $id_order = (int) Order::getOrderByCartId($cart->id); $order = new Order($id_order); if (Validate::isLoadedObject($order)) { $tax_calculation_method = $order->getTaxCalculationMethod(); $id_shop = (int) $order->id_shop; } else { $id_shop = (int) $cart->id_shop; $tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id); } if ($tax_calculation_method == PS_TAX_EXC) { $total_products = $summary['total_products']; $total_discounts = $summary['total_discounts_tax_exc']; $total_wrapping = $summary['total_wrapping_tax_exc']; $total_price = $summary['total_price_without_tax']; $total_shipping = $summary['total_shipping_tax_exc']; } else { $total_products = $summary['total_products_wt']; $total_discounts = $summary['total_discounts']; $total_wrapping = $summary['total_wrapping']; $total_price = $summary['total_price']; $total_shipping = $summary['total_shipping']; } foreach ($products as $k => &$product) { if ($tax_calculation_method == PS_TAX_EXC) { $product['product_price'] = $product['price']; $product['product_total'] = $product['total']; } else { $product['product_price'] = $product['price_wt']; $product['product_total'] = $product['total_wt']; } $image = array(); if (isset($product['id_product_attribute']) && (int) $product['id_product_attribute']) { $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'product_attribute_image WHERE id_product_attribute = ' . (int) $product['id_product_attribute']); } if (!isset($image['id_image'])) { $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'image WHERE id_product = ' . (int) $product['id_product'] . ' AND cover = 1'); } $product_obj = new Product($product['id_product']); $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct($product['id_product'], isset($product['id_product_attribute']) ? $product['id_product_attribute'] : null, (int) $id_shop); $image_product = new Image($image['id_image']); $product['image'] = isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $image_product->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['id_product'] . (isset($product['id_product_attribute']) ? '_' . (int) $product['id_product_attribute'] : '') . '.jpg', 45, 'jpg') : '--'; } $helper = new HelperKpi(); $helper->id = 'box-kpi-cart'; $helper->icon = 'icon-shopping-cart'; $helper->color = 'color1'; $helper->title = $this->l('Total Cart', null, null, false); $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id); $helper->value = Tools::displayPrice($total_price, $currency); $kpi = $helper->generate(); $this->tpl_view_vars = array('kpi' => $kpi, 'products' => $products, 'discounts' => $cart->getCartRules(), 'order' => $order, 'cart' => $cart, 'currency' => $currency, 'customer' => $customer, 'customer_stats' => $customer->getStats(), 'total_products' => $total_products, 'total_discounts' => $total_discounts, 'total_wrapping' => $total_wrapping, 'total_price' => $total_price, 'total_shipping' => $total_shipping, 'customized_datas' => $customized_datas); return parent::renderView(); }
public function renderForm() { $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Example'), 'image' => '../img/admin/cog.gif'), 'input' => array(array('type' => 'text', 'lang' => true, 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 40), array('type' => 'file', 'label' => $this->l('Logo:'), 'name' => 'image', 'display_image' => true, 'desc' => $this->l('Upload Example image from your computer')), array('type' => 'text', 'label' => $this->l('Lorem:'), 'name' => 'lorem', 'readonly' => true, 'disabled' => true, 'size' => 40), array('type' => 'date', 'name' => 'exampledate')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); if (!($obj = $this->loadObject(true))) { return; } /* Thumbnail * @todo Error, deletion of the image */ $image = ImageManager::thumbnail(_PS_IMG_DIR_ . 'region/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_PS_IMG_DIR_ . 'example/' . $obj->id . '.jpg') / 1000 : false); $this->fields_value = array('lorem' => 'ipsum'); return parent::renderForm(); }
public function renderForm() { $this->initToolbar(); $obj = $this->loadObject(true); $id_shop = Context::getContext()->shop->id; $selected_cat = array(isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop) ? (int) $obj->id_parent : (int) Tools::getValue('id_parent', Category::getRootCategory()->id)); $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP')); $default = new Group(Configuration::get('PS_CUSTOMER_GROUP')); $unidentified_group_information = sprintf($this->l('%s - All people without a validated customer account.'), '<b>' . $unidentified->name[$this->context->language->id] . '</b>'); $guest_group_information = sprintf($this->l('%s - Customer who placed an order with the Guest Checkout.'), '<b>' . $guest->name[$this->context->language->id] . '</b>'); $default_group_information = sprintf($this->l('%s - All people who have created an account on this site.'), '<b>' . $default->name[$this->context->language->id] . '</b>'); $root_category = Category::getRootCategory(); $root_category = array('id_category' => $root_category->id, 'name' => $root_category->name); $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Category'), 'image' => '../img/admin/tab-categories.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'lang' => true, 'size' => 48, 'required' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'radio', 'label' => $this->l('Displayed:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'categories', 'label' => $this->l('Parent category:'), 'name' => 'id_parent', 'values' => array('trads' => array('Root' => $root_category, 'selected' => $this->l('selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All')), 'selected_cat' => $selected_cat, 'input_name' => 'id_parent', 'use_radio' => true, 'use_search' => false, 'disabled_categories' => array(4), 'top_category' => Category::getTopCategory(), 'use_context' => true)), array('type' => 'radio', 'label' => $this->l('Root Category:'), 'name' => 'is_root_category', 'required' => false, 'is_bool' => true, 'class' => 't', 'values' => array(array('id' => 'is_root_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'is_root_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'lang' => true, 'rows' => 10, 'cols' => 100, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'file', 'label' => $this->l('Image:'), 'name' => 'image', 'display_image' => true, 'desc' => $this->l('Upload category logo from your computer')), array('type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description:'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords:'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}', 'desc' => $this->l('To add "tags" click in the field, write something, then press "Enter"')), array('type' => 'text', 'label' => $this->l('Friendly URL:'), 'name' => 'link_rewrite', 'lang' => true, 'required' => true, 'hint' => $this->l('Only letters and the minus (-) character are allowed')), array('type' => 'group', 'label' => $this->l('Group access:'), 'name' => 'groupBox', 'values' => Group::getGroups(Context::getContext()->language->id), 'info_introduction' => $this->l('You now have three default customer groups.'), 'unidentified' => $unidentified_group_information, 'guest' => $guest_group_information, 'customer' => $default_group_information, 'desc' => $this->l('Mark all customer groups you want to give access to this category'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); $this->tpl_form_vars['shared_category'] = Validate::isLoadedObject($obj) && $obj->hasMultishopEntries(); $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso'); } // remove category tree and radio button "is_root_category" if this category has the root category as parent category to avoid any conflict if ($this->_category->id_parent == Category::getTopCategory()->id && Tools::isSubmit('updatecategory')) { foreach ($this->fields_form['input'] as $k => $input) { if (in_array($input['name'], array('id_parent', 'is_root_category'))) { unset($this->fields_form['input'][$k]); } } } if (Tools::isSubmit('add' . $this->table . 'root')) { unset($this->fields_form['input'][2], $this->fields_form['input'][3]); } if (!($obj = $this->loadObject(true))) { return; } $image = ImageManager::thumbnail(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg') / 1000 : false); // Added values of object Group $category_groups_ids = $obj->getGroups(); $groups = Group::getGroups($this->context->language->id); // if empty $carrier_groups_ids : object creation : we set the default groups if (empty($category_groups_ids)) { $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP')); $category_groups_ids = array_merge($category_groups_ids, $preselected); } foreach ($groups as $group) { $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $category_groups_ids)); } return parent::renderForm(); }
public function renderForm() { if (!($obj = $this->loadObject(true))) { return; } $available_profiles = Profile::getProfiles($this->context->language->id); if ($obj->id_profile == _PS_ADMIN_PROFILE_ && $this->context->employee->id_profile != _PS_ADMIN_PROFILE_) { $this->errors[] = Tools::displayError('You cannot edit the SuperAdmin profile.'); return parent::renderForm(); } $this->fields_form = array('legend' => array('title' => $this->l('Employees'), 'icon' => 'icon-user'), 'input' => array(array('type' => 'text', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => true), array('type' => 'text', 'label' => $this->l('Last Name'), 'name' => 'lastname', 'required' => true), array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'image' => ImageManager::thumbnail($obj->getImage(), $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 150, $this->imageType, true, true), 'col' => 6, 'value' => true, 'display_image' => true), array('type' => 'password', 'label' => $this->l('Password'), 'name' => 'passwd', 'required' => true, 'hint' => $obj->id ? $this->l('Leave this field blank if you do not want to change your password.') : $this->l('Minimum of eight characters.')), array('type' => 'text', 'label' => $this->l('Email address'), 'name' => 'email', 'required' => true, 'autocomplete' => false), array('type' => 'default_tab', 'label' => $this->l('Default page'), 'name' => 'default_tab', 'hint' => $this->l('This page will be displayed just after login.'), 'options' => $this->tabs_list), array('type' => 'select', 'label' => $this->l('Language'), 'name' => 'id_lang', 'required' => true, 'options' => array('query' => Language::getLanguages(false), 'id' => 'id_lang', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Theme'), 'name' => 'bo_theme_css', 'options' => array('query' => $this->themes, 'id' => 'id', 'name' => 'name'), 'onchange' => 'var value_array = $(this).val().split("|"); $("link").first().attr("href", "themes/" + value_array[0] + "/css/" + value_array[1]);', 'hint' => $this->l('Back Office theme.')), array('type' => 'radio', 'label' => $this->l('Admin menu orientation'), 'name' => 'bo_menu', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'bo_menu_on', 'value' => 0, 'label' => $this->l('Top')), array('id' => 'bo_menu_off', 'value' => 1, 'label' => $this->l('Left')))))); if ((int) $this->tabAccess['edit'] && !$this->restrict_edition) { $this->fields_form['input'][] = array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Allow or disallow this employee to log into the Admin panel.')); // if employee is not SuperAdmin (id_profile = 1), don't make it possible to select the admin profile if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) { foreach ($available_profiles as $i => $profile) { if ($available_profiles[$i]['id_profile'] == _PS_ADMIN_PROFILE_) { unset($available_profiles[$i]); break; } } } $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Permission profile'), 'name' => 'id_profile', 'required' => true, 'options' => array('query' => $available_profiles, 'id' => 'id_profile', 'name' => 'name', 'default' => array('value' => '', 'label' => $this->l('-- Choose --')))); if (Shop::isFeatureActive()) { $this->context->smarty->assign('_PS_ADMIN_PROFILE_', (int) _PS_ADMIN_PROFILE_); $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'hint' => $this->l('Select the shops the employee is allowed to access.'), 'name' => 'checkBoxShopAsso'); } } $this->fields_form['submit'] = array('title' => $this->l('Save')); $this->fields_value['passwd'] = false; $this->fields_value['bo_theme_css'] = $obj->bo_theme . '|' . $obj->bo_css; if (empty($obj->id)) { $this->fields_value['id_lang'] = $this->context->language->id; } return parent::renderForm(); }