Пример #1
0
 public static function price($euro)
 {
     $theme = new Theme();
     $theme->set_title("Convertion euro > franc");
     $theme->add_to_body($euro * 6.55957);
     $theme->process_theme(Theme::STRUCT_DEFAULT);
 }
Пример #2
0
 public function page_permissions()
 {
     if (isset($_POST['save-permissions'])) {
         PermissionObject::removeAllPermissions();
         if (isset($_POST['permission'])) {
             foreach ($_POST['permission'] as $perm => $groups) {
                 foreach ($groups as $grp => $d) {
                     PermissionObject::addPermission($grp, $perm);
                 }
             }
         }
         Notification::statusNotify(t("configuration enregistrée"), Notification::STATUS_SUCCESS);
     }
     $defined_permissions = PermissionObject::loadAllPermissions();
     $df = array();
     foreach ($defined_permissions as $p) {
         if (!isset($df[$p->pid])) {
             $df[$p->pid] = array();
         }
         $df[$p->pid][$p->gid] = 1;
     }
     $p = new PermissionsManager();
     $permissions = $p->scanForPermission();
     $groups = GroupObject::loadAll();
     $table = array();
     $hcol = array("");
     $hrow = array();
     foreach ($permissions as $u => $t) {
         $hrow[] = $t;
         $row = array();
         foreach ($groups as $gd => $g) {
             if ($u == 0) {
                 $hcol[] = $g->label;
             }
             $pm = new PermissionObject();
             $pm->loadByName($t);
             $tlabel = "permission[" . $g->gid . "][" . $pm->pid . "]";
             if (isset($df[$pm->pid][$g->gid])) {
                 $row[] = "<input type='checkbox' name='{$tlabel}' id='{$tlabel}' checked='checked'/>";
             } else {
                 $row[] = "<input type='checkbox'  name='{$tlabel}' id='{$tlabel}' />";
             }
         }
         $table[] = $row;
     }
     $theme = new Theme();
     $theme->set_title(t("Permissions déclarées"));
     $table = Themed::tabling($table, $hcol, $hrow);
     $theme->add_to_body("<form method='POST' action=''>{$table} <input type='submit' name='save-permissions' value='" . t("Enregistrer") . "'/></form>");
     $theme->process_theme(Theme::STRUCT_ADMIN);
 }
Пример #3
0
 public function confirmDelete($label)
 {
     $group = new GroupObject();
     if ($group->load_by_label($label)) {
         if (isset($_POST['delete'])) {
             $group = new GroupObject();
             $group->load_by_label($label);
             $group->delete();
             header("Location:" . Page::url("/admin/groups"));
         }
         $theme = new Theme();
         $form = new Form("POST", Page::url("/admin/groups/confirm/{$label}"));
         $link = new FormElement("a", null, t("Retourner à la liste des groupes"), "", "");
         $link->setAttribute("href", Page::url("/admin/groups/"));
         $form->addElement($link);
         $form->addElement(new InputElement("delete", "", t("supprimer le groupe"), "submit"));
         $theme->add_to_body($theme->forming($form));
         $theme->set_title("Confirmer la suppression du groupe {$label}");
         $theme->process_theme(Theme::STRUCT_ADMIN);
     } else {
         header("Location:" . Page::url("/admin/groups?err=notexists"));
     }
 }
Пример #4
0
 public function documentation($rubrique, $sousrubrique = 'index')
 {
     $r = "";
     $rubrique = str_replace(" ", "-", $rubrique);
     if (file_exists("modules/doc/docs/{$rubrique}/{$sousrubrique}.md")) {
         $file = file_get_contents("modules/doc/docs/{$rubrique}/{$sousrubrique}.md");
     } else {
         $file = file_get_contents("modules/doc/docs/notfound.md");
     }
     preg_match('/@title:(.*)/', $file, $matches);
     if (isset($matches[1])) {
         $file = str_replace("@title:" . $matches[1], "", $file);
         Theme::set_title($matches[1]);
     }
     $p = new Parsedown();
     $r = $p->text($file);
     $theme = new Theme();
     $theme->add_to_head("<link rel='stylesheet' href='" . Page::url("/modules/doc/styles/atelier-forest.dark.css") . "'/>");
     $theme->add_to_head("<script src='" . Page::url("/modules/doc/highlight.pack.js") . "'></script>");
     $theme->add_to_head("<script>hljs.initHighlightingOnLoad();</script>");
     $theme->add_to_body("<div style='margin:15px;'>{$r}</div>");
     $theme->process_theme(Theme::STRUCT_ADMIN);
 }
Пример #5
0
 public static function list_of_friends($id_user = null)
 {
     $friends = new FriendshipObject();
     $output = "";
     if ($id_user == null && ($u = User::get_user_logged_id()) != null) {
         $id_user = $u;
     }
     $theme = new Theme();
     $theme->set_title(t("Liste des amis"));
     if ($tab = $friends->loadAllFriends($id_user)) {
         foreach ($tab as $k => $f) {
             $u = new UserObject();
             $u->load($f);
             $output .= "<div class=\"friend_line\">";
             $output .= "<div class=\"friend_line_avatar_area\">";
             $output .= "<div class=\"friend_line_avatar avatar\" style=\"background-image:url(" . $u->get_avatar() . ");\">";
             $output .= $theme->linking(Page::url("/profile/" . $f), "");
             $output .= "</div>";
             $output .= "</div>";
             $output .= "<div class=\"friend_line_name_area\">";
             $output .= "<div class=\"friend_line_name\">";
             $output .= $theme->linking(Page::url("/profile/" . $f), $u->firstname . " " . $u->lastname);
             $output .= "<div class=\"friend_line_name_icon\">";
             $output .= "<i class=\"fa fa-user fa-fw\"></i>";
             $output .= "</div>";
             $output .= "</div>";
             $output .= "</div>";
             $output .= "<div class=\"clear\"></div>";
             $output .= "</div>";
         }
         $theme->add_to_body($output);
     } else {
         Notification::statusNotify(t("Vous n'avez pas encore d'ami. " . $theme->linking(Page::url("/users"), t("Voir la liste des utilisateurs"))), Notification::STATUS_INFO);
     }
     $theme->process_theme(Theme::STRUCT_ADMIN);
     return;
 }
Пример #6
0
 public static function page_config()
 {
     if (isset($_GET['err'])) {
         switch ($_GET['err']) {
             case 'install':
                 Notification::statusNotify(t("Echec de l'installation du widget"), Notification::STATUS_ERROR);
                 break;
             case 'enable':
                 Notification::statusNotify(t("Echec de l'activation du widget"), Notification::STATUS_ERROR);
                 break;
             case 'disable':
                 Notification::statusNotify(t("Echec de la desactivation du widget"), Notification::STATUS_ERROR);
                 break;
             case 'uninstall':
                 Notification::statusNotify(t("Echec de la désinstation du widget"), Notification::STATUS_ERROR);
                 break;
             case 'up':
             case 'down':
                 Notification::statusNotify(t("Echec du changement de priorité du widget"), Notification::STATUS_ERROR);
                 break;
             default:
                 Notification::statusNotify(t("Une erreur inconnue est survenue"), Notification::STATUS_ERROR);
                 break;
         }
     }
     $widget = new Widget();
     $widget->scanForWidget();
     $widgets = WidgetObject::loadAll(true);
     $unistalled_widgets = WidgetObject::loadAll(false);
     $activates = WidgetObject::loadAllActivate();
     $theme = new Theme();
     $theme->set_title(t("Liste des widgets disponibles"));
     $c = count($widgets);
     $a = count($activates);
     $u = count($unistalled_widgets);
     $notification = "";
     $notification .= $c + $u > 1 ? "%cnt widgets disponibles" : ($c + $u == 1 ? "%cnt widget disponible" : "Aucun widget disponible");
     if ($c > 0) {
         $notification .= $a > 1 ? " · %ant widgets activés" : ($a == 1 ? " · %ant widget activé" : "");
         $notification .= $c > 1 ? " · %int widgets installés" : ($c == 1 ? " · %int widget installé" : "");
         $notification .= $u > 1 ? " · %unt widgets désinstallés" : ($u == 1 ? " · %unt widget désinstallé" : "");
     }
     Notification::statusNotify(t("{$notification}", array("%cnt" => $c + $u, "%ant" => $a, "%int" => $c, "%unt" => $u)), Notification::STATUS_INFO);
     $r = array(t("Nom du widget"), t("Etat du widget"), t("Actions"));
     $array = array();
     foreach ($widgets as $k => $w) {
         $uninstall = $theme->linking(Page::url("/admin/view/widget/uninstall/" . $w->widget_name), t("désinstaller"));
         $disable = $theme->linking(Page::url("/admin/view/widget/disable/" . $w->widget_name), t("désactiver"));
         $enable = $theme->linking(Page::url("/admin/view/widget/enable/" . $w->widget_name), t("activer"));
         $up = $theme->linking(Page::url("/admin/view/widget/up/" . $w->widget_name), "<i class='fa fa-arrow-up fa-fw'></i>", false, array("title" => "Monter"));
         $up_disabled = "<span class='link_disabled' title='Monter'><i class='fa fa-arrow-up fa-fw'></i></span>";
         $down = $theme->linking(Page::url("/admin/view/widget/down/" . $w->widget_name), "<i class='fa fa-arrow-down fa-fw'></i>", false, array("title" => "Descendre"));
         $down_disabled = "<span class='link_disabled' title='Descendre'><i class='fa fa-arrow-down fa-fw'></i></span>";
         // Si le widget est activé
         if ($w->activate) {
             $array[] = array($w->widget_name, t("Activé"), $disable, $k == 0 ? $up_disabled : $up, $k == $a - 1 ? $down_disabled : $down);
         } else {
             $array[] = array($w->widget_name, t("Désactivé"), $enable . " - " . $uninstall, $up_disabled, $down_disabled);
         }
     }
     foreach ($unistalled_widgets as $k => $w) {
         $install = $theme->linking(Page::url("/admin/view/widget/install/" . $w->widget_name), t("installer"));
         $up_disabled = "<span class='link_disabled' title='Monter'><i class='fa fa-arrow-up fa-fw'></i></span>";
         $down_disabled = "<span class='link_disabled' title='Descendre'><i class='fa fa-arrow-down fa-fw'></i></span>";
         $array[] = array($w->widget_name, t("Désinstallé"), $install, $up_disabled, $down_disabled);
     }
     $theme->add_to_body($theme->tabling($array, $r));
     $theme->process_theme(Theme::STRUCT_ADMIN);
     return;
 }
Пример #7
0
 public static function forming()
 {
     $form = new Form("POST", Page::url("/forms"));
     $input = new InputElement("login", "Identifiant :", "Pierre");
     $form->addElement($input);
     $form->addElement(new ClosedElement("br"));
     // Balise, Name, Label, Value
     $input = new FormElement("select", "age", "Age :", 10);
     $input->addElement(new FormElement("option", "", "0-10", 0));
     $input->addElement(new FormElement("option", "", "10-20", 10));
     $input->addElement(new FormElement("option", "", "20-30", 20));
     $input->addElement(new FormElement("option", "", "30-40", 30));
     $input->addElement(new FormElement("option", "", "40-50", 40));
     $form->addElement($input);
     $form->addElement(new ClosedElement("br"));
     $input = new FormElement("label", null, "Age : ");
     $input->addClasses("label_input_checkbox_radio");
     $form->addElement($input);
     $input = new InputElement("mabox1", "0-10", 0, "checkbox", "mabox1");
     $input->setAttribute("checked", "checked");
     $form->addElement($input);
     $input = new InputElement("mabox2", "10-20", 10, "checkbox", "mabox2");
     $input->setAttribute("checked", "checked");
     $form->addElement($input);
     $input = new InputElement("mabox3", "20-30", 20, "checkbox", "mabox3");
     $form->addElement($input);
     $input = new InputElement("mabox4", "30-40", 30, "checkbox", "mabox4");
     $input->setAttribute("checked", "checked");
     $input->setAttribute("disabled", "disabled");
     $form->addElement($input);
     $input = new InputElement("mabox5", "40-50", 40, "checkbox", "mabox5");
     $input->setAttribute("disabled", "disabled");
     $form->addElement($input);
     $input = new FormElement("label", null, "Age : ");
     $input->addClasses("label_input_checkbox_radio");
     $form->addElement($input);
     $input = new InputElement("monradio", "0-10", 0, "radio", "monradio1");
     $input->setAttribute("checked", "checked");
     $form->addElement($input);
     $input = new InputElement("monradio", "10-20", 10, "radio", "monradio2");
     $form->addElement($input);
     $input = new InputElement("monradio", "20-30", 20, "radio", "monradio3");
     $form->addElement($input);
     $input = new InputElement("monradio", "30-40", 30, "radio", "monradio4");
     $form->addElement($input);
     $input = new InputElement("monradio", "40-50", 40, "radio", "monradio5");
     $form->addElement($input);
     $input = new FormElement("textarea", "description", t("Description : "), "Test");
     $input->setAttribute("row", 6);
     $input->setAttribute("col", 18);
     $input->addClasses("actualite_area_text");
     $form->addElement($input);
     $form->addElement(new ClosedElement("br"));
     $input = new InputElement("monbutton", null, "Test JS", "button");
     $input->setAttribute("onclick", "alert('Test JS OK');");
     $form->addElement($input);
     $theme = new Theme();
     $theme->process_form($form);
     $theme->process_theme();
 }
Пример #8
0
 public static function page_set_avatar()
 {
     $theme = new Theme();
     if (isset($_FILES['file'])) {
         $file = new FileObject();
         if ($id_file = $file->uploadFile($_FILES['file'])) {
             $u = User::get_user_logged();
             $u->set_avatar($id_file);
             header("location: " . Page::url("/profile"));
             return;
         } else {
             Notification::statusNotify(t("Une erreur s'est produite lors de l'upload."), Notification::STATUS_ERROR);
         }
     }
     $f = new Form("POST", Page::url("/profile/settings/avatar"));
     $f->setAttribute("enctype", "multipart/form-data");
     $t = new InputElement("file", t("Fichier : "), "", "file");
     $f->addElement($t);
     $t = new InputElement("submit-file", "", t("Charger"), "submit");
     $f->addElement($t);
     $formulaire = $theme->forming($f);
     $theme->set_title("Changer mon avatar");
     $theme->add_to_body($formulaire);
     $theme->process_theme(Theme::STRUCT_ADMIN);
     return;
 }
Пример #9
0
 public function discussions()
 {
     if (User::get_user_logged_id() != null) {
         $messages = MessagesDB::getDiscussions(User::get_user_logged_id());
         $theme = new Theme();
         $theme->set_title(t("Messagerie"));
         foreach ($messages as $m) {
             $user = new UserObject();
             $user->load($m->conversation);
             $messagetype = "";
             if ($m->sid == $m->conversation && $m->read == 0) {
                 $messagetype = '<div class="messagerie_bloc_icone"><i class="fa fa-envelope fa-fw" title="Message lu"></i></div>';
             } else {
                 if ($m->sid == $m->conversation && $m->read == 1) {
                     $messagetype = '<div class="messagerie_bloc_icone"><i class="fa fa-envelope fa-fw" title="Message lu"></i></div>';
                 } elseif ($m->rid == $m->conversation && $m->read == 0) {
                     $messagetype = '<div class="messagerie_bloc_icone"><i class="fa  fa-reply fa-fw" title="Réponse envoyée"></i></div>';
                 } else {
                     $messagetype = '<div class="messagerie_bloc_icone"><i class="fa  fa-check fa-fw" title="Réponse envoyée et lu"></i></div>';
                 }
             }
             $theme->add_to_body('<div class="messagerie">
         <div class="messagerie_avatar_area">
             <div class="messagerie_avatar avatar" style="background-image:url(' . $user->get_avatar() . ')">
             </div>
             <div class="messagerie_nom"><a>' . $user->firstname . ' <br/>' . $user->lastname . '</a></div>
         </div>
         <div class="messagerie_bloc ' . ($m->read == 0 && $m->sid == $m->conversation ? "messagerie_bloc_new" : "") . '" onclick="window.location.href=\'' . Page::url("/messages/" . $m->conversation) . '\'">
             <div class="messagerie_bloc_informations"><span>' . $user->firstname . ' ' . $user->lastname . '</span> : 
                 <div class="messagerie_bloc_informations_date"><i class="fa  fa-clock-o fa-fw"></i> ' . date(t("d-m-Y à H:i"), $m->sent_on) . '</div></div>
             <div class="messagerie_bloc_texte">
                 <div class="messagerie_bloc_texte_inside">' . $m->message . '</div>
             </div>' . $messagetype . '</div>
         <div class="clear"></div>
     </div>');
         }
         $theme->process_theme(Theme::STRUCT_DEFAULT);
     }
 }
Пример #10
0
 public static function list_modules()
 {
     if (isset($_GET['err'])) {
         switch ($_GET['err']) {
             case 'install':
                 Notification::statusNotify(t("Echec de l'installation du module"), Notification::STATUS_ERROR);
                 break;
             case 'enable':
                 Notification::statusNotify(t("Echec de l'activation du module"), Notification::STATUS_ERROR);
                 break;
             case 'disable':
                 Notification::statusNotify(t("Echec de la desactivation du module"), Notification::STATUS_ERROR);
                 break;
             case 'uninstall':
                 Notification::statusNotify(t("Echec de la désinstation du module"), Notification::STATUS_ERROR);
                 break;
             default:
                 Notification::statusNotify(t("Une erreur inconnue est survenue"), Notification::STATUS_ERROR);
                 break;
         }
     }
     $modules = self::scan_all_modules();
     $theme = new Theme();
     $theme->set_title(t("Liste des modules disponibles"));
     Notification::statusNotify(t("%cnt modules disponibles", array("%cnt" => count($modules))), Notification::STATUS_INFO);
     $r = array(t("Nom du module"), t("Dépendances"), t("Etat du module"), t("Actions"));
     $array = array();
     foreach ($modules as $m) {
         $install = $theme->linking(Page::url("/admin/modules/install/" . $m['name']), t("installer"));
         $uninstall = $theme->linking(Page::url("/admin/modules/uninstall/" . $m['name']), t("désinstaller"));
         $disable = $theme->linking(Page::url("/admin/modules/disable/" . $m['name']), t("désactiver"));
         $enable = $theme->linking(Page::url("/admin/modules/enable/" . $m['name']), t("activer"));
         $statement = t("activé");
         $link_1 = $disable;
         $link_2 = null;
         if (!self::is_enabled($m['name'])) {
             $statement = t("installé");
             $link_1 = $enable;
             $link_2 = $uninstall;
         }
         if (!self::is_installed($m['name'])) {
             $link_1 = $install;
             $link_2 = null;
             $statement = t("désinstallé");
         }
         if ($m["system_module"] == 1) {
             $rtm = "";
             //t("système");
             $statement = t("système");
         } else {
             $rtm = $link_1 . ($link_2 == null ? "" : " - ") . $link_2;
         }
         $dependencies = "";
         if (isset($m['dependencies'])) {
             $dependencies = implode(", ", $m['dependencies']);
         }
         $array[] = array($m["readablename"], $dependencies, $statement, $rtm);
     }
     usort($array, function ($a, $b) {
         return strcmp($a[2], $b[2]) * 10 + strcmp($a[0], $b[0]);
     });
     $theme->add_to_body($theme->tabling($array, $r));
     $theme->process_theme(Theme::STRUCT_ADMIN);
     return;
 }
Пример #11
0
 public static function page_upload_content()
 {
     $theme = new Theme();
     if (isset($_FILES['file'])) {
         $file = new FileObject();
         if ($file->uploadFile($_FILES['file'])) {
             Notification::statusNotify(t("Le fichier a bien été uploadé."), Notification::STATUS_SUCCESS);
         } else {
             Notification::statusNotify(t("Une erreur s'est produite lors de l'upload."), Notification::STATUS_ERROR);
         }
     }
     $f = new Form("POST", Page::url("/file/upload"));
     $f->setAttribute("enctype", "multipart/form-data");
     $t = new InputElement("file", t("Fichier : "), "", "file");
     $f->addElement($t);
     $t = new InputElement("submit-file", "", t("Charger"), "submit");
     $f->addElement($t);
     $formulaire = $theme->forming($f);
     $theme->set_title("Charger un fichier");
     $theme->add_to_body($formulaire);
     $theme->process_theme(Theme::STRUCT_ADMIN);
     return;
 }