public function get_stated_intention_tile(Oedipus_StatedIntention $stated_intention, Oedipus_Actor $actor)
 {
     //                <a href="#" class="si-tile" id="actor1-option1">0</a>
     if ($this->edit_mode) {
         $html_tile_link = PublicHTML_URLHelper::get_oo_page_url('Oedipus_TableEditorRedirectScript', array('table_id' => $this->table->get_id(), 'edit_stated_intention' => 1, 'stated_intention_id' => $stated_intention->get_id(), 'stated_intention_tile' => $stated_intention->get_tile(), 'stated_intention_doubt' => $stated_intention->get_doubt()));
     } else {
         $html_tile_link = new HTMLTags_URL();
         $html_tile_link->set_file('#');
     }
     $html_tile = new HTMLTags_A($stated_intention->get_tile() . $stated_intention->get_doubt());
     $html_tile->set_href($html_tile_link);
     $html_tile->set_attribute_str('class', 'si-tile');
     $html_tile_id = $actor->get_color() . $stated_intention->get_tile() . $this->add_q_to_doubt($stated_intention->get_doubt());
     $html_tile->set_attribute_str('id', $html_tile_id);
     return $html_tile;
 }
    public function add_table(Oedipus_Drama $drama, $table_name)
    {
        // ADD TABLE TO DATABASE
        $drama_id = $drama->get_id();
        $dbh = DB::m();
        $sql = <<<SQL
INSERT INTO
\toedipus_tables
SET
\tname = '{$table_name}',
\tdrama_id = {$drama_id},
\tadded = NOW()
SQL;
        //                print_r($sql);exit;
        $result = mysql_query($sql, $dbh);
        $table_id = mysql_insert_id($dbh);
        // ADD DEFAULT ACTOR tO DATABASE
        $actor_name = 'First Actor';
        $actor_color = 'red';
        $sql2 = <<<SQL
INSERT INTO
\toedipus_actors
SET
\tname = '{$actor_name}',
\tcolor = '{$actor_color}',
\ttable_id = {$table_id},
\tadded = NOW()
SQL;
        //                print_r($sql);exit;
        $result2 = mysql_query($sql2, $dbh);
        $actor_id = mysql_insert_id($dbh);
        $actor = new Oedipus_Actor($actor_id, $actor_name, $actor_color);
        $actors = array();
        $actors[] = $actor;
        foreach ($actors as $actor) {
            // 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 = 'First Option';
            $sql4 = <<<SQL
INSERT INTO
\toedipus_options
SET
\tname = '{$option_name}',
\tactor_id = {$actor_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);
            $actors_option = new Oedipus_Option($option_id, $option_name, $stated_intention);
            $actor->add_option($actors_option);
        }
        // Create default positions
        foreach ($actors as $actor) {
            foreach ($actor->get_options() as $option) {
                $positions = array();
                foreach ($actors as $position_actor) {
                    // ADD DEFAULT position tO DATABASE
                    $position_position = '1';
                    $position_doubt = '';
                    $option_id = $option->get_id();
                    $actor_id = $position_actor->get_id();
                    $sql5 = <<<SQL
INSERT INTO
\toedipus_positions
SET
\tposition = '{$position_position}',
\tdoubt = '{$position_doubt}',
\toption_id = {$option_id},
\tactor_id = {$actor_id}
SQL;
                    //                                                        print_r($sql5);exit;
                    $result5 = mysql_query($sql5, $dbh);
                    $position_id = mysql_insert_id($dbh);
                    $positions[$position_actor->get_name()] = new Oedipus_Position($position_id, $position_position, $position_doubt, $position_actor);
                }
                $option->add_positions($positions);
            }
        }
        $table = new Oedipus_Table($table_id, $drama_id, $table_name, $actors);
        //                print_r($table);exit;
        //
        // Update Drama Object with new Table
        //                $drama->add_table($table);
        return $table;
    }