コード例 #1
0
ファイル: class-node.php プロジェクト: seanfbrown/jinzora
 function moveMedia($element, $newpath)
 {
     $root = new jzMediaNode();
     $be = new jzBackend();
     $playpath = $element->getFilePath();
     $type = $element->isLeaf() ? "leaf" : "node";
     if (is_string($newpath)) {
         $path = explode("/", $newpath);
     } else {
         if (is_array($newpath)) {
             $path = $newpath;
         } else {
             return false;
         }
     }
     if ($type == "node") {
         return false;
     }
     $pc = $element->getPlayCount();
     $dc = $element->getDownloadCount();
     $vc = $element->getViewCount();
     $desc = $element->getDescription();
     $sdesc = $element->getShortDescription();
     $art = $element->getMainArt();
     $discussion = $element->getDiscussion();
     $rating = $element->getRating();
     $rating_count = $element->getRatingCount();
     if ($be->hasFeature('setID')) {
         $mid = $element->getID();
     }
     // TODO:
     // This does not work correctly with nodes yet.
     // You should pull the above data, then recursively move children,
     // then remove me, and finally set the data as below.
     // I did not do this yet (8/11/05) because I would not have been
     // able to test it. (for things like collisions,
     // and also how to handle the filesystem)
     // If the backend has a lookup file, update it.
     if ($element->isLeaf()) {
         $media_path = getMediaDir($element);
         $be = new jzBackend();
         $rl_name = 'reverse_lookup-' . str_replace(':', '', str_replace('\\', '-', str_replace('/', '-', $media_path)));
         $LOOKUP = $be->loadData($rl_name);
         if (is_array($LOOKUP)) {
             if (isset($LOOKUP[$element->getFilename("host")])) {
                 $LOOKUP[$element->getFilename("host")] = implode('/', $path);
                 $be->storeData($rl_name, $LOOKUP);
             }
         }
     }
     $this->removeMedia($element);
     if (false !== ($new = $root->inject($path, $playpath))) {
         $new->setPlayCount($pc);
         $new->setDownloadCount($dc);
         $new->setViewCount($vc);
         $new->addRating($rating, $rating_count);
         if ($be->hasFeature('setID')) {
             $new->setID($mid);
         }
         if (!isNothing($desc)) {
             $new->addDescription($desc);
         }
         if (!isNothing($sdesc)) {
             $new->addShortDescription($sdesc);
         }
         if (!isNothing($art)) {
             $new->addMainArt($art);
         }
         if ($discussion != array() && !isNothing($discussion)) {
             $new->addFullDiscussion($discussion);
         }
         return $new;
     }
 }