Location: PHPKode > projects > RCS Man on the Web > RCSManager-0.2/classes/RCSFile.php
<?php
/** 
 * $Id$
 * $Log$
 */

/****************************************************************************************
 *
 * This class handle a RCS archived file
 *
 * Methods:
 *
 * RCSFile(String $name, String $type, String $location, Array $attribut)
 *   Builder of this class
 *
 * showRevisions()
 *
 ***************************************************************************************/
Class RCSFile extends xFile
{
  /**
   * Builder of this class
   * @param $name       name of this file
   * @param $location   location of this file
   * @param $attribut   status of this file
   */
  function RCSFile($name, $location, $attribut = false)
  {
    parent::xFile($name, "rcsfile", $location, $attribut);

    // Etat par défaut
    if(!$attribut["status"])
      $this->_attribut["status"] = "free"; 

  }/* RCSFile() */

  /**
   *
   */
  function showRevisions()
  {
    //$crlf = sprintf("%c%c",13,10);
    
    if($this->_type != "rcsfile") return false;
    
    $xtpl = new XTemplate(TplDIR . "/fichier.xtpl");
    $xtpl->assign("attribut", $this->_attribut);
    
    reset($this->_attribut[logs]);
    while(list($k,$v) = each($this->_attribut[logs]))
    {
      $pattern = "/(; +author: .*;) +(state: .*\n)/";
      $replace = "\\1\n\\2\n";
      $v = preg_replace($pattern, $replace, $v);
      $v = ereg_replace("\n", "\\n", $v);
      $xtpl->assign("revision", array("number" => $k, "log" => $v));
      if($this->_attribut["head"] == $k)
	$xtpl->assign("select", "selected");
      else
	$xtpl->assign("select", "");
      $xtpl->parse("main.revision_select.option");
      $xtpl->parse("main.revision_select.table");				
    }
    $xtpl->assign("file", urlencode("$this->_location/$this->_name"));
    $xtpl->parse("main.revision_select");
    $xtpl->out("main.revision_select");
  }/*showRevisions()*/
  
}/*Class RCSFile*/

?>
Return current item: RCS Man on the Web