sesskey_protected = false; // This action doesn't need sesskey protection /// Get needed strings $this->loadStrings(array( 'change' => 'xmldb', 'vieworiginal' => 'xmldb', 'viewedited' => 'xmldb', 'newsentence' => 'xmldb', 'sentences' => 'xmldb', 'edit' => 'xmldb', 'delete' => 'xmldb', 'duplicate' => 'xmldb', 'back' => 'xmldb' )); } /** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } /// ADD YOUR CODE HERE $statementparam = optional_param('statement', NULL, PARAM_CLEAN); /// If no statement, then we are coming for a new one. Look for /// type and table and build the correct statementparam if (!$statementparam) { $typeparam = optional_param('type', NULL, PARAM_CLEAN); $tableparam = optional_param('table', NULL, PARAM_CLEAN); $typename = XMLDBStatement::getXMLDBStatementName($typeparam); $statementparam = trim(strtolower($typename . ' ' . $tableparam)); } if (!$statement =& $structure->getStatement($statementparam)) { /// Arriving here from a name change, looking for the new statement name $statementname = required_param('name', PARAM_CLEAN); $statement =& $structure->getStatement($statementparam); } $dbdir =& $XMLDB->dbdirs[$dirpath]; $origstructure =& $dbdir->xml_file->getStructure(); /// Add the main form $o = '
'; $o.= '
'; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= ' '; $o.= '
Name:' . s($statement->getName()) .'
 
'; $o.= '
'; /// Calculate the buttons $b = '

'; /// The view original XML button if ($origstructure->getStatement($statementparam)) { $b .= ' [' . $this->str['vieworiginal'] . ']'; } else { $b .= ' [' . $this->str['vieworiginal'] . ']'; } /// The view edited XML button if ($statement->hasChanged()) { $b .= ' [' . $this->str['viewedited'] . ']'; } else { $b .= ' [' . $this->str['viewedited'] . ']'; } /// The new sentence button $b .= ' [' . $this->str['newsentence'] . ']'; /// The back to edit xml file button $b .= ' [' . $this->str['back'] . ']'; $b .= '

'; $o .= $b; /// Delete any 'changeme' sentence ///$statement->deleteSentence('changeme'); /// Add the fields list $sentences =& $statement->getSentences(); if (!empty($sentences)) { $o .= '

' . $this->str['sentences'] . '

'; $o .= ''; $row = 0; foreach ($sentences as $key => $sentence) { /// Prepend some SQL if ($statement->getType() == XMLDB_STATEMENT_INSERT) { $p = 'INSERT INTO ' . $statement->getTable() . ' '; } else { $p = 'UNSUPPORTED SENTENCE TYPE '; } /// Calculate buttons $b = ''; /// Print table row $o .= ''; $row = ($row + 1) % 2; } $o .= '
'; /// The edit button $b .= '[' . $this->str['edit'] . ']'; $b .= ''; /// The duplicate button $b .= '[' . $this->str['duplicate'] . ']'; $b .= ''; /// The delete button $b .= '[' . $this->str['delete'] . ']'; $b .= '
' . $p . $sentence . $b . '
'; } $this->output = $o; /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; } } ?>