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

/****************************************************************************************
 *
 * La classe suivante sert à générer le cadre d'informations sur un fichier.
 *
 * Method:
 *
 * InfosPage(String $pwd, String $body, Array $argv)
 *   Builder of this class
 *
 * boolean makeHtmlBody()
 *
 ***************************************************************************************/
Class InfosPage extends AbstractPage
{
  /** Répertoire courant */
  var $_pwd = "";

  /** Gestionnaire RCS */
  var $_rcs = false;

  /** Fichier à traiter */
  var $_file = false;

  /**
   * Builder of this class
   * @param $pwd   répertoire de travail
   * @param $body  paramètre du corps de page
   * @param $argv  argument de l'URL
   */
  function InfosPage($pwd, $body = false, $argv = false)
  {
    parent::AbstractPage(MyNAME . ":Infos", $body, $argv);
    $this->_pwd = $pwd;

    switch($this->_argv["type"])
    {
      case "rcsfile":
	$this->_rcs = new RCS($this->_pwd);
	$this->_file = $this->_rcs->getFile($this->_argv["file"]);
	break;

      case "sysfile":
	$this->_file = new SYSFile($this->_argv["file"], $this->_argv["type"], $pwd);
	break;
    }
  }/*InfosPage()*/

  /**
   * Génère le corps de la page html
   */
  function makeHtmlBody()
  {
    if(!parent::makeHtmlBody())
      return(false);

    switch($this->_argv[type])
    {
      case "sysfile":
	$fullname = BASE_dir . "$this->_pwd/" . $this->_file->_name;
	$this->_body->assign("file", $this->_file->_name);
	$stat = stat($fullname);
	$stat[mode] = decoct($stat[mode]);
	$this->_body->assign("stat", $stat);
	exec("ident -q $fullname", $flow, $code);
	next($flow);
	while(list($k,$v) = each($flow)) $msg = "$msg$v<br>\n";
	$this->_body->assign("keywords", $msg);
	$this->_body->parse("main.sysfile");
	$this->_body->out("main.sysfile");
	break;

      case "rcsfile":
	$result = $this->_file->_attribut;
	$this->_body->assign("result", $result);

	// traitement du champs locks
	reset($result[locks]);
	next($result[locks]);
	$locksList = "";
	while(list($k,$v) = each($result[locks]))
	  $locksList = "$locksList $v";
	$this->_body->assign("locksList", $locksList);

	// traitement du champs access list
	reset($result[accesslist]);
	next($result[accesslist]);
	list($k,$v) = each($result[accesslist]);
	$accessList = $v;
	while(list($k,$v) = each($result[accesslist]))
	  $accessList = "$accessList, $v";
	$this->_body->assign("accessList", $accessList);

	// traitement des symbolic names
	reset($result[symbolicnames]);
	next($result[symbolicnames]);
	$symbolicList = "";
	while(list($k,$v) = each($result[symbolicnames]))
	  $symbolicList = "$symbolicList $v";
	$this->_body->assign("symbolicList", $symbolicList);
	$this->_body->parse("main.rcsfile");
	$this->_body->out("main.rcsfile");
	$this->_file->showRevisions();
	break;

      case "checkout":
	$this->_body->assign("id", urlencode($this->_argv[result][id]));
	if($this->_argv[destination] == "download" && $this->_argv[result][code])
	  $this->_body->parse("main.checkResult.download");
      case "checkin":
	//afficheTable($this->_argv,0);
	if($this->_argv[result][code])
	  $this->_body->assign("etat", "r&eacute;ussi");
	else
	  $this->_body->assign("etat", "&eacute;chou&eacute");

	$this->_body->assign("cmd", $this->_argv[result][cmd]);
	$this->_body->assign("msg", $this->_argv[result][msg]);
	$this->_body->assign("file", $this->_pwd . "/" . $this->_argv[file]);
	$this->_body->assign("action", $this->_argv[type]);
	$this->_body->parse("main.checkResult");
	$this->_body->out("main.checkResult");
	break;

      case "prefs":
	$this->prefs();
	break;

      default:
	$this->_body->parse("main.default");
	$this->_body->out("main.default");				
    }
    return(true);
  }/* makeHtmlBody() */

  /**
   * This method make the body of the "prefs" frame
   */
  function prefs()
  {
    $this->_body->assign("mode", array($this->_argv[mode] => "checked"));
    $this->_body->assign("base", array(script => BASE_script));

    $css = makeCSSList($this->_argv[sheet]);
    while(list($k,$v) = each($css))
    {
      $this->_body->assign("style", $v);
      $this->_body->parse("main.prefs.styles");
    }/*while()*/

    $this->_body->parse("main.prefs");
    $this->_body->out("main.prefs");
  }/*prefs()*/

}/* Class InfosPage */
?>
Return current item: RCS Man on the Web