示例#1
0
/**
 *This function display the bom whith option to edit or delete the categories
 *
 * @author - < Benoît Muret >
 * @param   - elem             array     : the array of each category
 * @param   - father        string     : the father of the category
 *
 * @return  - $out
 *
 * display the bom whith option to edit or delete the categories
 */
function claro_disp_tree($elem, $father, $space)
{
    $out = '';
    if ($elem) {
        $space .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        $num = 0;
        foreach ($elem as $one_faculty) {
            if (!strcmp($one_faculty['code_P'], $father)) {
                $num++;
                $out .= '<tr><td>';
                $out .= $space;
                if ($one_faculty['nb_childs'] > 0) {
                    $out .= '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $one_faculty['id'] . '"> ' . ($one_faculty['visible'] ? '<img src="' . get_icon_url('collapse') . '" alt="-"  />' : '<img src="' . get_icon_url('expand') . '" alt="+"  />') . '</a> ' . '&nbsp;';
                } else {
                    $out .= '&nbsp;° &nbsp;&nbsp;&nbsp;';
                }
                $out .= $one_faculty['name'] . ' (' . $one_faculty['code'] . ') &nbsp;&nbsp;&nbsp;';
                //Number of faculty in this parent
                $nb = 0;
                foreach ($elem as $one_elem) {
                    if (!strcmp($one_elem['code_P'], $one_faculty['code_P'])) {
                        $nb++;
                    }
                }
                //Display the picture to edit and delete a category
                $out .= '</td>' . '<td  align="center">' . '<a href="./admincourses.php?category=' . urlencode($one_faculty['code']) . '">' . get_node_children_count_course($one_faculty['code']) . '</a>';
                $out .= '</td>' . '<td  align="center">' . '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $one_faculty['id'] . '&amp;cmd=rqEdit" >' . '<img src="' . get_icon_url('edit') . '"alt="' . get_lang('Edit') . '" /></a>' . '</td>' . '<td align="center">' . '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $one_faculty['id'] . '&amp;cmd=rqMove" >' . '<img src="' . get_icon_url('move') . '" alt="' . get_lang('Move') . '"  /></a>' . '</td>' . '<td align="center">' . '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $one_faculty['id'] . '&amp;cmd=exDelete"' . 'onclick="javascript:if(!confirm(\'' . clean_str_for_javascript(get_lang('Do you really want to delete the "%categoryCode%" category ?', array('%categoryCode%' => $one_faculty['code']))) . '\')) return false" >' . '<img src="' . get_icon_url('delete') . '" alt="' . get_lang('Delete') . '" /> </a>' . '</td>';
                //Search nbChild of the father
                $nbChild = 0;
                $father = $one_faculty['code_P'];
                foreach ($elem as $fac) {
                    if ($fac['code_P'] == $father) {
                        $nbChild++;
                    }
                }
                //If the number of child is >0, display the arrow up and down
                if ($nb > 1) {
                    $out .= '<td align="center">' . "\n";
                    //If isn't the first child, you can up
                    if ($num > 1) {
                        $out .= '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $one_faculty['id'] . '&amp;cmd=exUp">' . '<img src="' . get_icon_url('move_up') . '" alt="' . get_lang('Move up') . '" /></a>';
                    } else {
                        $out .= '&nbsp;';
                    }
                    $out .= '</td>' . "\n";
                    $out .= '<td align="center">' . "\n";
                    // If isn't the last child, you can down
                    if ($num < $nbChild) {
                        $out .= '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $one_faculty['id'] . '&amp;cmd=exDown">' . '<img src="' . get_icon_url('move_down') . '" alt="' . get_lang('Move down') . '"  /> </a>';
                    } else {
                        $out .= '&nbsp;';
                    }
                    $out .= '</td>' . "\n";
                } else {
                    $out .= '<td>&nbsp;</td>' . "\n" . '<td>&nbsp;</td>' . "\n";
                }
                $out .= '</tr>' . "\n";
                //display the bom of this category
                if ($one_faculty['visible']) {
                    $out .= claro_disp_tree($elem, $one_faculty['code'], $space);
                }
            }
        }
    }
    return $out;
}
示例#2
0
        $form .= ' value="0" />' . "\n" . '<label for="canHaveCoursesChild_0">' . get_lang('No') . '</label>' . "\n" . '<br /><br />' . "\n" . '<span class="required">*</span>&nbsp;' . get_lang('Denotes required fields') . '<br />' . "\n" . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel')) . '</form>' . "\n";
        $dialogBox->form($form);
        break;
    case DISP_FORM_MOVE:
        /**
         * Display information to change root of the category
         */
        $dialogBox->title(get_lang("Change parent's category of %catCode", array('%catCode' => $editedCat_Code)));
        $form = '<form action=" ' . $_SERVER['PHP_SELF'] . '" method="post">' . "\n" . '<input type="hidden" name="id" value="' . $editedCat_Id . '" />' . "\n" . '<input type="hidden" name="cmd" value="exChange" />' . "\n" . '<input type="hidden" name="nameCat" value="' . $editedCat_Name . '" />' . "\n" . '<input type="hidden" name="codeCat" value="' . $editedCat_Code . '" />' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . '<label for="fatherCat"> ' . get_lang('Parent category') . ' </label >' . "\n" . '<select name="fatherCat">' . "\n" . '<option value="NULL" > &nbsp;&nbsp;&nbsp;' . get_conf('siteName') . ' </option>' . "\n";
        //Display each category in the select
        $form .= build_select_faculty($categories, NULL, $editFather, '');
        $form .= '</select><br /><br />' . "\n" . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel')) . '</form>' . "\n";
        $dialogBox->form($form);
        break;
    default:
        //
}
/**
 * Output
 */
$out = '';
$out .= claro_html_tool_title($nameTools);
$out .= $dialogBox->render();
/** 
 * Command and list
 */
$out .= '<p>' . "\n" . '<a class="claroCmd" href="' . $_SERVER['PHP_SELF'] . '?cmd=rqCreate">' . get_lang('Create a category') . '</a>' . "\n" . '</p>' . "\n" . '<table class="claroTable emphaseLine" width="100%" border="0" cellspacing="2">' . "\n" . '<thead>' . "\n" . '<tr class="headerX" align="center" valign="top">' . "\n" . '<th>' . get_lang('Category code') . '</th>' . "\n" . '<th>' . get_lang('Courses') . '</th>' . "\n" . '<th>' . get_lang('Edit') . '</th>' . "\n" . '<th>' . get_lang('Move') . '</th>' . "\n" . '<th>' . get_lang('Delete') . '</th>' . "\n" . '<th colspan="2">' . get_lang('Order') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n" . '<tbody>' . "\n";
$out .= claro_disp_tree($categories, NULL, '');
$out .= '</tbody>' . "\n" . '</table>' . "\n";
$claroline->display->body->appendContent($out);
echo $claroline->display->render();