* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 1.4 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AdminShopUrl extends AdminTab { public function __construct() { $this->table = 'shop_url'; $this->className = 'ShopUrl'; $this->edit = true; $this->delete = true; $this->_select = 's.name shop_name'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'shop` s ON (s.id_shop = a.id_shop)'; $this->_listSkipDelete = array(1); $this->fieldsDisplay = array( 'id_shop_url' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'domain' => array('title' => $this->l('Domain'), 'width' => 130, 'filter_key' => 'domain'), 'domain_ssl' => array('title' => $this->l('Domain SSL'), 'width' => 130, 'filter_key' => 'domain'), 'uri' => array('title' => $this->l('Uri'), 'width' => 130, 'filter_key' => 'uri'), 'shop_name' => array('title' => $this->l('Shop name'), 'width' => 70), 'main' => array('title' => $this->l('Main URL'), 'align' => 'center', 'activeVisu' => 'main', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'main'), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active')); $this->_fieldsOptions = array('_PS_DIRECTORY_' => array('title' => $this->l('PS directory'), 'desc' => $this->l('Name of the PrestaShop directory on your Web server, bracketed by forward slashes (e.g., /shop/)'), 'validation' => 'isUrl', 'type' => 'text', 'size' => 20, 'default' => _PS_DIRECTORY_, 'visibility' => Shop::CONTEXT_ALL)); parent::__construct(); } public function postProcess() { if (Tools::isSubmit('submitAdd'.$this->table)) { $object = $this->loadObject(true); if ($object->id) { $beforeUpdate = new ShopUrl((int)$object->id); if ($beforeUpdate->main AND !Tools::getValue('main')) $this->_errors[] = Tools::displayError('You must have a main url per shop'); } if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('uri'))) $this->_errors[] = Tools::displayError('A shop url that use this domain and uri already exists'); Tools::generateHtaccess(dirname(__FILE__).'/../../.htaccess', Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Configuration::get('PS_HTACCESS_SPECIFIC')); } if (Tools::isSubmit('submitOptions'.$this->table)) { $baseUrls = array(); if ($_PS_DIRECTORY_ = Tools::getValue('_PS_DIRECTORY_')) $baseUrls['_PS_DIRECTORY_'] = $_PS_DIRECTORY_; rewriteSettingsFile($baseUrls, NULL, NULL); unset($this->_fieldsGeneral['_PS_DIRECTORY_']); } return parent::postProcess(); } protected function afterUpdate($object) { if (Tools::getValue('main')) $object->setMain(); } public function displayForm($isMainTab = true) { parent::displayForm($isMainTab = true); if (!($obj = $this->loadObject(true))) return; echo '
'.($obj->id ? '' : '').'
'.$this->l('Shop Url').'

'.$this->l('Folder of your store ex: ipods for http://yourshopname.com/ipods/, leave empty if no folder.').'
'.$this->l('URL Rewrite must be activated to use this feature.').'

getFieldValue($obj, 'main') ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'main') ? 'checked="checked" ' : '').'/>

'.$this->l('Set this url as main, all urls set to this shop will be redirected to this url.').'

getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>

'.$this->l('Enable or disable URL').'

* '.$this->l('Required field').'
'; } }