edit_table.class.php

来自「很棒的在线教学系统」· PHP 代码 · 共 312 行 · 第 1/2 页

PHP
312
字号
        foreach($plugins as $plugin) {            $classname = 'XMLDB' . $plugin;            $generator = new $classname();            $reserved_words = array_merge($reserved_words, $generator->getReservedWords());        }        sort($reserved_words);        $reserved_words = array_unique($reserved_words);    /// Delete any 'changeme' field/key/index        $table->deleteField('changeme');        $table->deleteKey('changeme');        $table->deleteIndex('changeme');    /// Add the fields list        $fields =& $table->getFields();        if (!empty($fields)) {            $o .= '<h3 class="main">' . $this->str['fields'] . '</h3>';            $o .= '<table id="listfields" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">';            $row = 0;            foreach ($fields as $field) {            /// Calculate buttons                $b = '</td><td class="button cell">';            /// The edit button (if the field has no uses)                if (!$structure->getFieldUses($table->getName(), $field->getName())) {                    $b .= '<a href="index.php?action=edit_field&amp;field=' .$field->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['edit'] . ']</a>';                } else {                    $b .= '[' . $this->str['edit'] . ']';                }                $b .= '</td><td class="button cell">';            /// The up button                if ($field->getPrevious()) {                    $b .= '<a href="index.php?action=move_updown_field&amp;direction=up&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;postaction=edit_table' . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['up'] . ']</a>';                } else {                    $b .= '[' . $this->str['up'] . ']';                }                $b .= '</td><td class="button cell">';            /// The down button                if ($field->getNext()) {                    $b .= '<a href="index.php?action=move_updown_field&amp;direction=down&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;postaction=edit_table' . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['down'] . ']</a>';                } else {                    $b .= '[' . $this->str['down'] . ']';                }                $b .= '</td><td class="button cell">';            /// The delete button (if we have more than one and it isn't used                if (count($fields) > 1 &&                !$structure->getFieldUses($table->getName(), $field->getName())) {                    $b .= '<a href="index.php?action=delete_field&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>';                } else {                    $b .= '[' . $this->str['delete'] . ']';                }            /// Detect if the table name is a reserved word                if (in_array($field->getName(), $reserved_words)) {                    $b .= '&nbsp;<a href="index.php?action=view_reserved_words"><span class="error">' . $this->str['reserved'] . '</span></a>';                }            /// The readable info                $r = '</td><td class="readableinfo cell">' . $field->readableInfo() . '</td>';            /// Print table row            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_field_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited">' . $field->getName() . '</a>' . $b . $r . '</tr>';                $row = ($row + 1) % 2;            }            $o .= '</table>';        }    /// Add the keys list        $keys =& $table->getKeys();        if (!empty($keys)) {            $o .= '<h3 class="main">' . $this->str['keys'] . '</h3>';            $o .= '<table id="listkeys" border="0"  cellpadding="5" cellspacing="1" class="boxaligncenter flexible">';            $row = 0;            foreach ($keys as $key) {            /// Calculate buttons                $b = '</td><td class="button cell">';            /// The edit button (if the key hasn't uses)                if (!$structure->getKeyUses($table->getName(), $key->getName())) {                    $b .= '<a href="index.php?action=edit_key&amp;key=' .$key->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['edit'] . ']</a>';                } else {                     $b .= '[' . $this->str['edit'] . ']';                }                $b .= '</td><td class="button cell">';            /// The up button                if ($key->getPrevious()) {                    $b .= '<a href="index.php?action=move_updown_key&amp;direction=up&amp;key=' . $key->getName() . '&amp;table=' . $table->getName() . '&amp;postaction=edit_table' . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['up'] . ']</a>';                } else {                    $b .= '[' . $this->str['up'] . ']';                }                $b .= '</td><td class="button cell">';            /// The down button                if ($key->getNext()) {                    $b .= '<a href="index.php?action=move_updown_key&amp;direction=down&amp;key=' . $key->getName() . '&amp;table=' . $table->getName() . '&amp;postaction=edit_table' . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['down'] . ']</a>';                } else {                    $b .= '[' . $this->str['down'] . ']';                }                $b .= '</td><td class="button cell">';            /// The delete button (if the key hasn't uses)                if (!$structure->getKeyUses($table->getName(), $key->getName())) {                    $b .= '<a href="index.php?action=delete_key&amp;key=' . $key->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>';                } else {                    $b .= '[' . $this->str['delete'] . ']';                }            /// The readable info                $r = '</td><td class="readableinfo cell">' . $key->readableInfo() . '</td>';            /// Print table row            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_key_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;key=' . $key->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited">' . $key->getName() . '</a>' . $b . $r .'</tr>';                $row = ($row + 1) % 2;            }            $o .= '</table>';        }   /// Add the indexes list        $indexes =& $table->getIndexes();        if (!empty($indexes)) {            $o .= '<h3 class="main">' . $this->str['indexes'] . '</h3>';            $o .= '<table id="listindexes" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">';            $row = 0;            foreach ($indexes as $index) {            /// Calculate buttons                $b = '</td><td class="button cell">';            /// The edit button            $b .= '<a href="index.php?action=edit_index&amp;index=' .$index->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['edit'] . ']</a>';                $b .= '</td><td class="button cell">';            /// The up button                if ($index->getPrevious()) {                    $b .= '<a href="index.php?action=move_updown_index&amp;direction=up&amp;index=' . $index->getName() . '&amp;table=' . $table->getName() . '&amp;postaction=edit_table' . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['up'] . ']</a>';                } else {                    $b .= '[' . $this->str['up'] . ']';                }                $b .= '</td><td class="button cell">';            /// The down button                if ($index->getNext()) {                    $b .= '<a href="index.php?action=move_updown_index&amp;direction=down&amp;index=' . $index->getName() . '&amp;table=' . $table->getName() . '&amp;postaction=edit_table' . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['down'] . ']</a>';                } else {                    $b .= '[' . $this->str['down'] . ']';                }                $b .= '</td><td class="button cell">';            /// The delete button                    $b .= '<a href="index.php?action=delete_index&amp;index=' . $index->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>';            /// The readable info                $r = '</td><td class="readableinfo cell">' . $index->readableInfo() . '</td>';            /// Print table row            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_index_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;index=' . $index->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited">' . $index->getName() . '</a>' . $b . $r .'</tr>';                $row = ($row + 1) % 2;            }            $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;    }}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?