1 |
<?php |
2 |
/** |
3 |
* |
4 |
* |
5 |
* @package openmairie_exemple |
6 |
* @version SVN : $Id: dashboard.php 850 2011-11-23 22:11:30Z fraynaud $ |
7 |
*/ |
8 |
|
9 |
require_once "../obj/utils.class.php"; |
10 |
if (!isset($f)) { |
11 |
$f = new utils(NULL, NULL, _("Tableau de bord")); |
12 |
} |
13 |
|
14 |
|
15 |
/** |
16 |
* |
17 |
*/ |
18 |
function widgetView($f = NULL, |
19 |
$id = NULL, |
20 |
$title = NULL, |
21 |
$content = NULL, |
22 |
$footer = NULL, |
23 |
$type = NULL, |
24 |
$mode_edit = false) { |
25 |
|
26 |
// Ouverture du conteneur du widget |
27 |
echo "<div"; |
28 |
echo " class=\"widget ui-widget ui-widget-content ui-helper-clearfix ui-corner-all\""; |
29 |
echo " id=\"widget_".$id."\""; |
30 |
echo ">\n"; |
31 |
|
32 |
// Titre du widget |
33 |
echo "<div class=\"widget-header "; |
34 |
if ($mode_edit == true) { |
35 |
echo "widget-header-edit widget-header-move "; |
36 |
} |
37 |
echo "ui-widget-header ui-corner-all\">"; |
38 |
echo "<h3>"; |
39 |
echo $title; |
40 |
echo "</h3>"; |
41 |
echo "</div>\n"; |
42 |
|
43 |
// Ouverture du wrapper : Contenu + Footer |
44 |
echo "<div class=\"widget-content-wrapper\">\n"; |
45 |
|
46 |
// Contenu du widget |
47 |
echo "<!-- Start Widget Content -->\n"; |
48 |
echo "<div class=\"widget-content\">\n\n"; |
49 |
// |
50 |
if ($type == "file") { |
51 |
// |
52 |
$file = "../app/widget_".$footer.".php"; |
53 |
$footer = "#"; |
54 |
include $file; |
55 |
} else { |
56 |
// |
57 |
echo $content; |
58 |
} |
59 |
echo "\n\n</div>\n"; |
60 |
echo "<!-- End Widget Content -->\n"; |
61 |
|
62 |
// Footer du widget |
63 |
if ($footer != "#" && $footer != "" && $footer != NULL) { |
64 |
echo "<div class=\"widget-footer\">\n"; |
65 |
echo "<a href='".$footer."' >"; |
66 |
if (isset($footer_title)) { |
67 |
echo $footer_title; |
68 |
} else { |
69 |
echo _("Acceder au lien"); |
70 |
} |
71 |
echo "</a>\n"; |
72 |
echo "</div>\n"; |
73 |
} |
74 |
|
75 |
// Fermeture du wrapper : Contenu + Footer |
76 |
echo "</div>\n"; |
77 |
|
78 |
// Fermeture du conteneur du widget |
79 |
echo "</div>\n"; |
80 |
|
81 |
} |
82 |
|
83 |
/** |
84 |
* Tableau de bord |
85 |
*/ |
86 |
// Ouverture du conteneur #dashboard |
87 |
echo "<div id=\"dashboard\">\n"; |
88 |
// Conteneur permettant de recevoir d'eventuels messages d'erreur des requetes |
89 |
// Ajax |
90 |
echo "<div id=\"info\"></div>\n"; |
91 |
// Ouverture du conteneur de colonnes |
92 |
echo "<div class=\"col".$f->config['dashboard_nb_column']."\">\n"; |
93 |
// On boucle sur chacune des colonnes |
94 |
for ($i = 1; $i <= $f->config['dashboard_nb_column']; $i++) { |
95 |
// Ouverture du conteneur .column |
96 |
echo "<div class=\"column\" id=\"column_".$i."\">\n"; |
97 |
// Requete de selection de tous les widgets de la colonne |
98 |
$sql = "select om_dashboard.om_dashboard, om_widget.om_widget as widget, "; |
99 |
$sql .= "om_widget.libelle as libelle, om_widget.lien as lien, "; |
100 |
$sql .= "om_widget.texte as texte, om_widget.type as type, om_dashboard.position "; |
101 |
$sql .= "from ".DB_PREFIXE."om_dashboard "; |
102 |
$sql .= "inner join ".DB_PREFIXE."om_widget on om_dashboard.om_widget=om_widget.om_widget "; |
103 |
$sql .= "inner join ".DB_PREFIXE."om_utilisateur on om_dashboard.om_profil=om_utilisateur.om_profil "; |
104 |
$sql .= "where om_dashboard.bloc ='C".$i."' and om_utilisateur.login = '".$_SESSION['login']."' "; |
105 |
$sql .= "order by position"; |
106 |
// Execution de la requete |
107 |
$res = $f->db->query($sql); |
108 |
// Logger |
109 |
$f->addToLog("scr/dashboard.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
110 |
// |
111 |
$f->isDatabaseError($res); |
112 |
// On boucle sur chacun des widgets |
113 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
114 |
// Affichage du widget |
115 |
widgetView($f, $row['om_dashboard'], $row['libelle'], $row['texte'], |
116 |
$row['lien'], $row["type"]); |
117 |
} |
118 |
// Fermeture du conteneur .column |
119 |
echo "</div>\n"; |
120 |
} |
121 |
// On affiche un conteneur vide pour avec la propriete clear a both pour |
122 |
// reinitialiser le positionnement des blocs |
123 |
echo "<div class=\"both\"><!-- --></div>\n"; |
124 |
// Fermeture du conteneur de colonnes |
125 |
echo "</div>\n"; |
126 |
// Fermeture du conteneur #dashboard |
127 |
echo "</div>\n"; |
128 |
|
129 |
?> |