com.lokorin.lokorin.lib
[ class tree: com.lokorin.lokorin.lib ] [ index: com.lokorin.lokorin.lib ] [ all elements ]

Source for file lib_admin.php

Documentation is available at lib_admin.php

  1. <?php
  2. /*
  3. * Lokorin.com
  4. * Copyright 2004-2006
  5. * Licensed under the GNU LGPL. See COPYING for full terms.
  6. */
  7. /**
  8. * A library that contains functions that are not used except when the viewer
  9. * has admin privileges.
  10. * @author Andreas Launila
  11. * @version $Revision: 1.5 $
  12. * @package com.lokorin.lokorin.lib
  13. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  14. */
  15. /**
  16. * For access to common constants and functions.
  17. */
  18. require_once('common.php');
  19.  
  20. /**
  21. * Gets an menu listing all available admin panels.
  22. * @return string XHTML compliant code describing the admin panels as a list.
  23. * @access public
  24. */
  25. function getAdminMenu() {
  26. /**
  27. * Strips any file extendsion from a file name.
  28. * @param string $fileName The name of the file from which the extensions
  29. * should be stripped.
  30. * @return The file name without any file extension.
  31. * @access private
  32. */
  33. function stripFileExtension($fileName) {
  34. return(preg_replace('/(.*?)\..*/', '$1', $fileName));
  35. }
  36. //Get a list of all interesting files in the admin directory.
  37. $fileList = array();
  38. if($dir = @opendir(ROOT.FOLDER_ADMIN)) {
  39. while(($file = readdir($dir)) !== false) {
  40. if(($file != '..') && ($file != '.') && ($file != 'login.php')) {
  41. $filelist[]=$file;
  42. }
  43. }
  44. closedir($dir);
  45. }
  46. if(sizeof($filelist) == 0) {
  47. return;
  48. }
  49. //Build the menu based on the files.
  50. sort($filelist);
  51. $output = '';
  52. foreach($filelist as $file) {
  53. $file = stripFileExtension($file);
  54. $display = str_replace('_', ' ', $file);
  55. $output .= '<li><a href="'.PAGE_ROOT.FOLDER_ADMIN.$file.'">'.
  56. strtoupper($display[0]).substr($display,1).'</a></li>'."\n";
  57. }
  58. return($output);
  59. }
  60.  
  61. ?>

Documentation generated on Sun, 16 Apr 2006 21:03:04 +0200 by phpDocumentor 1.3.0RC4