Esempio n. 1
0
 function item()
 {
     $item_id = $_GET['id'];
     $item_type = $_GET['type'];
     $item_user = @$_GET['user'];
     $redirect_link = "";
     $hash = "";
     switch ($item_type) {
         case 'slide':
             $slide = new Slide();
             $slide->createFromID($item_id);
             if (isset($item_user)) {
                 $last_revision = $slide->getLastRevisionID($item_user);
             } else {
                 $last_revision = $slide->last_revision_id;
             }
             $slide2 = new Slide();
             $slide2->createFromID($last_revision);
             $slide_usage = $slide2->getUsage();
             if (is_array($slide_usage) && count($slide_usage) == 1) {
                 $hash = 'tree-' . $slide_usage[0]->id . '-slide-' . $slide2->id . '-' . $slide2->getPosition() . '-view';
                 $parent_deck = $slide2->getLastOuterParent($slide_usage[0]->id);
                 $deck = new Deck();
                 $deck->id = $parent_deck;
                 $deck->title = $deck->getTitle();
                 $deck->slug_title = $deck->sluggify($deck->title);
                 $redirect_link = BASE_PATH . 'deck/' . $parent_deck . '_' . $deck->slug_title . '#' . $hash;
             } else {
                 $redirect_link = BASE_PATH . 'slide/' . $last_revision;
             }
             break;
         case 'deck':
             $deck = new Deck();
             $deck->createFromID($item_id);
             if (isset($item_user)) {
                 $last_revision = $deck->getLastRevisionID($item_user);
             } else {
                 $last_revision = $deck->last_revision_id;
             }
             $deck_for_title = new Deck();
             $deck_for_title->id = $last_revision;
             $deck_for_title->title = $deck_for_title->getTitle();
             $deck_for_title->slug_title = $deck_for_title->sluggify($deck->title);
             $deck2 = new Deck();
             $deck2->createFromID($last_revision);
             $deck_usage = $deck2->getUsage();
             if (is_array($deck_usage) && count($deck_usage) == 1) {
                 $hash = 'tree-' . $deck_usage[0]->id . '-deck-' . $deck2->id . '-' . $deck2->getPosition() . '-view';
                 $parent_deck = $deck2->getLastOuterParent($deck_usage[0]->id);
                 $deck_for_title = new Deck();
                 $deck_for_title->id = $parent_deck;
                 $deck_for_title->title = $deck->getTitle();
                 $deck_for_title->slug_title = $deck->sluggify($deck->title);
                 $redirect_link = BASE_PATH . 'deck/' . $parent_deck . '_' . $deck_for_title->slug_title . '#' . $hash;
             } else {
                 $redirect_link = BASE_PATH . 'deck/' . $last_revision . '_' . $deck_for_title->slug_title;
             }
             break;
     }
     header('Location: ' . $redirect_link);
 }