public function get_explanation_for_stated_intention(Oedipus_Character $character, Oedipus_StatedIntention $stated_intention, Oedipus_Option $option) { /* *Set the Phrases */ $owner_of_option = $character->get_name(); $owner_of_option_is_plural = self::is_plural($owner_of_option); if ($owner_of_option_is_plural) { $pronoun = ' they '; } else { $pronoun = ' he/she '; } $will_or_wont = self::get_stated_intention_str($stated_intention, $owner_of_position_is_plural); /* *Construct the sentence */ $explanation = ''; $explanation .= $owner_of_option . ' '; if ($owner_of_option_is_plural) { $explanation .= 'have '; } else { $explanation .= 'has '; } $explanation .= 'stated that ' . $pronoun . ' '; $explanation .= $will_or_wont . ' '; $explanation .= $option->get_name() . '.'; return $explanation; }
public function __construct(Oedipus_Frame $frame, Oedipus_Character $character) { parent::__construct($frame, 'character_editor'); // $this->frame = $frame; # Name Input $this->add_input_name_with_value('character_name', $character->get_name(), 'character'); # color Input $this->add_input_name_with_value('character_color', $character->get_color(), 'Color'); # Hidden Inputs $this->add_hidden_input('character_id', $character->get_id()); }
public function add_character(Oedipus_Character $character) { $this->characters[$character->get_name()] = $character; }
private function get_characters_background_color(Oedipus_Character $character) { // define some colors // These are full bright colours // $red = imagecolorallocate($this->image, 255, 0, 0); // $blue = imagecolorallocate($this->image, 0, 0, 255); // These are at 50% saturation $red = imagecolorallocate($this->image, 255, 128, 128); $blue = imagecolorallocate($this->image, 128, 128, 255); $green = imagecolorallocate($this->image, 128, 255, 128); $orange = imagecolorallocate($this->image, 255, 228, 128); $color = $character->get_color(); switch ($color) { case 'red': return $red; case 'blue': return $blue; case 'green': return $green; case 'orange': return $orange; default: return $red; } }
/** * Get the frame object. * * We should use a select with a few joins. * See http://oedipus-decision-maker.googlecode.com/svn/sites/main/trunk/sql/useful-queries/select-frame.sql * * The select should probably also be made into a view. */ public function get_frame_by_id($frame_id) { //print_r($frame_id);exit; $dbh = DB::m(); $frames_query = <<<SQL SELECT \t* \tFROM \t\toedipus_frames \tWHERE \t\tid = {$frame_id} SQL; // print_r($query);exit; // print_r($row);exit; // print_r($frames_query);exit; $frames_result = mysql_query($frames_query, $dbh); // print_r($frames);exit; $frame_result = mysql_fetch_array($frames_result); // ----------------------------------------------------------------------------- // Creating a Table // ----------------- // 1. // Create the characters, // and their options, options have stated intentions // For this frame, get the characters $frame_id = $frame_result['id']; // Get all characters for this drama $characters_query = <<<SQL SELECT \t* \tFROM \t\toedipus_characters \tWHERE \t\tframe_id = {$frame_id} SQL; // print_r($characters_query);exit; $characters_result = mysql_query($characters_query, $dbh); // print_r($characters);exit; // create an array of characters $characters = array(); while ($character_result = mysql_fetch_array($characters_result)) { $character = new Oedipus_Character($character_result['id'], $character_result['name'], $character_result['color']); //add the stated intentions to the option object //add the options to the character object // For this character, get the options $character_id = $character_result['id']; // Get all characters for this drama $options_query = <<<SQL SELECT \t* \tFROM \t\toedipus_options \tWHERE \t\tcharacter_id = {$character_id} SQL; //print_r($options_query);exit; $options_result = mysql_query($options_query, $dbh); // print_r($characters);exit; $options = array(); while ($option_result = mysql_fetch_array($options_result)) { //get the stated intention $stated_intention_id = $option_result['stated_intention_id']; $stated_intentions_query = <<<SQL SELECT \t* \tFROM \t\toedipus_stated_intentions \tWHERE \t\tid = {$stated_intention_id} SQL; // print_r($characters_query);exit; $stated_intentions_result = mysql_query($stated_intentions_query, $dbh); $stated_intention_result = mysql_fetch_array($stated_intentions_result); $stated_intention = new Oedipus_StatedIntention($stated_intention_result['id'], $stated_intention_result['position'], $stated_intention_result['doubt']); $characters_option = new Oedipus_Option($option_result['id'], $option_result['name'], $stated_intention); $character->add_option($characters_option); } $characters[] = $character; //add the positions to the option object // } // 2. // create the positions // attached to options for ease of display (?) // positions have an character as well as an option foreach ($characters as $character) { foreach ($character->get_options() as $option) { $positions = array(); foreach ($characters as $position_character) { $character_id = $position_character->get_id(); $option_id = $option->get_id(); // Get all characters for this drama $positions_query = <<<SQL SELECT \t* \tFROM \t\toedipus_positions \tWHERE \t\tcharacter_id = {$character_id} AND \t\toption_id = {$option_id} SQL; // print_r($characters_query);exit; $positions_result = mysql_query($positions_query, $dbh); // print_r($characters);exit; $position_result = mysql_fetch_array($positions_result); $positions[$position_character->get_id()] = new Oedipus_Position($position_result['id'], $position_result['position'], $position_result['doubt'], $position_character); } $option->add_positions($positions); } } $frame = new Oedipus_Frame($frame_result['id'], $frame_result['name'], $frame_result['added'], $frame_result['scene_id'], $characters); //print_r($frame);exit; return $frame; }
public static function create_oedipus_frame_from_get($get) { // Creating a frame // ----------------- // 1. // Create the characters, // and their options, options have stated intentions // foreach character, check if $characters = array(); for ($i = 1; $i <= $get['no_of_characters']; $i++) { $character = new Oedipus_Character($i, $get['character_name-' . $i], $get['character_color-' . $i]); for ($j = 1; $j <= $get['character-' . $i . '-no_of_options']; $j++) { $stated_intention = new Oedipus_StatedIntention('1', 'q'); $characters_option = new Oedipus_Option($j, $get['character-' . $i . '-option_name-' . $j], $stated_intention); $character->add_option($characters_option); } $characters[] = $character; } // 2. // create the positions // attached to options for ease of display (?) // positions have an character as well as an option foreach ($characters as $character) { foreach ($character->get_options() as $option) { $positions = array(); foreach ($characters as $position_character) { $positions[$position_character->get_id()] = new Oedipus_Position('0', 'q', $position_character); } $option->add_positions($positions); } } // 3. // Create the frame $frame = new Oedipus_Frame($get['frame_name'], $characters); // DEBUG // print_r($frame->get_characters());exit; return $frame; }
public function get_stated_intention_tile(Oedipus_StatedIntention $stated_intention, Oedipus_Character $character, $explanation) { // <a href="#" class="si-tile" id="character1-option1">0</a> if ($this->frame->is_editable()) { $html_tile_link = PublicHTML_URLHelper::get_oo_page_url('Oedipus_EditFrameRedirectScript', array('frame_id' => $this->frame->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())); if (isset($_GET['edit_frame'])) { $html_tile_link->set_get_variable('return_to_get', 'edit_frame'); } } 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); /** * An explanation for the position is set here in the * title attribute, for the javascript to use as a * cool -tip */ $html_tile->set_attribute_str('title', Oedipus_LanguageHelper::get_possessive($character->get_name()) . " Stated Intention" . '|' . $explanation); $html_tile->set_attribute_str('class', 'si-tile'); $html_tile_id = $character->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_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; }