示例#1
0
文件: view.php 项目: madcsaba/li-de
 function displaySchema()
 {
     require_once KPATH_ADMIN . '/install/schema.php';
     $schema = new KunenaModelSchema();
     $create = $schema->getCreateSQL();
     echo '<textarea cols="80" rows="50">';
     echo $this->escape($schema->getSchema()->saveXML());
     echo '</textarea>';
     if (KunenaForum::isDev()) {
         echo '<textarea cols="80" rows="20">';
         foreach ($create as $item) {
             echo $this->escape($item['sql']) . "\n\n";
         }
         echo '</textarea>';
     }
 }
示例#2
0
 public function installDatabase()
 {
     static $schema = null;
     static $create = null;
     static $tables = null;
     if ($schema === null) {
         // Run only once: get table creation SQL and existing tables
         require_once KPATH_ADMIN . '/install/schema.php';
         $schema = new KunenaModelSchema();
         $create = $schema->getCreateSQL();
         $tables = $this->listTables('kunena_', true);
     }
     $app = JFactory::getApplication();
     $state = $app->getUserState('com_kunena.install.dbstate', null);
     // First run: get all tables
     if ($state === null) {
         $state = array_keys($create);
     }
     // Handle only first table in the list
     $table = array_shift($state);
     if ($table) {
         $query = $create[$table];
         if (!isset($tables[$table])) {
             $result = $schema->updateSchemaTable($table);
             if ($result) {
                 $this->addStatus(JText::_('COM_KUNENA_INSTALL_CREATE') . ' ' . $result['name'], $result['success']);
             }
         }
         // Save user state with remaining tables
         $app->setUserState('com_kunena.install.dbstate', $state);
         // Database install continues
         return false;
     } else {
         // Reset user state
         $this->updateVersionState('upgradeDatabase');
         $app->setUserState('com_kunena.install.dbstate', null);
     }
     // Database install complete
     return true;
 }