public static function changePriority($widget, $direction) { $widgets = WidgetObject::loadAllActivate(); $c = count($widgets); switch ($direction) { case self::WIDGET_CHANGE_PRIORITY_UP: if ($widget->priority > 1) { $voisin_priority = $widget->priority - 1; } else { return false; } break; case self::WIDGET_CHANGE_PRIORITY_DOWN: if ($widget->priority < $c) { $voisin_priority = $widget->priority + 1; } else { return false; } break; default: return false; break; } $voisin = self::loadByPositionAndPriority($widget->position, $voisin_priority); if (sizeof($voisin) == 1) { $voisin[0]->priority = $widget->priority; $widget->priority = $voisin_priority; $voisin[0]->save(); $widget->save(); return true; } return false; }
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; }