public static function addWidget($data, $callback, $settings = NULL)
 {
     // CHECK
     if (!is_array($data)) {
         return false;
     }
     if (!isset($data["id"], $data["title"])) {
         return false;
     }
     if (!is_callable($callback)) {
         return false;
     }
     if ($settings !== NULL && !is_callable($settings)) {
         return false;
     }
     // CHECK CALLBACKs
     if (isset($data["enable"]) && !is_callable($data["enable"])) {
         return false;
     }
     if (isset($data["disable"]) && !is_callable($data["disable"])) {
         return false;
     }
     if (isset($data["uninstall"]) && !is_callable($data["uninstall"])) {
         return false;
     }
     // CREATE WIDGET ARRAY
     $widget = array();
     foreach (self::$validate as $key) {
         $widget[$key] = "";
         if (isset($data[$key])) {
             $widget[$key] = $data[$key];
         } else {
             if ($key == "size") {
                 $widget[$key] = 1;
             }
         }
     }
     $widget["callback"] = $callback;
     $widget["settings_cb"] = $settings;
     // ADD WIDGET
     $add[$data["id"]] = $widget;
     self::$widgets = array_merge(self::$widgets, $add);
     return true;
 }
<?php

/*
|	Dashboard - Wolf CMS Dashboard Plugin
|	@file		./disable.php
|	@author		SamBrishes <*****@*****.**>
|	@version	1.1.1 [1.1.0] - Alpha
|
|	@license	X11 / MIT License
|	@copyright	Copyright © 2015 SamBrishes, pytesNET
|				Copyright © 2011-2015 Martijn van der Kleijn <*****@*****.**>
|				Copyright © 2008-2011 Mika Tuupola
*/
if (!defined("IN_CMS")) {
    die;
}
// INCLUDE WIDGET CLASS
include_once dirname(__FILE__) . "/system/DashboardWidgets.php";
// CALL WIDGET CALLBACKs
DashboardWidgets::loadWidgets();
$widgets = DashboardWidgets::$widgets;
foreach ($widgets as $key => $value) {
    if (!empty($value["disable"]) && is_callable($value["disable"])) {
        call_user_func($value["disable"]);
    }
}
function dashboard_widgets_validate($data)
{
    $dashboard_widgets = new DashboardWidgets();
    if (strpos($data['fn'], "edit")) {
        $type = "edit";
    }
    if (strpos($data['fn'], "delete")) {
        $type = "delete";
    }
    if (strpos($data['fn'], "create")) {
        $type = "create";
    }
    return $dashboard_widgets->_validate($data, $type, false);
}
Beispiel #4
0
}
define("DASHBOARD_LOG_EMERG", 0);
define("DASHBOARD_LOG_ALERT", 1);
define("DASHBOARD_LOG_CRIT", 2);
define("DASHBOARD_LOG_ERR", 3);
define("DASHBOARD_LOG_WARNING", 4);
define("DASHBOARD_LOG_NOTICE", 5);
define("DASHBOARD_LOG_INFO", 6);
define("DASHBOARD_LOG_DEBUG", 7);
/*
|	REGISTER WIDGET
*/
AutoLoader::addFile("DateDifference", dirname(__FILE__) . DS . "DateDifference.php");
AutoLoader::addFile("DashboardLogEntry", dirname(__FILE__) . DS . "DashboardLogEntry.php");
AutoLoader::addFile("DashboardEvents", dirname(__FILE__) . DS . "DashboardEvents.php");
DashboardWidgets::addWidget(array("id" => "events", "title" => "Event Logbook", "description" => __("Keep up to date with what is happening with your site."), "enable" => "dashboard_events_widget_enable", "disable" => "dashboard_events_widget_disable", "uninstall" => "dashboard_events_widget_uninstall"), "dashboard_events_widget_render");
// INIT CLASS
global $dashboardEvents;
$dashboardEvents = new DashboardEvents();
/*
|	ENABLE EVENTS WIDGET
*/
function dashboard_events_widget_enable()
{
    $conn = Record::getConnection();
    $driver = strtolower($conn->getAttribute(PDO::ATTR_DRIVER_NAME));
    // MySQL SCHEMA
    if ($driver === "mysql") {
        $conn->exec("CREATE TABLE " . TABLE_PREFIX . "dashboard_log(\n\t\t\t\tid          INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tident       CHAR(16) NOT NULL,\n\t\t\t\tpriority    INT NOT NULL,\n\t\t\t\tmessage     VARCHAR(255),\n\t\t\t\tusername    VARCHAR(64),\n\t\t\t\tcreated_on  DATETIME DEFAULT NULL,\n\t\t\t\tPRIMARY KEY (id)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
    }
    // SQLite SCHEMA
 public function index()
 {
     // WIDGET SETTINGS
     if (get_request_method() == "POST" && isset($_POST["widget_action"]) && isset($_POST["widget_secure_token"])) {
         if (DashboardWidgets::setWidgetSettings($_POST["widget_action"], $_POST)) {
             redirect(get_url("plugins/dashboard"));
             die;
         }
     }
     // RENDER DASHBOARD
     ob_start();
     $this->renderDashboard();
     $this->content = ob_get_contents();
     ob_end_clean();
     // OUTPUT
     $render = new View("../layouts/backend", array("content_for_layout" => $this->content));
     $output = $render->render();
     print $output;
 }
Beispiel #6
0
<?php

/*
|	Dashboard - Wolf CMS Dashboard Plugin
|	@file		./widgets/rss_reader/index.php
|	@author		SamBrishes <*****@*****.**>
|	@version	1.1.1 [1.1.0] - Alpha
|
|	@license	X11 / MIT License
|	@copyright	Copyright © 2015 SamBrishes, pytesNET
*/
if (!defined("IN_CMS")) {
    die;
}
/*
|	REGISTER WIDGET
*/
AutoLoader::addFile("DashboardRSSReader", dirname(__FILE__) . DS . "class.rss-reader.php");
DashboardWidgets::addWidget(array("id" => "rss_reader", "size" => 1, "title" => "RSS Feed Reader", "description" => __("A small RSS Feed Reader"), "settings" => array("fetch_method" => "javascript", "rss_url" => "http://www.wolfcms.org/rss.xml", "show_items" => 3, "max_chars" => 235)), "DashboardRSSReader::renderWidget", "DashboardRSSReader::renderSettings");
Observer::observe("dashboard_load_css", "DashboardRSSReader::loadStylesheet");
Observer::observe("dashboard_load_js", "DashboardRSSReader::loadJavascript");