PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/api/_biz_data_tree_8php_source.html

http://openbiz-cubi.googlecode.com/
HTML | 143 lines | 142 code | 0 blank | 1 comment | 0 complexity | ff91c67528e02710ee90362780bb82d5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>openbiz: E:/E/GEAMP/www/openbiz/openbiz/bin/data/BizDataTree.php Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.7.2 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul class="tablist">
  14. <li><a href="main.html"><span>Main&#160;Page</span></a></li>
  15. <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  16. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  17. <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
  18. <li class="current"><a href="files.html"><span>Files</span></a></li>
  19. </ul>
  20. </div>
  21. <div class="tabs2">
  22. <ul class="tablist">
  23. <li><a href="files.html"><span>File&#160;List</span></a></li>
  24. </ul>
  25. </div>
  26. <div class="header">
  27. <div class="headertitle">
  28. <h1>E:/E/GEAMP/www/openbiz/openbiz/bin/data/BizDataTree.php</h1> </div>
  29. </div>
  30. <div class="contents">
  31. <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?<a class="code" href="category_p_h_p.html">PHP</a>
  32. <a name="l00017"></a>00017 include_once(OPENBIZ_BIN.<span class="stringliteral">&#39;data/BizDataObj.php&#39;</span>);
  33. <a name="l00018"></a>00018
  34. <a name="l00027"></a><a class="code" href="class_biz_data_tree.html">00027</a> <span class="keyword">class </span><a class="code" href="class_biz_data_tree.html">BizDataTree</a> <span class="keyword">extends</span> <a class="code" href="class_biz_data_obj.html">BizDataObj</a>
  35. <a name="l00028"></a>00028 {
  36. <a name="l00029"></a>00029 <span class="keyword">protected</span> $m_RootNodes;
  37. <a name="l00034"></a>00034 <span class="keyword">protected</span> $m_Depth;
  38. <a name="l00035"></a>00035
  39. <a name="l00040"></a>00040 <span class="keyword">protected</span> $m_globalSearchRule;
  40. <a name="l00041"></a>00041
  41. <a name="l00047"></a><a class="code" href="class_biz_data_tree.html#abed09406b8b4ab1618c60375ca26c840">00047</a> <span class="keyword">public</span> function <a class="code" href="class_biz_data_tree.html#abed09406b8b4ab1618c60375ca26c840">fetchTree</a>($rootSearchRule, $depth, $globalSearchRule=<span class="stringliteral">&quot;&quot;</span>)
  42. <a name="l00048"></a>00048 {
  43. <a name="l00049"></a>00049 $this-&gt;m_Depth = $depth;
  44. <a name="l00050"></a>00050 $this-&gt;m_globalSearchRule = $globalSearchRule;
  45. <a name="l00051"></a>00051
  46. <a name="l00052"></a>00052 <span class="comment">// query on given search rule</span>
  47. <a name="l00053"></a>00053 $searchRule = <span class="stringliteral">&quot;(&quot;</span> . $rootSearchRule . <span class="stringliteral">&quot;)&quot;</span>;
  48. <a name="l00054"></a>00054 <span class="keywordflow">if</span> ($globalSearchRule!=<span class="stringliteral">&quot;&quot;</span>)
  49. <a name="l00055"></a>00055 $searchRule .= <span class="stringliteral">&quot; AND (&quot;</span> . $globalSearchRule . <span class="stringliteral">&quot;)&quot;</span>;
  50. <a name="l00056"></a>00056 $recordList = $this-&gt;<a class="code" href="class_biz_data_obj___lite.html#a76dc543332df35530951dfd060fe1b21">directFetch</a>($searchRule);
  51. <a name="l00057"></a>00057 <span class="keywordflow">if</span> (!$recordList)
  52. <a name="l00058"></a>00058 {
  53. <a name="l00059"></a>00059 $this-&gt;m_RootNodes = array();
  54. <a name="l00060"></a>00060 <span class="keywordflow">return</span>;
  55. <a name="l00061"></a>00061 }
  56. <a name="l00062"></a>00062 <span class="keywordflow">foreach</span> ($recordList as $rec)
  57. <a name="l00063"></a>00063 {
  58. <a name="l00064"></a>00064 $this-&gt;m_RootNodes[] = <span class="keyword">new</span> <a class="code" href="class_node_record.html">NodeRecord</a>($rec);
  59. <a name="l00065"></a>00065 }
  60. <a name="l00066"></a>00066 <span class="keywordflow">if</span> ($this-&gt;m_Depth &lt;= 1)
  61. <a name="l00067"></a>00067 <span class="keywordflow">return</span> $this-&gt;m_RootNodes;
  62. <a name="l00068"></a>00068 <span class="keywordflow">if</span>(is_array($this-&gt;m_RootNodes)){
  63. <a name="l00069"></a>00069 <span class="keywordflow">foreach</span> ($this-&gt;m_RootNodes as $node)
  64. <a name="l00070"></a>00070 {
  65. <a name="l00071"></a>00071 $this-&gt;_getChildrenNodes($node, 1);
  66. <a name="l00072"></a>00072 }
  67. <a name="l00073"></a>00073 }
  68. <a name="l00074"></a>00074 <span class="keywordflow">return</span> $this-&gt;m_RootNodes;
  69. <a name="l00075"></a>00075 }
  70. <a name="l00076"></a>00076
  71. <a name="l00084"></a><a class="code" href="class_biz_data_tree.html#a389a4f4f663f435f55858948da2c7ca9">00084</a> <span class="keyword">public</span> function <a class="code" href="class_biz_data_tree.html#a389a4f4f663f435f55858948da2c7ca9">fetchNodePath</a>($nodeSearchRule, &amp;$pathArray)
  72. <a name="l00085"></a>00085 {
  73. <a name="l00086"></a>00086 $recordList = $this-&gt;<a class="code" href="class_biz_data_obj___lite.html#a76dc543332df35530951dfd060fe1b21">directFetch</a>($nodeSearchRule);
  74. <a name="l00087"></a>00087 <span class="keywordflow">if</span>(<a class="code" href="class_biz_data_obj___lite.html#ac751e87b3d4c4bf2feb03bee8b092755">count</a>($recordList)&gt;=1)
  75. <a name="l00088"></a>00088 {
  76. <a name="l00089"></a>00089
  77. <a name="l00090"></a>00090 <span class="keywordflow">if</span>($recordList[0][<span class="stringliteral">&#39;PId&#39;</span>]!=<span class="charliteral">&#39;0&#39;</span>)
  78. <a name="l00091"></a>00091 {
  79. <a name="l00092"></a>00092 $searchRule = <span class="stringliteral">&quot;[Id]=&#39;&quot;</span>.$recordList[0][<span class="stringliteral">&#39;PId&#39;</span>].<span class="stringliteral">&quot;&#39;&quot;</span>;
  80. <a name="l00093"></a>00093 $this-&gt;<a class="code" href="class_biz_data_tree.html#a389a4f4f663f435f55858948da2c7ca9">fetchNodePath</a>($searchRule, $pathArray);
  81. <a name="l00094"></a>00094 }
  82. <a name="l00095"></a>00095 $nodes = <span class="keyword">new</span> <a class="code" href="class_node_record.html">NodeRecord</a>($recordList[0]);
  83. <a name="l00096"></a>00096 array_push($pathArray,$nodes);
  84. <a name="l00097"></a>00097 <span class="keywordflow">return</span> $pathArray;
  85. <a name="l00098"></a>00098 }
  86. <a name="l00099"></a>00099 }
  87. <a name="l00100"></a>00100
  88. <a name="l00106"></a>00106 <span class="keyword">private</span> function _getChildrenNodes(&amp;$node, $depth)
  89. <a name="l00107"></a>00107 {
  90. <a name="l00108"></a>00108 $pid = $node-&gt;m_Id;
  91. <a name="l00109"></a>00109
  92. <a name="l00110"></a>00110 $searchRule = <span class="stringliteral">&quot;[PId]=&#39;$pid&#39;&quot;</span>;
  93. <a name="l00111"></a>00111 <span class="keywordflow">if</span> ($this-&gt;m_globalSearchRule!=<span class="stringliteral">&quot;&quot;</span>)
  94. <a name="l00112"></a>00112 $searchRule .= <span class="stringliteral">&quot; AND &quot;</span> . $this-&gt;m_globalSearchRule;
  95. <a name="l00113"></a>00113 $recordList = $this-&gt;<a class="code" href="class_biz_data_obj___lite.html#a76dc543332df35530951dfd060fe1b21">directFetch</a>($searchRule);
  96. <a name="l00114"></a>00114
  97. <a name="l00115"></a>00115 <span class="keywordflow">foreach</span> ($recordList as $rec)
  98. <a name="l00116"></a>00116 {
  99. <a name="l00117"></a>00117 $node-&gt;m_ChildNodes[] = <span class="keyword">new</span> <a class="code" href="class_node_record.html">NodeRecord</a>($rec);
  100. <a name="l00118"></a>00118 }
  101. <a name="l00119"></a>00119
  102. <a name="l00120"></a>00120 <span class="comment">// reach leave node</span>
  103. <a name="l00121"></a>00121 <span class="keywordflow">if</span> ($node-&gt;m_ChildNodes == null)
  104. <a name="l00122"></a>00122 <span class="keywordflow">return</span>;
  105. <a name="l00123"></a>00123
  106. <a name="l00124"></a>00124 $depth++;
  107. <a name="l00125"></a>00125 <span class="comment">// reach given depth</span>
  108. <a name="l00126"></a>00126 <span class="keywordflow">if</span> ($depth &gt;= $this-&gt;m_Depth)
  109. <a name="l00127"></a>00127 <span class="keywordflow">return</span>;
  110. <a name="l00128"></a>00128 <span class="keywordflow">else</span>
  111. <a name="l00129"></a>00129 {
  112. <a name="l00130"></a>00130 <span class="keywordflow">foreach</span> ($node-&gt;m_ChildNodes as $node_c)
  113. <a name="l00131"></a>00131 {
  114. <a name="l00132"></a>00132 $this-&gt;_getChildrenNodes($node_c, $depth);
  115. <a name="l00133"></a>00133 }
  116. <a name="l00134"></a>00134 }
  117. <a name="l00135"></a>00135 }
  118. <a name="l00136"></a>00136 }
  119. <a name="l00137"></a>00137
  120. <a name="l00149"></a><a class="code" href="class_node_record.html">00149</a> <span class="keyword">class </span><a class="code" href="class_node_record.html">NodeRecord</a>
  121. <a name="l00150"></a>00150 {
  122. <a name="l00151"></a>00151 <span class="keyword">public</span> $m_Id = <span class="stringliteral">&quot;&quot;</span>;
  123. <a name="l00152"></a>00152 <span class="keyword">public</span> $m_PId = <span class="stringliteral">&quot;&quot;</span>;
  124. <a name="l00153"></a>00153 <span class="keyword">public</span> $m_ChildNodes = null;
  125. <a name="l00154"></a>00154 <span class="keyword">public</span> $m_Record;
  126. <a name="l00155"></a>00155
  127. <a name="l00162"></a><a class="code" href="class_node_record.html#ae6ad007549f8be5e7f2b88b3529d5306">00162</a> function <a class="code" href="class_node_record.html#ae6ad007549f8be5e7f2b88b3529d5306">__construct</a>($rec)
  128. <a name="l00163"></a>00163 {
  129. <a name="l00164"></a>00164 $this-&gt;m_Id = $rec[<span class="stringliteral">&#39;Id&#39;</span>];
  130. <a name="l00165"></a>00165 $this-&gt;m_PId = $rec[<span class="stringliteral">&#39;PId&#39;</span>];
  131. <a name="l00166"></a>00166 $this-&gt;m_Record = $rec;
  132. <a name="l00167"></a>00167 }
  133. <a name="l00168"></a>00168 }
  134. <a name="l00169"></a>00169
  135. <a name="l00170"></a>00170
  136. <a name="l00171"></a>00171 ?&gt;
  137. </pre></div></div>
  138. </div>
  139. <hr class="footer"/><address class="footer"><small>Generated on Thu Apr 19 2012 17:09:13 for openbiz by&#160;
  140. <a href="http://www.doxygen.org/index.html">
  141. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
  142. </body>
  143. </html>