protected function get_scene_content_div()
 {
     $div = new HTMLTags_Div();
     # The left and right column divs
     $left_div = new HTMLTags_Div();
     $left_div->set_attribute_str('class', 'left-column');
     /*
      * Tree View Div
      */
     $left_div->append(Oedipus_FrameTreeHelper::get_frame_tree_div($this->get_scene()));
     $div->append_tag_to_content($left_div);
     $right_div = new HTMLTags_Div();
     $right_div->set_attribute_str('class', 'right-column');
     /*
      * Scene Note Div
      */
     $right_div->append(Oedipus_DramaHelper::get_scene_notes_div($this->get_scene()));
     $div->append_tag_to_content($right_div);
     $clear_div = new HTMLTags_Div();
     $clear_div->set_attribute_str('class', 'clear-columns');
     $div->append_tag_to_content($clear_div);
     return $div;
 }
 public static function get_frame_view_drama_page_url_for_scene_id($scene_id)
 {
     $drama_id = self::get_drama_id_for_scene_id($scene_id);
     $frame_id = Oedipus_FrameTreeHelper::get_root_frame_id_for_scene_id($scene_id);
     $url = self::get_drama_page_url_for_drama_id($drama_id);
     $url->set_get_variable('frame_id', $frame_id);
     return $url;
 }
 protected function do_actions()
 {
     //                print_r($_GET);exit;
     // print_r($_POST);exit;
     $return_to_url = $this->get_redirect_script_return_url();
     if (isset($_POST['add_frame']) && isset($_POST['scene_id']) && isset($_POST['parent_frame_id'])) {
         /*
          * Verify Data received?
          * CURRENTLY UNSAFE
          */
         $scene_id = $_POST['scene_id'];
         if (isset($_POST['frame_name'])) {
             $frame_name = $_POST['frame_name'];
         } else {
             $frame_name = NULL;
         }
         $parent_frame_id = $_POST['parent_frame_id'];
         $this->add_frame($scene_id, $frame_name, $parent_frame_id);
         /*
          * Set the Return to URL,
          * assuming we're on the DramaPage
          */
         $return_to_url = Oedipus_DramaHelper::get_drama_page_url_for_scene_id($scene_id);
     } elseif (isset($_POST['scene_name']) && isset($_POST['scene_id'])) {
         Oedipus_DramaHelper::set_scene_name($_POST['scene_id'], $_POST['scene_name']);
         //$this->set_return_message('saved scene name');
         //
         $return_to_url = Oedipus_DramaHelper::get_drama_page_url_for_scene_id($_POST['scene_id']);
     } elseif (isset($_GET['add_frame']) && isset($_GET['scene_id']) && isset($_GET['parent_frame_id'])) {
         /*
          * Verify Data received?
          * CURRENTLY UNSAFE
          */
         $scene_id = $_GET['scene_id'];
         if (isset($_GET['frame_name'])) {
             $frame_name = $_GET['frame_name'];
         } else {
             $frame_name = NULL;
         }
         $parent_frame_id = $_GET['parent_frame_id'];
         $frame = $this->add_frame($scene_id, $frame_name, $parent_frame_id);
         /*
          * Set the Return to URL,
          * assuming we're on the DramaPage
          */
         $return_to_url = Oedipus_DramaHelper::get_drama_page_url_for_frame_id($frame->get_id());
     } elseif (isset($_GET['rebuild_tree']) && isset($_GET['scene_id'])) {
         /*
          * Verify Data received?
          * CURRENTLY UNSAFE
          */
         $scene_id = $_GET['scene_id'];
         Oedipus_FrameTreeHelper::rebuild_tree_for_scene_id($scene_id);
         /*
          * Set the Return to URL,
          * assuming we're on the DramaPage
          */
         $return_to_url = Oedipus_DramaHelper::get_drama_page_url_for_scene_id($scene_id);
     }
     $this->set_return_to_url($return_to_url);
 }
 private function get_frame_navigation_div()
 {
     return Oedipus_FrameTreeHelper::get_frame_navigation_div($this->get_frame());
 }
    public function add_frame(Oedipus_Scene $scene, $frame_name, $parent_frame_id)
    {
        if ($parent_frame_id != 0) {
            return self::add_child_frame_as_duplicate_of_parent($scene, $parent_frame_id);
        }
        /*
         *Set Frame Name
         */
        if (!isset($frame_name)) {
            $frame_name = 'New Frame';
        }
        $scene_id = $scene->get_id();
        // ADD TABLE TO DATABASE
        $dbh = DB::m();
        $sql = <<<SQL
INSERT INTO
\toedipus_frames
SET
\tname = '{$frame_name}',
\tscene_id = {$scene_id},
\tadded = NOW()
SQL;
        //                print_r($sql);exit;
        $result = mysql_query($sql, $dbh);
        $frame_id = mysql_insert_id($dbh);
        // ADD DEFAULT ACTOR tO DATABASE
        $character_name = 'Wile E. Coyote';
        $character_color = 'red';
        $sql2 = <<<SQL
INSERT INTO
\toedipus_characters
SET
\tname = '{$character_name}',
\tcolor = '{$character_color}',
\tframe_id = {$frame_id},
\tadded = NOW()
SQL;
        //                print_r($sql);exit;
        $result2 = mysql_query($sql2, $dbh);
        $character_id = mysql_insert_id($dbh);
        $character = new Oedipus_Character($character_id, $character_name, $character_color);
        $characters = array();
        $characters[] = $character;
        foreach ($characters as $character) {
            // ADD DEFAULT stated_intention tO DATABASE
            $stated_intention_position = '1';
            $stated_intention_doubt = '';
            $sql3 = <<<SQL
INSERT INTO
\toedipus_stated_intentions
SET
\tposition = '{$stated_intention_position}',
\tdoubt = '{$stated_intention_doubt}'
SQL;
            //                print_r($sql);exit;
            $result3 = mysql_query($sql3, $dbh);
            $stated_intention_id = mysql_insert_id($dbh);
            // ADD DEFAULT option tO DATABASE
            $option_name = 'Chase Road Runner';
            $sql4 = <<<SQL
INSERT INTO
\toedipus_options
SET
\tname = '{$option_name}',
\tcharacter_id = {$character_id},
\tstated_intention_id = {$stated_intention_id},
\tadded = NOW()
SQL;
            //                print_r($sql);exit;
            $result4 = mysql_query($sql4, $dbh);
            $option_id = mysql_insert_id($dbh);
            $stated_intention = new Oedipus_StatedIntention($stated_intention_id, $stated_intention_position, $stated_intention_doubt);
            $characters_option = new Oedipus_Option($option_id, $option_name, $stated_intention);
            $character->add_option($characters_option);
        }
        // Create default positions
        foreach ($characters as $character) {
            foreach ($character->get_options() as $option) {
                $positions = array();
                foreach ($characters as $position_character) {
                    // ADD DEFAULT position tO DATABASE
                    $position_position = '1';
                    $position_doubt = '';
                    $option_id = $option->get_id();
                    $character_id = $position_character->get_id();
                    $sql5 = <<<SQL
INSERT INTO
\toedipus_positions
SET
\tposition = '{$position_position}',
\tdoubt = '{$position_doubt}',
\toption_id = {$option_id},
\tcharacter_id = {$character_id}
SQL;
                    //                                        print_r($sql5);exit;
                    $result5 = mysql_query($sql5, $dbh);
                    $position_id = mysql_insert_id($dbh);
                    $positions[$position_character->get_name()] = new Oedipus_Position($position_id, $position_position, $position_doubt, $position_character);
                }
                $option->add_positions($positions);
            }
        }
        $frame = new Oedipus_Frame($frame_id, $frame_name, date(), $scene_id, $characters);
        //__construct($id, $name, $added, $scene_id, $characters)
        //                print_r($frame);exit;
        // Add Frame to Tree
        Oedipus_FrameTreeHelper::add_frame_to_tree($frame, $parent_frame_id);
        return $frame;
    }