ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
ASP用ツリー作成パッケージをASP から PHP へコンバーション
日時: 2013/05/01 23:24
名前: lightbox



↓サンプル実行ページ
http://lightbox.on.coocan.jp/php/tree/sample.php

↓コンバート元の ASP パッケージ
http://lightbox.on.coocan.jp/download/make_tree_for_asp.lzh

http://asp2php.naken.cc/download.php

を利用してまず、tree.inc をコンバート

拡張子:
asp2php.exe -php5 -includes tree.inc
そのままでは使え無いので変更 その後、sample.asp をコンバートして使え無い部分を変更 以下のコードで実行
拡張子:
<? require("tree.php"); ?>
<HTML>
<HEAD>
<META http-equiv="Content-type" content="text/html; charset=Shift_JIS">
<TITLE>HTML テンプレート</TITLE>
<STYLE type="text/css">
* {
	font-family: "MS Pゴシック";
	font-size: 12px;
}
BODY {
	background-color: white;
	color: black;
}
</STYLE>

<SCRIPT language="javascript" type="text/javascript">

<? 
InitializeTreeEnv();
SetImageUrl("image");
SetControlJs();
?>

</SCRIPT>
<HEAD>
<? 

$Tree = "";

$Tree .= StartNode( "#", "ルートノード", "_self" );
$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", False );
$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", True );
$Tree .= EndNode( );


$Tree .= StartNode( "#", "ルートノード", "_self" );
$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", False );


	$Tree .= StartNode( "#", "ルートノード", "_self" );
	$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
	$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", False );


		$Tree .= StartNode( "#", "ルートノード", "_self" );
		$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
		$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", False );
		$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
		$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", True );
		$Tree .= EndNode( );


	$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
	$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", True );
	$Tree .= EndNode( );


$Tree .= AddLeaf( "http://www.google.co.jp/", "Google", "ActionWindow", False );
$Tree .= AddLeaf( "http://www.yahoo.co.jp/", "Yahoo", "ActionWindow", True );
$Tree .= EndNode( );

?>
<BODY>
<? echo $Tree;?>

<IFRAME

	style='position:absolute;left:300px;top:15px;'

	src="iframe.htm"

	name="ActionWindow"

	frameborder="yes"

	scrolling="yes"

	width="650"

	height="500"

></IFRAME>

</BODY>
</HTML>
メンテナンス

tree.php ( No.1 )
日時: 2007/10/02 17:32
名前: lightbox


日時: 2007/10/02 17:32
名前: lightbox
拡張子:
<? 

// **********************************************************
// 初期処理
// **********************************************************
function InitializeTreeEnv()
{

  $GLOBALS['tree_imageurl'] = "";
  $GLOBALS['tree_nid'] = 0;
  $GLOBALS['tree_lv'] = 0;

} 

// **********************************************************
// 画像URL変更
// **********************************************************
function SetImageUrl($url)
{

  $GLOBALS['tree_imageurl']=$url."/";

} 

// **********************************************************
// 専用javaScript 出力
// **********************************************************
function SetControlJs()
{
  extract($GLOBALS);



  $str="";
  $str=$str."function TreeControl(id,gid) {  "."\r\n"."  ";
  $str=$str.""."\r\n"."	if ( !document.getElementById(id).flg ";
  $str=$str.") {  "."\r\n"."		document.getElementById(id).flg ";
  $str=$str."= \"1\";  "."\r\n"."	}  "."\r\n"."  "."\r\n"."	if ";
  $str=$str."( document.getElementById(id).flg == \"1\" ";
  $str=$str.") {  "."\r\n"."		document.getElementById(id).style.display=\"\"; ";
  $str=$str." "."\r\n"."		document.getElementById(id).flg ";
  $str=$str."= \"0\";  "."\r\n"."		gid.src = \"".$tree_imageurl."m.png\" ";
  $str=$str." "."\r\n"."	}   "."\r\n"."	else {  "."\r\n"."		document.getElementById(id).style.display=\"none\"; ";
  $str=$str." "."\r\n"."		document.getElementById(id).flg ";
  $str=$str."= \"1\";  "."\r\n"."		gid.src = \"".$tree_imageurl."p.png\" ";
  $str=$str." "."\r\n"."	}  "."\r\n"."  "."\r\n"."}  "."\r\n"." ";
  $str=$str."";

  print $str;

  return $function_ret;
} 

// **********************************************************
// ノード開始部分作成
// **********************************************************
function StartNode($url,$title,$target)
{
  extract($GLOBALS);

  global $tree_nid,$tree_lv;

  $tree_nid=$tree_nid+1;
  $tree_lv=$tree_lv+1;

  $nTitleOffset=(($tree_lv-1)*2-20)*-1;

  if ($tree_lv==1)
  {

    $Buffer=$Buffer."<DIV style='position:relative;left:0px'"."\r\n".">";
  }
    else
  {

    $Buffer=$Buffer."<DIV style='position:relative;left:21px'"."\r\n".">";
  } 


  $Buffer=$Buffer."<IMG src=\"".$tree_imageurl."p.png\"";
  $Buffer=$Buffer." onClick='TreeControl(\"".$tree_nid."\", this)' border=\"0\" style='position:relative;left:4px'"."\r\n".">";
  $Buffer=$Buffer."<IMG src=\"".$tree_imageurl."folder.png\" style='position:relative;left:12px'"."\r\n".">";

  for ($I=2; $I<=$tree_lv; $I=$I+1)
  {
    $nVOffset=-39-24*($I-2);
    $Buffer=$Buffer."<IMG style='position:relative;left:".$nVOffset."px;' align=\"top\" src=\"".$tree_imageurl."l3.gif\" border=\"0\""."\r\n".">";

  }


  $Buffer=$Buffer."<A style='text-decoration:none;position:relative;left:".$nTitleOffset."px;'";
  $Buffer=$Buffer." href=\"".$url."\" target=\"".$target."\">".$title."</A><br>"."\r\n";

  $Buffer=$Buffer."<DIV style='position:relative;left:0px;display:none;' id=\"".$tree_nid."\" flg=\"1\""."\r\n".">";

  $function_ret=$Buffer;

  return $function_ret;
} 

// **********************************************************
// ノード終了部分作成
// **********************************************************
function EndNode()
{
  extract($GLOBALS);

  global $tree_nid,$tree_lv;


  $tree_lv=$tree_lv-1;

  $Buffer=$Buffer."</DIV></DIV>"."\r\n";

  $function_ret=$Buffer;

  return $function_ret;
} 

// **********************************************************
// 末端データ部分作成
// **********************************************************
function AddLeaf($url,$title,$target,$bLast)
{
  extract($GLOBALS);


  global $tree_nid,$tree_lv;


  $nTitleOffset=(($tree_lv-1)*3-25)*-1;

  $Buffer=$Buffer."<IMG style='position:relative;left:8px;' align=\"top\" src=\"".$tree_imageurl."l3.gif\" border=\"0\""."\r\n".">";
  if ($bLast)
  {

    $Buffer=$Buffer."<IMG style='position:relative;left:18px;'align=\"top\" src=\"".$tree_imageurl."l2.gif\" border=\"0\""."\r\n".">";
  }
    else
  {

    $Buffer=$Buffer."<IMG style='position:relative;left:18px;'align=\"top\" src=\"".$tree_imageurl."l.gif\" border=\"0\""."\r\n".">";
  } 

  $Buffer=$Buffer."<IMG style='position:relative;left:20px;top:3px;' align=\"top\" src=\"".$tree_imageurl."note.png\" border=\"0\""."\r\n".">";
  for ($I=2; $I<=$tree_lv; $I=$I+1)
  {
    $nVOffset=-47-24*($I-2);
    $Buffer=$Buffer."<IMG style='position:relative;left:".$nVOffset."px;' align=\"top\" src=\"".$tree_imageurl."l3.gif\" border=\"0\""."\r\n".">";

  }

  $Buffer=$Buffer."<A style='position:relative;left:".$nTitleOffset."px;top:2px;text-decoration:none;font-size:14px;'";
  $Buffer=$Buffer." href=\"".$url."\" target=\"".$target."\">".$title."</A><br>"."\r\n";

  $function_ret=$Buffer;

  return $function_ret;
} 


?>
このアーティクルの参照用URLをクリップボードにコピー メンテナンス