';
$tm = satb_update_tabs($tm); // handle any empty or new tabs
satb_debugLog('tabs array',$tm);
satb_debugLog('sidemenus array',$sm);
foreach($tm as $key=>$page){
// loop tabs array
$iscustomtab = sa_tb_array_index(sa_tb_array_index($page,0),'iscustom');
// check if tab is plugin tab
// picky note: built in tabs all use the first level sidemenu item as the default action, all plugins should follow this, arghhh
if( isset($ptabs[$key]) ){
// tab is plugin, so convert lang wrapped titles only and set func and action url parts
$tablink = $SA_ADMINPATH.'load.php?id=' . sa_tb_array_index(sa_tb_array_index($ptabs[$key],0),'func');
$tablink .= '&' . sa_tb_array_index(sa_tb_array_index($ptabs[$key],0),'action');
$title_i18n = true;
} else {
// tab is core
$tablink = sa_tb_array_index(sa_tb_array_index($page,0),'func');
// is tab custom
if($iscustomtab){
$title_i18n = true;
} else {
$title_i18n = false;
}
}
if($key != 'link'){
$menu.= '
';
satb_jsOutput();
}
/**
* Get either a Gravatar URL or complete image tag for a specified email address.
*
* @param string $email The email address
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
* @param boole $img True to return a complete IMG tag False for just the URL
* @param array $atts Optional, additional key/value attributes to include in the IMG tag
* @return String containing either just a URL or a complete image tag
* @source http://gravatar.com/site/implement/images/php/
*/
function satb_get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
$url = 'http://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$s&d=$d&r=$r";
if ( $img ) {
$url = ' $val )
$url .= ' ' . $key . '="' . $val . '"';
$url .= ' />';
}
return $url;
}
function satb_jsOutput(){
?>
$func,'title'=>$title);
return $array;
}
function satb_update_tabs($tm){
// adds or removes tabs as needed
GLOBAL $SATB_MENU_ADMIN;
$smkeys = array_keys($SATB_MENU_ADMIN);
$tmkeys = array_keys($tm);
// new tabs
foreach(array_diff($smkeys,$tmkeys) as $tab){
# $tm = sa_tb_addMenu($tm,$tab,$tab,'');
$tm[$tab][] = array('func'=>$tab,'title'=>$tab,'iscustom'=>true);
}
// empty tabs
foreach(array_diff($tmkeys,$smkeys) as $tab){
unset($tm[$tab]);
}
return $tm;
}
function sa_tb_get_PluginTabs(){
global $plugins;
$sa_plugins = $plugins;
$plugintabs = array();
foreach ($sa_plugins as $hook) {
if($hook['hook'] == 'nav-tab' and (isset($hook['args']) and isset($hook['args'][1]) and isset($hook['args'][2])) ){
# $plugintabs[$hook['args'][1]] = $hook['args'][2];
$plugintabs[$hook['args'][1]][] = array('title'=>$hook['args'][2],'func'=>$hook['args'][0],'action'=> isset($hook['args'][3]) ? $hook['args'][3] : null );
}
}
return $plugintabs;
}
function sa_tb_get_PluginMenus($pluginsidemenus = array(),$page = null){
global $plugins;
$sa_plugins = $plugins;
# satb_debuglog($sa_plugins);
foreach ($sa_plugins as $hook) {
if(substr($hook['hook'],-8,9) == '-sidebar'){
# satb_debuglog($hook);
$tab = str_replace('-sidebar','',$hook['hook']);
if(isset($hook['args']) and isset($hook['args'][0]) and isset($hook['args'][1])){
$allowAll = true; // allow plugins that use their own callbacks instead of createSideMenu, even though it is a terrible idea
if($hook['function'] == 'createSideMenu' or $allowAll){
$pluginsidemenus[$tab][] = array('title'=>$hook['args'][1],'func'=>$hook['args'][0],'action'=> isset($hook['args'][2]) ? $hook['args'][2] : null,'isplugin' => true,'file' => $hook['file'] );
}
}
}
}
# satb_debuglog($pluginsidemenus);
return $pluginsidemenus;
}
function sa_tb_executeheader(){ // assigns assets to queue or header
GLOBAL $SATB;
# debugLog("sa_dev_executeheader");
$PLUGIN_ID = $SATB['PLUGIN_ID'];
$PLUGIN_PATH = $SATB['PLUGIN_PATH'];
$owner = $SATB['owner'];
$regscript = $owner."register_script";
$regstyle = $owner."register_style";
$quescript = $owner."queue_script";
$questyle = $owner."queue_style";
$regstyle($PLUGIN_ID, $PLUGIN_PATH.'assets/css/sa_toolbar.css', '0.1', 'screen');
$questyle($PLUGIN_ID,GSBOTH);
$quescript('jquery',GSBOTH);
}
function SA_tb_register_style($handle, $src, $ver){echo ''."\n";}
function SA_tb_queue_style($name,$where){}
function SA_tb_register_script($handle, $src, $ver, $in_footer=FALSE){echo ''."\n";}
function SA_tb_queue_script($name,$where){}
function sa_tb_user_is_admin(){
GLOBAL $USR;
if (isset($USR) && $USR == get_cookie('GS_ADMIN_USERNAME')) {
return true;
}
}
function sa_tb_array_index($ary,$idx){ // handles all the isset error avoidance bullshit when checking an array for a key that might not exist
if( isset($ary) and isset($idx) and isset($ary[$idx]) ) return $ary[$idx];
}
function satb_is_frontend() {
GLOBAL $base;
if(isset($base)) {
return true;
} else {
return false;
}
}
// add_action('sa_toolbar_disp','satb_hook_test');
function satb_hook_test(){
GLOBAL $SITEURL,$GSADMIN,$SATB,$SATB_MENU_ADMIN,$SATB_MENU_STATIC;
if(SATB_DEBUG == false) return;
// known issues / limitations
// If you do not specify isplugin or iscustom, your string will be i18n decoded and wrapped in {} at this time
// To add a link to an existing sub menu, use the pages name or plugin name as the arrays key
$SATB_MENU_ADMIN['pages'][] = array('title'=>'my custom pages item','func'=>'#','iscustom'=>true);
$SATB_MENU_ADMIN['backups'][] = array('title'=>'my custom backup item','func'=>'#','iscustom'=>true);
// To add a link to a new sub menu, use the arkey for the menu name eg. "custom"
$SATB_MENU_ADMIN['custom'][] = array('title'=>'my custom sub menu item','func'=>'#','iscustom'=>true);
// TO add a single menu item link use 'link' as the page
$SATB_MENU_ADMIN['link'][] = array('title'=>'my custom menu item link','func'=>'#','iscustom'=>true);
// To remove an entire menu, remove it from the array
unset($SATB_MENU_ADMIN['settings']); // remove settings entirely
// To remove specific sub-menu items, you will have to loop through the array and remove items based on your criteria
// * menu items contain a 'file' attribute which can help identify a specific plugins submenus
// To change the edit button
# $SATB_MENU_STATIC['edit'] = array('title'=> 'Custom Edit','url'=>'javascript:alert(\'javacript example\');');
// To change the new page button
# $SATB_MENU_STATIC['new'] = array('title'=> 'Custom New','url'=>$SA_ADMINPATH.'load.php?id=blog&create_post');
$SATB_MENU_STATIC['blog'] = array('title'=> '+ New Blog Post','url'=>$SITEURL.$GSADMIN.'/'.'load.php?id=blog&create_post');
$SATB_MENU_STATIC['special'] = array('title'=> '+ New Special Page','url'=>$SITEURL.$GSADMIN.'/'.'load.php?id=i18n_specialpages&create');
// There is no way to add new top buttons yet, but its in the works.
satb_debugLog($SATB_MENU_ADMIN);
}
?>