public function __construct($file_uri, $user_id, $file_type) { $this->_user_id = $user_id; $this->_file_type = $file_type; $this->_file_uri = $file_uri; $this->_folder_name = ManipulationLib::getFormattedDate() . "_" . ManipulationLib::generateRandomName(); $this->_user_path = "." . DS . "upload" . DS . "html" . DS . $this->_user_id; //chdir("./upload/html/$this->_user_id/"); $this->_filename = ManipulationLib::getFileName($this->_file_uri); // Copy the file to the user location // return the path for the index.html $this->_short_index_html_path = $this->getIndexPath($this->_file_type, $this->_filename, $this->_user_path, $this->_folder_name); // Parse index.html file for the slides and meta-data $index_path = $this->_user_path . DS . $this->_short_index_html_path; // Getting the metadata from the presentation // $this->title // $this->deck_id - the container deck_id, deck can contain other decks // $this->deck_revision_id $meta_data = $this->getMetaData($index_path); foreach ($meta_data as $key => $value) { $this->{$key} = $value; } // Getting slides' information $this->_slides = $this->parseHtmlFile($index_path, $this->_folder_name, $this->_user_id, $this->_user_path); //var_dump($this->_slides); die; if (!count($this->_slides)) { die; } // create slides objects // compare them to the previous slides' revisions $user = new User(); $user->createFromID($user_id); $new_deck = new Deck(); $new_deck->user = $user; $new_deck->title = $user->username . " - new deck"; $new_deck->create(); $new_deck->deleteItemFromPosition(1); $slides_obj = array(); foreach ($this->_slides as $key => $slide) { //$old_slide = new Slide(); //$old_slide->createFromID($slide['slide_rev_id']); $new_slide = new Slide(); $user = new User(); $user->createFromID($user_id); $new_slide->user = $user; $new_slide->comment = "imported"; $slide_content = $slide['content']; $new_slide->content = $slide_content; $new_slide->deck = $new_deck->id; // handle position! //$new_slide->position = $slide['position_in_deck']; $new_slide->create(); $slides_obj[] = $new_slide; // compare slides! //$slide_identical = SlideCompare::compareSlideToSlide($old_slide, $new_slide); //$compare_table[$key]['old_slide'] = $old_slide; //$compare_table[$key]['new_slide'] = $new_slide; //$compare_table[$key]['slide_identical'] = $slide_identical; } //var_dump($slides_obj); $new_deck->addContent($slides_obj); $this->createddeckid = $new_deck->id; $this->createddecktitle = $new_deck->title; //$this->_compare_table = $compare_table; }