protected function do_actions() { $this->set_return_message('edited note'); $this->get_variables = array(); /* * The $_POST */ if (isset($_POST['edit_note']) && isset($_POST['note_id']) && isset($_POST['note_text'])) { Oedipus_NotesHelper::set_note_text($_POST['note_id'], $_POST['note_text']); } elseif (isset($_POST['add_note']) && isset($_POST['frame_id'])) { $frame = Oedipus_DramaHelper::get_frame_by_id($_POST['frame_id']); if (isset($_POST['note_text'])) { Oedipus_NotesHelper::add_note_to_frame($frame, $_POST['note_text']); } } /* * The $_GET */ if (isset($_POST['drama_id'])) { $this->get_variables['drama_id'] = $_POST['drama_id']; } if (isset($_POST['frame_id'])) { $this->get_variables['frame_id'] = $_POST['frame_id']; } $return_to_url = $this->get_return_to_url(); $this->set_return_to_url($return_to_url); }
protected function get_add_act_li() { $li = new HTMLTags_LI(); $a = new HTMLTags_A('Add Act'); $a->set_attribute_str('id', 'add'); $a->set_attribute_str('title', 'Add an Act'); $a->set_href(Oedipus_DramaHelper::get_add_act_url($this->drama->get_id())); $li->append($a); return $li; }
public static function get_frame_png_thumbnail_img_a(Oedipus_Frame $frame, $max_width = 250, $max_height = 185) { $url = Oedipus_DramaHelper::get_drama_page_url_for_frame_id($frame->get_id()); $a = new HTMLTags_A(); $a->set_href($url); $a->set_attribute_str('title', 'View this Frame'); $img = self::get_frame_png_thumbnail_img($frame, $max_width, $max_height); $a->append_tag_to_content($img); return $a; }
private function add_frame($scene_id, $frame_name, $parent_frame_id) { /* * Get the scene */ $scene = Oedipus_DramaHelper::get_scene_by_id($scene_id); /* * Add a default frame to the scene */ $frame = Oedipus_DramaHelper::add_frame($scene, $frame_name, $parent_frame_id); /* * Add a default note for the frame */ $note = Oedipus_NotesHelper::add_note_to_frame_with_default_content($frame); return $frame; }
public static function get_scene_notes_div(Oedipus_Scene $scene) { $div = new HTMLTags_Div(); $div->set_attribute_str('class', 'notes'); $div->set_attribute_str('id', 'scene'); /* * Put A Textbox for the heading if scene is editable, * Put a <h3> if it isn't */ if ($scene->is_editable()) { $name_div = new HTMLTags_Div(); $name_div->set_attribute_str('id', 'name-form'); $name_div->append(new Oedipus_EditSceneNameHTMLForm($scene)); $div->append($name_div); } else { $div->append($heading = new HTMLTags_Heading(3, $scene->get_name())); } /* * Put a Textbox for the Note, if frame is editable, * Put the note in a <pre> if it isn't */ try { if ($scene->is_editable()) { $drama_id = Oedipus_DramaHelper::get_drama_id_for_scene_id($scene->get_id()); $note_div = new HTMLTags_Div(); $note_div->set_attribute_str('id', 'note-form'); $note_div->set_attribute_str('class', 'user-html'); if (Oedipus_NotesHelper::has_scene_got_note($scene->get_id())) { $note = Oedipus_NotesHelper::get_note_by_scene_id($scene->get_id()); $note_div->append(self::get_note_preview_div($note)); $note_div->append(new Oedipus_EditSceneNoteHTMLForm($note, $drama_id, $scene->get_id())); } else { $note_div->append(new Oedipus_AddSceneNoteHTMLForm($drama_id, $scene)); } $div->append($note_div); } else { $note = Oedipus_NotesHelper::get_note_by_scene_id($scene->get_id()); $user_html_div = new HTMLTags_Div(); $user_html_div->set_attribute_str('class', 'user-html'); $user_html_div->append($note->get_note_text_html()); $div->append($user_html_div); } } catch (Exception $e) { throw new Exception('Failed to retrieve note'); } return $div; }
protected function get_return_to_url() { /* *Edit Frame page? */ if (isset($_POST['return_to_get']) || isset($_GET['return_to_get'])) { if ($_POST['return_to_get'] == 'edit_frame' || $_GET['return_to_get'] == 'edit_frame') { $url = Oedipus_DramaHelper::get_edit_frame_drama_page_url_for_frame_id($this->frame_id); } } else { /* *Normal Frame Page */ $url = Oedipus_DramaHelper::get_drama_page_url_for_frame_id($this->frame_id); } /* *Set the Return Message in the Get */ $url->set_get_variable('return_message', $this->get_return_message()); return $url; }
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; }
private function get_view_drama_url() { return Oedipus_DramaHelper::get_drama_page_url_for_drama($this->drama); }
protected function get_body_div_header_heading_content() { $home_link = new HTMLTags_A($this->get_body_div_header_link_content()); $home_link->set_href(Oedipus_DramaHelper::get_drama_page_url_for_drama_id($this->get_drama()->get_id())); return $home_link->get_as_string(); }
protected function get_option_trs() { $option_trs = array(); foreach ($this->characters as $character) { if ($character->has_options()) { // Actors Name TR $characters_name_tr = new HTMLTags_TR(); $characters_name_th = new HTMLTags_TH(); $characters_name_th->append($character->get_name()); $characters_name_th->set_attribute_str('class', 'option'); $characters_name_th->set_attribute_str('id', $character->get_color()); $characters_name_tr->append($characters_name_th); for ($i = -1; $i < count($this->characters); $i++) { $blank_td = new HTMLTags_TD(); $characters_name_tr->append($blank_td); } $option_trs[] = $characters_name_tr; // Option TRs with positions $options = $character->get_options(); foreach ($options as $option) { $tr = new HTMLTags_TR(); $option_em = new HTMLTags_Em($option->get_name()); $option_th = new HTMLTags_TH(); $option_th->append($option_em); $option_th->set_attribute_str('class', 'option'); $option_th->set_attribute_str('id', $character->get_color()); $tr->append_tag_to_content($option_th); foreach ($this->characters as $position_character) { $position = $option->get_position($position_character->get_id()); $position_td = new HTMLTags_TD(); $p_explanation = Oedipus_DramaHelper::get_explanation_for_position($character, $position, $option); $position_td->append_tag_to_content($this->get_position_tile($position, $p_explanation)); $tr->append_tag_to_content($position_td); } // Stated Intention TD $stated_intention = $option->get_stated_intention(); $stated_intention_td = new HTMLTags_TD(); $si_explanation = Oedipus_DramaHelper::get_explanation_for_stated_intention($character, $stated_intention, $option); $stated_intention_td->append_tag_to_content($this->get_stated_intention_tile($stated_intention, $character, $si_explanation)); $tr->append_tag_to_content($stated_intention_td); $option_trs[] = $tr; } // Blank TR $blank_tr = new HTMLTags_TR(); $blank_th = new HTMLTags_TH(); $blank_th->set_attribute_str('class', 'blank'); $blank_tr->append_tag_to_content($blank_th); for ($i = -1; $i < count($this->characters); $i++) { $blank_td = new HTMLTags_TD(); $blank_tr->append_tag_to_content($blank_td); } $option_trs[] = $blank_tr; } } return $option_trs; }
private function get_redirect_script_return_url() { return Oedipus_DramaHelper::get_drama_page_url(); }
private function get_tree_ul($root_frame_id, $scene_id, $editable) { $dbh = DB::m(); //retrieve the left and right value of the $root node $root_sql = <<<SQL SELECT lft, rgt FROM oedipus_frame_trees WHERE scene_id = {$scene_id} AND frame_id='{$root_frame_id}' SQL; // print_r($root_sql);exit; $result = mysql_query($root_sql, $dbh); $row = mysql_fetch_array($result); //start with an empty $right stack $right = array(); //now, retrieve all descendants of the $root node $root_right = $row['rgt']; $root_left = $row['lft']; $result_sql = <<<SQL SELECT \tframe_id, lft, rgt FROM \toedipus_frame_trees WHERE \tlft BETWEEN \t{$root_left} AND {$root_right} AND \tscene_id = {$scene_id} ORDER BY \tlft ASC SQL; // print_r($result_sql);exit; $result = mysql_query($result_sql, $dbh); //display each row $begin_ul_but_not_first = FALSE; $first = TRUE; $html = '<ul>'; while ($row = mysql_fetch_array($result)) { //only check stack if there is one if (count($right) > 0) { if ($begin_ul_but_not_first) { $html .= '<li><ul>'; $begin_ul_but_not_first = FALSE; } $begin_ul_but_not_first = TRUE; //check if we should remove a node from the stack while ($right[count($right) - 1] < $row['rgt']) { array_pop($right); $html .= '</ul></li>'; $begin_ul_but_not_first = TRUE; } } //display Frame Image if ($first) { $html .= '<li>'; $first = FALSE; } else { $html .= '<li class="node">'; } $frame = Oedipus_DramaHelper::get_frame_by_id($row['frame_id']); $frame_node_div = self::get_frame_node_div($frame, $editable); $html .= $frame_node_div->get_as_string(); $html .= '</li>'; //add this node to the stack $right[] = $row['rgt']; } $html .= '</ul>'; return $html; }
private function get_tree_view_url() { return Oedipus_DramaHelper::get_drama_page_url_for_scene_id($this->scene_id); }
private function get_new_frame_form_cancel_url() { /* Assuming we're on the Edit Drama Page */ $drama_id = Oedipus_DramaHelper::get_drama_id_for_scene_id($this->scene->get_id()); return Oedipus_DramaHelper::get_edit_drama_page_url_for_drama_id($drama_id); }
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 static function add_option($option_name, $character_id, $frame_id) { $option_data_is_valid = TRUE; //Implement this! if ($option_data_is_valid) { $frame = Oedipus_DramaHelper::get_frame_by_id($frame_id); $dbh = DB::m(); // Create the stated_intention $stated_intention_sql = <<<SQL INSERT INTO \toedipus_stated_intentions SET \tposition = '1', \tdoubt = '' SQL; // print_r($sql);exit; mysql_query($stated_intention_sql, $dbh); $stated_intention_id = mysql_insert_id($dbh); // Create the Option $option_sql = <<<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; mysql_query($option_sql, $dbh); $option_id = mysql_insert_id($dbh); // Create default positions // for all characters in the frame $frame_characters = $frame->get_characters(); foreach ($frame_characters as $frame_character) { // ADD DEFAULT position tO DATABASE $position_position = '1'; $position_doubt = ''; $character_id = $frame_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); } } else { // throw new Database_CRUDException("'$href' is not a validate HREF!"); } }
private function get_drama_page_url_for_drama(Oedipus_Drama $drama) { return Oedipus_DramaHelper::get_drama_page_url_for_drama($drama); }
private function get_drama_url_div() { return Oedipus_DramaHelper::get_drama_url_div($this->get_drama()); }
protected function get_dramas_list() { return Oedipus_DramaHelper::get_all_dramas_for_user($this->get_user_id()); }
protected function get_dramas_list() { return Oedipus_DramaHelper::get_latest_public_dramas(); }
public function get_drama_id() { return Oedipus_DramaHelper::get_drama_id_for_scene_id($this->get_scene_id()); }
public function get_drama_by_unique_name($unique_name) { $dbh = DB::m(); // Check if name is already in oedipus_dramas $query = <<<SQL SELECT \t* \tFROM \t\toedipus_dramas \tWHERE \t\tunique_name = '{$unique_name}' SQL; $result = mysql_query($query, $dbh); if ($row = mysql_fetch_array($result)) { return Oedipus_DramaHelper::get_drama_by_id($row['id']); } else { throw new Oedipus_DramaNotFoundException($unique_name); } }