• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP XMLDBAction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中XMLDBAction的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBAction类的具体用法?PHP XMLDBAction怎么用?PHP XMLDBAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了XMLDBAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: invoke

 /**
  * 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_XML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting result as needed
     /// Get the file parameter
     $file = required_param('file', PARAM_PATH);
     $file = $CFG->dirroot . $file;
     /// File must be under $CFG->wwwroot and
     ///  under one db directory (simple protection)
     if (substr($file, 0, strlen($CFG->dirroot)) == $CFG->dirroot && substr(dirname($file), -2, 2) == 'db') {
         /// Everything is ok. Load the file to memory
         $this->output = file_get_contents($file);
     } else {
         /// Switch to HTML and error
         $this->does_generate = ACTION_GENERATE_HTML;
         $this->errormsg = 'File not viewable (' . $file . ')';
         $result = false;
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:31,代码来源:view_xml.class.php


示例2: invoke

 /**
  * 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_NONE;
     //$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 . $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
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:36,代码来源:template.class.php


示例3: invoke

 /**
  * 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_NONE;
     //$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 . $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();
     }
     // If the changeme table exists, just get it and continue
     $changeme_exists = false;
     if ($tables =& $structure->getTables()) {
         if ($table =& $structure->getTable('changeme')) {
             $changeme_exists = true;
         }
     }
     if (!$changeme_exists) {
         // Lets create the table
         $field = new xmldb_field('id');
         $field->setType(XMLDB_TYPE_INTEGER);
         $field->setLength(10);
         $field->setNotNull(true);
         $field->setUnsigned(true);
         $field->setSequence(true);
         $field->setLoaded(true);
         $field->setChanged(true);
         $key = new xmldb_key('primary');
         $key->setType(XMLDB_KEY_PRIMARY);
         $key->setFields(array('id'));
         $key->setLoaded(true);
         $key->setChanged(true);
         $table = new xmldb_table('changeme');
         $table->setComment('Default comment for the table, please edit me');
         $table->addField($field);
         $table->addKey($key);
         // Finally, add the whole retrofitted table to the structure
         // in the place specified
         $structure->addTable($table);
     }
     // Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     // Return ok if arrived here
     return $result;
 }
开发者ID:raymondAntonio,项目名称:moodle,代码行数:65,代码来源:new_table.class.php


示例4: invoke

 /**
  * 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_NONE;
     //$this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting $result as needed
     /// Lets go to add all the db directories available inside Moodle
     /// Create the array if it doesn't exists
     if (!isset($XMLDB->dbdirs)) {
         $XMLDB->dbdirs = array();
     }
     /// get list of all dirs and create objects with status
     $db_direcotries = get_db_directories();
     foreach ($db_direcotries as $path) {
         $dbdir = new stdClass();
         $dbdir->path = $path;
         if (!isset($XMLDB->dbdirs[$dbdir->path])) {
             $XMLDB->dbdirs[$dbdir->path] = $dbdir;
         }
         $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path);
         //Update status
     }
     /// Sort by key
     ksort($XMLDB->dbdirs);
     /// Return ok if arrived here
     return true;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:36,代码来源:get_db_directories.class.php


示例5: invoke

 /**
  * 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_XML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting result as needed
     /// Get the file parameter
     $select = required_param('select', PARAM_ALPHA);
     //original/edited
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
     /// Get the correct dir
     if ($select == 'original') {
         if (!empty($XMLDB->dbdirs)) {
             $base =& $XMLDB->dbdirs[$dirpath];
         }
     } else {
         if ($select == 'edited') {
             if (!empty($XMLDB->editeddirs)) {
                 $base =& $XMLDB->editeddirs[$dirpath];
             }
         } else {
             $this->errormsg = 'Cannot access to ' . $select . ' info';
             $result = false;
         }
     }
     if ($base) {
         /// Only if the directory exists and it has been loaded
         if (!$base->path_exists || !$base->xml_loaded) {
             $this->errormsg = 'Directory ' . $dirpath . ' not loaded';
             return false;
         }
     } else {
         $this->errormsg = 'Problem handling ' . $select . ' files';
         return false;
     }
     /// Get the structure
     if ($result) {
         if (!($structure =& $base->xml_file->getStructure())) {
             $this->errormsg = 'Error retrieving ' . $select . ' structure';
             $result = false;
         }
     }
     if ($result) {
         /// Everything is ok. Generate the XML output
         $this->output = $structure->xmlOutput();
     } else {
         /// Switch to HTML and error
         $this->does_generate = ACTION_GENERATE_HTML;
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:62,代码来源:view_structure_xml.class.php


示例6: invoke

 /**
  * 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_NONE;
     //$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 dir
     if (!empty($XMLDB->dbdirs)) {
         $dbdir =& $XMLDB->dbdirs[$dirpath];
         if ($dbdir) {
             /// Set some defaults
             $dbdir->xml_exists = false;
             $dbdir->xml_writeable = false;
             $dbdir->xml_loaded = false;
             ///Only if the directory exists
             if (!$dbdir->path_exists) {
                 return false;
             }
             $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
             ///Set the XML DTD and schema
             $xmldb_file->setDTD($CFG->dirroot . '/lib/xmldb/xmldb.dtd');
             $xmldb_file->setSchema($CFG->dirroot . '/lib/xmldb/xmldb.xsd');
             /// Set dbdir as necessary
             if ($xmldb_file->fileExists()) {
                 $dbdir->xml_exists = true;
             }
             if ($xmldb_file->fileWriteable()) {
                 $dbdir->xml_writeable = true;
             }
             /// Load the XML contents to structure
             $loaded = $xmldb_file->loadXMLStructure();
             if ($loaded && $xmldb_file->isLoaded()) {
                 $dbdir->xml_loaded = true;
                 $dbdir->filemtime = filemtime($dbdir->path . '/install.xml');
             }
             $dbdir->xml_file = $xmldb_file;
         } else {
             $this->errormsg = 'Wrong directory (' . $dirpath . ')';
             $result = false;
         }
     } else {
         $this->errormsg = 'XMLDB structure not found';
         $result = false;
     }
     /// Launch postaction if exists
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     return $result;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:62,代码来源:load_xml_file.class.php


示例7: invoke

 /**
  * 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_NONE;
     // 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 . $dirpath;
     $unload = optional_param('unload', true, PARAM_BOOL);
     // Get the edited dir
     if (!empty($XMLDB->editeddirs)) {
         if (isset($XMLDB->editeddirs[$dirpath])) {
             $editeddir = $XMLDB->editeddirs[$dirpath];
         }
     }
     // Copy the edited dir over the original one
     if (!empty($XMLDB->dbdirs)) {
         if (isset($XMLDB->dbdirs[$dirpath])) {
             $XMLDB->dbdirs[$dirpath] = unserialize(serialize($editeddir));
             $dbdir = $XMLDB->dbdirs[$dirpath];
         }
     }
     // Check for perms
     if (!is_writeable($dirpath . '/install.xml')) {
         $this->errormsg = $this->str['filenotwriteable'] . '(' . $dirpath . '/install.xml)';
         return false;
     }
     // Save the original dir
     $result = $dbdir->xml_file->saveXMLFile();
     if ($result) {
         // Delete the edited dir
         unset($XMLDB->editeddirs[$dirpath]);
         // Unload de originaldir
         unset($XMLDB->dbdirs[$dirpath]->xml_file);
         unset($XMLDB->dbdirs[$dirpath]->xml_loaded);
         unset($XMLDB->dbdirs[$dirpath]->xml_changed);
         unset($XMLDB->dbdirs[$dirpath]->xml_exists);
         unset($XMLDB->dbdirs[$dirpath]->xml_writeable);
     } else {
         $this->errormsg = 'Error saving XML file (' . $dirpath . ')';
         return false;
     }
     // If unload has been disabled, simulate it by reloading the file now
     if (!$unload) {
         return $this->launch('load_xml_file');
     }
     // Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     // Return ok if arrived here
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:62,代码来源:save_xml_file.class.php


示例8: invoke

 /**
  * 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, $DB;
     $dbman = $DB->get_manager();
     /// Do the job, setting result as needed
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . $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
     /// Get parameters
     $tableparam = required_param('table', PARAM_PATH);
     if (!($table = $structure->getTable($tableparam))) {
         $this->errormsg = 'Wrong table specified: ' . $tableparam;
         return false;
     }
     /// The back to edit table button
     $b = ' <p class="centerpara buttons">';
     $b .= '<a href="index.php?action=edit_table&amp;table=' . $tableparam . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
     $b .= '</p>';
     $o = $b;
     $o .= '    <table id="formelements" class="boxaligncenter" cellpadding="5">';
     $o .= '      <tr><td><textarea cols="80" rows="32">';
     /// Get an array of statements
     if ($starr = $DB->get_manager()->generator->getCreateTableSQL($table)) {
         $starr = $dbman->generator->getEndedStatements($starr);
         $sqltext = '';
         foreach ($starr as $st) {
             $sqltext .= s($st) . "\n\n";
         }
         $sqltext = trim($sqltext);
         $o .= $sqltext;
     }
     $o .= '</textarea></td></tr>';
     $o .= '    </table>';
     $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;
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:62,代码来源:view_table_sql.class.php


示例9: invoke

 /**
  * 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);
     $confirmed = optional_param('confirmed', false, PARAM_BOOL);
     /// If  not confirmed, show confirmation box
     if (!$confirmed) {
         $o = '<table width="60" class="generalbox boxaligncenter" border="0" cellpadding="5" cellspacing="0" id="notice">';
         $o .= '  <tr><td class="generalboxcontent">';
         $o .= '    <p class="centerpara">' . $this->str['confirmrevertchanges'] . '<br /><br />' . $dirpath . '</p>';
         $o .= '    <table class="boxaligncenter" cellpadding="20"><tr><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=revert_changes&amp;sesskey=' . sesskey() . '&amp;confirmed=yes&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;postaction=main_view#lastused" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['yes'] . '" /></fieldset></form></div>';
         $o .= '      </td><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=main_view#lastused" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['no'] . '" /></fieldset></form></div>';
         $o .= '      </td></tr>';
         $o .= '    </table>';
         $o .= '  </td></tr>';
         $o .= '</table>';
         $this->output = $o;
     } else {
         /// Get the original dir and delete some elements
         if (!empty($XMLDB->dbdirs)) {
             if (isset($XMLDB->dbdirs[$dirpath])) {
                 $dbdir =& $XMLDB->dbdirs[$dirpath];
                 if ($dbdir) {
                     unset($dbdir->xml_changed);
                 }
             }
         }
         /// Get the edited dir and delete it completely
         if (!empty($XMLDB->editeddirs)) {
             if (isset($XMLDB->editeddirs[$dirpath])) {
                 unset($XMLDB->editeddirs[$dirpath]);
             }
         }
     }
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:60,代码来源:revert_changes.class.php


示例10: invoke

 /**
  * 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_NONE;
     //$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 = required_param('statement', PARAM_CLEAN);
     $basesentenceparam = optional_param('basesentence', NULL, PARAM_CLEAN);
     $statement =& $structure->getStatement($statementparam);
     $sentences =& $statement->getSentences();
     $sentence = NULL;
     /// If some sentence has been specified, create the new one
     /// based on it
     if (!empty($basesentenceparam)) {
         $sentence = $sentences[$basesentenceparam];
     }
     /// Else, try to create the new one based in the last
     if (empty($sentence) && !empty($sentences)) {
         $sentence = end($sentences);
     }
     /// Else, create one sentence by hand
     if (empty($sentence)) {
         $sentence = "(list, of, fields) VALUES ('list', 'of', 'values')";
     }
     /// Add the sentence to the statement
     $statement->addSentence($sentence);
     /// We have one new sentence, so the statement and the structure has changed
     $statement->setChanged(true);
     $structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
     $structure->setChanged(true);
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:60,代码来源:new_sentence.class.php


示例11: invoke

 /**
  * 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 . $dirpath;
     $statementparam = required_param('statement', PARAM_CLEAN);
     $confirmed = optional_param('confirmed', false, PARAM_BOOL);
     /// If  not confirmed, show confirmation box
     if (!$confirmed) {
         $o = '<table width="60" class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
         $o .= '  <tr><td class="generalboxcontent">';
         $o .= '    <p class="centerpara">' . $this->str['confirmdeletestatement'] . '<br /><br />' . $statementparam . '</p>';
         $o .= '    <table class="boxaligncenter" cellpadding="20"><tr><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=delete_statement&amp;confirmed=yes&amp;postaction=edit_xml_file&amp;statement=' . $statementparam . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['yes'] . '" /></fieldset></form></div>';
         $o .= '      </td><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['no'] . '" /></fieldset></form></div>';
         $o .= '      </td></tr>';
         $o .= '    </table>';
         $o .= '  </td></tr>';
         $o .= '</table>';
         $this->output = $o;
     } else {
         /// Get the edited dir
         if (!empty($XMLDB->editeddirs)) {
             if (isset($XMLDB->editeddirs[$dirpath])) {
                 $dbdir =& $XMLDB->dbdirs[$dirpath];
                 $editeddir =& $XMLDB->editeddirs[$dirpath];
                 if ($editeddir) {
                     $structure =& $editeddir->xml_file->getStructure();
                     /// Remove the table
                     $structure->deleteStatement($statementparam);
                 }
             }
         }
     }
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:58,代码来源:delete_statement.class.php


示例12: invoke

 /**
  * 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
     /// Add link back to home
     $b = ' <p class="centerpara buttons">';
     $b .= '&nbsp;<a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>';
     $b .= '</p>';
     $this->output = $b;
     $c = ' <p class="centerpara">';
     $c .= $this->str['documentationintro'];
     $c .= '</p>';
     $this->output .= $c;
     $this->docs = '';
     if (class_exists('XSLTProcessor')) {
         $doc = new DOMDocument();
         $xsl = new XSLTProcessor();
         $doc->load(dirname(__FILE__) . '/../generate_documentation/xmldb.xsl');
         $xsl->importStyleSheet($doc);
         $dbdirs = get_db_directories();
         sort($dbdirs);
         $index = $this->str['docindex'] . ' ';
         foreach ($dbdirs as $path) {
             if (!file_exists($path . '/install.xml')) {
                 continue;
             }
             $dir = trim(dirname(str_replace($CFG->dirroot, '', $path)), '/');
             $index .= '<a href="#file_' . str_replace('/', '_', $dir) . '">' . $dir . '</a>, ';
             $this->docs .= '<div class="file" id="file_' . str_replace('/', '_', $dir) . '">';
             $this->docs .= '<h2>' . $dir . '</h2>';
             $doc->load($path . '/install.xml');
             $this->docs .= $xsl->transformToXML($doc);
             $this->docs .= '</div>';
         }
         $this->output .= '<div id="file_idex">' . trim($index, ' ,') . '</div>' . $this->docs;
         $this->output .= $b;
     } else {
         $this->output .= get_string('extensionrequired', 'tool_xmldb', 'xsl');
     }
     /// Launch postaction if exists (leave this unmodified)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     return $result;
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:55,代码来源:generate_all_documentation.class.php


示例13: invoke

 /**
  * 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_NONE;
     //$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
     $tableparam = required_param('table', PARAM_CLEAN);
     $table =& $structure->getTable($tableparam);
     /// If the changeme field exists, just get it and continue
     $changeme_exists = false;
     if ($fields =& $table->getFields()) {
         if ($field =& $table->getField('changeme')) {
             $changeme_exists = true;
         }
     }
     if (!$changeme_exists) {
         /// Lets create the field
         $field = new XMLDBField('changeme');
         $field->setComment('Default comment for the field, please edit me');
         $table->addField($field);
         /// We have one new field, so the structure has changed
         $structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
         $structure->setChanged(true);
     }
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:veritech,项目名称:pare-project,代码行数:54,代码来源:new_field.class.php


示例14: invoke

 /**
  * 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_NONE;
     //$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);
     $plugintype = $this->get_plugin_type($dirpath);
     $dirpath = $CFG->dirroot . $dirpath;
     $file = $dirpath . '/install.xml';
     // Some variables
     $xmlpath = dirname(str_replace($CFG->dirroot . '/', '', $file));
     $xmlversion = userdate(time(), '%Y%m%d', 99, false);
     $xmlcomment = 'XMLDB file for Moodle ' . dirname($xmlpath);
     $xmltable = strtolower(basename(dirname($xmlpath)));
     if ($plugintype && $plugintype != 'mod') {
         $xmltable = $plugintype . '_' . $xmltable;
     }
     // Initial contents
     $c = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
     $c .= '  <XMLDB PATH="' . $xmlpath . '" VERSION="' . $xmlversion . '" COMMENT="' . $xmlcomment . '">' . "\n";
     $c .= '    <TABLES>' . "\n";
     $c .= '      <TABLE NAME="' . $xmltable . '" COMMENT="Default comment for ' . $xmltable . ', please edit me">' . "\n";
     $c .= '        <FIELDS>' . "\n";
     $c .= '          <FIELD NAME="id" TYPE="int" LENGTH="10" UNSIGNED="true" NOTNULL="true" SEQUENCE="true" />' . "\n";
     $c .= '        </FIELDS>' . "\n";
     $c .= '        <KEYS>' . "\n";
     $c .= '          <KEY NAME="primary" TYPE="primary" FIELDS="id" />' . "\n";
     $c .= '        </KEYS>' . "\n";
     $c .= '      </TABLE>' . "\n";
     $c .= '    </TABLES>' . "\n";
     $c .= '  </XMLDB>';
     if (!file_put_contents($file, $c)) {
         $errormsg = 'Error creando fichero ' . $file;
         $result = false;
     }
     // Launch postaction if exists
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     // Return ok if arrived here
     return $result;
 }
开发者ID:raymondAntonio,项目名称:moodle,代码行数:53,代码来源:create_xml_file.class.php


示例15: invoke

 /**
  * 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_NONE;
     //$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 . $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();
     }
     $tableparam = required_param('table', PARAM_CLEAN);
     $table = $structure->getTable($tableparam);
     // If the changeme index exists, just get it and continue
     $changeme_exists = false;
     if ($indexes = $table->getIndexes()) {
         if ($index = $table->getIndex('changeme')) {
             $changeme_exists = true;
         }
     }
     if (!$changeme_exists) {
         // Lets create the Index
         $index = new xmldb_index('changeme');
         $table->addIndex($index);
         // We have one new key, so the structure has changed
         $structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
         $structure->setChanged(true);
     }
     // Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     // Return ok if arrived here
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:52,代码来源:new_index.class.php


示例16: invoke

 /**
  * 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_NONE;
     //$this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting result as needed
     /// Get parameters
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
     $statementparam = strtolower(required_param('statement', PARAM_CLEAN));
     $name = trim(strtolower(required_param('name', PARAM_CLEAN)));
     $comment = required_param('comment', PARAM_CLEAN);
     $comment = stripslashes_safe($comment);
     $editeddir =& $XMLDB->editeddirs[$dirpath];
     $structure =& $editeddir->xml_file->getStructure();
     $statement =& $structure->getStatement($statementparam);
     $errors = array();
     /// To store all the errors found
     /// If there is one name change, do it, changing the prev and next
     /// atributes of the adjacent tables
     if ($statementparam != $name) {
         $statement->setName($name);
         if ($statement->getPrevious()) {
             $prev =& $structure->getStatement($statement->getPrevious());
             $prev->setNext($name);
             $prev->setChanged(true);
         }
         if ($statement->getNext()) {
             $next =& $structure->getStatement($statement->getNext());
             $next->setPrevious($name);
             $next->setChanged(true);
         }
     }
     /// Set comment
     $statement->setComment($comment);
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:51,代码来源:edit_statement_save.class.php


示例17: invoke

 /**
  * 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 . $dirpath;
     $path = $dirpath . '/install.xml';
     if (!file_exists($path) || !is_readable($path)) {
         return false;
     }
     // Add link back to home
     $b = ' <p class="centerpara buttons">';
     $b .= '&nbsp;<a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>';
     $b .= '</p>';
     $this->output = $b;
     $c = ' <p class="centerpara">';
     $c .= $this->str['documentationintro'];
     $c .= '</p>';
     $this->output .= $c;
     if (class_exists('XSLTProcessor')) {
         // Transform XML file and display it
         $doc = new DOMDocument();
         $xsl = new XSLTProcessor();
         $doc->load(__DIR__ . '/xmldb.xsl');
         $xsl->importStyleSheet($doc);
         $doc->load($path);
         $this->output .= $xsl->transformToXML($doc);
         $this->output .= $b;
     } else {
         $this->output .= get_string('extensionrequired', 'tool_xmldb', 'xsl');
     }
     // Launch postaction if exists (leave this unmodified)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:48,代码来源:generate_documentation.class.php


示例18: invoke

 /**
  * 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_NONE;
     //$this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting $result as needed
     /// Iterate over $XMLDB->dbdirs, loading their XML data to memory
     if ($XMLDB->dbdirs) {
         $dbdirs =& $XMLDB->dbdirs;
         foreach ($dbdirs as $dbdir) {
             /// Set some defaults
             $dbdir->xml_exists = false;
             $dbdir->xml_writeable = false;
             $dbdir->xml_loaded = false;
             ///Only if the directory exists
             if (!$dbdir->path_exists) {
                 continue;
             }
             $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
             /// Set dbdir as necessary
             if ($xmldb_file->fileExists()) {
                 $dbdir->xml_exists = true;
             }
             if ($xmldb_file->fileWriteable()) {
                 $dbdir->xml_writeable = true;
             }
             /// Load the XML contents to structure
             $loaded = $xmldb_file->loadXMLStructure();
             if ($loaded && $xmldb_file->isLoaded()) {
                 $dbdir->xml_loaded = true;
             }
             $dbdir->xml_file = $xmldb_file;
         }
     }
     return $result;
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:45,代码来源:load_xml_files.class.php


示例19: invoke

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP XMLDBField类代码示例发布时间:2022-05-23
下一篇:
PHP XMLDAO类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap