ホームページ バックエンド開発 PHPチュートリアル ExtPHP は主に、PHP コードから ExtJS 用の JavaScript コードを生成するために使用されます。

ExtPHP は主に、PHP コードから ExtJS 用の JavaScript コードを生成するために使用されます。

Jul 25, 2016 am 09:10 AM

ExtPHP は、Thinkphp 開発フレームワークに基づいた ExtJS 開発クラス ライブラリです。この種のライブラリを使用すると、ExtJS JavaScript コードを簡単に生成できます。
  1. /**
  2. * PHPExtJs 基本オブジェクト
  3. * @License: ( http://www.apache.org/licenses/LICENSE-2.0 )
  4. * @Author: wb
  5. */
  6. class ExtBase {
  7. /**
  8. * ExtJS のベースディレクトリ、このパラメータはパスです
  9. * @var String
  10. */
  11. public $exthome = '';
  12. /**
  13. * ExtJS ロケール設定、デフォルトは zh_cn (中国語) です
  14. * @var String
  15. */
  16. public $extlang = 'zh_cn';
  17. /**
  18. * ExtJS デバッグモード、デフォルトは false です
  19. * @var Boolean
  20. */
  21. public $debugmode = false;
  22. /**
  23. * ExtJS のカーネル モード、デフォルトは false です
  24. * @var Boolean
  25. */
  26. public $coremode = false;
  27. /**
  28. * ExtJSの環境ディレクトリのベースディレクトリ
  29. * @var String
  30. */
  31. public $extbasedir = "";
  32. /**
  33. *ExtJS の基本コード
  34. *@var String
  35. */
  36. public $extbasecode = "";
  37. /**
  38. * ページに必要な CSS ファイル
  39. * @var 配列
  40. */
  41. public $pageCss = array();
  42. /**
  43. * ページに必要な JS ファイル
  44. * @var 配列
  45. */
  46. public $pageJs = array();
  47. /**
  48. * ExtJs CSS ファイル
  49. * @var 文字列
  50. */
  51. private $extcss = "";
  52. /**
  53. * ExtJS ディレクトリ内のすべてのファイルのインデックスは、配列 (ファイル名 => ファイル パス) の形式になります
  54. * @var Array
  55. */
  56. public $ExtALLFiels = array();
  57. /**
  58. * ExtJS の基本的な実行ファイルを定義します。形式は次のとおりです: array (name => ファイル名) ここでは基本的なもののみを定義します
  59. * 例:base、all、css、core、debug
  60. * @var Array
  61. */
  62. public $ExtBaseFile = array(
  63. 'base' => 'ext-base.js',
  64. 'all' => 'ext-all.js',
  65. 'css' => 'ext- all.css',
  66. 'core' => 'ext-core.js',
  67. 'debug' => 'ext-all-debug.js',
  68. );
  69. /**
  70. * 基本パラメータに従って Extjs の基本環境を設定します
  71. *
  72. * @param string $exthome $basedir で指定されたディレクトリからの相対的な、ExtJS が配置されているディレクトリ
  73. * @param boolen $extdebue デバッグモードを有効にするかどうか
  74. * @param boolen $extcore コアモードかどうか
  75. * @param string $extlang ExtJS言語を設定します
  76. * @param string $basedir $exthomeディレクトリがあるディレクトリ
  77. */
  78. public function __construct($exthome = '', $basedir='', $extdebue=false, $extcore=false, $extlang='zh_cn') {
  79. //设設置基本运行環境
  80. $this->setExtBase($ exthome, $basedir, $extdebue, $extcore, $extlang);
  81. }
  82. /**
  83. * Extjs のベースディレクトリを設定します
  84. *
  85. * @param String $exthome ExtJs ファイルが配置されているディレクトリ
  86. * @param String $basedir ディレクトリが配置されているディレクトリは、そのディレクトリに基づいています。デフォルトは '/です。 '
  87. * @return Boolean
  88. */
  89. public function setExtHome($exthome="", $basedir="/") {
  90. //TODO - Extjs の基本目录
  91. if (!empty($basedir)) {
  92. $this->extbasedir = str_replace("/./", "/", $basedir);
  93. }
  94. if (!empty($exthome) )) {
  95. $this->ReadALLFile($exthome, $this->ExtALLFiels);
  96. if (!empty($this->ReadALLFile[$this->ExtBaseFile['base']])) {
  97. throw new Exception("不正确的exthome目录($exthome)!");
  98. }
  99. $this->exthome = $exthome;
  100. }
  101. return TRUE;
  102. }
  103. /**
  104. * Extjsの基本環境を設定します
  105. *
  106. * @param string $exthome $basedirで指定したディレクトリからの相対的な、ExtJSが配置されているディレクトリ
  107. * @param boolen $extdebue デバッグモードを有効にするかどうか
  108. * @param boolen $ extcore コアモードかどうか
  109. * @param string $extlang ExtJS 言語を設定します
  110. * @param string $basedir $exthome ディレクトリが配置されているディレクトリ
  111. * @return Boolean
  112. */
  113. public function setExtBase($exthome = '', $basedir='', $extdebue=false, $extcore=false, $extlang='zh-CN') {
  114. //Extjs の基本環境
  115. $this->setExtHome($exthome, $basedir);
  116. $this->setExtLang ($extlang);
  117. $this->debugmode = $extdebue;
  118. return TRUE;
  119. }
  120. /**
  121. * extjs の言語を設定します
  122. *
  123. * @param String $lang ここでの言語は、次のような ExtJs の言語ファイルのファイル名の言語部分のみです:
  124. * ext-lang-zh_cn.js 言語ファイル、zh_cnだけで十分です
  125. */
  126. public function setExtLang($lang='') {
  127. //TODO - 设置extjs的言説
  128. if (!empty($lang))
  129. $this->extlang = $lang;
  130. }
  131. /**
  132. * オブジェクトのStyel設定文字列を取得します
  133. */
  134. public function getExtBaseStyel() {
  135. $tmpstr = '';
  136. if (is_array($this->ExtALLFiels[$this->ExtBaseFile['css']])) {
  137. $cssfile = '';
  138. foreach ($this->ExtALLFiels[$this->ExtBaseFile[' css']] as $v) {
  139. if (preg_match('//docs/i', $v) == FALSE) {
  140. $cssfile = $v;
  141. Break;
  142. }
  143. }
  144. $tmpstr .= " n";
  145. } else {
  146. $tmpstr .= "n";
  147. }
  148. //その它css
  149. if (!empty($this->pageCss)) {
  150. foreach ($this->pageCss as $f) {
  151. if (is_array($f)) {
  152. $tmpstr . = "n";
  153. } else {
  154. $tmpstr .= "n";
  155. }
  156. }
  157. }
  158. return $tmpstr;
  159. }
  160. /**
  161. * オブジェクトの基本的なスクリプト構成文字列を取得します
  162. * @return String
  163. */
  164. public function getExtBaseScript() {
  165. $tmp = '';
  166. $tmpstr = '';
  167. if (is_array($this-> ExtALLFiels[$this->ExtBaseFile['base']])) {
  168. foreach ($this->ExtALLFiels[$this->ExtBaseFile['base']] as $v) {
  169. if (preg_match(' /source/i', $v) == FALSE) {
  170. $tmp = $v;
  171. Break;
  172. }
  173. }
  174. if (empty($tmp))
  175. $tmp = $this->ExtALLFiels[$this ->ExtBaseFile['base']][0];
  176. }else {
  177. $tmp = $this->ExtALLFiels[$this->ExtBaseFile['base']];
  178. }
  179. $tmpstr .= " n";
  180. if ($this->debugmode) {
  181. $tmpstr .= "n";
  182. }
  183. if ($this->coremode) {
  184. $tmpstr .= "n";
  185. }
  186. //设置语言
  187. $ ExtLangJS = 'ext-lang-{lang}.js';
  188. if (!empty($this->extlang)) {
  189. $tmpfile = strto lower(str_replace("{lang}", $this->gt;extlang, $ExtLangJS));
  190. if (isset($this->ExtALLFiels[$tmpfile])) {
  191. $tmpstr .= "n";
  192. }
  193. }
  194. //并入其它Js文件
  195. $tmpstr .= $this->gt;getExtPageJs();
  196. return $tmpstr;
  197. }
  198. /**
  199. * ExtJs のその他の設定を取得します
  200. * @return String
  201. */
  202. public function getExtPageJs(){
  203. $tmpstr = "";
  204. //设置其它js
  205. if (!empty($this->pageJs) ) {
  206. foreach ($this->pageJs as $f) {
  207. if (is_array($f)) {
  208. $tmpstr .= "n";
  209. } else {
  210. $tmpstr .= "n";
  211. }
  212. }
  213. }
  214. return $tmpstr;
  215. }
  216. /**
  217. * ExtJsの基本的なページ設定文字列を取得します
  218. * @return string
  219. */
  220. public function getExtBaseJs() {
  221. //s.gif
  222. $tmpstr = '';
  223. $tmpstr .= "< ;script type="text/javascript">Ext.BLANK_IMAGE_URL = '{$this->extbasedir}{$this->exthome}/resources/images/default/s.gif';n ";
  224. if (!empty($this->extcss) && isset($this->ExtALLFiels[$this->extcss])) {
  225. $tmpstr .= "n";
  226. }
  227. return $tmpstr;
  228. }
  229. /**
  230. * ExtJs のすべての設定文字列を取得します
  231. * @return String
  232. */
  233. public function getExtBaseCode() {
  234. $this-> ;extbasecode .= $this->getExtBaseStyel();
  235. $this->extbasecode .= $this->getExtBaseScript();
  236. $this->extbasecode .= $this->getExtBaseJs();
  237. return $this->extbasecode;
  238. }
  239. /**
  240. * ページ上に他の CSS ファイルを設定します
  241. * @param String CSS ファイル名とパス
  242. */
  243. public function setPageCssFile($fileName) {
  244. if (!empty($fileName)) {
  245. $this->pageCss[] = $ fileName;
  246. }
  247. }
  248. /**
  249. * ページのスタイルを設定します
  250. * @param $cssString スタイル文字列
  251. */
  252. public function setPageCss($cssString) {
  253. if (!empty($cssString)) {
  254. $this->pageCss[] = array("sytle" => $cssString);
  255. }
  256. }
  257. /**
  258. * ページ上に他の js ファイルを設定します
  259. * @param String JS ファイル名とパス
  260. */
  261. public function setPageJsFile($fileName) {
  262. if (!empty($fileName)) {
  263. $this->pageJs[] = $fileName;
  264. }
  265. }
  266. /**
  267. * ページの JS コードを設定します
  268. * @param $Js は ExtFunction オブジェクトまたは JS 文字列にすることができます
  269. */
  270. public function setPageJs($Js) {
  271. if (!empty($Js)) {
  272. $this->pageJs[] = array( "js" => $Js);
  273. }
  274. }
  275. /**
  276. * extjsのスタイルを設定します
  277. *
  278. * @param String $cssName CSSスタイル名 デフォルトはdefaultです
  279. */
  280. public function setExtCss($cssName="default") {
  281. if ($cssName != "default") {
  282. $this->extcss = "xtheme-" 。 $cssName 。 ".css";
  283. }
  284. }
  285. /**
  286. * $data を ExtJs オブジェクト Json 文字列にフォーマットします
  287. *
  288. * @param Array $data
  289. * @return String
  290. */
  291. public function ExtJsonFormat($data) {
  292. $i = 0;
  293. $retstr .= "{";
  294. foreach ($data as $ k => $v) {
  295. if ($i > 0)
  296. $retstr .= ",";
  297. if (is_string($v) && !is_numeric($v) && strto lower($v) != " true" && strto lower($v) != "false") {
  298. $retstr .= "$k:'$v'";
  299. }
  300. else
  301. $retstr .= "$k:$v";
  302. $i++ ;
  303. }
  304. $retstr .= "}";
  305. return $retstr;
  306. }
  307. /**
  308. * 指定されたフォルダー $floder 内のすべての内容を読み取ります (ファイル、フォルダー、およびサブフォルダー内のすべての内容を含む)
  309. *
  310. * @param String $floder フォルダー名 (ディレクトリ名) は相対ディレクトリにすることができます
  311. * @ param Array POT $ retarr コンテンツが保存される配列ポインター
  312. */
  313. public function ReadALLFile($floder, &$retarr = array()) {
  314. //TODO - 指定されたフォルダー $floder 内のすべてのコンテンツを読み取ります (ファイルとファイル フォルダー、コンテンツを含む)サブフォルダーの)、$retarr ポインターに返されます
  315. $tpath = '';
  316. $app_path = str_replace('\', '/', getcwd()) //echo "APP_PATH:"。 $app_path." BASE:".$this->extbasedir."
    n";
  317. if (strpos($this->extbasedir, $app_path) == FALSE) {
  318. $ tpath = $app_path . "/" . $floder;
  319. } else {
  320. $tpath = $this->extbasedir . "/" . $floder;
  321. }
  322. $tpath (array('/{2,} /', '/) /{2,}/'), '/', $tpath);
  323. $tmparr = $this->ReadFloder($tpath);
  324. if ($tmparr != FALSE && is_array($ tmparr)) {
  325. foreach ($tmparr[0] as $v) {
  326. $this->ReadALLFile($floder . '/' . $v, $retarr);
  327. }
  328. if (!empty($tmparr[1])) {
  329. foreach ($tmparr[1] as $v) {
  330. $k = strto lower($v);
  331. if (isset($retarr[$k])) {
  332. $tmpstr = preg_replace('/ /{2,} /', "/", $floder . $v);
  333. if (is_array($retarr[$k])) {
  334. $retarr[$k][] = $tmpstr; $retarr[$k] = array($retarr[$k], $tmpstr);
  335. }
  336. } else {
  337. $retarr[$k] = preg_replace('//{2,}/' , "/", $floder . '/' . $v);
  338. }
  339. }
  340. }
  341. }
  342. array_change_key_case($retarr);
  343. }
  344. /**
  345. * 指定したフォルダーの内容 (ファイルやフォルダーを含む) を読み取ります $floder
  346. *
  347. * @param String $floder
  348. * @return Array
  349. */
  350. public function ReadFloder($floder ) {
  351. // TODO - 指定されたフォルダー $floder の内容を読み取ります (ファイルとフォルダーを含む)
  352. if (!is_dir($floder)) {
  353. throw new ThinkException("ExtJs の動作環境を設定できません。設定されたディレクトリを確認してください: $floder ");
  354. }
  355. $flod = array();
  356. $files = array();
  357. $dh = opendir($floder);
  358. if (!$dh) {
  359. throw new ThinkException("ディレクトリを開く:" . dirname("../") " エラー! ");
  360. }
  361. while (false !== ($filename = readdir($dh))) {
  362. if ($filename != "." && $filename != "..") {
  363. if (strpos( $filename, ".") <= 0)
  364. $flod[] = $filename;
  365. else
  366. $files[] = $filename;
  367. }
  368. }
  369. return array($flod, $files);
  370. }
  371. /**
  372. * オブジェクトのプロパティを設定します
  373. * @param String $key
  374. * @param Mixed $val
  375. */
  376. public function __set($key, $val) {
  377. if (property_exists($this, $key)) {
  378. if ($key == "extlang") {
  379. $this-> ;setExtLang($val);
  380. } else {
  381. $this->$key = $val;
  382. }
  383. }
  384. }
  385. /**
  386. * オブジェクトの属性値を取得します
  387. * @param String $key
  388. * @return Mixed
  389. */
  390. public function __get($key) {
  391. if ( empty($key))
  392. return false;
  393. if (property_exists($this, $key)) {
  394. if ($key == "extbasecode")
  395. return $this->getExtBaseCode();
  396. else
  397. return $ this->$key;
  398. }
  399. return true;
  400. }
  401. /**
  402. * オブジェクトを文字列として返します
  403. * @return String
  404. */
  405. public function __toString() {
  406. return $this->getExtBaseCode();
  407. }
  408. }
  409. ?> ;
  410. コードをコピー
  1. /**
  2. * PHPExtJs オブジェクト生成クラス
  3. * @License: ( http://www.apache.org/licenses/LICENSE-2.0 )
  4. * @Author: wb
  5. */
  6. class ExtFunction {
  7. /**
  8. * オブジェクトパラメータセット
  9. * @var 配列パラメータセット
  10. */
  11. protected $param = array();
  12. /**
  13. * オブジェクトコード
  14. * @var String オブジェクトコード文字列
  15. */
  16. protected $code = '';
  17. /**
  18. * JS オブジェクト表記の名前
  19. * @var String オブジェクト名
  20. */
  21. protected $clsname = '';
  22. /**
  23. * パラメーター $param、コード $code および $clsnames に従って Ext 関数オブジェクトを設定します
  24. *
  25. * @param $param 関数の混合パラメーター リスト ("val, val1" または array("val", "val1") )
  26. * @param 混合 $code 関数コード、オブジェクトをたどることができます
  27. * @param String $clsname Ext カスタム オブジェクト名
  28. *
  29. */
  30. public function __construct($param = null, $code = null, $clsname = null) {
  31. $this->SetParam($param);
  32. $this->SetCode($code);
  33. $this->clsname = $clsname;
  34. }
  35. /**
  36. * オブジェクトのパラメータを設定します
  37. * @param String $param パラメータには配列を指定できます
  38. */
  39. public function SetParam($param) {
  40. if (is_array($param)) {
  41. $this->param = array_merge($this->param, $param);
  42. } elseif (is_string($) param) && preg_match("/,/", $param)) {
  43. $this->param = array_merge($this->param, Split(',', $param));
  44. } else {
  45. $ this->param [$param] = $param;
  46. }
  47. }
  48. /**
  49. * オブジェクトのコードを設定します
  50. * @param Mixed $code はコード文字列または PHPExtJS の他のオブジェクトにすることができます
  51. */
  52. public function SetCode($code) {
  53. if (!empty($this->code) && is_object($this->code) && Method_exists($this->code, 'render')) {
  54. $this->code = $this->code->render();
  55. }
  56. if (is_object($code) && Method_exists($code, 'render')) {
  57. $this->code .= $code->render();
  58. } else if (is_string($code)) {
  59. $this->code .= $code;
  60. }
  61. if (is_array($code)) {
  62. foreach ($code as $key => $val) {
  63. if ($key === "return") {
  64. //echo "KEY:$key
    n";
  65. $this->code .= "return ";
  66. }
  67. $this ->SetCode($val);
  68. $this->code .= ";";
  69. }
  70. }
  71. }
  72. /**
  73. * @param String $name DOM 名
  74. * @param String $clsname オブジェクト名
  75. */
  76. public function render($name = '', $ clsname = "") {
  77. $str = '';
  78. if (!empty($name)) {
  79. $str .= "var $name = function ";
  80. } else {
  81. $str .= "function ";
  82. }
  83. if (!empty($clsname))
  84. $this->clsname = $clsname;
  85. if (!empty($this->clsname)) {
  86. $str .= " " . $this->clsname 。 " ";
  87. $this->param = array();
  88. }
  89. $str .= "(" . implode(',', $this->param) . ")";
  90. if (!empty ($this->code)) {
  91. $str .= "{";
  92. if (is_object($this->code) && Method_exists($this->code, "render")) {
  93. $str .= $this->code->render();
  94. } elseif (is_string($this->code)) {
  95. $str .= $this->code;
  96. }
  97. $str .= " }";
  98. }
  99. if (!empty($name))
  100. $str .= ";";
  101. //去除注释行
  102. $search = array(
  103. '/(//.*)|(/*. **/)/i', //去掉注释
  104. '/[fnrt]*/i', //去掉回车符
  105. '/{(s)*/i',
  106. '/}(s)*} /i',
  107. '/}(s)*/i',
  108. //'/}(s)*if/i',
  109. '/(s)*}/',
  110. '/;(s)* /',
  111. '/,(s)*/i'
  112. );
  113. $replace = array(
  114. '',
  115. '',
  116. '{',
  117. '}}',
  118. '}',
  119. // '}if',
  120. '}',
  121. ';',
  122. ','
  123. );
  124. $str = preg_replace($search, $replace, $str);
  125. return $str;
  126. }
  127. public function __toString() {
  128. return $this->render();
  129. }
  130. }
  131. ?>
コードをコピー
  1. require_once 'ExtData.class.php';
  2. class ExtObject {
  3. protected static $indent = '';
  4. public $state = Array();
  5. public $showkeys = true;
  6. public $extClass = '';
  7. public $rendername = '';
  8. public $extend = '';
  9. /**
  10. * $properties プロパティに基づいて Ext オブジェクトを作成します
  11. *
  12. * @param String $ExtClass オブジェクト名 (例: Ext.TabPanel、Ext.grid.GridPanel など)
  13. * @param Array $properties オブジェクト プロパティ配列 (例) :
  14. * Array('labelWidth ' => 150,
  15. * 'url' => 'part.submit.php',
  16. * 'frame' => true,
  17. * 'bodyStyle' => 'padding: 5px 5px 0',
  18. * 'width' => 500,
  19. * 'defaults' => new ExtObject(null, Array('width' => 290)),
  20. * 'defaultType' => '
  21. * )
  22. * @ param String $name var name 例: $name='test'、生成されるコードは var test = new $ExtClass () {}
  23. * @param Boolen $showkeys ラベルを表示するかどうか構成配列 $properties の
  24. */
  25. public function __construct($ExtClass = null, $properties = null, $ name = null, $showkeys = true) {
  26. $this->extClass = $ExtClass;
  27. if (is_array($properties)) {
  28. $this->state = $properties;
  29. }
  30. $this-> showkeys = $showkeys;
  31. $this->rendername = $name;
  32. }
  33. /**
  34. * オブジェクトの属性を設定します。つまり、 $key = $val;
  35. *
  36. * @param String $key 属性名は ExtJS オブジェクトの要件を満たす必要があります
  37. * @param Anly_type $val
  38. */
  39. public function __set($key, $val) {
  40. if ($key == 'indent' ) {
  41. $this->indent = $val;
  42. } else {
  43. $this->state [$key] = $val;
  44. }
  45. }
  46. public function __get($key) {
  47. if (isset ($this->state[$key]))
  48. return $this->state [$key];
  49. }
  50. public function __isset($key) {
  51. return isset($this->state [$ key]);
  52. }
  53. public function del($key) {
  54. $this->unset($key);
  55. }
  56. public function __unset($key) {
  57. unset($this->state [ $key]);
  58. }
  59. public function __toString() {
  60. return $this->render();
  61. }
  62. /**
  63. * 属性 $name の属性値を $property に設定します
  64. *
  65. * @param String $name 属性名
  66. * @param 混合 $property 属性値
  67. */
  68. public function setProperty($name, $property) {
  69. if (!empty($name)) {
  70. $this->state [$name] = $property;
  71. }
  72. }
  73. /**
  74. * 構成配列 $properties に従って ExtClass プロパティを設定します
  75. *
  76. * @param ConfigArray $properties 構成配列
  77. */
  78. public function setProperties($properties) {
  79. $this->state = array_merge($this->state, $properties);
  80. }
  81. public function setExtendsClass($ExtClass) {
  82. $this->extend = $ExtClass;
  83. }
  84. public function JSRender ($items, $showkeys = true, $isparam = false) {
  85. //self::$indent .= ' ';
  86. $str = '';
  87. $total = count($items);
  88. $cnt = 1 ;
  89. if ($isparam && $total == 2 && is_object($items [0]) && is_array($items [1])) {
  90. $str .= "{{$this->JSRender($items[ 0])}},";
  91. $str .= "[{$this->JSRender($items[1])}]";
  92. } else {
  93. foreach ($items as $element => $value) {
  94. if ($showkeys) {
  95. if (is_numeric($showkeys)) {
  96. $str .= self::$indent . "'$element':";
  97. } else {
  98. if (!is_numeric($element))
  99. $str .= self::$indent . "$element: ";
  100. }
  101. }
  102. if (is_string($value)) {
  103. $str .= "'$value'";
  104. } else if (is_bool($value)) {
  105. $str .= ( $値)? "true" : "false";
  106. } else if (is_object($value)) {
  107. if (method_exists($value, 'render')) {
  108. $str .= $value->render();
  109. }
  110. } else if (is_array($value)) {
  111. if (count($value) == 1 && is_string($value [0])) {
  112. $str .= $value [0];
  113. }else {
  114. $str .= "[";
  115. $str .= $this->JSRender($value, false);
  116. $str .= self::$indent . "]";
  117. }
  118. } else if (is_numeric($value)) {
  119. $str .= $value;
  120. } else if ($value == '') {
  121. $str .= "''";
  122. } else {
  123. $str .= $value;
  124. }
  125. if ($cnt != $total) {
  126. $str .= ",";
  127. }
  128. $cnt++;
  129. }
  130. }
  131. self::$indent = substr(self::$indent, 0, - 2);
  132. return $str;
  133. }
  134. /**
  135. * 構築された ExtJs オブジェクトの Js コードを返します
  136. *
  137. * @param String $name
  138. * @return String
  139. */
  140. public function render($name = null) {
  141. $str = '';
  142. if (!empty($name))
  143. $this->rendername = $name;
  144. if (
  145. preg_match('/.alert/', $this->extClass) || preg_match('/.prompt/ ', $this->extClass)
  146. || preg_match('/.show/', $this->extClass) || preg_match('/.confirm/', $this->extClass)
  147. || ('/.progress/', $this->extClass) || preg_match('/.wait/', $this->extClass)
  148. || preg_match('/.updateProgress/', $this-> extClass)
  149. || preg_match('/.updateText/', $this->extClass)
  150. ) {
  151. if (!empty($this->rendername))
  152. $str = self::$indent . "var $this->rendername = $this->extClass(";
  153. else
  154. $str = self::$indent . "$this->extClass (";
  155. $str .= $this-> JSRender($this->state, FALSE);
  156. $str .= ");";
  157. } elseif (
  158. preg_match('/.ColumnModel/', $this->extClass) || preg_match('/. Record.create/', $this->extClass)
  159. ) {
  160. if (!empty($this->rendername))
  161. $str = self::$indent . "var $this->rendername = new $this->extClass([";
  162. else
  163. $str = self::$indent . "new $this->gt;extClass ([";
  164. $str .= $this->JSRender($this-> ;state, TRUE);
  165. $str .= "])";
  166. if ($this->rendername) {
  167. $str .= ";";
  168. }
  169. } elseif (
  170. preg_match('/.JsonReader/ ', $this->extClass) || preg_match('/.ArrayReader/', $this->extClass)
  171. ) {
  172. if (!empty($this->rendername))
  173. $str = self: :$indent . "var $this->rendername = new $this->extClass(";
  174. else
  175. $str = self::$indent . "new $this->extClass (";
  176. if (!empty($this->state['fields'])) {
  177. $str .= "{totalProperty:'" . $this->state[ 'totalProperty'] . "', ";
  178. $str .= "root:'" . $this->state['root'] . "'},";
  179. $str .= "[" . ->JSRender($this->state['fields'], TRUE) . "]";
  180. } else {
  181. $str .= $this->JSRender($this->state, TRUE);
  182. }
  183. $str .= ")";
  184. if ($this->rendername) {
  185. $str .= ";";
  186. }
  187. } elseif ($this->extend) { //如果是扩展对象
  188. $str = self::$indent 。 $this->extClass 。 " = Ext.extend( $this->extend ,{";
  189. $str .= $this->JSRender($this->state, TRUE);
  190. $str .= "});";
  191. } else {
  192. if ($this->rendername) {
  193. if ($this->extClass) {
  194. $str = self::$indent . "var $this->rendername = new $this->extClass({";
  195. } else {
  196. $str = self::$indent . "var $this->rendername = {";
  197. }
  198. } elseif ($this->extClass) {
  199. echo self::$indent;
  200. $str = self::$indent . "new $this->extClass({";
  201. } else {
  202. $str = self: :$indent . "{";
  203. }
  204. $str .= $this->JSRender($this->state, $this->showkeys);
  205. $str .= self::$indent "} ";
  206. if ($this->extClass) {
  207. $str .= ")";
  208. }
  209. if ($this->rendername) {
  210. $str .= ";";
  211. }
  212. }
  213. return $str;
  214. }
  215. }
  216. ?>
复制代
  1. /**
  2. * PHPExtJs ExtJs ページ オブジェクト
  3. * @License: ( http://www.apache.org/licenses/LICENSE-2.0 )
  4. * @Author: wb
  5. */
  6. class ExtPage {
  7. public $extjs = '';
  8. public $extbase = '';
  9. public $body = '';
  10. public $bodyPapm = '';
  11. public $title = '';
  12. public $charset = '';
  13. public $template = "";
  14. /**
  15. * ページテンプレートに従って extjshtml コードを出力します
  16. * テンプレートには、{charset}、{title}、{extbase}、{extjs}、{body} を含めることができます
  17. *
  18. * @param String $title ページタイトル
  19. * @param String $ extjs extjs code
  20. * @param String $body ページの本文
  21. * @param String $charset ページのエンコード設定、デフォルトは UTF-8 です
  22. * @param String $template ページのテンプレート
  23. */
  24. public function __construct($title='', $extjs ='', $extbase='', $body='', $charset='utf-8', $template='') {
  25. $this->title = $title;
  26. $this->extjs = $extjs;
  27. $this->extbase = $extbase;
  28. $this->gt;body = $body;
  29. $this->charset = $charset;
  30. if(!empty($template)) $this- >template = $template;
  31. else $this->template = "
  32. {title}
  33. {extbase}
  34. {body}
  35. ";
  36. }
  37. public function render() {
  38. if(!empty($this->template) ){
  39. $search = array("{charset}","{title}","{extbase}","{extjs}","{body}","{bodyPapm}");
  40. $replace = array ($this->charset,$this->title,$this->extbase,$this->extjs,$this->body,$this->bodyPapm);
  41. $this->gt; template = str_replace($search,$replace,$this->template);
  42. echo $this->template;
  43. }else{
  44. throw new Exception("页面模板は空,请先设置页面模板!") ;
  45. }
  46. }
  47. public function __set($key, $val) {
  48. switch($key) {
  49. case 'extjs':
  50. $this->extjs = $val;
  51. Break;
  52. case 'body' :
  53. $this->body = $val;
  54. Break;
  55. case 'bodyPapm':
  56. $this->bodyPapm = $val;
  57. Break;
  58. case 'charset':
  59. $this->body = $ val;
  60. Break;
  61. case 'template':
  62. $this->template = $val;
  63. Break;
  64. case 'extbase':
  65. $this->extbase = $val;
  66. Break;
  67. デフォルト:
  68. throw new Exception("非法的ExtPage プロパティ ExtPage::$key");
  69. }
  70. }
  71. public function __get($key) {
  72. switch($key) {
  73. case 'extjs':
  74. return $this-> extjs;
  75. case 'body':
  76. return $this->body;
  77. case 'bodyPapm':
  78. return $this->bodyPapm;
  79. case 'charset':
  80. return $this->charset;
  81. case ' template':
  82. return $this->template;
  83. default:
  84. throw new Exception("非法的ExtPage property ExtPage::$key");
  85. }
  86. }
  87. }
复制代
  1. /**
  2. * +---------------------------------------------- -----------------------
  3. * | PHPExtJs
  4. * +---------------------------------------------- ------------------------
  5. * | @License: ( http://www.apache.org/licenses/LICENSE-2.0 )
  6. * +-------------------------------------- ------------------------------------------
  7. * | @著者: wb
  8. * +------------------------------------- -----------------------------------
  9. */
  10. class ExtData extends ExtBase {
  11. public $Data = array ();
  12. public $DataName = '';
  13. public $isGridData = false;
  14. / **
  15. * 新しい ExtJs データセットを作成します。表形式データの場合は、テーブルの Json データ形式に自動的にフォーマットされます
  16. *
  17. * @param Array $DataArray データセット
  18. * @param String $DataName データセット名
  19. * @ param Blooen $ isGridData はテーブルデータです
  20. */
  21. public function __construct($DataArray, $DataName = '', $isGridData = false) {
  22. $this->setDataArray ( $DataArray );
  23. if (! empty ( $DataName )) {
  24. $this->DataName = $DataName;
  25. }
  26. if (is_bool ( $isGridData )) {
  27. $this->isGridData = $isGridData;
  28. }
  29. }
  30. /**
  31. * ExtData オブジェクトのデータセットを設定します
  32. *
  33. * @param Array $DataArray
  34. */
  35. public function setDataArray($DataArray) {
  36. if (! empty ( $DataArray ) && is_array ( $DataArray )) {
  37. $this->Data = $DataArray;
  38. }
  39. }
  40. /**
  41. *オブジェクトのJS文字列を取得します
  42. * @return string
  43. */
  44. public function getJavascript() {
  45. $str = '';
  46. if (! empty ( $this->DataName )) {
  47. $str .= "var $this->DataName = ";
  48. }
  49. if ($this ->isGridData) {
  50. $j = 0;
  51. $count = count ( $this->Data );
  52. $str .= "{totalProperty:$count,root:[";
  53. foreach ( $this-> ;$value としてのデータ) {
  54. if($j>0) $str .= ",";
  55. $str .= "[".$this->JSRender ( $value )."]";
  56. $j ++;
  57. }
  58. $str .= "]}";
  59. } else {
  60. $str .= "[".$this->JSRender ( $this->Data )."]";
  61. // $str .= $this->JSRender ( $this->Data );
  62. }
  63. if (! empty ( $this->DataName )) {
  64. $str .= ";";
  65. }
  66. return $str;
  67. }
  68. /**
  69. * $DataのデータをJS形式で出力します
  70. *
  71. * @param Array $Data 出力するデータ
  72. */
  73. public function JSRender($Data = Array()) {
  74. $str = "";
  75. foreach ( $Data as $element => $value ) {
  76. if(!empty($str)) $str .= ",";
  77. /*if (!is_numeric($ element)) {
  78. $str .= "'$element':";
  79. }*/
  80. if (is_string ( $value )) {
  81. $str .= "'$value'";
  82. } else if (is_bool ( $value )) {
  83. $str .= ($value) ? "true" : "false";
  84. } else if (is_array ( $value )) {
  85. if (count ( $value ) == 1 && is_string ( $value [0] )) {
  86. $str .= $value [ 0];
  87. } else {
  88. $str .= "[";
  89. $str .= $this->JSRender ( $value, false );
  90. $str .= "]";
  91. }
  92. } else {
  93. if(empty($value)){
  94. $str .= "''";
  95. }else{
  96. $str .= $value;
  97. }
  98. }
  99. }
  100. return $str;
  101. }
  102. public function render( ) {
  103. return $this->getJavascript ();
  104. }
  105. public function show() {
  106. echo $this->getJavascript ();
  107. }
  108. public function __toString() {
  109. return $this->gt; getJavascript ();
  110. }
  111. }
  112. ?>
复制代
  1. /**
  2. * +---------------------------------------------- -----------------------
  3. * | PHPExtJs
  4. * +---------------------------------------------- ------------------------
  5. * | @License: ( http://www.apache.org/licenses/LICENSE-2.0 )
  6. * +-------------------------------------- ------------------------------------------
  7. * | @著者: wb
  8. * +------------------------------------- -----------------------------------
  9. */
  10. include_once "ExtBase.class.php";
  11. include_once "ExtObject.class.php";
  12. include_once "ExtFunction.class.php";
  13. include_once " ExtPage.class.php";
  14. class viewport extends ExtBase{
  15. private $vpbody = null;
  16. public $property = array();
  17. public $items = array();
  18. /**
  19. * $configに従ってビューポートを設定します
  20. */
  21. public function __construct($config=array()) {
  22. if(!empty($config) && is_array($config)){
  23. foreach ($config as $k => $v){
  24. if($k == 'items') continue;
  25. $this->setProperty($k,$v);
  26. }
  27. if( !empty($config['items'])){
  28. if( is_array($config['items' ]) ){
  29. foreach ($config['items'] as $v){
  30. $this->addItems($v);
  31. }
  32. }else{
  33. $this->addItems($v);
  34. }
  35. }
  36. }
  37. }
  38. /**
  39. * プロパティ値 $value に従って $property 属性を設定します
  40. *
  41. * @param String $property プロパティ名
  42. * @param 混合 $value プロパティ値
  43. */
  44. public function setProperty($property,$value){
  45. if(!empty($property) && !empty($value)) $this-> property[$property] = $value;
  46. }
  47. /**
  48. * Viewportの表示オブジェクトを追加
  49. *
  50. * @param ExtObject $object
  51. */
  52. public function addItems($object){
  53. if(!empty($object)){
  54. $this->items[] = $object;
  55. }
  56. }
  57. /**
  58. * ビューポートを初期化します
  59. */
  60. プライベート関数 init(){
  61. $obj = new ExtObject("Ext.Viewport",array());
  62. $obj->setProperties( $this->property);
  63. $obj->setProperty("items",$this->items);
  64. $this->vpbody = $obj;
  65. }
  66. /**
  67. * ビューポートの JS を取得します
  68. *
  69. * @return String
  70. * /
  71. public function getJavascript(){
  72. $this->init();
  73. return $this->vpbody->render("vport");
  74. }
  75. /**
  76. *
  77. */
  78. public function render(){
  79. $js = $this->getJavascript ();
  80. $default = isset ( $_COOKIE ['exttheme'] ) ? $_COOKIE ['exttheme'] : $_SESSION ['SYS_THEM'];
  81. if (! empty ( $default ))
  82. $this->setExtCss ( $default ); //EXTJS の表示形式を設定します
  83. //extjs の表示面を設定し、表示面の基本 ext 実行環境を設定します
  84. $page = new ExtPage ( );
  85. $page->extbase = $this->getExtBaseCode (); //extBase
  86. を設置します
  87. $page->extjs .= "Ext.onReady(function(){";
  88. $page->extjs .= $js;
  89. $page->extjs .= "}) ;";
  90. //$page->body = "
    ";
  91. $page->render ();
  92. }
  93. public function show( ){
  94. $this->render();
  95. }
  96. public function __toString(){
  97. return $this->getJavascript();
  98. }
  99. }
  100. ?>
复制代
  1. /**
  2. * +---------------------------------------------- -----------------------
  3. * | PHPExtJs
  4. * +---------------------------------------------- ------------------------
  5. * | @License: ( http://www.apache.org/licenses/LICENSE-2.0 )
  6. * +-------------------------------------- ------------------------------------------
  7. * | @著者: wb
  8. * +------------------------------------- -----------------------------------
  9. */
  10. include_once "ExtBase.class.php";
  11. include_once "ExtObject.class.php";
  12. include_once "ExtFunction.class.php";
  13. include_once " ExtPage.class.php";
  14. class Window extends ExtBase {
  15. private $winname = '';
  16. private $winbody = null;
  17. private $winitems = null;
  18. private $winbutton = null;
  19. private $winbbar = null;
  20. private $property = array ();
  21. /**
  22. * Extjs ウィンドウを生成します
  23. * @param String $name ウィンドウ名
  24. * @param Array $config 設定配列
  25. */
  26. public function __construct($name,$config) {
  27. //parent::__construct ();
  28. if(!empty($name) ){
  29. $this->winname = $name;
  30. }
  31. if (! empty ( $config ) && is_array ( $config )) {
  32. foreach ( $config as $k => $v ) {
  33. if ( $k == 'アイテム' || $k == 'bbar' || $k == 'ボタン')
  34. $this->setProperty ( $k, $v );
  35. }
  36. if (! empty ( $config ['items'] )) {
  37. if (is_array ( $config ['items'] )) {
  38. foreach ( $config ['items'] as $v ) {
  39. $this->addItems ( $v );
  40. }
  41. } else {
  42. $this->addItems ( $v );
  43. }
  44. }
  45. if (! empty ( $config ['bbar'] )) {
  46. if (is_array ( $config [ 'bbar'] )) {
  47. foreach ( $config ['bbar'] as $v ) {
  48. $this->addBbar ( $v );
  49. }
  50. } else {
  51. $this->addBbar ( $v );
  52. }
  53. }
  54. if (! empty ( $config ['buttons'] )) {
  55. if (is_array ( $config ['buttons'] )) {
  56. foreach ( $config ['buttons'] as $v ) {
  57. $this->addBbar ( $v );
  58. }
  59. } else {
  60. $this->addBbar ( $v );
  61. }
  62. }
  63. }
  64. }
  65. /**
  66. * プロパティ値 $value に従って $property 属性を設定します
  67. *
  68. * @param String $property プロパティ名
  69. * @param 混合 $value プロパティ値
  70. */
  71. public function setProperty($property, $value ) {
  72. if (! empty ( $property ) && ! empty ( $value ))
  73. $this->property [$property] = $value;
  74. }
  75. /**
  76. * Windows 表示オブジェクトを追加します
  77. *
  78. * @param ExtObject $object
  79. */
  80. public function addItems ($object) {
  81. if (! empty ( $object )) {
  82. $this->winitems [] = $object;
  83. }
  84. }
  85. /**
  86. * Windows ツールを追加
  87. *
  88. * @param Mixed $object
  89. */
  90. public function addBbar($object) {
  91. if (! empty ( $object )) {
  92. $this->winbbar [] = $object;
  93. }
  94. }
  95. /**
  96. * Windows ボタンを追加
  97. *
  98. * @param Mixed $object
  99. */
  100. public function addButton($object) {
  101. if ( ! empty ( $object )) {
  102. $this->winbutton [] = $object;
  103. }
  104. }
  105. プライベート関数 init() {
  106. $obj = new ExtObject ( "Ext.Window", array () ) ;
  107. $obj->setProperties ( $this->property );
  108. if (! empty ( $this->winbbar ))
  109. $obj->setProperty ( "bbar", $this->winbbar ) ;
  110. if (! empty ( $this->winitems ))
  111. $obj->setProperty ( "items", $this->winitems );
  112. if (! empty ( $this->winbutton ))
  113. $obj->setProperty ( "ボタン", $this->winbutton );
  114. $this->winbody = $obj;
  115. }
  116. /**
  117. * Windows オブジェクトの JS を取得します
  118. *
  119. * @param String $winName
  120. */
  121. public function getJavascript() {
  122. $this->init ();
  123. if (! empty ( $this->winname ))
  124. return $this->winbody->render ( $this- >winname ) 。 "{$this->winname}.show();";
  125. else
  126. return $this->winbody->render ();
  127. }
  128. public function render($winName = '') {
  129. $ js = $this->getJavascript ( $winName );
  130. //extjs の構築面の基本 ext 実行環境
  131. $page = new ExtPage ();
  132. $page->extbase = $this-> ;getExtBaseCode(); //extBase
  133. を設置します
  134. $page->extjs .= "Ext.onReady(function(){";
  135. $page->gt;extjs .= $js;
  136. $page->extjs .= "}) ;";
  137. $page->render ();
  138. }
  139. public function show($winName = 'win1') {
  140. $this->render ( $winName );
  141. }
  142. public function __toString( ) {
  143. return $this->getJavascript ();
  144. }
  145. }
  146. ?>
コードをコピー
  1. vendor("com.qldx.ext.*");
  2. class FormWin extends Form {
  3. /**
  4. * 初期データをフォームにロードするためのオブジェクト
  5. * @var ExtObject
  6. */
  7. public $formLoad = null;
  8. /* *
  9. * フォームがデータを読み取るオブジェクト
  10. * @var ExtObject
  11. */
  12. public $formreader = null;
  13. /**
  14. * データのロード時に渡されるパラメータ
  15. * @var Mixed
  16. */
  17. public $formLoadParam = null;
  18. /**
  19. * ウィンドウオブジェクト
  20. * @var ExtObject
  21. */
  22. public $windolg = null;
  23. /**
  24. * フォームフィールドセット
  25. * @var 配列
  26. */
  27. public $fieldset = array();
  28. /**
  29. * フォームオブジェクトを初期化するコード
  30. * @var String
  31. */
  32. public $initcorde = '';
  33. /**
  34. * フォームにはボタンが含まれていません。これは、ボタンが含まれていることを意味します。*/
  35. public $noButton = false;
  36. /* *
  37. * フォームを構築します
  38. * @param String $formName フォーム名
  39. * @param String $ModelName フォーム関連データテーブルのモデル名
  40. * @param Mixed $dataId フォーム関連データ ID
  41. * @param Array $Properties ウィンドウ 本体属性配列
  42. */
  43. public function __construct($formName = '', $ModelName = "", $dataId = "", $Properties = array()) {
  44. parent::__construct($formName, $ModelName, $ dataId, $Properties);
  45. $this->formbody->setProperty("labelWidth", 80);
  46. $this->formbody->setProperty("defaults", array("{xtype:'textfield' ,anchor:'100%'}"));
  47. $this->windolg = new ExtObject("FormWin",
  48. array(
  49. 'id' => $this->formName,
  50. 'name' => ; $this->フォーム名,
  51. 'データID' => $this->データID,
  52. 'タイトル' => $this->formbody->title,
  53. 'collapsible' => true,
  54. '最大化可能' => true,
  55. 'レイアウト' => 'フィット',
  56. 'プレーン' => true,
  57. 'bodyStyle' => 'padding:5px;',
  58. 'buttonAlign' => 'center',
  59. "msk" => array("new Ext.LoadMask(Ext.getBody(), {msg : '正加下数据,请稍等...'})"),
  60. "createFormPanel" => null,
  61. "initComponent" => null
  62. )
  63. );
  64. $this->initcorde = new ExtFunction(NULL, "
  65. this.keys={
  66. キー: Ext.EventObject.ENTER,
  67. fn: this.save,
  68. スコープ: this
  69. };
  70. FormWin.superclass.initComponent.call(this);
  71. this.fp=this.createFormPanel();
  72. this.add(this.fp);
  73. if(!this.dataID && this.loadParam.id){
  74. this. dataID = this.loadParam.id
  75. }
  76. ");
  77. }
  78. /**
  79. * フォームのデフォルトの初期化コードを設定します
  80. * @param 混合 $code コード文字列または ExtObject オブジェクト
  81. */
  82. public function setFormInitCode($code) {
  83. $this->initcorde->SetCode($code);
  84. }
  85. /**
  86. * フォーム読み込みイベントを設定します。 注: $obj が空の場合は、デフォルトの Loader を追加する必要があります。
  87. * 最初に setFormLoaderParam メソッドを通じて他のオブジェクトを設定します
  88. * @param ExtObject $obj フォームローダーオブジェクト
  89. */
  90. public function setFormLoader($obj = null) {
  91. $tobj = null;
  92. $param = null;
  93. if ($this->dataId) {
  94. $param = new ExtObject(null, array('id' => $this->dataId));
  95. } else {
  96. $param = new ExtObject(null, array('id' => array('this.dataID' )));
  97. }
  98. if (!empty($obj) && is_object($obj)) {
  99. if (!isset($obj->param) || empty($obj->param)) {
  100. $this->setProperty("loadParam", $obj->param);
  101. $this->del('param');
  102. } else { //追加されるオブジェクトにparamが含まれていない場合、事前に設定されたloadParam
  103. $this->setProperty("loadParam", $param);
  104. }
  105. $obj->param = array("this.loadParam");
  106. $tobj = $obj;
  107. }else {
  108. $this->setProperty("loadParam", $param);
  109. $tobj = new ExtObject(null, array(
  110. "url" => __URL__ . "/getFormWinData",
  111. "params" => array('this.loadParam'),
  112. "success" => new ExtFunction(Null, "
  113. this.msk.hide();
  114. "),
  115. "scope" => array('this')
  116. ) );
  117. }
  118. $this->formLoad = $tobj;
  119. }
  120. /**
  121. * フォームのデータ読み込み Loader オブジェクトのプロパティを設定します
  122. * @param String $attrib
  123. * @param Mixed $value
  124. */
  125. public function setFormLoaderProperty($attrib, $value) {
  126. $this->formLoad-> setProperty($attrib, $value);
  127. }
  128. /**
  129. * フォーム読み込みオブジェクトの追加パラメータを設定します
  130. * @param String $param パラメータ名
  131. * @param Mixed $value パラメータ値
  132. */
  133. public function setFormLoaderParam($param, $value) {
  134. $this->formLoadParam->setProperty($param, $value) );
  135. }
  136. /**
  137. * ウィンドウコンテナの属性を設定します
  138. * @param String $attrib
  139. * @param Mixed $value
  140. */
  141. public function setWindowsProperty($attrib, $value) {
  142. $this->windolg->setProperty($attrib, $value);
  143. }
  144. / **
  145. * フォームリーダーのデータ識別子を設定します フォームリーダー
  146. */
  147. プライベート関数 setFormReader() {
  148. $this->formreader = new ExtObject(
  149. 'Ext.data.JsonReader',
  150. array(
  151. new ExtObject(
  152. null,
  153. array("root" => "データ")
  154. ),
  155. $this->fieldset
  156. )
  157. );
  158. }
  159. プライベート関数 setFormInt() {
  160. $twidth = 0;
  161. $tmpwidth = 16;
  162. $tmpheight = 40;
  163. / /form 体の会話取得データのマーク フィールド名列表
  164. foreach ($this->formFields as $n => $f) {
  165. $this->fieldset[] = new ExtObject(null, array(' name' => $n, 'mapping' => $n));
  166. }
  167. //そして体の高さ
  168. if (empty($this->windolg->height)) {
  169. foreach ($this->formFields as $n => $f) {
  170. if (isset($f->height) && $f->height > 0) {
  171. $tmpheight += $f-> ;height;
  172. } else {
  173. $tmpheight += 32;
  174. }
  175. if (isset($f->width) && $f->width > $tmpwidth) {
  176. $twidth = $f->; width;
  177. }
  178. }
  179. } else {
  180. $tmpheight = $this->windolg->height;
  181. $twidth = $this->windolg->width;
  182. }
  183. if (empty($tmpheight) ) {
  184. $tmpheight = 200;
  185. } elseif ($tmpheight > 750) {
  186. $tmpheight = 750;
  187. }
  188. if (empty($twidth)) {
  189. $tmpwidth += $twidth;
  190. }
  191. if (empty($tmpwidth) || $tmpwidth == 16) {
  192. $ tmpwidth = 340;
  193. }
  194. $this->windolg->setProperty("width", $tmpwidth);
  195. $this->windolg->setProperty("height", $tmpheight);
  196. $this- >windolg->setProperty("minWidth", $tmpwidth);
  197. $this->windolg->setProperty("minHeight", $tmpheight);
  198. }
  199. /**
  200. * フォームのデフォルトの追加ボタンを追加します
  201. * @param String $name デフォルトは: save
  202. * @param String $title デフォルトは: save
  203. * @param ExtFunction $hander デフォルトのイベント応答オブジェクト
  204. */
  205. public function addSaveButton($name = 'save', $title='保存', $hander=null) {
  206. if (empty($hander)) {
  207. $hander = new ExtFunction(null, "
  208. if(this.fp. form.isValid()){
  209. var turl = '" . __URL__ . "/saveFormWinData';
  210. if(this.dataID){
  211. turl += '/id/'+ this.dataID;
  212. }
  213. var fw = this;
  214. this.fp.form.submit({
  215. waitTitle: 'お待ちください',
  216. waitMsg : 'リクエストを処理中...',
  217. url : turl,
  218. params: this.loadParam,
  219. success : function(form, action){
  220. fw.close();
  221. if(form.rGrid){
  222. if(form.rGrid.root){
  223. form.rGrid.getLoader().load(form.rGrid.root );
  224. }else{
  225. form.rGrid.getLoader().load();
  226. }
  227. }
  228. },
  229. 失敗 : function() {
  230. fw.close;
  231. Ext.Msg.alert('システム エラー', 'Anサーバーでエラーが発生しました。後でもう一度お試しください。');
  232. }
  233. });
  234. }
  235. ");
  236. }
  237. $this->addButton($name, $title);
  238. $this->setButtonAttrib ( $name, 'handler', $hander);
  239. }
  240. /**
  241. * デフォルトのキャンセルボタンを追加します
  242. * @param String $name
  243. * @param String $title
  244. * @param ExtFunction $hander
  245. */
  246. public function addCancelButton($name = 'cancle', $title='Cancel', $hander=null) {
  247. if (empty($hander)) {
  248. $hander = new ExtFunction(null, "
  249. this.close();
  250. ");
  251. }
  252. $this->addButton($name, $title);
  253. $this - >setButtonAttrib($name, 'handler', $hander);
  254. }
  255. /**
  256. * モデルオブジェクト名に従って FormWin データモデルを設定します
  257. *
  258. * @param String $modelName モデルオブジェクト名
  259. * @param レコード番号に編集する $id を混合します
  260. */
  261. public function setDataModel($modelObject, $id) {
  262. $this->setDataSource($modelObject) , $id);
  263. }
  264. /**
  265. * モデルオブジェクト名に従って FormWin データモデルを設定します
  266. * @param String $modelName モデルオブジェクト名
  267. */
  268. public function setDataModelByName($modelName) {
  269. if (!empty($modelName)) {
  270. $model = D($modelName);
  271. $this - >setDataModel($model);
  272. }
  273. }
  274. /**
  275. * このメソッドは、このオブジェクトの JS 文字列を返します
  276. * @return String このオブジェクトの JS 文字列
  277. */
  278. public function getJavascript() {
  279. $this->initForm();
  280. $this->setFormInt();
  281. $this->setFormReader();
  282. $this->setFormLoader();
  283. //フォームに組み込まれたデータ読み込みオブジェクト
  284. $this->setFormInitCode("
  285. this.fp.load(" . $this ->formLoad->render() . ");
  286. ");
  287. //フォームの基本プロパティを設定します
  288. if (empty($this->formbody->baseCls)) {
  289. $this- > formbody->setproperty('baseCls', 'x-plain');
  290. }
  291. if (empty($this->formbody->reader)) {
  292. $this->formbody->setProperty (" Reader", $this->formreader);
  293. }
  294. $this->formbody->setProperty("items", $this->getElementArray());
  295. // ウィンドウを作成します
  296. $this- >windolg->setProperty(
  297. "createFormPanel",
  298. new ExtFunction(null,
  299. array("return" => $this->formbody->render())
  300. )
  301. );
  302. //追加button
  303. if (!$this->noButton) {
  304. if (!empty($this->formButtons) && is_array($this->formButtons)) {
  305. foreach ($this->formButtons as $k) => ; $v) {
  306. $this->initcorde->SetCode("this.addButton('" . $v->text . "',this." . $k . ",this);" );
  307. $this->windolg->setProperty($k, $v->handler);
  308. }
  309. } else {
  310. $this->initcorde->SetCode("
  311. this.addButton(' Save' ,this.save,this);
  312. this.addButton('Cancel', function(){this.close();},this);
  313. ");
  314. }
  315. }
  316. $this->windolg- > setProperty("initComponent", $this->initcorde);
  317. $this->windolg->setExtendsClass("Ext.Window");
  318. $this->formExtendJs を返します。 -> ;render();
  319. }
  320. }
  321. ?>
コードをコピー


このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

JSON Web Tokens(JWT)とPHP APIでのユースケースを説明してください。 JSON Web Tokens(JWT)とPHP APIでのユースケースを説明してください。 Apr 05, 2025 am 12:04 AM

JWTは、JSONに基づくオープン標準であり、主にアイデンティティ認証と情報交換のために、当事者間で情報を安全に送信するために使用されます。 1。JWTは、ヘッダー、ペイロード、署名の3つの部分で構成されています。 2。JWTの実用的な原則には、JWTの生成、JWTの検証、ペイロードの解析という3つのステップが含まれます。 3. PHPでの認証にJWTを使用する場合、JWTを生成および検証でき、ユーザーの役割と許可情報を高度な使用に含めることができます。 4.一般的なエラーには、署名検証障害、トークンの有効期限、およびペイロードが大きくなります。デバッグスキルには、デバッグツールの使用とロギングが含まれます。 5.パフォーマンスの最適化とベストプラクティスには、適切な署名アルゴリズムの使用、有効期間を合理的に設定することが含まれます。

PHPにおける後期静的結合の概念を説明します。 PHPにおける後期静的結合の概念を説明します。 Mar 21, 2025 pm 01:33 PM

記事では、PHP 5.3で導入されたPHPの後期静的結合(LSB)について説明し、より柔軟な継承を求める静的メソッドコールのランタイム解像度を可能にします。 LSBの実用的なアプリケーションと潜在的なパフォーマ

フレームワークセキュリティ機能:脆弱性から保護します。 フレームワークセキュリティ機能:脆弱性から保護します。 Mar 28, 2025 pm 05:11 PM

記事では、入力検証、認証、定期的な更新など、脆弱性から保護するためのフレームワークの重要なセキュリティ機能について説明します。

フレームワークのカスタマイズ/拡張:カスタム機能を追加する方法。 フレームワークのカスタマイズ/拡張:カスタム機能を追加する方法。 Mar 28, 2025 pm 05:12 PM

この記事では、フレームワークにカスタム機能を追加し、アーキテクチャの理解、拡張ポイントの識別、統合とデバッグのベストプラクティスに焦点を当てています。

PHPのCurlライブラリを使用してJSONデータを含むPOSTリクエストを送信する方法は? PHPのCurlライブラリを使用してJSONデータを含むPOSTリクエストを送信する方法は? Apr 01, 2025 pm 03:12 PM

PHP開発でPHPのCurlライブラリを使用してJSONデータを送信すると、外部APIと対話する必要があることがよくあります。一般的な方法の1つは、Curlライブラリを使用して投稿を送信することです。

確固たる原則と、それらがPHP開発にどのように適用されるかを説明してください。 確固たる原則と、それらがPHP開発にどのように適用されるかを説明してください。 Apr 03, 2025 am 12:04 AM

PHP開発における固体原理の適用には、次のものが含まれます。1。単一責任原則(SRP):各クラスは1つの機能のみを担当します。 2。オープンおよびクローズ原理(OCP):変更は、変更ではなく拡張によって達成されます。 3。Lischの代替原則(LSP):サブクラスは、プログラムの精度に影響を与えることなく、基本クラスを置き換えることができます。 4。インターフェイス分離原理(ISP):依存関係や未使用の方法を避けるために、細粒インターフェイスを使用します。 5。依存関係の反転原理(DIP):高レベルのモジュールと低レベルのモジュールは抽象化に依存し、依存関係噴射を通じて実装されます。

セッションのハイジャックはどのように機能し、どのようにPHPでそれを軽減できますか? セッションのハイジャックはどのように機能し、どのようにPHPでそれを軽減できますか? Apr 06, 2025 am 12:02 AM

セッションハイジャックは、次の手順で達成できます。1。セッションIDを取得します。2。セッションIDを使用します。3。セッションをアクティブに保ちます。 PHPでのセッションハイジャックを防ぐための方法には次のものが含まれます。1。セッション_regenerate_id()関数を使用して、セッションIDを再生します。2。データベースを介してストアセッションデータを3。

See all articles