public static function add_scene(Oedipus_Act $act, $name = NULL)
    {
        if ($name == NULL) {
            $name = Oedipus_DramaHelper::get_next_scene_name_for_act_id($act->get_id());
        }
        // ADD scene TO DATABASE
        $dbh = DB::m();
        $act_id = mysql_real_escape_string($act->get_id(), $dbh);
        $name = mysql_real_escape_string($name, $dbh);
        $sql = <<<SQL
INSERT INTO
\toedipus_scenes
SET
\tname = '{$name}',
\tadded = NOW(),
\tact_id = '{$act_id}'
SQL;
        //                print_r($sql);exit;
        $result = mysql_query($sql, $dbh);
        $scene_id = mysql_insert_id($dbh);
        $added = date();
        $scene = new Oedipus_Scene($scene_id, $scene_name, $added, $act_id);
        //                print_r($scene);exit;
        return $scene;
    }
 protected function get_act_div(Oedipus_Act $act)
 {
     $act_div = new HTMLTags_Div();
     $act_div->set_attribute_str('class', 'act');
     /*
      * Show the Drama Toolbar with act 
      * list and share links
      */
     $act_div->append(new Oedipus_DramaToolBarUL($this->get_drama(), $act->get_id()));
     /*
      * Get the Scene ID
      */
     if (isset($_GET['scene_id'])) {
         $scene_id = $_GET['scene_id'];
     } elseif (isset($_GET['frame_id'])) {
         $scene_id = Oedipus_DramaHelper::get_scene_id_for_frame_id($_GET['frame_id']);
     } else {
         $scene_id = Oedipus_DramaHelper::get_first_scene_id_for_act_id($act->get_id());
     }
     /*
      *Show the Act Toolbar with scene list
      */
     $act_div->append(new Oedipus_ActToolBarUL($act, $scene_id));
     /*
      *Get the Scene Div
      */
     $act_div->append($this->get_scene_div($act->get_scene($scene_id)));
     return $act_div;
 }
    public function get_act_by_id($act_id)
    {
        $dbh = DB::m();
        $query = <<<SQL
SELECT 
\t*
\tFROM
\t\toedipus_acts
\tWHERE
\t\tid = {$act_id}
SQL;
        //                                print_r($query);exit;
        $result = mysql_query($query, $dbh);
        $row = mysql_fetch_array($result);
        //                                print_r($row);exit;
        $act = new Oedipus_Act($row['id'], $row['name'], $row['added'], $row['drama_id']);
        // Add the scenes to this Act
        // Get all scenes for this drama
        $scenes_query = <<<SQL
SELECT 
\t*
\tFROM
\t\toedipus_scenes
\tWHERE
\t\tact_id = {$act_id}
SQL;
        //                                print_r($scenes_query);exit;
        $scenes_result = mysql_query($scenes_query, $dbh);
        // Add the scenes to the drama object
        //
        if ($scenes_result) {
            while ($scene_result = mysql_fetch_array($scenes_result)) {
                $scene_id = $scene_result['id'];
                $scene = self::get_scene_by_id($scene_id);
                $act->add_scene($scene);
            }
        }
        return $act;
    }
 public function add_act(Oedipus_Act $act)
 {
     //                $this->acts[$act->get_name()] = $act;
     $this->acts[$act->get_id()] = $act;
 }