* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/*
* TODO : move HTML code in template files
* TODO : phpDoc on two last methods: includeDatepicker() & bindDatepicker()
*/
class HelperCore
{
public $currentIndex;
public $table;
public $identifier;
public $token;
public $toolbar_btn;
public $ps_help_context;
public $title;
public $show_toolbar = true;
public $context;
public $toolbar_fix = false;
/** @var string Helper tpl folder */
public $base_folder;
/** @var string Controller tpl folder */
public $override_folder;
/**
* @var smartyTemplate base template object
*/
protected $tpl;
/**
* @var string base template name
*/
public $base_tpl = 'content.tpl';
public $tpl_vars = array();
public function __construct()
{
$this->context = Context::getContext();
}
public function setTpl($tpl)
{
$this->tpl = $this->createTemplate($tpl);
}
/**
* Create a template from the override file, else from the base file.
*
* @param string $tpl_name filename
* @return Template
*/
public function createTemplate($tpl_name)
{
// Overrides exists?
if ($this->override_folder && file_exists($this->context->smarty->template_dir[0].$this->override_folder.$tpl_name))
return $this->context->smarty->createTemplate($this->override_folder.$tpl_name);
return $this->context->smarty->createTemplate($this->base_folder.$tpl_name);
}
/**
* default behaviour for helper is to return a tpl fetched
*
* @return void
*/
public function generate()
{
$this->tpl->assign($this->tpl_vars);
return $this->tpl->fetch();
}
/**
*
* @param type $trads values of translations keys
* For the moment, translation are not automatic
* @param type $selected_cat array of selected categories
* Format
* Array
* (
* [0] => 1
* [1] => 2
* )
* OR
* Array
* (
* [1] => Array
* (
* [id_category] => 1
* [name] => Home page
* [link_rewrite] => home
* )
* )
* @param type $input_name name of input
* @return string
*/
public static function renderAdminCategorieTree($trads, $selected_cat = array(), $input_name = 'categoryBox', $use_radio = false, $use_search = false, $disabled_categories = array(), $use_in_popup = false)
{
if (!$use_radio)
$input_name = $input_name.'[]';
$context = Context::getContext();
$context->controller->addCSS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.css');
$context->controller->addJs(array(
_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.js',
_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.async.js',
_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.edit.js',
_PS_JS_DIR_.'admin-categories-tree.js'));
if ($use_search)
$context->controller->addJs(_PS_JS_DIR_.'jquery/plugins/autocomplete/jquery.autocomplete.js');
$html = '
';
$html .= '