Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap

This commit is contained in:
Kevin Granger
2013-11-04 14:43:10 +01:00
6 changed files with 490 additions and 5 deletions
+257 -5
View File
@@ -183,7 +183,6 @@ class HomeSlider extends Module
public function getContent()
{
$this->_html .= $this->headerHTML();
$this->_html .= '<h2>'.$this->displayName.'.</h2>';
/* Validate & process */
if (Tools::isSubmit('submitSlide') || Tools::isSubmit('delete_id_slide') ||
@@ -191,14 +190,24 @@ class HomeSlider extends Module
Tools::isSubmit('changeStatus'))
{
if ($this->_postValidation())
{
$this->_postProcess();
$this->_displayForm();
$this->_html .= $this->renderForm();
$this->_html .= $this->renderList();
}
else
$this->_html .= $this->renderAddForm();
}
elseif (Tools::isSubmit('addSlide') || (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide'))))
$this->_displayAddForm();
$this->_html .= $this->renderAddForm();
else
$this->_displayForm();
{
$this->_html .= $this->renderForm();
$this->_html .= $this->renderList();
}
return $this->_html;
}
@@ -456,6 +465,8 @@ class HomeSlider extends Module
/* If edit : checks id_slide */
if (Tools::isSubmit('id_slide'))
{
//d(var_dump(Tools::getValue('id_slide')));
if (!Validate::isInt(Tools::getValue('id_slide')) && !$this->slideExists(Tools::getValue('id_slide')))
$errors[] = $this->l('Invalid id_slide');
}
@@ -774,4 +785,245 @@ class HomeSlider extends Module
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($req);
return ($row);
}
public function renderList()
{
$slides = $this->getSlides();
foreach ($slides as $key => $slide)
$slides[$key]['status'] = $this->displayStatus($slide['id_slide'], $slide['active']);
$this->context->smarty->assign(array(
'link' => $this->context->link,
'slides' => $slides,
));
return $this->display(__FILE__, 'list.tpl');
}
public function renderAddForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Slide informations'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'file_lang',
'label' => $this->l('Select a file:'),
'name' => 'image',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Title:'),
'name' => 'title',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('URL:'),
'name' => 'url',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Legend:'),
'name' => 'legend',
'lang' => true,
),
array(
'type' => 'textarea',
'label' => $this->l('Description:'),
'name' => 'description',
'lang' => true,
),
array(
'type' => 'switch',
'label' => $this->l('Active'),
'name' => 'active_slide',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Yes')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('No')
)
),
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default')
),
);
if (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide')))
{
$slide = new HomeSlide((int)Tools::getValue('id_slide'));
$fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_slide');
$has_picture = true;
foreach (Language::getLanguages(false) as $lang)
if (!isset($slide->image[$lang['id_lang']]))
$has_picture &= false;
if ($has_picture)
$fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'has_picture');
}
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$this->fields_form = array();
$helper->module = $this;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitSlide';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->tpl_vars = array(
'base_url' => $this->context->shop->getBaseURL(),
'language' => array(
'id_lang' => $language->id,
'iso_code' => $language->iso_code
),
'fields_value' => $this->getAddFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
$helper->override_folder = '/';
return $helper->generateForm(array($fields_form));
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Height:'),
'name' => 'HOMESLIDER_HEIGHT',
'suffix' => 'px'
),
array(
'type' => 'text',
'label' => $this->l('Width:'),
'name' => 'HOMESLIDER_WIDTH',
'suffix' => 'px'
),
array(
'type' => 'text',
'label' => $this->l('Speed:'),
'name' => 'HOMESLIDER_SPEED',
'suffix' => 'ms'
),
array(
'type' => 'text',
'label' => $this->l('Pause:'),
'name' => 'HOMESLIDER_PAUSE',
'suffix' => 'ms'
),
array(
'type' => 'switch',
'label' => $this->l('Loop:'),
'name' => 'HOMESLIDER_LOOP',
'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' => 'btn btn-default')
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$this->fields_form = array();
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitSlider';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function getConfigFieldsValues()
{
return array(
'HOMESLIDER_HEIGHT' => Tools::getValue('HOMESLIDER_HEIGHT', Configuration::get('HOMESLIDER_HEIGHT')),
'HOMESLIDER_WIDTH' => Tools::getValue('HOMESLIDER_WIDTH', Configuration::get('HOMESLIDER_WIDTH')),
'HOMESLIDER_SPEED' => Tools::getValue('HOMESLIDER_SPEED', Configuration::get('HOMESLIDER_SPEED')),
'HOMESLIDER_PAUSE' => Tools::getValue('HOMESLIDER_PAUSE', Configuration::get('HOMESLIDER_PAUSE')),
'HOMESLIDER_LOOP' => Tools::getValue('HOMESLIDER_LOOP', Configuration::get('HOMESLIDER_LOOP')),
);
}
public function getAddFieldsValues()
{
$fields = array();
if (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide')))
{
$slide = new HomeSlide((int)Tools::getValue('id_slide'));
$fields['id_slide'] = (int)Tools::getValue('id_slide', $slide->id);
}
else
$slide = new HomeSlide();
$fields['active_slide'] = Tools::getValue('active_slide', $slide->active);
$fields['has_picture'] = true;
$languages = Language::getLanguages(false);
foreach ($languages as $lang)
{
$fields['image'][$lang['id_lang']] = Tools::getValue('image_'.(int)$lang['id_lang']);
$fields['title'][$lang['id_lang']] = Tools::getValue('title_'.(int)$lang['id_lang'], $slide->title[$lang['id_lang']]);
$fields['url'][$lang['id_lang']] = Tools::getValue('url_'.(int)$lang['id_lang'], $slide->url[$lang['id_lang']]);
$fields['legend'][$lang['id_lang']] = Tools::getValue('legend_'.(int)$lang['id_lang'], $slide->legend[$lang['id_lang']]);
$fields['description'][$lang['id_lang']] = Tools::getValue('description_'.(int)$lang['id_lang'], $slide->description[$lang['id_lang']]);
}
return $fields;
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
@@ -0,0 +1,78 @@
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file="helpers/form/form.tpl"}
{block name="field"}
{if $input.type == 'file_lang'}
<div class="row">
{foreach from=$languages item=language}
{if $languages|count > 1}
<div class="translatable-field lang-{$language.id_lang}" {if $language.id_lang != $defaultFormLanguage}style="display:none"{/if}>
{/if}
<div class="col-lg-6">
<input id="{$input.name}_{$language.id_lang}" type="file" name="{$input.name}_{$language.id_lang}" class="hide" />
<div class="dummyfile input-group">
<span class="input-group-addon"><i class="icon-file"></i></span>
<input id="{$input.name}_{$language.id_lang}-name" type="text" class="disabled" name="filename" readonly />
<span class="input-group-btn">
<button id="{$input.name}_{$language.id_lang}-selectbutton" type="button" name="submitAddAttachments" class="btn btn-default">
<i class="icon-folder-open"></i> {l s='Choose a file'}
</button>
</span>
</div>
</div>
{if $languages|count > 1}
<div class="col-lg-2">
<button type="button" class="btn btn-default dropdown-toggle" tabindex="-1" data-toggle="dropdown">
{$language.iso_code}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{foreach from=$languages item=lang}
<li><a href="javascript:hideOtherLanguage({$lang.id_lang});" tabindex="-1">{$lang.name}</a></li>
{/foreach}
</ul>
</div>
{/if}
{if $languages|count > 1}
</div>
{/if}
<script>
$(document).ready(function(){
$('#{$input.name}_{$language.id_lang}-selectbutton').click(function(e){
$('#{$input.name}_{$language.id_lang}').trigger('click');
});
$('#{$input.name}_{$language.id_lang}').change(function(e){
var val = $(this).val();
var file = val.split(/[\\/]/);
$('#{$input.name}_{$language.id_lang}-name').val(file[file.length-1]);
});
});
</script>
{/foreach}
</div>
{/if}
{$smarty.block.parent}
{/block}
@@ -0,0 +1,35 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../../');
@@ -0,0 +1,50 @@
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<fieldset>
<div class="panel-heading">
<i class="icon-list-ul"></i> {l s='Slides list'}
<span class="panel-heading-action">
<a id="desc-product-new" class="list-toolbar-btn" href="{$link->getAdminLink('AdminModules')}&configure=homeslider&addSlide=1">
<label><span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="Add new" data-html="true"><i class="process-icon-new "></i></span></label>
</a>
</span>
</div>
<div id="slidesContent" style="width: 400px; margin-top: 30px;">
<ul id="slides">
{foreach from=$slides item=slide}
<li id="slides_{$slide.id_slide}">
<strong>#{$slide.id_slide}</strong> {$slide.title}
<p style="float: right">
{$slide.status}
<a class="btn btn-primary" href="{$link->getAdminLink('AdminModules')}&configure=homeslider&id_slide={$slide.id_slide}"> {l s='Edit'}</a>
<a class="btn btn-danger" href="{$link->getAdminLink('AdminModules')}&configure=homeslider&delete_id_slide={$slide.id_slide}"> {l s='Delete'}</a>
</p>
</li>
{/foreach}
</ul>
</div>
</fieldset>
@@ -0,0 +1,35 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');