Exemplo n.º 1
0
function addEntry($aMenu)
{
    $sURLPath = $_SESSION['sURLPath'];
    $link = $aMenu['uri'] == "" ? "" : $sURLPath . "/" . $aMenu['uri'];
    $text = $aMenu['statustext'];
    $content = $aMenu['content'];
    if (!is_null($aMenu['session_var'])) {
        if ($link > "" && $aMenu['session_var_in_uri'] && isset($_SESSION[$aMenu['session_var']])) {
            $link .= "?" . $aMenu['url_parm_name'] . "=" . $_SESSION[$aMenu['session_var']];
        }
        if ($text > "" && $aMenu['session_var_in_text'] && isset($_SESSION[$aMenu['session_var']])) {
            $text .= " " . $_SESSION[$aMenu['session_var']];
        }
    }
    if (substr($content, 1, 10) == '----------') {
        $content = "--------------------";
    }
    if ($aMenu['ismenu']) {
        echo "</p>\n<p>\n";
    }
    if ($link > "") {
        echo "<a class=\"SmallText\" href=\"" . $link . "\">" . $content . "</a>";
    } else {
        echo $content;
    }
    echo "<br>\n";
    if ($aMenu['ismenu']) {
        addSection($aMenu['name']);
    }
}
            editSection();
            exit;
            break;
        case ACTION_DEL:
            $actionType = ACTION_DEL;
            checkNullwithRedirect(ADD_SECTION_PAGE, $_GET[SECTION_ID]);
            delSection();
            exit;
            break;
        case ACTION_ADD:
        default:
            break;
    }
}
checkNullwithRedirect(ADD_SECTION_PAGE, $_GET[SECTION_NAME]);
addSection();
function addSection()
{
    // TODO : Escape String for SQL Statement
    $sectionName = $_GET[SECTION_NAME];
    $redirectPage = SECTION_LIST_PAGE;
    $user = getUserInfo();
    $role = $user->getRole();
    $conn = DBConnection::getConnection($role);
    if ($conn) {
        $result = $conn->insertSection($sectionName);
        header("Location: {$redirectPage}");
        exit;
    }
}
function editSection()
    $cell_width = $GLOBALS["table_width"] / $nombre_colonnes;
    $table_identification->addRow($GLOBALS["style_row"]);
    $table_identification->addCell($cell_width, $GLOBALS["style_cellule_titre"])->addText("Identification du cours", $GLOBALS["style_font_titre"], $GLOBALS["style_align_center"]);
    $table_identification->addRow($GLOBALS["style_row"]);
    $table_identification->addCell($cell_width)->addText("Discipline", null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText($nom_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText($code_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addRow($GLOBALS["style_row"]);
    $table_identification->addCell($cell_width)->addText($ponderation_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText($nombre_unites_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText("test", null, $GLOBALS["style_align_center"]);
    // Fin de la section de l'indentification du cours
    // ----------------------------------------------
    $sections = getsections($_SESSION["id_plancadre"]);
    foreach ($sections as $i => $section) {
        addSection($php_word, $section["titre"], readFrom($_POST['save_path'] . $section["emplacement"] . ".txt"));
    }
    $path_docx = "../plancadre/" . $_SESSION["id_plancadre"] . "_" . $info_plancadre["CodeCours"] . ".docx";
    $php_word->save($path_docx);
    header('Location: ../view/view_create_plancadre.php');
} else {
    if (isset($_POST['open'])) {
        header('Location: ../view/view_elaboration_plancadre.php');
    }
}
function getPlanCadre($id_plancadre)
{
    return fetchPlanCadreElaboration_PlanCadre($id_plancadre);
}
function getPrealableCours($id_cours)
{
function buildPlanCadre($id_plancadre)
{
    $result = fetchAllInfoPlanCadre($id_plancadre);
    $info_plancadre = $result[0];
    $etat = $info_plancadre["Etat"];
    $nom_cours = "Titre du cours : " . $info_plancadre["NomCours"];
    $code_cours = "Numéro du cours : " . $info_plancadre["CodeCours"];
    $nom_programme = $info_plancadre["NomProgramme"];
    $code_programme = $info_plancadre["CodeProgramme"];
    $programme_cours = $nom_programme . "(" . $code_programme . ")";
    $ponderation_cours = "Pondération : " . $info_plancadre["Ponderation"];
    $nombre_unites_cours = "Nombre d'unité(s) : " . $info_plancadre["NombreUnites"];
    $prealable_cours = "Préalable(s) : " . "Aucun";
    $type_enseignement = $info_plancadre['TypeCours'];
    // le nom des fichiers textes serra :
    // clé primaire du plancadre + code ou le nom du cours + le nom de la section
    // exemple : 2_420-EDA-05_PresentationCours.txt
    $path_presentation = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "presentation" . ".txt";
    $path_integration = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "integration" . ".txt";
    $path_evalutation = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "evaluation" . ".txt";
    $path_competences = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "competences" . ".txt";
    $path_apprentissage = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "apprentissage" . ".txt";
    $presentation = ReadFrom($path_presentation);
    $integration = ReadFrom($path_integration);
    $evaluation = ReadFrom($path_evalutation);
    $competences = ReadFrom($path_competences);
    $apprentissage = ReadFrom($path_apprentissage);
    /*
        ----------------------------------------------
        Début de la création du document.
        Le code qui suit pourrait être considéré comme un template si 
        on arrive à le paramétrer correctement.
         ----------------------------------------------
    */
    $php_word = new \PhpOffice\PhpWord\PhpWord();
    // ----------------------------------------------
    // ajout des styles au document
    $php_word->addParagraphStyle("style_align_right", $GLOBALS["style_align_right"]);
    $php_word->addParagraphStyle("style_align_center", $GLOBALS["style_align_center"]);
    $php_word->addTableStyle('style_table', $GLOBALS["style_table"]);
    // ----------------------------------------------
    // ----------------------------------------------
    // Section de l'indentification du cours
    $section_template = $php_word->addSection();
    //
    $nom_etablissement = "Collège Lionel-Groulx";
    $section_template->addText($nom_etablissement);
    $section_template->addText($type_enseignement, null, "style_align_right");
    $section_template->addText($programme_cours, null, "style_align_right");
    switch ($info_plancadre["Etat"]) {
        case 'Adopté':
            if ($info_plancadre["Officiel"] > 0) {
                $titre_document = "Plan-cadre officiel";
            } else {
                $titre_document = "Plan-cadre en archive";
            }
            break;
        case 'Validé':
        case 'Élaboration':
        default:
            $titre_document = "Plan-cadre en élaboration";
            break;
    }
    // espace avant et après le titre du document
    $section_template->addText($GLOBALS["saut_ligne"]);
    $section_template->addText($titre_document, $GLOBALS["style_font_titre"], $GLOBALS["style_align_center"]);
    $section_template->addText($GLOBALS["saut_ligne"]);
    $table_identification = $section_template->addTable('style_table');
    $nombre_colonnes = 3;
    $cell_width = $GLOBALS["table_width"] / $nombre_colonnes;
    $table_identification->addRow($GLOBALS["style_row"]);
    $table_identification->addCell($cell_width, $GLOBALS["style_cellule_titre"])->addText("Identification du cours", $GLOBALS["style_font_titre"], $GLOBALS["style_align_center"]);
    $table_identification->addRow($GLOBALS["style_row"]);
    $table_identification->addCell($cell_width)->addText("Discipline", null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText($nom_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText($code_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addRow($GLOBALS["style_row"]);
    $table_identification->addCell($cell_width)->addText($ponderation_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText($nombre_unites_cours, null, $GLOBALS["style_align_center"]);
    $table_identification->addCell($cell_width)->addText("test", null, $GLOBALS["style_align_center"]);
    // Fin de la section de l'indentification du cours
    // ----------------------------------------------
    // ----------------------------------------------
    // Section de la présentation du cours
    $titre = "Présentation du cours";
    addSection($php_word, $titre, $presentation);
    // Fin de la section de la présentation du cours
    // ----------------------------------------------
    // ----------------------------------------------
    // Section de l'objectif d'intégration
    $titre = "Objectif d'intégration";
    addSection($php_word, $titre, $integration);
    // Fin de la section de l'objectif d'intégration
    // ----------------------------------------------
    // ----------------------------------------------
    // Section de l'évaluation des apprentissages
    $titre = 'Évaluation des apprentissages';
    addSection($php_word, $titre, $evaluation);
    // Fin de la section de l'évaluation des apprentissages
    // ----------------------------------------------
    // ----------------------------------------------
    // Section de l'énoncé des compétences
    $titre_section = "Énoncé des compétences";
    addSection($php_word, $titre, $competences);
    // Fin de la section de l'énoncé des compétences
    // ----------------------------------------------
    // ----------------------------------------------
    // Section des objectifs d'apprentissage
    $titre = "Objectifs d'apprentissage";
    addSection($php_word, $titre, $apprentissage);
    // Fin de la section des objectifs d'apprentissage
    // ----------------------------------------------
    $path_docx = "../plancadre/" . $id_plancadre . "_" . $code_cours . ".docx";
    $php_word->save($path_docx);
}