当前位置: 首页>>代码示例>>PHP>>正文


PHP xmldb_file::isLoaded方法代码示例

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


在下文中一共展示了xmldb_file::isLoaded方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_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 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 xmldb_file($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:ajv,项目名称:Offline-Caching,代码行数:62,代码来源:load_xml_file.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
     /// 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

示例3: recreate_table

 private function recreate_table($component, $tablename)
 {
     global $DB;
     unset($DB->donesetup);
     $manager = $DB->get_manager();
     $filename = get_component_directory($component) . "/db/install.xml";
     $xmldbfile = new xmldb_file($filename);
     if (!$xmldbfile->fileExists()) {
         throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
     }
     $loaded = $xmldbfile->loadXMLStructure();
     if (!$loaded || !$xmldbfile->isLoaded()) {
         // Show info about the error if we can find it.
         if ($structure =& $xmldbfile->getStructure()) {
             if ($errors = $structure->getAllErrors()) {
                 throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: ' . implode(', ', $errors));
             }
         }
         throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
     }
     $structure = $xmldbfile->getStructure();
     $table = $structure->getTable($tablename);
     $manager->create_table($table);
     $DB->donesetup = true;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:25,代码来源:utility_methods_test.php

示例4: stats_temp_table_create

/**
 * Create temporary tables to speed up log generation
 */
function stats_temp_table_create()
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // We are going to use database_manager services
    stats_temp_table_drop();
    $xmlfile = $CFG->dirroot . '/lib/db/install.xml';
    $tables = array();
    // Allows for the additional xml files to be used (if necessary)
    $files = array($xmlfile => array('stats_daily' => array('temp_stats_daily'), 'stats_user_daily' => array('temp_stats_user_daily'), 'temp_enroled_template' => array('temp_enroled'), 'temp_log_template' => array('temp_log1', 'temp_log2')));
    foreach ($files as $file => $contents) {
        $xmldb_file = new xmldb_file($file);
        if (!$xmldb_file->fileExists()) {
            throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
        }
        $loaded = $xmldb_file->loadXMLStructure();
        if (!$loaded || !$xmldb_file->isLoaded()) {
            throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
        }
        $xmldb_structure = $xmldb_file->getStructure();
        foreach ($contents as $template => $names) {
            $table = $xmldb_structure->getTable($template);
            if (is_null($table)) {
                throw new ddl_exception('ddlunknowntable', null, 'The table ' . $name . ' is not defined in the file ' . $xmlfile);
            }
            $table->setNext(null);
            $table->setPrevious(null);
            foreach ($names as $name) {
                $named = clone $table;
                $named->setName($name);
                $tables[$name] = $named;
            }
        }
    }
    try {
        foreach ($tables as $table) {
            $dbman->create_temp_table($table);
        }
    } catch (Exception $e) {
        mtrace('Temporary table creation failed: ' . $e->getMessage());
        return false;
    }
    return true;
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:47,代码来源:statslib.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_HTML;
     /// These are always here
     global $CFG, $XMLDB, $DB, $OUTPUT;
     /// And we nedd some ddl suff
     $dbman = $DB->get_manager();
     /// Here we'll acummulate all the wrong fields found
     $problemsfound = array();
     /// Do the job, setting $result as needed
     /// Get the confirmed to decide what to do
     $confirmed = optional_param('confirmed', false, PARAM_BOOL);
     /// If  not confirmed, show confirmation box
     if (!$confirmed) {
         $o = '<table class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
         $o .= '  <tr><td class="generalboxcontent">';
         $o .= '    <p class="centerpara">' . $this->str[$this->introstr] . '</p>';
         $o .= '    <table class="boxaligncenter" cellpadding="20"><tr><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=' . $this->title . '&amp;confirmed=yes&amp;sesskey=' . sesskey() . '" 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" 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 {
         /// The back to edit table button
         $b = ' <p class="centerpara buttons">';
         $b .= '<a href="index.php">[' . $this->str['back'] . ']</a>';
         $b .= '</p>';
         /// Iterate over $XMLDB->dbdirs, loading their XML data to memory
         if ($XMLDB->dbdirs) {
             $dbdirs =& $XMLDB->dbdirs;
             $o = '<ul>';
             foreach ($dbdirs as $dbdir) {
                 /// Only if the directory exists
                 if (!$dbdir->path_exists) {
                     continue;
                 }
                 /// Load the XML file
                 $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
                 /// Only if the file exists
                 if (!$xmldb_file->fileExists()) {
                     continue;
                 }
                 /// Load the XML contents to structure
                 $loaded = $xmldb_file->loadXMLStructure();
                 if (!$loaded || !$xmldb_file->isLoaded()) {
                     echo $OUTPUT->notification('Errors found in XMLDB file: ' . $dbdir->path . '/install.xml');
                     continue;
                 }
                 /// Arriving here, everything is ok, get the XMLDB structure
                 $structure = $xmldb_file->getStructure();
                 $o .= '    <li>' . str_replace($CFG->dirroot . '/', '', $dbdir->path . '/install.xml');
                 /// Getting tables
                 if ($xmldb_tables = $structure->getTables()) {
                     $o .= '        <ul>';
                     /// Foreach table, process its fields
                     foreach ($xmldb_tables as $xmldb_table) {
                         /// Skip table if not exists
                         if (!$dbman->table_exists($xmldb_table)) {
                             continue;
                         }
                         /// Fetch metadata from physical DB. All the columns info.
                         if (!($metacolumns = $DB->get_columns($xmldb_table->getName()))) {
                             //// Skip table if no metacolumns is available for it
                             continue;
                         }
                         /// Table processing starts here
                         $o .= '            <li>' . $xmldb_table->getName();
                         /// Do the specific check.
                         list($output, $newproblems) = $this->check_table($xmldb_table, $metacolumns);
                         $o .= $output;
                         $problemsfound = array_merge($problemsfound, $newproblems);
                         $o .= '    </li>';
                         /// Give the script some more time (resetting to current if exists)
                         if ($currenttl = @ini_get('max_execution_time')) {
                             @ini_set('max_execution_time', $currenttl);
                         }
                     }
                     $o .= '        </ul>';
                 }
                 $o .= '    </li>';
             }
             $o .= '</ul>';
         }
         /// Create a report of the problems found.
//.........这里部分代码省略.........
开发者ID:nigeldaley,项目名称:moodle,代码行数:101,代码来源:XMLDBCheckAction.class.php

示例6: create_temptable_from_real_table

 /**
  * Given one "real" tablename, create one temp table suitable for be used in backup/restore operations
  */
 public static function create_temptable_from_real_table($backupid, $realtablename, $temptablename)
 {
     global $CFG, $DB;
     $dbman = $DB->get_manager();
     // We are going to use database_manager services
     // As far as xmldb objects use a lot of circular references (prev and next) and we aren't destroying
     // them at all, that causes one memory leak of about 3M per backup execution, not problematic for
     // individual backups but critical for automated (multiple) ones.
     // So we are statically caching the xmldb_table definition here to produce the leak "only" once
     static $xmldb_tables = array();
     // Not cached, get it
     if (!isset($xmldb_tables[$realtablename])) {
         // Note: For now we are going to load the realtablename from core lib/db/install.xml
         // that way, any change in the "template" will be applied here automatically. If this causes
         // too much slow, we can always forget about the template and keep maintained the xmldb_table
         // structure inline - manually - here.
         // TODO: Right now, loading the whole lib/db/install.xml is "eating" 10M, we should
         // change our way here in order to decrease that memory usage
         $templatetablename = $realtablename;
         $targettablename = $temptablename;
         $xmlfile = $CFG->dirroot . '/lib/db/install.xml';
         $xmldb_file = new xmldb_file($xmlfile);
         if (!$xmldb_file->fileExists()) {
             throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
         }
         $loaded = $xmldb_file->loadXMLStructure();
         if (!$loaded || !$xmldb_file->isLoaded()) {
             throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
         }
         $xmldb_structure = $xmldb_file->getStructure();
         $xmldb_table = $xmldb_structure->getTable($templatetablename);
         if (is_null($xmldb_table)) {
             throw new ddl_exception('ddlunknowntable', null, 'The table ' . $templatetablename . ' is not defined in file ' . $xmlfile);
         }
         // Clean prev & next, we are alone
         $xmldb_table->setNext(null);
         $xmldb_table->setPrevious(null);
         // Rename
         $xmldb_table->setName($targettablename);
         // Cache it
         $xmldb_tables[$realtablename] = $xmldb_table;
     }
     // Arrived here, we have the table always in static cache, get it
     $xmldb_table = $xmldb_tables[$realtablename];
     // Set default backupid (not needed but this enforce any missing backupid). That's hackery in action!
     $xmldb_table->getField('backupid')->setDefault($backupid);
     $dbman->create_temp_table($xmldb_table);
     // And create it
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:52,代码来源:backup_controller_dbops.class.php

示例7: load_xmldb_file

 /**
  * Load an install.xml file, checking that it exists, and that the structure is OK.
  * @param string $file the full path to the XMLDB file.
  * @return xmldb_file the loaded file.
  */
 private function load_xmldb_file($file)
 {
     $xmldb_file = new xmldb_file($file);
     if (!$xmldb_file->fileExists()) {
         throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
     }
     $loaded = $xmldb_file->loadXMLStructure();
     if (!$loaded || !$xmldb_file->isLoaded()) {
         // Show info about the error if we can find it
         if ($structure = $xmldb_file->getStructure()) {
             if ($errors = $structure->getAllErrors()) {
                 throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: ' . implode(', ', $errors));
             }
         }
         throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
     }
     return $xmldb_file;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:23,代码来源:database_manager.php


注:本文中的xmldb_file::isLoaded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。