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); }
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; }
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!"); } }