Beispiel #1
0
 /**
  * Copy contents to clipboard
  *
  * @param	string		$a_hids		array of hierarchical ids of content objects
  */
 function copyContents($a_hids)
 {
     global $ilUser;
     //var_dump($a_hids);
     if (!is_array($a_hids)) {
         return;
     }
     $time = date("Y-m-d H:i:s", time());
     $hier_ids = array();
     $skip = array();
     foreach ($a_hids as $a_hid) {
         if ($a_hid == "") {
             continue;
         }
         $a_hid = explode(":", $a_hid);
         // check, whether new hid is child of existing one or vice versa
         reset($hier_ids);
         foreach ($hier_ids as $h) {
             if ($h . "_" == substr($a_hid[0], 0, strlen($h) + 1)) {
                 $skip[] = $a_hid[0];
             }
             if ($a_hid[0] . "_" == substr($h, 0, strlen($a_hid[0]) + 1)) {
                 $skip[] = $h;
             }
         }
         $pc_id[$a_hid[0]] = $a_hid[1];
         if ($a_hid[0] != "") {
             $hier_ids[$a_hid[0]] = $a_hid[0];
         }
     }
     foreach ($skip as $s) {
         unset($hier_ids[$s]);
     }
     include_once "./Services/COPage/classes/class.ilPageContent.php";
     $hier_ids = ilPageContent::sortHierIds($hier_ids);
     $nr = 1;
     foreach ($hier_ids as $hid) {
         $curr_node = $this->getContentNode($hid, $pc_id[$hid]);
         if (is_object($curr_node)) {
             if ($curr_node->node_name() == "PageContent") {
                 $content = $this->dom->dump_node($curr_node);
                 // remove pc and hier ids
                 $content = eregi_replace("PCID=\"[a-z0-9]*\"", "", $content);
                 $content = eregi_replace("HierId=\"[a-z0-9_]*\"", "", $content);
                 $ilUser->addToPCClipboard($content, $time, $nr);
                 $nr++;
             }
         }
     }
     include_once "./Modules/LearningModule/classes/class.ilEditClipboard.php";
     ilEditClipboard::setAction("copy");
 }