\n";
}
/**
* StartRighthandColumn
* Override this for different behavior or special functionality
* for the righthand column. Usual use would be a div open tag.
*/
function StartRighthandColumn()
{
echo '
\n";
}
/**
* DoRecentPages
* Setup method for displaying recent pages.
*/
function DoRecentPages()
{
if (count($this->recent) < 1)
{
$this->LoadRecentPages();
}
$this->DisplayRecentPages();
}
/**
* DisplayRecentPages
* Output Recent Page data. Over-ride this to alter display of Recent Pages information.
* Recent page information is available in $this->recent, which is an array of RecentPage
* objects.
* RecentPage objects contain two useful fields: title and url
*
*/
function DisplayRecentPages()
{
//echo "
\n";
echo '
'.lang('recentpages').'
';
echo "
".lang('recentpages')."
\n";
echo "
\n";
echo "
\n";
}
/**
* OutputHeaderJavascript
* This method can be used to dump out any javascript you'd like into the
* Admin page header. In fact, it can be used to put just about anything into
* the page header. It's recommended that you leave or copy the javascript
* below into your own method if you override this -- it's used by the dropdown
* menu in IE.
*/
function OutputHeaderJavascript()
{
?>
cms->config['root_url'];
echo "/lib/dynamic_tabs/tabs.js\">\n";
}
/**
* OutputFooterJavascript
* This method can be used to dump out any javascript you'd like into the
* Admin page footer.
* It's recommended that you leave or copy the javascript below into your
* own method if you override this -- it's used by bookmarks/recent pages tabs.
*/
function OutputFooterJavascript()
{
echo "";
}
/**
* FixSpaces
* This method converts spaces into a non-breaking space HTML entity.
* It's used for making menus that work nicely
*
* @param str string to have its spaces converted
*/
function FixSpaces($str)
{
$tmp = preg_replace('/\s+/u'," ",$str); // PREG UTF8
if(!empty($tmp)) return $tmp;
else return preg_replace('/\s+/'," ",$str); // bad UTF8
}
/**
* UnFixSpaces
* This method converts non-breaking space HTML entities into char(20)s.
*
* @param str string to have its spaces converted
*/
function UnFixSpaces($str)
{
return preg_replace('/ /'," ",$str);
}
/**
* PopulateAdminNavigation
* This method populates a big array containing the Navigation Taxonomy
* for the admin section. This array is then used to create menus and
* section main pages. It uses aggregate permissions to hide sections for which
* the user doesn't have permissions, and highlights the current section so
* menus can show the user where they are.
*
* @param subtitle any info to add to the page title
*
*/
function PopulateAdminNavigation($subtitle='')
{
if (count($this->menuItems) > 0)
{
// we have already created the list
return;
}
$this->subtitle = $subtitle;
$this->menuItems = array(
// base main menu ---------------------------------------------------------
'main'=>array('url'=>'index.php','parent'=>-1,
'title'=>'CMS',
'description'=>'','show_in_menu'=>true),
'home'=>array('url'=>'index.php','parent'=>'main',
'title'=>$this->FixSpaces(lang('home')),
'description'=>'','show_in_menu'=>true),
// 'dashboard'=>array('url'=>'dashboard.php','parent'=>'main',
// 'title'=>$this->FixSpaces(lang('dashboard')),
// 'description'=>'','show_in_menu'=>true),
'viewsite'=>array('url'=>'../index.php','parent'=>'main',
'title'=>$this->FixSpaces(lang('viewsite')),
'type'=>'external',
'description'=>'','show_in_menu'=>true, 'target'=>'_blank'),
'logout'=>array('url'=>'logout.php','parent'=>'main',
'title'=>$this->FixSpaces(lang('logout')),
'description'=>'','show_in_menu'=>true),
// base content menu ---------------------------------------------------------
'content'=>array('url'=>'topcontent.php','parent'=>-1,
'title'=>$this->FixSpaces(lang('content')),
'description'=>lang('contentdescription'),'show_in_menu'=>$this->HasPerm('contentPerms')),
'pages'=>array('url'=>'listcontent.php','parent'=>'content',
'title'=>$this->FixSpaces(lang('pages')),
'description'=>lang('pagesdescription'),'show_in_menu'=>$this->HasPerm('pagePerms')),
'addcontent'=>array('url'=>'addcontent.php','parent'=>'pages',
'title'=>$this->FixSpaces(lang('addcontent')),
'description'=>lang('addcontent'),'show_in_menu'=>false),
'editpage'=>array('url'=>'editcontent.php','parent'=>'pages',
'title'=>$this->FixSpaces(lang('editpage')),
'description'=>lang('editpage'),'show_in_menu'=>false),
/* 'files'=>array('url'=>'files.php','parent'=>'content',
'title'=>$this->FixSpaces(lang('filemanager')),
'description'=>lang('filemanagerdescription'),'show_in_menu'=>$this->HasPerm('filePerms')),
*/ 'images'=>array('url'=>'imagefiles.php','parent'=>'content',
'title'=>$this->FixSpaces(lang('imagemanager')),
'description'=>lang('imagemanagerdescription'),'show_in_menu'=>$this->HasPerm('filePerms')),
'blobs'=>array('url'=>'listhtmlblobs.php','parent'=>'content',
'title'=>$this->FixSpaces(lang('htmlblobs')),
'description'=>lang('htmlblobdescription'),'show_in_menu'=>$this->HasPerm('htmlPerms')),
'addhtmlblob'=>array('url'=>'addhtmlblob.php','parent'=>'blobs',
'title'=>$this->FixSpaces(lang('addhtmlblob')),
'description'=>lang('addhtmlblob'),'show_in_menu'=>false),
'edithtmlblob'=>array('url'=>'edithtmlblob.php','parent'=>'blobs',
'title'=>$this->FixSpaces(lang('edithtmlblob')),
'description'=>lang('edithtmlblob'),'show_in_menu'=>false),
// base layout menu ---------------------------------------------------------
'layout'=>array('url'=>'toplayout.php','parent'=>-1,
'title'=>$this->FixSpaces(lang('layout')),
'description'=>lang('layoutdescription'),'show_in_menu'=>$this->HasPerm('layoutPerms')),
'template'=>array('url'=>'listtemplates.php','parent'=>'layout',
'title'=>$this->FixSpaces(lang('templates')),
'description'=>lang('templatesdescription'),'show_in_menu'=>$this->HasPerm('templatePerms')),
'addtemplate'=>array('url'=>'addtemplate.php','parent'=>'template',
'title'=>$this->FixSpaces(lang('addtemplate')),
'description'=>lang('addtemplate'),'show_in_menu'=>false),
'edittemplate'=>array('url'=>'edittemplate.php','parent'=>'template',
'title'=>$this->FixSpaces(lang('edittemplate')),
'description'=>lang('edittemplate'),'show_in_menu'=>false),
'currentassociations'=>array('url'=>'listcssassoc.php','parent'=>'template',
'title'=>$this->FixSpaces(lang('currentassociations')),
'description'=>lang('currentassociations'),'show_in_menu'=>false),
'copytemplate'=>array('url'=>'copyemplate.php','parent'=>'template',
'title'=>$this->FixSpaces(lang('copytemplate')),
'description'=>lang('copytemplate'),'show_in_menu'=>false),
'stylesheets'=>array('url'=>'listcss.php','parent'=>'layout',
'title'=>$this->FixSpaces(lang('stylesheets')),
'description'=>lang('stylesheetsdescription'),
'show_in_menu'=>($this->HasPerm('cssPerms') || $this->HasPerm('cssAssocPerms'))),
'addcss'=>array('url'=>'addcss.php','parent'=>'stylesheets',
'title'=>$this->FixSpaces(lang('addstylesheet')),
'description'=>lang('addstylesheet'),'show_in_menu'=>false),
'editcss'=>array('url'=>'editcss.php','parent'=>'stylesheets',
'title'=>$this->FixSpaces(lang('editcss')),
'description'=>lang('editcss'),'show_in_menu'=>false),
'templatecss'=>array('url'=>'templatecss.php','parent'=>'stylesheets',
'title'=>$this->FixSpaces(lang('templatecss')),
'description'=>lang('templatecss'),'show_in_menu'=>false),
// base user/groups menu ---------------------------------------------------------
'usersgroups'=>array('url'=>'topusers.php','parent'=>-1,
'title'=>$this->FixSpaces(lang('usersgroups')),
'description'=>lang('usersgroupsdescription'),'show_in_menu'=>$this->HasPerm('usersGroupsPerms')),
'users'=>array('url'=>'listusers.php','parent'=>'usersgroups',
'title'=>$this->FixSpaces(lang('users')),
'description'=>lang('usersdescription'),'show_in_menu'=>$this->HasPerm('userPerms')),
'adduser'=>array('url'=>'adduser.php','parent'=>'users',
'title'=>$this->FixSpaces(lang('adduser')),
'description'=>lang('adduser'),'show_in_menu'=>false),
'edituser'=>array('url'=>'edituser.php','parent'=>'users',
'title'=>$this->FixSpaces(lang('edituser')),
'description'=>lang('edituser'),'show_in_menu'=>false),
'groups'=>array('url'=>'listgroups.php','parent'=>'usersgroups',
'title'=>$this->FixSpaces(lang('groups')),
'description'=>lang('groupsdescription'),'show_in_menu'=>$this->HasPerm('groupPerms')),
'addgroup'=>array('url'=>'addgroup.php','parent'=>'groups',
'title'=>$this->FixSpaces(lang('addgroup')),
'description'=>lang('addgroup'),'show_in_menu'=>false),
'editgroup'=>array('url'=>'editgroup.php','parent'=>'groups',
'title'=>$this->FixSpaces(lang('editgroup')),
'description'=>lang('editgroup'),'show_in_menu'=>false),
'groupmembers'=>array('url'=>'changegroupassign.php','parent'=>'usersgroups',
'title'=>$this->FixSpaces(lang('groupassignments')),
'description'=>lang('groupassignmentdescription'),'show_in_menu'=>$this->HasPerm('groupMemberPerms')),
'groupperms'=>array('url'=>'changegroupperm.php','parent'=>'usersgroups',
'title'=>$this->FixSpaces(lang('groupperms')),
'description'=>lang('grouppermsdescription'),'show_in_menu'=>$this->HasPerm('groupPermPerms')),
// base extensions menu ---------------------------------------------------------
'extensions'=>array('url'=>'topextensions.php','parent'=>-1,
'title'=>$this->FixSpaces(lang('extensions')),
'description'=>lang('extensionsdescription'),'show_in_menu'=>$this->HasPerm('extensionsPerms')),
'modules'=>array('url'=>'listmodules.php','parent'=>'extensions',
'title'=>$this->FixSpaces(lang('modules')),
'description'=>lang('moduledescription'),'show_in_menu'=>$this->HasPerm('modulePerms')),
'tags'=>array('url'=>'listtags.php','parent'=>'extensions',
'title'=>$this->FixSpaces(lang('tags')),
'description'=>lang('tagdescription'),'show_in_menu'=>$this->HasPerm('taghelpPerms')),
'usertags'=>array('url'=>'listusertags.php','parent'=>'extensions',
'title'=>$this->FixSpaces(lang('usertags')),
'description'=>lang('usertagdescription'),'show_in_menu'=>$this->HasPerm('codeBlockPerms')),
'eventhandlers'=>array('url'=>'eventhandlers.php','parent'=>'extensions',
'title'=>$this->FixSpaces(lang('eventhandlers')),
'description'=>lang('eventhandlerdescription'),'show_in_menu'=>$this->HasPerm('eventPerms')),
'editeventhandler'=>array('url'=>'editevent.php','parent'=>'eventhandlers',
'title'=>$this->FixSpaces(lang('editeventhandler')),
'description'=>lang('editeventshandler'),'show_in_menu'=>false),
'addusertag'=>array('url'=>'adduserplugin.php','parent'=>'usertags',
'title'=>$this->FixSpaces(lang('addusertag')),
'description'=>lang('addusertag'),'show_in_menu'=>false),
'editusertag'=>array('url'=>'edituserplugin.php','parent'=>'usertags',
'title'=>$this->FixSpaces(lang('editusertag')),
'description'=>lang('editusertag'),'show_in_menu'=>false),
// base admin menu ---------------------------------------------------------
'siteadmin'=>array('url'=>'topadmin.php','parent'=>-1,
'title'=>$this->FixSpaces(lang('admin')),
'description'=>lang('admindescription'),'show_in_menu'=>$this->HasPerm('siteAdminPerms')),
'siteprefs'=>array('url'=>'siteprefs.php','parent'=>'siteadmin',
'title'=>$this->FixSpaces(lang('globalconfig')),
'description'=>lang('preferencesdescription'),'show_in_menu'=>$this->HasPerm('sitePrefPerms')),
'pagedefaults'=>array('url'=>'pagedefaults.php','parent'=>'siteadmin',
'title'=>$this->FixSpaces(lang('pagedefaults')),
'description'=>lang('pagedefaultsdescription'),'show_in_menu'=>$this->HasPerm('sitePrefPerms')),
'systeminfo'=>array('url'=>'systeminfo.php','parent'=>'siteadmin',
'title'=>$this->FixSpaces(lang('systeminfo')),
'description'=>lang('systeminfodescription'),
'show_in_menu'=>$this->HasPerm('adminPerms')),
'checksum'=>array('url'=>'checksum.php','parent'=>'siteadmin',
'title'=>$this->FixSpaces(lang('system_verification')),
'description'=>lang('checksumdescription'),
'show_in_menu'=>$this->HasPerm('adminPerms')),
'adminlog'=>array('url'=>'adminlog.php','parent'=>'siteadmin',
'title'=>$this->FixSpaces(lang('adminlog')),
'description'=>lang('adminlogdescription'),'show_in_menu'=>$this->HasPerm('adminPerms')),
// base my prefs menu ---------------------------------------------------------
'myprefs'=>array('url'=>'topmyprefs.php','parent'=>-1,
'title'=>$this->FixSpaces(lang('myprefs')),
'description'=>lang('myprefsdescription'),'show_in_menu'=>true),
'myaccount'=>array('url'=>'edituser.php','parent'=>'myprefs',
'title'=>$this->FixSpaces(lang('myaccount')),
'description'=>lang('myaccountdescription'),'show_in_menu'=>true),
'preferences'=>array('url'=>'editprefs.php','parent'=>'myprefs',
'title'=>$this->FixSpaces(lang('adminprefs')),
'description'=>lang('adminprefsdescription'),'show_in_menu'=>true),
'managebookmarks'=>array('url'=>'listbookmarks.php','parent'=>'myprefs',
'title'=>$this->FixSpaces(lang('managebookmarks')),
'description'=>lang('managebookmarksdescription'),'show_in_menu'=>true),
'addbookmark'=>array('url'=>'addbookmark.php','parent'=>'myprefs',
'title'=>$this->FixSpaces(lang('addbookmark')),
'description'=>lang('addbookmark'),'show_in_menu'=>false),
'editbookmark'=>array('url'=>'editbookmark.php','parent'=>'myprefs',
'title'=>$this->FixSpaces(lang('editbookmark')),
'description'=>lang('editbookmark'),'show_in_menu'=>false),
);
// adjust all the urls to include the session key
foreach( $this->menuItems as $sectionKey => $sectionArray )
{
if( isset($sectionArray['url']) &&
(!isset($sectionArray['type']) || $sectionArray['type'] != 'external' ))
{
$this->menuItems[$sectionKey]['url'] .= '?'.CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY];
}
}
// add in all of the 'system' modules too
global $gCms;
foreach ($this->menuItems as $sectionKey=>$sectionArray)
{
$tmpArray = $this->MenuListSectionModules($sectionKey);
$first = true;
foreach ($tmpArray as $thisKey=>$thisVal)
{
$thisModuleKey = $thisKey;
$counter = 0;
// don't clobber existing keys
if (array_key_exists($thisModuleKey,$this->menuItems))
{
while (array_key_exists($thisModuleKey,$this->menuItems))
{
$thisModuleKey = $thisKey.$counter;
$counter++;
}
}
// if it's not a system module...
if (array_search($thisModuleKey, $gCms->cmssystemmodules) !== FALSE)
{
$this->menuItems[$thisModuleKey]=array('url'=>$thisVal['url'],
'parent'=>$sectionKey,
'title'=>$this->FixSpaces($thisVal['name']),
'description'=>$thisVal['description'],
'show_in_menu'=>true);
// Commenting out this code ensures that the module is thought of as (built in)
// if ($first)
// {
// $this->menuItems[$thisModuleKey]['firstmodule'] = 1;
// $first = false;
// }
// else
// {
// $this->menuItems[$thisModuleKey]['module'] = 1;
// }
}
}
}
// add in all of the modules
foreach ($this->menuItems as $sectionKey=>$sectionArray)
{
$tmpArray = $this->MenuListSectionModules($sectionKey);
$first = true;
foreach ($tmpArray as $thisKey=>$thisVal)
{
$thisModuleKey = $thisKey;
$counter = 0;
// don't clobber existing keys
if (array_key_exists($thisModuleKey,$this->menuItems))
{
while (array_key_exists($thisModuleKey,$this->menuItems))
{
$thisModuleKey = $thisKey.$counter;
$counter++;
}
if( $counter > 0 )
{
continue;
}
}
$this->menuItems[$thisModuleKey]=array('url'=>$thisVal['url'],
'parent'=>$sectionKey,
'title'=>$this->FixSpaces($thisVal['name']),
'description'=>$thisVal['description'],
'show_in_menu'=>true);
if ($first)
{
$this->menuItems[$thisModuleKey]['firstmodule'] = 1;
$first = false;
}
else
{
$this->menuItems[$thisModuleKey]['module'] = 1;
}
}
}
// resolve the tree to be doubly-linked,
// and make sure the selections are selected
foreach ($this->menuItems as $sectionKey=>$sectionArray)
{
// link the children to the parents; a little clumsy since we can't
// assume php5-style references in a foreach.
$this->menuItems[$sectionKey]['children'] = array();
foreach ($this->menuItems as $subsectionKey=>$subsectionArray)
{
if ($subsectionArray['parent'] == $sectionKey)
{
$this->menuItems[$sectionKey]['children'][] = $subsectionKey;
}
}
// set selected
if ($this->script == 'moduleinterface.php')
{
$a = preg_match('/(module|mact)=([^&,]+)/',$this->query,$matches);
if ($a > 0 && $matches[2] == $sectionKey)
{
$this->menuItems[$sectionKey]['selected'] = true;
$this->title .= $sectionArray['title'];
if ($sectionArray['parent'] != -1)
{
$parent = $sectionArray['parent'];
while ($parent != -1)
{
$this->menuItems[$parent]['selected'] = true;
$parent = $this->menuItems[$parent]['parent'];
}
}
}
else
{
$this->menuItems[$sectionKey]['selected'] = false;
}
}
else if (strstr($sectionArray['url'],$this->script) !== FALSE &&
(!isset($sectionArray['type']) || $sectionArray['type'] != 'external'))
{
$this->menuItems[$sectionKey]['selected'] = true;
$this->title .= $sectionArray['title'];
if ($sectionArray['parent'] != -1)
{
$parent = $sectionArray['parent'];
while ($parent != -1)
{
$this->menuItems[$parent]['selected'] = true;
$parent = $this->menuItems[$parent]['parent'];
}
}
}
else
{
$this->menuItems[$sectionKey]['selected'] = false;
}
}
// fix subtitle, if any
if ($subtitle != '')
{
$this->title .= ': '.$subtitle;
}
// generate breadcrumb array
$count = 0;
foreach ($this->menuItems as $key=>$menuItem)
{
if ($menuItem['selected'])
{
$this->breadcrumbs[] = array('title'=>$menuItem['title'], 'url'=>$menuItem['url']);
$count++;
}
}
if ($count > 0)
{
// and fix up the last breadcrumb...
if ($this->query != '' && strpos($this->breadcrumbs[$count-1]['url'],'&') === false)
{
$this->query = preg_replace('/\&/','&',$this->query);
$pos = strpos($this->breadcrumbs[$count-1]['url'],'?');
$tmp = substr($this->breadcrumbs[$count-1]['url'],0,$pos).'?'.$this->query;
$this->breadcrumbs[$count-1]['url'] = $tmp;
}
unset($this->breadcrumbs[$count-1]['url']);
if ($this->subtitle != '')
{
$this->breadcrumbs[$count-1]['title'] .= ': '.$this->subtitle;
}
}
}
/**
* BackUrl
* "Back" Url - link to the next-to-last item in the breadcrumbs
* for the back button.
*/
function BackUrl()
{
$count = count($this->breadcrumbs) - 2;
$urlext='?'.CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY];
if ($count > -1)
{
$txt = $this->breadcrumbs[$count]['url'];
return $txt;
}
else
{
// rely on base href to redirect back to the
// admin home page
return 'index.php'.$urlext;
}
}
/**
* DoTopMenu
* Setup function for displaying the top menu.
*
*/
function DoTopMenu()
{
$this->DisplayTopMenu();
}
/**
* DisplaySectionPages
* Shows admin section pages in the specified section, wrapped in a
* MainMenuItem div. This is used in the top-level section pages.
*
* You can override this if you want to change the
* way it is shown.
*
* @param section - section to display
*/
function DisplaySectionPages($section)
{
if (count($this->menuItems) < 1)
{
// menu should be initialized before this gets called.
// TODO: try to do initialization.
// Problem: current page selection, url, etc?
return -1;
}
foreach ($this->menuItems[$section]['children'] as $thisChild)
{
$thisItem = $this->menuItems[$thisChild];
if (! $thisItem['show_in_menu'] || strlen($thisItem['url']) < 1)
{
continue;
}
echo "
\n";
echo "
".$thisItem['title']."\n";
if (isset($thisItem['description']) && strlen($thisItem['description']) > 0)
{
echo "
";
echo $thisItem['description'];
echo "\n";
}
echo "
\n";
}
}
/**
* HasDisplayableChildren
* This method returns a boolean, based upon whether the section in question
* has displayable children.
*
* @param section - section to test
*/
function HasDisplayableChildren($section)
{
$displayableChildren=false;
foreach($this->menuItems[$section]['children'] as $thisChild)
{
$thisItem = $this->menuItems[$thisChild];
if ($thisItem['show_in_menu'])
{
$displayableChildren = true;
}
}
return $displayableChildren;
}
/**
* TopParent
* This method returns the menu node that is the top-level parent of the node you pass
* to it.
*
* @param section - section (menu tag) to find top-level parent
*/
function TopParent($section)
{
$next = $section;
$node = $this->menuItems[$next];
while ($node['parent'] != -1)
{
$next = $node['parent'];
$node = $this->menuItems[$next];
}
return $next;
}
/**
* ListSectionPages
* This method presents a nice, human-readable list of admin pages and
* modules that are in the specified admin section.
*
*
* @param section - section to display
*/
function ListSectionPages($section)
{
if (! isset($this->menuItems[$section]['children']) || count($this->menuItems[$section]['children']) < 1)
{
return;
}
if ($this->HasDisplayableChildren($section))
{
echo " ".lang('subitems').": ";
$count = 0;
foreach($this->menuItems[$section]['children'] as $thisChild)
{
$thisItem = $this->menuItems[$thisChild];
if (! $thisItem['show_in_menu'] || strlen($thisItem['url']) < 1)
{
continue;
}
if ($count++ > 0)
{
echo ", ";
}
echo "
".$thisItem['title']."";
}
}
}
/**
* DisplayAllSectionPages
*
* Shows all admin section pages and modules. This is used to display the
* admin "main" page.
*
*/
function DisplayAllSectionPages()
{
if (count($this->menuItems) < 1)
{
// menu should be initialized before this gets called.
// TODO: try to do initialization.
// Problem: current page selection, url, etc?
return -1;
}
foreach ($this->menuItems as $thisSection=>$menuItem)
{
if ($menuItem['parent'] != -1)
{
continue;
}
if (! $menuItem['show_in_menu'])
{
continue;
}
echo "
\n";
echo "
".$menuItem['title']."\n";
echo "
";
if (isset($menuItem['description']) && strlen($menuItem['description']) > 0)
{
echo $menuItem['description'];
}
$this->ListSectionPages($thisSection);
echo "\n";
echo "
\n";
}
}
function renderMenuSection($section, $depth, $maxdepth)
{
if ($maxdepth > 0 && $depth> $maxdepth)
{
return;
}
if (! $this->menuItems[$section]['show_in_menu'])
{
return;
}
if (strlen($this->menuItems[$section]['url']) < 1)
{
echo "
".$this->menuItems[$section]['title']."";
return;
}
echo "
menuItems[$section]['url'];
echo "\"";
if (array_key_exists('target', $this->menuItems[$section]))
{
echo " target=" . $this->menuItems[$section]['target'];
}
if ($this->menuItems[$section]['selected'])
{
echo " class=\"selected\"";
}
echo ">";
echo $this->menuItems[$section]['title'];
echo "";
if ($this->HasDisplayableChildren($section))
{
echo "";
foreach ($this->menuItems[$section]['children'] as $child)
{
$this->renderMenuSection($child, $depth+1, $maxdepth);
}
echo "
";
}
echo "";
return;
}
/**
* DisplayTopMenu
* Output Top Menu data. Over-ride this to alter display of the top menu.
*
* @param menuItems an array of associated items; each element has a section, title,
* url, and selection where title and url are strings, and selection is a boolean
* to indicate this is the current selection. You can use the "section" to trap for
* javascript links, etc.
*
* Cruftily written to only support a depth of two levels
*
*/
function DisplayTopMenu()
{
echo "\n";
}
/**
* DisplayFooter
* Displays an end-of-page footer.
*/
function DisplayFooter()
{
?>
\n";
}
/**
* DisplayHTMLStartTag
* Outputs the html open tag. Override at your own risk :)
*/
function DisplayHTMLStartTag()
{
echo $this->cms->nls['direction'] == 'rtl' ? "" : "\n";
}
/**
* DisplayHTMLHeader
* This method outputs the HEAD section of the html page in the admin section.
*/
function DisplayHTMLHeader($showielink = false, $addt = '')
{
global $gCms;
$config =& $gCms->GetConfig();
?>
title ?>
OutputHeaderJavascript(); ?>
\n";
}
/**
* DisplayMainDivStart
*
* Used to output the start of the main div that contains the admin page content
*/
function DisplayMainDivStart()
{
echo "
\n";
}
/**
* DisplayMainDivEnd
*
* Used to output the end of the main div that contains the admin page content
*/
function DisplayMainDivEnd()
{
echo '
';
echo "
\n";
}
/**
* DisplaySectionMenuDivStart
* Outputs the open div tag for the main section pages.
*/
function DisplaySectionMenuDivStart()
{
echo "
\n";
}
/**
* DisplaySectionMenuDivEnd
* Outputs the close div tag for the main section pages.
*/
function DisplaySectionMenuDivEnd()
{
echo "
\n";
}
/**
* AddToDashboard
*/
function AddNotification($priority,$module,$html)
{
if( !is_array($this->_notificationitems) )
{
$this->_notificationitems = array(array(),array(),array());
}
if( $priority < 1 ) $priority = 1;
if( $priority > 3 ) $priority = 3;
$this->_notificationitems[$priority-1][] = array($module,$html);
}
function DisplayNotifications($priority=2)
{
if( !is_array($this->_notificationitems) ) return;
// count the total number of notifications
$count=0;
for( $i = 1; $i <= $priority; $i++ )
{
$count += count($this->_notificationitems[$i-1]);
}
// Define that is singular or plural
$singular_or_plural = $count;
if($singular_or_plural > 1)
{
$notifications = lang('notifications_to_handle',$count);
}
else
{
$notifications = lang('notification_to_handle',$count);
}
// remove html tags like
2
$no_html_tags = preg_replace('/(<\/?)(\w+)([^>]*>)/e','',$notifications);
echo '
'."\n";
echo '
' . $notifications . '
'."\n";
echo '
'."\n";
/* echo "
""
\n";*/
echo '
'."\n";
echo "
\n";
for( $i = 1; $i <= $priority; $i++ )
{
if( count($this->_notificationitems) < $i ) break;
if( count($this->_notificationitems[$i-1]) == 0 ) continue;
foreach( $this->_notificationitems[$i-1] as $data )
{
echo '- ';
echo ''."\n";
echo $data[0]."\n";
echo "\n";
echo ''."\n";
echo $data[1]."\n";
echo "\n";
echo '
';
}
}
echo "
";
echo "
\n";
echo "
\n";
echo "
\n";
}
/**
* DisplayDashboardCallout
* Outputs warning if the install directory is still there.
*
* @param file file or dir to check for
* @param message to display if it does exist
*/
function DisplayDashboardCallout($file, $message = '')
{
if ($message == '')
$message = lang('installdirwarning');
echo "
\n";
if (file_exists($file))
{
echo '
'.$message.'
';
}
echo "
\n";
}
/**
* DisplayDashboardPageItem
* Outputs an item on the dashboard page
*
* @param itemtype to display, start/end/core/module
* @param output to display
*/
function DisplayDashboardPageItem($item="module", $title='', $content = '')
{
switch ($item) {
case "start" : return;
case "end" : return;
case "core" :
case "module" : {
echo "
";
echo "
".$title."
";
echo $content."";
}
}
}
/**
* DisplayImage will display the themed version of an image (if it exists),
* or the version from the default theme otherwise.
* @param imageName - name of image
* @param alt - alt text
* @param width
* @param height
*/
function DisplayImage($imageName, $alt='', $width='', $height='', $class='')
{
if (! isset($this->imageLink[$imageName]))
{
if (strpos($imageName,'/') !== false)
{
$imagePath = substr($imageName,0,strrpos($imageName,'/')+1);
$imageName = substr($imageName,strrpos($imageName,'/')+1);
}
else
{
$imagePath = '';
}
if (file_exists(dirname($this->cms->config['root_path'] . '/' . $this->cms->config['admin_dir'] .
'/themes/' . $this->themeName . '/images/' . $imagePath . $imageName) . '/'. $imageName))
{
$this->imageLink[$imageName] = 'themes/' .
$this->themeName . '/images/' . $imagePath . $imageName;
}
else
{
$this->imageLink[$imageName] = 'themes/default/images/' . $imagePath . $imageName;
}
}
$retStr = '

cms;
$config =& $cms->GetConfig();
$header = '';
return $header;
}
/**
* _ArraySearchRecursive
* recursively descend an arbitrarily deep multidimensional
* array, stopping at the first occurence of scalar $needle.
* return the path to $needle as an array (list) of keys
* if not found, return null.
* (will infinitely recurse on self-referential structures)
* From: http://us3.php.net/function.array-search
*/
function _ArraySearchRecursive($needle, $haystack)
{
$path = NULL;
$keys = array_keys($haystack);
while (!$path && (list($toss,$k)=each($keys))) {
$v = $haystack[$k];
if (is_scalar($v)) {
if ($v===$needle) {
$path = array($k);
}
} elseif (is_array($v)) {
if ($path=$this->_ArraySearchRecursive( $needle, $v )) {
array_unshift($path,$k);
}
}
}
return $path;
}
/**
* ShowError
* Outputs supplied errors with a link to the wiki for troublshooting.
*
* @param errors - array or string of 1 or more errors to be shown
* @param get_var - Name of the _GET variable that contains the
* name of the message lang string
*/
function ShowErrors($errors, $get_var = '')
{
global $gCms;
$config =& $gCms->GetConfig();
$wikiUrl = $config['wiki_url'];
if ($wikiUrl !='none'){
if (FALSE == empty($_REQUEST['module']) || FALSE == empty($_REQUEST['mact']))
{
if (FALSE == empty($_REQUEST['module']))
{
$wikiUrl .= '/'.$_REQUEST['module'];
}
else
{
$wikiUrl .= '/'.substr($_REQUEST['mact'], 0, strpos($_REQUEST['mact'], ','));
}
}
$wikiUrl .= '/Troubleshooting';
}//wiki check
$image_error = $this->DisplayImage('icons/system/stop.gif', lang('error'),'','','systemicon');
$output = '
';
}
$output .= '';
}
else
{
$output .= $image_error.' '.$errors;
}
if ($wikiUrl !='none'){
$output .= '
'.lang('troubleshooting').'';
}//wiki check
$output .= '
';
return $output;
}
/**
* ShowMessage
* Outputs a page status message
*
* @param message - Message to be shown
* @param get_var - Name of the _GET variable that contains the
* name of the message lang string
*/
function ShowMessage($message, $get_var = '')
{
$image_done = $this->DisplayImage('icons/system/accept.gif', lang('success'), '','','systemicon');
$output = '
';
return $output;
}
function &GetThemeObject()
{
global $gCms;
$config =& $gCms->GetConfig();
$themeName = get_preference(get_userid(), 'admintheme', 'default');
$themeObjectName = $themeName."Theme";
$userid = get_userid();
if (file_exists(dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.$config['admin_dir']."/themes/${themeName}/${themeObjectName}.php"))
{
include(dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.$config['admin_dir']."/themes/${themeName}/${themeObjectName}.php");
$themeObject = new $themeObjectName($gCms, $userid, $themeName);
}
else
{
$themeObject = new AdminTheme($gCms, $userid, $themeName);
}
$gCms->variables['admintheme']=&$themeObject;
return $themeObject;
}
function GetAdminPageDropdown($name,$selected)
{
$opts = array();
$opts[ucfirst(lang('none'))] = '';
$depth = 0;
foreach( $this->menuItems as $sectionKey=>$menuItem )
{
if( $menuItem['parent'] != -1 )
{
continue;
}
if( !$menuItem['show_in_menu'] || strlen($menuItem['url']) < 1 )
{
continue;
}
$opts[$menuItem['title']] = $menuItem['url'];
if( is_array($menuItem['children']) &&
count($menuItem['children']) )
{
foreach( $menuItem['children'] as $thisChild )
{
if( $thisChild == 'home' || $thisChild == 'logout' ||
$thisChild == 'viewsite')
{
continue;
}
$menuChild = $this->menuItems[$thisChild];
if( !$menuChild['show_in_menu'] || strlen($menuChild['url']) < 1 )
{
continue;
}
$opts[' '.$menuChild['title']] = cms_htmlentities($menuChild['url']);
}
}
}
$output = '