99 lines
3.2 KiB
PHP
99 lines
3.2 KiB
PHP
|
<?php
|
||
|
class Helper extends HelperCore {
|
||
|
public static $translationsKeysForAdminCategorieTree = array(
|
||
|
'Home', 'selected', 'selecteds', 'Collapse All', 'Expand All', 'Check All', 'Uncheck All', 'Toggle'
|
||
|
);
|
||
|
|
||
|
public static function renderAdminCategorieTree($trads, $selected_cat = array(), $input_name = 'categoryBox', $use_radio = false, $no_ps=FALSE)
|
||
|
{
|
||
|
if (!$use_radio)
|
||
|
$input_name = $input_name.'[]';
|
||
|
|
||
|
$html = '';
|
||
|
|
||
|
if($no_ps) {
|
||
|
$html .= '<script type="text/javascript">no_ps = true;</script>';
|
||
|
}
|
||
|
if($force_show) {
|
||
|
$html .= '<script type="text/javascript">force_show = true;</script>';
|
||
|
}
|
||
|
|
||
|
$html .= '
|
||
|
<script src="../js/jquery/treeview/jquery.treeview.js" type="text/javascript"></script>
|
||
|
<script src="../js/jquery/treeview/jquery.treeview.async.js" type="text/javascript"></script>
|
||
|
<script src="../js/jquery/treeview/jquery.treeview.edit.js" type="text/javascript"></script>
|
||
|
<script src="../js/admin-categories-tree.js" type="text/javascript"></script>
|
||
|
<script type="text/javascript">
|
||
|
var inputName = "'.$input_name.'";
|
||
|
';
|
||
|
if (sizeof($selected_cat) > 0)
|
||
|
{
|
||
|
if (isset($selected_cat[0]))
|
||
|
$html .= 'var selectedCat = "'.implode(',', $selected_cat).'"';
|
||
|
else
|
||
|
$html .= 'var selectedCat = "'.implode(',', array_keys($selected_cat)).'"';
|
||
|
} else {
|
||
|
$html .= 'var selectedCat = ""';
|
||
|
}
|
||
|
$html .= '
|
||
|
var selectedLabel = \''.$trads['selected'].'\';
|
||
|
var home = \''.$trads['Home'].'\';
|
||
|
var use_radio = '.(int)$use_radio.';
|
||
|
|
||
|
$(document).ready(function() {
|
||
|
$("#toggle_display").unbind("click").click(function(event) {
|
||
|
event.preventDefault();
|
||
|
if($("ul#categories-treeview:visible").length == 0) {
|
||
|
$("ul#categories-treeview").show();
|
||
|
} else {
|
||
|
$("ul#categories-treeview").hide();
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
<link type="text/css" rel="stylesheet" href="../css/jquery.treeview.css" />
|
||
|
';
|
||
|
|
||
|
$html .= '
|
||
|
<div style="background-color:#F4E6C9; width:99%;padding:5px 0 5px 5px;">
|
||
|
<a href="#" id="collapse_all" >'.$trads['Collapse All'].'</a>
|
||
|
- <a href="#" id="expand_all" >'.$trads['Expand All'].'</a>
|
||
|
'.(!$use_radio ? '
|
||
|
- <a href="#" id="check_all" >'.$trads['Check All'].'</a>
|
||
|
- <a href="#" id="uncheck_all" >'.$trads['Uncheck All'].'</a>
|
||
|
' : '').'
|
||
|
- <a id="toggle_display" style="cursor: pointer;" >'.$trads['Toggle'].'</a>
|
||
|
</div>
|
||
|
';
|
||
|
|
||
|
$home_is_selected = false;
|
||
|
foreach($selected_cat AS $cat)
|
||
|
{
|
||
|
if (is_array($cat))
|
||
|
{
|
||
|
if ($cat['id_category'] != 1)
|
||
|
$html .= '<input type="hidden" name="'.$input_name.'" value="'.$cat['id_category'].'" >';
|
||
|
else
|
||
|
$home_is_selected = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if ($cat != 1)
|
||
|
$html .= '<input type="hidden" name="'.$input_name.'" value="'.$cat.'" >';
|
||
|
else
|
||
|
$home_is_selected = true;
|
||
|
}
|
||
|
}
|
||
|
$html .= '
|
||
|
<ul id="categories-treeview" class="filetree" style="display:none">
|
||
|
<li id="1" class="hasChildren">
|
||
|
<span class="folder"> <input type="'.(!$use_radio ? 'checkbox' : 'radio').'" name="'.$input_name.'" value="1" '.($home_is_selected ? 'checked' : '').' onclick="clickOnCategoryBox($(this));" /> '.$trads['Home'].'</span>
|
||
|
<ul>
|
||
|
<li><span class="placeholder"> </span></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>';
|
||
|
return $html;
|
||
|
}
|
||
|
}
|