_SetInitialValues($cms, $userid, $themeName); } public function __get($key) { if( $key == 'menuItems' ) { return $this->get_admin_navigation(); } elseif ( $key == 'breadcrumbs' ) { return $this->get_breadcrumbs(); } return parent::__get($key); } /** * Sets object to some sane initial values */ private function _SetInitialValues($cms, $userid, $themeName) { $this->themeName = $themeName; $this->title = ''; $this->subtitle = ''; } /** * DoBookmarks * Setup method for displaying admin bookmarks. */ function DoBookmarks() { $gCms = cmsms(); $bookops = $gCms->GetBookmarkOperations(); $urlext='?'.CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY]; $marks = array_reverse($bookops->LoadBookmarks($this->userid)); $tmpMark = new Bookmark(); $tmpMark->title = lang('addbookmark'); $tmpMark->url = 'makebookmark.php'.$urlext.'&title='. urlencode($this->title); $marks[] = $tmpMark; $marks = array_reverse($marks); $tmpMark = new Bookmark(); $tmpMark->title = lang('managebookmarks'); $tmpMark->url = 'listbookmarks.php'.$urlext; $marks[] = $tmpMark; $this->DisplayBookmarks($marks); } /** * DoBookmarks * Method for displaying admin bookmarks (shortcuts) & help links. */ function ShowShortcuts() { if (get_preference($this->userid, 'bookmarks')) { $urlext='?'.CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY]; echo "
\n"; echo '
'; echo '
'; echo '

'.lang('bookmarks').'

'; echo '

'.lang('managebookmarks').'

'; $gCms = cmsms(); $bookops = $gCms->GetBookmarkOperations(); $marks = array_reverse($bookops->LoadBookmarks($this->userid)); $marks = array_reverse($marks); if (FALSE == empty($marks)) { echo '

'.lang('user_created').'

'; echo '\n"; } echo '

'.lang('help').'

'; echo ''; echo '
'; echo '
'; } } /** * DisplayBookmarks * Output bookmark data. Over-ride this to alter display of Bookmark information. * Bookmark objects contain two useful fields: title and url * * * @param marks - this is an array of Bookmark Objects */ function DisplayBookmarks($marks) { //echo "
"; echo '

'.lang('bookmarks').'

'; echo "

"; echo lang('bookmarks'); echo "

\n"; echo "\n"; echo "
\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 '
'; echo "\n"; echo '
'; } /** * EndRighthandColumn * Override this for different behavior or special functionality * for the righthand column. Usual use would be a div close tag. */ function EndRighthandColumn() { echo "
\n
\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() { $config = cmsms()->GetConfig(); $ssl = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off'); $ssl = $ssl && isset($config['ssl_url']); return cms_get_jquery('',$ssl); } /** * 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 ""; } /** * 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 */ public 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"; } } /** * 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. * */ public 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) { $menuitems = $this->get_admin_navigation(); if ($maxdepth > 0 && $depth> $maxdepth) return; if (! $menuitems[$section]['show_in_menu']) return; if (strlen($menuitems[$section]['url']) < 1) { echo "
  • ".$menuitems[$section]['title']."
  • "; return; } echo "
  • "; echo $menuitems[$section]['title']; echo ""; if ($this->HasDisplayableChildren($section)) { echo "
      "; foreach ($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"; $menuitems = $this->get_admin_navigation(); foreach ( $menuitems as $key=>$menuItem) { if ($menuItem['parent'] == -1) $this->renderMenuSection($key, 0, -1); } 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() { $info = CmsNlsOperations::get_language_info(CmsNlsOperations::get_current_language()); echo ($info->direction() == 'rtl') ? "" : "\n"; } /** * @since 1.9 * ThemeHeader * This method outputs the HEAD section of the html page in the admin Theme section, * after OutputHeaderJavascript() and before $addt. */ function ThemeHeader(){ if(file_exists('themes/'. $this->themeName. '/includes/standard.js')) { return ''."\n"; } } /** * DisplayHTMLHeader * This method outputs the HEAD section of the html page in the admin section. */ public function DisplayHTMLHeader($showielink = false, $addt = '') { $x = $this->breadcrumbs; // dummy function to trigger the navigation being built early. $config = cmsms()->GetConfig(); $urlext = CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY]; $title = get_site_preference('sitename').' - '.$this->title; $str = "\r\n"; $str .= <<{$title} EOT; if ($showielink) { $str .= << EOT; } $str .= $this->OutputHeaderJavascript()."\n"; $str .= "\n"; ob_start(); $tmp1 = $this->ThemeHeader(); $tmp2 = ob_get_contents(); ob_end_clean(); if( $tmp1 ) { // data is returned $str .= $tmp1; } else { // assume data is echoed $str .= $tmp2; } $str .= $addt."\n"; $str .= "\n"; // fix to correct and add the end header tag -- JLB echo $str; } /** * DisplayBodyTag * Outputs the admin page body tag. Leave in the funny text if you want this * to work properly. */ public function DisplayBodyTag() { echo "\n"; } /** * DisplayMainDivStart * * Used to output the start of the main div that contains the admin page content */ public function DisplayMainDivStart() { echo "
    \n"; } /** * DisplayMainDivEnd * * Used to output the end of the main div that contains the admin page content */ public function DisplayMainDivEnd() { echo '
    '; echo "
    \n"; } /** * DisplaySectionMenuDivStart * Outputs the open div tag for the main section pages. */ public function DisplaySectionMenuDivStart() { echo "
    \n"; } /** * DisplaySectionMenuDivEnd * Outputs the close div tag for the main section pages. */ public function DisplaySectionMenuDivEnd() { echo "
    \n"; if (get_preference($this->userid, 'bookmarks')) { echo "
    \n"; } } /** * Display the available notifications * * @param string $priority Priority threshold * @return void */ function DisplayNotifications($priority=2) { $tnotifications = $this->get_notifications(); if( count($tnotifications) == 0 ) return; // count the total number of notifications $count=0; for( $i = 0; $i < count($tnotifications); $i++ ) { if( $tnotifications[$i]->priority <= $priority ) $count++; } // Define that is singular or plural $singular_or_plural = $count; if($singular_or_plural > 1) { $tmp = lang('notifications_to_handle',$count); } else { $tmp = lang('notification_to_handle',$count); } // remove html tags like 2 $no_html_tags = preg_replace('/(<\/?)(\w+)([^>]*>)/e','',$tmp); echo '
    '."\n"; echo '
    ' . $tmp . '
    '."\n"; echo '
    '."\n"; echo '\n"; echo "
    \n"; echo "
     
    \n"; } /** * ShowHeader * Outputs the page header title along with a help link to that section in the wiki. * * @param title_name - page heading title * @param extra_lang_param - extra parameters to pass to lang() (I don't think this parm is needed) * @param link_text - Override the text to use for the help link. * @param module_help_type - FALSE if this is not a module, 'both' if link to * both the wiki and module help and 'builtin' if link to to the builtin help */ public function ShowHeader($title_name, $extra_lang_param=array(), $link_text = '', $module_help_type = FALSE) { $cms = cmsms(); $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 */ private 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 */ public function ShowErrors($errors, $get_var = '') { $config = cmsms()->GetConfig(); $image_error = $this->DisplayImage('icons/system/stop.gif', lang('error'),'','','systemicon'); $output = '
    '; } $output .= ''; } else { $output .= $image_error.' '.$errors; } $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 */ public function ShowMessage($message, $get_var = '') { $image_done = $this->DisplayImage('icons/system/accept.gif', lang('success'), '','','systemicon'); $output = '
    '; return $output; } public function do_header() { $this->DisplayDocType(); $this->DisplayHTMLStartTag(); $headtext = $this->get_value('headertext'); $this->DisplayHTMLHeader(false, $headtext); $this->DisplayBodyTag(); $this->DisplayTopMenu(); $this->DisplayMainDivStart(); $this->DisplayNotifications(3); // todo, a preference. $marks = get_preference(get_userid(), 'bookmarks'); if ($marks) { $this->StartRighthandColumn(); if ($marks) $this->DoBookmarks(); $this->EndRighthandColumn(); } } public function do_footer() { $this->DisplayMainDivEnd(); $this->OutputFooterJavascript(); $this->DisplayFooter(); } public function do_toppage($section_name) { $this->ShowShortcuts(); $this->DisplaySectionMenuDivStart(); if( $section_name ) { $this->DisplaySectionPages( $section_name ); } else { $this->DisplayAllSectionPages(); } $this->DisplaySectionMenuDivEnd(); } public function do_login($params) { // by default we're gonna grab the theme name foreach( $params as $key => $val ) { $$key = $val; } $config = cmsms()->GetConfig(); $config = cmsms()->GetConfig(); $fn = $config['admin_path']."/themes/".$this->themeName."/login.php"; include($fn); } public function postprocess($html) { return $html; } } # vim:ts=4 sw=4 noet ?>