OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / common / htmlEdit.php
1 <?php
2 /**
3  * 汎用HTML編集クラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2007 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: htmlEdit.php 2 2007-11-03 04:59:01Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 class HtmlEdit
17 {
18         /**
19          * コンストラクタ
20          */
21         function __construct()
22         {
23         }
24         /**
25          * セレクトメニュー作成
26          *
27          * @param SelectMenuItem $itemArray             メニューに表示する項目(SelectMenuItemクラスの配列)
28          * @param array $tagName                                タグ名
29          * @param array $tagAttribs                             selectタグの属性
30          * @return                                                              メニューのHTMLテキスト
31          */
32         public static function createSelectMenu($itemArray, $tagName, $tagAttribs)
33         {
34                 $html = "\n<select name=\"$tagName\" $tagAttribs>";
35                 $n = count($itemArray);
36                 for ($i = 0; $i < $n; $i++){
37                         $t = $itemArray[$i]->name;
38                         $k = $itemArray[$i]->value;
39
40                         $selected = '';
41                         if ($itemArray[$i]->selected){
42                                 $selected = " selected";
43                         }
44                         $html .= "\n\t<option value=\"".$k."\"$selected>" . $t . "</option>";
45                 }
46                 $html .= "\n</select>\n";
47                 return $html;
48         }
49         /**
50          * 改行コードをbrタグに変換
51          *
52          * @param string $src                   変換するデータ
53          * @return string                               変換後データ
54          */
55         public static function convLineBreakToBr($src)
56         {
57                 return preg_replace("/(\015\012)|(\015)|(\012)/","<br />", $src);
58         }
59 }
60 /**
61  * セレクトメニュー項目クラス
62  */
63 class SelectMenuItem
64 {
65         public $name = '';                      // 画面上に表示されるタイトル
66         public $value = '';                     // 実際の値
67         public $selected = false;       // 選択状態
68 }
69 ?>