mylocation = $mydir . DIRECTORY_SEPARATOR . basename(__FILE__);
$this->base_uri = $site_uri . '/wp-content/plugins/' . $mydir . '/';
register_activation_hook(__FILE__, array(&$this, 'install'));
register_deactivation_hook(__FILE__, array(&$this, 'uninstall'));
add_action('init', array(&$this,'plugin_init'), 1);
add_action('init', array(&$this,'gadgets_init'), 1);
add_action('init',array(&$this,'enqueue_dependancies'));
add_action('init',array(&$this,'handle_ajax'));
add_action('admin_menu', array(&$this,"add_admin_pages"));
add_action('admin_head',array(&$this,'show_header'));
add_action('init',array(&$this,'redirect_index'));
add_action('admin_head',array(&$this,'steal_dashboardmenu'));
}
function install() {
}
function uninstall() {
}
function getpluginoptions() {
if($this->uid == 0) {
$this->plugin_init();
}
$md = get_option("clearskys_dashboard_config");
if(empty($md) || !isset($md['build']) || $md['build'] < $this->build) {
// The options aren't set so set up the defaults here
$uid = $this->uid;
$mdp = get_option("clearskys_dashboard_pages");
if(!isset($md[$uid]['defaultpage']) && isset($md['defaultpage'])) {
// Transfer existing dashboard to a multi user format
if(isset($mdp['page-1'])) {
$mdp[$uid]['page-1'] = $mdp['page-1'];
unset($mdp['page-1']);
update_option("clearskys_dashboard_pages",$mdp);
}
$md[$uid]['defaultpage'] = $md['defaultpage'];
$md[$uid]['skin'] = $md['skin'];
$md[$uid]['show_original'] = $md['show_original'];
$md[$uid]['layout']['columns'] = $md['layout']['columns'];
$md[$uid]['layout']['style'] = $md['layout']['style'];
unset($md['defaultpage']);
unset($md['skin']);
unset($md['show_original']);
unset($md['layout']);
} elseif(!isset($md['defaultpage'])) {
$md[$uid]['skin'] = "default";
$md[$uid]['show_original'] = 0;
$md[$uid]['layout']['columns'] = 3;
$md[$uid]['layout']['style'] = 'even';
$md[$uid]['defaultpage'] = "page-1";
}
$md['build'] = $this->build;
update_option("clearskys_dashboard_config",$md);
}
return $md;
}
function plugin_init() {
// This function is used to setup and declare needed variables
// get the current user id and store it for later use
$user = wp_get_current_user();
$this->uid = (int) $user->id;
}
function ajax_nonce_pass($nonce, $action = -1) {
$adminurl = strtolower(get_option('siteurl')).'/wp-admin';
$referer = strtolower(wp_get_referer());
if (!(-1 == $action && strpos($referer, $adminurl) !== false)) {
return true;
// The lines below are skipped for the moment as I need to work out
// how to create a nonce in javascript.
// So for the moment, only the refering page is checked.
/*
$user = wp_get_current_user();
$uid = (int) $user->id;
$i = ceil(time() / 43200);
//Allow for expanding range, but only do one check if we can
if( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce || substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce )
return true;
return false;
*/
} else {
return false;
}
}
function handle_ajax() {
// This function receives all ajax calls for the gadgets, and passes them off
// to the relevant user functions
if($this->onpage('wp-admin/index.php') && $this->xss_clean($_GET['call']) == '_ajax' && function_exists('current_user_can') && current_user_can('edit_posts')) {
if(!$this->bad_karma() && function_exists('check_admin_referer') && !$this->ajax_nonce_pass('clearskys_dashboard_ajax',$_REQUEST['_wpnonce'])) {
exit();
}
$mdp = get_option("clearskys_dashboard_pages");
$this->load_stored_gadgets();
switch($this->xss_clean($_GET['action'])) {
case "updatecontent":
//echo $this->get_gadget_content($_GET['name']);
echo $this->show_gadget_box($this->xss_clean($_GET['name']));
break;
case "updatetitle":
//echo $this->get_gadget_title($_GET['name']);
break;
case "sendedit";
$sent = $this->xss_clean($_POST['update']);
if($sent != '') {
echo $this->show_gadget_box($sent);
}
break;
case "reordercolumn":
$tcolumn = $this->xss_clean($_GET['column']);
if(isset($mdp[$this->uid]['page-1'][$tcolumn]) && count($mdp[$this->uid]['page-1'][$tcolumn]) > 0) {
// make sure that the column actually exists and it has
// gadgets on it then
// create an array of gadget names in the order we want them
$gadgets = explode('&',$this->xss_clean($_GET['gadgets']));
for($n=0; $n < count($gadgets); $n++) {
$gadgets[$n] = str_replace($tcolumn . '[]=', '', $gadgets[$n]);
}
$newpagelayout = array();
foreach($gadgets as $gad) {
foreach($mdp[$this->uid]['page-1'][$tcolumn] as $ogadget) {
if($ogadget['name'] == $gad) {
array_push($newpagelayout, $ogadget);
break;
}
}
}
// Store the changes back to the database
$mdp[$this->uid]['page-1'][$tcolumn] = $newpagelayout;
update_option("clearskys_dashboard_pages",$mdp);
echo "ok";
} else {
echo "no column";
}
break;
case "movegadget":
$tcolumn = $this->xss_clean($_GET['tocolumn']);
$fcolumn = $this->xss_clean($_GET['fromcolumn']);
if(isset($mdp[$this->uid]['page-1'][$fcolumn]) && isset($mdp[$this->uid]['page-1'][$tcolumn]) && (count($mdp[$this->uid]['page-1'][$fcolumn]) > 0 || count($mdp[$this->uid]['page-1'][$tcolumn]) > 0)) {
// make sure that the columns exist and that there is actually something to move from one
// column to the other.
// Handle the to column first
$gadgets = explode('&',$this->xss_clean($_GET['togadgets']));
for($n=0; $n < count($gadgets); $n++) {
$gadgets[$n] = str_replace($tcolumn . '[]=', '', $gadgets[$n]);
}
$newpagelayout = array();
if(count($gadgets) > 0 && count($this->gadgetinstances) > 0) {
foreach($gadgets as $gad) {
foreach($this->gadgetinstances as $gi) {
if($gi['name'] == $gad) {
array_push($newpagelayout, $gi);
}
}
}
$mdp[$this->uid]['page-1'][$tcolumn] = $newpagelayout;
}
// Now handle the from column first
$gadgets = explode('&',$this->xss_clean($_GET['fromgadgets']));
for($n=0; $n < count($gadgets); $n++) {
$gadgets[$n] = str_replace($fcolumn . '[]=', '', $gadgets[$n]);
}
$newpagelayout = array();
if(count($gadgets) > 0 && count($this->gadgetinstances) > 0) {
foreach($gadgets as $gad) {
foreach($this->gadgetinstances as $gi) {
if($gi['name'] == $gad) {
array_push($newpagelayout, $gi);
}
}
}
$mdp[$this->uid]['page-1'][$fcolumn] = $newpagelayout;
}
update_option("clearskys_dashboard_pages",$mdp);
echo "ok";
} else {
echo "nothing to move";
}
break;
case "removegadget":
$gadget = $this->xss_clean($_GET['gadget']);
if($gadget != "" && $this->gadget_active($gadget)) {
// Check a gadget is passed and that it is active
// remove the gadget from the gadget instances
unset($this->gadgetinstances[$gadget]);
foreach($mdp[$this->uid]['page-1'] as $key=>$col) {
// Go through every column
// get the keys for the column
// need to do this as removing the first item in an array
// causes things to mess up a wee bit otherwise
$akeys = array_keys($col);
for($n = 0; $n < count($akeys); $n++) {
// go through each gadget in the column
if($col[$akeys[$n]]['name'] == $gadget) {
// if the gadget is found
unset($mdp[$this->uid]['page-1'][$key][$akeys[$n]]);
}
}
}
update_option("clearskys_dashboard_pages",$mdp);
echo "ok";
} else {
echo "no gadget to remove";
}
break;
case "addgadget":
if(isset($mdp[$this->uid]['page-1'])) {
// Get the Left hand column
$toadd = $this->xss_clean($_GET['gadget']);
if($toadd != "") {
$toadd = str_replace('addtopage_','',$toadd);
}
$column = $this->get_left_column($mdp[$this->uid]['page-1']);
$gadget = $this->create_gadget_instance($toadd);
if(isset($gadget['name'])) {
array_push($mdp[$this->uid]['page-1'][$column], $gadget);
update_option("clearskys_dashboard_pages",$mdp);
//echo $gadget['name'];
echo $this->show_gadget_box($gadget['name']);
}
}
break;
case "loadlibrary":
echo $this->show_library();
break;
}
// Ensure that the code stops here, otherwise the Wordpress headers are returned as well
exit();
}
}
function call_edit_gadget($name) {
// This function will call the update functionality on the
// gadgets edit callback ready for the gadget to be re-displayed
if($this->gadget_active($name)) {
// get the gadget parent (class) details
$gadgetparent = $this->gadgetinstances[$name]['parent'];
if($this->gadget_registered($gadgetparent)) {
// The parent is registered so we can access the relevant functions
$iam = array( 'name' => $name);
$gp = $this->availablegadgets[$gadgetparent];
if(is_callable($gp['editcallback'])) {
$editresults = call_user_func_array($gp['editcallback'],array( 'args' => $iam));
} else {
$editresults = "
');
}
// we have the template, now create and fill in the box
$this->draw_box($name, $editresults, $contentresults);
}
}
}
function reorder_gadgets($column, $gadgets) {
}
function load_stored_gadgets() {
/*
* This function will load the stored gadgets
* It is primarily used for ajax calls
*
*/
$mdp = get_option("clearskys_dashboard_pages");
if(count($mdp[$this->uid]['page-1']) > 0) {
// columns exist so output them
foreach($mdp[$this->uid]['page-1'] as $key=>$column) {
if(count($column) > 0) {
// there are gadgets in this box
foreach($column as $gadget) {
// check if the gadget is active
// and if it isn't active then load it
if(!$this->gadget_active($gadget['name'])) {
$this->load_gadget_instance($gadget);
}
}
}
}
}
}
function enqueue_dependancies() {
$md = $this->getpluginoptions();
if(($this->onpage('wp-admin/index.php') || $this->onpage('wp-admin/admin.php')) && $this->xss_clean($_GET['page']) == $this->mylocation) {
if(get_bloginfo('version') >= "2.2") {
// jquery native for versions from 2.2 and onwards so enqueue the jquery using standard wordpress calls
wp_enqueue_script('interface');
} else {
// jquery not standard on this version, so use bundled plugin libraries
wp_enqueue_script('jquery', $this->base_uri . 'js/library/jquery-latest.pack.js', array(), '1.1.3');
wp_enqueue_script('interface', $this->base_uri . 'js/library/interface.js', array('jquery'), '1.1.2');
}
//jquery.history_remote.pack.js
wp_enqueue_script('mydashplugins', $this->base_uri . 'js/library/jquery.mydash.js', array(), $this->build);
wp_enqueue_script('mydashboard', $this->base_uri . 'js/mydashboard.js', array(), $this->build);
$this->queueCss('mydashboard.css');
if(isset($md[$this->uid]['skin'])) {
$this->queueCss('skins/' . $md[$this->uid]['skin'] . '/skin.css');
} else {
$this->queueCss('skins/default/skin.css');
}
}
}
function show_header() {
if(count($this->localqueue) > 0) {
foreach($this->localqueue as $key=>$value) {
echo $value . "\n";
}
}
}
function add_admin_pages() {
add_submenu_page('index.php', 'My Dashboard page', 'My Dashboard', 0, __FILE__, array(&$this,'show_dashboard'));
add_submenu_page('themes.php', 'My Dashboard settings', 'My Dashboard', 8, __FILE__, array(&$this,'show_dashboard_layout'));
}
function redirect_index() {
$md = $this->getpluginoptions();
if($md[$this->uid]['show_original'] == '0' && $this->onpage('wp-admin/index.php') && $this->xss_clean($_GET['page']) == '' && $this->xss_clean($_GET['call']) != '_ajax') {
// If the call is for the standard index page and isn't an ajax call
Header('Location: index.php?page=' . $this->mylocation);
}
}
function steal_dashboardmenu() {
global $menu, $submenu;
$md = $this->getpluginoptions();
if($md[$this->uid]['show_original'] == '0') {
if(array_key_exists('index.php',$submenu)) {
// This is all a bit hacky, but we basically perform the following steps
// Check if there is a submenu of index - there should be as we added a sub menu item to it
if(isset($submenu['index.php'])) {
$maindash = -1;
for($n=0; $n < count($submenu['index.php']); $n++) {
// For each submenu item
if($submenu['index.php'][$n][0] == "Dashboard") {
// Oooh found the main Dashboard, so hijack it to be the new Dashboard
$submenu['index.php'][$n][0] = "My Dashboard";
$submenu['index.php'][$n][2] = $this->mylocation;
$maindash = $n;
}
if($submenu['index.php'][$n][0] == "My Dashboard" && $maindash != $n) {
// Found our added submenu (that isn't the one we hijacked earlier)
// We no longer need it, so remove it.
unset($submenu['index.php'][$n]);
}
}
}
// Finally after all our messing around, count the number of sub-menus
// If there is only one, and it is ours, then we don't really need it, so remove it.
if(count($submenu['index.php']) == 1 && $submenu['index.php'][0][0] == "My Dashboard") {
unset($submenu['index.php']);
}
}
}
}
function show_dashboard() {
$md = $this->getpluginoptions();
// Need to check if the initial page exists, otherwise
// this is our first time here, so we need to setup some
// default gadgets.
$mdp = get_option("clearskys_dashboard_pages");
if(!isset($mdp[$this->uid]['page-1'])) {
// No initial page is built so create a default one
$mdp[$this->uid][$md[$this->uid]['defaultpage']] = $this->build_default_page($md[$this->uid]['layout']['columns'], $md[$this->uid]['layout']['style']);
update_option("clearskys_dashboard_pages",$mdp);
}
$layout = $md[$this->uid]['layout'];
switch($layout['columns']) {
case 1:
$style = "singleColumn";
break;
case 2:
switch($layout['style']) {
case 'even':
$styleleft = "doubleColumn";
$styleright = "doubleColumn";
break;
case 'left':
$styleleft = "twothirdsColumn";
$styleright = "onethirdColumn";
break;
case 'right':
$styleleft = "onethirdColumn";
$styleright = "twothirdsColumn";
break;
}
break;
case 3:
$style = "tripleColumn";
break;
}
echo '
';
echo $this->topbar();
echo '
';
echo 'Loading library...';
echo '
';
echo '
';
// change code here to read the page from the page array
if(count($mdp[$this->uid]['page-1']) > 0) {
// columns exist so output them
foreach($mdp[$this->uid]['page-1'] as $key=>$column) {
echo '
';
if(count($column) > 0) {
// there are gadgets in this box
foreach($column as $gadget) {
// check if the gadget is active
// and if it isn't active then load it
if($this->gadget_active($gadget['name']) || $this->load_gadget_instance($gadget)) {
$this->show_gadget_box($gadget['name']);
}
}
}
echo '
';
}
}
echo '
';
echo '
';
}
function show_library() {
if(count($this->availablegadgets) > 0) {
// There are some available gadgets
foreach($this->availablegadgets as $key => $gadget) {
echo "
";
}
echo "";
}
}
function topbar() {
// Will add pages link code here in the fullness of time
// for the moment, here are the administration links
$html = "";
$html .= '
';
return $html;
}
function build_default_page($columns = 3, $layout = 'even') {
$t = array();
for($n = 1; $n <= $columns; $n++) {
$t['column-' . $n] = array();
}
// Get the Right hand column
$column = $this->get_right_column($t);
if($this->gadget_registered('mydash_latest_comments')) {
$gadget = $this->create_gadget_instance('mydash_latest_comments');
array_push($t[$column], $gadget);
}
if($this->gadget_registered('mydash_latest_posts')) {
$gadget = $this->create_gadget_instance('mydash_latest_posts');
array_push($t[$column], $gadget);
}
if($this->gadget_registered('mydash_blog_statistics')) {
$gadget = $this->create_gadget_instance('mydash_blog_statistics');
array_push($t[$column], $gadget);
}
if($this->gadget_registered('mydash_additional_items')) {
$gadget = $this->create_gadget_instance('mydash_additional_items');
array_push($t[$column], $gadget);
}
// Get the Left hand column
$column = $this->get_left_column($t);
if($this->gadget_registered('mydash_quick_links')) {
$gadget = $this->create_gadget_instance('mydash_quick_links');
array_push($t[$column], $gadget);
}
// Get the Middle column
$column = $this->get_middle_column($t);
if($this->gadget_registered('mydash_incoming_links')) {
$gadget = $this->create_gadget_instance('mydash_incoming_links');
array_push($t[$column], $gadget);
}
if($this->gadget_registered('mydash_dev_rss_feed')) {
// Wordpress Development blog
$gadget = $this->create_gadget_instance('mydash_dev_rss_feed');
array_push($t[$column], $gadget);
}
if($this->gadget_registered('mydash_planet_rss_feed')) {
// Other Wordpress news
$gadget = $this->create_gadget_instance('mydash_planet_rss_feed');
array_push($t[$column], $gadget);
}
return $t;
}
function get_gadget_content($name) {
/*
* This function will get the content for a gadget.
* It is usually called via ajax for updating content, such as feeds
*/
if($this->gadget_active($name)) {
// get the gadget parent (class) details
$gadgetparent = $this->gadgetinstances[$name]['parent'];
if($this->gadget_registered($gadgetparent)) {
// The parent is registered so we can access the relevant functions
$iam = array( 'name' => $name);
$gp = $this->availablegadgets[$gadgetparent];
if(is_callable($gp['contentcallback'])) {
$contentresults = call_user_func_array($gp['contentcallback'],array( 'args' => $iam));
if(!is_array($contentresults)) {
$content = $contentresults;
$contentresults = array( 'title' => $gp['title'],
'content' => $content
);
}
} else {
$contentresults = array( 'title' => $gp['title'],
'content' => 'There was a problem accessing this gadget');
}
// we have the template, now create and fill in the box
return $contentresults['content'];
} else {
return "This gadget isn't registered";
}
} else {
return "This gadget isn't active";
}
}
function show_gadget_box($name) {
/*
* This function will call the gadgets functions in order to display the required function
*/
// first check that the gadget actually exists
if($this->gadget_active($name)) {
// get the gadget parent (class) details
$gadgetparent = $this->gadgetinstances[$name]['parent'];
if($this->gadget_registered($gadgetparent)) {
// The parent is registered so we can access the relevant functions
$iam = array( 'name' => $name);
$gp = $this->availablegadgets[$gadgetparent];
if(is_callable($gp['editcallback'])) {
$editresults = call_user_func_array($gp['editcallback'],array( 'args' => $iam));
} else {
$editresults = "
');
}
// we have the template, now create and fill in the box
$this->draw_box($name, $editresults, $contentresults);
}
}
}
function draw_box($name, $editresults = "", $contentresults = array()) {
echo "";
echo '
';
}
function load_gadget_instance($gadget) {
// loads a gadget instance from a page layout
if(isset($gadget['parent']) && $this->gadget_registered($gadget['parent'])) {
// the parent is set and is a registered gadget
if(isset($gadget['name']) && !$this->gadget_active($gadget['name'])) {
// The name is set and the gadget isn't already active
// don't need to really check for allowmultiples as that check should have
// been done when the instance was first added to the column
// add it to the active gadgets array
$this->gadgetinstances[$gadget['name']] = $gadget;
return true;
} else {
return false;
}
} else {
return false;
}
}
function create_gadget_instance($gadget) {
if($this->gadget_registered($gadget)) {
// gagdet is registered so continue
if(!$this->gadget_active($gadget) || $this->availablegadgets[$gadget][allowmultiple] == true) {
// gadget isn't already active or is a gadget that allows multiple instances
// so create an instance
$instance = array();
$instance['parent'] = $gadget;
if($this->availablegadgets[$gadget][allowmultiple] == false) {
// this is a single instance gadget, so use the default name
$name = $gadget;
} else {
// this is a multiple instance gadget, so we need to
// get the next available gadget name
$n = 1;
while(isset($this->gadgetinstances[$gadget . '_' . $n])) {
$n++;
}
$name = $gadget . '_' . $n;
}
$instance['name'] = $name;
// call the creation function for the gadget
//createcallback
if(is_callable($this->availablegadgets[$gadget]['createcallback'])) {
$createresults = call_user_func_array($this->availablegadgets[$gadget]['createcallback'],array( 'args' => $instance));
}
// add it to the active gadgets array
$this->gadgetinstances[$name] = $instance;
// and return it so it can be added to a column
return $instance;
} else {
return false;
}
} else {
return false;
}
}
function can_add_instance($gadget) {
if($this->gadget_registered($gadget)) {
// gagdet is registered so continue
if(!$this->gadget_active($gadget) || $this->availablegadgets[$gadget][allowmultiple] == true) {
return true;
} else {
return false;
}
} else {
return false;
}
}
function gadget_registered($name) {
if(isset($this->availablegadgets[$name])) {
return true;
} else {
return false;
}
}
function gadget_active($name) {
if(isset($this->gadgetinstances[$name])) {
// single instance gadget exists, return true
return true;
} else {
// gadget might be a multiple instance gadget so find keys starting with $name
$foundgadget = false;
$keys = array_keys($this->gadgetinstances);
if(count($keys) > 0) {
// check if there are active gadgets
foreach($keys as $key) {
if(strpos($key,$name) === 0) {
// name exists at the beginning of the string
$foundgadget = true;
break;
}
}
}
return $foundgadget;
}
}
function column_exists() {
}
function get_left_column($page) {
// this function will attempt to return the left column, but in a single column layout
// it will return the single column instead.
if(isset($page['column-1'])) {
return 'column-1';
}
}
function get_middle_column($page, $defaultto = 'left') {
// this function will attempt to return the middle column, but in a two column layout
// will return the left column instead (can be altered by passing 'right' as a parameter)
if(isset($page['column-2'])) {
return 'column-2';
} else {
if($defaultto == 'left') {
return $this->get_left_column($page);
} else {
return $this->get_right_column($page);
}
}
}
function get_right_column($page) {
// this function will attempt to return the right column, but in a single column layout
// it will return the single column instead.
if(isset($page['column-3'])) {
return 'column-3';
} else {
// there isn't a 3rd column, so return the middle column (2) ensuring that
// it defaults to returning the left column on single column pages so we don't get
// a recursion problem.
return $this->get_middle_column($page, 'left');
}
}
function get_skin_data($skin) {
// Get skin meta data function - based on the get_theme_data function
// from WordPress
$skin_data = implode( '', file($skin) );
$skin_data = str_replace ( '\r', '\n', $skin_data );
preg_match( '|Skin Name:(.*)|i', $skin_data, $skin_name );
preg_match( '|Skin URI:(.*)|i', $skin_data, $skin_uri );
preg_match( '|Description:(.*)|i', $skin_data, $description );
preg_match( '|Author:(.*)|i', $skin_data, $author_name );
preg_match( '|Author URI:(.*)|i', $skin_data, $author_uri );
if ( preg_match( '|Version:(.*)|i', $skin_data, $version ) )
$version = trim( $version[1] );
else
$version ='';
$description = wptexturize( trim( $description[1] ) );
$name = $skin_name[1];
$name = trim( $name );
$skin = $name;
$skin_uri = trim( $skin_uri[1] );
if ( '' == $author_uri[1] ) {
$author = trim( $author_name[1] );
} else {
$author = '' . trim( $author_name[1] ) . '';
}
return array( 'Name' => $name, 'Title' => $skin, 'URI' => $skin_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version);
}
function get_skins($skin_root) {
// Get all the skins within the Styles/skins directory.
// each skin should have it's own sub directory within the skins directory
// and should have a file called skin.css as the master style sheet.
// based on the get_themes function from WordPress
$skins = array();
$md = $this->getpluginoptions();
//$skin_root = ABSPATH . 'wp-content/plugins/mydashboard/styles/skins/';
// find all the files in the skins directory
$skin_dir = @ dir($skin_root);
if(!$skin_dir)
return $skins;
while ( ($skin_t = $skin_dir->read()) !== false ) {
if ( is_dir($skin_root . '/' . $skin_t) && is_readable($skin_root . '/' . $skin_t) ) {
if ( $skin_t{0} == '.' || $skin_t == '..' || $skin_t == 'CVS' || $skin_t == '.svn' )
continue;
$stylish_dir = @ dir($skin_root . '/' . $skin_t);
$found_stylesheet = false;
while ( ($skin_file = $stylish_dir->read()) !== false ) {
if ( $skin_file == 'skin.css' ) {
$skins[] = $skin_t;
$found_stylesheet = true;
break;
}
}
}
}
return $skins;
}
function show_dashboard_layout() {
// Control the display and updates of the dashboard options panel
if ( ! current_user_can('manage_options') )
wp_die(__('You are not allowed to modify dashboard options.'));
$md = $this->getpluginoptions();
$site_uri = get_settings('siteurl');
if($this->xss_clean($_POST['submitted']) == 'yes') {
if(function_exists('check_admin_referer')) {
check_admin_referer('clearskys_dashboard_options');
}
if($this->xss_clean($_POST['show_original']) != $md[$this->uid]['show_original']) {
$md[$this->uid]['show_original'] = $this->xss_clean($_POST['show_original']);
}
if($this->xss_clean($_POST['skin']) != $md[$this->uid]['skin']) {
$md[$this->uid]['skin'] = $this->xss_clean($_POST['skin']);
}
update_option("clearskys_dashboard_config",$md);
echo '
Settings updated.
';
}
echo "
";
echo "
My Dashboard settings
";
?>
";
}
function onpage($page) {
$path = $this->xss_clean($_SERVER["SCRIPT_FILENAME"]);
if((stristr($path,$page) || stristr($path,$page."?")) && (stristr($path,get_option('upload_path')) === False)) {
return True;
} else {
return False;
}
}
function queueCss($css) {
if($css != "") {
$plugin_css_uri = $this->base_uri . 'styles/';
$cssstring = "";
$this->localqueue[$css] = $cssstring;
}
}
function register_gagdet($name, $options = array(), $type= 'standard') {
/*
* Registers a gadget as available to be added to the page
* NOTE: This does not add a gadget to the page, the user needs to do that manually.
*
* Available Options:
* id: the main id for the added box - this may end being different if you allow multiple boxes
* title: the title for the box
* link: a link for the box title
* createcallback: a function of array for class/function that displays and handles the setup of the gadget
* editcallback: a function or array for a class/function that displays and handles the edit form
* contentcallback: a function or array for a class/function that displays and handles the content
* allowmultiple: if true, then the user can add multiple instances of your gadget.
*
* The following are for use in the gadget library
*
* icon: the url of a graphic file for the icon, should be 32px by 32px (optional)
* fulltitle: a full title of the gadget
* description: a short description of the gadget
* authorlink: a link to the gadget website (optional)
* authoremail: an email address (optional)
*
* Important, the id you pass in when you register the gadget is not necessarily the id the gadget will
* have when it is loaded on a dashboard page. If you have allowed multiple gadgets to be created
* then the id will be appended with a unique identifier so your callback handles should be able to handle this.
*
*
*/
// set up some defaults in case they aren't passed through
if(!isset($options['allowmultiple'])) {
$options['allowmultiple'] = false;
}
$this->availablegadgets[$name] = $options;
}
function register_column($name, $page = "page-1") {
}
function register_page($name) {
}
function gadgets_init() {
if(function_exists('mydash_register_defaults')) {
mydash_register_defaults();
}
do_action('mydashboard_gadgets_init');
}
function columns_init() {
}
}
function register_mydashboard_gadget($name, $options = array(), $type = 'standard') {
global $CSmydash;
$CSmydash->register_gagdet($name, $options, $type);
}
function register_mydashboard_column($name, $page = "page-1") {
global $CSmydash;
$CSmydash->register_column($name, $page);
}
function register_mydashboard_page($name, $options = array(), $type = 'standard') {
global $CSmydash;
$CSmydash->register_page($name, $options, $type);
}
$CSmydash =& new CSMyDashboard();
?>