                                                                                                                                                                                                                            


<?php
//-->-->-->-->-->-->-->-->
//-- Name:
//--   fnHtmlAsciiMenuItems.php  - 
//--
//-- Description:
//--   The purpose of this function is to allow the simple creation
//--   of visual elements or symbols which act as a prompt for
//--   locating and activating functions within a particular context.
//--   To be more specific, this function transforms references of
//--   the form 'ascii-menu-item: search' into an HTML hyperlink
//--   with a visual display of some icon or symbol which may have
//--   a distinctive background and forground colour, and which
//--   will point to a particular URL within the current web-editing
//--   system. 
//--
//--   The transformation will also include possibly a 'roll-over'
//--   text to allow the user to establish what is the function
//--   or destination of the hyperlink by moving the mouse of the 
//--   icon or symbol. This should be embedded in the 'alt' tag
//--   of the hyperlink in order to support text only browsers and
//--   other non visual browsers.
//--
//-- Supported functions: admin, search, view-file-lines, copy-file ...
//--   
//-- Notes:
//--   It may be handy to write this function very specifically
//--   which would create linked symbols specifically for the 
//--   web-editing system. These could be called 
//--   web-edit-menu-items and would point to the correct locations
//--   within the web-editing system
//-- 
//--Author:
//--   matth3wbishop@yahoo.com
//--   http://www.geocities.com/matth3wbishop/



function fnHtmlAsciiMenuItems(
   $sPlainText, $sFilePath = '', 
   $MANAGEMENTWEBFOLDER = '',
   $WEBPADWEBFOLDER = '')
{
  $sReturn = $sPlainText;

  $sFilePathEncoded = htmlspecialchars($sFilePath);
  $sFilePathUrlEncoded = htmlspecialchars(urlencode($sFilePath));

  $sFileName = basename($sFilePath);
  $sFileNameEncoded = htmlspecialchars($sFileName);
  $sFileNameUrlEncoded = htmlspecialchars(urlencode($sFileName));

  //-- Ascii menu items are similar to ascii icons, but they
  //-- are designed to point to locale resources

  //-- Create 'ascii icons' which are html entities which are 
  //-- displayed in a large font and which should also be HTML hyperlinks
  //-- The idea of this is to provide simple visual clues to a user
  //-- of a webpage about various functions
  //--

  $sCssStyle = 
    "text-decoration: none; color:green; ".
    "background-color:transparent; }";
/*
   A:visited {color: #660066;}
   A:hover {text-decoration: none; color: #ff9900; 
   font-weight:bold;}
   A:active {color: red;text-decoration: none} ";
*/

  //-- Hyperlink this format
  //--    [ascii-menu-item: ... ] 
  //--

  $sAdminUrl = 
    "$MANAGEMENTWEBFOLDER/admin.php";

  $sTitle = "Go to the administration centre";

  $sReturn = 
    preg_replace(
     '#\[ascii-menu-item:\s{0,5}admin\]#im', 
     "<big><big><big><a href='$sAdminUrl' ".
     "title = '$sTitle' style='$sCssStyle'>".
     '&spades;</a></big></big></big>', $sReturn);

  $sSearchUrl = 
    "$MANAGEMENTWEBFOLDER/find-file-form.php?file=$sFileNameUrlEncoded";

  $sTitle = "Search for a file on this server";

  $sReturn = 
    preg_replace(
     '#\[ascii-menu-item:\s{0,5}search\]#im', 
     "<big><big><big><a href='$sSearchUrl' ".
     "title = '$sTitle' style='$sCssStyle'>".
     '&sect;</a></big></big></big>', $sReturn);

  $sWebEditUrl =
    "$WEBPADWEBFOLDER/webpad.php?file=$sFilePathUrlEncoded";

  $sTitle = "Edit a file with a browser wiki editor";

  $sReturn = 
    preg_replace(
     '#\[ascii-menu-item:\s{0,5}web-edit\]#im', 
     "<big><big><big><a href='$sWebEditUrl' ".
     "title = '$sTitle' style='$sCssStyle'>".
     '&epsilon;</a></big></big></big>', $sReturn);

  $sFileEditUrl =
    "$MANAGEMENTWEBFOLDER/notepad/retrovox-notepad.php?".
    "file=$sFilePathUrlEncoded";

  $sTitle = "Edit this file with a browser file editor";

  $sReturn = 
    preg_replace(
     '#\[ascii-menu-item:\s{0,5}file-edit\]#im', 
     "<big><big><big><a href='$sFileEditUrl' ".
     "title = '$sTitle' style='$sCssStyle'>".
     '&fnof;</a></big></big></big>', $sReturn);

  
  $sViewFileLinesUrl =
    "$MANAGEMENTWEBFOLDER/view-file-lines.php?".
    "file=$sFilePathUrlEncoded";

  $sTitle = "View this file with numbered lines";

  $sReturn = 
    preg_replace(
     '#\[ascii-menu-item:\s{0,5}view-file-lines\]#im', 
     "<big><big><big><a href='$sViewFileLinesUrl' ".
     "title = '$sTitle' style='$sCssStyle'>".
     '#</a></big></big></big>', $sReturn);


  $sCopyFileUrl =
    "$MANAGEMENTWEBFOLDER/move-file-form.php?".
    "file=$sFilePathUrlEncoded";

  $sTitle = "Copy this file";

  $sReturn = 
    preg_replace(
     '#\[ascii-menu-item:\s{0,5}copy-file\]#im', 
     "<big><big><big><a href='$sCopyFileUrl' ".
     "title = '$sTitle' style='$sCssStyle'>".
     '&harr;</a></big></big></big>', $sReturn);

  $sBrowseFoldersUrl =
    "$MANAGEMENTWEBFOLDER/select-folder.php";

  $sTitle = "Browse the directories on this server";

  $sReturn = 
    preg_replace(
     '#\[ascii-menu-item:\s{0,5}browse-folders\]#im', 
     "<big><big><big><a href='$sBrowseFoldersUrl' ".
     "title = '$sTitle' style='$sCssStyle'>".
     '&delta;</a></big></big></big>', $sReturn);

  return $sReturn;
} //-- function fnHtmlAsciiMenuItems
     

//--<--<--<--<--<--<--<--<
?>
                                                                                                                                                                                                                            