Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("content/classes/Pages/class.ilPageContent.php");
00025
00036 class ilPCTableData extends ilPageContent
00037 {
00038 var $dom;
00039
00044 function ilPCTableData(&$a_dom)
00045 {
00046 parent::ilPageContent();
00047 $this->setType("td");
00048
00049 $this->dom =& $a_dom;
00050 }
00051
00055 function newRowAfter()
00056 {
00057 $td =& $this->getNode();
00058 $parent_tr =& $td->parent_node();
00059 $new_tr = $parent_tr->clone_node(true);
00060 if ($next_tr =& $parent_tr->next_sibling())
00061 {
00062 $new_tr =& $next_tr->insert_before($new_tr, $next_tr);
00063 }
00064 else
00065 {
00066 $parent_table =& $parent_tr->parent_node();
00067 $new_tr =& $parent_table->append_child($new_tr);
00068 }
00069
00070
00071 $this->deleteRowContent($new_tr);
00072 }
00073
00074
00078 function newRowBefore()
00079 {
00080 $td =& $this->getNode();
00081 $parent_tr =& $td->parent_node();
00082 $new_tr = $parent_tr->clone_node(true);
00083 $new_tr =& $parent_tr->insert_before($new_tr, $parent_tr);
00084
00085
00086 $this->deleteRowContent($new_tr);
00087 }
00088
00089
00095 function deleteRowContent(&$a_row_node)
00096 {
00097
00098 $tds =& $a_row_node->child_nodes();
00099 for($i=0; $i<count($tds); $i++)
00100 {
00101 $td_childs =& $tds[$i]->child_nodes();
00102 for($j=0; $j<count($td_childs); $j++)
00103 {
00104 $tds[$i]->remove_child($td_childs[$j]);
00105 }
00106 }
00107 }
00108
00114 function deleteTDContent(&$a_td_node)
00115 {
00116 $td_childs =& $a_td_node->child_nodes();
00117 for($j=0; $j<count($td_childs); $j++)
00118 {
00119 $a_td_node->remove_child($td_childs[$j]);
00120 }
00121 }
00122
00123
00127 function deleteRow()
00128 {
00129 $td =& $this->getNode();
00130 $parent_tr =& $td->parent_node();
00131 $parent_tr->unlink($parent_tr);
00132 }
00133
00134
00138 function newColAfter()
00139 {
00140 $td =& $this->getNode();
00141
00142
00143 $hier_id = $this->getHierId();
00144 $parts = explode("_", $hier_id);
00145 $col_nr = array_pop($parts);
00146 $col_nr--;
00147
00148 $parent_tr =& $td->parent_node();
00149 $parent_table =& $parent_tr->parent_node();
00150
00151
00152 $rows =& $parent_table->child_nodes();
00153 for($i=0; $i<count($rows); $i++)
00154 {
00155 if($rows[$i]->node_name() == "TableRow")
00156 {
00157
00158 $tds =& $rows[$i]->child_nodes();
00159 $new_td =& $tds[$col_nr]->clone_node(true);
00160
00161
00162 if ($next_td =& $tds[$col_nr]->next_sibling())
00163 {
00164 $new_td =& $next_td->insert_before($new_td, $next_td);
00165 }
00166 else
00167 {
00168 $new_td =& $rows[$i]->append_child($new_td);
00169 }
00170 $this->deleteTDContent($new_td);
00171 }
00172 }
00173 }
00174
00178 function newColBefore()
00179 {
00180 $td =& $this->getNode();
00181
00182
00183 $hier_id = $this->getHierId();
00184 $parts = explode("_", $hier_id);
00185 $col_nr = array_pop($parts);
00186 $col_nr--;
00187
00188 $parent_tr =& $td->parent_node();
00189 $parent_table =& $parent_tr->parent_node();
00190
00191
00192 $rows =& $parent_table->child_nodes();
00193 for($i=0; $i<count($rows); $i++)
00194 {
00195 if($rows[$i]->node_name() == "TableRow")
00196 {
00197
00198 $tds =& $rows[$i]->child_nodes();
00199 $new_td =& $tds[$col_nr]->clone_node(true);
00200
00201
00202 $new_td =& $tds[$col_nr]->insert_before($new_td, $tds[$col_nr]);
00203 $this->deleteTDContent($new_td);
00204 }
00205 }
00206 }
00207
00211 function deleteCol()
00212 {
00213 $td =& $this->getNode();
00214
00215
00216 $hier_id = $this->getHierId();
00217 $parts = explode("_", $hier_id);
00218 $col_nr = array_pop($parts);
00219 $col_nr--;
00220
00221 $parent_tr =& $td->parent_node();
00222 $parent_table =& $parent_tr->parent_node();
00223
00224
00225 $rows =& $parent_table->child_nodes();
00226 for($i=0; $i<count($rows); $i++)
00227 {
00228 if($rows[$i]->node_name() == "TableRow")
00229 {
00230
00231 $tds =& $rows[$i]->child_nodes();
00232 $tds[$col_nr]->unlink($tds[$col_nr]);
00233 }
00234 }
00235 }
00236
00240 function moveRowDown()
00241 {
00242 $td =& $this->getNode();
00243 $tr =& $td->parent_node();
00244 $next =& $tr->next_sibling();
00245 $next_copy = $next->clone_node(true);
00246 $next_copy =& $tr->insert_before($next_copy, $tr);
00247 $next->unlink($next);
00248 }
00249
00253 function moveRowUp()
00254 {
00255 $td =& $this->getNode();
00256 $tr =& $td->parent_node();
00257 $prev =& $tr->previous_sibling();
00258 $tr_copy = $tr->clone_node(true);
00259 $tr_copy =& $prev->insert_before($tr_copy, $prev);
00260 $tr->unlink($tr);
00261 }
00262
00266 function moveColRight()
00267 {
00268 $td =& $this->getNode();
00269
00270
00271 $hier_id = $this->getHierId();
00272 $parts = explode("_", $hier_id);
00273 $col_nr = array_pop($parts);
00274 $col_nr--;
00275
00276 $parent_tr =& $td->parent_node();
00277 $parent_table =& $parent_tr->parent_node();
00278
00279
00280 $rows =& $parent_table->child_nodes();
00281 for($i=0; $i<count($rows); $i++)
00282 {
00283 if($rows[$i]->node_name() == "TableRow")
00284 {
00285 $tds =& $rows[$i]->child_nodes();
00286 $td =& $tds[$col_nr];
00287
00288 $next =& $td->next_sibling();
00289 $next_copy = $next->clone_node(true);
00290 $next_copy =& $td->insert_before($next_copy, $td);
00291 $next->unlink($next);
00292 }
00293 }
00294 }
00295
00299 function moveColLeft()
00300 {
00301 $td =& $this->getNode();
00302
00303
00304 $hier_id = $this->getHierId();
00305 $parts = explode("_", $hier_id);
00306 $col_nr = array_pop($parts);
00307 $col_nr--;
00308
00309 $parent_tr =& $td->parent_node();
00310 $parent_table =& $parent_tr->parent_node();
00311
00312
00313 $rows =& $parent_table->child_nodes();
00314 for($i=0; $i<count($rows); $i++)
00315 {
00316 if($rows[$i]->node_name() == "TableRow")
00317 {
00318 $tds =& $rows[$i]->child_nodes();
00319 $td =& $tds[$col_nr];
00320 $prev =& $td->previous_sibling();
00321 $td_copy = $td->clone_node(true);
00322 $td_copy =& $prev->insert_before($td_copy, $prev);
00323 $td->unlink($td);
00324 }
00325 }
00326 }
00327
00328 }
00329 ?>