                                                                                               <?php
//-->-->-->-->-->-->-->-->
//-- Description:
//--   The purpose of this function is to insert in an HTML template links 
//--   to edit the document which forms the content of the web-page
//--   and also the template which has been wrapped around the document.
//--
//--   This function, like all dodgy template languages, relies on
//--   certain special 'tags' being present in the HTML, which are
//--   in fact just strings within HTML comment delimiters. This is
//--   analogous to the Zope DTML system although obviously not 
//--   as complex.
//--
//--   Recognition of tags should probably be case insensitive
//--  
//-- Tags Recognised
//--
//--   <!--@document-edit-link--> ... <!--@document-edit-link-end-->
//--   
//--      These  tags are replace with an HTML hyperlink which points
//--      to a document editor which should probably be a webpage browser
//--      editor thingy
//-- 
//-- Author: 
//--   matth3wbishop@yahoo.com
//--   http://www.geocities.com/matth3wbishop/


function fnWebTemplateInsertSelfEdit(
  $sTemplateContents,
  $sDocumentFilePath,
  $sWebEditUrl
  )
{


  $sReturn = $sTemplateContents;

  $sEditUrl = "$sWebEditUrl".urlencode($sDocumentFilePath);

  if (stristr($sReturn, "<!--@document-edit-link-->"))
  {
    $sReturn = preg_replace(
       "#<!--@document-edit-link-->(.|\n)*<!--@document-edit-link-end-->#im", 
       "<a href = '$sEditUrl'>$1</a>", $sReturn);
  }
  

  return $sReturn;
} //-- function fnWebTemplateInsertSelfEdit
     

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