Merge branch 'QA_5_0' into STABLE
This commit is contained in:
commit
fda8a1b2da
@ -7,11 +7,8 @@ end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
|
||||
[*.{js,php,twig,phtml,json,css}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[{*.sql,package.json,.travis.yml}]
|
||||
indent_style = space
|
||||
[{*.{sql,scss,css,twig},package.json,.travis.yml}]
|
||||
indent_size = 2
|
||||
|
||||
@ -1,12 +1,29 @@
|
||||
{
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:no-jquery/deprecated"
|
||||
],
|
||||
"plugins": ["no-jquery"],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"jquery": true
|
||||
},
|
||||
"globals": {
|
||||
"AJAX": "readonly",
|
||||
"CodeMirror": "readonly",
|
||||
"CommonActions": "readonly",
|
||||
"CommonParams": "readonly",
|
||||
"Cookies": "readonly",
|
||||
"Functions": "readonly",
|
||||
"Messages": "readonly",
|
||||
"Navigation": "readonly",
|
||||
"OpenLayers": "readonly",
|
||||
"Sql": "readonly"
|
||||
},
|
||||
"rules": {
|
||||
"array-bracket-spacing": "error",
|
||||
"brace-style": "error",
|
||||
"camelcase": "warn",
|
||||
"camelcase": "error",
|
||||
"comma-style": ["error", "last"],
|
||||
"curly": "error",
|
||||
"dot-notation": "error",
|
||||
@ -14,19 +31,19 @@
|
||||
"eqeqeq": "error",
|
||||
"indent": ["error", 4],
|
||||
"keyword-spacing": "error",
|
||||
"new-cap": "warn",
|
||||
"no-array-constructor": "warn",
|
||||
"no-eval": "warn",
|
||||
"no-loop-func": "warn",
|
||||
"no-mixed-spaces-and-tabs": "error",
|
||||
"new-cap": "error",
|
||||
"no-array-constructor": "error",
|
||||
"no-eval": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-multiple-empty-lines": "error",
|
||||
"no-new-func": "error",
|
||||
"no-new-object": "error",
|
||||
"no-param-reassign": "warn",
|
||||
"no-param-reassign": "error",
|
||||
"no-prototype-builtins": "off",
|
||||
"no-redeclare": ["error", { "builtinGlobals": false }],
|
||||
"no-trailing-spaces": "error",
|
||||
"no-underscore-dangle": "warn",
|
||||
"no-underscore-dangle": "error",
|
||||
"no-unneeded-ternary": "error",
|
||||
"no-useless-escape": "warn",
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"one-var": ["error", "never"],
|
||||
"padded-blocks": ["error", "never"],
|
||||
|
||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
custom: https://www.phpmyadmin.net/donate/
|
||||
26
.github/ISSUE_TEMPLATE.md
vendored
26
.github/ISSUE_TEMPLATE.md
vendored
@ -1,26 +0,0 @@
|
||||
### Steps to reproduce
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Expected behaviour
|
||||
Tell us what should happen
|
||||
|
||||
### Actual behaviour
|
||||
Tell us what happens instead
|
||||
|
||||
### Server configuration
|
||||
**Operating system**:
|
||||
|
||||
**Web server:**
|
||||
|
||||
**Database:**
|
||||
|
||||
**PHP version:**
|
||||
|
||||
**phpMyAdmin version:**
|
||||
|
||||
### Client configuration
|
||||
**Browser:**
|
||||
|
||||
**Operating system:**
|
||||
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
### Describe the bug
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### To Reproduce
|
||||
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
### Expected behavior
|
||||
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### Screenshots
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
### Server configuration
|
||||
|
||||
- Operating system:
|
||||
- Web server:
|
||||
- Database version:
|
||||
- PHP version:
|
||||
- phpMyAdmin version:
|
||||
|
||||
### Client configuration
|
||||
|
||||
- Browser:
|
||||
- Operating system:
|
||||
|
||||
### Additional context
|
||||
|
||||
Add any other context about the problem here.
|
||||
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for phpMyAdmin
|
||||
|
||||
---
|
||||
|
||||
### Is your feature request related to a problem? Please describe.
|
||||
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
### Describe the solution you'd like
|
||||
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
### Describe alternatives you've considered
|
||||
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
### Additional context
|
||||
|
||||
- phpMyAdmin version:
|
||||
|
||||
Add any other context or screenshots about the feature request here.
|
||||
11
.github/ISSUE_TEMPLATE/security_report.md
vendored
Normal file
11
.github/ISSUE_TEMPLATE/security_report.md
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
name: Security report
|
||||
about: Disclose a security vulnerability responsibly by first reporting it to us privately
|
||||
|
||||
---
|
||||
|
||||
Security problems should not be reported here.
|
||||
|
||||
See our security page: https://www.phpmyadmin.net/security/
|
||||
|
||||
Thanks for your help!
|
||||
18
.github/PULL_REQUEST_TEMPLATE.md
vendored
18
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,6 +1,14 @@
|
||||
Before submitting pull request, please check that every commit:
|
||||
### Description
|
||||
|
||||
- [ ] Has proper Signed-Off-By
|
||||
- [ ] Has commit message which describes it
|
||||
- [ ] Is needed on it's own, if you have just minor fixes to previous commits, you can squash them
|
||||
- [ ] Any new functionality is covered by tests
|
||||
Please describe your pull request.
|
||||
|
||||
Fixes #
|
||||
|
||||
Before submitting pull request, please review the following checklist:
|
||||
|
||||
- [ ] Make sure you have read our [CONTRIBUTING.md](https://github.com/phpmyadmin/phpmyadmin/blob/master/CONTRIBUTING.md) document.
|
||||
- [ ] Make sure you are making a pull request against the correct branch. For example, for bug fixes in a released version use the corresponding QA branch and for new features use the _master_ branch. If you have a doubt, you can ask as a comment in the bug report or on the mailing list.
|
||||
- [ ] Every commit has proper `Signed-off-by` line as described in our [DCO](https://github.com/phpmyadmin/phpmyadmin/blob/master/DCO). This ensures that the work you're submitting is your own creation.
|
||||
- [ ] Every commit has a descriptive commit message.
|
||||
- [ ] Every commit is needed on its own, if you have just minor fixes to previous commits, you can squash them.
|
||||
- [ ] Any new functionality is covered by tests.
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -56,3 +56,4 @@ composer.lock
|
||||
/vendor/
|
||||
# NPM
|
||||
/node_modules/
|
||||
phpstan.neon
|
||||
|
||||
@ -11,12 +11,18 @@ filter:
|
||||
- vendor/
|
||||
checks:
|
||||
javascript: true
|
||||
php: true
|
||||
build:
|
||||
dependencies:
|
||||
before:
|
||||
- composer install
|
||||
- composer require tecnickcom/tcpdf pragmarx/google2fa bacon/bacon-qr-code samyoul/u2f-php-server
|
||||
tests:
|
||||
override:
|
||||
- php-scrutinizer-run
|
||||
- phpcs-run
|
||||
nodes:
|
||||
analysis:
|
||||
environment:
|
||||
php: 7.1
|
||||
node: 10
|
||||
dependencies:
|
||||
before:
|
||||
- composer install
|
||||
- composer require tecnickcom/tcpdf pragmarx/google2fa-qrcode samyoul/u2f-php-server
|
||||
tests:
|
||||
override:
|
||||
- php-scrutinizer-run
|
||||
- phpcs-run
|
||||
|
||||
21
.stylelintrc.json
Normal file
21
.stylelintrc.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"extends": [
|
||||
"stylelint-config-standard",
|
||||
"stylelint-config-recommended-scss"
|
||||
],
|
||||
"rules": {
|
||||
"no-descending-specificity": null,
|
||||
"no-duplicate-selectors": null,
|
||||
"block-closing-brace-newline-after": ["always", {
|
||||
"ignoreAtRules": ["if", "else"]
|
||||
}],
|
||||
"at-rule-empty-line-before": ["always", {
|
||||
"except": [
|
||||
"blockless-after-same-name-blockless",
|
||||
"first-nested"
|
||||
],
|
||||
"ignore": ["after-comment"],
|
||||
"ignoreAtRules": ["else"]
|
||||
}]
|
||||
}
|
||||
}
|
||||
261
.travis.yml
261
.travis.yml
@ -1,43 +1,20 @@
|
||||
# The Travis setup:
|
||||
# - run testsuite for every PHP version
|
||||
# - run lint for every PHP version
|
||||
# - run Selenium for single PHP version
|
||||
|
||||
dist: xenial
|
||||
|
||||
language: php
|
||||
|
||||
services:
|
||||
- mysql
|
||||
|
||||
php:
|
||||
- "7.3"
|
||||
- "7.2"
|
||||
- "7.1"
|
||||
- "7.0"
|
||||
- "5.6"
|
||||
- "hhvm-3.12"
|
||||
- "hhvm-3.18"
|
||||
- "hhvm-3.21"
|
||||
- "hhvm-3.24"
|
||||
- "hhvm-3.27"
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- CI_MODE=test
|
||||
global:
|
||||
- TESTSUITE_USER=root
|
||||
- TESTSUITE_URL=http://127.0.0.1:8000
|
||||
stages:
|
||||
- name: "Lint and analyse code"
|
||||
- name: "PHP Unit tests"
|
||||
- name: "Documentation"
|
||||
- name: "Other tests"
|
||||
|
||||
install:
|
||||
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then source ~/virtualenv/python3.6/bin/activate ; fi
|
||||
- ./test/ci-install-$CI_MODE
|
||||
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then case "$TRAVIS_PHP_VERSION" in hhvm*) ;; *) phpenv config-add test/php-noprofile.ini ;; esac ; fi
|
||||
- composer install --no-interaction
|
||||
- yarn install --non-interactive
|
||||
|
||||
before_script:
|
||||
- export TESTSUITE_PASSWORD=`openssl rand -base64 30`
|
||||
- export TESTSUITE_BROWSERSTACK_KEY=`echo cHlDcHJTNmZwZjVlaUR2RmV6VkU= | base64 --decode`
|
||||
- export PATH=~/.composer/vendor/bin/:$PATH
|
||||
- mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test"
|
||||
- mysql -uroot < sql/create_tables.sql
|
||||
- mysql -uroot -e "SET PASSWORD = PASSWORD('$TESTSUITE_PASSWORD')"
|
||||
@ -45,8 +22,7 @@ before_script:
|
||||
|
||||
script:
|
||||
- ./scripts/generate-mo --quiet
|
||||
- if [ $CI_MODE = test ] ; then ./test/ci-lint ; fi
|
||||
- ./test/ci-$CI_MODE
|
||||
- ./vendor/bin/phpunit --configuration phpunit.xml.dist --exclude-group selenium
|
||||
|
||||
after_script:
|
||||
- if [ -f vendor/bin/codacycoverage ] ; then php vendor/bin/codacycoverage clover || true ; fi
|
||||
@ -54,29 +30,81 @@ after_script:
|
||||
- if [ -f nginx-error.log ] ; then cat nginx-error.log ; fi
|
||||
- if [ -f build/logs/phpunit.json ] ; then ./scripts/phpunit-top-tests build/logs/phpunit.json ; fi
|
||||
- if [ -f config.inc.php ] ; then rm -rf config.inc.php; fi
|
||||
- if [ "$CI_MODE" = "selenium" ] ; then ~/browserstack/BrowserStackLocal --daemon stop; fi
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
after_success: bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: "7.1"
|
||||
env: CI_MODE=selenium
|
||||
before_install: phpenv config-rm xdebug.ini
|
||||
- php: "7.0"
|
||||
node_js: 10
|
||||
env: CI_MODE=release
|
||||
- php: "7.1"
|
||||
env: CI_MODE=docs
|
||||
- php: "7.1"
|
||||
env: CI_MODE=apidocs
|
||||
before_install: phpenv config-rm xdebug.ini
|
||||
services:
|
||||
- mysql
|
||||
|
||||
cache:
|
||||
pip: true
|
||||
yarn: true
|
||||
directories:
|
||||
- $HOME/.composer/cache/
|
||||
- $HOME/browserstack
|
||||
- node_modules
|
||||
|
||||
jobs:
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
- os: osx
|
||||
- name: "PHP 7.1 with dbase extension"
|
||||
|
||||
include:
|
||||
- stage: "Lint and analyse code"
|
||||
name: "Lint files"
|
||||
before_script: skip
|
||||
after_script: skip
|
||||
after_success: skip
|
||||
script:
|
||||
- ./test/ci-phplint
|
||||
- composer phpcs
|
||||
- yarn run js-lint --quiet
|
||||
- yarn run css-lint
|
||||
|
||||
- stage: "Lint and analyse code"
|
||||
name: "Run phpstan"
|
||||
before_script: skip
|
||||
after_script: skip
|
||||
after_success: skip
|
||||
script: composer phpstan
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
php: 7.1
|
||||
name: "PHP 7.1"
|
||||
env: CI_MODE=test
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
php: 7.2
|
||||
name: "PHP 7.2"
|
||||
env: CI_MODE=test
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
php: 7.3
|
||||
name: "PHP 7.3"
|
||||
env: CI_MODE=test
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
php: 7.4
|
||||
name: "PHP 7.4"
|
||||
env: CI_MODE=test
|
||||
before_install: phpenv config-rm xdebug.ini
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
php: nightly
|
||||
name: "PHP nightly"
|
||||
env: CI_MODE=test
|
||||
install:
|
||||
- composer install --no-interaction --ignore-platform-reqs
|
||||
- yarn install --non-interactive
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
name: "OSX"
|
||||
os: osx
|
||||
env: CI_MODE=test
|
||||
language: node_js
|
||||
node_js: 10
|
||||
env: CI_MODE=test
|
||||
before_install:
|
||||
- brew link --force gettext
|
||||
- echo "memory_limit=-1" > /usr/local/etc/php/7.4/conf.d/50-travis.ini
|
||||
@ -85,15 +113,6 @@ matrix:
|
||||
- sleep 5
|
||||
# Enable password access
|
||||
- mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');"
|
||||
install:
|
||||
- composer require --no-interaction php>=7.1
|
||||
- composer remove phpunit/phpunit-selenium --dev --no-interaction
|
||||
- composer remove phpunit/phpunit --dev --no-interaction
|
||||
- composer require --dev --no-interaction phpunit/phpunit ^8
|
||||
- rm -rf test/selenium
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i.bak~ 's/function setUpBeforeClass()/function setUpBeforeClass(): void/g'"
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i.bak~ 's/function setUp()/function setUp(): void/g'"
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i.bak~ 's/function tearDown()/function tearDown(): void/g'"
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
@ -101,73 +120,77 @@ matrix:
|
||||
- composer
|
||||
- mariadb
|
||||
update: true
|
||||
- php: "5.5"
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
name: "Windows"
|
||||
os: windows
|
||||
language: node_js
|
||||
node_js: 10
|
||||
env:
|
||||
- CI_MODE=test
|
||||
- YARN_GPG=no
|
||||
before_install:
|
||||
- choco install php composer mariadb
|
||||
- export PATH=/c/tools/php74:/c/ProgramData/ComposerSetup/bin:/c/"Program Files"/"MariaDB 10.4"/bin:$PATH
|
||||
- PHP_EXTENSIONS="mysqli curl bz2 gd2 pdo_mysql"
|
||||
- for php_ext in $PHP_EXTENSIONS ; do sed -i -e "s/^;extension=${php_ext}/extension=${php_ext}/" /c/tools/php74/php.ini ; done
|
||||
- sed -i -e 's/^memory_limit = .*/memory_limit = -1/' /c/tools/php74/php.ini
|
||||
- find . -type f -name "*.php" -print0 | xargs -0 sed -i ':a;N;$!ba;s/\r//g'
|
||||
|
||||
- stage: "PHP Unit tests"
|
||||
php: 7.1
|
||||
name: "PHP 7.1 with dbase extension"
|
||||
env: CI_MODE=test
|
||||
dist: trusty
|
||||
- php: "7.3"
|
||||
env: CI_MODE=test
|
||||
name: "Run tests using phpunit 8"
|
||||
install:
|
||||
- composer require --no-interaction php>=7.1
|
||||
- composer remove phpunit/phpunit-selenium --dev --no-interaction
|
||||
- composer remove phpunit/phpunit --dev --no-interaction
|
||||
- composer require --dev --no-interaction phpunit/phpunit ^8
|
||||
- rm -rf test/selenium
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function setUpBeforeClass()/function setUpBeforeClass(): void/g'"
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function setUp()/function setUp(): void/g'"
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function tearDown()/function tearDown(): void/g'"
|
||||
- php: "7.4"
|
||||
env: CI_MODE=test
|
||||
name: "PHP: 7.4"
|
||||
install:
|
||||
- composer require --no-interaction php>=7.1
|
||||
- composer remove phpunit/phpunit-selenium --dev --no-interaction
|
||||
- composer remove phpunit/phpunit --dev --no-interaction
|
||||
- composer require --dev --no-interaction phpunit/phpunit ^8
|
||||
- rm -rf test/selenium
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function setUpBeforeClass()/function setUpBeforeClass(): void/g'"
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function setUp()/function setUp(): void/g'"
|
||||
- "find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function tearDown()/function tearDown(): void/g'"
|
||||
- phpenv config-rm xdebug.ini
|
||||
- php: "7.1"
|
||||
env: CI_MODE=test DBASE=true
|
||||
install:
|
||||
- pecl channel-update pecl.php.net
|
||||
- pecl install dbase
|
||||
- test/ci-install-test
|
||||
- php: "5.6"
|
||||
env: CI_MODE=test DBASE=true
|
||||
install:
|
||||
- pecl channel-update pecl.php.net
|
||||
- pecl install dbase-5.1.1
|
||||
- test/ci-install-test
|
||||
- php: "nightly"
|
||||
env: CI_MODE=test
|
||||
install:
|
||||
- composer install --no-interaction --ignore-platform-reqs
|
||||
- php: "7.1"
|
||||
- composer install --no-interaction
|
||||
- yarn install --non-interactive
|
||||
|
||||
- stage: "Documentation"
|
||||
name: "Build docs"
|
||||
before_script: skip
|
||||
after_script: skip
|
||||
after_success: skip
|
||||
script:
|
||||
- test/ci-lint
|
||||
- vendor/bin/phpcs --standard=phpcs.xml.dist
|
||||
install:
|
||||
- source ~/virtualenv/python3.6/bin/activate
|
||||
- pip install 'Sphinx'
|
||||
script: ./test/ci-docs
|
||||
|
||||
allow_failures:
|
||||
- php: "nightly"
|
||||
- env: CI_MODE=test DBASE=true
|
||||
- stage: "Documentation"
|
||||
name: "Build API docs"
|
||||
before_install: phpenv config-rm xdebug.ini
|
||||
before_script: skip
|
||||
after_script: skip
|
||||
after_success: skip
|
||||
install: composer global require "sami/sami:^4.0"
|
||||
script: $HOME/.composer/vendor/bin/sami.php --no-interaction update ./test/sami-config.php
|
||||
|
||||
cache:
|
||||
pip: true
|
||||
directories:
|
||||
- $HOME/.composer/cache/
|
||||
- $HOME/browserstack
|
||||
- $HOME/runkit
|
||||
# Install APT packages
|
||||
# - git > 2.5.1 needed for worktrees
|
||||
# - mysql server does not seem to be always present on Travis Trusty environment
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- git
|
||||
- nginx
|
||||
- stage: "Other tests"
|
||||
name: "Build release"
|
||||
before_script: skip
|
||||
after_script: skip
|
||||
after_success: skip
|
||||
install:
|
||||
- source ~/virtualenv/python3.6/bin/activate
|
||||
- pip install 'Sphinx'
|
||||
script: ./scripts/create-release.sh --ci
|
||||
|
||||
- stage: "Other tests"
|
||||
name: "Run selenium tests on Google Chrome"
|
||||
env:
|
||||
- CI_MODE=selenium
|
||||
- TESTSUITE_SELENIUM_BROWSER=chrome
|
||||
- TESTSUITE_USER=root
|
||||
- TESTSUITE_URL=http://127.0.0.1:8000
|
||||
before_install: phpenv config-rm xdebug.ini
|
||||
install:
|
||||
- ./test/install-browserstack
|
||||
- composer install --no-interaction
|
||||
- yarn install --non-interactive
|
||||
- echo -e "<?php\n\$cfg['UploadDir'] = './test/test_data/';" > config.inc.php
|
||||
script: ./vendor/bin/phpunit --configuration phpunit.xml.nocoverage --group selenium --verbose --debug
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- nginx
|
||||
|
||||
@ -9,7 +9,7 @@ We appreciate your effort to improve phpMyAdmin by submitting a bug report. Befo
|
||||
1. Check whether the bug you face **hasn't been already reported**. Duplicate reports take us time, that we could be used to fix other bugs or make improvements.
|
||||
2. Specify the phpMyAdmin, server, PHP, MySQL and browser information that may be helpful to fix the problem, especially exact **version numbers**.
|
||||
3. If you got some error, please **describe what happened** and add an error message. Reports like "I get an error when I clicked on some link." are useless.
|
||||
4. Provide easy steps to reproduce and if possible include your table structure (``SHOW CREATE TABLE `tbl_name```); if your problem implies specific data, attach a small export file for sample rows.
|
||||
4. Provide easy steps to reproduce and if possible include your table structure (``SHOW CREATE TABLE `tbl_name`;``); if your problem implies specific data, attach a small export file for sample rows.
|
||||
5. **Security problems** should not be reported here. See [our security page](https://www.phpmyadmin.net/security/).
|
||||
Thanks for your help!
|
||||
|
||||
@ -39,6 +39,10 @@ details.
|
||||
[3]: https://github.com/phpmyadmin/phpmyadmin/blob/master/DCO
|
||||
[4]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff
|
||||
|
||||
## Triage issues [](https://www.codetriage.com/phpmyadmin/phpmyadmin)
|
||||
|
||||
You can triage issues, which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to phpMyAdmin on CodeTriage](https://www.codetriage.com/phpmyadmin/phpmyadmin).
|
||||
|
||||
## More information
|
||||
|
||||
You can find more information on our website:
|
||||
|
||||
46
ChangeLog
46
ChangeLog
@ -1,6 +1,52 @@
|
||||
phpMyAdmin - ChangeLog
|
||||
======================
|
||||
|
||||
5.0.0 (2019-12-26)
|
||||
- issue #13896 Drop support for PHP 5.5, PHP 5.6, PHP 7.0 and HHVM
|
||||
- issue #14007 Enable columns names by default for CSV exports
|
||||
- issue #13919 Remove font size feature
|
||||
- issue #12373 Add Metro theme
|
||||
- issue #14155 Add move columns preview SQL button
|
||||
- issue #14296 Enable strict mode in PHP files
|
||||
- issue #13627 Increase field width for editing varchar fields
|
||||
- issue #12603 Show warning for users with the default values for controluser and controlpass
|
||||
- issue #14589 Fix rendering of column comments in Safari, improve display in all browsers
|
||||
- issue #14330 New features for csv import plugin
|
||||
- issue #14417 Automatically add index while editing an existing row and setting auto increment
|
||||
- issue #13057 Add export option to drop user security definers from views
|
||||
- issue #14404 Drop view and or replace added to exporting view
|
||||
- issue #14594 Database "Search" selects all tables by default
|
||||
- issue #12158 Auto expand the single database
|
||||
- issue #13067 Inconsistency with submit buttons
|
||||
- issue #14683 Improper message in Show Hidden Navigation Tree Items
|
||||
- issue #14695 Remove unlabeled default collation from the bottom of the database list; this information is available elsewhere
|
||||
- issue #14677 Security confirm() before running UPDATE statement without WHERE condition
|
||||
- issue #13023 Show errors at the bottom of the page and add copy query button for errors in processing sql queries
|
||||
- issue #14633 Use Sass instead of PHP to compile CSS
|
||||
- issue #14765 Add initial support for Bootstrap 4
|
||||
- issue #14829 Change table column comment field from input to textarea
|
||||
- issue #14725 Console: ctrl+l clear line and ctrl+u clear console
|
||||
- issue #14837 Use charset 'windows-1252' when format is MS Excel
|
||||
- issue #15030 Move 'More settings' link from 'Appearance settings' to 'General settings'
|
||||
- issue #15029 Remove the redundant 'i' help/tool tip in page settings "Query History Length" area
|
||||
- issue #13424 Importing CSV now uses file name as the table name instead of 'TABLE #'
|
||||
- issue #14926 Add an Edit link for each view in tables list
|
||||
- issue #14890 Display column details in navigation bar
|
||||
- issue #14977 Add title for group in navigation bar
|
||||
- issue #14927 Show InnoDB table overhead (free space)
|
||||
- issue #15072 Add 'Close' button to the Monitor Instructions modal
|
||||
- issue #15174 Improved filter method in server variables page
|
||||
- issue #15266 Add an external dependency injection system
|
||||
- issue #15350 Change MIME type references to Media (MIME) type
|
||||
- issue Fixed url.php crashing because it's not loading the DatabaseInterface service
|
||||
- issue #15540 Fixed uncaught TypeError: htmlspecialchars() in NavigationTree
|
||||
- issue Fix twig deprecation notices for php 8.0
|
||||
- issue #15435 Fix ReCAPTCHA couldn't find user-provided function: Functions.recaptchaCallback
|
||||
- issue #15623 Fix width of picker modal and remove date picker for int fields
|
||||
- issue #14732 Fixed can't rename primary key with auto increment
|
||||
- issue #15677 Fix show process-list triggers a php exception
|
||||
- issue #15697 Fix uncaught php error: "Call to a member function get() on null" in db_export.php when exporting a table from the list
|
||||
|
||||
4.9.3 (2019-12-26)
|
||||
- issue #15570 Fix page contents go underneath of floating menubar in some cases
|
||||
- issue #15591 Fix php notice 'Undefined index: foreign_keys_data' on relations view when the user has column access
|
||||
|
||||
2
README
2
README
@ -1,7 +1,7 @@
|
||||
phpMyAdmin - Readme
|
||||
===================
|
||||
|
||||
Version 4.9.3
|
||||
Version 5.0.0
|
||||
|
||||
A web interface for MySQL and MariaDB.
|
||||
|
||||
|
||||
51
ajax.php
51
ajax.php
@ -5,17 +5,31 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Controllers\AjaxController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Util;
|
||||
use PhpMyAdmin\Core;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$_GET['ajax_request'] = 'true';
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
$response = Response::getInstance();
|
||||
$response->setAJAX(true);
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
$response->setAjax(true);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var AjaxController $controller */
|
||||
$controller = $containerBuilder->get(AjaxController::class);
|
||||
|
||||
if (empty($_POST['type'])) {
|
||||
Core::fatalError(__('Bad type!'));
|
||||
@ -23,25 +37,34 @@ if (empty($_POST['type'])) {
|
||||
|
||||
switch ($_POST['type']) {
|
||||
case 'list-databases':
|
||||
$response->addJSON('databases', $GLOBALS['dblist']->databases);
|
||||
$response->addJSON($controller->databases());
|
||||
break;
|
||||
case 'list-tables':
|
||||
Util::checkParameters(array('db'), true);
|
||||
$response->addJSON('tables', $GLOBALS['dbi']->getTables($_POST['db']));
|
||||
Util::checkParameters(['db'], true);
|
||||
$response->addJSON($controller->tables([
|
||||
'db' => $_POST['db'],
|
||||
]));
|
||||
break;
|
||||
case 'list-columns':
|
||||
Util::checkParameters(array('db', 'table'), true);
|
||||
$response->addJSON('columns', $GLOBALS['dbi']->getColumnNames($_POST['db'], $_POST['table']));
|
||||
Util::checkParameters(['db', 'table'], true);
|
||||
$response->addJSON($controller->columns([
|
||||
'db' => $_POST['db'],
|
||||
'table' => $_POST['table'],
|
||||
]));
|
||||
break;
|
||||
case 'config-get':
|
||||
Util::checkParameters(array('key'), true);
|
||||
$response->addJSON('value', $GLOBALS['PMA_Config']->get($_POST['key']));
|
||||
Util::checkParameters(['key'], true);
|
||||
$response->addJSON($controller->getConfig([
|
||||
'key' => $_POST['key'],
|
||||
]));
|
||||
break;
|
||||
case 'config-set':
|
||||
Util::checkParameters(array('key', 'value'), true);
|
||||
$result = $GLOBALS['PMA_Config']->setUserValue(null, $_POST['key'], json_decode($_POST['value']));
|
||||
Util::checkParameters(['key', 'value'], true);
|
||||
$result = $controller->setConfig([
|
||||
'key' => $_POST['key'],
|
||||
'value' => $_POST['value'],
|
||||
]);
|
||||
if ($result !== true) {
|
||||
$response = Response::getInstance();
|
||||
$response->setRequestStatus(false);
|
||||
$response->addJSON('message', $result);
|
||||
}
|
||||
|
||||
@ -5,70 +5,58 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\BrowseForeigners;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Controllers\BrowseForeignersController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* Sets globals from $_POST
|
||||
*/
|
||||
$request_params = array(
|
||||
'data',
|
||||
'field'
|
||||
);
|
||||
|
||||
foreach ($request_params as $one_request_param) {
|
||||
if (isset($_POST[$one_request_param])) {
|
||||
$GLOBALS[$one_request_param] = $_POST[$one_request_param];
|
||||
}
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
Util::checkParameters(array('db', 'table', 'field'));
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
Util::checkParameters(['db', 'table', 'field'], true);
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
/* Register BrowseForeignersController dependencies */
|
||||
$containerBuilder->set(
|
||||
'browse_foreigners',
|
||||
new BrowseForeigners(
|
||||
$GLOBALS['cfg']['LimitChars'],
|
||||
$GLOBALS['cfg']['MaxRows'],
|
||||
$GLOBALS['cfg']['RepeatCells'],
|
||||
$GLOBALS['cfg']['ShowAll'],
|
||||
$GLOBALS['pmaThemeImage'],
|
||||
$template
|
||||
)
|
||||
);
|
||||
|
||||
/** @var BrowseForeignersController $controller */
|
||||
$controller = $containerBuilder->get(BrowseForeignersController::class);
|
||||
|
||||
$response = Response::getInstance();
|
||||
$response->getFooter()->setMinimal();
|
||||
$header = $response->getHeader();
|
||||
$header->disableMenuAndConsole();
|
||||
$header->setBodyId('body_browse_foreigners');
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
/**
|
||||
* Displays the frame
|
||||
*/
|
||||
$foreigners = $relation->getForeigners($db, $table);
|
||||
$browseForeigners = new BrowseForeigners(
|
||||
$GLOBALS['cfg']['LimitChars'],
|
||||
$GLOBALS['cfg']['MaxRows'],
|
||||
$GLOBALS['cfg']['RepeatCells'],
|
||||
$GLOBALS['cfg']['ShowAll'],
|
||||
$GLOBALS['pmaThemeImage']
|
||||
);
|
||||
$foreign_limit = $browseForeigners->getForeignLimit(
|
||||
isset($_POST['foreign_showAll']) ? $_POST['foreign_showAll'] : null
|
||||
);
|
||||
|
||||
$foreignData = $relation->getForeignData(
|
||||
$foreigners, $_POST['field'], true,
|
||||
isset($_POST['foreign_filter'])
|
||||
? $_POST['foreign_filter']
|
||||
: '',
|
||||
isset($foreign_limit) ? $foreign_limit : null,
|
||||
true // for getting value in $foreignData['the_total']
|
||||
);
|
||||
|
||||
// HTML output
|
||||
$html = $browseForeigners->getHtmlForRelationalFieldSelection(
|
||||
$db,
|
||||
$table,
|
||||
$_POST['field'],
|
||||
$foreignData,
|
||||
isset($fieldkey) ? $fieldkey : null,
|
||||
isset($data) ? $data : null
|
||||
);
|
||||
|
||||
$response->addHtml($html);
|
||||
$response->addHTML($controller->index([
|
||||
'db' => $_POST['db'] ?? null,
|
||||
'table' => $_POST['table'] ?? null,
|
||||
'field' => $_POST['field'] ?? null,
|
||||
'fieldkey' => $_POST['fieldkey'] ?? null,
|
||||
'data' => $_POST['data'] ?? null,
|
||||
'foreign_showAll' => $_POST['foreign_showAll'] ?? null,
|
||||
'foreign_filter' => $_POST['foreign_filter'] ?? null,
|
||||
]));
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<property name="env.PHPUNIT_XML" value="phpunit.xml.dist"/>
|
||||
<property name="env.PHPUNIT_XML_NOCOVERAGE" value="phpunit.xml.nocoverage"/>
|
||||
<property name="env.PHPUNIT_XML_HHVM" value="phpunit.xml.hhvm"/>
|
||||
<property name="env.PHPUNIT_ARGS" value=""/>
|
||||
<property name="env.PHPUNIT_ARGS" value="--exclude-group selenium"/>
|
||||
|
||||
<target name="clean" description="Clean up and create artifact directories">
|
||||
<delete dir="${basedir}/build/api"/>
|
||||
|
||||
@ -5,12 +5,22 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Template;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets core libraries and defines some variables
|
||||
*/
|
||||
require 'libraries/common.inc.php';
|
||||
require ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
|
||||
$response = Response::getInstance();
|
||||
$response->disable();
|
||||
@ -23,7 +33,6 @@ $filename = CHANGELOG_FILE;
|
||||
*/
|
||||
// Check if the file is available, some distributions remove these.
|
||||
if (@is_readable($filename)) {
|
||||
|
||||
// Test if the if is in a compressed format
|
||||
if (substr($filename, -3) == '.gz') {
|
||||
ob_start();
|
||||
@ -53,7 +62,7 @@ $changelog = htmlspecialchars($changelog);
|
||||
$github_url = 'https://github.com/phpmyadmin/phpmyadmin/';
|
||||
$faq_url = 'https://docs.phpmyadmin.net/en/latest/faq.html';
|
||||
|
||||
$replaces = array(
|
||||
$replaces = [
|
||||
'@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@'
|
||||
=> '<a href="url.php?url=\\1">\\1</a>',
|
||||
|
||||
@ -79,11 +88,11 @@ $replaces = array(
|
||||
|
||||
// Highlight releases (with links)
|
||||
'/([0-9]+)\.([0-9]+)\.([0-9]+)\.0 (\([0-9-]+\))/'
|
||||
=> '<a name="\\1_\\2_\\3"></a>'
|
||||
=> '<a id="\\1_\\2_\\3"></a>'
|
||||
. '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3">'
|
||||
. '\\1.\\2.\\3.0 \\4</a>',
|
||||
'/([0-9]+)\.([0-9]+)\.([0-9]+)\.([1-9][0-9]*) (\([0-9-]+\))/'
|
||||
=> '<a name="\\1_\\2_\\3_\\4"></a>'
|
||||
=> '<a id="\\1_\\2_\\3_\\4"></a>'
|
||||
. '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3_\\4">'
|
||||
. '\\1.\\2.\\3.\\4 \\5</a>',
|
||||
|
||||
@ -92,26 +101,12 @@ $replaces = array(
|
||||
=> '\\1<b>\\2</b>',
|
||||
|
||||
// Links target and rel
|
||||
'/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="'
|
||||
'/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="',
|
||||
|
||||
);
|
||||
];
|
||||
|
||||
header('Content-type: text/html; charset=utf-8');
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<link rel="icon" href="favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||
<title>phpMyAdmin - ChangeLog</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>phpMyAdmin - ChangeLog</h1>
|
||||
<?php
|
||||
echo '<pre>';
|
||||
echo preg_replace(array_keys($replaces), $replaces, $changelog);
|
||||
echo '</pre>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
echo $template->render('changelog', [
|
||||
'changelog' => preg_replace(array_keys($replaces), $replaces, $changelog),
|
||||
]);
|
||||
|
||||
25
chk_rel.php
25
chk_rel.php
@ -5,18 +5,30 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$relation = new Relation();
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var Relation $relation */
|
||||
$relation = $containerBuilder->get('relation');
|
||||
|
||||
// If request for creating the pmadb
|
||||
if (isset($_POST['create_pmadb'])) {
|
||||
if ($relation->createPmaDatabase()) {
|
||||
$relation->fixPmaTables('phpmyadmin');
|
||||
}
|
||||
if (isset($_POST['create_pmadb']) && $relation->createPmaDatabase()) {
|
||||
$relation->fixPmaTables('phpmyadmin');
|
||||
}
|
||||
|
||||
// If request for creating all PMA tables.
|
||||
@ -30,7 +42,6 @@ if (isset($_POST['fix_pmadb'])) {
|
||||
$relation->fixPmaTables($cfgRelation['db']);
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
$response->addHTML(
|
||||
$relation->getRelationsParamDiagnostic($cfgRelation)
|
||||
);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "phpmyadmin/phpmyadmin",
|
||||
"type": "project",
|
||||
"description": "MySQL web administration tool",
|
||||
"description": "A web interface for MySQL and MariaDB",
|
||||
"keywords": ["phpmyadmin","mysql","web"],
|
||||
"homepage": "https://www.phpmyadmin.net/",
|
||||
"support": {
|
||||
@ -22,8 +22,7 @@
|
||||
"non-feature-branches": ["RELEASE_.*"],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpMyAdmin\\": "libraries/classes",
|
||||
"PhpMyAdmin\\Setup\\": "setup/lib"
|
||||
"PhpMyAdmin\\": "libraries/classes"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
@ -39,29 +38,33 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"ext-mysqli": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-json": "*",
|
||||
"ext-ctype": "*",
|
||||
"php": "^7.1.3",
|
||||
"ext-hash": "*",
|
||||
"phpmyadmin/sql-parser": "^4.3.2",
|
||||
"ext-iconv": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mysqli": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-xml": "*",
|
||||
"google/recaptcha": "^1.1",
|
||||
"phpmyadmin/motranslator": "^4.0",
|
||||
"phpmyadmin/shapefile": "^2.0",
|
||||
"phpmyadmin/sql-parser": "^5.0",
|
||||
"phpseclib/phpseclib": "^2.0",
|
||||
"google/recaptcha": "^1.1",
|
||||
"psr/container": "^1.0",
|
||||
"twig/twig": "^1.34 || ^2.0",
|
||||
"symfony/config": "^4.2.8",
|
||||
"symfony/dependency-injection": "^4.2.8",
|
||||
"symfony/expression-language": "^4.2",
|
||||
"symfony/polyfill-ctype": "^1.8",
|
||||
"symfony/polyfill-mbstring": "^1.3",
|
||||
"symfony/yaml": "^4.2.8",
|
||||
"twig/extensions": "~1.5.1",
|
||||
"symfony/expression-language": "^3.2 || ^2.8",
|
||||
"symfony/polyfill-mbstring": "^1.3"
|
||||
"twig/twig": "^2.4",
|
||||
"williamdes/mariadb-mysql-kbs": "^1.2"
|
||||
},
|
||||
"conflict": {
|
||||
"phpseclib/phpseclib": "2.0.8",
|
||||
"tecnickcom/tcpdf": "<6.2",
|
||||
"pragmarx/google2fa": "<3.0.1",
|
||||
"bacon/bacon-qr-code": "<1.0",
|
||||
"pragmarx/google2fa": ">=6.1",
|
||||
"pragmarx/google2fa-qrcode": "<1.0.1",
|
||||
"samyoul/u2f-php-server": "<1.1"
|
||||
},
|
||||
"suggest": {
|
||||
@ -74,30 +77,37 @@
|
||||
"ext-gd2": "For image transformations",
|
||||
"ext-mbstring": "For best performance",
|
||||
"tecnickcom/tcpdf": "For PDF support",
|
||||
"pragmarx/google2fa": "For 2FA authentication",
|
||||
"bacon/bacon-qr-code": "For 2FA authentication",
|
||||
"pragmarx/google2fa-qrcode": "For 2FA authentication",
|
||||
"samyoul/u2f-php-server": "For FIDO U2F authentication"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.36 || ^5.7",
|
||||
"codacy/coverage": "^1.3.0",
|
||||
"phpunit/phpunit-selenium": "~1.2 || ^3.0",
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"tecnickcom/tcpdf": "^6.3",
|
||||
"pragmarx/google2fa": "^3.0",
|
||||
"bacon/bacon-qr-code": "^1.0",
|
||||
"facebook/webdriver": "^1.7.1",
|
||||
"phpmyadmin/coding-standard": "^1.0",
|
||||
"phpstan/phpstan": "^0.11.5",
|
||||
"phpunit/phpunit": "^7.5 || ^8.0",
|
||||
"pragmarx/google2fa-qrcode": "^1.0.1",
|
||||
"samyoul/u2f-php-server": "^1.1",
|
||||
"phpmyadmin/coding-standard": "^0.3"
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"tecnickcom/tcpdf": "^6.3"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.9.x-dev"
|
||||
"dev-master": "5.0.x-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"phpcbf": "phpcbf",
|
||||
"phpcs": "phpcs",
|
||||
"phpstan": "phpstan analyse",
|
||||
"phpunit": "phpunit",
|
||||
"test": [
|
||||
"phpcs",
|
||||
"phpunit --color=always"
|
||||
"@phpcs",
|
||||
"@phpstan",
|
||||
"@phpunit"
|
||||
]
|
||||
},
|
||||
"config":{
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This is needed for cookie based authentication to encrypt password in
|
||||
|
||||
@ -1,180 +1,137 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Central Columns view/edit
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
use PhpMyAdmin\CentralColumns;
|
||||
use PhpMyAdmin\Controllers\Database\CentralColumnsController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Url;
|
||||
|
||||
/**
|
||||
* Gets some core libraries
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
$centralColumns = new CentralColumns($GLOBALS['dbi']);
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
if (isset($_POST['edit_save']) || isset($_POST['add_new_column'])) {
|
||||
$col_name = $_POST['col_name'];
|
||||
if (isset($_POST['edit_save'])) {
|
||||
$orig_col_name = $_POST['orig_col_name'];
|
||||
}
|
||||
$col_default = $_POST['col_default'];
|
||||
if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
|
||||
$col_default = "";
|
||||
}
|
||||
$col_extra = isset($_POST['col_extra']) ? $_POST['col_extra'] : '';
|
||||
$col_isNull = isset($_POST['col_isNull'])?1:0;
|
||||
$col_length = $_POST['col_length'];
|
||||
$col_attribute = $_POST['col_attribute'];
|
||||
$col_type = $_POST['col_type'];
|
||||
$collation = $_POST['collation'];
|
||||
if (isset($orig_col_name) && $orig_col_name) {
|
||||
echo $centralColumns->updateOneColumn(
|
||||
$db, $orig_col_name, $col_name, $col_type, $col_attribute,
|
||||
$col_length, $col_isNull, $collation, $col_extra, $col_default
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
$tmp_msg = $centralColumns->updateOneColumn(
|
||||
$db, "", $col_name, $col_type, $col_attribute,
|
||||
$col_length, $col_isNull, $collation, $col_extra, $col_default
|
||||
);
|
||||
}
|
||||
/** @var CentralColumns $centralColumns */
|
||||
$centralColumns = $containerBuilder->get('central_columns');
|
||||
|
||||
/** @var CentralColumnsController $controller */
|
||||
$controller = $containerBuilder->get(CentralColumnsController::class);
|
||||
|
||||
/** @var string $db */
|
||||
$db = $containerBuilder->getParameter('db');
|
||||
|
||||
if (isset($_POST['edit_save'])) {
|
||||
echo $controller->editSave([
|
||||
'col_name' => $_POST['col_name'] ?? null,
|
||||
'orig_col_name' => $_POST['orig_col_name'] ?? null,
|
||||
'col_default' => $_POST['col_default'] ?? null,
|
||||
'col_default_sel' => $_POST['col_default_sel'] ?? null,
|
||||
'col_extra' => $_POST['col_extra'] ?? null,
|
||||
'col_isNull' => $_POST['col_isNull'] ?? null,
|
||||
'col_length' => $_POST['col_length'] ?? null,
|
||||
'col_attribute' => $_POST['col_attribute'] ?? null,
|
||||
'col_type' => $_POST['col_type'] ?? null,
|
||||
'collation' => $_POST['collation'] ?? null,
|
||||
]);
|
||||
exit;
|
||||
} elseif (isset($_POST['add_new_column'])) {
|
||||
$tmp_msg = $controller->addNewColumn([
|
||||
'col_name' => $_POST['col_name'] ?? null,
|
||||
'col_default' => $_POST['col_default'] ?? null,
|
||||
'col_default_sel' => $_POST['col_default_sel'] ?? null,
|
||||
'col_extra' => $_POST['col_extra'] ?? null,
|
||||
'col_isNull' => $_POST['col_isNull'] ?? null,
|
||||
'col_length' => $_POST['col_length'] ?? null,
|
||||
'col_attribute' => $_POST['col_attribute'] ?? null,
|
||||
'col_type' => $_POST['col_type'] ?? null,
|
||||
'collation' => $_POST['collation'] ?? null,
|
||||
]);
|
||||
}
|
||||
if (isset($_POST['populateColumns'])) {
|
||||
$selected_tbl = $_POST['selectedTable'];
|
||||
echo $centralColumns->getHtmlForColumnDropdown(
|
||||
$db,
|
||||
$selected_tbl
|
||||
);
|
||||
$response->addHTML($controller->populateColumns([
|
||||
'selectedTable' => $_POST['selectedTable'],
|
||||
]));
|
||||
exit;
|
||||
}
|
||||
if (isset($_POST['getColumnList'])) {
|
||||
echo $centralColumns->getListRaw(
|
||||
$db,
|
||||
$_POST['cur_table']
|
||||
);
|
||||
$response->addJSON($controller->getColumnList([
|
||||
'cur_table' => $_POST['cur_table'] ?? null,
|
||||
]));
|
||||
exit;
|
||||
}
|
||||
if (isset($_POST['add_column'])) {
|
||||
$selected_col = array();
|
||||
$selected_tbl = $_POST['table-select'];
|
||||
$selected_col[] = $_POST['column-select'];
|
||||
$tmp_msg = $centralColumns->syncUniqueColumns(
|
||||
$selected_col,
|
||||
false,
|
||||
$selected_tbl
|
||||
);
|
||||
$tmp_msg = $controller->addColumn([
|
||||
'table-select' => $_POST['table-select'] ?? null,
|
||||
'column-select' => $_POST['column-select'] ?? null,
|
||||
]);
|
||||
}
|
||||
$response = Response::getInstance();
|
||||
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
|
||||
$scripts->addFile('vendor/jquery/jquery.tablesorter.js');
|
||||
$scripts->addFile('db_central_columns.js');
|
||||
$cfgCentralColumns = $centralColumns->getParams();
|
||||
$pmadb = $cfgCentralColumns['db'];
|
||||
$pmatable = $cfgCentralColumns['table'];
|
||||
$max_rows = intval($GLOBALS['cfg']['MaxRows']);
|
||||
$scripts->addFile('database/central_columns.js');
|
||||
|
||||
if (isset($_POST['edit_central_columns_page'])) {
|
||||
$selected_fld = $_POST['selected_fld'];
|
||||
$selected_db = $_POST['db'];
|
||||
$edit_central_column_page = $centralColumns->getHtmlForEditingPage(
|
||||
$selected_fld,
|
||||
$selected_db
|
||||
);
|
||||
$response->addHTML($edit_central_column_page);
|
||||
$response->addHTML($controller->editPage([
|
||||
'selected_fld' => $_POST['selected_fld'] ?? null,
|
||||
'db' => $_POST['db'] ?? null,
|
||||
]));
|
||||
exit;
|
||||
}
|
||||
if (isset($_POST['multi_edit_central_column_save'])) {
|
||||
$message = $centralColumns->updateMultipleColumn();
|
||||
if (!is_bool($message)) {
|
||||
$message = $controller->updateMultipleColumn([
|
||||
'db' => $_POST['db'] ?? null,
|
||||
'orig_col_name' => $_POST['orig_col_name'] ?? null,
|
||||
'field_name' => $_POST['field_name'] ?? null,
|
||||
'field_default_type' => $_POST['field_default_type'] ?? null,
|
||||
'field_default_value' => $_POST['field_default_value'] ?? null,
|
||||
'field_length' => $_POST['field_length'] ?? null,
|
||||
'field_attribute' => $_POST['field_attribute'] ?? null,
|
||||
'field_type' => $_POST['field_type'] ?? null,
|
||||
'field_collation' => $_POST['field_collation'] ?? null,
|
||||
'field_null' => $_POST['field_null'] ?? null,
|
||||
'col_extra' => $_POST['col_extra'] ?? null,
|
||||
]);
|
||||
if (! is_bool($message)) {
|
||||
$response->setRequestStatus(false);
|
||||
$response->addJSON('message', $message);
|
||||
}
|
||||
}
|
||||
if (isset($_POST['delete_save'])) {
|
||||
$col_name = array();
|
||||
parse_str($_POST['col_name'], $col_name);
|
||||
$tmp_msg = $centralColumns->deleteColumnsFromList(
|
||||
$col_name['selected_fld'],
|
||||
false
|
||||
);
|
||||
}
|
||||
if (!empty($_POST['total_rows'])
|
||||
&& Core::isValid($_POST['total_rows'], 'integer')
|
||||
) {
|
||||
$total_rows = $_POST['total_rows'];
|
||||
} else {
|
||||
$total_rows = $centralColumns->getCount($db);
|
||||
$tmp_msg = $controller->deleteSave([
|
||||
'db' => $_POST['db'] ?? null,
|
||||
'col_name' => $_POST['col_name'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
$response->addHTML($controller->index([
|
||||
'pos' => $_POST['pos'] ?? null,
|
||||
'total_rows' => $_POST['total_rows'] ?? null,
|
||||
]));
|
||||
|
||||
$pos = 0;
|
||||
if (Core::isValid($_POST['pos'], 'integer')) {
|
||||
$pos = intval($_POST['pos']);
|
||||
} else {
|
||||
$pos = 0;
|
||||
$pos = (int) $_POST['pos'];
|
||||
}
|
||||
$addNewColumn = $centralColumns->getHtmlForAddNewColumn($db, $total_rows);
|
||||
$response->addHTML($addNewColumn);
|
||||
if ($total_rows <= 0) {
|
||||
$response->addHTML(
|
||||
'<fieldset>' . __(
|
||||
'The central list of columns for the current database is empty.'
|
||||
) . '</fieldset>'
|
||||
);
|
||||
$columnAdd = $centralColumns->getHtmlForAddColumn($total_rows, $pos, $db);
|
||||
$response->addHTML($columnAdd);
|
||||
exit;
|
||||
}
|
||||
$table_navigation_html = $centralColumns->getHtmlForTableNavigation(
|
||||
$total_rows,
|
||||
$num_cols = $centralColumns->getColumnsCount(
|
||||
$db,
|
||||
$pos,
|
||||
$db
|
||||
(int) $GLOBALS['cfg']['MaxRows']
|
||||
);
|
||||
$response->addHTML($table_navigation_html);
|
||||
$columnAdd = $centralColumns->getHtmlForAddColumn($total_rows, $pos, $db);
|
||||
$response->addHTML($columnAdd);
|
||||
$deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
|
||||
. Url::getHiddenInputs(
|
||||
$db
|
||||
)
|
||||
. '<input id="del_col_name" type="hidden" name="col_name" value="">'
|
||||
. '<input type="hidden" name="pos" value="' . $pos . '">'
|
||||
. '<input type="hidden" name="delete_save" value="delete"></form>';
|
||||
$response->addHTML($deleteRowForm);
|
||||
$table_struct = '<div id="tableslistcontainer">'
|
||||
. '<form name="tableslistcontainer">'
|
||||
. '<table id="table_columns" class="tablesorter" '
|
||||
. 'class="data">';
|
||||
$response->addHTML($table_struct);
|
||||
$tableheader = $centralColumns->getTableHeader(
|
||||
'column_heading', __('Click to sort.'), 2
|
||||
);
|
||||
$response->addHTML($tableheader);
|
||||
$result = $centralColumns->getColumnsList($db, $pos, $max_rows);
|
||||
$row_num = 0;
|
||||
foreach ($result as $row) {
|
||||
$tableHtmlRow = $centralColumns->getHtmlForTableRow(
|
||||
$row,
|
||||
$row_num,
|
||||
$db
|
||||
);
|
||||
$response->addHTML($tableHtmlRow);
|
||||
$row_num++;
|
||||
}
|
||||
$response->addHTML('</table>');
|
||||
$tablefooter = $centralColumns->getTableFooter($pmaThemeImage, $text_dir);
|
||||
$response->addHTML($tablefooter);
|
||||
$response->addHTML('</form></div>');
|
||||
$message = Message::success(
|
||||
sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + count($result)))
|
||||
sprintf(__('Showing rows %1$s - %2$s.'), $pos + 1, $pos + $num_cols)
|
||||
);
|
||||
if (isset($tmp_msg) && $tmp_msg !== true) {
|
||||
$message = $tmp_msg;
|
||||
|
||||
220
db_datadict.php
220
db_datadict.php
@ -5,211 +5,27 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
use PhpMyAdmin\Relation;
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Controllers\Database\DataDictionaryController;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Gets the variables sent or posted to this script, then displays headers
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
if (! isset($selected_tbl)) {
|
||||
include 'libraries/db_common.inc.php';
|
||||
list(
|
||||
$tables,
|
||||
$num_tables,
|
||||
$total_num_tables,
|
||||
$sub_part,
|
||||
$is_show_stats,
|
||||
$db_is_system_schema,
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = PhpMyAdmin\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
Util::checkParameters(['db']);
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DataDictionaryController $controller */
|
||||
$controller = $containerBuilder->get(DataDictionaryController::class);
|
||||
|
||||
$header = $response->getHeader();
|
||||
$header->enablePrintView();
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
/**
|
||||
* Gets the relations settings
|
||||
*/
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
/**
|
||||
* Check parameters
|
||||
*/
|
||||
PhpMyAdmin\Util::checkParameters(array('db'));
|
||||
|
||||
/**
|
||||
* Defines the url to return to in case of error in a sql statement
|
||||
*/
|
||||
$err_url = 'db_sql.php' . Url::getCommon(array('db' => $db));
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$comment = $relation->getDbComment($db);
|
||||
|
||||
/**
|
||||
* Displays DB comment
|
||||
*/
|
||||
if ($comment) {
|
||||
echo '<p>' , __('Database comment')
|
||||
, '<br /><i>' , htmlspecialchars($comment) , '</i></p>';
|
||||
} // end if
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the database and gets tables names
|
||||
*/
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$tables = $GLOBALS['dbi']->getTables($db);
|
||||
|
||||
$count = 0;
|
||||
foreach ($tables as $table) {
|
||||
$comments = $relation->getComments($db, $table);
|
||||
|
||||
echo '<div>' , "\n";
|
||||
|
||||
echo '<h2>' , htmlspecialchars($table) , '</h2>' , "\n";
|
||||
|
||||
/**
|
||||
* Gets table information
|
||||
*/
|
||||
$show_comment = $GLOBALS['dbi']->getTable($db, $table)
|
||||
->getStatusInfo('TABLE_COMMENT');
|
||||
|
||||
/**
|
||||
* Gets table keys and retains them
|
||||
*/
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
|
||||
list($primary, $pk_array, $indexes_info, $indexes_data)
|
||||
= PhpMyAdmin\Util::processIndexData($indexes);
|
||||
|
||||
/**
|
||||
* Gets columns properties
|
||||
*/
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
|
||||
// Check if we can use Relations
|
||||
list($res_rel, $have_rel) = $relation->getRelationsAndStatus(
|
||||
! empty($cfgRelation['relation']), $db, $table
|
||||
);
|
||||
|
||||
/**
|
||||
* Displays the comments of the table if MySQL >= 3.23
|
||||
*/
|
||||
if (!empty($show_comment)) {
|
||||
echo __('Table comments:') , ' ';
|
||||
echo htmlspecialchars($show_comment) , '<br /><br />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the table structure
|
||||
*/
|
||||
|
||||
echo '<table width="100%" class="print">';
|
||||
echo '<tr><th width="50">' , __('Column') , '</th>';
|
||||
echo '<th width="80">' , __('Type') , '</th>';
|
||||
echo '<th width="40">' , __('Null') , '</th>';
|
||||
echo '<th width="70">' , __('Default') , '</th>';
|
||||
if ($have_rel) {
|
||||
echo ' <th>' , __('Links to') , '</th>' , "\n";
|
||||
}
|
||||
echo ' <th>' , __('Comments') , '</th>' , "\n";
|
||||
if ($cfgRelation['mimework']) {
|
||||
echo ' <th>MIME</th>' , "\n";
|
||||
}
|
||||
echo '</tr>';
|
||||
foreach ($columns as $row) {
|
||||
|
||||
if ($row['Null'] == '') {
|
||||
$row['Null'] = 'NO';
|
||||
}
|
||||
$extracted_columnspec
|
||||
= PhpMyAdmin\Util::extractColumnSpec($row['Type']);
|
||||
|
||||
// reformat mysql query output
|
||||
// set or enum types: slashes single quotes inside options
|
||||
|
||||
$type = htmlspecialchars($extracted_columnspec['print_type']);
|
||||
$attribute = $extracted_columnspec['attribute'];
|
||||
if (! isset($row['Default'])) {
|
||||
if ($row['Null'] != 'NO') {
|
||||
$row['Default'] = '<i>NULL</i>';
|
||||
}
|
||||
} else {
|
||||
$row['Default'] = htmlspecialchars($row['Default']);
|
||||
}
|
||||
$column_name = $row['Field'];
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td class="nowrap">';
|
||||
echo htmlspecialchars($column_name);
|
||||
|
||||
if (isset($pk_array[$row['Field']])) {
|
||||
echo ' <em>(' , __('Primary') , ')</em>';
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td'
|
||||
, PhpMyAdmin\Util::getClassForType(
|
||||
$extracted_columnspec['type']
|
||||
)
|
||||
, ' lang="en" dir="ltr">' , $type , '</td>';
|
||||
|
||||
echo '<td>';
|
||||
echo (($row['Null'] == 'NO') ? __('No') : __('Yes'));
|
||||
echo '</td>';
|
||||
echo '<td class="nowrap">';
|
||||
if (isset($row['Default'])) {
|
||||
echo $row['Default'];
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
if ($have_rel) {
|
||||
echo ' <td>';
|
||||
if ($foreigner = $relation->searchColumnInForeigners($res_rel, $column_name)) {
|
||||
echo htmlspecialchars(
|
||||
$foreigner['foreign_table']
|
||||
. ' -> '
|
||||
. $foreigner['foreign_field']
|
||||
);
|
||||
}
|
||||
echo '</td>' , "\n";
|
||||
}
|
||||
echo ' <td>';
|
||||
if (isset($comments[$column_name])) {
|
||||
echo htmlspecialchars($comments[$column_name]);
|
||||
}
|
||||
echo '</td>' , "\n";
|
||||
if ($cfgRelation['mimework']) {
|
||||
$mime_map = Transformations::getMIME($db, $table, true);
|
||||
|
||||
echo ' <td>';
|
||||
if (isset($mime_map[$column_name])) {
|
||||
echo htmlspecialchars(
|
||||
str_replace('_', '/', $mime_map[$column_name]['mimetype'])
|
||||
);
|
||||
}
|
||||
echo '</td>' , "\n";
|
||||
}
|
||||
echo '</tr>';
|
||||
} // end foreach
|
||||
$count++;
|
||||
echo '</table>';
|
||||
// display indexes information
|
||||
if (count(PhpMyAdmin\Index::getFromTable($table, $db)) > 0) {
|
||||
echo PhpMyAdmin\Index::getHtmlForIndexes($table, $db, true);
|
||||
}
|
||||
echo '</div>';
|
||||
} //ends main while
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
*/
|
||||
echo PhpMyAdmin\Util::getButton();
|
||||
$response->addHTML($controller->index());
|
||||
|
||||
113
db_designer.php
113
db_designer.php
@ -5,19 +5,34 @@
|
||||
*
|
||||
* @package PhpMyAdmin-Designer
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Database\Designer;
|
||||
use PhpMyAdmin\Database\Designer\Common;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
global $db;
|
||||
|
||||
$databaseDesigner = new Designer();
|
||||
$designerCommon = new Common();
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var Designer $databaseDesigner */
|
||||
$databaseDesigner = $containerBuilder->get('designer');
|
||||
|
||||
/** @var Common $designerCommon */
|
||||
$designerCommon = $containerBuilder->get('designer_common');
|
||||
|
||||
if (isset($_POST['dialog'])) {
|
||||
|
||||
if ($_POST['dialog'] == 'edit') {
|
||||
$html = $databaseDesigner->getHtmlForEditOrDeletePages($_POST['db'], 'editPage');
|
||||
} elseif ($_POST['dialog'] == 'delete') {
|
||||
@ -26,7 +41,8 @@ if (isset($_POST['dialog'])) {
|
||||
$html = $databaseDesigner->getHtmlForPageSaveAs($_POST['db']);
|
||||
} elseif ($_POST['dialog'] == 'export') {
|
||||
$html = $databaseDesigner->getHtmlForSchemaExport(
|
||||
$_POST['db'], $_POST['selected_page']
|
||||
$_POST['db'],
|
||||
$_POST['selected_page']
|
||||
);
|
||||
} elseif ($_POST['dialog'] == 'add_table') {
|
||||
// Pass the db and table to the getTablesInfo so we only have the table we asked for
|
||||
@ -38,8 +54,11 @@ if (isset($_POST['dialog'])) {
|
||||
$html = $databaseDesigner->getDatabaseTables(
|
||||
$_POST['db'],
|
||||
$script_display_field,
|
||||
array(), -1, $tab_column,
|
||||
$tables_all_keys, $tables_pk_or_unique_keys
|
||||
[],
|
||||
-1,
|
||||
$tab_column,
|
||||
$tables_all_keys,
|
||||
$tables_pk_or_unique_keys
|
||||
);
|
||||
}
|
||||
|
||||
@ -50,7 +69,6 @@ if (isset($_POST['dialog'])) {
|
||||
}
|
||||
|
||||
if (isset($_POST['operation'])) {
|
||||
|
||||
if ($_POST['operation'] == 'deletePage') {
|
||||
$success = $designerCommon->deletePage($_POST['selected_page']);
|
||||
$response->setRequestStatus($success);
|
||||
@ -64,10 +82,10 @@ if (isset($_POST['operation'])) {
|
||||
$success = $designerCommon->saveTablePositions($page);
|
||||
$response->setRequestStatus($success);
|
||||
} elseif ($_POST['operation'] == 'setDisplayField') {
|
||||
list(
|
||||
[
|
||||
$success,
|
||||
$message,
|
||||
) = $designerCommon->saveDisplayField(
|
||||
] = $designerCommon->saveDisplayField(
|
||||
$_POST['db'],
|
||||
$_POST['table'],
|
||||
$_POST['field']
|
||||
@ -105,7 +123,7 @@ if (isset($_POST['operation'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
require ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
$script_display_field = $designerCommon->getTablesInfo();
|
||||
|
||||
@ -114,12 +132,10 @@ $selected_page = null;
|
||||
|
||||
if (isset($_GET['query'])) {
|
||||
$display_page = $designerCommon->getDefaultPage($_GET['db']);
|
||||
} elseif (! empty($_GET['page'])) {
|
||||
$display_page = $_GET['page'];
|
||||
} else {
|
||||
if (! empty($_GET['page'])) {
|
||||
$display_page = $_GET['page'];
|
||||
} else {
|
||||
$display_page = $designerCommon->getLoadingPage($_GET['db']);
|
||||
}
|
||||
$display_page = $designerCommon->getLoadingPage($_GET['db']);
|
||||
}
|
||||
if ($display_page != -1) {
|
||||
$selected_page = $designerCommon->getPageName($display_page);
|
||||
@ -128,13 +144,13 @@ $tab_pos = $designerCommon->getTablePositions($display_page);
|
||||
|
||||
$fullTableNames = [];
|
||||
|
||||
foreach($script_display_field as $designerTable) {
|
||||
foreach ($script_display_field as $designerTable) {
|
||||
$fullTableNames[] = $designerTable->getDbTableString();
|
||||
}
|
||||
|
||||
foreach($tab_pos as $position) {
|
||||
foreach ($tab_pos as $position) {
|
||||
if (! in_array($position['dbName'] . '.' . $position['tableName'], $fullTableNames)) {
|
||||
foreach($designerCommon->getTablesInfo($position['dbName'], $position['tableName']) as $designerTable) {
|
||||
foreach ($designerCommon->getTablesInfo($position['dbName'], $position['tableName']) as $designerTable) {
|
||||
$script_display_field[] = $designerTable;
|
||||
}
|
||||
}
|
||||
@ -150,7 +166,7 @@ $classes_side_menu = $databaseDesigner->returnClassNamesFromMenuButtons();
|
||||
|
||||
$script_contr = $designerCommon->getScriptContr($script_display_field);
|
||||
|
||||
$params = array('lang' => $GLOBALS['lang']);
|
||||
$params = ['lang' => $GLOBALS['lang']];
|
||||
if (isset($_GET['db'])) {
|
||||
$params['db'] = $_GET['db'];
|
||||
}
|
||||
@ -184,51 +200,22 @@ list(
|
||||
// Embed some data into HTML, later it will be read
|
||||
// by designer/init.js and converted to JS variables.
|
||||
$response->addHTML(
|
||||
$databaseDesigner->getHtmlForJsFields(
|
||||
$script_tables, $script_contr, $script_display_field, $display_page
|
||||
)
|
||||
);
|
||||
$response->addHTML(
|
||||
$databaseDesigner->getPageMenu(
|
||||
isset($_GET['query']),
|
||||
$selected_page,
|
||||
$classes_side_menu
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
$response->addHTML('<div id="canvas_outer">');
|
||||
$response->addHTML(
|
||||
'<form action="" id="container-form" method="post">'
|
||||
);
|
||||
|
||||
$response->addHTML($databaseDesigner->getHtmlCanvas());
|
||||
$response->addHTML($databaseDesigner->getHtmlTableList());
|
||||
|
||||
$response->addHTML(
|
||||
$databaseDesigner->getDatabaseTables(
|
||||
$databaseDesigner->getHtmlForMain(
|
||||
$db,
|
||||
$_GET['db'],
|
||||
$script_display_field,
|
||||
$tab_pos, $display_page, $tab_column,
|
||||
$tables_all_keys, $tables_pk_or_unique_keys
|
||||
$script_tables,
|
||||
$script_contr,
|
||||
$script_display_field,
|
||||
$display_page,
|
||||
isset($_GET['query']),
|
||||
$selected_page,
|
||||
$classes_side_menu,
|
||||
$tab_pos,
|
||||
$tab_column,
|
||||
$tables_all_keys,
|
||||
$tables_pk_or_unique_keys
|
||||
)
|
||||
);
|
||||
$response->addHTML('</form>');
|
||||
$response->addHTML('</div>'); // end canvas_outer
|
||||
|
||||
$response->addHTML('<div id="designer_hint"></div>');
|
||||
|
||||
$response->addHTML($databaseDesigner->getNewRelationPanel());
|
||||
$response->addHTML($databaseDesigner->getDeleteRelationPanel());
|
||||
|
||||
if (isset($_GET['query'])) {
|
||||
$response->addHTML($databaseDesigner->getOptionsPanel());
|
||||
$response->addHTML($databaseDesigner->getRenameToPanel());
|
||||
$response->addHTML($databaseDesigner->getHavingQueryPanel());
|
||||
$response->addHTML($databaseDesigner->getAggregateQueryPanel());
|
||||
$response->addHTML($databaseDesigner->getWhereQueryPanel());
|
||||
$response->addHTML($databaseDesigner->getQueryDetails($_GET['db']));
|
||||
}
|
||||
|
||||
$response->addHTML('<div id="PMA_disable_floating_menubar"></div>');
|
||||
|
||||
@ -5,14 +5,76 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Include required files
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
use PhpMyAdmin\Controllers\Database\EventsController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/**
|
||||
* Do the magic
|
||||
*/
|
||||
$_PMA_RTE = 'EVN';
|
||||
require_once 'libraries/rte/rte_main.inc.php';
|
||||
|
||||
/** @var EventsController $controller */
|
||||
$controller = $containerBuilder->get(EventsController::class);
|
||||
|
||||
/** @var string $db */
|
||||
$db = $containerBuilder->getParameter('db');
|
||||
|
||||
/** @var string $table */
|
||||
$table = $containerBuilder->getParameter('table');
|
||||
|
||||
if (! $response->isAjax()) {
|
||||
/**
|
||||
* Displays the header and tabs
|
||||
*/
|
||||
if (! empty($table) && in_array($table, $dbi->getTables($db))) {
|
||||
include_once ROOT_PATH . 'libraries/tbl_common.inc.php';
|
||||
} else {
|
||||
$table = '';
|
||||
include_once ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
list(
|
||||
$tables,
|
||||
$num_tables,
|
||||
$total_num_tables,
|
||||
$sub_part,
|
||||
$is_show_stats,
|
||||
$db_is_system_schema,
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Since we did not include some libraries, we need
|
||||
* to manually select the required database and
|
||||
* create the missing $url_query variable
|
||||
*/
|
||||
if (strlen($db) > 0) {
|
||||
$dbi->selectDb($db);
|
||||
if (! isset($url_query)) {
|
||||
$url_query = Url::getCommon(
|
||||
[
|
||||
'db' => $db,
|
||||
'table' => $table,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$controller->index();
|
||||
|
||||
@ -5,29 +5,43 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Display\Export as DisplayExport;
|
||||
use PhpMyAdmin\Export;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Gets some core libraries
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
global $db, $table, $url_query, $containerBuilder;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
PageSettings::showGroup('Export');
|
||||
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('export.js');
|
||||
|
||||
/** @var Export $export */
|
||||
$export = $containerBuilder->get('export');
|
||||
|
||||
// $sub_part is used in Util::getDbInfo() to see if we are coming from
|
||||
// db_export.php, in which case we don't obey $cfg['MaxTableList']
|
||||
$sub_part = '_export';
|
||||
require_once 'libraries/db_common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
$url_query .= '&goto=db_export.php';
|
||||
|
||||
list(
|
||||
@ -40,7 +54,7 @@ list(
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
) = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
|
||||
|
||||
/**
|
||||
* Displays the form
|
||||
@ -72,40 +86,44 @@ $multi_values .= '<table class="export_table_select">'
|
||||
. '<td></td>'
|
||||
. '<td class="export_table_name all">' . __('Select all') . '</td>'
|
||||
. '<td class="export_structure all">'
|
||||
. '<input type="checkbox" id="table_structure_all" /></td>'
|
||||
. '<td class="export_data all"><input type="checkbox" id="table_data_all" />'
|
||||
. '<input type="checkbox" id="table_structure_all"></td>'
|
||||
. '<td class="export_data all"><input type="checkbox" id="table_data_all">'
|
||||
. '</td>'
|
||||
. '</tr></thead>'
|
||||
. '<tbody>';
|
||||
$multi_values .= "\n";
|
||||
|
||||
// when called by libraries/mult_submits.inc.php
|
||||
if (!empty($_POST['selected_tbl']) && empty($table_select)) {
|
||||
if (! empty($_POST['selected_tbl']) && empty($table_select)) {
|
||||
$table_select = $_POST['selected_tbl'];
|
||||
}
|
||||
|
||||
foreach ($tables as $each_table) {
|
||||
if (isset($_POST['table_select']) && is_array($_POST['table_select'])) {
|
||||
$is_checked = Export::getCheckedClause(
|
||||
$each_table['Name'], $_POST['table_select']
|
||||
$is_checked = $export->getCheckedClause(
|
||||
$each_table['Name'],
|
||||
$_POST['table_select']
|
||||
);
|
||||
} elseif (isset($table_select)) {
|
||||
$is_checked = Export::getCheckedClause(
|
||||
$each_table['Name'], $table_select
|
||||
$is_checked = $export->getCheckedClause(
|
||||
$each_table['Name'],
|
||||
$table_select
|
||||
);
|
||||
} else {
|
||||
$is_checked = ' checked="checked"';
|
||||
}
|
||||
if (isset($_POST['table_structure']) && is_array($_POST['table_structure'])) {
|
||||
$structure_checked = Export::getCheckedClause(
|
||||
$each_table['Name'], $_POST['table_structure']
|
||||
$structure_checked = $export->getCheckedClause(
|
||||
$each_table['Name'],
|
||||
$_POST['table_structure']
|
||||
);
|
||||
} else {
|
||||
$structure_checked = $is_checked;
|
||||
}
|
||||
if (isset($_POST['table_data']) && is_array($_POST['table_data'])) {
|
||||
$data_checked = Export::getCheckedClause(
|
||||
$each_table['Name'], $_POST['table_data']
|
||||
$data_checked = $export->getCheckedClause(
|
||||
$each_table['Name'],
|
||||
$_POST['table_data']
|
||||
);
|
||||
} else {
|
||||
$data_checked = $is_checked;
|
||||
@ -113,15 +131,15 @@ foreach ($tables as $each_table) {
|
||||
$table_html = htmlspecialchars($each_table['Name']);
|
||||
$multi_values .= '<tr class="marked">';
|
||||
$multi_values .= '<td><input type="checkbox" name="table_select[]"'
|
||||
. ' value="' . $table_html . '"' . $is_checked . ' class="checkall"/></td>';
|
||||
. ' value="' . $table_html . '"' . $is_checked . ' class="checkall"></td>';
|
||||
$multi_values .= '<td class="export_table_name">'
|
||||
. str_replace(' ', ' ', $table_html) . '</td>';
|
||||
$multi_values .= '<td class="export_structure">'
|
||||
. '<input type="checkbox" name="table_structure[]"'
|
||||
. ' value="' . $table_html . '"' . $structure_checked . ' /></td>';
|
||||
. ' value="' . $table_html . '"' . $structure_checked . '></td>';
|
||||
$multi_values .= '<td class="export_data">'
|
||||
. '<input type="checkbox" name="table_data[]"'
|
||||
. ' value="' . $table_html . '"' . $data_checked . ' /></td>';
|
||||
. ' value="' . $table_html . '"' . $data_checked . '></td>';
|
||||
$multi_values .= '</tr>';
|
||||
} // end for
|
||||
|
||||
@ -137,14 +155,19 @@ if (! isset($num_tables)) {
|
||||
if (! isset($unlim_num_rows)) {
|
||||
$unlim_num_rows = 0;
|
||||
}
|
||||
if (! isset($multi_values)) {
|
||||
if ($multi_values === null) {
|
||||
$multi_values = '';
|
||||
}
|
||||
$response = Response::getInstance();
|
||||
$displayExport = new DisplayExport();
|
||||
$response->addHTML(
|
||||
$displayExport->getDisplay(
|
||||
'database', $db, $table, $sql_query, $num_tables,
|
||||
$unlim_num_rows, $multi_values
|
||||
'database',
|
||||
$db,
|
||||
$table,
|
||||
$sql_query,
|
||||
$num_tables,
|
||||
$unlim_num_rows,
|
||||
$multi_values
|
||||
)
|
||||
);
|
||||
|
||||
@ -5,12 +5,19 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Display\Import;
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
global $db, $table;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
PageSettings::showGroup('Import');
|
||||
|
||||
@ -19,10 +26,12 @@ $header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('import.js');
|
||||
|
||||
$import = new Import();
|
||||
|
||||
/**
|
||||
* Gets tables information and displays top links
|
||||
*/
|
||||
require 'libraries/db_common.inc.php';
|
||||
require ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
list(
|
||||
$tables,
|
||||
@ -38,7 +47,10 @@ list(
|
||||
|
||||
$response = Response::getInstance();
|
||||
$response->addHTML(
|
||||
Import::get(
|
||||
'database', $db, $table, $max_upload_size
|
||||
$import->get(
|
||||
'database',
|
||||
$db,
|
||||
$table,
|
||||
$max_upload_size
|
||||
)
|
||||
);
|
||||
|
||||
@ -5,34 +5,47 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
use PhpMyAdmin\Database\MultiTableQuery;
|
||||
use PhpMyAdmin\Response;
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
use PhpMyAdmin\Controllers\Database\MultiTableQueryController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Template;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var MultiTableQueryController $controller */
|
||||
$controller = $containerBuilder->get(MultiTableQueryController::class);
|
||||
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
|
||||
if (isset($_POST['sql_query'])) {
|
||||
MultiTableQuery::displayResults(
|
||||
$_POST['sql_query'],
|
||||
$_REQUEST['db'],
|
||||
$pmaThemeImage
|
||||
);
|
||||
} if (isset($_GET['tables'])) {
|
||||
$constrains = $GLOBALS['dbi']->getForeignKeyConstrains(
|
||||
$_REQUEST['db'],
|
||||
$_GET['tables']
|
||||
);
|
||||
$response = Response::getInstance();
|
||||
$response->addJSON('foreignKeyConstrains',$constrains);
|
||||
$controller->displayResults([
|
||||
'sql_query' => $_POST['sql_query'],
|
||||
'db' => $_REQUEST['db'] ?? null,
|
||||
]);
|
||||
} elseif (isset($_GET['tables'])) {
|
||||
$response->addJSON($controller->table([
|
||||
'tables' => $_GET['tables'],
|
||||
'db' => $_REQUEST['db'] ?? null,
|
||||
]));
|
||||
} else {
|
||||
$response = Response::getInstance();
|
||||
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('vendor/jquery/jquery.md5.js');
|
||||
$scripts->addFile('db_multi_table_query.js');
|
||||
$scripts->addFile('db_query_generator.js');
|
||||
$scripts->addFile('database/multi_table_query.js');
|
||||
$scripts->addFile('database/query_generator.js');
|
||||
|
||||
$queryInstance = new MultiTableQuery($GLOBALS['dbi'], $db);
|
||||
|
||||
$response->addHTML($queryInstance->getFormHtml());
|
||||
$response->addHTML($controller->index($template));
|
||||
}
|
||||
|
||||
@ -11,6 +11,9 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Display\CreateTable;
|
||||
use PhpMyAdmin\Message;
|
||||
@ -22,30 +25,38 @@ use PhpMyAdmin\RelationCleanup;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* requirements
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* functions implementation for this script
|
||||
*/
|
||||
require_once 'libraries/check_user_privileges.inc.php';
|
||||
global $cfg, $db, $server, $url_query;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
$checkUserPrivileges = new CheckUserPrivileges($dbi);
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
// add a javascript file for jQuery functions to handle Ajax actions
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('db_operations.js');
|
||||
$scripts->addFile('database/operations.js');
|
||||
|
||||
$sql_query = '';
|
||||
|
||||
$operations = new Operations();
|
||||
/** @var Relation $relation */
|
||||
$relation = $containerBuilder->get('relation');
|
||||
$operations = new Operations($dbi, $relation);
|
||||
$relationCleanup = new RelationCleanup($dbi, $relation);
|
||||
|
||||
/**
|
||||
* Rename/move or copy database
|
||||
*/
|
||||
if (strlen($GLOBALS['db']) > 0
|
||||
if (strlen($db) > 0
|
||||
&& (! empty($_POST['db_rename']) || ! empty($_POST['db_copy']))
|
||||
) {
|
||||
if (! empty($_POST['db_rename'])) {
|
||||
@ -58,7 +69,7 @@ if (strlen($GLOBALS['db']) > 0
|
||||
$message = Message::error(__('The database name is empty!'));
|
||||
} else {
|
||||
// lower_case_table_names=1 `DB` becomes `db`
|
||||
if ($GLOBALS['dbi']->getLowerCaseNames() === '1') {
|
||||
if ($dbi->getLowerCaseNames() === '1') {
|
||||
$_POST['newname'] = mb_strtolower(
|
||||
$_POST['newname']
|
||||
);
|
||||
@ -80,38 +91,42 @@ if (strlen($GLOBALS['db']) > 0
|
||||
// to avoid selecting alternatively the current and new db
|
||||
// we would need to modify the CREATE definitions to qualify
|
||||
// the db name
|
||||
$operations->runProcedureAndFunctionDefinitions($GLOBALS['db']);
|
||||
$operations->runProcedureAndFunctionDefinitions($db);
|
||||
|
||||
// go back to current db, just in case
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$dbi->selectDb($db);
|
||||
|
||||
$tables_full = $GLOBALS['dbi']->getTablesFull($GLOBALS['db']);
|
||||
$tables_full = $dbi->getTablesFull($db);
|
||||
|
||||
// remove all foreign key constraints, otherwise we can get errors
|
||||
/* @var $export_sql_plugin ExportSql */
|
||||
/** @var ExportSql $export_sql_plugin */
|
||||
$export_sql_plugin = Plugins::getPlugin(
|
||||
"export",
|
||||
"sql",
|
||||
'libraries/classes/Plugins/Export/',
|
||||
array(
|
||||
[
|
||||
'single_table' => isset($single_table),
|
||||
'export_type' => 'database'
|
||||
)
|
||||
'export_type' => 'database',
|
||||
]
|
||||
);
|
||||
|
||||
// create stand-in tables for views
|
||||
$views = $operations->getViewsAndCreateSqlViewStandIn(
|
||||
$tables_full, $export_sql_plugin, $GLOBALS['db']
|
||||
$tables_full,
|
||||
$export_sql_plugin,
|
||||
$db
|
||||
);
|
||||
|
||||
// copy tables
|
||||
$sqlConstratints = $operations->copyTables(
|
||||
$tables_full, $move, $GLOBALS['db']
|
||||
$tables_full,
|
||||
$move,
|
||||
$db
|
||||
);
|
||||
|
||||
// handle the views
|
||||
if (! $_error) {
|
||||
$operations->handleTheViews($views, $move, $GLOBALS['db']);
|
||||
$operations->handleTheViews($views, $move, $db);
|
||||
}
|
||||
unset($views);
|
||||
|
||||
@ -121,53 +136,53 @@ if (strlen($GLOBALS['db']) > 0
|
||||
}
|
||||
unset($sqlConstratints);
|
||||
|
||||
if ($GLOBALS['dbi']->getVersion() >= 50100) {
|
||||
if ($dbi->getVersion() >= 50100) {
|
||||
// here DELIMITER is not used because it's not part of the
|
||||
// language; each statement is sent one by one
|
||||
|
||||
$operations->runEventDefinitionsForDb($GLOBALS['db']);
|
||||
$operations->runEventDefinitionsForDb($db);
|
||||
}
|
||||
|
||||
// go back to current db, just in case
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$dbi->selectDb($db);
|
||||
|
||||
// Duplicate the bookmarks for this db (done once for each db)
|
||||
$operations->duplicateBookmarks($_error, $GLOBALS['db']);
|
||||
$operations->duplicateBookmarks($_error, $db);
|
||||
|
||||
if (! $_error && $move) {
|
||||
if (isset($_POST['adjust_privileges'])
|
||||
&& ! empty($_POST['adjust_privileges'])
|
||||
) {
|
||||
$operations->adjustPrivilegesMoveDb($GLOBALS['db'], $_POST['newname']);
|
||||
$operations->adjustPrivilegesMoveDb($db, $_POST['newname']);
|
||||
}
|
||||
|
||||
/**
|
||||
* cleanup pmadb stuff for this db
|
||||
*/
|
||||
RelationCleanup::database($GLOBALS['db']);
|
||||
$relationCleanup->database($db);
|
||||
|
||||
// if someday the RENAME DATABASE reappears, do not DROP
|
||||
$local_query = 'DROP DATABASE '
|
||||
. Util::backquote($GLOBALS['db']) . ';';
|
||||
. Util::backquote($db) . ';';
|
||||
$sql_query .= "\n" . $local_query;
|
||||
$GLOBALS['dbi']->query($local_query);
|
||||
$dbi->query($local_query);
|
||||
|
||||
$message = Message::success(
|
||||
__('Database %1$s has been renamed to %2$s.')
|
||||
);
|
||||
$message->addParam($GLOBALS['db']);
|
||||
$message->addParam($db);
|
||||
$message->addParam($_POST['newname']);
|
||||
} elseif (! $_error) {
|
||||
if (isset($_POST['adjust_privileges'])
|
||||
&& ! empty($_POST['adjust_privileges'])
|
||||
) {
|
||||
$operations->adjustPrivilegesCopyDb($GLOBALS['db'], $_POST['newname']);
|
||||
$operations->adjustPrivilegesCopyDb($db, $_POST['newname']);
|
||||
}
|
||||
|
||||
$message = Message::success(
|
||||
__('Database %1$s has been copied to %2$s.')
|
||||
);
|
||||
$message->addParam($GLOBALS['db']);
|
||||
$message->addParam($db);
|
||||
$message->addParam($_POST['newname']);
|
||||
} else {
|
||||
$message = Message::error();
|
||||
@ -176,13 +191,13 @@ if (strlen($GLOBALS['db']) > 0
|
||||
|
||||
/* Change database to be used */
|
||||
if (! $_error && $move) {
|
||||
$GLOBALS['db'] = $_POST['newname'];
|
||||
$db = $_POST['newname'];
|
||||
} elseif (! $_error) {
|
||||
if (isset($_POST['switch_to_new'])
|
||||
&& $_POST['switch_to_new'] == 'true'
|
||||
) {
|
||||
$_SESSION['pma_switch_to_new'] = true;
|
||||
$GLOBALS['db'] = $_POST['newname'];
|
||||
$db = $_POST['newname'];
|
||||
} else {
|
||||
$_SESSION['pma_switch_to_new'] = false;
|
||||
}
|
||||
@ -202,7 +217,7 @@ if (strlen($GLOBALS['db']) > 0
|
||||
'sql_query',
|
||||
Util::getMessage(null, $sql_query)
|
||||
);
|
||||
$response->addJSON('db', $GLOBALS['db']);
|
||||
$response->addJSON('db', $db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -210,8 +225,6 @@ if (strlen($GLOBALS['db']) > 0
|
||||
/**
|
||||
* Settings for relations stuff
|
||||
*/
|
||||
$relation = new Relation();
|
||||
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
/**
|
||||
@ -219,10 +232,10 @@ $cfgRelation = $relation->getRelationsParam();
|
||||
* (must be done before displaying the menu tabs)
|
||||
*/
|
||||
if (isset($_POST['comment'])) {
|
||||
$relation->setDbComment($GLOBALS['db'], $_POST['comment']);
|
||||
$relation->setDbComment($db, $_POST['comment']);
|
||||
}
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
require ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
$url_query .= '&goto=db_operations.php';
|
||||
|
||||
// Gets the database structure
|
||||
@ -238,7 +251,7 @@ list(
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
) = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
|
||||
|
||||
echo "\n";
|
||||
|
||||
@ -247,15 +260,15 @@ if (isset($message)) {
|
||||
unset($message);
|
||||
}
|
||||
|
||||
$db_collation = $GLOBALS['dbi']->getDbCollation($GLOBALS['db']);
|
||||
$is_information_schema = $GLOBALS['dbi']->isSystemSchema($GLOBALS['db']);
|
||||
$db_collation = $dbi->getDbCollation($db);
|
||||
$is_information_schema = $dbi->isSystemSchema($db);
|
||||
|
||||
if (!$is_information_schema) {
|
||||
if (! $is_information_schema) {
|
||||
if ($cfgRelation['commwork']) {
|
||||
/**
|
||||
* database comment
|
||||
*/
|
||||
$response->addHTML($operations->getHtmlForDatabaseComment($GLOBALS['db']));
|
||||
$response->addHTML($operations->getHtmlForDatabaseComment($db));
|
||||
}
|
||||
|
||||
$response->addHTML('<div>');
|
||||
@ -265,29 +278,29 @@ if (!$is_information_schema) {
|
||||
/**
|
||||
* rename database
|
||||
*/
|
||||
if ($GLOBALS['db'] != 'mysql') {
|
||||
$response->addHTML($operations->getHtmlForRenameDatabase($GLOBALS['db'], $db_collation));
|
||||
if ($db != 'mysql') {
|
||||
$response->addHTML($operations->getHtmlForRenameDatabase($db, $db_collation));
|
||||
}
|
||||
|
||||
// Drop link if allowed
|
||||
// Don't even try to drop information_schema.
|
||||
// You won't be able to. Believe me. You won't.
|
||||
// Don't allow to easily drop mysql database, RFE #1327514.
|
||||
if (($GLOBALS['dbi']->isSuperuser() || $GLOBALS['cfg']['AllowUserDropDatabase'])
|
||||
if (($dbi->isSuperuser() || $cfg['AllowUserDropDatabase'])
|
||||
&& ! $db_is_system_schema
|
||||
&& $GLOBALS['db'] != 'mysql'
|
||||
&& $db != 'mysql'
|
||||
) {
|
||||
$response->addHTML($operations->getHtmlForDropDatabaseLink($GLOBALS['db']));
|
||||
$response->addHTML($operations->getHtmlForDropDatabaseLink($db));
|
||||
}
|
||||
/**
|
||||
* Copy database
|
||||
*/
|
||||
$response->addHTML($operations->getHtmlForCopyDatabase($GLOBALS['db'], $db_collation));
|
||||
$response->addHTML($operations->getHtmlForCopyDatabase($db, $db_collation));
|
||||
|
||||
/**
|
||||
* Change database charset
|
||||
*/
|
||||
$response->addHTML($operations->getHtmlForChangeDatabaseCharset($GLOBALS['db'], $db_collation));
|
||||
$response->addHTML($operations->getHtmlForChangeDatabaseCharset($db, $db_collation));
|
||||
|
||||
if (! $cfgRelation['allworks']
|
||||
&& $cfg['PmaNoRelation_DisableWarning'] == false
|
||||
@ -301,7 +314,7 @@ if (!$is_information_schema) {
|
||||
$message->addParamHtml('<a href="./chk_rel.php" data-post="' . $url_query . '">');
|
||||
$message->addParamHtml('</a>');
|
||||
/* Show error if user has configured something, notice elsewhere */
|
||||
if (!empty($cfg['Servers'][$server]['pmadb'])) {
|
||||
if (! empty($cfg['Servers'][$server]['pmadb'])) {
|
||||
$message->isError(true);
|
||||
}
|
||||
} // end if
|
||||
|
||||
60
db_qbe.php
60
db_qbe.php
@ -5,7 +5,10 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Database\Qbe;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Response;
|
||||
@ -15,31 +18,42 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* requirements
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
$relation = new Relation();
|
||||
global $db, $pmaThemeImage, $url_query;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var Relation $relation */
|
||||
$relation = $containerBuilder->get('relation');
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
|
||||
// Gets the relation settings
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
$savedSearchList = array();
|
||||
$savedSearchList = [];
|
||||
$savedSearch = null;
|
||||
$currentSearchId = null;
|
||||
if ($cfgRelation['savedsearcheswork']) {
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('db_qbe.js');
|
||||
$scripts->addFile('database/qbe.js');
|
||||
|
||||
//Get saved search list.
|
||||
$savedSearch = new SavedSearches($GLOBALS);
|
||||
$savedSearch = new SavedSearches($GLOBALS, $relation);
|
||||
$savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])
|
||||
->setDbname($GLOBALS['db']);
|
||||
->setDbname($db);
|
||||
|
||||
if (!empty($_POST['searchId'])) {
|
||||
if (! empty($_POST['searchId'])) {
|
||||
$savedSearch->setId($_POST['searchId']);
|
||||
}
|
||||
|
||||
@ -56,17 +70,17 @@ if ($cfgRelation['savedsearcheswork']) {
|
||||
} elseif ('delete' === $_POST['action']) {
|
||||
$deleteResult = $savedSearch->delete();
|
||||
//After deletion, reset search.
|
||||
$savedSearch = new SavedSearches($GLOBALS);
|
||||
$savedSearch = new SavedSearches($GLOBALS, $relation);
|
||||
$savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])
|
||||
->setDbname($GLOBALS['db']);
|
||||
$_POST = array();
|
||||
->setDbname($db);
|
||||
$_POST = [];
|
||||
} elseif ('load' === $_POST['action']) {
|
||||
if (empty($_POST['searchId'])) {
|
||||
//when not loading a search, reset the object.
|
||||
$savedSearch = new SavedSearches($GLOBALS);
|
||||
$savedSearch = new SavedSearches($GLOBALS, $relation);
|
||||
$savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])
|
||||
->setDbname($GLOBALS['db']);
|
||||
$_POST = array();
|
||||
->setDbname($db);
|
||||
$_POST = [];
|
||||
} else {
|
||||
$loadResult = $savedSearch->load();
|
||||
}
|
||||
@ -83,7 +97,7 @@ if ($cfgRelation['savedsearcheswork']) {
|
||||
*/
|
||||
$message_to_display = false;
|
||||
if (isset($_POST['submit_sql']) && ! empty($sql_query)) {
|
||||
if (! preg_match('@^SELECT@i', $sql_query)) {
|
||||
if (0 !== stripos($sql_query, "SELECT")) {
|
||||
$message_to_display = true;
|
||||
} else {
|
||||
$goto = 'db_sql.php';
|
||||
@ -112,7 +126,7 @@ if (isset($_POST['submit_sql']) && ! empty($sql_query)) {
|
||||
}
|
||||
|
||||
$sub_part = '_qbe';
|
||||
require 'libraries/db_common.inc.php';
|
||||
require ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
$url_query .= '&goto=db_qbe.php';
|
||||
$url_params['goto'] = 'db_qbe.php';
|
||||
|
||||
@ -126,7 +140,7 @@ list(
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
) = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
|
||||
|
||||
if ($message_to_display) {
|
||||
Message::error(
|
||||
@ -137,7 +151,7 @@ if ($message_to_display) {
|
||||
unset($message_to_display);
|
||||
|
||||
// create new qbe search instance
|
||||
$db_qbe = new Qbe($GLOBALS['db'], $savedSearchList, $savedSearch);
|
||||
$db_qbe = new Qbe($relation, $template, $dbi, $db, $savedSearchList, $savedSearch);
|
||||
|
||||
$secondaryTabs = [
|
||||
'multi' => [
|
||||
@ -150,7 +164,7 @@ $secondaryTabs = [
|
||||
],
|
||||
];
|
||||
$response->addHTML(
|
||||
Template::get('secondary_tabs')->render([
|
||||
$template->render('secondary_tabs', [
|
||||
'url_params' => $url_params,
|
||||
'sub_tabs' => $secondaryTabs,
|
||||
])
|
||||
@ -159,7 +173,7 @@ $response->addHTML(
|
||||
$url = 'db_designer.php' . Url::getCommon(
|
||||
array_merge(
|
||||
$url_params,
|
||||
array('query' => 1)
|
||||
['query' => 1]
|
||||
)
|
||||
);
|
||||
$response->addHTML(
|
||||
|
||||
@ -5,19 +5,83 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Include required files
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Controllers\Database\RoutinesController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
*/
|
||||
require_once 'libraries/check_user_privileges.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var string $db */
|
||||
$db = $containerBuilder->getParameter('db');
|
||||
|
||||
/** @var string $table */
|
||||
$table = $containerBuilder->getParameter('table');
|
||||
|
||||
/** @var CheckUserPrivileges $checkUserPrivileges */
|
||||
$checkUserPrivileges = $containerBuilder->get('check_user_privileges');
|
||||
$checkUserPrivileges->getPrivileges();
|
||||
|
||||
/**
|
||||
* Do the magic
|
||||
*/
|
||||
$_PMA_RTE = 'RTN';
|
||||
require_once 'libraries/rte/rte_main.inc.php';
|
||||
|
||||
/** @var RoutinesController $controller */
|
||||
$controller = $containerBuilder->get(RoutinesController::class);
|
||||
|
||||
if (! $response->isAjax()) {
|
||||
/**
|
||||
* Displays the header and tabs
|
||||
*/
|
||||
if (! empty($table) && in_array($table, $dbi->getTables($db))) {
|
||||
include_once ROOT_PATH . 'libraries/tbl_common.inc.php';
|
||||
} else {
|
||||
$table = '';
|
||||
include_once ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
list(
|
||||
$tables,
|
||||
$num_tables,
|
||||
$total_num_tables,
|
||||
$sub_part,
|
||||
$is_show_stats,
|
||||
$db_is_system_schema,
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Since we did not include some libraries, we need
|
||||
* to manually select the required database and
|
||||
* create the missing $url_query variable
|
||||
*/
|
||||
if (strlen($db) > 0) {
|
||||
$dbi->selectDb($db);
|
||||
if (! isset($url_query)) {
|
||||
$url_query = Url::getCommon(
|
||||
[
|
||||
'db' => $db,
|
||||
'table' => $table,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$controller->index([
|
||||
'type' => $_REQUEST['type'] ?? null,
|
||||
]);
|
||||
|
||||
@ -7,36 +7,53 @@
|
||||
* @todo display executed query, optional?
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Database\Search;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Gets some core libraries
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('db_search.js');
|
||||
global $db, $url_query;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('database/search.js');
|
||||
$scripts->addFile('sql.js');
|
||||
$scripts->addFile('makegrid.js');
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
require ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
// If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
|
||||
if (! $GLOBALS['cfg']['UseDbSearch']) {
|
||||
Util::mysqlDie(
|
||||
__('Access denied!'), '', false, $err_url
|
||||
__('Access denied!'),
|
||||
'',
|
||||
false,
|
||||
$err_url
|
||||
);
|
||||
} // end if
|
||||
$url_query .= '&goto=db_search.php';
|
||||
$url_params['goto'] = 'db_search.php';
|
||||
|
||||
// Create a database search instance
|
||||
$db_search = new Search($GLOBALS['db']);
|
||||
$db_search = new Search($dbi, $db, $template);
|
||||
|
||||
// Display top links if we are not in an Ajax request
|
||||
if (! $response->isAjax()) {
|
||||
@ -64,10 +81,4 @@ if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
|
||||
}
|
||||
|
||||
// Display the search form
|
||||
$response->addHTML($db_search->getSelectionForm());
|
||||
$response->addHTML('<div id="searchresults"></div>');
|
||||
$response->addHTML(
|
||||
'<div id="togglesearchresultsdiv"><a id="togglesearchresultlink"></a></div>'
|
||||
);
|
||||
$response->addHTML('<br class="clearfloat" />');
|
||||
$response->addHTML($db_search->getResultDivs());
|
||||
$response->addHTML($db_search->getMainHtml());
|
||||
|
||||
56
db_sql.php
56
db_sql.php
@ -5,42 +5,44 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Controllers\Database\SqlController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\SqlQueryForm;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
PageSettings::showGroup('Sql');
|
||||
global $containerBuilder;
|
||||
|
||||
/**
|
||||
* Runs common work
|
||||
*/
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var SqlController $controller */
|
||||
$controller = $containerBuilder->get(SqlController::class);
|
||||
|
||||
/** @var SqlQueryForm $sqlQueryForm */
|
||||
$sqlQueryForm = $containerBuilder->get('sql_query_form');
|
||||
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
|
||||
$scripts->addFile('sql.js');
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
|
||||
// After a syntax error, we return to this script
|
||||
// with the typed query in the textarea.
|
||||
$goto = 'db_sql.php';
|
||||
$back = 'db_sql.php';
|
||||
|
||||
/**
|
||||
* Query box, bookmark, insert data from textfile
|
||||
*/
|
||||
$response->addHTML(
|
||||
SqlQueryForm::getHtml(
|
||||
true, false,
|
||||
isset($_POST['delimiter'])
|
||||
? htmlspecialchars($_POST['delimiter'])
|
||||
: ';'
|
||||
$controller->index(
|
||||
[
|
||||
'delimiter' => $_POST['delimiter'] ?? null,
|
||||
],
|
||||
$sqlQueryForm
|
||||
)
|
||||
);
|
||||
|
||||
@ -5,23 +5,37 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
if ($GLOBALS['cfg']['EnableAutocompleteForTablesAndColumns']) {
|
||||
$db = isset($_POST['db']) ? $_POST['db'] : $GLOBALS['db'];
|
||||
$sql_autocomplete = array();
|
||||
$sql_autocomplete = [];
|
||||
if ($db) {
|
||||
$tableNames = $GLOBALS['dbi']->getTables($db);
|
||||
$tableNames = $dbi->getTables($db);
|
||||
foreach ($tableNames as $tableName) {
|
||||
$sql_autocomplete[$tableName] = $GLOBALS['dbi']->getColumns(
|
||||
$db, $tableName
|
||||
$sql_autocomplete[$tableName] = $dbi->getColumns(
|
||||
$db,
|
||||
$tableName
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql_autocomplete = true;
|
||||
}
|
||||
$response = Response::getInstance();
|
||||
|
||||
$response->addJSON("tables", json_encode($sql_autocomplete));
|
||||
|
||||
@ -5,15 +5,21 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loading common files. Used to check for authorization, localization and to
|
||||
* load the parsing library.
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
$query = !empty($_POST['sql']) ? $_POST['sql'] : '';
|
||||
$query = ! empty($_POST['sql']) ? $_POST['sql'] : '';
|
||||
|
||||
$query = PhpMyAdmin\SqlParser\Utils\Formatter::format($query);
|
||||
|
||||
|
||||
@ -5,34 +5,58 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Controllers\Database\DatabaseStructureController;
|
||||
use PhpMyAdmin\Di\Container;
|
||||
use PhpMyAdmin\Controllers\Database\StructureController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/db_common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
$container->factory(
|
||||
'PhpMyAdmin\Controllers\Database\DatabaseStructureController'
|
||||
);
|
||||
$container->alias(
|
||||
'DatabaseStructureController',
|
||||
'PhpMyAdmin\Controllers\Database\DatabaseStructureController'
|
||||
);
|
||||
$container->set('PhpMyAdmin\Response', Response::getInstance());
|
||||
$container->alias('response', 'PhpMyAdmin\Response');
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
/* Define dependencies for the concerned controller */
|
||||
$dependency_definitions = array(
|
||||
'db' => $db,
|
||||
);
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseStructureController $controller */
|
||||
$controller = $container->get(
|
||||
'DatabaseStructureController',
|
||||
$dependency_definitions
|
||||
);
|
||||
$controller->indexAction();
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var StructureController $controller */
|
||||
$controller = $containerBuilder->get(StructureController::class);
|
||||
|
||||
if ($response->isAjax() && ! empty($_REQUEST['favorite_table'])) {
|
||||
$json = $controller->addRemoveFavoriteTablesAction([
|
||||
'favorite_table' => $_REQUEST['favorite_table'],
|
||||
'favoriteTables' => $_REQUEST['favoriteTables'] ?? null,
|
||||
'sync_favorite_tables' => $_REQUEST['sync_favorite_tables'] ?? null,
|
||||
'add_favorite' => $_REQUEST['add_favorite'] ?? null,
|
||||
'remove_favorite' => $_REQUEST['remove_favorite'] ?? null,
|
||||
]);
|
||||
if ($json !== null) {
|
||||
$response->addJSON($json);
|
||||
}
|
||||
} elseif ($response->isAjax()
|
||||
&& isset($_REQUEST['real_row_count'])
|
||||
&& (bool) $_REQUEST['real_row_count'] === true
|
||||
) {
|
||||
$response->addJSON($controller->handleRealRowCountRequestAction([
|
||||
'real_row_count_all' => $_REQUEST['real_row_count_all'] ?? null,
|
||||
'table' => $_REQUEST['table'] ?? null,
|
||||
]));
|
||||
} else {
|
||||
$response->getHeader()->getScripts()->addFiles([
|
||||
'database/structure.js',
|
||||
'table/change.js',
|
||||
]);
|
||||
|
||||
$response->addHTML($controller->index([
|
||||
'submit_mult' => $_POST['submit_mult'] ?? null,
|
||||
'selected_tbl' => $_POST['selected_tbl'] ?? null,
|
||||
'mult_btn' => $_POST['mult_btn'] ?? null,
|
||||
'sort' => $_REQUEST['sort'] ?? null,
|
||||
'sort_order' => $_REQUEST['sort_order'] ?? null,
|
||||
]));
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Display\CreateTable;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Relation;
|
||||
@ -13,22 +15,28 @@ use PhpMyAdmin\Tracker;
|
||||
use PhpMyAdmin\Tracking;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Run common work
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
global $db, $pmaThemeImage, $text_dir, $url_query;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
//Get some js files needed for Ajax requests
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('vendor/jquery/jquery.tablesorter.js');
|
||||
$scripts->addFile('db_tracking.js');
|
||||
$scripts->addFile('database/tracking.js');
|
||||
|
||||
/** @var Tracking $tracking */
|
||||
$tracking = $containerBuilder->get('tracking');
|
||||
|
||||
/**
|
||||
* If we are not in an Ajax request, then do the common work and show the links etc.
|
||||
*/
|
||||
require 'libraries/db_common.inc.php';
|
||||
require ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
$url_query .= '&goto=tbl_tracking.php&back=db_tracking.php';
|
||||
$url_params['goto'] = 'tbl_tracking.php';
|
||||
$url_params['back'] = 'db_tracking.php';
|
||||
@ -46,18 +54,15 @@ list(
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
) = Util::getDbInfo($db, $sub_part === null ? '' : $sub_part);
|
||||
|
||||
if (isset($_POST['delete_tracking']) && isset($_POST['table'])) {
|
||||
|
||||
Tracker::deleteTracking($GLOBALS['db'], $_POST['table']);
|
||||
Tracker::deleteTracking($db, $_POST['table']);
|
||||
Message::success(
|
||||
__('Tracking data deleted successfully.')
|
||||
)->display();
|
||||
|
||||
} elseif (isset($_POST['submit_create_version'])) {
|
||||
|
||||
Tracking::createTrackingForMultipleTables($_POST['selected']);
|
||||
$tracking->createTrackingForMultipleTables($_POST['selected']);
|
||||
Message::success(
|
||||
sprintf(
|
||||
__(
|
||||
@ -67,25 +72,20 @@ if (isset($_POST['delete_tracking']) && isset($_POST['table'])) {
|
||||
htmlspecialchars($_POST['version'])
|
||||
)
|
||||
)->display();
|
||||
|
||||
} elseif (isset($_POST['submit_mult'])) {
|
||||
|
||||
if (! empty($_POST['selected_tbl'])) {
|
||||
if ($_POST['submit_mult'] == 'delete_tracking') {
|
||||
|
||||
foreach ($_POST['selected_tbl'] as $table) {
|
||||
Tracker::deleteTracking($GLOBALS['db'], $table);
|
||||
Tracker::deleteTracking($db, $table);
|
||||
}
|
||||
Message::success(
|
||||
__('Tracking data deleted successfully.')
|
||||
)->display();
|
||||
|
||||
} elseif ($_POST['submit_mult'] == 'track') {
|
||||
|
||||
echo Tracking::getHtmlForDataDefinitionAndManipulationStatements(
|
||||
echo $tracking->getHtmlForDataDefinitionAndManipulationStatements(
|
||||
'db_tracking.php' . $url_query,
|
||||
0,
|
||||
$GLOBALS['db'],
|
||||
$db,
|
||||
$_POST['selected_tbl']
|
||||
);
|
||||
exit;
|
||||
@ -98,10 +98,10 @@ if (isset($_POST['delete_tracking']) && isset($_POST['table'])) {
|
||||
}
|
||||
|
||||
// Get tracked data about the database
|
||||
$data = Tracker::getTrackedData($GLOBALS['db'], '', '1');
|
||||
$data = Tracker::getTrackedData($db, '', '1');
|
||||
|
||||
// No tables present and no log exist
|
||||
if ($num_tables == 0 && count($data['ddlog']) == 0) {
|
||||
if ($num_tables == 0 && count($data['ddlog']) === 0) {
|
||||
echo '<p>' , __('No tables found in database.') , '</p>' , "\n";
|
||||
|
||||
if (empty($db_is_system_schema)) {
|
||||
@ -111,38 +111,13 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
echo $tracking->getHtmlForDbTrackingTables(
|
||||
$db,
|
||||
$url_query,
|
||||
$pmaThemeImage,
|
||||
$text_dir
|
||||
);
|
||||
|
||||
// Prepare statement to get HEAD version
|
||||
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
|
||||
Util::backquote($cfgRelation['db']) . '.' .
|
||||
Util::backquote($cfgRelation['tracking']) .
|
||||
' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($GLOBALS['db']) .
|
||||
'\' ' .
|
||||
' GROUP BY table_name' .
|
||||
' ORDER BY table_name ASC';
|
||||
|
||||
$all_tables_result = $relation->queryAsControlUser($all_tables_query);
|
||||
|
||||
// If a HEAD version exists
|
||||
if (is_object($all_tables_result)
|
||||
&& $GLOBALS['dbi']->numRows($all_tables_result) > 0
|
||||
) {
|
||||
echo Tracking::getHtmlForTrackedTables(
|
||||
$GLOBALS['db'], $all_tables_result, $url_query, $pmaThemeImage,
|
||||
$text_dir, $cfgRelation
|
||||
);
|
||||
}
|
||||
|
||||
$untracked_tables = Tracking::getUntrackedTables($GLOBALS['db']);
|
||||
|
||||
// If untracked tables exist
|
||||
if (count($untracked_tables) > 0) {
|
||||
echo Tracking::getHtmlForUntrackedTables(
|
||||
$GLOBALS['db'], $untracked_tables, $url_query, $pmaThemeImage, $text_dir
|
||||
);
|
||||
}
|
||||
// If available print out database log
|
||||
if (count($data['ddlog']) > 0) {
|
||||
$log = '';
|
||||
|
||||
@ -5,14 +5,76 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Include required files
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
use PhpMyAdmin\Controllers\Database\TriggersController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/**
|
||||
* Do the magic
|
||||
*/
|
||||
$_PMA_RTE = 'TRI';
|
||||
require_once 'libraries/rte/rte_main.inc.php';
|
||||
|
||||
/** @var TriggersController $controller */
|
||||
$controller = $containerBuilder->get(TriggersController::class);
|
||||
|
||||
/** @var string $db */
|
||||
$db = $containerBuilder->getParameter('db');
|
||||
|
||||
/** @var string $table */
|
||||
$table = $containerBuilder->getParameter('table');
|
||||
|
||||
if (! $response->isAjax()) {
|
||||
/**
|
||||
* Displays the header and tabs
|
||||
*/
|
||||
if (! empty($table) && in_array($table, $dbi->getTables($db))) {
|
||||
include_once ROOT_PATH . 'libraries/tbl_common.inc.php';
|
||||
} else {
|
||||
$table = '';
|
||||
include_once ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
list(
|
||||
$tables,
|
||||
$num_tables,
|
||||
$total_num_tables,
|
||||
$sub_part,
|
||||
$is_show_stats,
|
||||
$db_is_system_schema,
|
||||
$tooltip_truename,
|
||||
$tooltip_aliasname,
|
||||
$pos
|
||||
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Since we did not include some libraries, we need
|
||||
* to manually select the required database and
|
||||
* create the missing $url_query variable
|
||||
*/
|
||||
if (strlen($db) > 0) {
|
||||
$dbi->selectDb($db);
|
||||
if (! isset($url_query)) {
|
||||
$url_query = Url::getCommon(
|
||||
[
|
||||
'db' => $db,
|
||||
'table' => $table,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$controller->index();
|
||||
|
||||
@ -51,7 +51,7 @@ copyright = u'2012 - 2018, The phpMyAdmin devel team'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.9.3'
|
||||
version = '5.0.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ Basic settings
|
||||
|
||||
Sets here the complete :term:`URL` (with full path) to your phpMyAdmin
|
||||
installation's directory. E.g.
|
||||
``https://www.example.net/path_to_your_phpMyAdmin_directory/``. Note also
|
||||
``https://www.example.net/path_to_your_phpMyAdmin_directory/``. Note also
|
||||
that the :term:`URL` on most of web servers are case sensitive (even on
|
||||
Windows). Don’t forget the trailing slash at the end.
|
||||
|
||||
@ -212,12 +212,14 @@ Basic settings
|
||||
|
||||
.. config:option:: $cfg['AllowThirdPartyFraming']
|
||||
|
||||
:type: boolean
|
||||
:type: boolean|string
|
||||
:default: false
|
||||
|
||||
Setting this to ``true`` allows phpMyAdmin to be included inside a frame,
|
||||
and is a potential security hole allowing cross-frame scripting attacks or
|
||||
clickjacking.
|
||||
clickjacking. Setting this to 'sameorigin' prevents phpMyAdmin to be
|
||||
included from another document in a frame, unless that document belongs
|
||||
to the same domain.
|
||||
|
||||
Server connection settings
|
||||
--------------------------
|
||||
@ -728,6 +730,12 @@ Server connection settings
|
||||
:type: string
|
||||
:default: ``'mysqli'``
|
||||
|
||||
.. deprecated:: 4.2.0
|
||||
|
||||
This setting was removed. The ``mysql`` extension will only be used when
|
||||
the ``mysqli`` extension is not available. As of 5.0.0, only the
|
||||
``mysqli`` extension can be used.
|
||||
|
||||
The PHP MySQL extension to use (``mysql`` or ``mysqli``).
|
||||
|
||||
It is recommended to use ``mysqli`` in all installations.
|
||||
@ -1736,6 +1744,15 @@ Generic settings
|
||||
Define whether phpMyAdmin will continue executing a multi-query
|
||||
statement if one of the queries fails. Default is to abort execution.
|
||||
|
||||
.. config:option:: $cfg['enable_drag_drop_import']
|
||||
|
||||
:type: boolean
|
||||
:default: true
|
||||
|
||||
Whether or not the drag and drop import feature is enabled.
|
||||
When enabled, a user can drag a file in to their browser and phpMyAdmin will
|
||||
attempt to import the file.
|
||||
|
||||
Cookie authentication options
|
||||
-----------------------------
|
||||
|
||||
@ -3001,7 +3018,7 @@ the files.
|
||||
:default: ``''``
|
||||
|
||||
The name of the directory where :term:`SQL` files have been uploaded by
|
||||
other means than phpMyAdmin (for example, ftp). Those files are available
|
||||
other means than phpMyAdmin (for example, FTP). Those files are available
|
||||
under a drop-down box when you click the database or table name, then the
|
||||
Import tab.
|
||||
|
||||
@ -3254,6 +3271,11 @@ Theme manager settings
|
||||
:type: string
|
||||
:default: '82%'
|
||||
|
||||
.. deprecated:: 5.0.0
|
||||
|
||||
This setting was removed as the browser is more efficient,
|
||||
thus no need of this option.
|
||||
|
||||
Font size to use, is applied in CSS.
|
||||
|
||||
Default queries
|
||||
@ -3483,7 +3505,6 @@ This example uses :file:`examples/signon.php` to demonstrate usage of :ref:`auth
|
||||
$cfg['Servers'][$i]['auth_type'] = 'signon';
|
||||
$cfg['Servers'][$i]['SignonSession'] = 'SignonSession';
|
||||
$cfg['Servers'][$i]['SignonURL'] = 'examples/signon.php';
|
||||
?>`
|
||||
|
||||
Example for IP address limited autologin
|
||||
++++++++++++++++++++++++++++++++++++++++
|
||||
@ -3539,7 +3560,6 @@ following example shows two of them:
|
||||
$cfg['ServerDefault'] = 0; // to choose the server on startup
|
||||
|
||||
// further general options ...
|
||||
?>
|
||||
|
||||
.. _example-google-ssl:
|
||||
|
||||
|
||||
@ -439,6 +439,43 @@ Credits, in chronological order
|
||||
|
||||
* Other UI improvements
|
||||
|
||||
* Maurício Meneghini Fauth
|
||||
|
||||
* Major improvements and upgrades to the JavaScript core
|
||||
* Modernize JavaScript library functionality
|
||||
* Modernize templating and introduce Twig
|
||||
|
||||
* William Desportes
|
||||
|
||||
* Coding style improvements based on PHPStan
|
||||
* Improve links to external MySQL and MariaDB documentation
|
||||
* Numerous other bug fixes
|
||||
|
||||
* Emanuel Bronshtein
|
||||
|
||||
* Comprehensive security assessment and suggestions
|
||||
|
||||
* Lakshya Arora (Google Summer of Code 2018)
|
||||
|
||||
* Various improvements including:
|
||||
|
||||
* Integrate user preferences with local storage
|
||||
* Use a modal login after session expiration
|
||||
* Add support for CHECK CONSTRAINTS
|
||||
* and more!
|
||||
|
||||
* Saksham Gupta (Google Summer of Code 2018)
|
||||
|
||||
* Automated theme generator tool
|
||||
|
||||
* Leonardo Strozzi (Google Summer of Code 2018)
|
||||
|
||||
* Refactoring Twig templates and other internal code improvements
|
||||
|
||||
* Piyush Vijay (Google Summer of Code 2018)
|
||||
|
||||
* Modernize the JavaScript code including introducing Webpack, Babel, and Yarn as well as eslint and Jsdoc
|
||||
|
||||
And also to the following people who have contributed minor changes,
|
||||
enhancements, bugfixes or support for a new language since version
|
||||
2.1.0:
|
||||
|
||||
36
doc/faq.rst
36
doc/faq.rst
@ -167,14 +167,14 @@ to the latest version to take advantage of the new import features.
|
||||
|
||||
The first things to check (or ask your host provider to check) are the values
|
||||
of ``max_execution_time``, ``upload_max_filesize``, ``memory_limit`` and
|
||||
``post_max_size`` in the :file:`php.ini` configuration file. All of these three
|
||||
``post_max_size`` in the :file:`php.ini` configuration file. All of these
|
||||
settings limit the maximum size of data that can be submitted and handled by
|
||||
PHP. Please note that ``post_max_size`` needs to be larger than
|
||||
``upload_max_filesize``. There exist several workarounds if your upload is too
|
||||
big or your hosting provider is unwilling to change the settings:
|
||||
|
||||
* Look at the :config:option:`$cfg['UploadDir']` feature. This allows one to upload a file to the server
|
||||
via scp, ftp, or your favorite file transfer method. PhpMyAdmin is
|
||||
via scp, FTP, or your favorite file transfer method. PhpMyAdmin is
|
||||
then able to import the files from the temporary directory. More
|
||||
information is available in the :ref:`config` of this document.
|
||||
* Using a utility (such as `BigDump
|
||||
@ -433,7 +433,9 @@ releases.
|
||||
PHP 7 is supported since phpMyAdmin 4.6, PHP 7.1 is supported since 4.6.5,
|
||||
PHP 7.2 is supported since 4.7.4.
|
||||
|
||||
phpMyAdmin also works fine with HHVM.
|
||||
HHVM is supported up to phpMyAdmin 4.8.
|
||||
|
||||
Since release 5.0, phpMyAdmin supports only PHP 7.1 and newer.
|
||||
|
||||
.. _faq1_32:
|
||||
|
||||
@ -461,20 +463,22 @@ Yes. This procedure was tested with phpMyAdmin 2.6.1, PHP 4.3.9 in
|
||||
|
||||
.. _faq1_34:
|
||||
|
||||
1.34 Can I access directly to database or table pages?
|
||||
------------------------------------------------------
|
||||
1.34 Can I directly access a database or table pages?
|
||||
-----------------------------------------------------
|
||||
|
||||
Yes. Out of the box, you can use :term:`URL` like
|
||||
Yes. Out of the box, you can use a :term:`URL` like
|
||||
``http://server/phpMyAdmin/index.php?server=X&db=database&table=table&target=script``.
|
||||
For ``server`` you use the server number
|
||||
which refers to the order of the server paragraph in
|
||||
:file:`config.inc.php`. Table and script parts are optional. If you want
|
||||
``http://server/phpMyAdmin/database[/table][/script]`` :term:`URL`, you need to do some configuration. Following
|
||||
lines apply only for `Apache <https://httpd.apache.org>`_ web server.
|
||||
First make sure, that you have enabled some features within global
|
||||
For ``server`` you can use the server number
|
||||
which refers to the numeric host index (from ``$i``) in
|
||||
:file:`config.inc.php`. The table and script parts are optional.
|
||||
|
||||
If you want a URL like
|
||||
``http://server/phpMyAdmin/database[/table][/script]``, you need to do some additional configuration. The following
|
||||
lines apply only for the `Apache <https://httpd.apache.org>`_ web server.
|
||||
First, make sure that you have enabled some features within the Apache global
|
||||
configuration. You need ``Options SymLinksIfOwnerMatch`` and ``AllowOverride
|
||||
FileInfo`` enabled for directory where phpMyAdmin is installed and you
|
||||
need mod\_rewrite to be enabled. Then you just need to create
|
||||
need mod\_rewrite to be enabled. Then you just need to create the
|
||||
following :term:`.htaccess` file in root folder of phpMyAdmin installation (don't
|
||||
forget to change directory name inside of it):
|
||||
|
||||
@ -487,6 +491,8 @@ forget to change directory name inside of it):
|
||||
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ index.php?db=$1&table=$2 [R]
|
||||
RewriteRule ^([a-zA-Z0-9_]+)$ index.php?db=$1 [R]
|
||||
|
||||
.. seealso:: :ref:`faq4_8`
|
||||
|
||||
.. _faq1_35:
|
||||
|
||||
1.35 Can I use HTTP authentication with Apache CGI?
|
||||
@ -1175,6 +1181,8 @@ or one of the host names present in the configuration file.
|
||||
For example, to jump directly to a particular database, a URL can be constructed as
|
||||
``https://example.com/phpmyadmin/?db=sakila``.
|
||||
|
||||
.. seealso:: :ref:`faq1_34`
|
||||
|
||||
.. versionchanged:: 4.9.0
|
||||
|
||||
Support for using the ``pma_username`` and ``pma_password`` parameters was removed
|
||||
@ -1615,7 +1623,7 @@ It means "average".
|
||||
any) will be included in backup.
|
||||
* "Enclose table and column names with backquotes" ensures that column
|
||||
and table names formed with special characters are protected.
|
||||
* "Add into comments" includes column comments, relations, and MIME
|
||||
* "Add into comments" includes column comments, relations, and media (MIME)
|
||||
types set in the pmadb in the dump as :term:`SQL` comments
|
||||
(*/\* xxx \*/*).
|
||||
|
||||
|
||||
@ -220,6 +220,12 @@ From Wikipedia, the free encyclopedia
|
||||
|
||||
.. seealso:: <https://www.php.net/mcrypt>
|
||||
|
||||
Media type
|
||||
A media type (formerly known as MIME type) is a two-part identifier
|
||||
for file formats and format contents transmitted on the Internet.
|
||||
|
||||
.. seealso:: <https://en.wikipedia.org/wiki/Media_type>
|
||||
|
||||
MIME
|
||||
Multipurpose Internet Mail Extensions is
|
||||
an Internet Standard for the format of e-mail.
|
||||
|
||||
@ -12,7 +12,7 @@ web server (such as Apache, nginx, :term:`IIS`) to install phpMyAdmin's files in
|
||||
PHP
|
||||
---
|
||||
|
||||
* You need PHP 5.5.0 or newer, with ``session`` support, the Standard PHP Library
|
||||
* You need PHP 7.1.3 or newer, with ``session`` support, the Standard PHP Library
|
||||
(SPL) extension, hash, ctype, and JSON support.
|
||||
|
||||
* The ``mbstring`` extension (see :term:`mbstring`) is strongly recommended
|
||||
|
||||
@ -91,6 +91,13 @@ You can find more of such options at `Wikipedia <https://en.wikipedia.org/wiki/L
|
||||
Installing from Git
|
||||
+++++++++++++++++++
|
||||
|
||||
In order to install from Git, you'll need a few supporting applications:
|
||||
|
||||
* `Git <https://git-scm.com/downloads>`_ to download the source, or you can download the most recent source directly from `Github <https://codeload.github.com/phpmyadmin/phpmyadmin/zip/master>`_
|
||||
* `Composer <https://getcomposer.org/download/>`__
|
||||
* `Node.js <https://nodejs.org/en/download/>`_ (version 8 or higher)
|
||||
* `Yarn <https://yarnpkg.com/lang/en/docs/install>`_
|
||||
|
||||
You can clone current phpMyAdmin source from
|
||||
``https://github.com/phpmyadmin/phpmyadmin.git``:
|
||||
|
||||
@ -98,7 +105,7 @@ You can clone current phpMyAdmin source from
|
||||
|
||||
git clone https://github.com/phpmyadmin/phpmyadmin.git
|
||||
|
||||
Additionally you need to install dependencies using the `Composer tool`_:
|
||||
Additionally you need to install dependencies using `Composer <https://getcomposer.org>`__:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
@ -111,6 +118,12 @@ by invoking:
|
||||
|
||||
composer update --no-dev
|
||||
|
||||
Finally, you'll need to use `Yarn`_ to install some JavaScript dependencies:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
yarn install
|
||||
|
||||
.. _composer:
|
||||
|
||||
Installing using Composer
|
||||
@ -253,7 +266,6 @@ configuration file:
|
||||
|
||||
<?php
|
||||
$cfg['Export']['csv_columns'] = true;
|
||||
?>
|
||||
|
||||
You can also use it to define server configuration instead of using the
|
||||
environment variables listed in :ref:`docker-vars`:
|
||||
@ -467,7 +479,7 @@ Quick Install
|
||||
webserver's document root. If you don't have direct access to your
|
||||
document root, put the files in a directory on your local machine,
|
||||
and, after step 4, transfer the directory on your web server using,
|
||||
for example, ftp.
|
||||
for example, FTP.
|
||||
#. Ensure that all the scripts have the appropriate owner (if PHP is
|
||||
running in safe mode, having some scripts with an owner different from
|
||||
the owner of other scripts will be a problem). See :ref:`faq4_2` and
|
||||
@ -502,8 +514,7 @@ simple configuration may look like this:
|
||||
$i++;
|
||||
$cfg['Servers'][$i]['auth_type'] = 'cookie';
|
||||
// if you insist on "root" having no password:
|
||||
// $cfg['Servers'][$i]['AllowNoPassword'] = true; `
|
||||
?>
|
||||
// $cfg['Servers'][$i]['AllowNoPassword'] = true;
|
||||
|
||||
Or, if you prefer to not be prompted every time you log in:
|
||||
|
||||
@ -516,7 +527,6 @@ Or, if you prefer to not be prompted every time you log in:
|
||||
$cfg['Servers'][$i]['user'] = 'root';
|
||||
$cfg['Servers'][$i]['password'] = 'cbb74bc'; // use here your password
|
||||
$cfg['Servers'][$i]['auth_type'] = 'config';
|
||||
?>
|
||||
|
||||
.. warning::
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ manually; the typical way of doing so is with the command:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
composer require pragmarx/google2fa bacon/bacon-qr-code
|
||||
composer require pragmarx/google2fa-qrcode
|
||||
|
||||
Or when using a hardware security key with FIDO U2F:
|
||||
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
Distributing and packaging phpMyAdmin
|
||||
=====================================
|
||||
|
||||
This document is intended to give advices to people who want to
|
||||
redistribute phpMyAdmin inside other software package such as Linux
|
||||
This document is intended to give pieces of advice to people who want to
|
||||
redistribute phpMyAdmin inside other software packages such as Linux
|
||||
distribution or some all in one package including web server and MySQL
|
||||
server.
|
||||
|
||||
Generally you can customize some basic aspects (paths to some files and
|
||||
Generally, you can customize some basic aspects (paths to some files and
|
||||
behavior) in :file:`libraries/vendor_config.php`.
|
||||
|
||||
For example if you want setup script to generate config file in var, change
|
||||
For example, if you want setup script to generate a config file in var, change
|
||||
``SETUP_CONFIG_FILE`` to :file:`/var/lib/phpmyadmin/config.inc.php` and you
|
||||
will also probably want to skip directory writable check, so set
|
||||
``SETUP_DIR_WRITABLE`` to false.
|
||||
@ -19,7 +19,7 @@ External libraries
|
||||
|
||||
phpMyAdmin includes several external libraries, you might want to
|
||||
replace them with system ones if they are available, but please note
|
||||
that you should test whether version you provide is compatible with the
|
||||
that you should test whether the version you provide is compatible with the
|
||||
one we ship.
|
||||
|
||||
Currently known list of external libraries:
|
||||
|
||||
@ -5,23 +5,30 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\ErrorReport;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\Utils\HttpRequest;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (!isset($_POST['exception_type'])
|
||||
||!in_array($_POST['exception_type'], array('js', 'php'))
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
if (! isset($_POST['exception_type'])
|
||||
|| ! in_array($_POST['exception_type'], ['js', 'php'])
|
||||
) {
|
||||
die('Oops, something went wrong!!');
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
|
||||
$errorReport = new ErrorReport(new HttpRequest());
|
||||
/** @var ErrorReport $errorReport */
|
||||
$errorReport = $containerBuilder->get('error_report');
|
||||
|
||||
if (isset($_POST['send_error_report'])
|
||||
&& ($_POST['send_error_report'] == true
|
||||
@ -37,17 +44,17 @@ if (isset($_POST['send_error_report'])
|
||||
if (isset($_SESSION['prev_error_subm_time'])
|
||||
&& isset($_SESSION['error_subm_count'])
|
||||
&& $_SESSION['error_subm_count'] >= 3
|
||||
&& ($_SESSION['prev_error_subm_time']-time()) <= 3000
|
||||
&& ($_SESSION['prev_error_subm_time'] - time()) <= 3000
|
||||
) {
|
||||
$_SESSION['error_subm_count'] = 0;
|
||||
$_SESSION['prev_errors'] = '';
|
||||
$response->addJSON('_stopErrorReportLoop', '1');
|
||||
$response->addJSON('stopErrorReportLoop', '1');
|
||||
} else {
|
||||
$_SESSION['prev_error_subm_time'] = time();
|
||||
$_SESSION['error_subm_count'] = (
|
||||
(isset($_SESSION['error_subm_count']))
|
||||
? ($_SESSION['error_subm_count']+1)
|
||||
: (0)
|
||||
isset($_SESSION['error_subm_count'])
|
||||
? ($_SESSION['error_subm_count'] + 1)
|
||||
: 0
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -59,7 +66,7 @@ if (isset($_POST['send_error_report'])
|
||||
$success = false;
|
||||
} else {
|
||||
$decoded_response = json_decode($server_response, true);
|
||||
$success = !empty($decoded_response) ?
|
||||
$success = ! empty($decoded_response) ?
|
||||
$decoded_response["success"] : false;
|
||||
}
|
||||
|
||||
@ -101,10 +108,10 @@ if (isset($_POST['send_error_report'])
|
||||
if ($_POST['exception_type'] == 'js') {
|
||||
$response->addJSON('message', $msg);
|
||||
} else {
|
||||
$response->addJSON('_errSubmitMsg', $msg);
|
||||
$response->addJSON('errSubmitMsg', $msg);
|
||||
}
|
||||
} elseif ($_POST['exception_type'] == 'php') {
|
||||
$jsCode = 'PMA_ajaxShowMessage("<div class=\"error\">'
|
||||
$jsCode = 'Functions.ajaxShowMessage("<div class=\"error\">'
|
||||
. $msg
|
||||
. '</div>", false);';
|
||||
$response->getFooter()->getScripts()->addCode($jsCode);
|
||||
@ -125,11 +132,9 @@ if (isset($_POST['send_error_report'])
|
||||
}
|
||||
} elseif (! empty($_POST['get_settings'])) {
|
||||
$response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']);
|
||||
} elseif ($_POST['exception_type'] == 'js') {
|
||||
$response->addHTML($errorReport->getForm());
|
||||
} else {
|
||||
if ($_POST['exception_type'] == 'js') {
|
||||
$response->addHTML($errorReport->getForm());
|
||||
} else {
|
||||
// clear previous errors & save new ones.
|
||||
$GLOBALS['error_handler']->savePreviousErrors();
|
||||
}
|
||||
// clear previous errors & save new ones.
|
||||
$GLOBALS['error_handler']->savePreviousErrors();
|
||||
}
|
||||
|
||||
@ -8,14 +8,15 @@
|
||||
* @package PhpMyAdmin
|
||||
* @subpackage Example
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
$i=0;
|
||||
$hosts = array (
|
||||
$i = 0;
|
||||
$hosts = [
|
||||
"foo.example.com",
|
||||
"bar.example.com",
|
||||
"baz.example.com",
|
||||
"quux.example.com",
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($hosts as $host) {
|
||||
$i++;
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
* @package PhpMyAdmin
|
||||
* @subpackage Example
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
if (false === @include_once 'OpenID/RelyingParty.php') {
|
||||
exit;
|
||||
@ -26,12 +27,12 @@ $secure_cookie = false;
|
||||
/**
|
||||
* Map of authenticated users to MySQL user/password pairs.
|
||||
*/
|
||||
$AUTH_MAP = array(
|
||||
'https://launchpad.net/~username' => array(
|
||||
$AUTH_MAP = [
|
||||
'https://launchpad.net/~username' => [
|
||||
'user' => 'root',
|
||||
'password' => '',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Simple function to show HTML page with given content.
|
||||
@ -48,9 +49,9 @@ function Show_page($contents)
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="../favicon.ico" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
|
||||
<meta charset="utf-8">
|
||||
<title>phpMyAdmin OpenID signon example</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -105,11 +106,11 @@ if ($returnTo[strlen($returnTo) - 1] != '/') {
|
||||
$returnTo .= 'openid.php';
|
||||
|
||||
/* Display form */
|
||||
if (!count($_GET) && !count($_POST) || isset($_GET['phpMyAdmin'])) {
|
||||
if (! count($_GET) && ! count($_POST) || isset($_GET['phpMyAdmin'])) {
|
||||
/* Show simple form */
|
||||
$content = '<form action="openid.php" method="post">
|
||||
OpenID: <input type="text" name="identifier" /><br />
|
||||
<input type="submit" name="start" />
|
||||
OpenID: <input type="text" name="identifier"><br>
|
||||
<input type="submit" name="start">
|
||||
</form>
|
||||
</body>
|
||||
</html>';
|
||||
@ -147,7 +148,7 @@ if (isset($_POST['start'])) {
|
||||
exit;
|
||||
} else {
|
||||
/* Grab query string */
|
||||
if (!count($_POST)) {
|
||||
if (! count($_POST)) {
|
||||
list(, $queryString) = explode('?', $_SERVER['REQUEST_URI']);
|
||||
} else {
|
||||
// I hate php sometimes
|
||||
@ -163,7 +164,7 @@ if (isset($_POST['start'])) {
|
||||
|
||||
$id = $message->get('openid.claimed_id');
|
||||
|
||||
if (!empty($id) && isset($AUTH_MAP[$id])) {
|
||||
if (! empty($id) && isset($AUTH_MAP[$id])) {
|
||||
$_SESSION['PMA_single_signon_user'] = $AUTH_MAP[$id]['user'];
|
||||
$_SESSION['PMA_single_signon_password'] = $AUTH_MAP[$id]['password'];
|
||||
session_write_close();
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
* @package PhpMyAdmin
|
||||
* @subpackage Example
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This function returns username and password.
|
||||
@ -24,12 +24,16 @@
|
||||
function get_login_credentials($user)
|
||||
{
|
||||
/* Optionally we can use passed username */
|
||||
if (!empty($user)) {
|
||||
return array($user, 'password');
|
||||
if (! empty($user)) {
|
||||
return [
|
||||
$user,
|
||||
'password',
|
||||
];
|
||||
}
|
||||
|
||||
/* Here we would retrieve the credentials */
|
||||
$credentials = array('root', '');
|
||||
|
||||
return $credentials;
|
||||
return [
|
||||
'root',
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
* @package PhpMyAdmin
|
||||
* @subpackage Example
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
/* Use cookies for session */
|
||||
ini_set('session.use_cookies', 'true');
|
||||
@ -32,7 +33,7 @@ if (isset($_POST['user'])) {
|
||||
$_SESSION['PMA_single_signon_host'] = $_POST['host'];
|
||||
$_SESSION['PMA_single_signon_port'] = $_POST['port'];
|
||||
/* Update another field of server configuration */
|
||||
$_SESSION['PMA_single_signon_cfgupdate'] = array('verbose' => 'Signon test');
|
||||
$_SESSION['PMA_single_signon_cfgupdate'] = ['verbose' => 'Signon test'];
|
||||
$id = session_id();
|
||||
/* Close that session */
|
||||
@session_write_close();
|
||||
@ -46,9 +47,9 @@ if (isset($_POST['user'])) {
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="../favicon.ico" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
|
||||
<meta charset="utf-8">
|
||||
<title>phpMyAdmin single signon example</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -60,13 +61,13 @@ if (isset($_POST['user'])) {
|
||||
}
|
||||
?>
|
||||
<form action="signon.php" method="post">
|
||||
Username: <input type="text" name="user" /><br />
|
||||
Password: <input type="password" name="password" /><br />
|
||||
Username: <input type="text" name="user"><br>
|
||||
Password: <input type="password" name="password"><br>
|
||||
Host: (will use the one from config.inc.php by default)
|
||||
<input type="text" name="host" /><br />
|
||||
<input type="text" name="host"><br>
|
||||
Port: (will use the one from config.inc.php by default)
|
||||
<input type="text" name="port" /><br />
|
||||
<input type="submit" />
|
||||
<input type="text" name="port"><br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
494
export.php
494
export.php
@ -5,28 +5,44 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Export;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Sanitize;
|
||||
use PhpMyAdmin\SqlParser\Parser;
|
||||
use PhpMyAdmin\SqlParser\Statements\SelectStatement;
|
||||
use PhpMyAdmin\SqlParser\Utils\Misc;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
/**
|
||||
* Get the variables sent or posted to this script and a core script
|
||||
*/
|
||||
include_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
global $db, $sql_query;
|
||||
|
||||
include_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('export_output.js');
|
||||
|
||||
/** @var Export $export */
|
||||
$export = $containerBuilder->get('export');
|
||||
|
||||
//check if it's the GET request to check export time out
|
||||
if (isset($_GET['check_time_out'])) {
|
||||
if (isset($_SESSION['pma_export_error'])) {
|
||||
@ -48,123 +64,125 @@ if (isset($_GET['check_time_out'])) {
|
||||
* TODO: this should be removed to avoid passing user input to GLOBALS
|
||||
* without checking
|
||||
*/
|
||||
$post_params = array(
|
||||
'db',
|
||||
'table',
|
||||
'what',
|
||||
'single_table',
|
||||
'export_type',
|
||||
'export_method',
|
||||
'quick_or_custom',
|
||||
'db_select',
|
||||
'table_select',
|
||||
'table_structure',
|
||||
'table_data',
|
||||
'limit_to',
|
||||
'limit_from',
|
||||
'allrows',
|
||||
'lock_tables',
|
||||
'output_format',
|
||||
'filename_template',
|
||||
'maxsize',
|
||||
'remember_template',
|
||||
'charset',
|
||||
'compression',
|
||||
'as_separate_files',
|
||||
'knjenc',
|
||||
'xkana',
|
||||
'htmlword_structure_or_data',
|
||||
'htmlword_null',
|
||||
'htmlword_columns',
|
||||
'mediawiki_headers',
|
||||
'mediawiki_structure_or_data',
|
||||
'mediawiki_caption',
|
||||
'pdf_structure_or_data',
|
||||
'odt_structure_or_data',
|
||||
'odt_relation',
|
||||
'odt_comments',
|
||||
'odt_mime',
|
||||
'odt_columns',
|
||||
'odt_null',
|
||||
'codegen_structure_or_data',
|
||||
'codegen_format',
|
||||
'excel_null',
|
||||
'excel_removeCRLF',
|
||||
'excel_columns',
|
||||
'excel_edition',
|
||||
'excel_structure_or_data',
|
||||
'yaml_structure_or_data',
|
||||
'ods_null',
|
||||
'ods_structure_or_data',
|
||||
'ods_columns',
|
||||
'json_structure_or_data',
|
||||
'json_pretty_print',
|
||||
'json_unicode',
|
||||
'xml_structure_or_data',
|
||||
'xml_export_events',
|
||||
'xml_export_functions',
|
||||
'xml_export_procedures',
|
||||
'xml_export_tables',
|
||||
'xml_export_triggers',
|
||||
'xml_export_views',
|
||||
'xml_export_contents',
|
||||
'texytext_structure_or_data',
|
||||
'texytext_columns',
|
||||
'texytext_null',
|
||||
'phparray_structure_or_data',
|
||||
'sql_include_comments',
|
||||
'sql_header_comment',
|
||||
'sql_dates',
|
||||
'sql_relation',
|
||||
'sql_mime',
|
||||
'sql_use_transaction',
|
||||
'sql_disable_fk',
|
||||
'sql_compatibility',
|
||||
'sql_structure_or_data',
|
||||
'sql_create_database',
|
||||
'sql_drop_table',
|
||||
'sql_procedure_function',
|
||||
'sql_create_table',
|
||||
'sql_create_view',
|
||||
'sql_create_trigger',
|
||||
'sql_if_not_exists',
|
||||
'sql_auto_increment',
|
||||
'sql_backquotes',
|
||||
'sql_truncate',
|
||||
'sql_delayed',
|
||||
'sql_ignore',
|
||||
'sql_type',
|
||||
'sql_insert_syntax',
|
||||
'sql_max_query_size',
|
||||
'sql_hex_for_binary',
|
||||
'sql_utc_time',
|
||||
'sql_drop_database',
|
||||
'sql_views_as_tables',
|
||||
'sql_metadata',
|
||||
'csv_separator',
|
||||
'csv_enclosed',
|
||||
'csv_escaped',
|
||||
'csv_terminated',
|
||||
'csv_null',
|
||||
'csv_removeCRLF',
|
||||
'csv_columns',
|
||||
'csv_structure_or_data',
|
||||
// csv_replace should have been here but we use it directly from $_POST
|
||||
'latex_caption',
|
||||
'latex_structure_or_data',
|
||||
'latex_structure_caption',
|
||||
'latex_structure_continued_caption',
|
||||
'latex_structure_label',
|
||||
'latex_relation',
|
||||
'latex_comments',
|
||||
'latex_mime',
|
||||
'latex_columns',
|
||||
'latex_data_caption',
|
||||
'latex_data_continued_caption',
|
||||
'latex_data_label',
|
||||
'latex_null',
|
||||
'aliases'
|
||||
);
|
||||
$post_params = [
|
||||
'db',
|
||||
'table',
|
||||
'what',
|
||||
'single_table',
|
||||
'export_type',
|
||||
'export_method',
|
||||
'quick_or_custom',
|
||||
'db_select',
|
||||
'table_select',
|
||||
'table_structure',
|
||||
'table_data',
|
||||
'limit_to',
|
||||
'limit_from',
|
||||
'allrows',
|
||||
'lock_tables',
|
||||
'output_format',
|
||||
'filename_template',
|
||||
'maxsize',
|
||||
'remember_template',
|
||||
'charset',
|
||||
'compression',
|
||||
'as_separate_files',
|
||||
'knjenc',
|
||||
'xkana',
|
||||
'htmlword_structure_or_data',
|
||||
'htmlword_null',
|
||||
'htmlword_columns',
|
||||
'mediawiki_headers',
|
||||
'mediawiki_structure_or_data',
|
||||
'mediawiki_caption',
|
||||
'pdf_structure_or_data',
|
||||
'odt_structure_or_data',
|
||||
'odt_relation',
|
||||
'odt_comments',
|
||||
'odt_mime',
|
||||
'odt_columns',
|
||||
'odt_null',
|
||||
'codegen_structure_or_data',
|
||||
'codegen_format',
|
||||
'excel_null',
|
||||
'excel_removeCRLF',
|
||||
'excel_columns',
|
||||
'excel_edition',
|
||||
'excel_structure_or_data',
|
||||
'yaml_structure_or_data',
|
||||
'ods_null',
|
||||
'ods_structure_or_data',
|
||||
'ods_columns',
|
||||
'json_structure_or_data',
|
||||
'json_pretty_print',
|
||||
'json_unicode',
|
||||
'xml_structure_or_data',
|
||||
'xml_export_events',
|
||||
'xml_export_functions',
|
||||
'xml_export_procedures',
|
||||
'xml_export_tables',
|
||||
'xml_export_triggers',
|
||||
'xml_export_views',
|
||||
'xml_export_contents',
|
||||
'texytext_structure_or_data',
|
||||
'texytext_columns',
|
||||
'texytext_null',
|
||||
'phparray_structure_or_data',
|
||||
'sql_include_comments',
|
||||
'sql_header_comment',
|
||||
'sql_dates',
|
||||
'sql_relation',
|
||||
'sql_mime',
|
||||
'sql_use_transaction',
|
||||
'sql_disable_fk',
|
||||
'sql_compatibility',
|
||||
'sql_structure_or_data',
|
||||
'sql_create_database',
|
||||
'sql_drop_table',
|
||||
'sql_procedure_function',
|
||||
'sql_create_table',
|
||||
'sql_create_view',
|
||||
'sql_create_trigger',
|
||||
'sql_view_current_user',
|
||||
'sql_if_not_exists',
|
||||
'sql_or_replace_view',
|
||||
'sql_auto_increment',
|
||||
'sql_backquotes',
|
||||
'sql_truncate',
|
||||
'sql_delayed',
|
||||
'sql_ignore',
|
||||
'sql_type',
|
||||
'sql_insert_syntax',
|
||||
'sql_max_query_size',
|
||||
'sql_hex_for_binary',
|
||||
'sql_utc_time',
|
||||
'sql_drop_database',
|
||||
'sql_views_as_tables',
|
||||
'sql_metadata',
|
||||
'csv_separator',
|
||||
'csv_enclosed',
|
||||
'csv_escaped',
|
||||
'csv_terminated',
|
||||
'csv_null',
|
||||
'csv_removeCRLF',
|
||||
'csv_columns',
|
||||
'csv_structure_or_data',
|
||||
// csv_replace should have been here but we use it directly from $_POST
|
||||
'latex_caption',
|
||||
'latex_structure_or_data',
|
||||
'latex_structure_caption',
|
||||
'latex_structure_continued_caption',
|
||||
'latex_structure_label',
|
||||
'latex_relation',
|
||||
'latex_comments',
|
||||
'latex_mime',
|
||||
'latex_columns',
|
||||
'latex_data_caption',
|
||||
'latex_data_continued_caption',
|
||||
'latex_data_label',
|
||||
'latex_null',
|
||||
'aliases',
|
||||
];
|
||||
|
||||
foreach ($post_params as $one_post_param) {
|
||||
if (isset($_POST[$one_post_param])) {
|
||||
@ -174,21 +192,21 @@ foreach ($post_params as $one_post_param) {
|
||||
|
||||
$table = $GLOBALS['table'];
|
||||
|
||||
PhpMyAdmin\Util::checkParameters(array('what', 'export_type'));
|
||||
PhpMyAdmin\Util::checkParameters(['what', 'export_type']);
|
||||
|
||||
// sanitize this parameter which will be used below in a file inclusion
|
||||
$what = Core::securePath($_POST['what']);
|
||||
|
||||
// export class instance, not array of properties, as before
|
||||
/* @var $export_plugin ExportPlugin */
|
||||
/** @var ExportPlugin $export_plugin */
|
||||
$export_plugin = Plugins::getPlugin(
|
||||
"export",
|
||||
$what,
|
||||
'libraries/classes/Plugins/Export/',
|
||||
array(
|
||||
[
|
||||
'export_type' => $export_type,
|
||||
'single_table' => isset($single_table)
|
||||
)
|
||||
'single_table' => isset($single_table),
|
||||
]
|
||||
);
|
||||
|
||||
// Check export type
|
||||
@ -199,15 +217,15 @@ if (empty($export_plugin)) {
|
||||
/**
|
||||
* valid compression methods
|
||||
*/
|
||||
$compression_methods = array(
|
||||
$compression_methods = [
|
||||
'zip',
|
||||
'gzip'
|
||||
);
|
||||
'gzip',
|
||||
];
|
||||
|
||||
/**
|
||||
* init and variable checking
|
||||
*/
|
||||
$compression = false;
|
||||
$compression = '';
|
||||
$onserver = false;
|
||||
$save_on_server = false;
|
||||
$buffer_needed = false;
|
||||
@ -266,25 +284,29 @@ if ($_POST['output_format'] == 'astext') {
|
||||
if (isset($_POST['output_format']) && $_POST['output_format'] == 'sendit' && ! $save_on_server) {
|
||||
$response->disable();
|
||||
//Disable all active buffers (see: ob_get_status(true) at this point)
|
||||
while (@ob_end_clean());
|
||||
do {
|
||||
$hasBuffer = @ob_end_clean();
|
||||
} while ($hasBuffer);
|
||||
}
|
||||
|
||||
$tables = [];
|
||||
// Generate error url and check for needed variables
|
||||
if ($export_type == 'server') {
|
||||
$err_url = 'server_export.php' . Url::getCommon();
|
||||
} elseif ($export_type == 'database' && strlen($db) > 0) {
|
||||
$err_url = 'db_export.php' . Url::getCommon(array('db' => $db));
|
||||
$err_url = 'db_export.php' . Url::getCommon(['db' => $db]);
|
||||
// Check if we have something to export
|
||||
if (isset($table_select)) {
|
||||
$tables = $table_select;
|
||||
} else {
|
||||
$tables = array();
|
||||
$tables = [];
|
||||
}
|
||||
} elseif ($export_type == 'table' && strlen($db) > 0 && strlen($table) > 0) {
|
||||
$err_url = 'tbl_export.php' . Url::getCommon(
|
||||
array(
|
||||
'db' => $db, 'table' => $table
|
||||
)
|
||||
[
|
||||
'db' => $db,
|
||||
'table' => $table,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
Core::fatalError(__('Bad parameters!'));
|
||||
@ -293,15 +315,15 @@ if ($export_type == 'server') {
|
||||
// Merge SQL Query aliases with Export aliases from
|
||||
// export page, Export page aliases are given more
|
||||
// preference over SQL Query aliases.
|
||||
$parser = new \PhpMyAdmin\SqlParser\Parser($sql_query);
|
||||
$aliases = array();
|
||||
if ((!empty($parser->statements[0]))
|
||||
&& ($parser->statements[0] instanceof \PhpMyAdmin\SqlParser\Statements\SelectStatement)
|
||||
$parser = new Parser($sql_query);
|
||||
$aliases = [];
|
||||
if (! empty($parser->statements[0])
|
||||
&& ($parser->statements[0] instanceof SelectStatement)
|
||||
) {
|
||||
$aliases = \PhpMyAdmin\SqlParser\Utils\Misc::getAliases($parser->statements[0], $db);
|
||||
$aliases = Misc::getAliases($parser->statements[0], $db);
|
||||
}
|
||||
if (!empty($_POST['aliases'])) {
|
||||
$aliases = Export::mergeAliases($aliases, $_POST['aliases']);
|
||||
if (! empty($_POST['aliases'])) {
|
||||
$aliases = $export->mergeAliases($aliases, $_POST['aliases']);
|
||||
$_SESSION['tmpval']['aliases'] = $_POST['aliases'];
|
||||
}
|
||||
|
||||
@ -312,13 +334,13 @@ Util::setTimeLimit();
|
||||
if (! empty($cfg['MemoryLimit'])) {
|
||||
ini_set('memory_limit', $cfg['MemoryLimit']);
|
||||
}
|
||||
register_shutdown_function('PhpMyAdmin\Export::shutdown');
|
||||
register_shutdown_function([$export, 'shutdown']);
|
||||
// Start with empty buffer
|
||||
$dump_buffer = '';
|
||||
$dump_buffer_len = 0;
|
||||
|
||||
// Array of dump_buffers - used in separate file exports
|
||||
$dump_buffer_objects = array();
|
||||
$dump_buffer_objects = [];
|
||||
|
||||
// We send fake headers to avoid browser timeout when buffering
|
||||
$time_start = time();
|
||||
@ -342,7 +364,7 @@ $output_charset_conversion = $asfile
|
||||
$GLOBALS['onfly_compression'] = $GLOBALS['cfg']['CompressOnFly']
|
||||
&& $compression == 'gzip';
|
||||
if ($GLOBALS['onfly_compression']) {
|
||||
$GLOBALS['memory_limit'] = Export::getMemoryLimit();
|
||||
$GLOBALS['memory_limit'] = $export->getMemoryLimit();
|
||||
}
|
||||
|
||||
// Generate filename and mime type if needed
|
||||
@ -350,8 +372,11 @@ if ($asfile) {
|
||||
if (empty($remember_template)) {
|
||||
$remember_template = '';
|
||||
}
|
||||
list($filename, $mime_type) = Export::getFilenameAndMimetype(
|
||||
$export_type, $remember_template, $export_plugin, $compression,
|
||||
list($filename, $mime_type) = $export->getFilenameAndMimetype(
|
||||
$export_type,
|
||||
$remember_template,
|
||||
$export_plugin,
|
||||
$compression,
|
||||
$filename_template
|
||||
);
|
||||
} else {
|
||||
@ -360,13 +385,14 @@ if ($asfile) {
|
||||
|
||||
// Open file on server if needed
|
||||
if ($save_on_server) {
|
||||
list($save_filename, $message, $file_handle) = Export::openFile(
|
||||
$filename, $quick_export
|
||||
list($save_filename, $message, $file_handle) = $export->openFile(
|
||||
$filename,
|
||||
$quick_export
|
||||
);
|
||||
|
||||
// problem opening export file on server?
|
||||
if (! empty($message)) {
|
||||
Export::showPage($db, $table, $export_type);
|
||||
$export->showPage($db, $table, $export_type);
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
@ -385,24 +411,27 @@ if ($save_on_server) {
|
||||
// HTML
|
||||
if ($export_type == 'database') {
|
||||
$num_tables = count($tables);
|
||||
if ($num_tables == 0) {
|
||||
if ($num_tables === 0) {
|
||||
$message = PhpMyAdmin\Message::error(
|
||||
__('No tables found in database.')
|
||||
);
|
||||
$active_page = 'db_export.php';
|
||||
include 'db_export.php';
|
||||
exit();
|
||||
include ROOT_PATH . 'db_export.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
list($html, $back_button, $refreshButton) = Export::getHtmlForDisplayedExportHeader(
|
||||
$export_type, $db, $table
|
||||
list($html, $back_button, $refreshButton) = $export->getHtmlForDisplayedExportHeader(
|
||||
$export_type,
|
||||
$db,
|
||||
$table
|
||||
);
|
||||
echo $html;
|
||||
unset($html);
|
||||
} // end download
|
||||
}
|
||||
|
||||
$relation = new Relation();
|
||||
/** @var Relation $relation */
|
||||
$relation = $containerBuilder->get('relation');
|
||||
|
||||
// Fake loop just to allow skip of remain of this code by break, I'd really
|
||||
// need exceptions here :-)
|
||||
@ -437,39 +466,71 @@ do {
|
||||
if (! isset($db_select)) {
|
||||
$db_select = '';
|
||||
}
|
||||
Export::exportServer(
|
||||
$db_select, $whatStrucOrData, $export_plugin, $crlf, $err_url,
|
||||
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
|
||||
$aliases, $separate_files
|
||||
$export->exportServer(
|
||||
$db_select,
|
||||
$whatStrucOrData,
|
||||
$export_plugin,
|
||||
$crlf,
|
||||
$err_url,
|
||||
$export_type,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
$do_mime,
|
||||
$do_dates,
|
||||
$aliases,
|
||||
$separate_files
|
||||
);
|
||||
} elseif ($export_type == 'database') {
|
||||
if (!isset($table_structure) || !is_array($table_structure)) {
|
||||
$table_structure = array();
|
||||
if (! isset($table_structure) || ! is_array($table_structure)) {
|
||||
$table_structure = [];
|
||||
}
|
||||
if (!isset($table_data) || !is_array($table_data)) {
|
||||
$table_data = array();
|
||||
if (! isset($table_data) || ! is_array($table_data)) {
|
||||
$table_data = [];
|
||||
}
|
||||
if (!empty($_POST['structure_or_data_forced'])) {
|
||||
if (! empty($_POST['structure_or_data_forced'])) {
|
||||
$table_structure = $tables;
|
||||
$table_data = $tables;
|
||||
}
|
||||
if (isset($lock_tables)) {
|
||||
Export::lockTables($db, $tables, "READ");
|
||||
$export->lockTables($db, $tables, "READ");
|
||||
try {
|
||||
Export::exportDatabase(
|
||||
$db, $tables, $whatStrucOrData, $table_structure,
|
||||
$table_data, $export_plugin, $crlf, $err_url, $export_type,
|
||||
$do_relation, $do_comments, $do_mime, $do_dates, $aliases,
|
||||
$export->exportDatabase(
|
||||
$db,
|
||||
$tables,
|
||||
$whatStrucOrData,
|
||||
$table_structure,
|
||||
$table_data,
|
||||
$export_plugin,
|
||||
$crlf,
|
||||
$err_url,
|
||||
$export_type,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
$do_mime,
|
||||
$do_dates,
|
||||
$aliases,
|
||||
$separate_files
|
||||
);
|
||||
} finally {
|
||||
Export::unlockTables();
|
||||
$export->unlockTables();
|
||||
}
|
||||
} else {
|
||||
Export::exportDatabase(
|
||||
$db, $tables, $whatStrucOrData, $table_structure, $table_data,
|
||||
$export_plugin, $crlf, $err_url, $export_type, $do_relation,
|
||||
$do_comments, $do_mime, $do_dates, $aliases, $separate_files
|
||||
$export->exportDatabase(
|
||||
$db,
|
||||
$tables,
|
||||
$whatStrucOrData,
|
||||
$table_structure,
|
||||
$table_data,
|
||||
$export_plugin,
|
||||
$crlf,
|
||||
$err_url,
|
||||
$export_type,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
$do_mime,
|
||||
$do_dates,
|
||||
$aliases,
|
||||
$separate_files
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -479,47 +540,71 @@ do {
|
||||
$allrows = '';
|
||||
}
|
||||
if (! isset($limit_to)) {
|
||||
$limit_to = 0;
|
||||
$limit_to = '0';
|
||||
}
|
||||
if (! isset($limit_from)) {
|
||||
$limit_from = 0;
|
||||
$limit_from = '0';
|
||||
}
|
||||
if (isset($lock_tables)) {
|
||||
try {
|
||||
Export::lockTables($db, array($table), "READ");
|
||||
Export::exportTable(
|
||||
$db, $table, $whatStrucOrData, $export_plugin, $crlf,
|
||||
$err_url, $export_type, $do_relation, $do_comments,
|
||||
$do_mime, $do_dates, $allrows, $limit_to, $limit_from,
|
||||
$sql_query, $aliases
|
||||
$export->lockTables($db, [$table], "READ");
|
||||
$export->exportTable(
|
||||
$db,
|
||||
$table,
|
||||
$whatStrucOrData,
|
||||
$export_plugin,
|
||||
$crlf,
|
||||
$err_url,
|
||||
$export_type,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
$do_mime,
|
||||
$do_dates,
|
||||
$allrows,
|
||||
$limit_to,
|
||||
$limit_from,
|
||||
$sql_query,
|
||||
$aliases
|
||||
);
|
||||
} finally {
|
||||
Export::unlockTables();
|
||||
$export->unlockTables();
|
||||
}
|
||||
} else {
|
||||
Export::exportTable(
|
||||
$db, $table, $whatStrucOrData, $export_plugin, $crlf, $err_url,
|
||||
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
|
||||
$allrows, $limit_to, $limit_from, $sql_query, $aliases
|
||||
$export->exportTable(
|
||||
$db,
|
||||
$table,
|
||||
$whatStrucOrData,
|
||||
$export_plugin,
|
||||
$crlf,
|
||||
$err_url,
|
||||
$export_type,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
$do_mime,
|
||||
$do_dates,
|
||||
$allrows,
|
||||
$limit_to,
|
||||
$limit_from,
|
||||
$sql_query,
|
||||
$aliases
|
||||
);
|
||||
}
|
||||
}
|
||||
if (! $export_plugin->exportFooter()) {
|
||||
break;
|
||||
}
|
||||
|
||||
} while (false);
|
||||
// End of fake loop
|
||||
|
||||
if ($save_on_server && ! empty($message)) {
|
||||
Export::showPage($db, $table, $export_type);
|
||||
$export->showPage($db, $table, $export_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the dump as a file...
|
||||
*/
|
||||
if (empty($asfile)) {
|
||||
echo Export::getHtmlForDisplayedExportFooter($back_button, $refreshButton);
|
||||
echo $export->getHtmlForDisplayedExportFooter($back_button, $refreshButton);
|
||||
return;
|
||||
} // end if
|
||||
|
||||
@ -535,21 +620,24 @@ if ($output_charset_conversion) {
|
||||
// Compression needed?
|
||||
if ($compression) {
|
||||
if (! empty($separate_files)) {
|
||||
$dump_buffer = Export::compress(
|
||||
$dump_buffer_objects, $compression, $filename
|
||||
$dump_buffer = $export->compress(
|
||||
$dump_buffer_objects,
|
||||
$compression,
|
||||
$filename
|
||||
);
|
||||
} else {
|
||||
$dump_buffer = Export::compress($dump_buffer, $compression, $filename);
|
||||
$dump_buffer = $export->compress($dump_buffer, $compression, $filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* If we saved on server, we have to close file now */
|
||||
if ($save_on_server) {
|
||||
$message = Export::closeFile(
|
||||
$file_handle, $dump_buffer, $save_filename
|
||||
$message = $export->closeFile(
|
||||
$file_handle,
|
||||
$dump_buffer,
|
||||
$save_filename
|
||||
);
|
||||
Export::showPage($db, $table, $export_type);
|
||||
$export->showPage($db, $table, $export_type);
|
||||
} else {
|
||||
echo $dump_buffer;
|
||||
}
|
||||
|
||||
@ -5,47 +5,43 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Gis\GisFactory;
|
||||
use PhpMyAdmin\Gis\GisVisualization;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Escapes special characters if the variable is set.
|
||||
* Returns an empty string otherwise.
|
||||
*
|
||||
* @param string $variable variable to be escaped
|
||||
*
|
||||
* @return string escaped variable
|
||||
*/
|
||||
function escape($variable)
|
||||
{
|
||||
return isset($variable) ? htmlspecialchars($variable) : '';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
|
||||
if (! isset($_POST['field'])) {
|
||||
PhpMyAdmin\Util::checkParameters(array('field'));
|
||||
Util::checkParameters(['field']);
|
||||
}
|
||||
|
||||
// Get data if any posted
|
||||
$gis_data = array();
|
||||
$gis_data = [];
|
||||
if (Core::isValid($_POST['gis_data'], 'array')) {
|
||||
$gis_data = $_POST['gis_data'];
|
||||
}
|
||||
|
||||
$gis_types = array(
|
||||
$gis_types = [
|
||||
'POINT',
|
||||
'MULTIPOINT',
|
||||
'LINESTRING',
|
||||
'MULTILINESTRING',
|
||||
'POLYGON',
|
||||
'MULTIPOLYGON',
|
||||
'GEOMETRYCOLLECTION'
|
||||
);
|
||||
'GEOMETRYCOLLECTION',
|
||||
];
|
||||
|
||||
// Extract type from the initial call and make sure that it's a valid one.
|
||||
// Extract from field's values if available, if not use the column type passed.
|
||||
@ -61,37 +57,42 @@ if (! isset($gis_data['gis_type'])) {
|
||||
mb_strpos($_POST['value'], "(") - $start
|
||||
);
|
||||
}
|
||||
if ((! isset($gis_data['gis_type']))
|
||||
if (! isset($gis_data['gis_type'])
|
||||
|| (! in_array($gis_data['gis_type'], $gis_types))
|
||||
) {
|
||||
$gis_data['gis_type'] = $gis_types[0];
|
||||
}
|
||||
}
|
||||
$geom_type = htmlspecialchars($gis_data['gis_type']);
|
||||
$geom_type = $gis_data['gis_type'];
|
||||
|
||||
// Generate parameters from value passed.
|
||||
$gis_obj = GisFactory::factory($geom_type);
|
||||
if (isset($_POST['value'])) {
|
||||
$gis_data = array_merge(
|
||||
$gis_data, $gis_obj->generateParams($_POST['value'])
|
||||
$gis_data,
|
||||
$gis_obj->generateParams($_POST['value'])
|
||||
);
|
||||
}
|
||||
|
||||
// Generate Well Known Text
|
||||
$srid = (isset($gis_data['srid']) && $gis_data['srid'] != '')
|
||||
? htmlspecialchars($gis_data['srid']) : 0;
|
||||
$srid = (isset($gis_data['srid']) && $gis_data['srid'] != '') ? $gis_data['srid'] : 0;
|
||||
$wkt = $gis_obj->generateWkt($gis_data, 0);
|
||||
$wkt_with_zero = $gis_obj->generateWkt($gis_data, 0, '0');
|
||||
$result = "'" . $wkt . "'," . $srid;
|
||||
|
||||
// Generate SVG based visualization
|
||||
$visualizationSettings = array(
|
||||
$visualizationSettings = [
|
||||
'width' => 450,
|
||||
'height' => 300,
|
||||
'spatialColumn' => 'wkt',
|
||||
'mysqlVersion' => $GLOBALS['dbi']->getVersion()
|
||||
);
|
||||
$data = array(array('wkt' => $wkt_with_zero, 'srid' => $srid));
|
||||
'mysqlVersion' => $GLOBALS['dbi']->getVersion(),
|
||||
];
|
||||
$data = [
|
||||
[
|
||||
'wkt' => $wkt_with_zero,
|
||||
'srid' => $srid,
|
||||
],
|
||||
];
|
||||
$visualization = GisVisualization::getByData($data, $visualizationSettings)
|
||||
->toImage('svg');
|
||||
|
||||
@ -100,337 +101,38 @@ $open_layers = GisVisualization::getByData($data, $visualizationSettings)
|
||||
|
||||
// If the call is to update the WKT and visualization make an AJAX response
|
||||
if (isset($_POST['generate']) && $_POST['generate'] == true) {
|
||||
$extra_data = array(
|
||||
$extra_data = [
|
||||
'result' => $result,
|
||||
'visualization' => $visualization,
|
||||
'openLayers' => $open_layers,
|
||||
);
|
||||
];
|
||||
$response = Response::getInstance();
|
||||
$response->addJSON($extra_data);
|
||||
exit;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
echo '<form id="gis_data_editor_form" action="gis_data_editor.php" method="post">';
|
||||
echo '<input type="hidden" id="pmaThemeImage"'
|
||||
, ' value="' , $GLOBALS['pmaThemeImage'] , '" />';
|
||||
echo '<div id="gis_data_editor">';
|
||||
|
||||
echo '<h3>';
|
||||
printf(
|
||||
__('Value for the column "%s"'),
|
||||
htmlspecialchars($_POST['field'])
|
||||
);
|
||||
echo '</h3>';
|
||||
|
||||
echo '<input type="hidden" name="field" value="'
|
||||
, htmlspecialchars($_POST['field']) , '" />';
|
||||
// The input field to which the final result should be added
|
||||
// and corresponding null checkbox
|
||||
if (isset($_POST['input_name'])) {
|
||||
echo '<input type="hidden" name="input_name" value="'
|
||||
, htmlspecialchars($_POST['input_name']) , '" />';
|
||||
}
|
||||
echo Url::getHiddenInputs();
|
||||
|
||||
echo '<!-- Visualization section -->';
|
||||
echo '<div id="placeholder"'
|
||||
, ($srid != 0 ? 'class="hide"' : '') , '>';
|
||||
echo $visualization;
|
||||
echo '</div>';
|
||||
|
||||
// No not remove inline style or it will cause "Cannot read property 'w' of null" on GIS editor map init
|
||||
echo '<div id="openlayersmap" style="width: ' . $visualizationSettings['width'] . 'px; height: ' . $visualizationSettings['height'] . 'px;" '
|
||||
, ($srid == 0 ? 'class="hide"' : '') , '>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="choice floatright">';
|
||||
echo '<input type="checkbox" id="choice" value="useBaseLayer"'
|
||||
, ($srid != 0 ? ' checked="checked"' : '') , '/>';
|
||||
echo '<label for="choice">' , __("Use OpenStreetMaps as Base Layer") , '</label>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<script language="javascript" type="text/javascript">';
|
||||
echo $open_layers;
|
||||
echo '</script>';
|
||||
echo '<!-- End of visualization section -->';
|
||||
|
||||
|
||||
echo '<!-- Header section - Inclueds GIS type selector and input field for SRID -->';
|
||||
echo '<div id="gis_data_header">';
|
||||
echo '<select name="gis_data[gis_type]" class="gis_type">';
|
||||
foreach ($gis_types as $gis_type) {
|
||||
echo '<option value="' , $gis_type , '"';
|
||||
if ($geom_type == $gis_type) {
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' , $gis_type , '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo ' ';
|
||||
/* l10n: Spatial Reference System Identifier */
|
||||
echo '<label for="srid">' , __('SRID:') , '</label>';
|
||||
echo '<input name="gis_data[srid]" type="text" value="' , $srid , '" />';
|
||||
echo '</div>';
|
||||
echo '<!-- End of header section -->';
|
||||
|
||||
echo '<!-- Data section -->';
|
||||
echo '<div id="gis_data">';
|
||||
|
||||
$geom_count = 1;
|
||||
if ($geom_type == 'GEOMETRYCOLLECTION') {
|
||||
$geom_count = (isset($gis_data[$geom_type]['geom_count']))
|
||||
$geom_count = isset($gis_data[$geom_type]['geom_count'])
|
||||
? intval($gis_data[$geom_type]['geom_count']) : 1;
|
||||
if (isset($gis_data[$geom_type]['add_geom'])) {
|
||||
$geom_count++;
|
||||
}
|
||||
echo '<input type="hidden" name="gis_data[GEOMETRYCOLLECTION][geom_count]"'
|
||||
, ' value="' , $geom_count , '" />';
|
||||
}
|
||||
|
||||
for ($a = 0; $a < $geom_count; $a++) {
|
||||
if (! isset($gis_data[$a])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($geom_type == 'GEOMETRYCOLLECTION') {
|
||||
echo '<br/><br/>';
|
||||
printf(__('Geometry %d:'), $a + 1);
|
||||
echo '<br/>';
|
||||
if (isset($gis_data[$a]['gis_type'])) {
|
||||
$type = htmlspecialchars($gis_data[$a]['gis_type']);
|
||||
} else {
|
||||
$type = $gis_types[0];
|
||||
}
|
||||
echo '<select name="gis_data[' , $a , '][gis_type]" class="gis_type">';
|
||||
foreach (array_slice($gis_types, 0, 6) as $gis_type) {
|
||||
echo '<option value="' , $gis_type , '"';
|
||||
if ($type == $gis_type) {
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' , $gis_type , '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
} else {
|
||||
$type = $geom_type;
|
||||
}
|
||||
|
||||
if ($type == 'POINT') {
|
||||
echo '<br/>';
|
||||
echo __('Point:');
|
||||
echo '<label for="x">' , __("X") , '</label>';
|
||||
echo '<input name="gis_data[' , $a , '][POINT][x]" type="text"'
|
||||
, ' value="' , escape($gis_data[$a]['POINT']['x']) , '" />';
|
||||
echo '<label for="y">' , __("Y") , '</label>';
|
||||
echo '<input name="gis_data[' , $a , '][POINT][y]" type="text"'
|
||||
, ' value="' , escape($gis_data[$a]['POINT']['y']) , '" />';
|
||||
|
||||
} elseif ($type == 'MULTIPOINT' || $type == 'LINESTRING') {
|
||||
$no_of_points = isset($gis_data[$a][$type]['no_of_points'])
|
||||
? intval($gis_data[$a][$type]['no_of_points']) : 1;
|
||||
if ($type == 'LINESTRING' && $no_of_points < 2) {
|
||||
$no_of_points = 2;
|
||||
}
|
||||
if ($type == 'MULTIPOINT' && $no_of_points < 1) {
|
||||
$no_of_points = 1;
|
||||
}
|
||||
|
||||
if (isset($gis_data[$a][$type]['add_point'])) {
|
||||
$no_of_points++;
|
||||
}
|
||||
echo '<input type="hidden" value="' , $no_of_points , '"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][no_of_points]" />';
|
||||
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
echo '<br/>';
|
||||
printf(__('Point %d'), $i + 1);
|
||||
echo ': ';
|
||||
echo '<label for="x">' , __("X") , '</label>';
|
||||
echo '<input type="text"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $i , '][x]"'
|
||||
, ' value="' , escape($gis_data[$a][$type][$i]['x']) , '" />';
|
||||
echo '<label for="y">' , __("Y") , '</label>';
|
||||
echo '<input type="text"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $i , '][y]"'
|
||||
, ' value="' , escape($gis_data[$a][$type][$i]['y']) , '" />';
|
||||
}
|
||||
echo '<input type="submit"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][add_point]"'
|
||||
, ' class="add addPoint" value="' , __("Add a point") , '" />';
|
||||
|
||||
} elseif ($type == 'MULTILINESTRING' || $type == 'POLYGON') {
|
||||
$no_of_lines = isset($gis_data[$a][$type]['no_of_lines'])
|
||||
? intval($gis_data[$a][$type]['no_of_lines']) : 1;
|
||||
if ($no_of_lines < 1) {
|
||||
$no_of_lines = 1;
|
||||
}
|
||||
if (isset($gis_data[$a][$type]['add_line'])) {
|
||||
$no_of_lines++;
|
||||
}
|
||||
echo '<input type="hidden" value="' , $no_of_lines , '"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][no_of_lines]" />';
|
||||
|
||||
for ($i = 0; $i < $no_of_lines; $i++) {
|
||||
echo '<br/>';
|
||||
if ($type == 'MULTILINESTRING') {
|
||||
printf(__('Linestring %d:'), $i + 1);
|
||||
} else {
|
||||
if ($i == 0) {
|
||||
echo __('Outer ring:');
|
||||
} else {
|
||||
printf(__('Inner ring %d:'), $i);
|
||||
}
|
||||
}
|
||||
|
||||
$no_of_points = isset($gis_data[$a][$type][$i]['no_of_points'])
|
||||
? intval($gis_data[$a][$type][$i]['no_of_points']) : 2;
|
||||
if ($type == 'MULTILINESTRING' && $no_of_points < 2) {
|
||||
$no_of_points = 2;
|
||||
}
|
||||
if ($type == 'POLYGON' && $no_of_points < 4) {
|
||||
$no_of_points = 4;
|
||||
}
|
||||
if (isset($gis_data[$a][$type][$i]['add_point'])) {
|
||||
$no_of_points++;
|
||||
}
|
||||
echo '<input type="hidden" value="' , $no_of_points , '"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $i
|
||||
, '][no_of_points]" />';
|
||||
|
||||
for ($j = 0; $j < $no_of_points; $j++) {
|
||||
echo('<br/>');
|
||||
printf(__('Point %d'), $j + 1);
|
||||
echo ': ';
|
||||
echo '<label for="x">' , __("X") , '</label>';
|
||||
echo '<input type="text" name="gis_data[' , $a , '][' , $type . ']['
|
||||
, $i , '][' , $j , '][x]" value="'
|
||||
, escape($gis_data[$a][$type][$i][$j]['x']) , '" />';
|
||||
echo '<label for="y">' , __("Y") , '</label>';
|
||||
echo '<input type="text" name="gis_data[' , $a , '][' , $type , ']['
|
||||
, $i , '][' , $j , '][y]"' , ' value="'
|
||||
, escape($gis_data[$a][$type][$i][$j]['y']) , '" />';
|
||||
}
|
||||
echo '<input type="submit" name="gis_data[' , $a , '][' , $type , ']['
|
||||
, $i , '][add_point]"'
|
||||
, ' class="add addPoint" value="' , __("Add a point") , '" />';
|
||||
}
|
||||
$caption = ($type == 'MULTILINESTRING')
|
||||
? __('Add a linestring')
|
||||
: __('Add an inner ring');
|
||||
echo '<br/>';
|
||||
echo '<input type="submit"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][add_line]"'
|
||||
, ' class="add addLine" value="' , $caption , '" />';
|
||||
|
||||
} elseif ($type == 'MULTIPOLYGON') {
|
||||
$no_of_polygons = isset($gis_data[$a][$type]['no_of_polygons'])
|
||||
? intval($gis_data[$a][$type]['no_of_polygons']) : 1;
|
||||
if ($no_of_polygons < 1) {
|
||||
$no_of_polygons = 1;
|
||||
}
|
||||
if (isset($gis_data[$a][$type]['add_polygon'])) {
|
||||
$no_of_polygons++;
|
||||
}
|
||||
echo '<input type="hidden"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][no_of_polygons]"'
|
||||
, ' value="' , $no_of_polygons , '" />';
|
||||
|
||||
for ($k = 0; $k < $no_of_polygons; $k++) {
|
||||
echo '<br/>';
|
||||
printf(__('Polygon %d:'), $k + 1);
|
||||
$no_of_lines = isset($gis_data[$a][$type][$k]['no_of_lines'])
|
||||
? intval($gis_data[$a][$type][$k]['no_of_lines']) : 1;
|
||||
if ($no_of_lines < 1) {
|
||||
$no_of_lines = 1;
|
||||
}
|
||||
if (isset($gis_data[$a][$type][$k]['add_line'])) {
|
||||
$no_of_lines++;
|
||||
}
|
||||
echo '<input type="hidden"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $k
|
||||
, '][no_of_lines]"' , ' value="' , $no_of_lines , '" />';
|
||||
|
||||
for ($i = 0; $i < $no_of_lines; $i++) {
|
||||
echo '<br/><br/>';
|
||||
if ($i == 0) {
|
||||
echo __('Outer ring:');
|
||||
} else {
|
||||
printf(__('Inner ring %d:'), $i);
|
||||
}
|
||||
|
||||
$no_of_points = isset($gis_data[$a][$type][$k][$i]['no_of_points'])
|
||||
? intval($gis_data[$a][$type][$k][$i]['no_of_points']) : 4;
|
||||
if ($no_of_points < 4) {
|
||||
$no_of_points = 4;
|
||||
}
|
||||
if (isset($gis_data[$a][$type][$k][$i]['add_point'])) {
|
||||
$no_of_points++;
|
||||
}
|
||||
echo '<input type="hidden"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $k , '][' , $i
|
||||
, '][no_of_points]"' , ' value="' , $no_of_points , '" />';
|
||||
|
||||
for ($j = 0; $j < $no_of_points; $j++) {
|
||||
echo '<br/>';
|
||||
printf(__('Point %d'), $j + 1);
|
||||
echo ': ';
|
||||
echo '<label for="x">' , __("X") , '</label>';
|
||||
echo '<input type="text"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $k , ']['
|
||||
, $i , '][' , $j , '][x]"'
|
||||
, ' value="' , escape($gis_data[$a][$type][$k][$i][$j]['x'])
|
||||
, '" />';
|
||||
echo '<label for="y">' , __("Y") , '</label>';
|
||||
echo '<input type="text"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $k , ']['
|
||||
, $i , '][' , $j , '][y]"'
|
||||
, ' value="' , escape($gis_data[$a][$type][$k][$i][$j]['y'])
|
||||
, '" />';
|
||||
}
|
||||
echo '<input type="submit"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $k , '][' , $i
|
||||
, '][add_point]"'
|
||||
, ' class="add addPoint" value="' , __("Add a point") , '" />';
|
||||
}
|
||||
echo '<br/>';
|
||||
echo '<input type="submit"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][' , $k , '][add_line]"'
|
||||
, ' class="add addLine" value="' , __('Add an inner ring') , '" />';
|
||||
echo '<br/>';
|
||||
}
|
||||
echo '<br/>';
|
||||
echo '<input type="submit"'
|
||||
, ' name="gis_data[' , $a , '][' , $type , '][add_polygon]"'
|
||||
, ' class="add addPolygon" value="' , __('Add a polygon') , '" />';
|
||||
}
|
||||
}
|
||||
if ($geom_type == 'GEOMETRYCOLLECTION') {
|
||||
echo '<br/><br/>';
|
||||
echo '<input type="submit" name="gis_data[GEOMETRYCOLLECTION][add_geom]"'
|
||||
, 'class="add addGeom" value="' , __("Add geometry") , '" />';
|
||||
}
|
||||
echo '</div>';
|
||||
echo '<!-- End of data section -->';
|
||||
|
||||
echo '<br/>';
|
||||
echo '<input type="submit" name="gis_data[save]" value="' , __('Go') , '" />';
|
||||
|
||||
echo '<div id="gis_data_output">';
|
||||
echo '<h3>' , __('Output') , '</h3>';
|
||||
echo '<p>';
|
||||
echo __(
|
||||
'Choose "ST_GeomFromText" from the "Function" column and paste the'
|
||||
. ' string below into the "Value" field.'
|
||||
);
|
||||
echo '</p>';
|
||||
echo '<textarea id="gis_data_textarea" cols="95" rows="5">';
|
||||
echo htmlspecialchars($result);
|
||||
echo '</textarea>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
Response::getInstance()->addJSON('gis_editor', ob_get_contents());
|
||||
ob_end_clean();
|
||||
$templateOutput = $template->render('gis_data_editor_form', [
|
||||
'width' => $visualizationSettings['width'],
|
||||
'height' => $visualizationSettings['height'],
|
||||
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
|
||||
'field' => $_POST['field'],
|
||||
'input_name' => $_POST['input_name'],
|
||||
'srid' => $srid,
|
||||
'visualization' => $visualization,
|
||||
'open_layers' => $open_layers,
|
||||
'gis_types' => $gis_types,
|
||||
'geom_type' => $geom_type,
|
||||
'geom_count' => $geom_count,
|
||||
'gis_data' => $gis_data,
|
||||
'result' => $result,
|
||||
]);
|
||||
Response::getInstance()->addJSON('gis_editor', $templateOutput);
|
||||
|
||||
319
import.php
319
import.php
@ -5,9 +5,11 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Bookmark;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Import;
|
||||
@ -19,15 +21,27 @@ use PhpMyAdmin\Sql;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/* Enable LOAD DATA LOCAL INFILE for LDI plugin */
|
||||
if (isset($_POST['format']) && $_POST['format'] == 'ldi') {
|
||||
define('PMA_ENABLE_LDI', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the variables sent or posted to this script and a core script
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
global $db, $pmaThemeImage, $table;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var import $import */
|
||||
$import = $containerBuilder->get('import');
|
||||
|
||||
if (isset($_POST['show_as_php'])) {
|
||||
$GLOBALS['show_as_php'] = $_POST['show_as_php'];
|
||||
@ -35,18 +49,17 @@ if (isset($_POST['show_as_php'])) {
|
||||
|
||||
// If there is a request to 'Simulate DML'.
|
||||
if (isset($_POST['simulate_dml'])) {
|
||||
Import::handleSimulateDmlRequest();
|
||||
$import->handleSimulateDmlRequest();
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
|
||||
$sql = new Sql();
|
||||
|
||||
// If it's a refresh console bookmarks request
|
||||
if (isset($_GET['console_bookmark_refresh'])) {
|
||||
$response->addJSON(
|
||||
'console_message_bookmark', PhpMyAdmin\Console::getBookmarkContent()
|
||||
'console_message_bookmark',
|
||||
PhpMyAdmin\Console::getBookmarkContent()
|
||||
);
|
||||
exit;
|
||||
}
|
||||
@ -56,15 +69,15 @@ if (isset($_POST['console_bookmark_add'])) {
|
||||
&& isset($_POST['bookmark_query']) && isset($_POST['shared'])
|
||||
) {
|
||||
$cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
|
||||
$bookmarkFields = array(
|
||||
$bookmarkFields = [
|
||||
'bkm_database' => $_POST['db'],
|
||||
'bkm_user' => $cfgBookmark['user'],
|
||||
'bkm_sql_query' => $_POST['bookmark_query'],
|
||||
'bkm_label' => $_POST['label']
|
||||
);
|
||||
'bkm_label' => $_POST['label'],
|
||||
];
|
||||
$isShared = ($_POST['shared'] == 'true' ? true : false);
|
||||
$bookmark = Bookmark::createBookmark(
|
||||
$GLOBALS['dbi'],
|
||||
$dbi,
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$bookmarkFields,
|
||||
$isShared
|
||||
@ -88,7 +101,7 @@ $format = '';
|
||||
/**
|
||||
* Sets globals from $_POST
|
||||
*/
|
||||
$post_params = array(
|
||||
$post_params = [
|
||||
'charset_of_file',
|
||||
'format',
|
||||
'import_type',
|
||||
@ -97,8 +110,8 @@ $post_params = array(
|
||||
'message_to_show',
|
||||
'noplugin',
|
||||
'skip_queries',
|
||||
'local_import_file'
|
||||
);
|
||||
'local_import_file',
|
||||
];
|
||||
|
||||
foreach ($post_params as $one_post_param) {
|
||||
if (isset($_POST[$one_post_param])) {
|
||||
@ -114,15 +127,15 @@ $GLOBALS['reload'] = false;
|
||||
|
||||
// Use to identify current cycle is executing
|
||||
// a multiquery statement or stored routine
|
||||
if (!isset($_SESSION['is_multi_query'])) {
|
||||
if (! isset($_SESSION['is_multi_query'])) {
|
||||
$_SESSION['is_multi_query'] = false;
|
||||
}
|
||||
|
||||
$ajax_reload = array();
|
||||
$ajax_reload = [];
|
||||
$import_text = '';
|
||||
// Are we just executing plain query or sql file?
|
||||
// (eg. non import, but query box/window run)
|
||||
if (! empty($sql_query)) {
|
||||
|
||||
// apply values for parameters
|
||||
if (! empty($_POST['parameterized'])
|
||||
&& ! empty($_POST['parameters'])
|
||||
@ -134,13 +147,13 @@ if (! empty($sql_query)) {
|
||||
// making sure that :param does not apply values to :param1
|
||||
$sql_query = preg_replace(
|
||||
'/' . $quoted . '([^a-zA-Z0-9_])/',
|
||||
$GLOBALS['dbi']->escapeString($replacement) . '${1}',
|
||||
$dbi->escapeString($replacement) . '${1}',
|
||||
$sql_query
|
||||
);
|
||||
// for parameters the appear at the end of the string
|
||||
$sql_query = preg_replace(
|
||||
'/' . $quoted . '$/',
|
||||
$GLOBALS['dbi']->escapeString($replacement),
|
||||
$dbi->escapeString($replacement),
|
||||
$sql_query
|
||||
);
|
||||
}
|
||||
@ -154,7 +167,7 @@ if (! empty($sql_query)) {
|
||||
|
||||
// If there is a request to ROLLBACK when finished.
|
||||
if (isset($_POST['rollback_query'])) {
|
||||
Import::handleRollbackRequest($import_text);
|
||||
$import->handleRollbackRequest($import_text);
|
||||
}
|
||||
|
||||
// refresh navigation and main panels
|
||||
@ -199,7 +212,7 @@ if (! empty($sql_query)) {
|
||||
|
||||
// If we didn't get any parameters, either user called this directly, or
|
||||
// upload limit has been reached, let's assume the second possibility.
|
||||
if ($_POST == array() && $_GET == array()) {
|
||||
if ($_POST == [] && $_GET == []) {
|
||||
$message = PhpMyAdmin\Message::error(
|
||||
__(
|
||||
'You probably tried to upload a file that is too large. Please refer ' .
|
||||
@ -231,15 +244,15 @@ if (isset($_POST['console_message_id'])) {
|
||||
|
||||
if (! in_array(
|
||||
$format,
|
||||
array(
|
||||
[
|
||||
'csv',
|
||||
'ldi',
|
||||
'mediawiki',
|
||||
'ods',
|
||||
'shp',
|
||||
'sql',
|
||||
'xml'
|
||||
)
|
||||
'xml',
|
||||
]
|
||||
)
|
||||
) {
|
||||
// this should not happen for a normal user
|
||||
@ -247,25 +260,28 @@ if (! in_array(
|
||||
Core::fatalError('Incorrect format parameter');
|
||||
}
|
||||
|
||||
$post_patterns = array(
|
||||
$post_patterns = [
|
||||
'/^force_file_/',
|
||||
'/^' . $format . '_/'
|
||||
);
|
||||
'/^' . $format . '_/',
|
||||
];
|
||||
|
||||
Core::setPostAsGlobal($post_patterns);
|
||||
|
||||
// Check needed parameters
|
||||
PhpMyAdmin\Util::checkParameters(array('import_type', 'format'));
|
||||
PhpMyAdmin\Util::checkParameters(['import_type', 'format']);
|
||||
|
||||
// We don't want anything special in format
|
||||
$format = Core::securePath($format);
|
||||
|
||||
if (strlen($table) > 0 && strlen($db) > 0) {
|
||||
$urlparams = array('db' => $db, 'table' => $table);
|
||||
$urlparams = [
|
||||
'db' => $db,
|
||||
'table' => $table,
|
||||
];
|
||||
} elseif (strlen($db) > 0) {
|
||||
$urlparams = array('db' => $db);
|
||||
$urlparams = ['db' => $db];
|
||||
} else {
|
||||
$urlparams = array();
|
||||
$urlparams = [];
|
||||
}
|
||||
|
||||
// Create error and goto url
|
||||
@ -275,15 +291,13 @@ if ($import_type == 'table') {
|
||||
$goto = 'db_import.php';
|
||||
} elseif ($import_type == 'server') {
|
||||
$goto = 'server_import.php';
|
||||
} else {
|
||||
if (empty($goto) || !preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
|
||||
if (strlen($table) > 0 && strlen($db) > 0) {
|
||||
$goto = 'tbl_structure.php';
|
||||
} elseif (strlen($db) > 0) {
|
||||
$goto = 'db_structure.php';
|
||||
} else {
|
||||
$goto = 'server_sql.php';
|
||||
}
|
||||
} elseif (empty($goto) || ! preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
|
||||
if (strlen($table) > 0 && strlen($db) > 0) {
|
||||
$goto = 'tbl_structure.php';
|
||||
} elseif (strlen($db) > 0) {
|
||||
$goto = 'db_structure.php';
|
||||
} else {
|
||||
$goto = 'server_sql.php';
|
||||
}
|
||||
}
|
||||
$err_url = $goto . Url::getCommon($urlparams);
|
||||
@ -296,7 +310,7 @@ if (basename($_SERVER['SCRIPT_NAME']) === 'import.php') {
|
||||
|
||||
|
||||
if (strlen($db) > 0) {
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$dbi->selectDb($db);
|
||||
}
|
||||
|
||||
Util::setTimeLimit();
|
||||
@ -332,88 +346,88 @@ $msg = 'Sorry an unexpected error happened!';
|
||||
|
||||
// Bookmark Support: get a query back from bookmark if required
|
||||
if (! empty($_POST['id_bookmark'])) {
|
||||
$id_bookmark = (int)$_POST['id_bookmark'];
|
||||
$id_bookmark = (int) $_POST['id_bookmark'];
|
||||
switch ($_POST['action_bookmark']) {
|
||||
case 0: // bookmarked query that have to be run
|
||||
$bookmark = Bookmark::get(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$db,
|
||||
$id_bookmark,
|
||||
'id',
|
||||
isset($_POST['action_bookmark_all'])
|
||||
);
|
||||
|
||||
if (! empty($_POST['bookmark_variable'])) {
|
||||
$import_text = $bookmark->applyVariables(
|
||||
$_POST['bookmark_variable']
|
||||
case 0: // bookmarked query that have to be run
|
||||
$bookmark = Bookmark::get(
|
||||
$dbi,
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$db,
|
||||
$id_bookmark,
|
||||
'id',
|
||||
isset($_POST['action_bookmark_all'])
|
||||
);
|
||||
} else {
|
||||
$import_text = $bookmark->getQuery();
|
||||
}
|
||||
|
||||
// refresh navigation and main panels
|
||||
if (preg_match(
|
||||
'/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
|
||||
$import_text
|
||||
)) {
|
||||
$GLOBALS['reload'] = true;
|
||||
$ajax_reload['reload'] = true;
|
||||
}
|
||||
|
||||
// refresh navigation panel only
|
||||
if (preg_match(
|
||||
'/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
|
||||
$import_text
|
||||
)
|
||||
) {
|
||||
$ajax_reload['reload'] = true;
|
||||
}
|
||||
break;
|
||||
case 1: // bookmarked query that have to be displayed
|
||||
$bookmark = Bookmark::get(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$db,
|
||||
$id_bookmark
|
||||
);
|
||||
$import_text = $bookmark->getQuery();
|
||||
if ($response->isAjax()) {
|
||||
$message = PhpMyAdmin\Message::success(__('Showing bookmark'));
|
||||
$response->setRequestStatus($message->isSuccess());
|
||||
$response->addJSON('message', $message);
|
||||
$response->addJSON('sql_query', $import_text);
|
||||
$response->addJSON('action_bookmark', $_POST['action_bookmark']);
|
||||
exit;
|
||||
} else {
|
||||
$run_query = false;
|
||||
}
|
||||
break;
|
||||
case 2: // bookmarked query that have to be deleted
|
||||
$bookmark = Bookmark::get(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$db,
|
||||
$id_bookmark
|
||||
);
|
||||
if (! empty($bookmark)) {
|
||||
$bookmark->delete();
|
||||
if ($response->isAjax()) {
|
||||
$message = PhpMyAdmin\Message::success(
|
||||
__('The bookmark has been deleted.')
|
||||
if (! empty($_POST['bookmark_variable'])) {
|
||||
$import_text = $bookmark->applyVariables(
|
||||
$_POST['bookmark_variable']
|
||||
);
|
||||
} else {
|
||||
$import_text = $bookmark->getQuery();
|
||||
}
|
||||
|
||||
// refresh navigation and main panels
|
||||
if (preg_match(
|
||||
'/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
|
||||
$import_text
|
||||
)) {
|
||||
$GLOBALS['reload'] = true;
|
||||
$ajax_reload['reload'] = true;
|
||||
}
|
||||
|
||||
// refresh navigation panel only
|
||||
if (preg_match(
|
||||
'/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
|
||||
$import_text
|
||||
)
|
||||
) {
|
||||
$ajax_reload['reload'] = true;
|
||||
}
|
||||
break;
|
||||
case 1: // bookmarked query that have to be displayed
|
||||
$bookmark = Bookmark::get(
|
||||
$dbi,
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$db,
|
||||
$id_bookmark
|
||||
);
|
||||
$import_text = $bookmark->getQuery();
|
||||
if ($response->isAjax()) {
|
||||
$message = PhpMyAdmin\Message::success(__('Showing bookmark'));
|
||||
$response->setRequestStatus($message->isSuccess());
|
||||
$response->addJSON('message', $message);
|
||||
$response->addJSON('sql_query', $import_text);
|
||||
$response->addJSON('action_bookmark', $_POST['action_bookmark']);
|
||||
$response->addJSON('id_bookmark', $id_bookmark);
|
||||
exit;
|
||||
} else {
|
||||
$run_query = false;
|
||||
$error = true; // this is kind of hack to skip processing the query
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2: // bookmarked query that have to be deleted
|
||||
$bookmark = Bookmark::get(
|
||||
$dbi,
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$db,
|
||||
$id_bookmark
|
||||
);
|
||||
if (! empty($bookmark)) {
|
||||
$bookmark->delete();
|
||||
if ($response->isAjax()) {
|
||||
$message = PhpMyAdmin\Message::success(
|
||||
__('The bookmark has been deleted.')
|
||||
);
|
||||
$response->setRequestStatus($message->isSuccess());
|
||||
$response->addJSON('message', $message);
|
||||
$response->addJSON('action_bookmark', $_POST['action_bookmark']);
|
||||
$response->addJSON('id_bookmark', $id_bookmark);
|
||||
exit;
|
||||
} else {
|
||||
$run_query = false;
|
||||
$error = true; // this is kind of hack to skip processing the query
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
} // end bookmarks reading
|
||||
|
||||
@ -435,15 +449,15 @@ if ($memory_limit == -1) {
|
||||
}
|
||||
|
||||
// Calculate value of the limit
|
||||
$memoryUnit = mb_strtolower(substr($memory_limit, -1));
|
||||
$memoryUnit = mb_strtolower(substr((string) $memory_limit, -1));
|
||||
if ('m' == $memoryUnit) {
|
||||
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
|
||||
$memory_limit = (int) substr((string) $memory_limit, 0, -1) * 1024 * 1024;
|
||||
} elseif ('k' == $memoryUnit) {
|
||||
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
|
||||
$memory_limit = (int) substr((string) $memory_limit, 0, -1) * 1024;
|
||||
} elseif ('g' == $memoryUnit) {
|
||||
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
|
||||
$memory_limit = (int) substr((string) $memory_limit, 0, -1) * 1024 * 1024 * 1024;
|
||||
} else {
|
||||
$memory_limit = (int)$memory_limit;
|
||||
$memory_limit = (int) $memory_limit;
|
||||
}
|
||||
|
||||
// Just to be sure, there might be lot of memory needed for uncompression
|
||||
@ -452,9 +466,9 @@ $read_limit = $memory_limit / 8;
|
||||
// handle filenames
|
||||
if (isset($_FILES['import_file'])) {
|
||||
$import_file = $_FILES['import_file']['tmp_name'];
|
||||
$import_file_name = $_FILES['import_file']['name'];
|
||||
}
|
||||
if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
|
||||
|
||||
// sanitize $local_import_file as it comes from a POST
|
||||
$local_import_file = Core::securePath($local_import_file);
|
||||
|
||||
@ -469,7 +483,6 @@ if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
|
||||
if (@is_link($import_file)) {
|
||||
$import_file = 'none';
|
||||
}
|
||||
|
||||
} elseif (empty($import_file) || ! is_uploaded_file($import_file)) {
|
||||
$import_file = 'none';
|
||||
}
|
||||
@ -483,12 +496,12 @@ if ($import_file != 'none' && ! $error) {
|
||||
$import_handle = new File($import_file);
|
||||
$import_handle->checkUploadedFile();
|
||||
if ($import_handle->isError()) {
|
||||
Import::stop($import_handle->getError());
|
||||
$import->stop($import_handle->getError());
|
||||
}
|
||||
$import_handle->setDecompressContent(true);
|
||||
$import_handle->open();
|
||||
if ($import_handle->isError()) {
|
||||
Import::stop($import_handle->getError());
|
||||
$import->stop($import_handle->getError());
|
||||
}
|
||||
} elseif (! $error) {
|
||||
if (! isset($import_text) || empty($import_text)) {
|
||||
@ -499,7 +512,7 @@ if ($import_file != 'none' && ! $error) {
|
||||
'by your PHP configuration. See [doc@faq1-16]FAQ 1.16[/doc].'
|
||||
)
|
||||
);
|
||||
Import::stop($message);
|
||||
$import->stop($message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -512,7 +525,7 @@ if (Encoding::isSupported() && isset($charset_of_file)) {
|
||||
$charset_conversion = true;
|
||||
}
|
||||
} elseif (isset($charset_of_file) && $charset_of_file != 'utf-8') {
|
||||
$GLOBALS['dbi']->query('SET NAMES \'' . $charset_of_file . '\'');
|
||||
$dbi->query('SET NAMES \'' . $charset_of_file . '\'');
|
||||
// We can not show query in this case, it is in different charset
|
||||
$sql_query_disabled = true;
|
||||
$reset_charset = true;
|
||||
@ -522,7 +535,7 @@ if (Encoding::isSupported() && isset($charset_of_file)) {
|
||||
if (! $error && isset($_POST['skip'])) {
|
||||
$original_skip = $skip = intval($_POST['skip']);
|
||||
while ($skip > 0 && ! $finished) {
|
||||
Import::getNextChunk($skip < $read_limit ? $skip : $read_limit);
|
||||
$import->getNextChunk($skip < $read_limit ? $skip : $read_limit);
|
||||
// Disable read progressivity, otherwise we eat all memory!
|
||||
$read_multiply = 1;
|
||||
$skip -= $read_limit;
|
||||
@ -532,10 +545,15 @@ if (! $error && isset($_POST['skip'])) {
|
||||
|
||||
// This array contain the data like numberof valid sql queries in the statement
|
||||
// and complete valid sql statement (which affected for rows)
|
||||
$sql_data = array('valid_sql' => array(), 'valid_queries' => 0);
|
||||
$sql_data = [
|
||||
'valid_sql' => [],
|
||||
'valid_queries' => 0,
|
||||
];
|
||||
|
||||
if (! $error) {
|
||||
/* @var $import_plugin ImportPlugin */
|
||||
/**
|
||||
* @var ImportPlugin $import_plugin
|
||||
*/
|
||||
$import_plugin = Plugins::getPlugin(
|
||||
"import",
|
||||
$format,
|
||||
@ -546,11 +564,11 @@ if (! $error) {
|
||||
$message = PhpMyAdmin\Message::error(
|
||||
__('Could not load import plugins, please check your installation!')
|
||||
);
|
||||
Import::stop($message);
|
||||
$import->stop($message);
|
||||
} else {
|
||||
// Do the real import
|
||||
$default_fk_check = PhpMyAdmin\Util::handleDisableFKCheckInit();
|
||||
try {
|
||||
$default_fk_check = PhpMyAdmin\Util::handleDisableFKCheckInit();
|
||||
$import_plugin->doImport($sql_data);
|
||||
PhpMyAdmin\Util::handleDisableFKCheckCleanup($default_fk_check);
|
||||
} catch (Exception $e) {
|
||||
@ -571,8 +589,8 @@ if ($file_to_unlink != '') {
|
||||
|
||||
// Reset charset back, if we did some changes
|
||||
if ($reset_charset) {
|
||||
$GLOBALS['dbi']->query('SET CHARACTER SET ' . $GLOBALS['charset_connection']);
|
||||
$GLOBALS['dbi']->setCollation($collation_connection);
|
||||
$dbi->query('SET CHARACTER SET ' . $GLOBALS['charset_connection']);
|
||||
$dbi->setCollation($collation_connection);
|
||||
}
|
||||
|
||||
// Show correct message
|
||||
@ -583,7 +601,7 @@ if (! empty($id_bookmark) && $_POST['action_bookmark'] == 2) {
|
||||
} elseif (! empty($id_bookmark) && $_POST['action_bookmark'] == 1) {
|
||||
$message = PhpMyAdmin\Message::notice(__('Showing bookmark'));
|
||||
} elseif ($bookmark_created) {
|
||||
$special_message = '[br]' . sprintf(
|
||||
$special_message = '[br]' . sprintf(
|
||||
__('Bookmark %s has been created.'),
|
||||
htmlspecialchars($_POST['bkm_label'])
|
||||
);
|
||||
@ -662,7 +680,7 @@ if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
|
||||
// @todo: possibly refactor
|
||||
extract($analyzed_sql_results);
|
||||
|
||||
if ($table != $table_from_sql && !empty($table_from_sql)) {
|
||||
if ($table != $table_from_sql && ! empty($table_from_sql)) {
|
||||
$table = $table_from_sql;
|
||||
}
|
||||
}
|
||||
@ -671,24 +689,26 @@ if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
|
||||
if (isset($my_die)) {
|
||||
foreach ($my_die as $key => $die) {
|
||||
PhpMyAdmin\Util::mysqlDie(
|
||||
$die['error'], $die['sql'], false, $err_url, $error
|
||||
$die['error'],
|
||||
$die['sql'],
|
||||
false,
|
||||
$err_url,
|
||||
$error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($go_sql) {
|
||||
|
||||
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1)) {
|
||||
$_SESSION['is_multi_query'] = true;
|
||||
$sql_queries = $sql_data['valid_sql'];
|
||||
} else {
|
||||
$sql_queries = array($sql_query);
|
||||
$sql_queries = [$sql_query];
|
||||
}
|
||||
|
||||
$html_output = '';
|
||||
|
||||
foreach ($sql_queries as $sql_query) {
|
||||
|
||||
// parse sql query
|
||||
list(
|
||||
$analyzed_sql_results,
|
||||
@ -700,7 +720,9 @@ if ($go_sql) {
|
||||
|
||||
// Check if User is allowed to issue a 'DROP DATABASE' Statement
|
||||
if ($sql->hasNoRightsToDropDatabase(
|
||||
$analyzed_sql_results, $cfg['AllowUserDropDatabase'], $GLOBALS['dbi']->isSuperuser()
|
||||
$analyzed_sql_results,
|
||||
$cfg['AllowUserDropDatabase'],
|
||||
$dbi->isSuperuser()
|
||||
)) {
|
||||
PhpMyAdmin\Util::mysqlDie(
|
||||
__('"DROP DATABASE" statements are disabled.'),
|
||||
@ -711,7 +733,7 @@ if ($go_sql) {
|
||||
return;
|
||||
} // end if
|
||||
|
||||
if ($table != $table_from_sql && !empty($table_from_sql)) {
|
||||
if ($table != $table_from_sql && ! empty($table_from_sql)) {
|
||||
$table = $table_from_sql;
|
||||
}
|
||||
|
||||
@ -743,23 +765,26 @@ if ($go_sql) {
|
||||
if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
|
||||
$cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
|
||||
$sql->storeTheQueryAsBookmark(
|
||||
$db, $cfgBookmark['user'],
|
||||
$_POST['sql_query'], $_POST['bkm_label'],
|
||||
$db,
|
||||
$cfgBookmark['user'],
|
||||
$_POST['sql_query'],
|
||||
$_POST['bkm_label'],
|
||||
isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
|
||||
);
|
||||
}
|
||||
|
||||
$response->addJSON('ajax_reload', $ajax_reload);
|
||||
$response->addHTML($html_output);
|
||||
exit();
|
||||
|
||||
exit;
|
||||
} elseif ($result) {
|
||||
// Save a Bookmark with more than one queries (if Bookmark label given).
|
||||
if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
|
||||
$cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
|
||||
$sql->storeTheQueryAsBookmark(
|
||||
$db, $cfgBookmark['user'],
|
||||
$_POST['sql_query'], $_POST['bkm_label'],
|
||||
$db,
|
||||
$cfgBookmark['user'],
|
||||
$_POST['sql_query'],
|
||||
$_POST['bkm_label'],
|
||||
isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
|
||||
);
|
||||
}
|
||||
@ -770,15 +795,15 @@ if ($go_sql) {
|
||||
'sql_query',
|
||||
PhpMyAdmin\Util::getMessage($msg, $sql_query, 'success')
|
||||
);
|
||||
} elseif ($result == false) {
|
||||
} elseif ($result === false) {
|
||||
$response->setRequestStatus(false);
|
||||
$response->addJSON('message', PhpMyAdmin\Message::error($msg));
|
||||
} else {
|
||||
$active_page = $goto;
|
||||
include '' . $goto;
|
||||
include ROOT_PATH . $goto;
|
||||
}
|
||||
|
||||
// If there is request for ROLLBACK in the end.
|
||||
if (isset($_POST['rollback_query'])) {
|
||||
$GLOBALS['dbi']->query('ROLLBACK');
|
||||
$dbi->query('ROLLBACK');
|
||||
}
|
||||
|
||||
@ -5,10 +5,15 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Display\ImportAjax;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/* PHP 5.4 stores upload progress data only in the default session.
|
||||
* After calling session_name(), we won't find the progress data anymore.
|
||||
*
|
||||
@ -52,7 +57,7 @@ if (ini_get('session.upload_progress.enabled')) {
|
||||
|
||||
define('PMA_MINIMUM_COMMON', 1);
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
list(
|
||||
$SESSION_KEY,
|
||||
$upload_id,
|
||||
@ -82,7 +87,6 @@ if (defined('SESSIONUPLOAD')) {
|
||||
|
||||
// $_GET["message"] is used for asking for an import message
|
||||
if (isset($_GET["message"]) && $_GET["message"]) {
|
||||
|
||||
// AJAX requests can't be cached!
|
||||
Core::noCacheHeader();
|
||||
|
||||
@ -116,7 +120,6 @@ if (isset($_GET["message"]) && $_GET["message"]) {
|
||||
echo ' [ <a href="' , $_SESSION['Import_message']['go_back_url']
|
||||
. '">' , __('Back') , '</a> ]' , "\n";
|
||||
echo '</fieldset>' , "\n";
|
||||
|
||||
} else {
|
||||
ImportAjax::status($_GET["id"]);
|
||||
}
|
||||
|
||||
687
index.php
687
index.php
@ -5,37 +5,33 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\Config;
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Controllers\HomeController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Display\GitRevision;
|
||||
use PhpMyAdmin\LanguageManager;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\RecentFavoriteTable;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Sanitize;
|
||||
use PhpMyAdmin\Server\Select;
|
||||
use PhpMyAdmin\ThemeManager;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
/**
|
||||
* Gets some core libraries and displays a top message if required
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
global $server;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* pass variables to child pages
|
||||
*/
|
||||
$drops = array(
|
||||
$drops = [
|
||||
'lang',
|
||||
'server',
|
||||
'collation_connection',
|
||||
'db',
|
||||
'table'
|
||||
);
|
||||
'table',
|
||||
];
|
||||
foreach ($drops as $each_drop) {
|
||||
if (array_key_exists($each_drop, $_GET)) {
|
||||
unset($_GET[$each_drop]);
|
||||
@ -43,649 +39,82 @@ foreach ($drops as $each_drop) {
|
||||
}
|
||||
unset($drops, $each_drop);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Black list of all scripts to which front-end must submit data.
|
||||
* Such scripts must not be loaded on home page.
|
||||
*
|
||||
*/
|
||||
$target_blacklist = array (
|
||||
'import.php', 'export.php'
|
||||
);
|
||||
$target_blacklist = [
|
||||
'import.php',
|
||||
'export.php',
|
||||
];
|
||||
|
||||
// If we have a valid target, let's load that script instead
|
||||
if (! empty($_REQUEST['target'])
|
||||
&& is_string($_REQUEST['target'])
|
||||
&& ! preg_match('/^index/', $_REQUEST['target'])
|
||||
&& 0 !== strpos($_REQUEST['target'], "index")
|
||||
&& ! in_array($_REQUEST['target'], $target_blacklist)
|
||||
&& Core::checkPageValidity($_REQUEST['target'], [], true)
|
||||
) {
|
||||
include $_REQUEST['target'];
|
||||
include ROOT_PATH . $_REQUEST['target'];
|
||||
exit;
|
||||
}
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get(Response::class);
|
||||
|
||||
/** @var DatabaseInterface $dbi */
|
||||
$dbi = $containerBuilder->get(DatabaseInterface::class);
|
||||
|
||||
/** @var HomeController $controller */
|
||||
$controller = $containerBuilder->get(HomeController::class);
|
||||
|
||||
if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// user selected font size
|
||||
if (isset($_POST['set_fontsize']) && preg_match('/^[0-9.]+(px|em|pt|\%)$/', $_POST['set_fontsize'])) {
|
||||
$GLOBALS['PMA_Config']->setUserValue(
|
||||
null,
|
||||
'FontSize',
|
||||
$_POST['set_fontsize'],
|
||||
'82%'
|
||||
);
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
exit();
|
||||
}
|
||||
// if user selected a theme
|
||||
if (isset($_POST['set_theme'])) {
|
||||
$tmanager = ThemeManager::getInstance();
|
||||
$tmanager->setActiveTheme($_POST['set_theme']);
|
||||
$tmanager->setThemeCookie();
|
||||
|
||||
$userPreferences = new UserPreferences();
|
||||
$prefs = $userPreferences->load();
|
||||
$prefs["config_data"]["ThemeDefault"] = $_POST['set_theme'];
|
||||
$userPreferences->save($prefs["config_data"]);
|
||||
$controller->setTheme([
|
||||
'set_theme' => $_POST['set_theme'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
exit();
|
||||
}
|
||||
// Change collation connection
|
||||
if (isset($_POST['collation_connection'])) {
|
||||
$GLOBALS['PMA_Config']->setUserValue(
|
||||
null,
|
||||
'DefaultConnectionCollation',
|
||||
$_POST['collation_connection'],
|
||||
'utf8mb4_unicode_ci'
|
||||
);
|
||||
} elseif (isset($_POST['collation_connection'])) {
|
||||
$controller->setCollationConnection([
|
||||
'collation_connection' => $_POST['collation_connection'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// See FAQ 1.34
|
||||
if (! empty($_REQUEST['db'])) {
|
||||
} elseif (! empty($_REQUEST['db'])) {
|
||||
// See FAQ 1.34
|
||||
$page = null;
|
||||
if (! empty($_REQUEST['table'])) {
|
||||
$page = Util::getScriptNameForOption(
|
||||
$GLOBALS['cfg']['DefaultTabTable'], 'table'
|
||||
$GLOBALS['cfg']['DefaultTabTable'],
|
||||
'table'
|
||||
);
|
||||
} else {
|
||||
$page = Util::getScriptNameForOption(
|
||||
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
|
||||
$GLOBALS['cfg']['DefaultTabDatabase'],
|
||||
'database'
|
||||
);
|
||||
}
|
||||
include $page;
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
/**
|
||||
* Check if it is an ajax request to reload the recent tables list.
|
||||
*/
|
||||
if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
|
||||
$response->addJSON(
|
||||
'list',
|
||||
RecentFavoriteTable::getInstance('recent')->getHtmlList()
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($GLOBALS['PMA_Config']->isGitRevision()) {
|
||||
// If ajax request to get revision
|
||||
if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
|
||||
GitRevision::display();
|
||||
exit;
|
||||
}
|
||||
// Else show empty html
|
||||
echo '<div id="is_git_revision"></div>';
|
||||
}
|
||||
|
||||
// Handles some variables that may have been sent by the calling script
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
$show_query = '1';
|
||||
|
||||
// Any message to display?
|
||||
if (! empty($message)) {
|
||||
echo Util::getMessage($message);
|
||||
unset($message);
|
||||
}
|
||||
if (isset($_SESSION['partial_logout'])) {
|
||||
Message::success(
|
||||
__('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
|
||||
)->display();
|
||||
unset($_SESSION['partial_logout']);
|
||||
}
|
||||
|
||||
$common_url_query = Url::getCommon();
|
||||
$mysql_cur_user_and_host = '';
|
||||
|
||||
// when $server > 0, a server has been chosen so we can display
|
||||
// all MySQL-related information
|
||||
if ($server > 0) {
|
||||
include 'libraries/server_common.inc.php';
|
||||
|
||||
// Use the verbose name of the server instead of the hostname
|
||||
// if a value is set
|
||||
$server_info = '';
|
||||
if (! empty($cfg['Server']['verbose'])) {
|
||||
$server_info .= htmlspecialchars($cfg['Server']['verbose']);
|
||||
if ($GLOBALS['cfg']['ShowServerInfo']) {
|
||||
$server_info .= ' (';
|
||||
}
|
||||
}
|
||||
if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
|
||||
$server_info .= $GLOBALS['dbi']->getHostInfo();
|
||||
}
|
||||
if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
|
||||
$server_info .= ')';
|
||||
}
|
||||
$mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
|
||||
|
||||
// should we add the port info here?
|
||||
$short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
|
||||
? $GLOBALS['cfg']['Server']['verbose']
|
||||
: $GLOBALS['cfg']['Server']['host']);
|
||||
}
|
||||
|
||||
echo '<div id="maincontainer">' , "\n";
|
||||
// Anchor for favorite tables synchronization.
|
||||
echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
|
||||
echo '<div id="main_pane_left">';
|
||||
if ($server > 0 || count($cfg['Servers']) > 1
|
||||
include ROOT_PATH . $page;
|
||||
} elseif ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
|
||||
$response->addJSON($controller->reloadRecentTablesList());
|
||||
} elseif ($GLOBALS['PMA_Config']->isGitRevision()
|
||||
&& isset($_REQUEST['git_revision'])
|
||||
&& $response->isAjax()
|
||||
) {
|
||||
if ($cfg['DBG']['demo']) {
|
||||
echo '<div class="group">';
|
||||
echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
|
||||
echo '<p class="cfg_dbg_demo">';
|
||||
printf(
|
||||
__(
|
||||
'You are using the demo server. You can do anything here, but '
|
||||
. 'please do not change root, debian-sys-maint and pma users. '
|
||||
. 'More information is available at %s.'
|
||||
),
|
||||
'<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
|
||||
);
|
||||
echo '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="group">';
|
||||
echo '<h2>' , __('General settings') , '</h2>';
|
||||
echo '<ul>';
|
||||
$response->addHTML($controller->gitRevision());
|
||||
} else {
|
||||
// Handles some variables that may have been sent by the calling script
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
$show_query = '1';
|
||||
|
||||
/**
|
||||
* Displays the MySQL servers choice form
|
||||
*/
|
||||
if ($cfg['ServerDefault'] == 0
|
||||
|| (! $cfg['NavigationDisplayServers']
|
||||
&& (count($cfg['Servers']) > 1
|
||||
|| ($server == 0 && count($cfg['Servers']) == 1)))
|
||||
) {
|
||||
echo '<li id="li_select_server" class="no_bullets" >';
|
||||
echo Util::getImage('s_host') , " "
|
||||
, Select::render(true, true);
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the mysql server related links
|
||||
*/
|
||||
if ($server > 0) {
|
||||
include_once 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
// Logout for advanced authentication
|
||||
if ($cfg['Server']['auth_type'] != 'config') {
|
||||
if ($cfg['ShowChgPassword']) {
|
||||
$conditional_class = 'ajax';
|
||||
Core::printListItem(
|
||||
Util::getImage('s_passwd') . " " . __(
|
||||
'Change password'
|
||||
),
|
||||
'li_change_password',
|
||||
'user_password.php' . $common_url_query,
|
||||
null,
|
||||
null,
|
||||
'change_password_anchor',
|
||||
"no_bullets",
|
||||
$conditional_class
|
||||
);
|
||||
}
|
||||
} // end if
|
||||
echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
|
||||
echo ' <form class="disableAjax" method="post" action="index.php">' , "\n"
|
||||
. Url::getHiddenInputs(null, null, 4, 'collation_connection')
|
||||
. ' <label for="select_collation_connection">' . "\n"
|
||||
. ' ' . Util::getImage('s_asci')
|
||||
. " " . __('Server connection collation') . "\n"
|
||||
// put the doc link in the form so that it appears on the same line
|
||||
. Util::showMySQLDocu('Charset-connection')
|
||||
. ': ' . "\n"
|
||||
. ' </label>' . "\n"
|
||||
|
||||
. Charsets::getCollationDropdownBox(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['DisableIS'],
|
||||
'collation_connection',
|
||||
'select_collation_connection',
|
||||
$collation_connection,
|
||||
true,
|
||||
true
|
||||
)
|
||||
. ' </form>' . "\n"
|
||||
. ' </li>' . "\n";
|
||||
} // end of if ($server > 0)
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="group">';
|
||||
echo '<h2>' , __('Appearance settings') , '</h2>';
|
||||
echo ' <ul>';
|
||||
|
||||
// Displays language selection combo
|
||||
$language_manager = LanguageManager::getInstance();
|
||||
if (empty($cfg['Lang']) && $language_manager->hasChoice()) {
|
||||
echo '<li id="li_select_lang" class="no_bullets">';
|
||||
|
||||
echo Util::getImage('s_lang') , " "
|
||||
, $language_manager->getSelectorDisplay();
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
// ThemeManager if available
|
||||
|
||||
if ($GLOBALS['cfg']['ThemeManager']) {
|
||||
echo '<li id="li_select_theme" class="no_bullets">';
|
||||
echo Util::getImage('s_theme') , " "
|
||||
, ThemeManager::getInstance()->getHtmlSelectBox();
|
||||
echo '</li>';
|
||||
}
|
||||
echo '<li id="li_select_fontsize">';
|
||||
echo Config::getFontsizeForm();
|
||||
echo '</li>';
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
// User preferences
|
||||
|
||||
if ($server > 0) {
|
||||
echo '<ul>';
|
||||
Core::printListItem(
|
||||
Util::getImage('b_tblops') . " " . __(
|
||||
'More settings'
|
||||
),
|
||||
'li_user_preferences',
|
||||
'prefs_manage.php' . $common_url_query,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"no_bullets"
|
||||
);
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
||||
echo '</div>';
|
||||
echo '<div id="main_pane_right">';
|
||||
|
||||
|
||||
if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
|
||||
|
||||
echo '<div class="group">';
|
||||
echo '<h2>' , __('Database server') , '</h2>';
|
||||
echo '<ul>' , "\n";
|
||||
Core::printListItem(
|
||||
__('Server:') . ' ' . $server_info,
|
||||
'li_server_info'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('Server type:') . ' ' . Util::getServerType(),
|
||||
'li_server_type'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('Server connection:') . ' ' . Util::getServerSSL(),
|
||||
'li_server_type'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('Server version:')
|
||||
. ' '
|
||||
. $GLOBALS['dbi']->getVersionString() . ' - ' . $GLOBALS['dbi']->getVersionComment(),
|
||||
'li_server_version'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
|
||||
'li_mysql_proto'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
|
||||
'li_user_info'
|
||||
);
|
||||
|
||||
echo ' <li id="li_select_mysql_charset">';
|
||||
echo ' ' , __('Server charset:') , ' '
|
||||
. ' <span lang="en" dir="ltr">';
|
||||
|
||||
$charset = Charsets::getServerCharset($GLOBALS['dbi']);
|
||||
$charsets = Charsets::getMySQLCharsetsDescriptions(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['DisableIS']
|
||||
);
|
||||
|
||||
echo ' ' , (isset($charsets[$charset]) ? $charsets[$charset] : '') , ' (' . $charset, ')';
|
||||
echo ' </span>'
|
||||
. ' </li>'
|
||||
. ' </ul>'
|
||||
. ' </div>';
|
||||
}
|
||||
|
||||
if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
|
||||
echo '<div class="group">';
|
||||
echo '<h2>' , __('Web server') , '</h2>';
|
||||
echo '<ul>';
|
||||
if ($GLOBALS['cfg']['ShowServerInfo']) {
|
||||
Core::printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
|
||||
|
||||
if ($server > 0) {
|
||||
$client_version_str = $GLOBALS['dbi']->getClientInfo();
|
||||
if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
|
||||
$client_version_str = 'libmysql - ' . $client_version_str;
|
||||
}
|
||||
Core::printListItem(
|
||||
__('Database client version:') . ' ' . $client_version_str,
|
||||
'li_mysql_client_version'
|
||||
);
|
||||
|
||||
$php_ext_string = __('PHP extension:') . ' ';
|
||||
|
||||
$extensions = Util::listPHPExtensions();
|
||||
|
||||
foreach ($extensions as $extension) {
|
||||
$php_ext_string .= ' ' . $extension
|
||||
. Util::showPHPDocu('book.' . $extension . '.php');
|
||||
}
|
||||
|
||||
Core::printListItem(
|
||||
$php_ext_string,
|
||||
'li_used_php_extension'
|
||||
);
|
||||
|
||||
$php_version_string = __('PHP version:') . ' ' . phpversion();
|
||||
|
||||
Core::printListItem(
|
||||
$php_version_string,
|
||||
'li_used_php_version'
|
||||
);
|
||||
}
|
||||
include ROOT_PATH . 'libraries/server_common.inc.php';
|
||||
}
|
||||
|
||||
if ($cfg['ShowPhpInfo']) {
|
||||
Core::printListItem(
|
||||
__('Show PHP information'),
|
||||
'li_phpinfo',
|
||||
'phpinfo.php' . $common_url_query,
|
||||
null,
|
||||
'_blank'
|
||||
);
|
||||
}
|
||||
echo ' </ul>';
|
||||
echo ' </div>';
|
||||
}
|
||||
|
||||
echo '<div class="group pmagroup">';
|
||||
echo '<h2>phpMyAdmin</h2>';
|
||||
echo '<ul>';
|
||||
$class = null;
|
||||
if ($GLOBALS['cfg']['VersionCheck']) {
|
||||
$class = 'jsversioncheck';
|
||||
}
|
||||
Core::printListItem(
|
||||
__('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
|
||||
'li_pma_version',
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$class
|
||||
);
|
||||
Core::printListItem(
|
||||
__('Documentation'),
|
||||
'li_pma_docs',
|
||||
Util::getDocuLink('index'),
|
||||
null,
|
||||
'_blank'
|
||||
);
|
||||
|
||||
// does not work if no target specified, don't know why
|
||||
Core::printListItem(
|
||||
__('Official Homepage'),
|
||||
'li_pma_homepage',
|
||||
Core::linkURL('https://www.phpmyadmin.net/'),
|
||||
null,
|
||||
'_blank'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('Contribute'),
|
||||
'li_pma_contribute',
|
||||
Core::linkURL('https://www.phpmyadmin.net/contribute/'),
|
||||
null,
|
||||
'_blank'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('Get support'),
|
||||
'li_pma_support',
|
||||
Core::linkURL('https://www.phpmyadmin.net/support/'),
|
||||
null,
|
||||
'_blank'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('List of changes'),
|
||||
'li_pma_changes',
|
||||
'changelog.php' . Url::getCommon(),
|
||||
null,
|
||||
'_blank'
|
||||
);
|
||||
Core::printListItem(
|
||||
__('License'),
|
||||
'li_pma_license',
|
||||
'license.php' . Url::getCommon(),
|
||||
null,
|
||||
'_blank'
|
||||
);
|
||||
echo ' </ul>';
|
||||
echo ' </div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/**
|
||||
* mbstring is used for handling multibytes inside parser, so it is good
|
||||
* to tell user something might be broken without it, see bug #1063149.
|
||||
*/
|
||||
if (! extension_loaded('mbstring')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The mbstring PHP extension was not found and you seem to be using'
|
||||
. ' a multibyte charset. Without the mbstring extension phpMyAdmin'
|
||||
. ' is unable to split strings correctly and it may result in'
|
||||
. ' unexpected results.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Missing functionality
|
||||
*/
|
||||
if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The curl extension was not found and allow_url_fopen is '
|
||||
. 'disabled. Due to this some features such as error reporting '
|
||||
. 'or version check are disabled.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($cfg['LoginCookieValidityDisableWarning'] == false) {
|
||||
/**
|
||||
* Check whether session.gc_maxlifetime limits session validity.
|
||||
*/
|
||||
$gc_time = (int)ini_get('session.gc_maxlifetime');
|
||||
if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
|
||||
'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
|
||||
'gc_maxlifetime[/a] is lower than cookie validity configured ' .
|
||||
'in phpMyAdmin, because of this, your login might expire sooner ' .
|
||||
'than configured in phpMyAdmin.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether LoginCookieValidity is limited by LoginCookieStore.
|
||||
*/
|
||||
if ($GLOBALS['cfg']['LoginCookieStore'] != 0
|
||||
&& $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
|
||||
) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Login cookie store is lower than cookie validity configured in ' .
|
||||
'phpMyAdmin, because of this, your login will expire sooner than ' .
|
||||
'configured in phpMyAdmin.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user does not have defined blowfish secret and it is being used.
|
||||
*/
|
||||
if (! empty($_SESSION['encryption_key'])) {
|
||||
if (empty($GLOBALS['cfg']['blowfish_secret'])) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The configuration file now needs a secret passphrase (blowfish_secret).'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
} elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The secret passphrase in configuration (blowfish_secret) is too short.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for existence of config directory which should not exist in
|
||||
* production environment.
|
||||
*/
|
||||
if (@file_exists('config')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Directory [code]config[/code], which is used by the setup script, ' .
|
||||
'still exists in your phpMyAdmin directory. It is strongly ' .
|
||||
'recommended to remove it once phpMyAdmin has been configured. ' .
|
||||
'Otherwise the security of your server may be compromised by ' .
|
||||
'unauthorized people downloading your configuration.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
if ($server > 0) {
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if (! $cfgRelation['allworks']
|
||||
&& $cfg['PmaNoRelation_DisableWarning'] == false
|
||||
) {
|
||||
$msg_text = __(
|
||||
'The phpMyAdmin configuration storage is not completely '
|
||||
. 'configured, some extended features have been deactivated. '
|
||||
. '%sFind out why%s. '
|
||||
);
|
||||
if ($cfg['ZeroConf'] == true) {
|
||||
$msg_text .= '<br>' .
|
||||
__(
|
||||
'Or alternately go to \'Operations\' tab of any database '
|
||||
. 'to set it up there.'
|
||||
);
|
||||
}
|
||||
$msg = Message::notice($msg_text);
|
||||
$msg->addParamHtml('<a href="./chk_rel.php" data-post="' . $common_url_query . '">');
|
||||
$msg->addParamHtml('</a>');
|
||||
/* Show error if user has configured something, notice elsewhere */
|
||||
if (!empty($cfg['Servers'][$server]['pmadb'])) {
|
||||
$msg->isError(true);
|
||||
}
|
||||
$msg->display();
|
||||
} // end if
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning about Suhosin only if its simulation mode is not enabled
|
||||
*/
|
||||
if ($cfg['SuhosinDisableWarning'] == false
|
||||
&& ini_get('suhosin.request.max_value_length')
|
||||
&& ini_get('suhosin.simulation') == '0'
|
||||
) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__(
|
||||
'Server running with Suhosin. Please refer to %sdocumentation%s ' .
|
||||
'for possible issues.'
|
||||
),
|
||||
'[doc@faq1-38]',
|
||||
'[/doc]'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/* Missing template cache */
|
||||
if (is_null($GLOBALS['PMA_Config']->getTempDir('twig'))) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__('The $cfg[\'TempDir\'] (%s) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.'),
|
||||
$GLOBALS['PMA_Config']->get('TempDir')
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning about incomplete translations.
|
||||
*
|
||||
* The data file is created while creating release by ./scripts/remove-incomplete-mo
|
||||
*/
|
||||
if (@file_exists('libraries/language_stats.inc.php')) {
|
||||
include 'libraries/language_stats.inc.php';
|
||||
/*
|
||||
* This message is intentionally not translated, because we're
|
||||
* handling incomplete translations here and focus on english
|
||||
* speaking users.
|
||||
*/
|
||||
if (isset($GLOBALS['language_stats'][$lang])
|
||||
&& $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
|
||||
) {
|
||||
trigger_error(
|
||||
'You are using an incomplete translation, please help to make it '
|
||||
. 'better by [a@https://www.phpmyadmin.net/translate/'
|
||||
. '@_blank]contributing[/a].',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
$response->addHTML($controller->index());
|
||||
}
|
||||
|
||||
414
js/ajax.js
414
js/ajax.js
@ -1,4 +1,9 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/* global isStorageSupported */ // js/config.js
|
||||
/* global ErrorReport */ // js/error_report.js
|
||||
/* global MicroHistory */ // js/microhistory.js
|
||||
|
||||
/**
|
||||
* This object handles ajax requests for pages. It also
|
||||
* handles the reloading of the main menu and scripts.
|
||||
@ -24,14 +29,14 @@ var AJAX = {
|
||||
* @var function Callback to execute after a successful request
|
||||
* Used by PMA_commonFunctions from common.js
|
||||
*/
|
||||
_callback: function () {},
|
||||
callback: function () {},
|
||||
/**
|
||||
* @var bool _debug Makes noise in your Firebug console
|
||||
* @var bool debug Makes noise in your Firebug console
|
||||
*/
|
||||
_debug: false,
|
||||
debug: false,
|
||||
/**
|
||||
* @var object $msgbox A reference to a jQuery object that links to a message
|
||||
* box that is generated by PMA_ajaxShowMessage()
|
||||
* box that is generated by Functions.ajaxShowMessage()
|
||||
*/
|
||||
$msgbox: null,
|
||||
/**
|
||||
@ -43,13 +48,14 @@ var AJAX = {
|
||||
* @return int
|
||||
*/
|
||||
hash: function (key) {
|
||||
var newKey = key;
|
||||
/* http://burtleburtle.net/bob/hash/doobs.html#one */
|
||||
key += '';
|
||||
var len = key.length;
|
||||
newKey += '';
|
||||
var len = newKey.length;
|
||||
var hash = 0;
|
||||
var i = 0;
|
||||
for (; i < len; ++i) {
|
||||
hash += key.charCodeAt(i);
|
||||
hash += newKey.charCodeAt(i);
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
@ -69,7 +75,8 @@ var AJAX = {
|
||||
registerOnload: function (file, func) {
|
||||
var eventName = 'onload_' + AJAX.hash(file);
|
||||
$(document).on(eventName, func);
|
||||
if (this._debug) {
|
||||
if (this.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
// no need to translate
|
||||
'Registered event ' + eventName + ' for file ' + file
|
||||
@ -90,7 +97,8 @@ var AJAX = {
|
||||
registerTeardown: function (file, func) {
|
||||
var eventName = 'teardown_' + AJAX.hash(file);
|
||||
$(document).on(eventName, func);
|
||||
if (this._debug) {
|
||||
if (this.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
// no need to translate
|
||||
'Registered event ' + eventName + ' for file ' + file
|
||||
@ -109,7 +117,8 @@ var AJAX = {
|
||||
fireOnload: function (file) {
|
||||
var eventName = 'onload_' + AJAX.hash(file);
|
||||
$(document).trigger(eventName);
|
||||
if (this._debug) {
|
||||
if (this.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
// no need to translate
|
||||
'Fired event ' + eventName + ' for file ' + file
|
||||
@ -127,7 +136,8 @@ var AJAX = {
|
||||
fireTeardown: function (file) {
|
||||
var eventName = 'teardown_' + AJAX.hash(file);
|
||||
$(document).triggerHandler(eventName);
|
||||
if (this._debug) {
|
||||
if (this.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
// no need to translate
|
||||
'Fired event ' + eventName + ' for file ' + file
|
||||
@ -181,7 +191,7 @@ var AJAX = {
|
||||
// Show lock icon if locked targets is not empty.
|
||||
// otherwise remove lock icon
|
||||
if (!jQuery.isEmptyObject(AJAX.lockedTargets)) {
|
||||
$('#lock_page_icon').html(PMA_getImage('s_lock', PMA_messages.strLockToolTip).toString());
|
||||
$('#lock_page_icon').html(Functions.getImage('s_lock', Messages.strLockToolTip).toString());
|
||||
} else {
|
||||
$('#lock_page_icon').html('');
|
||||
}
|
||||
@ -201,7 +211,7 @@ var AJAX = {
|
||||
// Remove duplicate wrapper
|
||||
// TODO: don't send it in the response
|
||||
.children().first().remove();
|
||||
$('#topmenu').menuResizer(PMA_mainMenuResizerCallback);
|
||||
$('#topmenu').menuResizer(Functions.mainMenuResizerCallback);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@ -245,10 +255,17 @@ var AJAX = {
|
||||
// the click event is not triggered by script
|
||||
if (typeof event !== 'undefined' && event.type === 'click' &&
|
||||
event.isTrigger !== true &&
|
||||
!jQuery.isEmptyObject(AJAX.lockedTargets) &&
|
||||
confirm(PMA_messages.strConfirmNavigation) === false
|
||||
!jQuery.isEmptyObject(AJAX.lockedTargets)
|
||||
) {
|
||||
return false;
|
||||
if (confirm(Messages.strConfirmNavigation) === false) {
|
||||
return false;
|
||||
} else {
|
||||
if (isStorageSupported('localStorage')) {
|
||||
window.localStorage.removeItem('autoSavedSql');
|
||||
} else {
|
||||
Cookies.set('autoSavedSql', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
AJAX.resetLock();
|
||||
var isLink = !! href || false;
|
||||
@ -263,7 +280,7 @@ var AJAX = {
|
||||
AJAX.xhr.abort();
|
||||
if (AJAX.xhr.status === 0 && AJAX.xhr.statusText === 'abort') {
|
||||
// If aborted
|
||||
AJAX.$msgbox = PMA_ajaxShowMessage(PMA_messages.strAbortedRequest);
|
||||
AJAX.$msgbox = Functions.ajaxShowMessage(Messages.strAbortedRequest);
|
||||
AJAX.active = false;
|
||||
AJAX.xhr = null;
|
||||
previousLinkAborted = true;
|
||||
@ -282,7 +299,7 @@ var AJAX = {
|
||||
$('html, body').animate({ scrollTop: 0 }, 'fast');
|
||||
|
||||
var url = isLink ? href : $(this).attr('action');
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var params = 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
var dataPost = AJAX.source.getPostData();
|
||||
if (! isLink) {
|
||||
@ -293,16 +310,17 @@ var AJAX = {
|
||||
}
|
||||
if (! (history && history.pushState)) {
|
||||
// Add a list of menu hashes that we have in the cache to the request
|
||||
params += PMA_MicroHistory.menus.getRequestParam();
|
||||
params += MicroHistory.menus.getRequestParam();
|
||||
}
|
||||
|
||||
if (AJAX._debug) {
|
||||
if (AJAX.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Loading: ' + url); // no need to translate
|
||||
}
|
||||
|
||||
if (isLink) {
|
||||
AJAX.active = true;
|
||||
AJAX.$msgbox = PMA_ajaxShowMessage();
|
||||
AJAX.$msgbox = Functions.ajaxShowMessage();
|
||||
// Save reference for the new link request
|
||||
AJAX.xhr = $.get(url, params, AJAX.responseHandler);
|
||||
if (history && history.pushState) {
|
||||
@ -328,8 +346,115 @@ var AJAX = {
|
||||
// or if it returns a value that evaluates to true
|
||||
if (typeof onsubmit !== 'function' || onsubmit.apply(this, [event])) {
|
||||
AJAX.active = true;
|
||||
AJAX.$msgbox = PMA_ajaxShowMessage();
|
||||
$.post(url, params, AJAX.responseHandler);
|
||||
AJAX.$msgbox = Functions.ajaxShowMessage();
|
||||
if ($(this).attr('id') === 'login_form') {
|
||||
$.post(url, params, AJAX.loginResponseHandler);
|
||||
} else {
|
||||
$.post(url, params, AJAX.responseHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Response handler to handle login request from login modal after session expiration
|
||||
*
|
||||
* To refer to self use 'AJAX', instead of 'this' as this function
|
||||
* is called in the jQuery context.
|
||||
*
|
||||
* @param object data Event data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
loginResponseHandler: function (data) {
|
||||
if (typeof data === 'undefined' || data === null) {
|
||||
return;
|
||||
}
|
||||
Functions.ajaxRemoveMessage(AJAX.$msgbox);
|
||||
|
||||
CommonParams.set('token', data.new_token);
|
||||
|
||||
AJAX.scriptHandler.load([]);
|
||||
|
||||
if (data.displayMessage) {
|
||||
$('#page_content').prepend(data.displayMessage);
|
||||
Functions.highlightSql($('#page_content'));
|
||||
}
|
||||
|
||||
$('#pma_errors').remove();
|
||||
|
||||
var msg = '';
|
||||
if (data.errSubmitMsg) {
|
||||
msg = data.errSubmitMsg;
|
||||
}
|
||||
if (data.errors) {
|
||||
$('<div></div>', { id : 'pma_errors', class : 'clearfloat' })
|
||||
.insertAfter('#selflink')
|
||||
.append(data.errors);
|
||||
// bind for php error reporting forms (bottom)
|
||||
$('#pma_ignore_errors_bottom').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
Functions.ignorePhpErrors();
|
||||
});
|
||||
$('#pma_ignore_all_errors_bottom').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
Functions.ignorePhpErrors(false);
|
||||
});
|
||||
// In case of 'sendErrorReport'='always'
|
||||
// submit the hidden error reporting form.
|
||||
if (data.sendErrorAlways === '1' &&
|
||||
data.stopErrorReportLoop !== '1'
|
||||
) {
|
||||
$('#pma_report_errors_form').trigger('submit');
|
||||
Functions.ajaxShowMessage(Messages.phpErrorsBeingSubmitted, false);
|
||||
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
|
||||
} else if (data.promptPhpErrors) {
|
||||
// otherwise just prompt user if it is set so.
|
||||
msg = msg + Messages.phpErrorsFound;
|
||||
// scroll to bottom where all the errors are displayed.
|
||||
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
|
||||
}
|
||||
}
|
||||
|
||||
Functions.ajaxShowMessage(msg, false);
|
||||
// bind for php error reporting forms (popup)
|
||||
$('#pma_ignore_errors_popup').on('click', function () {
|
||||
Functions.ignorePhpErrors();
|
||||
});
|
||||
$('#pma_ignore_all_errors_popup').on('click', function () {
|
||||
Functions.ignorePhpErrors(false);
|
||||
});
|
||||
|
||||
if (typeof data.success !== 'undefined' && data.success) {
|
||||
// reload page if user trying to login has changed
|
||||
if (CommonParams.get('user') !== data.params.user) {
|
||||
window.location = 'index.php';
|
||||
Functions.ajaxShowMessage(Messages.strLoading, false);
|
||||
AJAX.active = false;
|
||||
AJAX.xhr = null;
|
||||
return;
|
||||
}
|
||||
// remove the login modal if the login is successful otherwise show error.
|
||||
if (typeof data.logged_in !== 'undefined' && data.logged_in === 1) {
|
||||
if ($('#modalOverlay').length) {
|
||||
$('#modalOverlay').remove();
|
||||
}
|
||||
$('fieldset.disabled_for_expiration').removeAttr('disabled').removeClass('disabled_for_expiration');
|
||||
AJAX.fireTeardown('functions.js');
|
||||
AJAX.fireOnload('functions.js');
|
||||
}
|
||||
if (typeof data.new_token !== 'undefined') {
|
||||
$('input[name=token]').val(data.new_token);
|
||||
}
|
||||
} else if (typeof data.logged_in !== 'undefined' && data.logged_in === 0) {
|
||||
$('#modalOverlay').replaceWith(data.error);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
AJAX.active = false;
|
||||
AJAX.xhr = null;
|
||||
Functions.handleRedirectAndReload(data);
|
||||
if (data.fieldWithError) {
|
||||
$(':input.error').removeClass('error');
|
||||
$('#' + data.fieldWithError).addClass('error');
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -352,43 +477,43 @@ var AJAX = {
|
||||
}
|
||||
if (typeof data.success !== 'undefined' && data.success) {
|
||||
$('html, body').animate({ scrollTop: 0 }, 'fast');
|
||||
PMA_ajaxRemoveMessage(AJAX.$msgbox);
|
||||
Functions.ajaxRemoveMessage(AJAX.$msgbox);
|
||||
|
||||
if (data._redirect) {
|
||||
PMA_ajaxShowMessage(data._redirect, false);
|
||||
if (data.redirect) {
|
||||
Functions.ajaxShowMessage(data.redirect, false);
|
||||
AJAX.active = false;
|
||||
AJAX.xhr = null;
|
||||
return;
|
||||
}
|
||||
|
||||
AJAX.scriptHandler.reset(function () {
|
||||
if (data._reloadNavigation) {
|
||||
PMA_reloadNavigation();
|
||||
if (data.reloadNavigation) {
|
||||
Navigation.reload();
|
||||
}
|
||||
if (data._title) {
|
||||
$('title').replaceWith(data._title);
|
||||
if (data.title) {
|
||||
$('title').replaceWith(data.title);
|
||||
}
|
||||
if (data._menu) {
|
||||
if (data.menu) {
|
||||
if (history && history.pushState) {
|
||||
var state = {
|
||||
url : data._selflink,
|
||||
menu : data._menu
|
||||
url : data.selflink,
|
||||
menu : data.menu
|
||||
};
|
||||
history.replaceState(state, null);
|
||||
AJAX.handleMenu.replace(data._menu);
|
||||
AJAX.handleMenu.replace(data.menu);
|
||||
} else {
|
||||
PMA_MicroHistory.menus.replace(data._menu);
|
||||
PMA_MicroHistory.menus.add(data._menuHash, data._menu);
|
||||
MicroHistory.menus.replace(data.menu);
|
||||
MicroHistory.menus.add(data.menuHash, data.menu);
|
||||
}
|
||||
} else if (data._menuHash) {
|
||||
} else if (data.menuHash) {
|
||||
if (! (history && history.pushState)) {
|
||||
PMA_MicroHistory.menus.replace(PMA_MicroHistory.menus.get(data._menuHash));
|
||||
MicroHistory.menus.replace(MicroHistory.menus.get(data.menuHash));
|
||||
}
|
||||
}
|
||||
if (data._disableNaviSettings) {
|
||||
PMA_disableNaviSettings();
|
||||
if (data.disableNaviSettings) {
|
||||
Navigation.disableSettings();
|
||||
} else {
|
||||
PMA_ensureNaviSettings(data._selflink);
|
||||
Navigation.ensureSettings(data.selflink);
|
||||
}
|
||||
|
||||
// Remove all containers that may have
|
||||
@ -410,99 +535,105 @@ var AJAX = {
|
||||
$('#page_content').replaceWith(
|
||||
'<div id=\'page_content\'>' + data.message + '</div>'
|
||||
);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
checkNumberOfFields();
|
||||
Functions.highlightSql($('#page_content'));
|
||||
Functions.checkNumberOfFields();
|
||||
}
|
||||
|
||||
if (data._selflink) {
|
||||
var source = data._selflink.split('?')[0];
|
||||
if (data.selflink) {
|
||||
var source = data.selflink.split('?')[0];
|
||||
// Check for faulty links
|
||||
$selflink_replace = {
|
||||
var $selflinkReplace = {
|
||||
'import.php': 'tbl_sql.php',
|
||||
'tbl_chart.php': 'sql.php',
|
||||
'tbl_gis_visualization.php': 'sql.php'
|
||||
};
|
||||
if ($selflink_replace[source]) {
|
||||
var replacement = $selflink_replace[source];
|
||||
data._selflink = data._selflink.replace(source, replacement);
|
||||
if ($selflinkReplace[source]) {
|
||||
var replacement = $selflinkReplace[source];
|
||||
data.selflink = data.selflink.replace(source, replacement);
|
||||
}
|
||||
$('#selflink').find('> a').attr('href', data._selflink);
|
||||
$('#selflink').find('> a').attr('href', data.selflink);
|
||||
}
|
||||
if (data._params) {
|
||||
PMA_commonParams.setAll(data._params);
|
||||
if (data.params) {
|
||||
CommonParams.setAll(data.params);
|
||||
}
|
||||
if (data._scripts) {
|
||||
AJAX.scriptHandler.load(data._scripts);
|
||||
if (data.scripts) {
|
||||
AJAX.scriptHandler.load(data.scripts);
|
||||
}
|
||||
if (data._selflink && data._scripts && data._menuHash && data._params) {
|
||||
if (data.selflink && data.scripts && data.menuHash && data.params) {
|
||||
if (! (history && history.pushState)) {
|
||||
PMA_MicroHistory.add(
|
||||
data._selflink,
|
||||
data._scripts,
|
||||
data._menuHash,
|
||||
data._params,
|
||||
MicroHistory.add(
|
||||
data.selflink,
|
||||
data.scripts,
|
||||
data.menuHash,
|
||||
data.params,
|
||||
AJAX.source.attr('rel')
|
||||
);
|
||||
}
|
||||
}
|
||||
if (data._displayMessage) {
|
||||
$('#page_content').prepend(data._displayMessage);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
if (data.displayMessage) {
|
||||
$('#page_content').prepend(data.displayMessage);
|
||||
Functions.highlightSql($('#page_content'));
|
||||
}
|
||||
|
||||
$('#pma_errors').remove();
|
||||
|
||||
var msg = '';
|
||||
if (data._errSubmitMsg) {
|
||||
msg = data._errSubmitMsg;
|
||||
if (data.errSubmitMsg) {
|
||||
msg = data.errSubmitMsg;
|
||||
}
|
||||
if (data._errors) {
|
||||
$('<div/>', { id : 'pma_errors', class : 'clearfloat' })
|
||||
if (data.errors) {
|
||||
$('<div></div>', { id : 'pma_errors', class : 'clearfloat' })
|
||||
.insertAfter('#selflink')
|
||||
.append(data._errors);
|
||||
.append(data.errors);
|
||||
// bind for php error reporting forms (bottom)
|
||||
$('#pma_ignore_errors_bottom').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
PMA_ignorePhpErrors();
|
||||
Functions.ignorePhpErrors();
|
||||
});
|
||||
$('#pma_ignore_all_errors_bottom').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
PMA_ignorePhpErrors(false);
|
||||
Functions.ignorePhpErrors(false);
|
||||
});
|
||||
// In case of 'sendErrorReport'='always'
|
||||
// submit the hidden error reporting form.
|
||||
if (data._sendErrorAlways === '1' &&
|
||||
data._stopErrorReportLoop !== '1'
|
||||
if (data.sendErrorAlways === '1' &&
|
||||
data.stopErrorReportLoop !== '1'
|
||||
) {
|
||||
$('#pma_report_errors_form').submit();
|
||||
PMA_ajaxShowMessage(PMA_messages.phpErrorsBeingSubmitted, false);
|
||||
$('#pma_report_errors_form').trigger('submit');
|
||||
Functions.ajaxShowMessage(Messages.phpErrorsBeingSubmitted, false);
|
||||
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
|
||||
} else if (data._promptPhpErrors) {
|
||||
} else if (data.promptPhpErrors) {
|
||||
// otherwise just prompt user if it is set so.
|
||||
msg = msg + PMA_messages.phpErrorsFound;
|
||||
msg = msg + Messages.phpErrorsFound;
|
||||
// scroll to bottom where all the errors are displayed.
|
||||
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
|
||||
}
|
||||
}
|
||||
PMA_ajaxShowMessage(msg, false);
|
||||
Functions.ajaxShowMessage(msg, false);
|
||||
// bind for php error reporting forms (popup)
|
||||
$('#pma_ignore_errors_popup').on('click', function () {
|
||||
PMA_ignorePhpErrors();
|
||||
Functions.ignorePhpErrors();
|
||||
});
|
||||
$('#pma_ignore_all_errors_popup').on('click', function () {
|
||||
PMA_ignorePhpErrors(false);
|
||||
Functions.ignorePhpErrors(false);
|
||||
});
|
||||
|
||||
if (typeof AJAX._callback === 'function') {
|
||||
AJAX._callback.call();
|
||||
if (typeof AJAX.callback === 'function') {
|
||||
AJAX.callback.call();
|
||||
}
|
||||
AJAX._callback = function () {};
|
||||
AJAX.callback = function () {};
|
||||
});
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxRemoveMessage(AJAX.$msgbox);
|
||||
var $ajaxError = $('<div></div>');
|
||||
$ajaxError.attr({ 'id': 'ajaxError' });
|
||||
$('#page_content').append($ajaxError);
|
||||
$ajaxError.html(data.error);
|
||||
$('html, body').animate({ scrollTop: $(document).height() }, 200);
|
||||
AJAX.active = false;
|
||||
AJAX.xhr = null;
|
||||
PMA_handleRedirectAndReload(data);
|
||||
Functions.handleRedirectAndReload(data);
|
||||
if (data.fieldWithError) {
|
||||
$(':input.error').removeClass('error');
|
||||
$('#' + data.fieldWithError).addClass('error');
|
||||
@ -516,25 +647,25 @@ var AJAX = {
|
||||
*/
|
||||
scriptHandler: {
|
||||
/**
|
||||
* @var array _scripts The list of files already downloaded
|
||||
* @var array scripts The list of files already downloaded
|
||||
*/
|
||||
_scripts: [],
|
||||
scripts: [],
|
||||
/**
|
||||
* @var string _scriptsVersion version of phpMyAdmin from which the
|
||||
* @var string scriptsVersion version of phpMyAdmin from which the
|
||||
* scripts have been loaded
|
||||
*/
|
||||
_scriptsVersion: null,
|
||||
scriptsVersion: null,
|
||||
/**
|
||||
* @var array _scriptsToBeLoaded The list of files that
|
||||
* @var array scriptsToBeLoaded The list of files that
|
||||
* need to be downloaded
|
||||
*/
|
||||
_scriptsToBeLoaded: [],
|
||||
scriptsToBeLoaded: [],
|
||||
/**
|
||||
* @var array _scriptsToBeFired The list of files for which
|
||||
* @var array scriptsToBeFired The list of files for which
|
||||
* to fire the onload and unload events
|
||||
*/
|
||||
_scriptsToBeFired: [],
|
||||
_scriptsCompleted: false,
|
||||
scriptsToBeFired: [],
|
||||
scriptsCompleted: false,
|
||||
/**
|
||||
* Records that a file has been downloaded
|
||||
*
|
||||
@ -545,11 +676,11 @@ var AJAX = {
|
||||
* @return self For chaining
|
||||
*/
|
||||
add: function (file, fire) {
|
||||
this._scripts.push(file);
|
||||
this.scripts.push(file);
|
||||
if (fire) {
|
||||
// Record whether to fire any events for the file
|
||||
// This is necessary to correctly tear down the initial page
|
||||
this._scriptsToBeFired.push(file);
|
||||
this.scriptsToBeFired.push(file);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
@ -565,28 +696,28 @@ var AJAX = {
|
||||
var i;
|
||||
// Clear loaded scripts if they are from another version of phpMyAdmin.
|
||||
// Depends on common params being set before loading scripts in responseHandler
|
||||
if (self._scriptsVersion === null) {
|
||||
self._scriptsVersion = PMA_commonParams.get('PMA_VERSION');
|
||||
} else if (self._scriptsVersion !== PMA_commonParams.get('PMA_VERSION')) {
|
||||
self._scripts = [];
|
||||
self._scriptsVersion = PMA_commonParams.get('PMA_VERSION');
|
||||
if (self.scriptsVersion === null) {
|
||||
self.scriptsVersion = CommonParams.get('PMA_VERSION');
|
||||
} else if (self.scriptsVersion !== CommonParams.get('PMA_VERSION')) {
|
||||
self.scripts = [];
|
||||
self.scriptsVersion = CommonParams.get('PMA_VERSION');
|
||||
}
|
||||
self._scriptsCompleted = false;
|
||||
self._scriptsToBeFired = [];
|
||||
self.scriptsCompleted = false;
|
||||
self.scriptsToBeFired = [];
|
||||
// We need to first complete list of files to load
|
||||
// as next loop will directly fire requests to load them
|
||||
// and that triggers removal of them from
|
||||
// self._scriptsToBeLoaded
|
||||
// self.scriptsToBeLoaded
|
||||
for (i in files) {
|
||||
self._scriptsToBeLoaded.push(files[i].name);
|
||||
self.scriptsToBeLoaded.push(files[i].name);
|
||||
if (files[i].fire) {
|
||||
self._scriptsToBeFired.push(files[i].name);
|
||||
self.scriptsToBeFired.push(files[i].name);
|
||||
}
|
||||
}
|
||||
for (i in files) {
|
||||
var script = files[i].name;
|
||||
// Only for scripts that we don't already have
|
||||
if ($.inArray(script, self._scripts) === -1) {
|
||||
if ($.inArray(script, self.scripts) === -1) {
|
||||
this.add(script);
|
||||
this.appendScript(script, callback);
|
||||
} else {
|
||||
@ -603,21 +734,21 @@ var AJAX = {
|
||||
*/
|
||||
done: function (script, callback) {
|
||||
if (typeof ErrorReport !== 'undefined') {
|
||||
ErrorReport.wrap_global_functions();
|
||||
ErrorReport.wrapGlobalFunctions();
|
||||
}
|
||||
if ($.inArray(script, this._scriptsToBeFired)) {
|
||||
if ($.inArray(script, this.scriptsToBeFired)) {
|
||||
AJAX.fireOnload(script);
|
||||
}
|
||||
if ($.inArray(script, this._scriptsToBeLoaded)) {
|
||||
this._scriptsToBeLoaded.splice($.inArray(script, this._scriptsToBeLoaded), 1);
|
||||
if ($.inArray(script, this.scriptsToBeLoaded)) {
|
||||
this.scriptsToBeLoaded.splice($.inArray(script, this.scriptsToBeLoaded), 1);
|
||||
}
|
||||
if (script === null) {
|
||||
this._scriptsCompleted = true;
|
||||
this.scriptsCompleted = true;
|
||||
}
|
||||
/* We need to wait for last signal (with null) or last script load */
|
||||
AJAX.active = (this._scriptsToBeLoaded.length > 0) || ! this._scriptsCompleted;
|
||||
AJAX.active = (this.scriptsToBeLoaded.length > 0) || ! this.scriptsCompleted;
|
||||
/* Run callback on last script */
|
||||
if (! AJAX.active && $.isFunction(callback)) {
|
||||
if (! AJAX.active && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
@ -632,7 +763,7 @@ var AJAX = {
|
||||
var self = this;
|
||||
|
||||
script.type = 'text/javascript';
|
||||
script.src = 'js/' + name + '?' + 'v=' + encodeURIComponent(PMA_commonParams.get('PMA_VERSION'));
|
||||
script.src = 'js/' + name + '?' + 'v=' + encodeURIComponent(CommonParams.get('PMA_VERSION'));
|
||||
script.async = false;
|
||||
script.onload = function () {
|
||||
self.done(name, callback);
|
||||
@ -648,10 +779,10 @@ var AJAX = {
|
||||
* @return void
|
||||
*/
|
||||
reset: function (callback) {
|
||||
for (var i in this._scriptsToBeFired) {
|
||||
AJAX.fireTeardown(this._scriptsToBeFired[i]);
|
||||
for (var i in this.scriptsToBeFired) {
|
||||
AJAX.fireTeardown(this.scriptsToBeFired[i]);
|
||||
}
|
||||
this._scriptsToBeFired = [];
|
||||
this.scriptsToBeFired = [];
|
||||
/**
|
||||
* Re-attach a generic event handler to clicks
|
||||
* on pages and submissions of forms
|
||||
@ -659,7 +790,7 @@ var AJAX = {
|
||||
$(document).off('click', 'a').on('click', 'a', AJAX.requestHandler);
|
||||
$(document).off('submit', 'form').on('submit', 'form', AJAX.requestHandler);
|
||||
if (! (history && history.pushState)) {
|
||||
PMA_MicroHistory.update();
|
||||
MicroHistory.update();
|
||||
}
|
||||
callback();
|
||||
}
|
||||
@ -683,17 +814,17 @@ AJAX.registerOnload('functions.js', function () {
|
||||
}
|
||||
});
|
||||
|
||||
var $page_content = $('#page_content');
|
||||
var $pageContent = $('#page_content');
|
||||
/**
|
||||
* Workaround for passing submit button name,value on ajax form submit
|
||||
* by appending hidden element with submit button name and value.
|
||||
*/
|
||||
$page_content.on('click', 'form input[type=submit]', function () {
|
||||
$pageContent.on('click', 'form input[type=submit]', function () {
|
||||
var buttonName = $(this).attr('name');
|
||||
if (typeof buttonName === 'undefined') {
|
||||
return;
|
||||
}
|
||||
$(this).closest('form').append($('<input/>', {
|
||||
$(this).closest('form').append($('<input>', {
|
||||
'type' : 'hidden',
|
||||
'name' : buttonName,
|
||||
'value': $(this).val()
|
||||
@ -704,7 +835,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
* Attach event listener to events when user modify visible
|
||||
* Input,Textarea and select fields to make changes in forms
|
||||
*/
|
||||
$page_content.on(
|
||||
$pageContent.on(
|
||||
'keyup change',
|
||||
'form.lock-page textarea, ' +
|
||||
'form.lock-page input[type="text"], ' +
|
||||
@ -713,7 +844,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
{ value:1 },
|
||||
AJAX.lockPageHandler
|
||||
);
|
||||
$page_content.on(
|
||||
$pageContent.on(
|
||||
'change',
|
||||
'form.lock-page input[type="checkbox"], ' +
|
||||
'form.lock-page input[type="radio"]',
|
||||
@ -725,7 +856,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
* Note: reset does not bubble in all browser so attach to
|
||||
* form directly.
|
||||
*/
|
||||
$('form.lock-page').on('reset', function (event) {
|
||||
$('form.lock-page').on('reset', function () {
|
||||
AJAX.resetLock();
|
||||
});
|
||||
});
|
||||
@ -757,8 +888,8 @@ $(function () {
|
||||
}
|
||||
var state = event.originalEvent.state;
|
||||
if (state && state.menu) {
|
||||
AJAX.$msgbox = PMA_ajaxShowMessage();
|
||||
var params = 'ajax_request=true' + PMA_commonParams.get('arg_separator') + 'ajax_page_request=true';
|
||||
AJAX.$msgbox = Functions.ajaxShowMessage();
|
||||
var params = 'ajax_request=true' + CommonParams.get('arg_separator') + 'ajax_page_request=true';
|
||||
var url = state.url || location.href;
|
||||
$.get(url, params, AJAX.responseHandler);
|
||||
// TODO: Check if sometimes menu is not retrieved from server,
|
||||
@ -773,20 +904,20 @@ $(function () {
|
||||
AJAX.scriptHandler
|
||||
.load([{ 'name' : 'microhistory.js', 'fire' : 1 }], function () {
|
||||
// The cache primer is set by the footer class
|
||||
if (PMA_MicroHistory.primer.url) {
|
||||
PMA_MicroHistory.menus.add(
|
||||
PMA_MicroHistory.primer.menuHash,
|
||||
if (MicroHistory.primer.url) {
|
||||
MicroHistory.menus.add(
|
||||
MicroHistory.primer.menuHash,
|
||||
menuContent
|
||||
);
|
||||
}
|
||||
$(function () {
|
||||
// Queue up this event twice to make sure that we get a copy
|
||||
// of the page after all other onload events have been fired
|
||||
if (PMA_MicroHistory.primer.url) {
|
||||
PMA_MicroHistory.add(
|
||||
PMA_MicroHistory.primer.url,
|
||||
PMA_MicroHistory.primer.scripts,
|
||||
PMA_MicroHistory.primer.menuHash
|
||||
if (MicroHistory.primer.url) {
|
||||
MicroHistory.add(
|
||||
MicroHistory.primer.url,
|
||||
MicroHistory.primer.scripts,
|
||||
MicroHistory.primer.menuHash
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -805,8 +936,9 @@ $(document).on('submit', 'form', AJAX.requestHandler);
|
||||
* Gracefully handle fatal server errors
|
||||
* (e.g: 500 - Internal server error)
|
||||
*/
|
||||
$(document).ajaxError(function (event, request, settings) {
|
||||
if (AJAX._debug) {
|
||||
$(document).ajaxError(function (event, request) {
|
||||
if (AJAX.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('AJAX error: status=' + request.status + ', text=' + request.statusText);
|
||||
}
|
||||
// Don't handle aborted requests
|
||||
@ -815,15 +947,15 @@ $(document).ajaxError(function (event, request, settings) {
|
||||
var state = request.state();
|
||||
|
||||
if (request.status !== 0) {
|
||||
details += '<div>' + escapeHtml(PMA_sprintf(PMA_messages.strErrorCode, request.status)) + '</div>';
|
||||
details += '<div>' + Functions.escapeHtml(Functions.sprintf(Messages.strErrorCode, request.status)) + '</div>';
|
||||
}
|
||||
details += '<div>' + escapeHtml(PMA_sprintf(PMA_messages.strErrorText, request.statusText + ' (' + state + ')')) + '</div>';
|
||||
details += '<div>' + Functions.escapeHtml(Functions.sprintf(Messages.strErrorText, request.statusText + ' (' + state + ')')) + '</div>';
|
||||
if (state === 'rejected' || state === 'timeout') {
|
||||
details += '<div>' + escapeHtml(PMA_messages.strErrorConnection) + '</div>';
|
||||
details += '<div>' + Functions.escapeHtml(Messages.strErrorConnection) + '</div>';
|
||||
}
|
||||
PMA_ajaxShowMessage(
|
||||
Functions.ajaxShowMessage(
|
||||
'<div class="error">' +
|
||||
PMA_messages.strErrorProcessingRequest +
|
||||
Messages.strErrorProcessingRequest +
|
||||
details +
|
||||
'</div>',
|
||||
false
|
||||
|
||||
15
js/chart.js
15
js/chart.js
@ -28,7 +28,7 @@ var ColumnType = {
|
||||
var ChartFactory = function () {
|
||||
};
|
||||
ChartFactory.prototype = {
|
||||
createChart : function (type, options) {
|
||||
createChart : function () {
|
||||
throw new Error('createChart must be implemented by a subclass');
|
||||
}
|
||||
};
|
||||
@ -43,10 +43,10 @@ var Chart = function (elementId) {
|
||||
this.elementId = elementId;
|
||||
};
|
||||
Chart.prototype = {
|
||||
draw : function (data, options) {
|
||||
draw : function () {
|
||||
throw new Error('draw must be implemented by a subclass');
|
||||
},
|
||||
redraw : function (options) {
|
||||
redraw : function () {
|
||||
throw new Error('redraw must be implemented by a subclass');
|
||||
},
|
||||
destroy : function () {
|
||||
@ -58,7 +58,7 @@ Chart.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract representation of charts that operates on DataTable where,<br />
|
||||
* Abstract representation of charts that operates on DataTable where,<br>
|
||||
* <ul>
|
||||
* <li>First column provides index to the data.</li>
|
||||
* <li>Each subsequent columns are of type
|
||||
@ -153,6 +153,7 @@ ScatterChart.prototype.validateColumns = function (dataTable) {
|
||||
/**
|
||||
* The data table contains column information and data for the chart.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var DataTable = function () {
|
||||
var columns = [];
|
||||
var data = null;
|
||||
@ -228,15 +229,15 @@ JQPlotChart.prototype.redraw = function (options) {
|
||||
this.plot.replot(options);
|
||||
}
|
||||
};
|
||||
JQPlotChart.prototype.toImageString = function (options) {
|
||||
JQPlotChart.prototype.toImageString = function () {
|
||||
if (this.plot !== null) {
|
||||
return $('#' + this.elementId).jqplotToImageStr({});
|
||||
}
|
||||
};
|
||||
JQPlotChart.prototype.populateOptions = function (dataTable, options) {
|
||||
JQPlotChart.prototype.populateOptions = function () {
|
||||
throw new Error('populateOptions must be implemented by a subclass');
|
||||
};
|
||||
JQPlotChart.prototype.prepareData = function (dataTable) {
|
||||
JQPlotChart.prototype.prepareData = function () {
|
||||
throw new Error('prepareData must be implemented by a subclass');
|
||||
};
|
||||
|
||||
|
||||
10
js/codemirror/addon/lint/sql-lint.js
vendored
10
js/codemirror/addon/lint/sql-lint.js
vendored
@ -9,9 +9,11 @@ CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
|
||||
var found = [];
|
||||
for (var idx in response) {
|
||||
found.push({
|
||||
// eslint-disable-next-line new-cap
|
||||
from: CodeMirror.Pos(
|
||||
response[idx].fromLine, response[idx].fromColumn
|
||||
),
|
||||
// eslint-disable-next-line new-cap
|
||||
to: CodeMirror.Pos(
|
||||
response[idx].toLine, response[idx].toColumn
|
||||
),
|
||||
@ -28,10 +30,10 @@ CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
|
||||
url: 'lint.php',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
sql_query: text,
|
||||
server: PMA_commonParams.get('server'),
|
||||
options: options.lintOptions,
|
||||
no_history: true,
|
||||
'sql_query': text,
|
||||
'server': CommonParams.get('server'),
|
||||
'options': options.lintOptions,
|
||||
'no_history': true,
|
||||
},
|
||||
success: handleResponse
|
||||
});
|
||||
|
||||
440
js/common.js
440
js/common.js
@ -1,7 +1,7 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
$(function () {
|
||||
checkNumberOfFields();
|
||||
Functions.checkNumberOfFields();
|
||||
});
|
||||
|
||||
/**
|
||||
@ -10,7 +10,7 @@ $(function () {
|
||||
* The content for this is normally loaded from Header.php or
|
||||
* Response.php and executed by ajax.js
|
||||
*/
|
||||
var PMA_commonParams = (function () {
|
||||
var CommonParams = (function () {
|
||||
/**
|
||||
* @var hash params An associative array of key value pairs
|
||||
* @access private
|
||||
@ -27,21 +27,19 @@ var PMA_commonParams = (function () {
|
||||
* @return void
|
||||
*/
|
||||
setAll: function (obj) {
|
||||
var reload = false;
|
||||
var updateNavigation = false;
|
||||
for (var i in obj) {
|
||||
if (params[i] !== undefined && params[i] !== obj[i]) {
|
||||
if (i === 'db' || i === 'table') {
|
||||
updateNavigation = true;
|
||||
}
|
||||
reload = true;
|
||||
}
|
||||
params[i] = obj[i];
|
||||
}
|
||||
if (updateNavigation &&
|
||||
$('#pma_navigation_tree').hasClass('synced')
|
||||
) {
|
||||
PMA_showCurrentNavigation();
|
||||
Navigation.showCurrent();
|
||||
}
|
||||
},
|
||||
/**
|
||||
@ -74,7 +72,7 @@ var PMA_commonParams = (function () {
|
||||
if (updateNavigation &&
|
||||
$('#pma_navigation_tree').hasClass('synced')
|
||||
) {
|
||||
PMA_showCurrentNavigation();
|
||||
Navigation.showCurrent();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
@ -86,11 +84,11 @@ var PMA_commonParams = (function () {
|
||||
getUrlQuery: function () {
|
||||
var common = this.get('common_query');
|
||||
var separator = '?';
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
if (common.length > 0) {
|
||||
separator = argsep;
|
||||
}
|
||||
return PMA_sprintf(
|
||||
return Functions.sprintf(
|
||||
'%s%sserver=%s' + argsep + 'db=%s' + argsep + 'table=%s',
|
||||
this.get('common_query'),
|
||||
separator,
|
||||
@ -108,33 +106,34 @@ var PMA_commonParams = (function () {
|
||||
* The content for this is normally loaded from Header.php or
|
||||
* Response.php and executed by ajax.js
|
||||
*/
|
||||
var PMA_commonActions = {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var CommonActions = {
|
||||
/**
|
||||
* Saves the database name when it's changed
|
||||
* and reloads the query window, if necessary
|
||||
*
|
||||
* @param new_db string new_db The name of the new database
|
||||
* @param newDb string new_db The name of the new database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
setDb: function (new_db) {
|
||||
if (new_db !== PMA_commonParams.get('db')) {
|
||||
PMA_commonParams.setAll({ 'db': new_db, 'table': '' });
|
||||
setDb: function (newDb) {
|
||||
if (newDb !== CommonParams.get('db')) {
|
||||
CommonParams.setAll({ 'db': newDb, 'table': '' });
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Opens a database in the main part of the page
|
||||
*
|
||||
* @param new_db string The name of the new database
|
||||
* @param newDb string The name of the new database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
openDb: function (new_db) {
|
||||
PMA_commonParams
|
||||
.set('db', new_db)
|
||||
openDb: function (newDb) {
|
||||
CommonParams
|
||||
.set('db', newDb)
|
||||
.set('table', '');
|
||||
this.refreshMain(
|
||||
PMA_commonParams.get('opendb_url')
|
||||
CommonParams.get('opendb_url')
|
||||
);
|
||||
},
|
||||
/**
|
||||
@ -146,405 +145,16 @@ var PMA_commonActions = {
|
||||
* @return void
|
||||
*/
|
||||
refreshMain: function (url, callback) {
|
||||
if (! url) {
|
||||
url = $('#selflink').find('a').attr('href') || window.location.pathname;
|
||||
url = url.substring(0, url.indexOf('?'));
|
||||
var newUrl = url;
|
||||
if (! newUrl) {
|
||||
newUrl = $('#selflink').find('a').attr('href') || window.location.pathname;
|
||||
newUrl = newUrl.substring(0, newUrl.indexOf('?'));
|
||||
}
|
||||
url += PMA_commonParams.getUrlQuery();
|
||||
$('<a />', { href: url })
|
||||
newUrl += CommonParams.getUrlQuery();
|
||||
$('<a></a>', { href: newUrl })
|
||||
.appendTo('body')
|
||||
.click()
|
||||
.trigger('click')
|
||||
.remove();
|
||||
AJAX._callback = callback;
|
||||
AJAX.callback = callback;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Class to handle PMA Drag and Drop Import
|
||||
* feature
|
||||
*/
|
||||
PMA_DROP_IMPORT = {
|
||||
/**
|
||||
* @var int, count of total uploads in this view
|
||||
*/
|
||||
uploadCount: 0,
|
||||
/**
|
||||
* @var int, count of live uploads
|
||||
*/
|
||||
liveUploadCount: 0,
|
||||
/**
|
||||
* @var string array, allowed extensions
|
||||
*/
|
||||
allowedExtensions: ['sql', 'xml', 'ldi', 'mediawiki', 'shp'],
|
||||
/**
|
||||
* @var string array, allowed extensions for compressed files
|
||||
*/
|
||||
allowedCompressedExtensions: ['gz', 'bz2', 'zip'],
|
||||
/**
|
||||
* @var obj array to store message returned by import_status.php
|
||||
*/
|
||||
importStatus: [],
|
||||
/**
|
||||
* Checks if any dropped file has valid extension or not
|
||||
*
|
||||
* @param file filename
|
||||
*
|
||||
* @return string, extension for valid extension, '' otherwise
|
||||
*/
|
||||
_getExtension: function (file) {
|
||||
var arr = file.split('.');
|
||||
ext = arr[arr.length - 1];
|
||||
|
||||
// check if compressed
|
||||
if (jQuery.inArray(ext.toLowerCase(),
|
||||
PMA_DROP_IMPORT.allowedCompressedExtensions) !== -1) {
|
||||
ext = arr[arr.length - 2];
|
||||
}
|
||||
|
||||
// Now check for extension
|
||||
if (jQuery.inArray(ext.toLowerCase(),
|
||||
PMA_DROP_IMPORT.allowedExtensions) !== -1) {
|
||||
return ext;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Shows upload progress for different sql uploads
|
||||
*
|
||||
* @param: hash (string), hash for specific file upload
|
||||
* @param: percent (float), file upload percentage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_setProgress: function (hash, percent) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.children('progress').val(percent);
|
||||
},
|
||||
/**
|
||||
* Function to upload the file asynchronously
|
||||
*
|
||||
* @param formData FormData object for a specific file
|
||||
* @param hash hash of the current file upload
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_sendFileToServer: function (formData, hash) {
|
||||
var uploadURL = './import.php'; // Upload URL
|
||||
var extraData = {};
|
||||
var jqXHR = $.ajax({
|
||||
xhr: function () {
|
||||
var xhrobj = $.ajaxSettings.xhr();
|
||||
if (xhrobj.upload) {
|
||||
xhrobj.upload.addEventListener('progress', function (event) {
|
||||
var percent = 0;
|
||||
var position = event.loaded || event.position;
|
||||
var total = event.total;
|
||||
if (event.lengthComputable) {
|
||||
percent = Math.ceil(position / total * 100);
|
||||
}
|
||||
// Set progress
|
||||
PMA_DROP_IMPORT._setProgress(hash, percent);
|
||||
}, false);
|
||||
}
|
||||
return xhrobj;
|
||||
},
|
||||
url: uploadURL,
|
||||
type: 'POST',
|
||||
contentType:false,
|
||||
processData: false,
|
||||
cache: false,
|
||||
data: formData,
|
||||
success: function (data) {
|
||||
PMA_DROP_IMPORT._importFinished(hash, false, data.success);
|
||||
if (!data.success) {
|
||||
PMA_DROP_IMPORT.importStatus[PMA_DROP_IMPORT.importStatus.length] = {
|
||||
hash: hash,
|
||||
message: data.error
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// -- provide link to cancel the upload
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize').html('<span hash="' +
|
||||
hash + '" class="pma_drop_file_status" task="cancel">' +
|
||||
PMA_messages.dropImportMessageCancel + '</span>');
|
||||
|
||||
// -- add event listener to this link to abort upload operation
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.on('click', function () {
|
||||
if ($(this).attr('task') === 'cancel') {
|
||||
jqXHR.abort();
|
||||
$(this).html('<span>' + PMA_messages.dropImportMessageAborted + '</span>');
|
||||
PMA_DROP_IMPORT._importFinished(hash, true, false);
|
||||
} else if ($(this).children('span').html() ===
|
||||
PMA_messages.dropImportMessageFailed) {
|
||||
// -- view information
|
||||
var $this = $(this);
|
||||
$.each(PMA_DROP_IMPORT.importStatus,
|
||||
function (key, value) {
|
||||
if (value.hash === hash) {
|
||||
$('.pma_drop_result:visible').remove();
|
||||
var filename = $this.parent('span').attr('data-filename');
|
||||
$('body').append('<div class="pma_drop_result"><h2>' +
|
||||
PMA_messages.dropImportImportResultHeader + ' - ' +
|
||||
filename + '<span class="close">x</span></h2>' + value.message + '</div>');
|
||||
$('.pma_drop_result').draggable(); // to make this dialog draggable
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Triggered when an object is dragged into the PMA UI
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_dragenter : function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (!PMA_DROP_IMPORT._hasFiles(event)) {
|
||||
return;
|
||||
}
|
||||
if (PMA_commonParams.get('db') === '') {
|
||||
$('.pma_drop_handler').html(PMA_messages.dropImportSelectDB);
|
||||
} else {
|
||||
$('.pma_drop_handler').html(PMA_messages.dropImportDropFiles);
|
||||
}
|
||||
$('.pma_drop_handler').fadeIn();
|
||||
},
|
||||
/**
|
||||
* Check if dragged element contains Files
|
||||
*
|
||||
* @param event the event object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
_hasFiles: function (event) {
|
||||
return !(typeof event.originalEvent.dataTransfer.types === 'undefined' ||
|
||||
$.inArray('Files', event.originalEvent.dataTransfer.types) < 0 ||
|
||||
$.inArray(
|
||||
'application/x-moz-nativeimage',
|
||||
event.originalEvent.dataTransfer.types
|
||||
) >= 0);
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged file is being dragged over PMA UI
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_dragover: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (!PMA_DROP_IMPORT._hasFiles(event)) {
|
||||
return;
|
||||
}
|
||||
$('.pma_drop_handler').fadeIn();
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged objects are left
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_dragleave: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
var $pma_drop_handler = $('.pma_drop_handler');
|
||||
$pma_drop_handler.clearQueue().stop();
|
||||
$pma_drop_handler.fadeOut();
|
||||
$pma_drop_handler.html(PMA_messages.dropImportDropFiles);
|
||||
},
|
||||
/**
|
||||
* Called when upload has finished
|
||||
*
|
||||
* @param string, unique hash for a certain upload
|
||||
* @param bool, true if upload was aborted
|
||||
* @param bool, status of sql upload, as sent by server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_importFinished: function (hash, aborted, status) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.children('progress').hide();
|
||||
var icon = 'icon ic_s_success';
|
||||
// -- provide link to view upload status
|
||||
if (!aborted) {
|
||||
if (status) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.html('<span>' + PMA_messages.dropImportMessageSuccess + '</a>');
|
||||
} else {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.html('<span class="underline">' + PMA_messages.dropImportMessageFailed +
|
||||
'</a>');
|
||||
icon = 'icon ic_s_error';
|
||||
}
|
||||
} else {
|
||||
icon = 'icon ic_s_notice';
|
||||
}
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.attr('task', 'info');
|
||||
|
||||
// Set icon
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.prepend('<img src="./themes/dot.gif" title="finished" class="' +
|
||||
icon + '"> ');
|
||||
|
||||
// Decrease liveUploadCount by one
|
||||
$('.pma_import_count').html(--PMA_DROP_IMPORT.liveUploadCount);
|
||||
if (!PMA_DROP_IMPORT.liveUploadCount) {
|
||||
$('.pma_sql_import_status h2 .close').fadeIn();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged objects are dropped to UI
|
||||
* From this function, the AJAX Upload operation is initiated
|
||||
*
|
||||
* @param event object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_drop: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dbname = PMA_commonParams.get('db');
|
||||
var server = PMA_commonParams.get('server');
|
||||
|
||||
// if no database is selected -- no
|
||||
if (dbname !== '') {
|
||||
var files = event.originalEvent.dataTransfer.files;
|
||||
if (!files || files.length === 0) {
|
||||
// No files actually transferred
|
||||
$('.pma_drop_handler').fadeOut();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
$('.pma_sql_import_status').slideDown();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var ext = (PMA_DROP_IMPORT._getExtension(files[i].name));
|
||||
var hash = AJAX.hash(++PMA_DROP_IMPORT.uploadCount);
|
||||
|
||||
var $pma_sql_import_status_div = $('.pma_sql_import_status div');
|
||||
$pma_sql_import_status_div.append('<li data-hash="' + hash + '">' +
|
||||
((ext !== '') ? '' : '<img src="./themes/dot.gif" title="invalid format" class="icon ic_s_notice"> ') +
|
||||
escapeHtml(files[i].name) + '<span class="filesize" data-filename="' +
|
||||
escapeHtml(files[i].name) + '">' + (files[i].size / 1024).toFixed(2) +
|
||||
' kb</span></li>');
|
||||
|
||||
// scroll the UI to bottom
|
||||
$pma_sql_import_status_div.scrollTop(
|
||||
$pma_sql_import_status_div.scrollTop() + 50
|
||||
); // 50 hardcoded for now
|
||||
|
||||
if (ext !== '') {
|
||||
// Increment liveUploadCount by one
|
||||
$('.pma_import_count').html(++PMA_DROP_IMPORT.liveUploadCount);
|
||||
$('.pma_sql_import_status h2 .close').fadeOut();
|
||||
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.append('<br><progress max="100" value="2"></progress>');
|
||||
|
||||
// uploading
|
||||
var fd = new FormData();
|
||||
fd.append('import_file', files[i]);
|
||||
fd.append('noplugin', Math.random().toString(36).substring(2, 12));
|
||||
fd.append('db', dbname);
|
||||
fd.append('server', server);
|
||||
fd.append('token', PMA_commonParams.get('token'));
|
||||
fd.append('import_type', 'database');
|
||||
// todo: method to find the value below
|
||||
fd.append('MAX_FILE_SIZE', '4194304');
|
||||
// todo: method to find the value below
|
||||
fd.append('charset_of_file','utf-8');
|
||||
// todo: method to find the value below
|
||||
fd.append('allow_interrupt', 'yes');
|
||||
fd.append('skip_queries', '0');
|
||||
fd.append('format',ext);
|
||||
fd.append('sql_compatibility','NONE');
|
||||
fd.append('sql_no_auto_value_on_zero','something');
|
||||
fd.append('ajax_request','true');
|
||||
fd.append('hash', hash);
|
||||
|
||||
// init uploading
|
||||
PMA_DROP_IMPORT._sendFileToServer(fd, hash);
|
||||
} else if (!PMA_DROP_IMPORT.liveUploadCount) {
|
||||
$('.pma_sql_import_status h2 .close').fadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
$('.pma_drop_handler').fadeOut();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when some user drags, dragover, leave
|
||||
* a file to the PMA UI
|
||||
* @param object Event data
|
||||
* @return void
|
||||
*/
|
||||
$(document).on('dragenter', PMA_DROP_IMPORT._dragenter);
|
||||
$(document).on('dragover', PMA_DROP_IMPORT._dragover);
|
||||
$(document).on('dragleave', '.pma_drop_handler', PMA_DROP_IMPORT._dragleave);
|
||||
|
||||
// when file is dropped to PMA UI
|
||||
$(document).on('drop', 'body', PMA_DROP_IMPORT._drop);
|
||||
|
||||
// minimizing-maximising the sql ajax upload status
|
||||
$(document).on('click', '.pma_sql_import_status h2 .minimize', function () {
|
||||
if ($(this).attr('toggle') === 'off') {
|
||||
$('.pma_sql_import_status div').css('height','270px');
|
||||
$(this).attr('toggle','on');
|
||||
$(this).html('-'); // to minimize
|
||||
} else {
|
||||
$('.pma_sql_import_status div').css('height','0px');
|
||||
$(this).attr('toggle','off');
|
||||
$(this).html('+'); // to maximise
|
||||
}
|
||||
});
|
||||
|
||||
// closing sql ajax upload status
|
||||
$(document).on('click', '.pma_sql_import_status h2 .close', function () {
|
||||
$('.pma_sql_import_status').fadeOut(function () {
|
||||
$('.pma_sql_import_status div').html('');
|
||||
PMA_DROP_IMPORT.importStatus = []; // clear the message array
|
||||
});
|
||||
});
|
||||
|
||||
// Closing the import result box
|
||||
$(document).on('click', '.pma_drop_result h2 .close', function () {
|
||||
$(this).parent('h2').parent('div').remove();
|
||||
});
|
||||
|
||||
299
js/config.js
299
js/config.js
@ -3,6 +3,9 @@
|
||||
* Functions used in configuration forms and on user preferences pages
|
||||
*/
|
||||
|
||||
var configInlineParams;
|
||||
var configScriptLoaded;
|
||||
|
||||
/**
|
||||
* checks whether browser supports web storage
|
||||
*
|
||||
@ -22,7 +25,7 @@ function isStorageSupported (type, warn) {
|
||||
} catch (error) {
|
||||
// Not supported
|
||||
if (warn) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strNoLocalStorage, false);
|
||||
Functions.ajaxShowMessage(Messages.strNoLocalStorage, false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -42,9 +45,9 @@ AJAX.registerTeardown('config.js', function () {
|
||||
});
|
||||
|
||||
AJAX.registerOnload('config.js', function () {
|
||||
var $topmenu_upt = $('#topmenu2.user_prefs_tabs');
|
||||
$topmenu_upt.find('li.active a').attr('rel', 'samepage');
|
||||
$topmenu_upt.find('li:not(.active) a').attr('rel', 'newpage');
|
||||
var $topmenuUpt = $('#topmenu2.user_prefs_tabs');
|
||||
$topmenuUpt.find('li.active a').attr('rel', 'samepage');
|
||||
$topmenuUpt.find('li:not(.active) a').attr('rel', 'newpage');
|
||||
});
|
||||
|
||||
// default values for fields
|
||||
@ -105,12 +108,12 @@ function markField (field) {
|
||||
* o Array of values - if field_type is 'select'
|
||||
*
|
||||
* @param {Element} field
|
||||
* @param {String} field_type see {@link #getFieldType}
|
||||
* @param {String} fieldType see {@link #getFieldType}
|
||||
* @param {String|Boolean} value
|
||||
*/
|
||||
function setFieldValue (field, field_type, value) {
|
||||
function setFieldValue (field, fieldType, value) {
|
||||
var $field = $(field);
|
||||
switch (field_type) {
|
||||
switch (fieldType) {
|
||||
case 'text':
|
||||
case 'number':
|
||||
$field.val(value);
|
||||
@ -122,9 +125,8 @@ function setFieldValue (field, field_type, value) {
|
||||
var options = $field.prop('options');
|
||||
var i;
|
||||
var imax = options.length;
|
||||
var i, imax = options.length;
|
||||
for (i = 0; i < imax; i++) {
|
||||
options[i].selected = (value.indexOf(options[i].value) != -1);
|
||||
options[i].selected = (value.indexOf(options[i].value) !== -1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -140,12 +142,12 @@ function setFieldValue (field, field_type, value) {
|
||||
* o Array of values - if type is 'select'
|
||||
*
|
||||
* @param {Element} field
|
||||
* @param {String} field_type returned by {@link #getFieldType}
|
||||
* @param {String} fieldType returned by {@link #getFieldType}
|
||||
* @type Boolean|String|String[]
|
||||
*/
|
||||
function getFieldValue (field, field_type) {
|
||||
function getFieldValue (field, fieldType) {
|
||||
var $field = $(field);
|
||||
switch (field_type) {
|
||||
switch (fieldType) {
|
||||
case 'text':
|
||||
case 'number':
|
||||
return $field.prop('value');
|
||||
@ -169,6 +171,7 @@ function getFieldValue (field, field_type) {
|
||||
/**
|
||||
* Returns values for all fields in fieldsets
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function getAllValues () {
|
||||
var $elements = $('fieldset input, fieldset select, fieldset textarea');
|
||||
var values = {};
|
||||
@ -197,21 +200,21 @@ function getAllValues () {
|
||||
*/
|
||||
function checkFieldDefault (field, type) {
|
||||
var $field = $(field);
|
||||
var field_id = $field.attr('id');
|
||||
if (typeof defaultValues[field_id] === 'undefined') {
|
||||
var fieldId = $field.attr('id');
|
||||
if (typeof defaultValues[fieldId] === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
var isDefault = true;
|
||||
var currentValue = getFieldValue($field, type);
|
||||
if (type !== 'select') {
|
||||
isDefault = currentValue === defaultValues[field_id];
|
||||
isDefault = currentValue === defaultValues[fieldId];
|
||||
} else {
|
||||
// compare arrays, will work for our representation of select values
|
||||
if (currentValue.length !== defaultValues[field_id].length) {
|
||||
if (currentValue.length !== defaultValues[fieldId].length) {
|
||||
isDefault = false;
|
||||
} else {
|
||||
for (var i = 0; i < currentValue.length; i++) {
|
||||
if (currentValue[i] !== defaultValues[field_id][i]) {
|
||||
if (currentValue[i] !== defaultValues[fieldId][i]) {
|
||||
isDefault = false;
|
||||
break;
|
||||
}
|
||||
@ -225,6 +228,7 @@ function checkFieldDefault (field, type) {
|
||||
* Returns element's id prefix
|
||||
* @param {Element} element
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function getIdPrefix (element) {
|
||||
return $(element).attr('id').replace(/[^-]+$/, '');
|
||||
}
|
||||
@ -239,44 +243,42 @@ var validate = {};
|
||||
// form validator list
|
||||
var validators = {
|
||||
// regexp: numeric value
|
||||
_regexp_numeric: /^[0-9]+$/,
|
||||
regExpNumeric: /^[0-9]+$/,
|
||||
// regexp: extract parts from PCRE expression
|
||||
_regexp_pcre_extract: /(.)(.*)\1(.*)?/,
|
||||
regExpPcreExtract: /(.)(.*)\1(.*)?/,
|
||||
/**
|
||||
* Validates positive number
|
||||
*
|
||||
* @param {boolean} isKeyUp
|
||||
*/
|
||||
PMA_validatePositiveNumber: function (isKeyUp) {
|
||||
validatePositiveNumber: function (isKeyUp) {
|
||||
if (isKeyUp && this.value === '') {
|
||||
return true;
|
||||
}
|
||||
var result = this.value !== '0' && validators._regexp_numeric.test(this.value);
|
||||
return result ? true : PMA_messages.error_nan_p;
|
||||
var result = this.value !== '0' && validators.regExpNumeric.test(this.value);
|
||||
return result ? true : Messages.error_nan_p;
|
||||
},
|
||||
/**
|
||||
* Validates non-negative number
|
||||
*
|
||||
* @param {boolean} isKeyUp
|
||||
*/
|
||||
PMA_validateNonNegativeNumber: function (isKeyUp) {
|
||||
validateNonNegativeNumber: function (isKeyUp) {
|
||||
if (isKeyUp && this.value === '') {
|
||||
return true;
|
||||
}
|
||||
var result = validators._regexp_numeric.test(this.value);
|
||||
return result ? true : PMA_messages.error_nan_nneg;
|
||||
var result = validators.regExpNumeric.test(this.value);
|
||||
return result ? true : Messages.error_nan_nneg;
|
||||
},
|
||||
/**
|
||||
* Validates port number
|
||||
*
|
||||
* @param {boolean} isKeyUp
|
||||
*/
|
||||
PMA_validatePortNumber: function (isKeyUp) {
|
||||
validatePortNumber: function () {
|
||||
if (this.value === '') {
|
||||
return true;
|
||||
}
|
||||
var result = validators._regexp_numeric.test(this.value) && this.value !== '0';
|
||||
return result && this.value <= 65535 ? true : PMA_messages.error_incorrect_port;
|
||||
var result = validators.regExpNumeric.test(this.value) && this.value !== '0';
|
||||
return result && this.value <= 65535 ? true : Messages.error_incorrect_port;
|
||||
},
|
||||
/**
|
||||
* Validates value according to given regular expression
|
||||
@ -284,33 +286,33 @@ var validators = {
|
||||
* @param {boolean} isKeyUp
|
||||
* @param {string} regexp
|
||||
*/
|
||||
PMA_validateByRegex: function (isKeyUp, regexp) {
|
||||
validateByRegex: function (isKeyUp, regexp) {
|
||||
if (isKeyUp && this.value === '') {
|
||||
return true;
|
||||
}
|
||||
// convert PCRE regexp
|
||||
var parts = regexp.match(validators._regexp_pcre_extract);
|
||||
var parts = regexp.match(validators.regExpPcreExtract);
|
||||
var valid = this.value.match(new RegExp(parts[2], parts[3])) !== null;
|
||||
return valid ? true : PMA_messages.error_invalid_value;
|
||||
return valid ? true : Messages.error_invalid_value;
|
||||
},
|
||||
/**
|
||||
* Validates upper bound for numeric inputs
|
||||
*
|
||||
* @param {boolean} isKeyUp
|
||||
* @param {int} max_value
|
||||
* @param {int} maxValue
|
||||
*/
|
||||
PMA_validateUpperBound: function (isKeyUp, max_value) {
|
||||
validateUpperBound: function (isKeyUp, maxValue) {
|
||||
var val = parseInt(this.value, 10);
|
||||
if (isNaN(val)) {
|
||||
return true;
|
||||
}
|
||||
return val <= max_value ? true : PMA_sprintf(PMA_messages.error_value_lte, max_value);
|
||||
return val <= maxValue ? true : Functions.sprintf(Messages.error_value_lte, maxValue);
|
||||
},
|
||||
// field validators
|
||||
_field: {
|
||||
field: {
|
||||
},
|
||||
// fieldset validators
|
||||
_fieldset: {
|
||||
fieldset: {
|
||||
}
|
||||
};
|
||||
|
||||
@ -322,7 +324,8 @@ var validators = {
|
||||
* @param {boolean} onKeyUp whether fire on key up
|
||||
* @param {Array} params validation function parameters
|
||||
*/
|
||||
function validateField (id, type, onKeyUp, params) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function registerFieldValidator (id, type, onKeyUp, params) {
|
||||
if (typeof validators[type] === 'undefined') {
|
||||
return;
|
||||
}
|
||||
@ -337,27 +340,27 @@ function validateField (id, type, onKeyUp, params) {
|
||||
/**
|
||||
* Returns validation functions associated with form field
|
||||
*
|
||||
* @param {String} field_id form field id
|
||||
* @param {boolean} onKeyUpOnly see validateField
|
||||
* @param {String} fieldId form field id
|
||||
* @param {boolean} onKeyUpOnly see registerFieldValidator
|
||||
* @type Array
|
||||
* @return array of [function, parameters to be passed to function]
|
||||
*/
|
||||
function getFieldValidators (field_id, onKeyUpOnly) {
|
||||
function getFieldValidators (fieldId, onKeyUpOnly) {
|
||||
// look for field bound validator
|
||||
var name = field_id && field_id.match(/[^-]+$/)[0];
|
||||
if (typeof validators._field[name] !== 'undefined') {
|
||||
return [[validators._field[name], null]];
|
||||
var name = fieldId && fieldId.match(/[^-]+$/)[0];
|
||||
if (typeof validators.field[name] !== 'undefined') {
|
||||
return [[validators.field[name], null]];
|
||||
}
|
||||
|
||||
// look for registered validators
|
||||
var functions = [];
|
||||
if (typeof validate[field_id] !== 'undefined') {
|
||||
if (typeof validate[fieldId] !== 'undefined') {
|
||||
// validate[field_id]: array of [type, params, onKeyUp]
|
||||
for (var i = 0, imax = validate[field_id].length; i < imax; i++) {
|
||||
if (onKeyUpOnly && !validate[field_id][i][2]) {
|
||||
for (var i = 0, imax = validate[fieldId].length; i < imax; i++) {
|
||||
if (onKeyUpOnly && !validate[fieldId][i][2]) {
|
||||
continue;
|
||||
}
|
||||
functions.push([validators[validate[field_id][i][0]], validate[field_id][i][1]]);
|
||||
functions.push([validators[validate[fieldId][i][0]], validate[fieldId][i][1]]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,16 +373,16 @@ function getFieldValidators (field_id, onKeyUpOnly) {
|
||||
* WARNING: created DOM elements must be identical with the ones made by
|
||||
* PhpMyAdmin\Config\FormDisplayTemplate::displayInput()!
|
||||
*
|
||||
* @param {Object} error_list list of errors in the form {field id: error array}
|
||||
* @param {Object} errorList list of errors in the form {field id: error array}
|
||||
*/
|
||||
function displayErrors (error_list) {
|
||||
function displayErrors (errorList) {
|
||||
var tempIsEmpty = function (item) {
|
||||
return item !== '';
|
||||
};
|
||||
|
||||
for (var field_id in error_list) {
|
||||
var errors = error_list[field_id];
|
||||
var $field = $('#' + field_id);
|
||||
for (var fieldId in errorList) {
|
||||
var errors = errorList[fieldId];
|
||||
var $field = $('#' + fieldId);
|
||||
var isFieldset = $field.attr('tagName') === 'FIELDSET';
|
||||
var $errorCnt;
|
||||
if (isFieldset) {
|
||||
@ -402,10 +405,10 @@ function displayErrors (error_list) {
|
||||
// if error container doesn't exist, create it
|
||||
if ($errorCnt.length === 0) {
|
||||
if (isFieldset) {
|
||||
$errorCnt = $('<dl class="errors" />');
|
||||
$errorCnt = $('<dl class="errors"></dl>');
|
||||
$field.find('table').before($errorCnt);
|
||||
} else {
|
||||
$errorCnt = $('<dl class="inline_errors" />');
|
||||
$errorCnt = $('<dl class="inline_errors"></dl>');
|
||||
$field.closest('td').append($errorCnt);
|
||||
}
|
||||
}
|
||||
@ -425,16 +428,16 @@ function displayErrors (error_list) {
|
||||
/**
|
||||
* Validates fields and fieldsets and call displayError function as required
|
||||
*/
|
||||
function setDisplayError() {
|
||||
function setDisplayError () {
|
||||
var elements = $('.optbox input[id], .optbox select[id], .optbox textarea[id]');
|
||||
// run all field validators
|
||||
var errors = {};
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
validate_field(elements[i], false, errors);
|
||||
validateField(elements[i], false, errors);
|
||||
}
|
||||
// run all fieldset validators
|
||||
$('fieldset.optbox').each(function () {
|
||||
validate_fieldset(this, false, errors);
|
||||
validateFieldset(this, false, errors);
|
||||
});
|
||||
displayErrors(errors);
|
||||
}
|
||||
@ -446,18 +449,18 @@ function setDisplayError() {
|
||||
* @param {boolean} isKeyUp
|
||||
* @param {Object} errors
|
||||
*/
|
||||
function validate_fieldset (fieldset, isKeyUp, errors) {
|
||||
function validateFieldset (fieldset, isKeyUp, errors) {
|
||||
var $fieldset = $(fieldset);
|
||||
if ($fieldset.length && typeof validators._fieldset[$fieldset.attr('id')] !== 'undefined') {
|
||||
var fieldset_errors = validators._fieldset[$fieldset.attr('id')].apply($fieldset[0], [isKeyUp]);
|
||||
for (var field_id in fieldset_errors) {
|
||||
if (typeof errors[field_id] === 'undefined') {
|
||||
errors[field_id] = [];
|
||||
if ($fieldset.length && typeof validators.fieldset[$fieldset.attr('id')] !== 'undefined') {
|
||||
var fieldsetErrors = validators.fieldset[$fieldset.attr('id')].apply($fieldset[0], [isKeyUp]);
|
||||
for (var fieldId in fieldsetErrors) {
|
||||
if (typeof errors[fieldId] === 'undefined') {
|
||||
errors[fieldId] = [];
|
||||
}
|
||||
if (typeof fieldset_errors[field_id] === 'string') {
|
||||
fieldset_errors[field_id] = [fieldset_errors[field_id]];
|
||||
if (typeof fieldsetErrors[fieldId] === 'string') {
|
||||
fieldsetErrors[fieldId] = [fieldsetErrors[fieldId]];
|
||||
}
|
||||
$.merge(errors[field_id], fieldset_errors[field_id]);
|
||||
$.merge(errors[fieldId], fieldsetErrors[fieldId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -469,13 +472,13 @@ function validate_fieldset (fieldset, isKeyUp, errors) {
|
||||
* @param {boolean} isKeyUp
|
||||
* @param {Object} errors
|
||||
*/
|
||||
function validate_field (field, isKeyUp, errors) {
|
||||
function validateField (field, isKeyUp, errors) {
|
||||
var args;
|
||||
var result;
|
||||
var $field = $(field);
|
||||
var field_id = $field.attr('id');
|
||||
errors[field_id] = [];
|
||||
var functions = getFieldValidators(field_id, isKeyUp);
|
||||
var fieldId = $field.attr('id');
|
||||
errors[fieldId] = [];
|
||||
var functions = getFieldValidators(fieldId, isKeyUp);
|
||||
for (var i = 0; i < functions.length; i++) {
|
||||
if (typeof functions[i][1] !== 'undefined' && functions[i][1] !== null) {
|
||||
args = functions[i][1].slice(0);
|
||||
@ -488,7 +491,7 @@ function validate_field (field, isKeyUp, errors) {
|
||||
if (typeof result === 'string') {
|
||||
result = [result];
|
||||
}
|
||||
$.merge(errors[field_id], result);
|
||||
$.merge(errors[fieldId], result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -499,11 +502,11 @@ function validate_field (field, isKeyUp, errors) {
|
||||
* @param {Element} field
|
||||
* @param {boolean} isKeyUp
|
||||
*/
|
||||
function validate_field_and_fieldset (field, isKeyUp) {
|
||||
function validateFieldAndFieldset (field, isKeyUp) {
|
||||
var $field = $(field);
|
||||
var errors = {};
|
||||
validate_field($field, isKeyUp, errors);
|
||||
validate_fieldset($field.closest('fieldset.optbox'), isKeyUp, errors);
|
||||
validateField($field, isKeyUp, errors);
|
||||
validateFieldset($field.closest('fieldset.optbox'), isKeyUp, errors);
|
||||
displayErrors(errors);
|
||||
}
|
||||
|
||||
@ -530,14 +533,14 @@ function setupValidation () {
|
||||
markField(this);
|
||||
var $el = $(this);
|
||||
$el.on('change', function () {
|
||||
validate_field_and_fieldset(this, false);
|
||||
validateFieldAndFieldset(this, false);
|
||||
markField(this);
|
||||
});
|
||||
var tagName = $el.attr('tagName');
|
||||
// text fields can be validated after each change
|
||||
if (tagName === 'INPUT' && $el.attr('type') === 'text') {
|
||||
$el.keyup(function () {
|
||||
validate_field_and_fieldset($el, true);
|
||||
$el.on('keyup', function () {
|
||||
validateFieldAndFieldset($el, true);
|
||||
markField($el);
|
||||
});
|
||||
}
|
||||
@ -549,21 +552,21 @@ function setupValidation () {
|
||||
|
||||
// check whether we've refreshed a page and browser remembered modified
|
||||
// form values
|
||||
var $check_page_refresh = $('#check_page_refresh');
|
||||
if ($check_page_refresh.length === 0 || $check_page_refresh.val() === '1') {
|
||||
var $checkPageRefresh = $('#check_page_refresh');
|
||||
if ($checkPageRefresh.length === 0 || $checkPageRefresh.val() === '1') {
|
||||
// run all field validators
|
||||
var errors = {};
|
||||
for (var i = 0; i < $elements.length; i++) {
|
||||
validate_field($elements[i], false, errors);
|
||||
validateField($elements[i], false, errors);
|
||||
}
|
||||
// run all fieldset validators
|
||||
$('fieldset.optbox').each(function () {
|
||||
validate_fieldset(this, false, errors);
|
||||
validateFieldset(this, false, errors);
|
||||
});
|
||||
|
||||
displayErrors(errors);
|
||||
} else if ($check_page_refresh) {
|
||||
$check_page_refresh.val('1');
|
||||
} else if ($checkPageRefresh) {
|
||||
$checkPageRefresh.val('1');
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,17 +585,17 @@ AJAX.registerOnload('config.js', function () {
|
||||
/**
|
||||
* Sets active tab
|
||||
*
|
||||
* @param {String} tab_id
|
||||
* @param {String} tabId
|
||||
*/
|
||||
function setTab (tab_id) {
|
||||
function setTab (tabId) {
|
||||
$('ul.tabs').each(function () {
|
||||
var $this = $(this);
|
||||
if (!$this.find('li a[href="#' + tab_id + '"]').length) {
|
||||
if (!$this.find('li a[href="#' + tabId + '"]').length) {
|
||||
return;
|
||||
}
|
||||
$this.find('li').removeClass('active').find('a[href="#' + tab_id + '"]').parent().addClass('active');
|
||||
$this.parent().find('div.tabs_contents fieldset').hide().filter('#' + tab_id).show();
|
||||
var hashValue = 'tab_' + tab_id;
|
||||
$this.find('li').removeClass('active').find('a[href="#' + tabId + '"]').parent().addClass('active');
|
||||
$this.parent().find('div.tabs_contents fieldset').hide().filter('#' + tabId).show();
|
||||
var hashValue = 'tab_' + tabId;
|
||||
location.hash = hashValue;
|
||||
$this.parent().find('input[name=tab_hash]').val(hashValue);
|
||||
});
|
||||
@ -609,7 +612,7 @@ function setupConfigTabs () {
|
||||
// add tabs events and activate one tab (the first one or indicated by location hash)
|
||||
$tabs.find('li').removeClass('active');
|
||||
$tabs.find('a')
|
||||
.click(function (e) {
|
||||
.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
setTab($(this).attr('href').substr(1));
|
||||
})
|
||||
@ -636,21 +639,21 @@ AJAX.registerOnload('config.js', function () {
|
||||
|
||||
// tab links handling, check each 200ms
|
||||
// (works with history in FF, further browser support here would be an overkill)
|
||||
var prev_hash;
|
||||
var tab_check_fnc = function () {
|
||||
if (location.hash !== prev_hash) {
|
||||
prev_hash = location.hash;
|
||||
if (prev_hash.match(/^#tab_[a-zA-Z0-9_]+$/)) {
|
||||
var prevHash;
|
||||
var tabCheckFnc = function () {
|
||||
if (location.hash !== prevHash) {
|
||||
prevHash = location.hash;
|
||||
if (prevHash.match(/^#tab_[a-zA-Z0-9_]+$/)) {
|
||||
// session ID is sometimes appended here
|
||||
var hash = prev_hash.substr(5).split('&')[0];
|
||||
var hash = prevHash.substr(5).split('&')[0];
|
||||
if ($('#' + hash).length) {
|
||||
setTab(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
tab_check_fnc();
|
||||
setInterval(tab_check_fnc, 200);
|
||||
tabCheckFnc();
|
||||
setInterval(tabCheckFnc, 200);
|
||||
});
|
||||
|
||||
//
|
||||
@ -682,14 +685,14 @@ AJAX.registerOnload('config.js', function () {
|
||||
/**
|
||||
* Restores field's default value
|
||||
*
|
||||
* @param {String} field_id
|
||||
* @param {String} fieldId
|
||||
*/
|
||||
function restoreField (field_id) {
|
||||
var $field = $('#' + field_id);
|
||||
if ($field.length === 0 || defaultValues[field_id] === undefined) {
|
||||
function restoreField (fieldId) {
|
||||
var $field = $('#' + fieldId);
|
||||
if ($field.length === 0 || defaultValues[fieldId] === undefined) {
|
||||
return;
|
||||
}
|
||||
setFieldValue($field, getFieldType($field), defaultValues[field_id]);
|
||||
setFieldValue($field, getFieldType($field), defaultValues[fieldId]);
|
||||
}
|
||||
|
||||
function setupRestoreField () {
|
||||
@ -703,16 +706,16 @@ function setupRestoreField () {
|
||||
.on('click', '.restore-default, .set-value', function (e) {
|
||||
e.preventDefault();
|
||||
var href = $(this).attr('href');
|
||||
var field_sel;
|
||||
var fieldSel;
|
||||
if ($(this).hasClass('restore-default')) {
|
||||
field_sel = href;
|
||||
restoreField(field_sel.substr(1));
|
||||
fieldSel = href;
|
||||
restoreField(fieldSel.substr(1));
|
||||
} else {
|
||||
field_sel = href.match(/^[^=]+/)[0];
|
||||
var value = href.match(/\=(.+)$/)[1];
|
||||
setFieldValue($(field_sel), 'text', value);
|
||||
fieldSel = href.match(/^[^=]+/)[0];
|
||||
var value = href.match(/=(.+)$/)[1];
|
||||
setFieldValue($(fieldSel), 'text', value);
|
||||
}
|
||||
$(field_sel).trigger('change');
|
||||
$(fieldSel).trigger('change');
|
||||
})
|
||||
.find('.restore-default, .set-value')
|
||||
// inline-block for IE so opacity inheritance works
|
||||
@ -742,32 +745,32 @@ AJAX.registerOnload('config.js', function () {
|
||||
$radios
|
||||
.prop('disabled', false)
|
||||
.add('#export_text_file, #import_text_file')
|
||||
.click(function () {
|
||||
var enable_id = $(this).attr('id');
|
||||
var disable_id;
|
||||
if (enable_id.match(/local_storage$/)) {
|
||||
disable_id = enable_id.replace(/local_storage$/, 'text_file');
|
||||
.on('click', function () {
|
||||
var enableId = $(this).attr('id');
|
||||
var disableId;
|
||||
if (enableId.match(/local_storage$/)) {
|
||||
disableId = enableId.replace(/local_storage$/, 'text_file');
|
||||
} else {
|
||||
disable_id = enable_id.replace(/text_file$/, 'local_storage');
|
||||
disableId = enableId.replace(/text_file$/, 'local_storage');
|
||||
}
|
||||
$('#opts_' + disable_id).addClass('disabled').find('input').prop('disabled', true);
|
||||
$('#opts_' + enable_id).removeClass('disabled').find('input').prop('disabled', false);
|
||||
$('#opts_' + disableId).addClass('disabled').find('input').prop('disabled', true);
|
||||
$('#opts_' + enableId).removeClass('disabled').find('input').prop('disabled', false);
|
||||
});
|
||||
|
||||
// detect localStorage state
|
||||
var ls_supported = isStorageSupported('localStorage', true);
|
||||
var ls_exists = ls_supported ? (window.localStorage.config || false) : false;
|
||||
$('div.localStorage-' + (ls_supported ? 'un' : '') + 'supported').hide();
|
||||
$('div.localStorage-' + (ls_exists ? 'empty' : 'exists')).hide();
|
||||
if (ls_exists) {
|
||||
var lsSupported = isStorageSupported('localStorage', true);
|
||||
var lsExists = lsSupported ? (window.localStorage.config || false) : false;
|
||||
$('div.localStorage-' + (lsSupported ? 'un' : '') + 'supported').hide();
|
||||
$('div.localStorage-' + (lsExists ? 'empty' : 'exists')).hide();
|
||||
if (lsExists) {
|
||||
updatePrefsDate();
|
||||
}
|
||||
$('form.prefs-form').change(function () {
|
||||
$('form.prefs-form').on('change', function () {
|
||||
var $form = $(this);
|
||||
var disabled = false;
|
||||
if (!ls_supported) {
|
||||
if (!lsSupported) {
|
||||
disabled = $form.find('input[type=radio][value$=local_storage]').prop('checked');
|
||||
} else if (!ls_exists && $form.attr('name') === 'prefs_import' &&
|
||||
} else if (!lsExists && $form.attr('name') === 'prefs_import' &&
|
||||
$('#import_local_storage')[0].checked
|
||||
) {
|
||||
disabled = true;
|
||||
@ -801,7 +804,7 @@ AJAX.registerOnload('config.js', function () {
|
||||
* @param {Element} form
|
||||
*/
|
||||
function savePrefsToLocalStorage (form) {
|
||||
$form = $(form);
|
||||
var $form = $(form);
|
||||
var submit = $form.find('input[type=submit]');
|
||||
submit.prop('disabled', true);
|
||||
$.ajax({
|
||||
@ -809,15 +812,15 @@ function savePrefsToLocalStorage (form) {
|
||||
cache: false,
|
||||
type: 'POST',
|
||||
data: {
|
||||
ajax_request: true,
|
||||
server: PMA_commonParams.get('server'),
|
||||
submit_get_json: true
|
||||
'ajax_request': true,
|
||||
'server': CommonParams.get('server'),
|
||||
'submit_get_json': true
|
||||
},
|
||||
success: function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
window.localStorage.config = data.prefs;
|
||||
window.localStorage.config_mtime = data.mtime;
|
||||
window.localStorage.config_mtime_local = (new Date()).toUTCString();
|
||||
window.localStorage.configMtime = data.mtime;
|
||||
window.localStorage.configMtimeLocal = (new Date()).toUTCString();
|
||||
updatePrefsDate();
|
||||
$('div.localStorage-empty').hide();
|
||||
$('div.localStorage-exists').show();
|
||||
@ -826,7 +829,7 @@ function savePrefsToLocalStorage (form) {
|
||||
$form.hide('fast');
|
||||
$form.prev('.click-hide-message').show('fast');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
Functions.ajaxShowMessage(data.error);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
@ -839,10 +842,10 @@ function savePrefsToLocalStorage (form) {
|
||||
* Updates preferences timestamp in Import form
|
||||
*/
|
||||
function updatePrefsDate () {
|
||||
var d = new Date(window.localStorage.config_mtime_local);
|
||||
var msg = PMA_messages.strSavedOn.replace(
|
||||
var d = new Date(window.localStorage.configMtimeLocal);
|
||||
var msg = Messages.strSavedOn.replace(
|
||||
'@DATE@',
|
||||
PMA_formatDateTime(d)
|
||||
Functions.formatDateTime(d)
|
||||
);
|
||||
$('#opts_import_local_storage').find('div.localStorage-exists').html(msg);
|
||||
}
|
||||
@ -851,36 +854,32 @@ function updatePrefsDate () {
|
||||
* Prepares message which informs that localStorage preferences are available and can be imported or deleted
|
||||
*/
|
||||
function offerPrefsAutoimport () {
|
||||
var has_config = (isStorageSupported('localStorage')) && (window.localStorage.config || false);
|
||||
var hasConfig = (isStorageSupported('localStorage')) && (window.localStorage.config || false);
|
||||
var $cnt = $('#prefs_autoload');
|
||||
if (!$cnt.length || !has_config) {
|
||||
if (!$cnt.length || !hasConfig) {
|
||||
return;
|
||||
}
|
||||
$cnt.find('a').click(function (e) {
|
||||
$cnt.find('a').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $a = $(this);
|
||||
if ($a.attr('href') === '#no') {
|
||||
$cnt.remove();
|
||||
$.post('index.php', {
|
||||
server: PMA_commonParams.get('server'),
|
||||
prefs_autoload: 'hide'
|
||||
'server': CommonParams.get('server'),
|
||||
'prefs_autoload': 'hide'
|
||||
}, null, 'html');
|
||||
return;
|
||||
} else if ($a.attr('href') === '#delete') {
|
||||
$cnt.remove();
|
||||
localStorage.clear();
|
||||
$.post('index.php', {
|
||||
server: PMA_commonParams.get('server'),
|
||||
prefs_autoload: 'hide'
|
||||
'server': CommonParams.get('server'),
|
||||
'prefs_autoload': 'hide'
|
||||
}, null, 'html');
|
||||
return;
|
||||
}
|
||||
$cnt.find('input[name=json]').val(window.localStorage.config);
|
||||
$cnt.find('form').submit();
|
||||
$cnt.find('form').trigger('submit');
|
||||
});
|
||||
$cnt.show();
|
||||
}
|
||||
|
||||
//
|
||||
// END: User preferences import/export
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
720
js/console.js
720
js/console.js
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,11 @@
|
||||
* Conditionally included if framing is not allowed
|
||||
*/
|
||||
if (self === top) {
|
||||
var style_element = document.getElementById('cfs-style');
|
||||
// check if style_element has already been removed
|
||||
var styleElement = document.getElementById('cfs-style');
|
||||
// check if styleElement has already been removed
|
||||
// to avoid frequently reported js error
|
||||
if (typeof(style_element) !== 'undefined' && style_element !== null) {
|
||||
style_element.parentNode.removeChild(style_element);
|
||||
if (typeof(styleElement) !== 'undefined' && styleElement !== null) {
|
||||
styleElement.parentNode.removeChild(styleElement);
|
||||
}
|
||||
} else {
|
||||
top.location = self.location;
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
AJAX.registerTeardown('db_central_columns.js', function () {
|
||||
AJAX.registerTeardown('database/central_columns.js', function () {
|
||||
$('.edit').off('click');
|
||||
$('.edit_save_form').off('click');
|
||||
$('.edit_cancel_form').off('click');
|
||||
@ -33,7 +33,7 @@ AJAX.registerTeardown('db_central_columns.js', function () {
|
||||
$('button[name=\'edit_central_columns\']').off('click');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('db_central_columns.js', function () {
|
||||
AJAX.registerOnload('database/central_columns.js', function () {
|
||||
$('#tableslistcontainer input,#tableslistcontainer select,#tableslistcontainer .default_value,#tableslistcontainer .open_enum_editor').hide();
|
||||
$('#tableslistcontainer').find('.checkall').show();
|
||||
$('#tableslistcontainer').find('.checkall_box').show();
|
||||
@ -46,38 +46,38 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#tableslistcontainer').find('button[name="delete_central_columns"]').click(function (event) {
|
||||
$('#tableslistcontainer').find('button[name="delete_central_columns"]').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var multi_delete_columns = $('.checkall:checkbox:checked').serialize();
|
||||
if (multi_delete_columns === '') {
|
||||
PMA_ajaxShowMessage(PMA_messages.strRadioUnchecked);
|
||||
var multiDeleteColumns = $('.checkall:checkbox:checked').serialize();
|
||||
if (multiDeleteColumns === '') {
|
||||
Functions.ajaxShowMessage(Messages.strRadioUnchecked);
|
||||
return false;
|
||||
}
|
||||
PMA_ajaxShowMessage();
|
||||
$('#del_col_name').val(multi_delete_columns);
|
||||
$('#del_form').submit();
|
||||
Functions.ajaxShowMessage();
|
||||
$('#del_col_name').val(multiDeleteColumns);
|
||||
$('#del_form').trigger('submit');
|
||||
});
|
||||
$('#tableslistcontainer').find('button[name="edit_central_columns"]').click(function (event) {
|
||||
$('#tableslistcontainer').find('button[name="edit_central_columns"]').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var editColumnList = $('.checkall:checkbox:checked').serialize();
|
||||
if (editColumnList === '') {
|
||||
PMA_ajaxShowMessage(PMA_messages.strRadioUnchecked);
|
||||
Functions.ajaxShowMessage(Messages.strRadioUnchecked);
|
||||
return false;
|
||||
}
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var editColumnData = editColumnList + '' + argsep + 'edit_central_columns_page=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(PMA_commonParams.get('db'));
|
||||
PMA_ajaxShowMessage();
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var editColumnData = editColumnList + '' + argsep + 'edit_central_columns_page=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db'));
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $(this);
|
||||
$.post('db_central_columns.php', editColumnData, AJAX.responseHandler);
|
||||
});
|
||||
$('#multi_edit_central_columns').submit(function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var multi_column_edit_data = $('#multi_edit_central_columns').serialize() + argsep + 'multi_edit_central_column_save=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(PMA_commonParams.get('db'));
|
||||
PMA_ajaxShowMessage();
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var multiColumnEditData = $('#multi_edit_central_columns').serialize() + argsep + 'multi_edit_central_column_save=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db'));
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $(this);
|
||||
$.post('db_central_columns.php', multi_column_edit_data, AJAX.responseHandler);
|
||||
$.post('db_central_columns.php', multiColumnEditData, AJAX.responseHandler);
|
||||
});
|
||||
$('#add_new').find('td').each(function () {
|
||||
if ($(this).attr('name') !== 'undefined') {
|
||||
@ -98,32 +98,32 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
}).get();
|
||||
$.uiTableFilter($('#table_columns'), $(this).val(), cols, null, 'td span');
|
||||
});
|
||||
$('.edit').click(function () {
|
||||
$('.edit').on('click', function () {
|
||||
var rownum = $(this).parent().data('rownum');
|
||||
$('#save_' + rownum).show();
|
||||
$(this).hide();
|
||||
$('#f_' + rownum + ' td span').hide();
|
||||
$('#f_' + rownum + ' input, #f_' + rownum + ' select, #f_' + rownum + ' .open_enum_editor').show();
|
||||
var attribute_val = $('#f_' + rownum + ' td[name=col_attribute] span').html();
|
||||
$('#f_' + rownum + ' select[name=field_attribute\\[' + rownum + '\\] ] option[value="' + attribute_val + '"]').attr('selected','selected');
|
||||
var attributeVal = $('#f_' + rownum + ' td[name=col_attribute] span').html();
|
||||
$('#f_' + rownum + ' select[name=field_attribute\\[' + rownum + '\\] ] option[value="' + attributeVal + '"]').attr('selected','selected');
|
||||
if ($('#f_' + rownum + ' .default_type').val() === 'USER_DEFINED') {
|
||||
$('#f_' + rownum + ' .default_type').siblings('.default_value').show();
|
||||
} else {
|
||||
$('#f_' + rownum + ' .default_type').siblings('.default_value').hide();
|
||||
}
|
||||
});
|
||||
$('.del_row').click(function (event) {
|
||||
$('.del_row').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var $td = $(this);
|
||||
var question = PMA_messages.strDeleteCentralColumnWarning;
|
||||
$td.PMA_confirm(question, null, function (url) {
|
||||
var question = Messages.strDeleteCentralColumnWarning;
|
||||
$td.confirm(question, null, function () {
|
||||
var rownum = $td.data('rownum');
|
||||
$('#del_col_name').val('selected_fld%5B%5D=' + $('#checkbox_row_' + rownum).val());
|
||||
$('#del_form').submit();
|
||||
$('#del_form').trigger('submit');
|
||||
});
|
||||
});
|
||||
$('.edit_cancel_form').click(function (event) {
|
||||
$('.edit_cancel_form').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var rownum = $(this).data('rownum');
|
||||
@ -133,7 +133,7 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
$('#f_' + rownum + ' input, #f_' + rownum + ' select,#f_' + rownum + ' .default_value, #f_' + rownum + ' .open_enum_editor').hide();
|
||||
$('#tableslistcontainer').find('.checkall').show();
|
||||
});
|
||||
$('.edit_save_form').click(function (event) {
|
||||
$('.edit_save_form').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var rownum = $(this).data('rownum');
|
||||
@ -154,11 +154,11 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'db_central_columns.php',
|
||||
data: datastring + PMA_commonParams.get('arg_separator') + 'ajax_request=true',
|
||||
data: datastring + CommonParams.get('arg_separator') + 'ajax_request=true',
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.message !== '1') {
|
||||
PMA_ajaxShowMessage(
|
||||
Functions.ajaxShowMessage(
|
||||
'<div class="error">' +
|
||||
data.message +
|
||||
'</div>',
|
||||
@ -182,41 +182,42 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
$('#tableslistcontainer').find('.checkall').show();
|
||||
},
|
||||
error: function () {
|
||||
PMA_ajaxShowMessage(
|
||||
Functions.ajaxShowMessage(
|
||||
'<div class="error">' +
|
||||
PMA_messages.strErrorProcessingRequest +
|
||||
Messages.strErrorProcessingRequest +
|
||||
'</div>',
|
||||
false
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#table-select').change(function (e) {
|
||||
var selectvalue = $(this).val();
|
||||
var default_column_select = $('#column-select').find('option:first');
|
||||
$('#table-select').on('change', function () {
|
||||
var selectValue = $(this).val();
|
||||
var defaultColumnSelect = $('#column-select').find('option:first');
|
||||
var href = 'db_central_columns.php';
|
||||
var params = {
|
||||
'ajax_request' : true,
|
||||
'server' : PMA_commonParams.get('server'),
|
||||
'db' : PMA_commonParams.get('db'),
|
||||
'selectedTable' : selectvalue,
|
||||
'server' : CommonParams.get('server'),
|
||||
'db' : CommonParams.get('db'),
|
||||
'selectedTable' : selectValue,
|
||||
'populateColumns' : true
|
||||
};
|
||||
$('#column-select').html('<option value="">' + PMA_messages.strLoading + '</option>');
|
||||
if (selectvalue !== '') {
|
||||
$('#column-select').html('<option value="">' + Messages.strLoading + '</option>');
|
||||
if (selectValue !== '') {
|
||||
$.post(href, params, function (data) {
|
||||
$('#column-select').empty().append(default_column_select);
|
||||
$('#column-select').empty().append(defaultColumnSelect);
|
||||
$('#column-select').append(data.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#column-select').change(function (e) {
|
||||
var selectvalue = $(this).val();
|
||||
if (selectvalue !== '') {
|
||||
$('#add_column').submit();
|
||||
$('#add_column').submit(function (e) {
|
||||
var selectvalue = $('#column-select').val();
|
||||
if (selectvalue === '') {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
$('#add_col_div').find('>a').click(function (event) {
|
||||
$('#add_col_div').find('>a').on('click', function () {
|
||||
$('#add_new').slideToggle('slow');
|
||||
var $addColDivLinkSpan = $('#add_col_div').find('>a span');
|
||||
if ($addColDivLinkSpan.html() === '+') {
|
||||
@ -225,10 +226,10 @@ AJAX.registerOnload('db_central_columns.js', function () {
|
||||
$addColDivLinkSpan.html('+');
|
||||
}
|
||||
});
|
||||
$('#add_new').submit(function (event) {
|
||||
$('#add_new').submit(function () {
|
||||
$('#add_new').toggle();
|
||||
});
|
||||
$('#tableslistcontainer').find('select.default_type').change(function () {
|
||||
$('#tableslistcontainer').find('select.default_type').on('change', function () {
|
||||
if ($(this).val() === 'USER_DEFINED') {
|
||||
$(this).siblings('.default_value').attr('name','col_default');
|
||||
$(this).attr('name','col_default_sel');
|
||||
@ -6,10 +6,12 @@
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
* @requires js/db_query_generator.js
|
||||
* @requires js/database/query_generator.js
|
||||
*
|
||||
*/
|
||||
|
||||
/* global generateFromBlock, generateWhereBlock */ // js/database/query_generator.js
|
||||
|
||||
/**
|
||||
* js file for handling AJAX and other events in db_multi_table_query.php
|
||||
*/
|
||||
@ -17,7 +19,7 @@
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('db_multi_table_query.js', function () {
|
||||
AJAX.registerTeardown('database/multi_table_query.js', function () {
|
||||
$('.tableNameSelect').each(function () {
|
||||
$(this).off('change');
|
||||
});
|
||||
@ -25,20 +27,20 @@ AJAX.registerTeardown('db_multi_table_query.js', function () {
|
||||
$('#add_column_button').off('click');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('db_multi_table_query.js', function () {
|
||||
var editor = PMA_getSQLEditor($('#MultiSqlquery'), {}, 'both');
|
||||
AJAX.registerOnload('database/multi_table_query.js', function () {
|
||||
var editor = Functions.getSqlEditor($('#MultiSqlquery'), {}, 'both');
|
||||
$('.CodeMirror-line').css('text-align', 'left');
|
||||
editor.setSize(-1, 50);
|
||||
|
||||
var column_count = 3;
|
||||
PMA_init_slider();
|
||||
var columnCount = 3;
|
||||
Functions.initSlider();
|
||||
addNewColumnCallbacks();
|
||||
|
||||
$('#update_query_button').on('click', function () {
|
||||
var columns = [];
|
||||
var tableAliases = {};
|
||||
$('.tableNameSelect').each(function () {
|
||||
$show = $(this).siblings('.show_col').first();
|
||||
var $show = $(this).siblings('.show_col').first();
|
||||
if ($(this).val() !== '' && $show.prop('checked')) {
|
||||
var tableAlias = $(this).siblings('.table_alias').first().val();
|
||||
var columnAlias = $(this).siblings('.col_alias').first().val();
|
||||
@ -61,7 +63,7 @@ AJAX.registerOnload('db_multi_table_query.js', function () {
|
||||
}
|
||||
});
|
||||
if (Object.keys(tableAliases).length === 0) {
|
||||
PMA_ajaxShowMessage('Nothing selected', false, 'error');
|
||||
Functions.ajaxShowMessage('Nothing selected', false, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -75,39 +77,39 @@ AJAX.registerOnload('db_multi_table_query.js', function () {
|
||||
'db': $('#db_name').val(),
|
||||
'tables': Object.keys(tableAliases),
|
||||
'ajax_request': '1',
|
||||
'token': PMA_commonParams.get('token')
|
||||
'token': CommonParams.get('token')
|
||||
},
|
||||
success: function (response) {
|
||||
foreignKeys = response.foreignKeyConstrains;
|
||||
}
|
||||
});
|
||||
|
||||
query = 'SELECT ' + '`' + escapeBacktick(columns[0][0]) + '`.';
|
||||
var query = 'SELECT ' + '`' + Functions.escapeBacktick(columns[0][0]) + '`.';
|
||||
if (columns[0][1] === '*') {
|
||||
query += '*';
|
||||
} else {
|
||||
query += '`' + escapeBacktick(columns[0][1]) + '`';
|
||||
query += '`' + Functions.escapeBacktick(columns[0][1]) + '`';
|
||||
}
|
||||
if (columns[0][2] !== '') {
|
||||
query += ' AS ' + columns[0][2];
|
||||
}
|
||||
for (var i = 1; i < columns.length; i++) {
|
||||
query += ', `' + escapeBacktick(columns[i][0]) + '`.';
|
||||
query += ', `' + Functions.escapeBacktick(columns[i][0]) + '`.';
|
||||
if (columns[i][1] === '*') {
|
||||
query += '*';
|
||||
} else {
|
||||
query += '`' + escapeBacktick(columns[i][1]) + '`';
|
||||
query += '`' + Functions.escapeBacktick(columns[i][1]) + '`';
|
||||
}
|
||||
if (columns[i][2] !== '') {
|
||||
query += ' AS `' + escapeBacktick(columns[0][2]) + '`';
|
||||
query += ' AS `' + Functions.escapeBacktick(columns[0][2]) + '`';
|
||||
}
|
||||
}
|
||||
query += '\nFROM ';
|
||||
|
||||
query += generateFromBlock(tableAliases, foreignKeys);
|
||||
|
||||
$criteria_col_count = $('.criteria_col:checked').length;
|
||||
if ($criteria_col_count > 0) {
|
||||
var $criteriaColCount = $('.criteria_col:checked').length;
|
||||
if ($criteriaColCount > 0) {
|
||||
query += '\nWHERE ';
|
||||
query += generateWhereBlock();
|
||||
}
|
||||
@ -120,53 +122,53 @@ AJAX.registerOnload('db_multi_table_query.js', function () {
|
||||
var query = editor.getDoc().getValue();
|
||||
// Verifying that the query is not empty
|
||||
if (query === '') {
|
||||
PMA_ajaxShowMessage(PMA_messages.strEmptyQuery, false, 'error');
|
||||
Functions.ajaxShowMessage(Messages.strEmptyQuery, false, 'error');
|
||||
return;
|
||||
}
|
||||
var data = {
|
||||
'db': $('#db_name').val(),
|
||||
'sql_query': query,
|
||||
'ajax_request': '1',
|
||||
'token': PMA_commonParams.get('token')
|
||||
'token': CommonParams.get('token')
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'db_multi_table_query.php',
|
||||
data: data,
|
||||
success: function (data) {
|
||||
$results_dom = $(data.message);
|
||||
$results_dom.find('.ajax:not(.pageselector)').each(function () {
|
||||
var $resultsDom = $(data.message);
|
||||
$resultsDom.find('.ajax:not(.pageselector)').each(function () {
|
||||
$(this).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
$results_dom.find('.autosubmit, .pageselector, .showAllRows, .filter_rows').each(function () {
|
||||
$resultsDom.find('.autosubmit, .pageselector, .showAllRows, .filter_rows').each(function () {
|
||||
$(this).on('change click select focus', function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
$('#sql_results').html($results_dom);
|
||||
$('#page_content').find('a').first().click();
|
||||
$('#sql_results').html($resultsDom);
|
||||
$('#page_content').find('a').first().trigger('click');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#add_column_button').on('click', function () {
|
||||
column_count++;
|
||||
$new_column_dom = $($('#new_column_layout').html()).clone();
|
||||
$new_column_dom.find('div').first().find('div').first().attr('id', column_count.toString());
|
||||
$new_column_dom.find('a').first().remove();
|
||||
$new_column_dom.find('.pma_auto_slider').first().unwrap();
|
||||
$new_column_dom.find('.pma_auto_slider').first().attr('title', 'criteria');
|
||||
$('#add_column_button').parent().before($new_column_dom);
|
||||
PMA_init_slider();
|
||||
columnCount++;
|
||||
var $newColumnDom = $($('#new_column_layout').html()).clone();
|
||||
$newColumnDom.find('div').first().find('div').first().attr('id', columnCount.toString());
|
||||
$newColumnDom.find('a').first().remove();
|
||||
$newColumnDom.find('.pma_auto_slider').first().unwrap();
|
||||
$newColumnDom.find('.pma_auto_slider').first().attr('title', 'criteria');
|
||||
$('#add_column_button').parent().before($newColumnDom);
|
||||
Functions.initSlider();
|
||||
addNewColumnCallbacks();
|
||||
});
|
||||
|
||||
function addNewColumnCallbacks () {
|
||||
$('.tableNameSelect').each(function () {
|
||||
$(this).on('change', function () {
|
||||
$sibs = $(this).siblings('.columnNameSelect');
|
||||
var $sibs = $(this).siblings('.columnNameSelect');
|
||||
if ($sibs.length === 0) {
|
||||
$sibs = $(this).parent().parent().find('.columnNameSelect');
|
||||
}
|
||||
@ -183,11 +185,11 @@ AJAX.registerOnload('db_multi_table_query.js', function () {
|
||||
$('a.ajax').each(function () {
|
||||
$(this).on('click', function (event, from) {
|
||||
if (from === null) {
|
||||
$checkbox = $(this).siblings('.criteria_col').first();
|
||||
var $checkbox = $(this).siblings('.criteria_col').first();
|
||||
$checkbox.prop('checked', !$checkbox.prop('checked'));
|
||||
}
|
||||
$criteria_col_count = $('.criteria_col:checked').length;
|
||||
if ($criteria_col_count > 1) {
|
||||
var $criteriaColCount = $('.criteria_col:checked').length;
|
||||
if ($criteriaColCount > 1) {
|
||||
$(this).siblings('.slide-wrapper').first().find('.logical_operator').first().css('display','table-row');
|
||||
}
|
||||
});
|
||||
@ -195,24 +197,24 @@ AJAX.registerOnload('db_multi_table_query.js', function () {
|
||||
|
||||
$('.criteria_col').each(function () {
|
||||
$(this).on('change', function () {
|
||||
$anchor = $(this).siblings('a.ajax').first();
|
||||
var $anchor = $(this).siblings('a.ajax').first();
|
||||
$anchor.trigger('click', ['Trigger']);
|
||||
});
|
||||
});
|
||||
|
||||
$('.criteria_rhs').each(function () {
|
||||
$(this).on('change', function () {
|
||||
$rhs_col = $(this).parent().parent().siblings('.rhs_table').first();
|
||||
$rhs_text = $(this).parent().parent().siblings('.rhs_text').first();
|
||||
var $rhsCol = $(this).parent().parent().siblings('.rhs_table').first();
|
||||
var $rhsText = $(this).parent().parent().siblings('.rhs_text').first();
|
||||
if ($(this).val() === 'text') {
|
||||
$rhs_col.css('display', 'none');
|
||||
$rhs_text.css('display', 'table-row');
|
||||
$rhsCol.css('display', 'none');
|
||||
$rhsText.css('display', 'table-row');
|
||||
} else if ($(this).val() === 'anotherColumn') {
|
||||
$rhs_text.css('display', 'none');
|
||||
$rhs_col.css('display', 'table-row');
|
||||
$rhsText.css('display', 'none');
|
||||
$rhsCol.css('display', 'table-row');
|
||||
} else {
|
||||
$rhs_text.css('display', 'none');
|
||||
$rhs_col.css('display', 'none');
|
||||
$rhsText.css('display', 'none');
|
||||
$rhsCol.css('display', 'none');
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -22,45 +22,45 @@
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('db_operations.js', function () {
|
||||
AJAX.registerTeardown('database/operations.js', function () {
|
||||
$(document).off('submit', '#rename_db_form.ajax');
|
||||
$(document).off('submit', '#copy_db_form.ajax');
|
||||
$(document).off('submit', '#change_db_charset_form.ajax');
|
||||
$(document).off('click', '#drop_db_anchor.ajax');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('db_operations.js', function () {
|
||||
AJAX.registerOnload('database/operations.js', function () {
|
||||
/**
|
||||
* Ajax event handlers for 'Rename Database'
|
||||
*/
|
||||
$(document).on('submit', '#rename_db_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var old_db_name = PMA_commonParams.get('db');
|
||||
var new_db_name = $('#new_db_name').val();
|
||||
var oldDbName = CommonParams.get('db');
|
||||
var newDbName = $('#new_db_name').val();
|
||||
|
||||
if (new_db_name === old_db_name) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strDatabaseRenameToSameName, false, 'error');
|
||||
if (newDbName === oldDbName) {
|
||||
Functions.ajaxShowMessage(Messages.strDatabaseRenameToSameName, false, 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
var $form = $(this);
|
||||
|
||||
var question = escapeHtml('CREATE DATABASE ' + new_db_name + ' / DROP DATABASE ' + old_db_name);
|
||||
var question = Functions.escapeHtml('CREATE DATABASE ' + newDbName + ' / DROP DATABASE ' + oldDbName);
|
||||
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
|
||||
$form.PMA_confirm(question, $form.attr('action'), function (url) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strRenamingDatabases, false);
|
||||
$.post(url, $('#rename_db_form').serialize() + PMA_commonParams.get('arg_separator') + 'is_js_confirmed=1', function (data) {
|
||||
$form.confirm(question, $form.attr('action'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strRenamingDatabases, false);
|
||||
$.post(url, $('#rename_db_form').serialize() + CommonParams.get('arg_separator') + 'is_js_confirmed=1', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
PMA_commonParams.set('db', data.newname);
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
CommonParams.set('db', data.newname);
|
||||
|
||||
PMA_reloadNavigation(function () {
|
||||
Navigation.reload(function () {
|
||||
$('#pma_navigation_tree')
|
||||
.find('a:not(\'.expander\')')
|
||||
.each(function (index) {
|
||||
.each(function () {
|
||||
var $thisAnchor = $(this);
|
||||
if ($thisAnchor.text() === data.newname) {
|
||||
// simulate a click on the new db name
|
||||
@ -70,7 +70,7 @@ AJAX.registerOnload('db_operations.js', function () {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
});
|
||||
@ -81,25 +81,25 @@ AJAX.registerOnload('db_operations.js', function () {
|
||||
*/
|
||||
$(document).on('submit', '#copy_db_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
PMA_ajaxShowMessage(PMA_messages.strCopyingDatabase, false);
|
||||
Functions.ajaxShowMessage(Messages.strCopyingDatabase, false);
|
||||
var $form = $(this);
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
$.post($form.attr('action'), $form.serialize(), function (data) {
|
||||
// use messages that stay on screen
|
||||
$('div.success, div.error').fadeOut();
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
if ($('#checkbox_switch').is(':checked')) {
|
||||
PMA_commonParams.set('db', data.newname);
|
||||
PMA_commonActions.refreshMain(false, function () {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
CommonParams.set('db', data.newname);
|
||||
CommonActions.refreshMain(false, function () {
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
});
|
||||
} else {
|
||||
PMA_commonParams.set('db', data.db);
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
CommonParams.set('db', data.db);
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
}
|
||||
PMA_reloadNavigation();
|
||||
Navigation.reload();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end copy database
|
||||
@ -118,13 +118,13 @@ AJAX.registerOnload('db_operations.js', function () {
|
||||
$(document).on('submit', '#change_db_charset_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
var $form = $(this);
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
PMA_ajaxShowMessage(PMA_messages.strChangingCharset);
|
||||
$.post($form.attr('action'), $form.serialize() + PMA_commonParams.get('arg_separator') + 'submitcollation=1', function (data) {
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
Functions.ajaxShowMessage(Messages.strChangingCharset);
|
||||
$.post($form.attr('action'), $form.serialize() + CommonParams.get('arg_separator') + 'submitcollation=1', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end change charset
|
||||
@ -138,28 +138,28 @@ AJAX.registerOnload('db_operations.js', function () {
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = PMA_messages.strDropDatabaseStrongWarning + ' ';
|
||||
question += PMA_sprintf(
|
||||
PMA_messages.strDoYouReally,
|
||||
'DROP DATABASE `' + escapeHtml(PMA_commonParams.get('db') + '`')
|
||||
var question = Messages.strDropDatabaseStrongWarning + ' ';
|
||||
question += Functions.sprintf(
|
||||
Messages.strDoYouReally,
|
||||
'DROP DATABASE `' + Functions.escapeHtml(CommonParams.get('db') + '`')
|
||||
);
|
||||
var params = getJSConfirmCommonParam(this, $link.getPostData());
|
||||
var params = Functions.getJsConfirmCommonParam(this, $link.getPostData());
|
||||
|
||||
$(this).PMA_confirm(question, $(this).attr('href'), function (url) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
$(this).confirm(question, $(this).attr('href'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success) {
|
||||
// Database deleted successfully, refresh both the frames
|
||||
PMA_reloadNavigation();
|
||||
PMA_commonParams.set('db', '');
|
||||
PMA_commonActions.refreshMain(
|
||||
Navigation.reload();
|
||||
CommonParams.set('db', '');
|
||||
CommonActions.refreshMain(
|
||||
'server_databases.php',
|
||||
function () {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -19,7 +19,7 @@
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('db_qbe.js', function () {
|
||||
AJAX.registerTeardown('database/qbe.js', function () {
|
||||
$(document).off('change', 'select[name^=criteriaColumn]');
|
||||
$(document).off('change', '#searchId');
|
||||
$(document).off('click', '#saveSearch');
|
||||
@ -27,8 +27,8 @@ AJAX.registerTeardown('db_qbe.js', function () {
|
||||
$(document).off('click', '#deleteSearch');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('db_qbe.js', function () {
|
||||
PMA_getSQLEditor($('#textSqlquery'), {}, 'none');
|
||||
AJAX.registerOnload('database/qbe.js', function () {
|
||||
Functions.getSqlEditor($('#textSqlquery'), {}, 'none');
|
||||
|
||||
$('#tblQbe').width($('#tblQbe').parent().width());
|
||||
$('#tblQbeFooters').width($('#tblQbeFooters').parent().width());
|
||||
@ -41,7 +41,7 @@ AJAX.registerOnload('db_qbe.js', function () {
|
||||
/**
|
||||
* Ajax handler to check the corresponding 'show' checkbox when column is selected
|
||||
*/
|
||||
$(document).on('change', 'select[name^=criteriaColumn]', function (event) {
|
||||
$(document).on('change', 'select[name^=criteriaColumn]', function () {
|
||||
if ($(this).val()) {
|
||||
var index = (/\d+/).exec($(this).attr('name'));
|
||||
$('input[name=criteriaShow\\[' + index + '\\]]').prop('checked', true);
|
||||
@ -51,9 +51,9 @@ AJAX.registerOnload('db_qbe.js', function () {
|
||||
/**
|
||||
* Ajax event handlers for 'Select saved search'
|
||||
*/
|
||||
$(document).on('change', '#searchId', function (event) {
|
||||
$(document).on('change', '#searchId', function () {
|
||||
$('#action').val('load');
|
||||
$('#formQBE').submit();
|
||||
$('#formQBE').trigger('submit');
|
||||
});
|
||||
|
||||
/**
|
||||
@ -66,15 +66,15 @@ AJAX.registerOnload('db_qbe.js', function () {
|
||||
/**
|
||||
* Ajax event handlers for 'Update bookmark'
|
||||
*/
|
||||
$(document).on('click', '#updateSearch', function (event) {
|
||||
$(document).on('click', '#updateSearch', function () {
|
||||
$('#action').val('update');
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax event handlers for 'Delete bookmark'
|
||||
*/
|
||||
$(document).on('click', '#deleteSearch', function (event) {
|
||||
var question = PMA_sprintf(PMA_messages.strConfirmDeleteQBESearch, $('#searchId').find('option:selected').text());
|
||||
$(document).on('click', '#deleteSearch', function () {
|
||||
var question = Functions.sprintf(Messages.strConfirmDeleteQBESearch, $('#searchId').find('option:selected').text());
|
||||
if (!confirm(question)) {
|
||||
return false;
|
||||
}
|
||||
@ -9,6 +9,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* global sprintf */ // js/vendor/sprintf.js
|
||||
|
||||
function getFormatsText () {
|
||||
return {
|
||||
'=': ' = \'%s\'',
|
||||
@ -18,7 +20,7 @@ function getFormatsText () {
|
||||
'<=': ' <= \'%s\'',
|
||||
'!=': ' != \'%s\'',
|
||||
'LIKE': ' LIKE \'%s\'',
|
||||
'LIKE \%...\%': ' LIKE \'%%%s%%\'',
|
||||
'LIKE %...%': ' LIKE \'%%%s%%\'',
|
||||
'NOT LIKE': ' NOT LIKE \'%s\'',
|
||||
'BETWEEN': ' BETWEEN \'%s\'',
|
||||
'NOT BETWEEN': ' NOT BETWEEN \'%s\'',
|
||||
@ -31,19 +33,20 @@ function getFormatsText () {
|
||||
}
|
||||
|
||||
function generateCondition (criteriaDiv, table) {
|
||||
query = '`' + escapeBacktick(table.val()) + '`.';
|
||||
query += '`' + escapeBacktick(table.siblings('.columnNameSelect').first().val()) + '`';
|
||||
var query = '`' + Functions.escapeBacktick(table.val()) + '`.';
|
||||
query += '`' + Functions.escapeBacktick(table.siblings('.columnNameSelect').first().val()) + '`';
|
||||
if (criteriaDiv.find('.criteria_rhs').first().val() === 'text') {
|
||||
formatsText = getFormatsText();
|
||||
query += sprintf(formatsText[criteriaDiv.find('.criteria_op').first().val()], escapeSingleQuote(criteriaDiv.find('.rhs_text_val').first().val()));
|
||||
var formatsText = getFormatsText();
|
||||
query += sprintf(formatsText[criteriaDiv.find('.criteria_op').first().val()], Functions.escapeSingleQuote(criteriaDiv.find('.rhs_text_val').first().val()));
|
||||
} else {
|
||||
query += ' ' + criteriaDiv.find('.criteria_op').first().val();
|
||||
query += ' `' + escapeBacktick(criteriaDiv.find('.tableNameSelect').first().val()) + '`.';
|
||||
query += '`' + escapeBacktick(criteriaDiv.find('.columnNameSelect').first().val()) + '`';
|
||||
query += ' `' + Functions.escapeBacktick(criteriaDiv.find('.tableNameSelect').first().val()) + '`.';
|
||||
query += '`' + Functions.escapeBacktick(criteriaDiv.find('.columnNameSelect').first().val()) + '`';
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function generateWhereBlock () {
|
||||
var count = 0;
|
||||
var query = '';
|
||||
@ -66,19 +69,19 @@ function generateWhereBlock () {
|
||||
}
|
||||
|
||||
function generateJoin (newTable, tableAliases, fk) {
|
||||
query = '';
|
||||
query += ' \n\tLEFT JOIN ' + '`' + escapeBacktick(newTable) + '`';
|
||||
var query = '';
|
||||
query += ' \n\tLEFT JOIN ' + '`' + Functions.escapeBacktick(newTable) + '`';
|
||||
if (tableAliases[fk.TABLE_NAME][0] !== '') {
|
||||
query += ' AS `' + escapeBacktick(tableAliases[newTable][0]) + '`';
|
||||
query += ' ON `' + escapeBacktick(tableAliases[fk.TABLE_NAME][0]) + '`';
|
||||
query += ' AS `' + Functions.escapeBacktick(tableAliases[newTable][0]) + '`';
|
||||
query += ' ON `' + Functions.escapeBacktick(tableAliases[fk.TABLE_NAME][0]) + '`';
|
||||
} else {
|
||||
query += ' ON `' + escapeBacktick(fk.TABLE_NAME) + '`';
|
||||
query += ' ON `' + Functions.escapeBacktick(fk.TABLE_NAME) + '`';
|
||||
}
|
||||
query += '.`' + fk.COLUMN_NAME + '`';
|
||||
if (tableAliases[fk.REFERENCED_TABLE_NAME][0] !== '') {
|
||||
query += ' = `' + escapeBacktick(tableAliases[fk.REFERENCED_TABLE_NAME][0]) + '`';
|
||||
query += ' = `' + Functions.escapeBacktick(tableAliases[fk.REFERENCED_TABLE_NAME][0]) + '`';
|
||||
} else {
|
||||
query += ' = `' + escapeBacktick(fk.REFERENCED_TABLE_NAME) + '`';
|
||||
query += ' = `' + Functions.escapeBacktick(fk.REFERENCED_TABLE_NAME) + '`';
|
||||
}
|
||||
query += '.`' + fk.REFERENCED_COLUMN_NAME + '`';
|
||||
return query;
|
||||
@ -106,18 +109,19 @@ function appendTable (table, tableAliases, usedTables, foreignKeys) {
|
||||
if (usedTables.length > 0) {
|
||||
query += '\n\t, ';
|
||||
}
|
||||
query += '`' + escapeBacktick(table) + '`';
|
||||
query += '`' + Functions.escapeBacktick(table) + '`';
|
||||
if (tableAliases[table][0] !== '') {
|
||||
query += ' AS `' + escapeBacktick(tableAliases[table][0]) + '`';
|
||||
query += ' AS `' + Functions.escapeBacktick(tableAliases[table][0]) + '`';
|
||||
}
|
||||
}
|
||||
usedTables.push(table);
|
||||
return query;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function generateFromBlock (tableAliases, foreignKeys) {
|
||||
var usedTables = [];
|
||||
query = '';
|
||||
var query = '';
|
||||
for (var table in tableAliases) {
|
||||
if (tableAliases.hasOwnProperty(table)) {
|
||||
query += appendTable(table, tableAliases, usedTables, foreignKeys);
|
||||
@ -8,6 +8,8 @@
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/* global makeGrid */ // js/makegrid.js
|
||||
|
||||
/**
|
||||
* AJAX script for the Database Search page.
|
||||
*
|
||||
@ -18,7 +20,7 @@
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('db_search.js', function () {
|
||||
AJAX.registerTeardown('database/search.js', function () {
|
||||
$('a.browse_results').off('click');
|
||||
$('a.delete_results').off('click');
|
||||
$('#buttonGo').off('click');
|
||||
@ -28,13 +30,13 @@ AJAX.registerTeardown('db_search.js', function () {
|
||||
$(document).off('submit', '#db_search_form.ajax');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('db_search.js', function () {
|
||||
AJAX.registerOnload('database/search.js', function () {
|
||||
/** Hide the table link in the initial search result */
|
||||
var icon = PMA_getImage('s_tbl', '', { 'id': 'table-image' }).toString();
|
||||
var icon = Functions.getImage('s_tbl', '', { 'id': 'table-image' }).toString();
|
||||
$('#table-info').prepend(icon).hide();
|
||||
|
||||
/** Hide the browse and deleted results in the new search criteria */
|
||||
$('#buttonGo').click(function () {
|
||||
$('#buttonGo').on('click', function () {
|
||||
$('#table-info').hide();
|
||||
$('#browse-results').hide();
|
||||
$('#sqlqueryform').hide();
|
||||
@ -52,14 +54,14 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
* the hide/show criteria in search result forms
|
||||
*/
|
||||
$('#togglesearchresultlink')
|
||||
.html(PMA_messages.strHideSearchResults)
|
||||
.html(Messages.strHideSearchResults)
|
||||
.on('click', function () {
|
||||
var $link = $(this);
|
||||
$('#searchresults').slideToggle();
|
||||
if ($link.text() === PMA_messages.strHideSearchResults) {
|
||||
$link.text(PMA_messages.strShowSearchResults);
|
||||
if ($link.text() === Messages.strHideSearchResults) {
|
||||
$link.text(Messages.strShowSearchResults);
|
||||
} else {
|
||||
$link.text(PMA_messages.strHideSearchResults);
|
||||
$link.text(Messages.strHideSearchResults);
|
||||
}
|
||||
/** avoid default click action */
|
||||
return false;
|
||||
@ -81,10 +83,10 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
.on('click', function () {
|
||||
var $link = $(this);
|
||||
$('#sqlqueryform').slideToggle('medium');
|
||||
if ($link.text() === PMA_messages.strHideQueryBox) {
|
||||
$link.text(PMA_messages.strShowQueryBox);
|
||||
if ($link.text() === Messages.strHideQueryBox) {
|
||||
$link.text(Messages.strShowQueryBox);
|
||||
} else {
|
||||
$link.text(PMA_messages.strHideQueryBox);
|
||||
$link.text(Messages.strHideQueryBox);
|
||||
}
|
||||
/** avoid default click action */
|
||||
return false;
|
||||
@ -97,14 +99,14 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
* the hide/show criteria in search criteria form
|
||||
*/
|
||||
$('#togglesearchformlink')
|
||||
.html(PMA_messages.strShowSearchCriteria)
|
||||
.html(Messages.strShowSearchCriteria)
|
||||
.on('click', function () {
|
||||
var $link = $(this);
|
||||
$('#db_search_form').slideToggle();
|
||||
if ($link.text() === PMA_messages.strHideSearchCriteria) {
|
||||
$link.text(PMA_messages.strShowSearchCriteria);
|
||||
if ($link.text() === Messages.strHideSearchCriteria) {
|
||||
$link.text(Messages.strShowSearchCriteria);
|
||||
} else {
|
||||
$link.text(PMA_messages.strHideSearchCriteria);
|
||||
$link.text(Messages.strHideSearchCriteria);
|
||||
}
|
||||
/** avoid default click action */
|
||||
return false;
|
||||
@ -116,36 +118,36 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
$(document).on('click', 'a.browse_results', function (e) {
|
||||
e.preventDefault();
|
||||
/** Hides the results shown by the delete criteria */
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strBrowsing, false);
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strBrowsing, false);
|
||||
$('#sqlqueryform').hide();
|
||||
$('#togglequerybox').hide();
|
||||
/** Load the browse results to the page */
|
||||
$('#table-info').show();
|
||||
var table_name = $(this).data('table-name');
|
||||
$('#table-link').attr({ 'href' : $(this).attr('href') }).text(table_name);
|
||||
var tableName = $(this).data('table-name');
|
||||
$('#table-link').attr({ 'href' : $(this).attr('href') }).text(tableName);
|
||||
|
||||
var url = $(this).attr('href') + '#searchresults';
|
||||
var browse_sql = $(this).data('browse-sql');
|
||||
var browseSql = $(this).data('browse-sql');
|
||||
var params = {
|
||||
'ajax_request': true,
|
||||
'is_js_confirmed': true,
|
||||
'sql_query' : browse_sql
|
||||
'sql_query' : browseSql
|
||||
};
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success) {
|
||||
$('#browse-results').html(data.message);
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
$('.table_results').each(function () {
|
||||
PMA_makegrid(this, true, true, true, true);
|
||||
makeGrid(this, true, true, true, true);
|
||||
});
|
||||
$('#browse-results').show();
|
||||
PMA_highlightSQL($('#browse-results'));
|
||||
Functions.highlightSql($('#browse-results'));
|
||||
$('html, body')
|
||||
.animate({
|
||||
scrollTop: $('#browse-results').offset().top
|
||||
}, 1000);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -160,12 +162,12 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
$('#sqlqueryform').hide();
|
||||
$('#togglequerybox').hide();
|
||||
/** Conformation message for deletion */
|
||||
var msg = PMA_sprintf(
|
||||
PMA_messages.strConfirmDeleteResults,
|
||||
var msg = Functions.sprintf(
|
||||
Messages.strConfirmDeleteResults,
|
||||
$(this).data('table-name')
|
||||
);
|
||||
if (confirm(msg)) {
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strDeleting, false);
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strDeleting, false);
|
||||
/** Load the deleted option to the page*/
|
||||
$('#sqlqueryform').html('');
|
||||
var params = {
|
||||
@ -177,14 +179,14 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data === 'undefined' || !data.success) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#sqlqueryform').html(data.sql_query);
|
||||
/** Refresh the search results after the deletion */
|
||||
document.getElementById('buttonGo').click();
|
||||
$('#togglequerybox').html(PMA_messages.strHideQueryBox);
|
||||
document.getElementById('buttonGo').trigger('click');
|
||||
$('#togglequerybox').html(Messages.strHideQueryBox);
|
||||
/** Show the results of the deletion option */
|
||||
$('#browse-results').hide();
|
||||
$('#sqlqueryform').show();
|
||||
@ -193,7 +195,7 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
.animate({
|
||||
scrollTop: $('#browse-results').offset().top
|
||||
}, 1000);
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -204,13 +206,13 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
$(document).on('submit', '#db_search_form.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strSearching, false);
|
||||
var $msgbox = Functions.ajaxShowMessage(Messages.strSearching, false);
|
||||
// jQuery object to reuse
|
||||
var $form = $(this);
|
||||
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
Functions.prepareForAjaxRequest($form);
|
||||
|
||||
var url = $form.serialize() + PMA_commonParams.get('arg_separator') + 'submit_search=' + $('#buttonGo').val();
|
||||
var url = $form.serialize() + CommonParams.get('arg_separator') + 'submit_search=' + $('#buttonGo').val();
|
||||
$.post($form.attr('action'), url, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
// found results
|
||||
@ -218,7 +220,7 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
|
||||
$('#togglesearchresultlink')
|
||||
// always start with the Show message
|
||||
.text(PMA_messages.strHideSearchResults);
|
||||
.text(Messages.strHideSearchResults);
|
||||
$('#togglesearchresultsdiv')
|
||||
// now it's time to show the div containing the link
|
||||
.show();
|
||||
@ -231,7 +233,7 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
.hide();
|
||||
$('#togglesearchformlink')
|
||||
// always start with the Show message
|
||||
.text(PMA_messages.strShowSearchCriteria);
|
||||
.text(Messages.strShowSearchCriteria);
|
||||
$('#togglesearchformdiv')
|
||||
// now it's time to show the div containing the link
|
||||
.show();
|
||||
@ -240,7 +242,7 @@ AJAX.registerOnload('db_search.js', function () {
|
||||
$('#searchresults').html(data.error).show();
|
||||
}
|
||||
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
Functions.ajaxRemoveMessage($msgbox);
|
||||
});
|
||||
});
|
||||
}); // end $()
|
||||
@ -8,6 +8,8 @@
|
||||
* @required js/functions.js
|
||||
*/
|
||||
|
||||
var DatabaseStructure = {};
|
||||
|
||||
/**
|
||||
* AJAX scripts for db_structure.php
|
||||
*
|
||||
@ -21,7 +23,7 @@
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('db_structure.js', function () {
|
||||
AJAX.registerTeardown('database/structure.js', function () {
|
||||
$(document).off('click', 'a.truncate_table_anchor.ajax');
|
||||
$(document).off('click', 'a.drop_table_anchor.ajax');
|
||||
$(document).off('click', '#real_end_input');
|
||||
@ -36,22 +38,22 @@ AJAX.registerTeardown('db_structure.js', function () {
|
||||
* Adjust number of rows and total size in the summary
|
||||
* when truncating, creating, dropping or inserting into a table
|
||||
*/
|
||||
function PMA_adjustTotals () {
|
||||
DatabaseStructure.adjustTotals = function () {
|
||||
var byteUnits = [
|
||||
PMA_messages.strB,
|
||||
PMA_messages.strKiB,
|
||||
PMA_messages.strMiB,
|
||||
PMA_messages.strGiB,
|
||||
PMA_messages.strTiB,
|
||||
PMA_messages.strPiB,
|
||||
PMA_messages.strEiB
|
||||
Messages.strB,
|
||||
Messages.strKiB,
|
||||
Messages.strMiB,
|
||||
Messages.strGiB,
|
||||
Messages.strTiB,
|
||||
Messages.strPiB,
|
||||
Messages.strEiB
|
||||
];
|
||||
/**
|
||||
* @var $allTr jQuery object that references all the rows in the list of tables
|
||||
*/
|
||||
var $allTr = $('#tablesForm').find('table.data tbody:first tr');
|
||||
// New summary values for the table
|
||||
var tableSum = $allTr.size();
|
||||
var tableSum = $allTr.length;
|
||||
var rowsSum = 0;
|
||||
var sizeSum = 0;
|
||||
var overheadSum = 0;
|
||||
@ -112,15 +114,15 @@ function PMA_adjustTotals () {
|
||||
strRowSum = '~' + strRowSum;
|
||||
}
|
||||
// Calculate the magnitude for the size and overhead values
|
||||
var size_magnitude = 0;
|
||||
var overhead_magnitude = 0;
|
||||
var sizeMagnitude = 0;
|
||||
var overheadMagnitude = 0;
|
||||
while (sizeSum >= 1024) {
|
||||
sizeSum /= 1024;
|
||||
size_magnitude++;
|
||||
sizeMagnitude++;
|
||||
}
|
||||
while (overheadSum >= 1024) {
|
||||
overheadSum /= 1024;
|
||||
overhead_magnitude++;
|
||||
overheadMagnitude++;
|
||||
}
|
||||
|
||||
sizeSum = Math.round(sizeSum * 10) / 10;
|
||||
@ -128,26 +130,26 @@ function PMA_adjustTotals () {
|
||||
|
||||
// Update summary with new data
|
||||
var $summary = $('#tbl_summary_row');
|
||||
$summary.find('.tbl_num').text(PMA_sprintf(PMA_messages.strNTables, tableSum));
|
||||
$summary.find('.tbl_num').text(Functions.sprintf(Messages.strNTables, tableSum));
|
||||
if (rowSumApproximated) {
|
||||
$summary.find('.row_count_sum').text(strRowSum);
|
||||
} else {
|
||||
$summary.find('.tbl_rows').text(strRowSum);
|
||||
}
|
||||
$summary.find('.tbl_size').text(sizeSum + ' ' + byteUnits[size_magnitude]);
|
||||
$summary.find('.tbl_overhead').text(overheadSum + ' ' + byteUnits[overhead_magnitude]);
|
||||
}
|
||||
$summary.find('.tbl_size').text(sizeSum + ' ' + byteUnits[sizeMagnitude]);
|
||||
$summary.find('.tbl_overhead').text(overheadSum + ' ' + byteUnits[overheadMagnitude]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the real row count for a table or DB.
|
||||
* @param object $target Target for appending the real count value.
|
||||
*/
|
||||
function PMA_fetchRealRowCount ($target) {
|
||||
DatabaseStructure.fetchRealRowCount = function ($target) {
|
||||
var $throbber = $('#pma_navigation').find('.throbber')
|
||||
.first()
|
||||
.clone()
|
||||
.css({ visibility: 'visible', display: 'inline-block' })
|
||||
.click(false);
|
||||
.on('click', false);
|
||||
$target.html($throbber);
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
@ -172,18 +174,18 @@ function PMA_fetchRealRowCount ($target) {
|
||||
$target.parent().text(response.real_row_count);
|
||||
}
|
||||
// Adjust the 'Sum' displayed at the bottom.
|
||||
PMA_adjustTotals();
|
||||
DatabaseStructure.adjustTotals();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorRealRowCount);
|
||||
Functions.ajaxShowMessage(Messages.strErrorRealRowCount);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorRealRowCount);
|
||||
Functions.ajaxShowMessage(Messages.strErrorRealRowCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
AJAX.registerOnload('db_structure.js', function () {
|
||||
AJAX.registerOnload('database/structure.js', function () {
|
||||
/**
|
||||
* function to open the confirmation dialog for making table consistent with central list
|
||||
*
|
||||
@ -195,18 +197,18 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
var dialogObj = $('<div class=\'hide\'>' + msg + '</div>');
|
||||
$('body').append(dialogObj);
|
||||
var buttonOptions = {};
|
||||
buttonOptions[PMA_messages.strContinue] = function () {
|
||||
buttonOptions[Messages.strContinue] = function () {
|
||||
success();
|
||||
$(this).dialog('close');
|
||||
};
|
||||
buttonOptions[PMA_messages.strCancel] = function () {
|
||||
buttonOptions[Messages.strCancel] = function () {
|
||||
$(this).dialog('close');
|
||||
$('#tablesForm')[0].reset();
|
||||
};
|
||||
$(dialogObj).dialog({
|
||||
resizable: false,
|
||||
modal: true,
|
||||
title: PMA_messages.confirmTitle,
|
||||
title: Messages.confirmTitle,
|
||||
buttons: buttonOptions
|
||||
});
|
||||
};
|
||||
@ -214,13 +216,13 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
/**
|
||||
* Event handler on select of "Make consistent with central list"
|
||||
*/
|
||||
$('select[name=submit_mult]').change(function (event) {
|
||||
$('select[name=submit_mult]').on('change', function (event) {
|
||||
if ($(this).val() === 'make_consistent_with_central_list') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
jqConfirm(
|
||||
PMA_messages.makeConsistentMessage, function () {
|
||||
$('#tablesForm').submit();
|
||||
Messages.makeConsistentMessage, function () {
|
||||
$('#tablesForm').trigger('submit');
|
||||
}
|
||||
);
|
||||
return false;
|
||||
@ -233,13 +235,13 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
var formData = $('#tablesForm').serialize();
|
||||
var modalTitle = '';
|
||||
if ($(this).val() === 'copy_tbl') {
|
||||
modalTitle = PMA_messages.strCopyTablesTo;
|
||||
modalTitle = Messages.strCopyTablesTo;
|
||||
} else if ($(this).val() === 'add_prefix_tbl') {
|
||||
modalTitle = PMA_messages.strAddPrefix;
|
||||
modalTitle = Messages.strAddPrefix;
|
||||
} else if ($(this).val() === 'replace_prefix_tbl') {
|
||||
modalTitle = PMA_messages.strReplacePrefix;
|
||||
modalTitle = Messages.strReplacePrefix;
|
||||
} else if ($(this).val() === 'copy_tbl_change_prefix') {
|
||||
modalTitle = PMA_messages.strCopyPrefix;
|
||||
modalTitle = Messages.strCopyPrefix;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -251,11 +253,11 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
var dialogObj = $('<div class=\'hide\'>' + data + '</div>');
|
||||
$('body').append(dialogObj);
|
||||
var buttonOptions = {};
|
||||
buttonOptions[PMA_messages.strContinue] = function () {
|
||||
$('#ajax_form').submit();
|
||||
buttonOptions[Messages.strContinue] = function () {
|
||||
$('#ajax_form').trigger('submit');
|
||||
$(this).dialog('close');
|
||||
};
|
||||
buttonOptions[PMA_messages.strCancel] = function () {
|
||||
buttonOptions[Messages.strCancel] = function () {
|
||||
$(this).dialog('close');
|
||||
$('#tablesForm')[0].reset();
|
||||
};
|
||||
@ -268,7 +270,7 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$('#tablesForm').submit();
|
||||
$('#tablesForm').trigger('submit');
|
||||
}
|
||||
});
|
||||
|
||||
@ -281,46 +283,46 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
/**
|
||||
* @var $this_anchor Object referring to the anchor clicked
|
||||
*/
|
||||
var $this_anchor = $(this);
|
||||
var $thisAnchor = $(this);
|
||||
|
||||
// extract current table name and build the question string
|
||||
/**
|
||||
* @var curr_table_name String containing the name of the table to be truncated
|
||||
*/
|
||||
var curr_table_name = $this_anchor.parents('tr').children('th').children('a').text();
|
||||
var currTableName = $thisAnchor.parents('tr').children('th').children('a').text();
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = PMA_messages.strTruncateTableStrongWarning + ' ' +
|
||||
PMA_sprintf(PMA_messages.strDoYouReally, 'TRUNCATE `' + escapeHtml(curr_table_name) + '`') +
|
||||
getForeignKeyCheckboxLoader();
|
||||
var question = Messages.strTruncateTableStrongWarning + ' ' +
|
||||
Functions.sprintf(Messages.strDoYouReally, 'TRUNCATE `' + Functions.escapeHtml(currTableName) + '`') +
|
||||
Functions.getForeignKeyCheckboxLoader();
|
||||
|
||||
$this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function (url) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
$thisAnchor.confirm(question, $thisAnchor.attr('href'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.getPostData());
|
||||
var params = Functions.getJsConfirmCommonParam(this, $thisAnchor.getPostData());
|
||||
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
// Adjust table statistics
|
||||
var $tr = $this_anchor.closest('tr');
|
||||
var $tr = $thisAnchor.closest('tr');
|
||||
$tr.find('.tbl_rows').text('0');
|
||||
$tr.find('.tbl_size, .tbl_overhead').text('-');
|
||||
// Fetch inner span of this anchor
|
||||
// and replace the icon with its disabled version
|
||||
var span = $this_anchor.html().replace(/b_empty/, 'bd_empty');
|
||||
var span = $thisAnchor.html().replace(/b_empty/, 'bd_empty');
|
||||
// To disable further attempts to truncate the table,
|
||||
// replace the a element with its inner span (modified)
|
||||
$this_anchor
|
||||
$thisAnchor
|
||||
.replaceWith(span)
|
||||
.removeClass('truncate_table_anchor');
|
||||
PMA_adjustTotals();
|
||||
DatabaseStructure.adjustTotals();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
Functions.ajaxShowMessage(Messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}, loadForeignKeyCheckbox); // end $.PMA_confirm()
|
||||
}, Functions.loadForeignKeyCheckbox);
|
||||
}); // end of Truncate Table Ajax action
|
||||
|
||||
/**
|
||||
@ -329,51 +331,51 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
$(document).on('click', 'a.drop_table_anchor.ajax', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $this_anchor = $(this);
|
||||
var $thisAnchor = $(this);
|
||||
|
||||
// extract current table name and build the question string
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $curr_row = $this_anchor.parents('tr');
|
||||
var $currRow = $thisAnchor.parents('tr');
|
||||
/**
|
||||
* @var curr_table_name String containing the name of the table to be truncated
|
||||
*/
|
||||
var curr_table_name = $curr_row.children('th').children('a').text();
|
||||
var currTableName = $currRow.children('th').children('a').text();
|
||||
/**
|
||||
* @var is_view Boolean telling if we have a view
|
||||
*/
|
||||
var is_view = $curr_row.hasClass('is_view') || $this_anchor.hasClass('view');
|
||||
var isView = $currRow.hasClass('is_view') || $thisAnchor.hasClass('view');
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question;
|
||||
if (! is_view) {
|
||||
question = PMA_messages.strDropTableStrongWarning + ' ' +
|
||||
PMA_sprintf(PMA_messages.strDoYouReally, 'DROP TABLE `' + escapeHtml(curr_table_name) + '`');
|
||||
if (! isView) {
|
||||
question = Messages.strDropTableStrongWarning + ' ' +
|
||||
Functions.sprintf(Messages.strDoYouReally, 'DROP TABLE `' + Functions.escapeHtml(currTableName) + '`');
|
||||
} else {
|
||||
question =
|
||||
PMA_sprintf(PMA_messages.strDoYouReally, 'DROP VIEW `' + escapeHtml(curr_table_name) + '`');
|
||||
Functions.sprintf(Messages.strDoYouReally, 'DROP VIEW `' + Functions.escapeHtml(currTableName) + '`');
|
||||
}
|
||||
question += getForeignKeyCheckboxLoader();
|
||||
question += Functions.getForeignKeyCheckboxLoader();
|
||||
|
||||
$this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function (url) {
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
$thisAnchor.confirm(question, $thisAnchor.attr('href'), function (url) {
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.getPostData());
|
||||
var params = Functions.getJsConfirmCommonParam(this, $thisAnchor.getPostData());
|
||||
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$curr_row.hide('medium').remove();
|
||||
PMA_adjustTotals();
|
||||
PMA_reloadNavigation();
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxShowMessage(data.message);
|
||||
$currRow.hide('medium').remove();
|
||||
DatabaseStructure.adjustTotals();
|
||||
Navigation.reload();
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
Functions.ajaxShowMessage(Messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}, loadForeignKeyCheckbox); // end $.PMA_confirm()
|
||||
}, Functions.loadForeignKeyCheckbox);
|
||||
}); // end of Drop Table Ajax action
|
||||
|
||||
/**
|
||||
@ -383,7 +385,7 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
event.preventDefault();
|
||||
|
||||
// Take to preview mode
|
||||
printPreview();
|
||||
Functions.printPreview();
|
||||
}); // end of Print View action
|
||||
|
||||
// Calculate Real End for InnoDB
|
||||
@ -397,9 +399,9 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = PMA_messages.strOperationTakesLongTime;
|
||||
var question = Messages.strOperationTakesLongTime;
|
||||
|
||||
$(this).PMA_confirm(question, '', function () {
|
||||
$(this).confirm(question, '', function () {
|
||||
return true;
|
||||
});
|
||||
return false;
|
||||
@ -407,7 +409,7 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
|
||||
// Add tooltip to favorite icons.
|
||||
$('.favorite_table_anchor').each(function () {
|
||||
PMA_tooltip(
|
||||
Functions.tooltip(
|
||||
$(this),
|
||||
'a',
|
||||
$(this).attr('title')
|
||||
@ -417,11 +419,11 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
// Get real row count via Ajax.
|
||||
$('a.real_row_count').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
PMA_fetchRealRowCount($(this));
|
||||
DatabaseStructure.fetchRealRowCount($(this));
|
||||
});
|
||||
// Get all real row count.
|
||||
$('a.row_count_sum').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
PMA_fetchRealRowCount($(this));
|
||||
DatabaseStructure.fetchRealRowCount($(this));
|
||||
});
|
||||
}); // end $()
|
||||
});
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Unbind all event handlers before tearing down the page
|
||||
*/
|
||||
AJAX.registerTeardown('db_tracking.js', function () {
|
||||
AJAX.registerTeardown('database/tracking.js', function () {
|
||||
$('body').off('click', '#trackedForm.ajax button[name="submit_mult"], #trackedForm.ajax input[name="submit_mult"]');
|
||||
$('body').off('click', '#untrackedForm.ajax button[name="submit_mult"], #untrackedForm.ajax input[name="submit_mult"]');
|
||||
$('body').off('click', 'a.delete_tracking_anchor.ajax');
|
||||
@ -10,7 +10,7 @@ AJAX.registerTeardown('db_tracking.js', function () {
|
||||
/**
|
||||
* Bind event handlers
|
||||
*/
|
||||
AJAX.registerOnload('db_tracking.js', function () {
|
||||
AJAX.registerOnload('database/tracking.js', function () {
|
||||
var $versions = $('#versions');
|
||||
$versions.find('tr:first th').append($('<div class="sorticon"></div>'));
|
||||
$versions.tablesorter({
|
||||
@ -43,18 +43,18 @@ AJAX.registerOnload('db_tracking.js', function () {
|
||||
e.preventDefault();
|
||||
var $button = $(this);
|
||||
var $form = $button.parent('form');
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'submit_mult=' + $button.val();
|
||||
|
||||
if ($button.val() === 'delete_tracking') {
|
||||
var question = PMA_messages.strDeleteTrackingDataMultiple;
|
||||
$button.PMA_confirm(question, $form.attr('action'), function (url) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strDeletingTrackingData);
|
||||
var question = Messages.strDeleteTrackingDataMultiple;
|
||||
$button.confirm(question, $form.attr('action'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strDeletingTrackingData);
|
||||
AJAX.source = $form;
|
||||
$.post(url, submitData, AJAX.responseHandler);
|
||||
});
|
||||
} else {
|
||||
PMA_ajaxShowMessage();
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $form;
|
||||
$.post($form.attr('action'), submitData, AJAX.responseHandler);
|
||||
}
|
||||
@ -67,9 +67,9 @@ AJAX.registerOnload('db_tracking.js', function () {
|
||||
e.preventDefault();
|
||||
var $button = $(this);
|
||||
var $form = $button.parent('form');
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'submit_mult=' + $button.val();
|
||||
PMA_ajaxShowMessage();
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $form;
|
||||
$.post($form.attr('action'), submitData, AJAX.responseHandler);
|
||||
});
|
||||
@ -80,12 +80,12 @@ AJAX.registerOnload('db_tracking.js', function () {
|
||||
$body.on('click', 'a.delete_tracking_anchor.ajax', function (e) {
|
||||
e.preventDefault();
|
||||
var $anchor = $(this);
|
||||
var question = PMA_messages.strDeleteTrackingData;
|
||||
$anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strDeletingTrackingData);
|
||||
var question = Messages.strDeleteTrackingData;
|
||||
$anchor.confirm(question, $anchor.attr('href'), function (url) {
|
||||
Functions.ajaxShowMessage(Messages.strDeletingTrackingData);
|
||||
AJAX.source = $anchor;
|
||||
var argSep = PMA_commonParams.get('arg_separator');
|
||||
var params = getJSConfirmCommonParam(this, $anchor.getPostData());
|
||||
var argSep = CommonParams.get('arg_separator');
|
||||
var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData());
|
||||
params += argSep + 'ajax_page_request=1';
|
||||
$.post(url, params, AJAX.responseHandler);
|
||||
});
|
||||
@ -1,6 +1,17 @@
|
||||
var designer_tables = [{ name: 'pdf_pages', key: 'pg_nr', auto_inc: true },
|
||||
{ name: 'table_coords', key: 'id', auto_inc: true }];
|
||||
var designerTables = [
|
||||
{
|
||||
name: 'pdf_pages',
|
||||
key: 'pgNr',
|
||||
autoIncrement: true
|
||||
},
|
||||
{
|
||||
name: 'table_coords',
|
||||
key: 'id',
|
||||
autoIncrement: true
|
||||
}
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var DesignerOfflineDB = (function () {
|
||||
var designerDB = {};
|
||||
var datastore = null;
|
||||
@ -13,16 +24,17 @@ var DesignerOfflineDB = (function () {
|
||||
var db = e.target.result;
|
||||
e.target.transaction.onerror = designerDB.onerror;
|
||||
|
||||
for (var t in designer_tables) {
|
||||
if (db.objectStoreNames.contains(designer_tables[t].name)) {
|
||||
db.deleteObjectStore(designer_tables[t].name);
|
||||
var t;
|
||||
for (t in designerTables) {
|
||||
if (db.objectStoreNames.contains(designerTables[t].name)) {
|
||||
db.deleteObjectStore(designerTables[t].name);
|
||||
}
|
||||
}
|
||||
|
||||
for (var t in designer_tables) {
|
||||
db.createObjectStore(designer_tables[t].name, {
|
||||
keyPath: designer_tables[t].key,
|
||||
autoIncrement: designer_tables[t].auto_inc
|
||||
for (t in designerTables) {
|
||||
db.createObjectStore(designerTables[t].name, {
|
||||
keyPath: designerTables[t].key,
|
||||
autoIncrement: designerTables[t].autoIncrement
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -58,7 +70,7 @@ var DesignerOfflineDB = (function () {
|
||||
var cursorRequest = objStore.openCursor(keyRange);
|
||||
var results = [];
|
||||
|
||||
transaction.oncomplete = function (e) {
|
||||
transaction.oncomplete = function () {
|
||||
callback(results);
|
||||
};
|
||||
|
||||
@ -82,7 +94,7 @@ var DesignerOfflineDB = (function () {
|
||||
var cursorRequest = objStore.openCursor(keyRange);
|
||||
var firstResult = null;
|
||||
|
||||
transaction.oncomplete = function (e) {
|
||||
transaction.oncomplete = function () {
|
||||
callback(firstResult);
|
||||
};
|
||||
|
||||
@ -118,7 +130,7 @@ var DesignerOfflineDB = (function () {
|
||||
var objStore = transaction.objectStore(table);
|
||||
var request = objStore.delete(parseInt(id));
|
||||
|
||||
request.onsuccess = function (e) {
|
||||
request.onsuccess = function () {
|
||||
if (typeof callback !== 'undefined' && callback !== null) {
|
||||
callback(true);
|
||||
}
|
||||
@ -128,6 +140,7 @@ var DesignerOfflineDB = (function () {
|
||||
};
|
||||
|
||||
designerDB.onerror = function (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(e);
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3,64 +3,73 @@
|
||||
* Initialises the data required to run Designer, then fires it up.
|
||||
*/
|
||||
|
||||
var j_tabs;
|
||||
var h_tabs;
|
||||
/* global DesignerOfflineDB */ // js/designer/database.js
|
||||
/* global DesignerHistory */ // js/designer/history.js
|
||||
/* global DesignerMove */ // js/designer/move.js
|
||||
/* global DesignerPage */ // js/designer/page.js
|
||||
/* global designerConfig */ // templates/database/designer/main.twig
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
var jTabs;
|
||||
var hTabs;
|
||||
var contr;
|
||||
var display_field;
|
||||
var displayField;
|
||||
var server;
|
||||
var selectedPage;
|
||||
/* eslint-enable no-unused-vars */
|
||||
|
||||
var db;
|
||||
var selected_page;
|
||||
var designer_tables_enabled;
|
||||
var designerTablesEnabled;
|
||||
|
||||
AJAX.registerTeardown('designer/init.js', function () {
|
||||
$('.trigger').off('click');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('designer/init.js', function () {
|
||||
$('.trigger').click(function () {
|
||||
$('.trigger').on('click', function () {
|
||||
$('.panel').toggle('fast');
|
||||
$(this).toggleClass('active');
|
||||
$('#ab').accordion('refresh');
|
||||
return false;
|
||||
});
|
||||
|
||||
j_tabs = designer_config.scriptTables.j_tabs;
|
||||
h_tabs = designer_config.scriptTables.h_tabs;
|
||||
contr = designer_config.scriptContr;
|
||||
display_field = designer_config.scriptDisplayField;
|
||||
jTabs = designerConfig.scriptTables.j_tabs;
|
||||
hTabs = designerConfig.scriptTables.h_tabs;
|
||||
contr = designerConfig.scriptContr;
|
||||
displayField = designerConfig.scriptDisplayField;
|
||||
|
||||
server = designer_config.server;
|
||||
db = designer_config.db;
|
||||
selected_page = designer_config.displayPage;
|
||||
designer_tables_enabled = designer_config.tablesEnabled;
|
||||
server = designerConfig.server;
|
||||
db = designerConfig.db;
|
||||
selectedPage = designerConfig.displayPage;
|
||||
designerTablesEnabled = designerConfig.tablesEnabled;
|
||||
|
||||
Main();
|
||||
DesignerMove.main();
|
||||
|
||||
if (! designer_tables_enabled) {
|
||||
if (! designerTablesEnabled) {
|
||||
DesignerOfflineDB.open(function (success) {
|
||||
if (success) {
|
||||
Show_tables_in_landing_page(db);
|
||||
DesignerPage.showTablesInLandingPage(db);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#query_Aggregate_Button').click(function () {
|
||||
$('#query_Aggregate_Button').on('click', function () {
|
||||
document.getElementById('query_Aggregate').style.display = 'none';
|
||||
});
|
||||
|
||||
$('#query_having_button').click(function () {
|
||||
$('#query_having_button').on('click', function () {
|
||||
document.getElementById('query_having').style.display = 'none';
|
||||
});
|
||||
|
||||
$('#query_rename_to_button').click(function () {
|
||||
$('#query_rename_to_button').on('click', function () {
|
||||
document.getElementById('query_rename_to').style.display = 'none';
|
||||
});
|
||||
|
||||
$('#build_query_button').click(function () {
|
||||
build_query('SQL Query on Database', 0);
|
||||
$('#build_query_button').on('click', function () {
|
||||
DesignerHistory.buildQuery('SQL Query on Database', 0);
|
||||
});
|
||||
|
||||
$('#query_where_button').click(function () {
|
||||
$('#query_where_button').on('click', function () {
|
||||
document.getElementById('query_where').style.display = 'none';
|
||||
});
|
||||
});
|
||||
|
||||
1862
js/designer/move.js
1862
js/designer/move.js
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,17 @@
|
||||
function PDFPage (db_name, page_descr, tbl_cords) {
|
||||
// no dot set the auto increment before put() in the database
|
||||
// issue #12900
|
||||
// this.pg_nr = null;
|
||||
this.db_name = db_name;
|
||||
this.page_descr = page_descr;
|
||||
this.tbl_cords = tbl_cords;
|
||||
}
|
||||
|
||||
function TableCoordinate (db_name, table_name, pdf_pg_nr, x, y) {
|
||||
// no dot set the auto increment before put() in the database
|
||||
// issue #12900
|
||||
// this.id = null;
|
||||
this.db_name = db_name;
|
||||
this.table_name = table_name;
|
||||
this.pdf_pg_nr = pdf_pg_nr;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var DesignerObjects = {
|
||||
PdfPage: function (dbName, pageDescr, tblCords) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var pgNr;
|
||||
this.dbName = dbName;
|
||||
this.pageDescr = pageDescr;
|
||||
this.tblCords = tblCords;
|
||||
},
|
||||
TableCoordinate: function (dbName, tableName, pdfPgNr, x, y) {
|
||||
this.dbName = dbName;
|
||||
this.tableName = tableName;
|
||||
this.pdfPgNr = pdfPgNr;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,94 +1,103 @@
|
||||
function Show_tables_in_landing_page (db) {
|
||||
Load_first_page(db, function (page) {
|
||||
/* global DesignerOfflineDB */ // js/designer/database.js
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
/* global db, selectedPage:writable */ // js/designer/init.js
|
||||
/* global DesignerMove */ // js/designer/move.js
|
||||
/* global DesignerObjects */ // js/designer/objects.js
|
||||
|
||||
var DesignerPage = {};
|
||||
|
||||
DesignerPage.showTablesInLandingPage = function (db) {
|
||||
DesignerPage.loadFirstPage(db, function (page) {
|
||||
if (page) {
|
||||
Load_HTML_for_page(page.pg_nr);
|
||||
selected_page = page.pg_nr;
|
||||
DesignerPage.loadHtmlForPage(page.pgNr);
|
||||
selectedPage = page.pgNr;
|
||||
} else {
|
||||
Show_new_page_tables(true);
|
||||
DesignerPage.showNewPageTables(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Save_to_new_page (db, page_name, table_positions, callback) {
|
||||
Create_new_page(db, page_name, function (page) {
|
||||
DesignerPage.saveToNewPage = function (db, pageName, tablePositions, callback) {
|
||||
DesignerPage.createNewPage(db, pageName, function (page) {
|
||||
if (page) {
|
||||
var tbl_cords = [];
|
||||
for (var pos = 0; pos < table_positions.length; pos++) {
|
||||
table_positions[pos].pdf_pg_nr = page.pg_nr;
|
||||
Save_table_positions(table_positions[pos], function (id) {
|
||||
tbl_cords.push(id);
|
||||
if (table_positions.length === tbl_cords.length) {
|
||||
page.tbl_cords = tbl_cords;
|
||||
DesignerOfflineDB.addObject('pdf_pages', page);
|
||||
}
|
||||
});
|
||||
var tblCords = [];
|
||||
var saveCallback = function (id) {
|
||||
tblCords.push(id);
|
||||
if (tablePositions.length === tblCords.length) {
|
||||
page.tblCords = tblCords;
|
||||
DesignerOfflineDB.addObject('pdf_pages', page);
|
||||
}
|
||||
};
|
||||
for (var pos = 0; pos < tablePositions.length; pos++) {
|
||||
tablePositions[pos].pdfPgNr = page.pgNr;
|
||||
DesignerPage.saveTablePositions(tablePositions[pos], saveCallback);
|
||||
}
|
||||
if (typeof callback !== 'undefined') {
|
||||
callback(page);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Save_to_selected_page (db, page_id, page_name, table_positions, callback) {
|
||||
Delete_page(page_id);
|
||||
Save_to_new_page(db, page_name, table_positions, function (page) {
|
||||
DesignerPage.saveToSelectedPage = function (db, pageId, pageName, tablePositions, callback) {
|
||||
DesignerPage.deletePage(pageId);
|
||||
DesignerPage.saveToNewPage(db, pageName, tablePositions, function (page) {
|
||||
if (typeof callback !== 'undefined') {
|
||||
callback(page);
|
||||
}
|
||||
selected_page = page.pg_nr;
|
||||
selectedPage = page.pgNr;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Create_new_page (db, page_name, callback) {
|
||||
var newPage = new PDFPage(db, page_name);
|
||||
DesignerOfflineDB.addObject('pdf_pages', newPage, function (pg_nr) {
|
||||
newPage.pg_nr = pg_nr;
|
||||
DesignerPage.createNewPage = function (db, pageName, callback) {
|
||||
var newPage = new DesignerObjects.PdfPage(db, pageName);
|
||||
DesignerOfflineDB.addObject('pdf_pages', newPage, function (pgNr) {
|
||||
newPage.pgNr = pgNr;
|
||||
if (typeof callback !== 'undefined') {
|
||||
callback(newPage);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Save_table_positions (positions, callback) {
|
||||
DesignerPage.saveTablePositions = function (positions, callback) {
|
||||
DesignerOfflineDB.addObject('table_coords', positions, callback);
|
||||
}
|
||||
};
|
||||
|
||||
function Create_page_list (db, callback) {
|
||||
DesignerPage.createPageList = function (db, callback) {
|
||||
DesignerOfflineDB.loadAllObjects('pdf_pages', function (pages) {
|
||||
var html = '';
|
||||
for (var p = 0; p < pages.length; p++) {
|
||||
var page = pages[p];
|
||||
if (page.db_name === db) {
|
||||
html += '<option value="' + page.pg_nr + '">';
|
||||
html += escapeHtml(page.page_descr) + '</option>';
|
||||
if (page.dbName === db) {
|
||||
html += '<option value="' + page.pgNr + '">';
|
||||
html += Functions.escapeHtml(page.pageDescr) + '</option>';
|
||||
}
|
||||
}
|
||||
if (typeof callback !== 'undefined') {
|
||||
callback(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Delete_page (page_id, callback) {
|
||||
DesignerOfflineDB.loadObject('pdf_pages', page_id, function (page) {
|
||||
DesignerPage.deletePage = function (pageId, callback) {
|
||||
DesignerOfflineDB.loadObject('pdf_pages', pageId, function (page) {
|
||||
if (page) {
|
||||
for (var i = 0; i < page.tbl_cords.length; i++) {
|
||||
DesignerOfflineDB.deleteObject('table_coords', page.tbl_cords[i]);
|
||||
for (var i = 0; i < page.tblCords.length; i++) {
|
||||
DesignerOfflineDB.deleteObject('table_coords', page.tblCords[i]);
|
||||
}
|
||||
DesignerOfflineDB.deleteObject('pdf_pages', page_id, callback);
|
||||
DesignerOfflineDB.deleteObject('pdf_pages', pageId, callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Load_first_page (db, callback) {
|
||||
DesignerPage.loadFirstPage = function (db, callback) {
|
||||
DesignerOfflineDB.loadAllObjects('pdf_pages', function (pages) {
|
||||
var firstPage = null;
|
||||
for (var i = 0; i < pages.length; i++) {
|
||||
var page = pages[i];
|
||||
if (page.db_name === db) {
|
||||
if (page.dbName === db) {
|
||||
// give preference to a page having same name as the db
|
||||
if (page.page_descr === db) {
|
||||
if (page.pageDescr === db) {
|
||||
callback(page);
|
||||
return;
|
||||
}
|
||||
@ -99,62 +108,62 @@ function Load_first_page (db, callback) {
|
||||
}
|
||||
callback(firstPage);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Show_new_page_tables (check) {
|
||||
var all_tables = $('#id_scroll_tab').find('td input:checkbox');
|
||||
all_tables.prop('checked', check);
|
||||
for (var tab = 0; tab < all_tables.length; tab++) {
|
||||
var input = all_tables[tab];
|
||||
DesignerPage.showNewPageTables = function (check) {
|
||||
var allTables = $('#id_scroll_tab').find('td input:checkbox');
|
||||
allTables.prop('checked', check);
|
||||
for (var tab = 0; tab < allTables.length; tab++) {
|
||||
var input = allTables[tab];
|
||||
if (input.value) {
|
||||
var element = document.getElementById(input.value);
|
||||
element.style.top = Get_random(550, 20) + 'px';
|
||||
element.style.left = Get_random(700, 20) + 'px';
|
||||
VisibleTab(input, input.value);
|
||||
element.style.top = DesignerPage.getRandom(550, 20) + 'px';
|
||||
element.style.left = DesignerPage.getRandom(700, 20) + 'px';
|
||||
DesignerMove.visibleTab(input, input.value);
|
||||
}
|
||||
}
|
||||
selected_page = -1;
|
||||
$('#page_name').text(PMA_messages.strUntitled);
|
||||
MarkUnsaved();
|
||||
}
|
||||
selectedPage = -1;
|
||||
$('#page_name').text(Messages.strUntitled);
|
||||
DesignerMove.markUnsaved();
|
||||
};
|
||||
|
||||
function Load_HTML_for_page (page_id) {
|
||||
Show_new_page_tables(false);
|
||||
Load_page_objects(page_id, function (page, tbl_cords) {
|
||||
$('#name-panel').find('#page_name').text(page.page_descr);
|
||||
MarkSaved();
|
||||
for (var t = 0; t < tbl_cords.length; t++) {
|
||||
var tb_id = db + '.' + tbl_cords[t].table_name;
|
||||
var table = document.getElementById(tb_id);
|
||||
table.style.top = tbl_cords[t].y + 'px';
|
||||
table.style.left = tbl_cords[t].x + 'px';
|
||||
DesignerPage.loadHtmlForPage = function (pageId) {
|
||||
DesignerPage.showNewPageTables(false);
|
||||
DesignerPage.loadPageObjects(pageId, function (page, tblCords) {
|
||||
$('#name-panel').find('#page_name').text(page.pageDescr);
|
||||
DesignerMove.markSaved();
|
||||
for (var t = 0; t < tblCords.length; t++) {
|
||||
var tbId = db + '.' + tblCords[t].tableName;
|
||||
var table = document.getElementById(tbId);
|
||||
table.style.top = tblCords[t].y + 'px';
|
||||
table.style.left = tblCords[t].x + 'px';
|
||||
|
||||
var checkbox = document.getElementById('check_vis_' + tb_id);
|
||||
var checkbox = document.getElementById('check_vis_' + tbId);
|
||||
checkbox.checked = true;
|
||||
VisibleTab(checkbox, checkbox.value);
|
||||
DesignerMove.visibleTab(checkbox, checkbox.value);
|
||||
}
|
||||
selected_page = page.pg_nr;
|
||||
selectedPage = page.pgNr;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Load_page_objects (page_id, callback) {
|
||||
DesignerOfflineDB.loadObject('pdf_pages', page_id, function (page) {
|
||||
var tbl_cords = [];
|
||||
var count = page.tbl_cords.length;
|
||||
DesignerPage.loadPageObjects = function (pageId, callback) {
|
||||
DesignerOfflineDB.loadObject('pdf_pages', pageId, function (page) {
|
||||
var tblCords = [];
|
||||
var count = page.tblCords.length;
|
||||
for (var i = 0; i < count; i++) {
|
||||
DesignerOfflineDB.loadObject('table_coords', page.tbl_cords[i], function (tbl_cord) {
|
||||
tbl_cords.push(tbl_cord);
|
||||
if (tbl_cords.length === count) {
|
||||
DesignerOfflineDB.loadObject('table_coords', page.tblCords[i], function (tblCord) {
|
||||
tblCords.push(tblCord);
|
||||
if (tblCords.length === count) {
|
||||
if (typeof callback !== 'undefined') {
|
||||
callback(page, tbl_cords);
|
||||
callback(page, tblCords);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Get_random (max, min) {
|
||||
DesignerPage.getRandom = function (max, min) {
|
||||
var val = Math.random() * (max - min) + min;
|
||||
return Math.floor(val);
|
||||
}
|
||||
};
|
||||
|
||||
708
js/doclinks.js
708
js/doclinks.js
@ -2,364 +2,366 @@
|
||||
* Definition of links to MySQL documentation.
|
||||
*/
|
||||
|
||||
var mysql_doc_keyword = {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var mysqlDocKeyword = {
|
||||
/* Multi word */
|
||||
'CHARACTER SET': Array('charset'),
|
||||
'SHOW AUTHORS': Array('show-authors'),
|
||||
'SHOW BINARY LOGS': Array('show-binary-logs'),
|
||||
'SHOW BINLOG EVENTS': Array('show-binlog-events'),
|
||||
'SHOW CHARACTER SET': Array('show-character-set'),
|
||||
'SHOW COLLATION': Array('show-collation'),
|
||||
'SHOW COLUMNS': Array('show-columns'),
|
||||
'SHOW CONTRIBUTORS': Array('show-contributors'),
|
||||
'SHOW CREATE DATABASE': Array('show-create-database'),
|
||||
'SHOW CREATE EVENT': Array('show-create-event'),
|
||||
'SHOW CREATE FUNCTION': Array('show-create-function'),
|
||||
'SHOW CREATE PROCEDURE': Array('show-create-procedure'),
|
||||
'SHOW CREATE TABLE': Array('show-create-table'),
|
||||
'SHOW CREATE TRIGGER': Array('show-create-trigger'),
|
||||
'SHOW CREATE VIEW': Array('show-create-view'),
|
||||
'SHOW DATABASES': Array('show-databases'),
|
||||
'SHOW ENGINE': Array('show-engine'),
|
||||
'SHOW ENGINES': Array('show-engines'),
|
||||
'SHOW ERRORS': Array('show-errors'),
|
||||
'SHOW EVENTS': Array('show-events'),
|
||||
'SHOW FUNCTION CODE': Array('show-function-code'),
|
||||
'SHOW FUNCTION STATUS': Array('show-function-status'),
|
||||
'SHOW GRANTS': Array('show-grants'),
|
||||
'SHOW INDEX': Array('show-index'),
|
||||
'SHOW MASTER STATUS': Array('show-master-status'),
|
||||
'SHOW OPEN TABLES': Array('show-open-tables'),
|
||||
'SHOW PLUGINS': Array('show-plugins'),
|
||||
'SHOW PRIVILEGES': Array('show-privileges'),
|
||||
'SHOW PROCEDURE CODE': Array('show-procedure-code'),
|
||||
'SHOW PROCEDURE STATUS': Array('show-procedure-status'),
|
||||
'SHOW PROCESSLIST': Array('show-processlist'),
|
||||
'SHOW PROFILE': Array('show-profile'),
|
||||
'SHOW PROFILES': Array('show-profiles'),
|
||||
'SHOW RELAYLOG EVENTS': Array('show-relaylog-events'),
|
||||
'SHOW SLAVE HOSTS': Array('show-slave-hosts'),
|
||||
'SHOW SLAVE STATUS': Array('show-slave-status'),
|
||||
'SHOW STATUS': Array('show-status'),
|
||||
'SHOW TABLE STATUS': Array('show-table-status'),
|
||||
'SHOW TABLES': Array('show-tables'),
|
||||
'SHOW TRIGGERS': Array('show-triggers'),
|
||||
'SHOW VARIABLES': Array('show-variables'),
|
||||
'SHOW WARNINGS': Array('show-warnings'),
|
||||
'LOAD DATA INFILE': Array('load-data'),
|
||||
'LOAD XML': Array('load-xml'),
|
||||
'LOCK TABLES': Array('lock-tables'),
|
||||
'UNLOCK TABLES': Array('lock-tables'),
|
||||
'ALTER DATABASE': Array('alter-database'),
|
||||
'ALTER EVENT': Array('alter-event'),
|
||||
'ALTER LOGFILE GROUP': Array('alter-logfile-group'),
|
||||
'ALTER FUNCTION': Array('alter-function'),
|
||||
'ALTER PROCEDURE': Array('alter-procedure'),
|
||||
'ALTER SERVER': Array('alter-server'),
|
||||
'ALTER TABLE': Array('alter-table'),
|
||||
'ALTER TABLESPACE': Array('alter-tablespace'),
|
||||
'ALTER VIEW': Array('alter-view'),
|
||||
'CREATE DATABASE': Array('create-database'),
|
||||
'CREATE EVENT': Array('create-event'),
|
||||
'CREATE FUNCTION': Array('create-function'),
|
||||
'CREATE INDEX': Array('create-index'),
|
||||
'CREATE LOGFILE GROUP': Array('create-logfile-group'),
|
||||
'CREATE PROCEDURE': Array('create-procedure'),
|
||||
'CREATE SERVER': Array('create-server'),
|
||||
'CREATE TABLE': Array('create-table'),
|
||||
'CREATE TABLESPACE': Array('create-tablespace'),
|
||||
'CREATE TRIGGER': Array('create-trigger'),
|
||||
'CREATE VIEW': Array('create-view'),
|
||||
'DROP DATABASE': Array('drop-database'),
|
||||
'DROP EVENT': Array('drop-event'),
|
||||
'DROP FUNCTION': Array('drop-function'),
|
||||
'DROP INDEX': Array('drop-index'),
|
||||
'DROP LOGFILE GROUP': Array('drop-logfile-group'),
|
||||
'DROP PROCEDURE': Array('drop-procedure'),
|
||||
'DROP SERVER': Array('drop-server'),
|
||||
'DROP TABLE': Array('drop-table'),
|
||||
'DROP TABLESPACE': Array('drop-tablespace'),
|
||||
'DROP TRIGGER': Array('drop-trigger'),
|
||||
'DROP VIEW': Array('drop-view'),
|
||||
'RENAME TABLE': Array('rename-table'),
|
||||
'TRUNCATE TABLE': Array('truncate-table'),
|
||||
'CHARACTER SET': ['charset'],
|
||||
'SHOW AUTHORS': ['show-authors'],
|
||||
'SHOW BINARY LOGS': ['show-binary-logs'],
|
||||
'SHOW BINLOG EVENTS': ['show-binlog-events'],
|
||||
'SHOW CHARACTER SET': ['show-character-set'],
|
||||
'SHOW COLLATION': ['show-collation'],
|
||||
'SHOW COLUMNS': ['show-columns'],
|
||||
'SHOW CONTRIBUTORS': ['show-contributors'],
|
||||
'SHOW CREATE DATABASE': ['show-create-database'],
|
||||
'SHOW CREATE EVENT': ['show-create-event'],
|
||||
'SHOW CREATE FUNCTION': ['show-create-function'],
|
||||
'SHOW CREATE PROCEDURE': ['show-create-procedure'],
|
||||
'SHOW CREATE TABLE': ['show-create-table'],
|
||||
'SHOW CREATE TRIGGER': ['show-create-trigger'],
|
||||
'SHOW CREATE VIEW': ['show-create-view'],
|
||||
'SHOW DATABASES': ['show-databases'],
|
||||
'SHOW ENGINE': ['show-engine'],
|
||||
'SHOW ENGINES': ['show-engines'],
|
||||
'SHOW ERRORS': ['show-errors'],
|
||||
'SHOW EVENTS': ['show-events'],
|
||||
'SHOW FUNCTION CODE': ['show-function-code'],
|
||||
'SHOW FUNCTION STATUS': ['show-function-status'],
|
||||
'SHOW GRANTS': ['show-grants'],
|
||||
'SHOW INDEX': ['show-index'],
|
||||
'SHOW MASTER STATUS': ['show-master-status'],
|
||||
'SHOW OPEN TABLES': ['show-open-tables'],
|
||||
'SHOW PLUGINS': ['show-plugins'],
|
||||
'SHOW PRIVILEGES': ['show-privileges'],
|
||||
'SHOW PROCEDURE CODE': ['show-procedure-code'],
|
||||
'SHOW PROCEDURE STATUS': ['show-procedure-status'],
|
||||
'SHOW PROCESSLIST': ['show-processlist'],
|
||||
'SHOW PROFILE': ['show-profile'],
|
||||
'SHOW PROFILES': ['show-profiles'],
|
||||
'SHOW RELAYLOG EVENTS': ['show-relaylog-events'],
|
||||
'SHOW SLAVE HOSTS': ['show-slave-hosts'],
|
||||
'SHOW SLAVE STATUS': ['show-slave-status'],
|
||||
'SHOW STATUS': ['show-status'],
|
||||
'SHOW TABLE STATUS': ['show-table-status'],
|
||||
'SHOW TABLES': ['show-tables'],
|
||||
'SHOW TRIGGERS': ['show-triggers'],
|
||||
'SHOW VARIABLES': ['show-variables'],
|
||||
'SHOW WARNINGS': ['show-warnings'],
|
||||
'LOAD DATA INFILE': ['load-data'],
|
||||
'LOAD XML': ['load-xml'],
|
||||
'LOCK TABLES': ['lock-tables'],
|
||||
'UNLOCK TABLES': ['lock-tables'],
|
||||
'ALTER DATABASE': ['alter-database'],
|
||||
'ALTER EVENT': ['alter-event'],
|
||||
'ALTER LOGFILE GROUP': ['alter-logfile-group'],
|
||||
'ALTER FUNCTION': ['alter-function'],
|
||||
'ALTER PROCEDURE': ['alter-procedure'],
|
||||
'ALTER SERVER': ['alter-server'],
|
||||
'ALTER TABLE': ['alter-table'],
|
||||
'ALTER TABLESPACE': ['alter-tablespace'],
|
||||
'ALTER VIEW': ['alter-view'],
|
||||
'CREATE DATABASE': ['create-database'],
|
||||
'CREATE EVENT': ['create-event'],
|
||||
'CREATE FUNCTION': ['create-function'],
|
||||
'CREATE INDEX': ['create-index'],
|
||||
'CREATE LOGFILE GROUP': ['create-logfile-group'],
|
||||
'CREATE PROCEDURE': ['create-procedure'],
|
||||
'CREATE SERVER': ['create-server'],
|
||||
'CREATE TABLE': ['create-table'],
|
||||
'CREATE TABLESPACE': ['create-tablespace'],
|
||||
'CREATE TRIGGER': ['create-trigger'],
|
||||
'CREATE VIEW': ['create-view'],
|
||||
'DROP DATABASE': ['drop-database'],
|
||||
'DROP EVENT': ['drop-event'],
|
||||
'DROP FUNCTION': ['drop-function'],
|
||||
'DROP INDEX': ['drop-index'],
|
||||
'DROP LOGFILE GROUP': ['drop-logfile-group'],
|
||||
'DROP PROCEDURE': ['drop-procedure'],
|
||||
'DROP SERVER': ['drop-server'],
|
||||
'DROP TABLE': ['drop-table'],
|
||||
'DROP TABLESPACE': ['drop-tablespace'],
|
||||
'DROP TRIGGER': ['drop-trigger'],
|
||||
'DROP VIEW': ['drop-view'],
|
||||
'RENAME TABLE': ['rename-table'],
|
||||
'TRUNCATE TABLE': ['truncate-table'],
|
||||
|
||||
/* Statements */
|
||||
'SELECT': Array('select'),
|
||||
'SET': Array('set'),
|
||||
'EXPLAIN': Array('explain'),
|
||||
'DESCRIBE': Array('describe'),
|
||||
'DELETE': Array('delete'),
|
||||
'SHOW': Array('show'),
|
||||
'UPDATE': Array('update'),
|
||||
'INSERT': Array('insert'),
|
||||
'REPLACE': Array('replace'),
|
||||
'CALL': Array('call'),
|
||||
'DO': Array('do'),
|
||||
'HANDLER': Array('handler'),
|
||||
'COLLATE': Array('charset-collations'),
|
||||
'SELECT': ['select'],
|
||||
'SET': ['set'],
|
||||
'EXPLAIN': ['explain'],
|
||||
'DESCRIBE': ['describe'],
|
||||
'DELETE': ['delete'],
|
||||
'SHOW': ['show'],
|
||||
'UPDATE': ['update'],
|
||||
'INSERT': ['insert'],
|
||||
'REPLACE': ['replace'],
|
||||
'CALL': ['call'],
|
||||
'DO': ['do'],
|
||||
'HANDLER': ['handler'],
|
||||
'COLLATE': ['charset-collations'],
|
||||
|
||||
/* Functions */
|
||||
'ABS': Array('mathematical-functions', 'function_abs'),
|
||||
'ACOS': Array('mathematical-functions', 'function_acos'),
|
||||
'ADDDATE': Array('date-and-time-functions', 'function_adddate'),
|
||||
'ADDTIME': Array('date-and-time-functions', 'function_addtime'),
|
||||
'AES_DECRYPT': Array('encryption-functions', 'function_aes_decrypt'),
|
||||
'AES_ENCRYPT': Array('encryption-functions', 'function_aes_encrypt'),
|
||||
'AND': Array('logical-operators', 'operator_and'),
|
||||
'ASCII': Array('string-functions', 'function_ascii'),
|
||||
'ASIN': Array('mathematical-functions', 'function_asin'),
|
||||
'ATAN2': Array('mathematical-functions', 'function_atan2'),
|
||||
'ATAN': Array('mathematical-functions', 'function_atan'),
|
||||
'AVG': Array('group-by-functions', 'function_avg'),
|
||||
'BENCHMARK': Array('information-functions', 'function_benchmark'),
|
||||
'BIN': Array('string-functions', 'function_bin'),
|
||||
'BINARY': Array('cast-functions', 'operator_binary'),
|
||||
'BIT_AND': Array('group-by-functions', 'function_bit_and'),
|
||||
'BIT_COUNT': Array('bit-functions', 'function_bit_count'),
|
||||
'BIT_LENGTH': Array('string-functions', 'function_bit_length'),
|
||||
'BIT_OR': Array('group-by-functions', 'function_bit_or'),
|
||||
'BIT_XOR': Array('group-by-functions', 'function_bit_xor'),
|
||||
'CASE': Array('control-flow-functions', 'operator_case'),
|
||||
'CAST': Array('cast-functions', 'function_cast'),
|
||||
'CEIL': Array('mathematical-functions', 'function_ceil'),
|
||||
'CEILING': Array('mathematical-functions', 'function_ceiling'),
|
||||
'CHAR_LENGTH': Array('string-functions', 'function_char_length'),
|
||||
'CHAR': Array('string-functions', 'function_char'),
|
||||
'CHARACTER_LENGTH': Array('string-functions', 'function_character_length'),
|
||||
'CHARSET': Array('information-functions', 'function_charset'),
|
||||
'COALESCE': Array('comparison-operators', 'function_coalesce'),
|
||||
'COERCIBILITY': Array('information-functions', 'function_coercibility'),
|
||||
'COLLATION': Array('information-functions', 'function_collation'),
|
||||
'COMPRESS': Array('encryption-functions', 'function_compress'),
|
||||
'CONCAT_WS': Array('string-functions', 'function_concat_ws'),
|
||||
'CONCAT': Array('string-functions', 'function_concat'),
|
||||
'CONNECTION_ID': Array('information-functions', 'function_connection_id'),
|
||||
'CONV': Array('mathematical-functions', 'function_conv'),
|
||||
'CONVERT_TZ': Array('date-and-time-functions', 'function_convert_tz'),
|
||||
'Convert': Array('cast-functions', 'function_convert'),
|
||||
'COS': Array('mathematical-functions', 'function_cos'),
|
||||
'COT': Array('mathematical-functions', 'function_cot'),
|
||||
'COUNT': Array('group-by-functions', 'function_count'),
|
||||
'CRC32': Array('mathematical-functions', 'function_crc32'),
|
||||
'CURDATE': Array('date-and-time-functions', 'function_curdate'),
|
||||
'CURRENT_DATE': Array('date-and-time-functions', 'function_current_date'),
|
||||
'CURRENT_TIME': Array('date-and-time-functions', 'function_current_time'),
|
||||
'CURRENT_TIMESTAMP': Array('date-and-time-functions', 'function_current_timestamp'),
|
||||
'CURRENT_USER': Array('information-functions', 'function_current_user'),
|
||||
'CURTIME': Array('date-and-time-functions', 'function_curtime'),
|
||||
'DATABASE': Array('information-functions', 'function_database'),
|
||||
'DATE_ADD': Array('date-and-time-functions', 'function_date_add'),
|
||||
'DATE_FORMAT': Array('date-and-time-functions', 'function_date_format'),
|
||||
'DATE_SUB': Array('date-and-time-functions', 'function_date_sub'),
|
||||
'DATE': Array('date-and-time-functions', 'function_date'),
|
||||
'DATEDIFF': Array('date-and-time-functions', 'function_datediff'),
|
||||
'DAY': Array('date-and-time-functions', 'function_day'),
|
||||
'DAYNAME': Array('date-and-time-functions', 'function_dayname'),
|
||||
'DAYOFMONTH': Array('date-and-time-functions', 'function_dayofmonth'),
|
||||
'DAYOFWEEK': Array('date-and-time-functions', 'function_dayofweek'),
|
||||
'DAYOFYEAR': Array('date-and-time-functions', 'function_dayofyear'),
|
||||
'DECLARE': Array('declare', 'declare'),
|
||||
'DECODE': Array('encryption-functions', 'function_decode'),
|
||||
'DEFAULT': Array('miscellaneous-functions', 'function_default'),
|
||||
'DEGREES': Array('mathematical-functions', 'function_degrees'),
|
||||
'DES_DECRYPT': Array('encryption-functions', 'function_des_decrypt'),
|
||||
'DES_ENCRYPT': Array('encryption-functions', 'function_des_encrypt'),
|
||||
'DIV': Array('arithmetic-functions', 'operator_div'),
|
||||
'ELT': Array('string-functions', 'function_elt'),
|
||||
'ENCODE': Array('encryption-functions', 'function_encode'),
|
||||
'ENCRYPT': Array('encryption-functions', 'function_encrypt'),
|
||||
'EXP': Array('mathematical-functions', 'function_exp'),
|
||||
'EXPORT_SET': Array('string-functions', 'function_export_set'),
|
||||
'EXTRACT': Array('date-and-time-functions', 'function_extract'),
|
||||
'ExtractValue': Array('xml-functions', 'function_extractvalue'),
|
||||
'FIELD': Array('string-functions', 'function_field'),
|
||||
'FIND_IN_SET': Array('string-functions', 'function_find_in_set'),
|
||||
'FLOOR': Array('mathematical-functions', 'function_floor'),
|
||||
'FORMAT': Array('string-functions', 'function_format'),
|
||||
'FOUND_ROWS': Array('information-functions', 'function_found_rows'),
|
||||
'FROM_DAYS': Array('date-and-time-functions', 'function_from_days'),
|
||||
'FROM_UNIXTIME': Array('date-and-time-functions', 'function_from_unixtime'),
|
||||
'GET_FORMAT': Array('date-and-time-functions', 'function_get_format'),
|
||||
'GET_LOCK': Array('miscellaneous-functions', 'function_get_lock'),
|
||||
'GREATEST': Array('comparison-operators', 'function_greatest'),
|
||||
'GROUP_CONCAT': Array('group-by-functions', 'function_group_concat'),
|
||||
'HEX': Array('string-functions', 'function_hex'),
|
||||
'HOUR': Array('date-and-time-functions', 'function_hour'),
|
||||
'IF': Array('control-flow-functions', 'function_if'),
|
||||
'IFNULL': Array('control-flow-functions', 'function_ifnull'),
|
||||
'IN': Array('comparison-operators', 'function_in'),
|
||||
'INET_ATON': Array('miscellaneous-functions', 'function_inet_aton'),
|
||||
'INET_NTOA': Array('miscellaneous-functions', 'function_inet_ntoa'),
|
||||
'INSTR': Array('string-functions', 'function_instr'),
|
||||
'INTERVAL': Array('comparison-operators', 'function_interval'),
|
||||
'IS_FREE_LOCK': Array('miscellaneous-functions', 'function_is_free_lock'),
|
||||
'IS_USED_LOCK': Array('miscellaneous-functions', 'function_is_used_lock'),
|
||||
'IS': Array('comparison-operators', 'operator_is'),
|
||||
'ISNULL': Array('comparison-operators', 'function_isnull'),
|
||||
'LAST_DAY': Array('date-and-time-functions', 'function_last_day'),
|
||||
'LAST_INSERT_ID': Array('information-functions', 'function_last_insert_id'),
|
||||
'LCASE': Array('string-functions', 'function_lcase'),
|
||||
'LEAST': Array('comparison-operators', 'function_least'),
|
||||
'LEFT': Array('string-functions', 'function_left'),
|
||||
'LENGTH': Array('string-functions', 'function_length'),
|
||||
'LIKE': Array('string-comparison-functions', 'operator_like'),
|
||||
'LN': Array('mathematical-functions', 'function_ln'),
|
||||
'LOAD_FILE': Array('string-functions', 'function_load_file'),
|
||||
'LOCALTIME': Array('date-and-time-functions', 'function_localtime'),
|
||||
'LOCALTIMESTAMP': Array('date-and-time-functions', 'function_localtimestamp'),
|
||||
'LOCATE': Array('string-functions', 'function_locate'),
|
||||
'LOG10': Array('mathematical-functions', 'function_log10'),
|
||||
'LOG2': Array('mathematical-functions', 'function_log2'),
|
||||
'LOG': Array('mathematical-functions', 'function_log'),
|
||||
'LOWER': Array('string-functions', 'function_lower'),
|
||||
'LPAD': Array('string-functions', 'function_lpad'),
|
||||
'LTRIM': Array('string-functions', 'function_ltrim'),
|
||||
'MAKE_SET': Array('string-functions', 'function_make_set'),
|
||||
'MAKEDATE': Array('date-and-time-functions', 'function_makedate'),
|
||||
'MAKETIME': Array('date-and-time-functions', 'function_maketime'),
|
||||
'MASTER_POS_WAIT': Array('miscellaneous-functions', 'function_master_pos_wait'),
|
||||
'MATCH': Array('fulltext-search', 'function_match'),
|
||||
'MAX': Array('group-by-functions', 'function_max'),
|
||||
'MD5': Array('encryption-functions', 'function_md5'),
|
||||
'MICROSECOND': Array('date-and-time-functions', 'function_microsecond'),
|
||||
'MID': Array('string-functions', 'function_mid'),
|
||||
'MIN': Array('group-by-functions', 'function_min'),
|
||||
'MINUTE': Array('date-and-time-functions', 'function_minute'),
|
||||
'MOD': Array('mathematical-functions', 'function_mod'),
|
||||
'MONTH': Array('date-and-time-functions', 'function_month'),
|
||||
'MONTHNAME': Array('date-and-time-functions', 'function_monthname'),
|
||||
'NAME_CONST': Array('miscellaneous-functions', 'function_name_const'),
|
||||
'NOT': Array('logical-operators', 'operator_not'),
|
||||
'NOW': Array('date-and-time-functions', 'function_now'),
|
||||
'NULLIF': Array('control-flow-functions', 'function_nullif'),
|
||||
'OCT': Array('mathematical-functions', 'function_oct'),
|
||||
'OCTET_LENGTH': Array('string-functions', 'function_octet_length'),
|
||||
'OLD_PASSWORD': Array('encryption-functions', 'function_old_password'),
|
||||
'OR': Array('logical-operators', 'operator_or'),
|
||||
'ORD': Array('string-functions', 'function_ord'),
|
||||
'PASSWORD': Array('encryption-functions', 'function_password'),
|
||||
'PERIOD_ADD': Array('date-and-time-functions', 'function_period_add'),
|
||||
'PERIOD_DIFF': Array('date-and-time-functions', 'function_period_diff'),
|
||||
'PI': Array('mathematical-functions', 'function_pi'),
|
||||
'POSITION': Array('string-functions', 'function_position'),
|
||||
'POW': Array('mathematical-functions', 'function_pow'),
|
||||
'POWER': Array('mathematical-functions', 'function_power'),
|
||||
'QUARTER': Array('date-and-time-functions', 'function_quarter'),
|
||||
'QUOTE': Array('string-functions', 'function_quote'),
|
||||
'RADIANS': Array('mathematical-functions', 'function_radians'),
|
||||
'RAND': Array('mathematical-functions', 'function_rand'),
|
||||
'REGEXP': Array('regexp', 'operator_regexp'),
|
||||
'RELEASE_LOCK': Array('miscellaneous-functions', 'function_release_lock'),
|
||||
'REPEAT': Array('string-functions', 'function_repeat'),
|
||||
'REVERSE': Array('string-functions', 'function_reverse'),
|
||||
'RIGHT': Array('string-functions', 'function_right'),
|
||||
'RLIKE': Array('regexp', 'operator_rlike'),
|
||||
'ROUND': Array('mathematical-functions', 'function_round'),
|
||||
'ROW_COUNT': Array('information-functions', 'function_row_count'),
|
||||
'RPAD': Array('string-functions', 'function_rpad'),
|
||||
'RTRIM': Array('string-functions', 'function_rtrim'),
|
||||
'SCHEMA': Array('information-functions', 'function_schema'),
|
||||
'SEC_TO_TIME': Array('date-and-time-functions', 'function_sec_to_time'),
|
||||
'SECOND': Array('date-and-time-functions', 'function_second'),
|
||||
'SESSION_USER': Array('information-functions', 'function_session_user'),
|
||||
'SHA': Array('encryption-functions', 'function_sha1'),
|
||||
'SHA1': Array('encryption-functions', 'function_sha1'),
|
||||
'SIGN': Array('mathematical-functions', 'function_sign'),
|
||||
'SIN': Array('mathematical-functions', 'function_sin'),
|
||||
'SLEEP': Array('miscellaneous-functions', 'function_sleep'),
|
||||
'SOUNDEX': Array('string-functions', 'function_soundex'),
|
||||
'SPACE': Array('string-functions', 'function_space'),
|
||||
'SQRT': Array('mathematical-functions', 'function_sqrt'),
|
||||
'STD': Array('group-by-functions', 'function_std'),
|
||||
'STDDEV_POP': Array('group-by-functions', 'function_stddev_pop'),
|
||||
'STDDEV_SAMP': Array('group-by-functions', 'function_stddev_samp'),
|
||||
'STDDEV': Array('group-by-functions', 'function_stddev'),
|
||||
'STR_TO_DATE': Array('date-and-time-functions', 'function_str_to_date'),
|
||||
'STRCMP': Array('string-comparison-functions', 'function_strcmp'),
|
||||
'SUBDATE': Array('date-and-time-functions', 'function_subdate'),
|
||||
'SUBSTR': Array('string-functions', 'function_substr'),
|
||||
'SUBSTRING_INDEX': Array('string-functions', 'function_substring_index'),
|
||||
'SUBSTRING': Array('string-functions', 'function_substring'),
|
||||
'SUBTIME': Array('date-and-time-functions', 'function_subtime'),
|
||||
'SUM': Array('group-by-functions', 'function_sum'),
|
||||
'SYSDATE': Array('date-and-time-functions', 'function_sysdate'),
|
||||
'SYSTEM_USER': Array('information-functions', 'function_system_user'),
|
||||
'TAN': Array('mathematical-functions', 'function_tan'),
|
||||
'TIME_FORMAT': Array('date-and-time-functions', 'function_time_format'),
|
||||
'TIME_TO_SEC': Array('date-and-time-functions', 'function_time_to_sec'),
|
||||
'TIME': Array('date-and-time-functions', 'function_time'),
|
||||
'TIMEDIFF': Array('date-and-time-functions', 'function_timediff'),
|
||||
'TIMESTAMP': Array('date-and-time-functions', 'function_timestamp'),
|
||||
'TIMESTAMPADD': Array('date-and-time-functions', 'function_timestampadd'),
|
||||
'TIMESTAMPDIFF': Array('date-and-time-functions', 'function_timestampdiff'),
|
||||
'TO_DAYS': Array('date-and-time-functions', 'function_to_days'),
|
||||
'TRIM': Array('string-functions', 'function_trim'),
|
||||
'TRUNCATE': Array('mathematical-functions', 'function_truncate'),
|
||||
'UCASE': Array('string-functions', 'function_ucase'),
|
||||
'UNCOMPRESS': Array('encryption-functions', 'function_uncompress'),
|
||||
'UNCOMPRESSED_LENGTH': Array('encryption-functions', 'function_uncompressed_length'),
|
||||
'UNHEX': Array('string-functions', 'function_unhex'),
|
||||
'UNIX_TIMESTAMP': Array('date-and-time-functions', 'function_unix_timestamp'),
|
||||
'UpdateXML': Array('xml-functions', 'function_updatexml'),
|
||||
'UPPER': Array('string-functions', 'function_upper'),
|
||||
'USER': Array('information-functions', 'function_user'),
|
||||
'UTC_DATE': Array('date-and-time-functions', 'function_utc_date'),
|
||||
'UTC_TIME': Array('date-and-time-functions', 'function_utc_time'),
|
||||
'UTC_TIMESTAMP': Array('date-and-time-functions', 'function_utc_timestamp'),
|
||||
'UUID_SHORT': Array('miscellaneous-functions', 'function_uuid_short'),
|
||||
'UUID': Array('miscellaneous-functions', 'function_uuid'),
|
||||
'VALUES': Array('miscellaneous-functions', 'function_values'),
|
||||
'VAR_POP': Array('group-by-functions', 'function_var_pop'),
|
||||
'VAR_SAMP': Array('group-by-functions', 'function_var_samp'),
|
||||
'VARIANCE': Array('group-by-functions', 'function_variance'),
|
||||
'VERSION': Array('information-functions', 'function_version'),
|
||||
'WEEK': Array('date-and-time-functions', 'function_week'),
|
||||
'WEEKDAY': Array('date-and-time-functions', 'function_weekday'),
|
||||
'WEEKOFYEAR': Array('date-and-time-functions', 'function_weekofyear'),
|
||||
'XOR': Array('logical-operators', 'operator_xor'),
|
||||
'YEAR': Array('date-and-time-functions', 'function_year'),
|
||||
'YEARWEEK': Array('date-and-time-functions', 'function_yearweek'),
|
||||
'SOUNDS_LIKE': Array('string-functions', 'operator_sounds-like'),
|
||||
'IS_NOT_NULL': Array('comparison-operators', 'operator_is-not-null'),
|
||||
'IS_NOT': Array('comparison-operators', 'operator_is-not'),
|
||||
'IS_NULL': Array('comparison-operators', 'operator_is-null'),
|
||||
'NOT_LIKE': Array('string-comparison-functions', 'operator_not-like'),
|
||||
'NOT_REGEXP': Array('regexp', 'operator_not-regexp'),
|
||||
'COUNT_DISTINCT': Array('group-by-functions', 'function_count-distinct'),
|
||||
'NOT_IN': Array('comparison-operators', 'function_not-in')
|
||||
'ABS': ['mathematical-functions', 'function_abs'],
|
||||
'ACOS': ['mathematical-functions', 'function_acos'],
|
||||
'ADDDATE': ['date-and-time-functions', 'function_adddate'],
|
||||
'ADDTIME': ['date-and-time-functions', 'function_addtime'],
|
||||
'AES_DECRYPT': ['encryption-functions', 'function_aes_decrypt'],
|
||||
'AES_ENCRYPT': ['encryption-functions', 'function_aes_encrypt'],
|
||||
'AND': ['logical-operators', 'operator_and'],
|
||||
'ASCII': ['string-functions', 'function_ascii'],
|
||||
'ASIN': ['mathematical-functions', 'function_asin'],
|
||||
'ATAN2': ['mathematical-functions', 'function_atan2'],
|
||||
'ATAN': ['mathematical-functions', 'function_atan'],
|
||||
'AVG': ['group-by-functions', 'function_avg'],
|
||||
'BENCHMARK': ['information-functions', 'function_benchmark'],
|
||||
'BIN': ['string-functions', 'function_bin'],
|
||||
'BINARY': ['cast-functions', 'operator_binary'],
|
||||
'BIT_AND': ['group-by-functions', 'function_bit_and'],
|
||||
'BIT_COUNT': ['bit-functions', 'function_bit_count'],
|
||||
'BIT_LENGTH': ['string-functions', 'function_bit_length'],
|
||||
'BIT_OR': ['group-by-functions', 'function_bit_or'],
|
||||
'BIT_XOR': ['group-by-functions', 'function_bit_xor'],
|
||||
'CASE': ['control-flow-functions', 'operator_case'],
|
||||
'CAST': ['cast-functions', 'function_cast'],
|
||||
'CEIL': ['mathematical-functions', 'function_ceil'],
|
||||
'CEILING': ['mathematical-functions', 'function_ceiling'],
|
||||
'CHAR_LENGTH': ['string-functions', 'function_char_length'],
|
||||
'CHAR': ['string-functions', 'function_char'],
|
||||
'CHARACTER_LENGTH': ['string-functions', 'function_character_length'],
|
||||
'CHARSET': ['information-functions', 'function_charset'],
|
||||
'COALESCE': ['comparison-operators', 'function_coalesce'],
|
||||
'COERCIBILITY': ['information-functions', 'function_coercibility'],
|
||||
'COLLATION': ['information-functions', 'function_collation'],
|
||||
'COMPRESS': ['encryption-functions', 'function_compress'],
|
||||
'CONCAT_WS': ['string-functions', 'function_concat_ws'],
|
||||
'CONCAT': ['string-functions', 'function_concat'],
|
||||
'CONNECTION_ID': ['information-functions', 'function_connection_id'],
|
||||
'CONV': ['mathematical-functions', 'function_conv'],
|
||||
'CONVERT_TZ': ['date-and-time-functions', 'function_convert_tz'],
|
||||
'Convert': ['cast-functions', 'function_convert'],
|
||||
'COS': ['mathematical-functions', 'function_cos'],
|
||||
'COT': ['mathematical-functions', 'function_cot'],
|
||||
'COUNT': ['group-by-functions', 'function_count'],
|
||||
'CRC32': ['mathematical-functions', 'function_crc32'],
|
||||
'CURDATE': ['date-and-time-functions', 'function_curdate'],
|
||||
'CURRENT_DATE': ['date-and-time-functions', 'function_current_date'],
|
||||
'CURRENT_TIME': ['date-and-time-functions', 'function_current_time'],
|
||||
'CURRENT_TIMESTAMP': ['date-and-time-functions', 'function_current_timestamp'],
|
||||
'CURRENT_USER': ['information-functions', 'function_current_user'],
|
||||
'CURTIME': ['date-and-time-functions', 'function_curtime'],
|
||||
'DATABASE': ['information-functions', 'function_database'],
|
||||
'DATE_ADD': ['date-and-time-functions', 'function_date_add'],
|
||||
'DATE_FORMAT': ['date-and-time-functions', 'function_date_format'],
|
||||
'DATE_SUB': ['date-and-time-functions', 'function_date_sub'],
|
||||
'DATE': ['date-and-time-functions', 'function_date'],
|
||||
'DATEDIFF': ['date-and-time-functions', 'function_datediff'],
|
||||
'DAY': ['date-and-time-functions', 'function_day'],
|
||||
'DAYNAME': ['date-and-time-functions', 'function_dayname'],
|
||||
'DAYOFMONTH': ['date-and-time-functions', 'function_dayofmonth'],
|
||||
'DAYOFWEEK': ['date-and-time-functions', 'function_dayofweek'],
|
||||
'DAYOFYEAR': ['date-and-time-functions', 'function_dayofyear'],
|
||||
'DECLARE': ['declare', 'declare'],
|
||||
'DECODE': ['encryption-functions', 'function_decode'],
|
||||
'DEFAULT': ['miscellaneous-functions', 'function_default'],
|
||||
'DEGREES': ['mathematical-functions', 'function_degrees'],
|
||||
'DES_DECRYPT': ['encryption-functions', 'function_des_decrypt'],
|
||||
'DES_ENCRYPT': ['encryption-functions', 'function_des_encrypt'],
|
||||
'DIV': ['arithmetic-functions', 'operator_div'],
|
||||
'ELT': ['string-functions', 'function_elt'],
|
||||
'ENCODE': ['encryption-functions', 'function_encode'],
|
||||
'ENCRYPT': ['encryption-functions', 'function_encrypt'],
|
||||
'EXP': ['mathematical-functions', 'function_exp'],
|
||||
'EXPORT_SET': ['string-functions', 'function_export_set'],
|
||||
'EXTRACT': ['date-and-time-functions', 'function_extract'],
|
||||
'ExtractValue': ['xml-functions', 'function_extractvalue'],
|
||||
'FIELD': ['string-functions', 'function_field'],
|
||||
'FIND_IN_SET': ['string-functions', 'function_find_in_set'],
|
||||
'FLOOR': ['mathematical-functions', 'function_floor'],
|
||||
'FORMAT': ['string-functions', 'function_format'],
|
||||
'FOUND_ROWS': ['information-functions', 'function_found_rows'],
|
||||
'FROM_DAYS': ['date-and-time-functions', 'function_from_days'],
|
||||
'FROM_UNIXTIME': ['date-and-time-functions', 'function_from_unixtime'],
|
||||
'GET_FORMAT': ['date-and-time-functions', 'function_get_format'],
|
||||
'GET_LOCK': ['miscellaneous-functions', 'function_get_lock'],
|
||||
'GREATEST': ['comparison-operators', 'function_greatest'],
|
||||
'GROUP_CONCAT': ['group-by-functions', 'function_group_concat'],
|
||||
'HEX': ['string-functions', 'function_hex'],
|
||||
'HOUR': ['date-and-time-functions', 'function_hour'],
|
||||
'IF': ['control-flow-functions', 'function_if'],
|
||||
'IFNULL': ['control-flow-functions', 'function_ifnull'],
|
||||
'IN': ['comparison-operators', 'function_in'],
|
||||
'INET_ATON': ['miscellaneous-functions', 'function_inet_aton'],
|
||||
'INET_NTOA': ['miscellaneous-functions', 'function_inet_ntoa'],
|
||||
'INSTR': ['string-functions', 'function_instr'],
|
||||
'INTERVAL': ['comparison-operators', 'function_interval'],
|
||||
'IS_FREE_LOCK': ['miscellaneous-functions', 'function_is_free_lock'],
|
||||
'IS_USED_LOCK': ['miscellaneous-functions', 'function_is_used_lock'],
|
||||
'IS': ['comparison-operators', 'operator_is'],
|
||||
'ISNULL': ['comparison-operators', 'function_isnull'],
|
||||
'LAST_DAY': ['date-and-time-functions', 'function_last_day'],
|
||||
'LAST_INSERT_ID': ['information-functions', 'function_last_insert_id'],
|
||||
'LCASE': ['string-functions', 'function_lcase'],
|
||||
'LEAST': ['comparison-operators', 'function_least'],
|
||||
'LEFT': ['string-functions', 'function_left'],
|
||||
'LENGTH': ['string-functions', 'function_length'],
|
||||
'LIKE': ['string-comparison-functions', 'operator_like'],
|
||||
'LN': ['mathematical-functions', 'function_ln'],
|
||||
'LOAD_FILE': ['string-functions', 'function_load_file'],
|
||||
'LOCALTIME': ['date-and-time-functions', 'function_localtime'],
|
||||
'LOCALTIMESTAMP': ['date-and-time-functions', 'function_localtimestamp'],
|
||||
'LOCATE': ['string-functions', 'function_locate'],
|
||||
'LOG10': ['mathematical-functions', 'function_log10'],
|
||||
'LOG2': ['mathematical-functions', 'function_log2'],
|
||||
'LOG': ['mathematical-functions', 'function_log'],
|
||||
'LOWER': ['string-functions', 'function_lower'],
|
||||
'LPAD': ['string-functions', 'function_lpad'],
|
||||
'LTRIM': ['string-functions', 'function_ltrim'],
|
||||
'MAKE_SET': ['string-functions', 'function_make_set'],
|
||||
'MAKEDATE': ['date-and-time-functions', 'function_makedate'],
|
||||
'MAKETIME': ['date-and-time-functions', 'function_maketime'],
|
||||
'MASTER_POS_WAIT': ['miscellaneous-functions', 'function_master_pos_wait'],
|
||||
'MATCH': ['fulltext-search', 'function_match'],
|
||||
'MAX': ['group-by-functions', 'function_max'],
|
||||
'MD5': ['encryption-functions', 'function_md5'],
|
||||
'MICROSECOND': ['date-and-time-functions', 'function_microsecond'],
|
||||
'MID': ['string-functions', 'function_mid'],
|
||||
'MIN': ['group-by-functions', 'function_min'],
|
||||
'MINUTE': ['date-and-time-functions', 'function_minute'],
|
||||
'MOD': ['mathematical-functions', 'function_mod'],
|
||||
'MONTH': ['date-and-time-functions', 'function_month'],
|
||||
'MONTHNAME': ['date-and-time-functions', 'function_monthname'],
|
||||
'NAME_CONST': ['miscellaneous-functions', 'function_name_const'],
|
||||
'NOT': ['logical-operators', 'operator_not'],
|
||||
'NOW': ['date-and-time-functions', 'function_now'],
|
||||
'NULLIF': ['control-flow-functions', 'function_nullif'],
|
||||
'OCT': ['mathematical-functions', 'function_oct'],
|
||||
'OCTET_LENGTH': ['string-functions', 'function_octet_length'],
|
||||
'OLD_PASSWORD': ['encryption-functions', 'function_old_password'],
|
||||
'OR': ['logical-operators', 'operator_or'],
|
||||
'ORD': ['string-functions', 'function_ord'],
|
||||
'PASSWORD': ['encryption-functions', 'function_password'],
|
||||
'PERIOD_ADD': ['date-and-time-functions', 'function_period_add'],
|
||||
'PERIOD_DIFF': ['date-and-time-functions', 'function_period_diff'],
|
||||
'PI': ['mathematical-functions', 'function_pi'],
|
||||
'POSITION': ['string-functions', 'function_position'],
|
||||
'POW': ['mathematical-functions', 'function_pow'],
|
||||
'POWER': ['mathematical-functions', 'function_power'],
|
||||
'QUARTER': ['date-and-time-functions', 'function_quarter'],
|
||||
'QUOTE': ['string-functions', 'function_quote'],
|
||||
'RADIANS': ['mathematical-functions', 'function_radians'],
|
||||
'RAND': ['mathematical-functions', 'function_rand'],
|
||||
'REGEXP': ['regexp', 'operator_regexp'],
|
||||
'RELEASE_LOCK': ['miscellaneous-functions', 'function_release_lock'],
|
||||
'REPEAT': ['string-functions', 'function_repeat'],
|
||||
'REVERSE': ['string-functions', 'function_reverse'],
|
||||
'RIGHT': ['string-functions', 'function_right'],
|
||||
'RLIKE': ['regexp', 'operator_rlike'],
|
||||
'ROUND': ['mathematical-functions', 'function_round'],
|
||||
'ROW_COUNT': ['information-functions', 'function_row_count'],
|
||||
'RPAD': ['string-functions', 'function_rpad'],
|
||||
'RTRIM': ['string-functions', 'function_rtrim'],
|
||||
'SCHEMA': ['information-functions', 'function_schema'],
|
||||
'SEC_TO_TIME': ['date-and-time-functions', 'function_sec_to_time'],
|
||||
'SECOND': ['date-and-time-functions', 'function_second'],
|
||||
'SESSION_USER': ['information-functions', 'function_session_user'],
|
||||
'SHA': ['encryption-functions', 'function_sha1'],
|
||||
'SHA1': ['encryption-functions', 'function_sha1'],
|
||||
'SIGN': ['mathematical-functions', 'function_sign'],
|
||||
'SIN': ['mathematical-functions', 'function_sin'],
|
||||
'SLEEP': ['miscellaneous-functions', 'function_sleep'],
|
||||
'SOUNDEX': ['string-functions', 'function_soundex'],
|
||||
'SPACE': ['string-functions', 'function_space'],
|
||||
'SQRT': ['mathematical-functions', 'function_sqrt'],
|
||||
'STD': ['group-by-functions', 'function_std'],
|
||||
'STDDEV_POP': ['group-by-functions', 'function_stddev_pop'],
|
||||
'STDDEV_SAMP': ['group-by-functions', 'function_stddev_samp'],
|
||||
'STDDEV': ['group-by-functions', 'function_stddev'],
|
||||
'STR_TO_DATE': ['date-and-time-functions', 'function_str_to_date'],
|
||||
'STRCMP': ['string-comparison-functions', 'function_strcmp'],
|
||||
'SUBDATE': ['date-and-time-functions', 'function_subdate'],
|
||||
'SUBSTR': ['string-functions', 'function_substr'],
|
||||
'SUBSTRING_INDEX': ['string-functions', 'function_substring_index'],
|
||||
'SUBSTRING': ['string-functions', 'function_substring'],
|
||||
'SUBTIME': ['date-and-time-functions', 'function_subtime'],
|
||||
'SUM': ['group-by-functions', 'function_sum'],
|
||||
'SYSDATE': ['date-and-time-functions', 'function_sysdate'],
|
||||
'SYSTEM_USER': ['information-functions', 'function_system_user'],
|
||||
'TAN': ['mathematical-functions', 'function_tan'],
|
||||
'TIME_FORMAT': ['date-and-time-functions', 'function_time_format'],
|
||||
'TIME_TO_SEC': ['date-and-time-functions', 'function_time_to_sec'],
|
||||
'TIME': ['date-and-time-functions', 'function_time'],
|
||||
'TIMEDIFF': ['date-and-time-functions', 'function_timediff'],
|
||||
'TIMESTAMP': ['date-and-time-functions', 'function_timestamp'],
|
||||
'TIMESTAMPADD': ['date-and-time-functions', 'function_timestampadd'],
|
||||
'TIMESTAMPDIFF': ['date-and-time-functions', 'function_timestampdiff'],
|
||||
'TO_DAYS': ['date-and-time-functions', 'function_to_days'],
|
||||
'TRIM': ['string-functions', 'function_trim'],
|
||||
'TRUNCATE': ['mathematical-functions', 'function_truncate'],
|
||||
'UCASE': ['string-functions', 'function_ucase'],
|
||||
'UNCOMPRESS': ['encryption-functions', 'function_uncompress'],
|
||||
'UNCOMPRESSED_LENGTH': ['encryption-functions', 'function_uncompressed_length'],
|
||||
'UNHEX': ['string-functions', 'function_unhex'],
|
||||
'UNIX_TIMESTAMP': ['date-and-time-functions', 'function_unix_timestamp'],
|
||||
'UpdateXML': ['xml-functions', 'function_updatexml'],
|
||||
'UPPER': ['string-functions', 'function_upper'],
|
||||
'USER': ['information-functions', 'function_user'],
|
||||
'UTC_DATE': ['date-and-time-functions', 'function_utc_date'],
|
||||
'UTC_TIME': ['date-and-time-functions', 'function_utc_time'],
|
||||
'UTC_TIMESTAMP': ['date-and-time-functions', 'function_utc_timestamp'],
|
||||
'UUID_SHORT': ['miscellaneous-functions', 'function_uuid_short'],
|
||||
'UUID': ['miscellaneous-functions', 'function_uuid'],
|
||||
'VALUES': ['miscellaneous-functions', 'function_values'],
|
||||
'VAR_POP': ['group-by-functions', 'function_var_pop'],
|
||||
'VAR_SAMP': ['group-by-functions', 'function_var_samp'],
|
||||
'VARIANCE': ['group-by-functions', 'function_variance'],
|
||||
'VERSION': ['information-functions', 'function_version'],
|
||||
'WEEK': ['date-and-time-functions', 'function_week'],
|
||||
'WEEKDAY': ['date-and-time-functions', 'function_weekday'],
|
||||
'WEEKOFYEAR': ['date-and-time-functions', 'function_weekofyear'],
|
||||
'XOR': ['logical-operators', 'operator_xor'],
|
||||
'YEAR': ['date-and-time-functions', 'function_year'],
|
||||
'YEARWEEK': ['date-and-time-functions', 'function_yearweek'],
|
||||
'SOUNDS_LIKE': ['string-functions', 'operator_sounds-like'],
|
||||
'IS_NOT_NULL': ['comparison-operators', 'operator_is-not-null'],
|
||||
'IS_NOT': ['comparison-operators', 'operator_is-not'],
|
||||
'IS_NULL': ['comparison-operators', 'operator_is-null'],
|
||||
'NOT_LIKE': ['string-comparison-functions', 'operator_not-like'],
|
||||
'NOT_REGEXP': ['regexp', 'operator_not-regexp'],
|
||||
'COUNT_DISTINCT': ['group-by-functions', 'function_count-distinct'],
|
||||
'NOT_IN': ['comparison-operators', 'function_not-in']
|
||||
};
|
||||
|
||||
var mysql_doc_builtin = {
|
||||
'TINYINT': Array('numeric-types'),
|
||||
'SMALLINT': Array('numeric-types'),
|
||||
'MEDIUMINT': Array('numeric-types'),
|
||||
'INT': Array('numeric-types'),
|
||||
'BIGINT': Array('numeric-types'),
|
||||
'DECIMAL': Array('numeric-types'),
|
||||
'FLOAT': Array('numeric-types'),
|
||||
'DOUBLE': Array('numeric-types'),
|
||||
'REAL': Array('numeric-types'),
|
||||
'BIT': Array('numeric-types'),
|
||||
'BOOLEAN': Array('numeric-types'),
|
||||
'SERIAL': Array('numeric-types'),
|
||||
'DATE': Array('date-and-time-types'),
|
||||
'DATETIME': Array('date-and-time-types'),
|
||||
'TIMESTAMP': Array('date-and-time-types'),
|
||||
'TIME': Array('date-and-time-types'),
|
||||
'YEAR': Array('date-and-time-types'),
|
||||
'CHAR': Array('string-types'),
|
||||
'VARCHAR': Array('string-types'),
|
||||
'TINYTEXT': Array('string-types'),
|
||||
'TEXT': Array('string-types'),
|
||||
'MEDIUMTEXT': Array('string-types'),
|
||||
'LONGTEXT': Array('string-types'),
|
||||
'BINARY': Array('string-types'),
|
||||
'VARBINARY': Array('string-types'),
|
||||
'TINYBLOB': Array('string-types'),
|
||||
'MEDIUMBLOB': Array('string-types'),
|
||||
'BLOB': Array('string-types'),
|
||||
'LONGBLOB': Array('string-types'),
|
||||
'ENUM': Array('string-types'),
|
||||
'SET': Array('string-types')
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var mysqlDocBuiltin = {
|
||||
'TINYINT': ['numeric-types'],
|
||||
'SMALLINT': ['numeric-types'],
|
||||
'MEDIUMINT': ['numeric-types'],
|
||||
'INT': ['numeric-types'],
|
||||
'BIGINT': ['numeric-types'],
|
||||
'DECIMAL': ['numeric-types'],
|
||||
'FLOAT': ['numeric-types'],
|
||||
'DOUBLE': ['numeric-types'],
|
||||
'REAL': ['numeric-types'],
|
||||
'BIT': ['numeric-types'],
|
||||
'BOOLEAN': ['numeric-types'],
|
||||
'SERIAL': ['numeric-types'],
|
||||
'DATE': ['date-and-time-types'],
|
||||
'DATETIME': ['date-and-time-types'],
|
||||
'TIMESTAMP': ['date-and-time-types'],
|
||||
'TIME': ['date-and-time-types'],
|
||||
'YEAR': ['date-and-time-types'],
|
||||
'CHAR': ['string-types'],
|
||||
'VARCHAR': ['string-types'],
|
||||
'TINYTEXT': ['string-types'],
|
||||
'TEXT': ['string-types'],
|
||||
'MEDIUMTEXT': ['string-types'],
|
||||
'LONGTEXT': ['string-types'],
|
||||
'BINARY': ['string-types'],
|
||||
'VARBINARY': ['string-types'],
|
||||
'TINYBLOB': ['string-types'],
|
||||
'MEDIUMBLOB': ['string-types'],
|
||||
'BLOB': ['string-types'],
|
||||
'LONGBLOB': ['string-types'],
|
||||
'ENUM': ['string-types'],
|
||||
'SET': ['string-types']
|
||||
};
|
||||
|
||||
392
js/drag_drop_import.js
Normal file
392
js/drag_drop_import.js
Normal file
@ -0,0 +1,392 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/* This script handles PMA Drag Drop Import, loaded only when configuration is enabled.*/
|
||||
|
||||
/**
|
||||
* Class to handle PMA Drag and Drop Import
|
||||
* feature
|
||||
*/
|
||||
var DragDropImport = {
|
||||
/**
|
||||
* @var int, count of total uploads in this view
|
||||
*/
|
||||
uploadCount: 0,
|
||||
/**
|
||||
* @var int, count of live uploads
|
||||
*/
|
||||
liveUploadCount: 0,
|
||||
/**
|
||||
* @var string array, allowed extensions
|
||||
*/
|
||||
allowedExtensions: ['sql', 'xml', 'ldi', 'mediawiki', 'shp'],
|
||||
/**
|
||||
* @var string array, allowed extensions for compressed files
|
||||
*/
|
||||
allowedCompressedExtensions: ['gz', 'bz2', 'zip'],
|
||||
/**
|
||||
* @var obj array to store message returned by import_status.php
|
||||
*/
|
||||
importStatus: [],
|
||||
/**
|
||||
* Checks if any dropped file has valid extension or not
|
||||
*
|
||||
* @param file filename
|
||||
*
|
||||
* @return string, extension for valid extension, '' otherwise
|
||||
*/
|
||||
getExtension: function (file) {
|
||||
var arr = file.split('.');
|
||||
var ext = arr[arr.length - 1];
|
||||
|
||||
// check if compressed
|
||||
if (jQuery.inArray(ext.toLowerCase(),
|
||||
DragDropImport.allowedCompressedExtensions) !== -1) {
|
||||
ext = arr[arr.length - 2];
|
||||
}
|
||||
|
||||
// Now check for extension
|
||||
if (jQuery.inArray(ext.toLowerCase(),
|
||||
DragDropImport.allowedExtensions) !== -1) {
|
||||
return ext;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Shows upload progress for different sql uploads
|
||||
*
|
||||
* @param: hash (string), hash for specific file upload
|
||||
* @param: percent (float), file upload percentage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
setProgress: function (hash, percent) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.children('progress').val(percent);
|
||||
},
|
||||
/**
|
||||
* Function to upload the file asynchronously
|
||||
*
|
||||
* @param formData FormData object for a specific file
|
||||
* @param hash hash of the current file upload
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
sendFileToServer: function (formData, hash) {
|
||||
var uploadURL = './import.php'; // Upload URL
|
||||
var jqXHR = $.ajax({
|
||||
xhr: function () {
|
||||
var xhrobj = $.ajaxSettings.xhr();
|
||||
if (xhrobj.upload) {
|
||||
xhrobj.upload.addEventListener('progress', function (event) {
|
||||
var percent = 0;
|
||||
var position = event.loaded || event.position;
|
||||
var total = event.total;
|
||||
if (event.lengthComputable) {
|
||||
percent = Math.ceil(position / total * 100);
|
||||
}
|
||||
// Set progress
|
||||
DragDropImport.setProgress(hash, percent);
|
||||
}, false);
|
||||
}
|
||||
return xhrobj;
|
||||
},
|
||||
url: uploadURL,
|
||||
type: 'POST',
|
||||
contentType:false,
|
||||
processData: false,
|
||||
cache: false,
|
||||
data: formData,
|
||||
success: function (data) {
|
||||
DragDropImport.importFinished(hash, false, data.success);
|
||||
if (!data.success) {
|
||||
DragDropImport.importStatus[DragDropImport.importStatus.length] = {
|
||||
hash: hash,
|
||||
message: data.error
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// -- provide link to cancel the upload
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize').html('<span hash="' +
|
||||
hash + '" class="pma_drop_file_status" task="cancel">' +
|
||||
Messages.dropImportMessageCancel + '</span>');
|
||||
|
||||
// -- add event listener to this link to abort upload operation
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.on('click', function () {
|
||||
if ($(this).attr('task') === 'cancel') {
|
||||
jqXHR.abort();
|
||||
$(this).html('<span>' + Messages.dropImportMessageAborted + '</span>');
|
||||
DragDropImport.importFinished(hash, true, false);
|
||||
} else if ($(this).children('span').html() ===
|
||||
Messages.dropImportMessageFailed) {
|
||||
// -- view information
|
||||
var $this = $(this);
|
||||
$.each(DragDropImport.importStatus,
|
||||
function (key, value) {
|
||||
if (value.hash === hash) {
|
||||
$('.pma_drop_result:visible').remove();
|
||||
var filename = $this.parent('span').attr('data-filename');
|
||||
$('body').append('<div class="pma_drop_result"><h2>' +
|
||||
Messages.dropImportImportResultHeader + ' - ' +
|
||||
filename + '<span class="close">x</span></h2>' + value.message + '</div>');
|
||||
$('.pma_drop_result').draggable(); // to make this dialog draggable
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Triggered when an object is dragged into the PMA UI
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
dragEnter : function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (!DragDropImport.hasFiles(event)) {
|
||||
return;
|
||||
}
|
||||
if (CommonParams.get('db') === '') {
|
||||
$('.pma_drop_handler').html(Messages.dropImportSelectDB);
|
||||
} else {
|
||||
$('.pma_drop_handler').html(Messages.dropImportDropFiles);
|
||||
}
|
||||
$('.pma_drop_handler').fadeIn();
|
||||
},
|
||||
/**
|
||||
* Check if dragged element contains Files
|
||||
*
|
||||
* @param event the event object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
hasFiles: function (event) {
|
||||
return !(typeof event.originalEvent.dataTransfer.types === 'undefined' ||
|
||||
$.inArray('Files', event.originalEvent.dataTransfer.types) < 0 ||
|
||||
$.inArray(
|
||||
'application/x-moz-nativeimage',
|
||||
event.originalEvent.dataTransfer.types
|
||||
) >= 0);
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged file is being dragged over PMA UI
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
dragOver: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (!DragDropImport.hasFiles(event)) {
|
||||
return;
|
||||
}
|
||||
$('.pma_drop_handler').fadeIn();
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged objects are left
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
dragLeave: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
var $dropHandler = $('.pma_drop_handler');
|
||||
$dropHandler.clearQueue().stop();
|
||||
$dropHandler.fadeOut();
|
||||
$dropHandler.html(Messages.dropImportDropFiles);
|
||||
},
|
||||
/**
|
||||
* Called when upload has finished
|
||||
*
|
||||
* @param string, unique hash for a certain upload
|
||||
* @param bool, true if upload was aborted
|
||||
* @param bool, status of sql upload, as sent by server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
importFinished: function (hash, aborted, status) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.children('progress').hide();
|
||||
var icon = 'icon ic_s_success';
|
||||
// -- provide link to view upload status
|
||||
if (!aborted) {
|
||||
if (status) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.html('<span>' + Messages.dropImportMessageSuccess + '</a>');
|
||||
} else {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.html('<span class="underline">' + Messages.dropImportMessageFailed +
|
||||
'</a>');
|
||||
icon = 'icon ic_s_error';
|
||||
}
|
||||
} else {
|
||||
icon = 'icon ic_s_notice';
|
||||
}
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.attr('task', 'info');
|
||||
|
||||
// Set icon
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.prepend('<img src="./themes/dot.gif" title="finished" class="' +
|
||||
icon + '"> ');
|
||||
|
||||
// Decrease liveUploadCount by one
|
||||
$('.pma_import_count').html(--DragDropImport.liveUploadCount);
|
||||
if (!DragDropImport.liveUploadCount) {
|
||||
$('.pma_sql_import_status h2 .close').fadeIn();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged objects are dropped to UI
|
||||
* From this function, the AJAX Upload operation is initiated
|
||||
*
|
||||
* @param event object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
drop: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dbname = CommonParams.get('db');
|
||||
var server = CommonParams.get('server');
|
||||
|
||||
// if no database is selected -- no
|
||||
if (dbname !== '') {
|
||||
var files = event.originalEvent.dataTransfer.files;
|
||||
if (!files || files.length === 0) {
|
||||
// No files actually transferred
|
||||
$('.pma_drop_handler').fadeOut();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
$('.pma_sql_import_status').slideDown();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var ext = (DragDropImport.getExtension(files[i].name));
|
||||
var hash = AJAX.hash(++DragDropImport.uploadCount);
|
||||
|
||||
var $sqlImportStatusDiv = $('.pma_sql_import_status div');
|
||||
$sqlImportStatusDiv.append('<li data-hash="' + hash + '">' +
|
||||
((ext !== '') ? '' : '<img src="./themes/dot.gif" title="invalid format" class="icon ic_s_notice"> ') +
|
||||
Functions.escapeHtml(files[i].name) + '<span class="filesize" data-filename="' +
|
||||
Functions.escapeHtml(files[i].name) + '">' + (files[i].size / 1024).toFixed(2) +
|
||||
' kb</span></li>');
|
||||
|
||||
// scroll the UI to bottom
|
||||
$sqlImportStatusDiv.scrollTop(
|
||||
$sqlImportStatusDiv.scrollTop() + 50
|
||||
); // 50 hardcoded for now
|
||||
|
||||
if (ext !== '') {
|
||||
// Increment liveUploadCount by one
|
||||
$('.pma_import_count').html(++DragDropImport.liveUploadCount);
|
||||
$('.pma_sql_import_status h2 .close').fadeOut();
|
||||
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.append('<br><progress max="100" value="2"></progress>');
|
||||
|
||||
// uploading
|
||||
var fd = new FormData();
|
||||
fd.append('import_file', files[i]);
|
||||
fd.append('noplugin', Math.random().toString(36).substring(2, 12));
|
||||
fd.append('db', dbname);
|
||||
fd.append('server', server);
|
||||
fd.append('token', CommonParams.get('token'));
|
||||
fd.append('import_type', 'database');
|
||||
// todo: method to find the value below
|
||||
fd.append('MAX_FILE_SIZE', '4194304');
|
||||
// todo: method to find the value below
|
||||
fd.append('charset_of_file','utf-8');
|
||||
// todo: method to find the value below
|
||||
fd.append('allow_interrupt', 'yes');
|
||||
fd.append('skip_queries', '0');
|
||||
fd.append('format',ext);
|
||||
fd.append('sql_compatibility','NONE');
|
||||
fd.append('sql_no_auto_value_on_zero','something');
|
||||
fd.append('ajax_request','true');
|
||||
fd.append('hash', hash);
|
||||
|
||||
// init uploading
|
||||
DragDropImport.sendFileToServer(fd, hash);
|
||||
} else if (!DragDropImport.liveUploadCount) {
|
||||
$('.pma_sql_import_status h2 .close').fadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
$('.pma_drop_handler').fadeOut();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when some user drags, dragover, leave
|
||||
* a file to the PMA UI
|
||||
* @param object Event data
|
||||
* @return void
|
||||
*/
|
||||
$(document).on('dragenter', DragDropImport.dragEnter);
|
||||
$(document).on('dragover', DragDropImport.dragOver);
|
||||
$(document).on('dragleave', '.pma_drop_handler', DragDropImport.dragLeave);
|
||||
|
||||
// when file is dropped to PMA UI
|
||||
$(document).on('drop', 'body', DragDropImport.drop);
|
||||
|
||||
// minimizing-maximising the sql ajax upload status
|
||||
$(document).on('click', '.pma_sql_import_status h2 .minimize', function () {
|
||||
if ($(this).attr('toggle') === 'off') {
|
||||
$('.pma_sql_import_status div').css('height','270px');
|
||||
$(this).attr('toggle','on');
|
||||
$(this).html('-'); // to minimize
|
||||
} else {
|
||||
$('.pma_sql_import_status div').css('height','0px');
|
||||
$(this).attr('toggle','off');
|
||||
$(this).html('+'); // to maximise
|
||||
}
|
||||
});
|
||||
|
||||
// closing sql ajax upload status
|
||||
$(document).on('click', '.pma_sql_import_status h2 .close', function () {
|
||||
$('.pma_sql_import_status').fadeOut(function () {
|
||||
$('.pma_sql_import_status div').html('');
|
||||
DragDropImport.importStatus = []; // clear the message array
|
||||
});
|
||||
});
|
||||
|
||||
// Closing the import result box
|
||||
$(document).on('click', '.pma_drop_result h2 .close', function () {
|
||||
$(this).parent('h2').parent('div').remove();
|
||||
});
|
||||
@ -1,52 +1,54 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/* global TraceKit */ // js/vendor/tracekit.js
|
||||
|
||||
/**
|
||||
* general function, usually for data manipulation pages
|
||||
*
|
||||
*/
|
||||
|
||||
var ErrorReport = {
|
||||
/**
|
||||
* @var object stores the last exception info
|
||||
*/
|
||||
_last_exception: null,
|
||||
lastException: null,
|
||||
/**
|
||||
* handles thrown error exceptions based on user preferences
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
error_handler: function (exception) {
|
||||
errorHandler: function (exception) {
|
||||
// issue: 14359
|
||||
if (JSON.stringify(ErrorReport._last_exception) === JSON.stringify(exception)) {
|
||||
if (JSON.stringify(ErrorReport.lastException) === JSON.stringify(exception)) {
|
||||
return;
|
||||
}
|
||||
if (exception.name === null || typeof(exception.name) === 'undefined') {
|
||||
exception.name = ErrorReport._extractExceptionName(exception);
|
||||
exception.name = ErrorReport.extractExceptionName(exception);
|
||||
}
|
||||
ErrorReport._last_exception = exception;
|
||||
ErrorReport.lastException = exception;
|
||||
$.post('error_report.php', {
|
||||
ajax_request: true,
|
||||
server: PMA_commonParams.get('server'),
|
||||
get_settings: true,
|
||||
exception_type: 'js'
|
||||
'ajax_request': true,
|
||||
'server': CommonParams.get('server'),
|
||||
'get_settings': true,
|
||||
'exception_type': 'js'
|
||||
}, function (data) {
|
||||
if (data.success !== true) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
return;
|
||||
}
|
||||
if (data.report_setting === 'ask') {
|
||||
ErrorReport._showErrorNotification();
|
||||
ErrorReport.showErrorNotification();
|
||||
} else if (data.report_setting === 'always') {
|
||||
report_data = ErrorReport._get_report_data(exception);
|
||||
post_data = $.extend(report_data, {
|
||||
send_error_report: true,
|
||||
automatic: true
|
||||
var reportData = ErrorReport.getReportData(exception);
|
||||
var postData = $.extend(reportData, {
|
||||
'send_error_report': true,
|
||||
'automatic': true
|
||||
});
|
||||
$.post('error_report.php', post_data, function (data) {
|
||||
$.post('error_report.php', postData, function (data) {
|
||||
if (data.success === false) {
|
||||
// in the case of an error, show the error message returned.
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.message, false);
|
||||
Functions.ajaxShowMessage(data.message, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -59,8 +61,8 @@ var ErrorReport = {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_showReportDialog: function (exception) {
|
||||
var report_data = ErrorReport._get_report_data(exception);
|
||||
showReportDialog: function (exception) {
|
||||
var reportData = ErrorReport.getReportData(exception);
|
||||
|
||||
/* Remove the hidden dialogs if there are*/
|
||||
if ($('#error_report_dialog').length !== 0) {
|
||||
@ -69,43 +71,43 @@ var ErrorReport = {
|
||||
var $div = $('<div id="error_report_dialog"></div>');
|
||||
$div.css('z-index', '1000');
|
||||
|
||||
var button_options = {};
|
||||
var buttonOptions = {};
|
||||
|
||||
button_options[PMA_messages.strSendErrorReport] = function () {
|
||||
buttonOptions[Messages.strSendErrorReport] = function () {
|
||||
var $dialog = $(this);
|
||||
var post_data = $.extend(report_data, {
|
||||
send_error_report: true,
|
||||
description: $('#report_description').val(),
|
||||
always_send: $('#always_send_checkbox')[0].checked
|
||||
var postData = $.extend(reportData, {
|
||||
'send_error_report': true,
|
||||
'description': $('#report_description').val(),
|
||||
'always_send': $('#always_send_checkbox')[0].checked
|
||||
});
|
||||
$.post('error_report.php', post_data, function (data) {
|
||||
$.post('error_report.php', postData, function (data) {
|
||||
$dialog.dialog('close');
|
||||
if (data.success === false) {
|
||||
// in the case of an error, show the error message returned.
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.message, 3000);
|
||||
Functions.ajaxShowMessage(data.message, 3000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
button_options[PMA_messages.strCancel] = function () {
|
||||
buttonOptions[Messages.strCancel] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
$.post('error_report.php', report_data, function (data) {
|
||||
$.post('error_report.php', reportData, function (data) {
|
||||
if (data.success === false) {
|
||||
// in the case of an error, show the error message returned.
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
// Show dialog if the request was successful
|
||||
$div
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: PMA_messages.strSubmitErrorReport,
|
||||
title: Messages.strSubmitErrorReport,
|
||||
width: 650,
|
||||
modal: true,
|
||||
buttons: button_options,
|
||||
buttons: buttonOptions,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
@ -118,44 +120,44 @@ var ErrorReport = {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_showErrorNotification: function () {
|
||||
ErrorReport._removeErrorNotification();
|
||||
showErrorNotification: function () {
|
||||
ErrorReport.removeErrorNotification();
|
||||
|
||||
var $div = $(
|
||||
'<div style="position:fixed;bottom:0;left:0;right:0;margin:0;' +
|
||||
'z-index:1000" class="error" id="error_notification"></div>'
|
||||
).append(
|
||||
PMA_getImage('s_error') + PMA_messages.strErrorOccurred
|
||||
Functions.getImage('s_error') + Messages.strErrorOccurred
|
||||
);
|
||||
|
||||
var $buttons = $('<div class="floatright"></div>');
|
||||
|
||||
var button_html = '<button id="show_error_report">';
|
||||
button_html += PMA_messages.strShowReportDetails;
|
||||
button_html += '</button>';
|
||||
var buttonHtml = '<button id="show_error_report">';
|
||||
buttonHtml += Messages.strShowReportDetails;
|
||||
buttonHtml += '</button>';
|
||||
|
||||
button_html += '<a id="change_error_settings">';
|
||||
button_html += PMA_getImage('s_cog', PMA_messages.strChangeReportSettings);
|
||||
button_html += '</a>';
|
||||
buttonHtml += '<a id="change_error_settings">';
|
||||
buttonHtml += Functions.getImage('s_cog', Messages.strChangeReportSettings);
|
||||
buttonHtml += '</a>';
|
||||
|
||||
button_html += '<a href="#" id="ignore_error">';
|
||||
button_html += PMA_getImage('b_close', PMA_messages.strIgnore);
|
||||
button_html += '</a>';
|
||||
buttonHtml += '<a href="#" id="ignore_error">';
|
||||
buttonHtml += Functions.getImage('b_close', Messages.strIgnore);
|
||||
buttonHtml += '</a>';
|
||||
|
||||
$buttons.html(button_html);
|
||||
$buttons.html(buttonHtml);
|
||||
|
||||
$div.append($buttons);
|
||||
$div.appendTo(document.body);
|
||||
$(document).on('click', '#change_error_settings', ErrorReport._redirect_to_settings);
|
||||
$(document).on('click', '#show_error_report', ErrorReport._createReportDialog);
|
||||
$(document).on('click', '#ignore_error', ErrorReport._removeErrorNotification);
|
||||
$(document).on('click', '#change_error_settings', ErrorReport.redirectToSettings);
|
||||
$(document).on('click', '#show_error_report', ErrorReport.createReportDialog);
|
||||
$(document).on('click', '#ignore_error', ErrorReport.removeErrorNotification);
|
||||
},
|
||||
/**
|
||||
* Removes the notification if it was displayed before
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_removeErrorNotification: function (e) {
|
||||
removeErrorNotification: function (e) {
|
||||
if (e) {
|
||||
// don't remove the hash fragment by navigating to #
|
||||
e.preventDefault();
|
||||
@ -169,15 +171,15 @@ var ErrorReport = {
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
_extractExceptionName: function (exception) {
|
||||
extractExceptionName: function (exception) {
|
||||
if (exception.message === null || typeof(exception.message) === 'undefined') {
|
||||
return '';
|
||||
}
|
||||
|
||||
var reg = /([a-zA-Z]+):/;
|
||||
var regex_result = reg.exec(exception.message);
|
||||
if (regex_result && regex_result.length === 2) {
|
||||
return regex_result[1];
|
||||
var regexResult = reg.exec(exception.message);
|
||||
if (regexResult && regexResult.length === 2) {
|
||||
return regexResult[1];
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -187,9 +189,9 @@ var ErrorReport = {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_createReportDialog: function () {
|
||||
ErrorReport._removeErrorNotification();
|
||||
ErrorReport._showReportDialog(ErrorReport._last_exception);
|
||||
createReportDialog: function () {
|
||||
ErrorReport.removeErrorNotification();
|
||||
ErrorReport.showReportDialog(ErrorReport.lastException);
|
||||
},
|
||||
/**
|
||||
* Redirects to the settings page containing error report
|
||||
@ -197,7 +199,7 @@ var ErrorReport = {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_redirect_to_settings: function () {
|
||||
redirectToSettings: function () {
|
||||
window.location.href = 'prefs_forms.php';
|
||||
},
|
||||
/**
|
||||
@ -207,7 +209,7 @@ var ErrorReport = {
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
_get_report_data: function (exception) {
|
||||
getReportData: function (exception) {
|
||||
if (exception && exception.stack && exception.stack.length) {
|
||||
for (var i = 0; i < exception.stack.length; i++) {
|
||||
var stack = exception.stack[i];
|
||||
@ -220,33 +222,33 @@ var ErrorReport = {
|
||||
}
|
||||
}
|
||||
}
|
||||
var report_data = {
|
||||
'server': PMA_commonParams.get('server'),
|
||||
var reportData = {
|
||||
'server': CommonParams.get('server'),
|
||||
'ajax_request': true,
|
||||
'exception': exception,
|
||||
'url': window.location.href,
|
||||
'exception_type': 'js'
|
||||
};
|
||||
if (AJAX.scriptHandler._scripts.length > 0) {
|
||||
report_data.scripts = AJAX.scriptHandler._scripts.map(
|
||||
if (AJAX.scriptHandler.scripts.length > 0) {
|
||||
reportData.scripts = AJAX.scriptHandler.scripts.map(
|
||||
function (script) {
|
||||
return script;
|
||||
}
|
||||
);
|
||||
}
|
||||
return report_data;
|
||||
return reportData;
|
||||
},
|
||||
/**
|
||||
* Wraps all global functions that start with PMA_
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
wrap_global_functions: function () {
|
||||
wrapGlobalFunctions: function () {
|
||||
for (var key in window) {
|
||||
if (key.indexOf('PMA_') === 0) {
|
||||
var global = window[key];
|
||||
if (typeof(global) === 'function') {
|
||||
window[key] = ErrorReport.wrap_function(global);
|
||||
window[key] = ErrorReport.wrapFunction(global);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -258,20 +260,20 @@ var ErrorReport = {
|
||||
*
|
||||
* @return function
|
||||
*/
|
||||
wrap_function: function (func) {
|
||||
wrapFunction: function (func) {
|
||||
if (!func.wrapped) {
|
||||
var new_func = function () {
|
||||
var newFunc = function () {
|
||||
try {
|
||||
return func.apply(this, arguments);
|
||||
} catch (x) {
|
||||
TraceKit.report(x);
|
||||
}
|
||||
};
|
||||
new_func.wrapped = true;
|
||||
newFunc.wrapped = true;
|
||||
// Set guid of wrapped function same as original function, so it can be removed
|
||||
// See bug#4146 (problem with jquery draggable and sortable)
|
||||
new_func.guid = func.guid = func.guid || new_func.guid || jQuery.guid++;
|
||||
return new_func;
|
||||
newFunc.guid = func.guid = func.guid || newFunc.guid || jQuery.guid++;
|
||||
return newFunc;
|
||||
} else {
|
||||
return func;
|
||||
}
|
||||
@ -281,11 +283,11 @@ var ErrorReport = {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_wrap_ajax_onload_callback: function () {
|
||||
wrapAjaxOnloadCallback: function () {
|
||||
var oldOnload = AJAX.registerOnload;
|
||||
AJAX.registerOnload = function (file, func) {
|
||||
func = ErrorReport.wrap_function(func);
|
||||
oldOnload.call(this, file, func);
|
||||
var wrappedFunction = ErrorReport.wrapFunction(func);
|
||||
oldOnload.call(this, file, wrappedFunction);
|
||||
};
|
||||
},
|
||||
/**
|
||||
@ -293,12 +295,12 @@ var ErrorReport = {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_wrap_$_on_callback: function () {
|
||||
wrapJqueryOnCallback: function () {
|
||||
var oldOn = $.fn.on;
|
||||
$.fn.on = function () {
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
if (typeof(arguments[i]) === 'function') {
|
||||
arguments[i] = ErrorReport.wrap_function(arguments[i]);
|
||||
arguments[i] = ErrorReport.wrapFunction(arguments[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -311,16 +313,15 @@ var ErrorReport = {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
set_up_error_reporting: function () {
|
||||
ErrorReport.wrap_global_functions();
|
||||
ErrorReport._wrap_ajax_onload_callback();
|
||||
ErrorReport._wrap_$_on_callback();
|
||||
setUpErrorReporting: function () {
|
||||
ErrorReport.wrapGlobalFunctions();
|
||||
ErrorReport.wrapAjaxOnloadCallback();
|
||||
ErrorReport.wrapJqueryOnCallback();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
AJAX.registerOnload('error_report.js', function () {
|
||||
TraceKit.report.subscribe(ErrorReport.error_handler);
|
||||
ErrorReport.set_up_error_reporting();
|
||||
ErrorReport.wrap_global_functions();
|
||||
TraceKit.report.subscribe(ErrorReport.errorHandler);
|
||||
ErrorReport.setUpErrorReporting();
|
||||
ErrorReport.wrapGlobalFunctions();
|
||||
});
|
||||
|
||||
512
js/export.js
512
js/export.js
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@ AJAX.registerOnload('export_output.js', function () {
|
||||
$(document).on('keydown', function (e) {
|
||||
if ((e.which || e.keyCode) === 116) {
|
||||
e.preventDefault();
|
||||
$('#export_refresh_form').submit();
|
||||
$('#export_refresh_form').trigger('submit');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
2389
js/functions.js
2389
js/functions.js
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* global addZoomPanControllers, loadSVG, selectVisualization, styleOSM, zoomAndPan */ // js/table/gis_visualization.js
|
||||
/* global pmaThemeImage */ // js/messages.php
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var gisEditorLoaded = false;
|
||||
|
||||
/**
|
||||
@ -24,20 +28,20 @@ function closeGISEditor () {
|
||||
function prepareJSVersion () {
|
||||
// Change the text on the submit button
|
||||
$('#gis_editor').find('input[name=\'gis_data[save]\']')
|
||||
.val(PMA_messages.strCopy)
|
||||
.val(Messages.strCopy)
|
||||
.insertAfter($('#gis_data_textarea'))
|
||||
.before('<br/><br/>');
|
||||
.before('<br><br>');
|
||||
|
||||
// Add close and cancel links
|
||||
$('#gis_data_editor').prepend('<a class="close_gis_editor" href="#">' + PMA_messages.strClose + '</a>');
|
||||
$('<a class="cancel_gis_editor" href="#"> ' + PMA_messages.strCancel + '</a>')
|
||||
$('#gis_data_editor').prepend('<a class="close_gis_editor" href="#">' + Messages.strClose + '</a>');
|
||||
$('<a class="cancel_gis_editor" href="#"> ' + Messages.strCancel + '</a>')
|
||||
.insertAfter($('input[name=\'gis_data[save]\']'));
|
||||
|
||||
// Remove the unnecessary text
|
||||
$('div#gis_data_output p').remove();
|
||||
|
||||
// Remove 'add' buttons and add links
|
||||
$('#gis_editor').find('input.add').each(function (e) {
|
||||
$('#gis_editor').find('input.add').each(function () {
|
||||
var $button = $(this);
|
||||
$button.addClass('addJs').removeClass('add');
|
||||
var classes = $button.attr('class');
|
||||
@ -57,12 +61,12 @@ function prepareJSVersion () {
|
||||
* @returns the HTML for a data point
|
||||
*/
|
||||
function addDataPoint (pointNumber, prefix) {
|
||||
return '<br/>' +
|
||||
PMA_sprintf(PMA_messages.strPointN, (pointNumber + 1)) + ': ' +
|
||||
'<label for="x">' + PMA_messages.strX + '</label>' +
|
||||
'<input type="text" name="' + prefix + '[' + pointNumber + '][x]" value=""/>' +
|
||||
'<label for="y">' + PMA_messages.strY + '</label>' +
|
||||
'<input type="text" name="' + prefix + '[' + pointNumber + '][y]" value=""/>';
|
||||
return '<br>' +
|
||||
Functions.sprintf(Messages.strPointN, (pointNumber + 1)) + ': ' +
|
||||
'<label for="x">' + Messages.strX + '</label>' +
|
||||
'<input type="text" name="' + prefix + '[' + pointNumber + '][x]" value="">' +
|
||||
'<label for="y">' + Messages.strY + '</label>' +
|
||||
'<input type="text" name="' + prefix + '[' + pointNumber + '][y]" value="">';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,10 +90,11 @@ function initGISEditorVisualization () {
|
||||
* @param value current value of the geometry field
|
||||
* @param field field name
|
||||
* @param type geometry type
|
||||
* @param input_name name of the input field
|
||||
* @param inputName name of the input field
|
||||
* @param token token
|
||||
*/
|
||||
function loadJSAndGISEditor (value, field, type, input_name) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function loadJSAndGISEditor (value, field, type, inputName) {
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var script;
|
||||
|
||||
@ -97,7 +102,7 @@ function loadJSAndGISEditor (value, field, type, input_name) {
|
||||
var smallScripts = ['js/vendor/jquery/jquery.svg.js',
|
||||
'js/vendor/jquery/jquery.mousewheel.js',
|
||||
'js/vendor/jquery/jquery.event.drag-2.2.js',
|
||||
'js/tbl_gis_visualization.js'];
|
||||
'js/table/gis_visualization.js'];
|
||||
|
||||
for (var i = 0; i < smallScripts.length; i++) {
|
||||
script = document.createElement('script');
|
||||
@ -113,14 +118,14 @@ function loadJSAndGISEditor (value, field, type, input_name) {
|
||||
|
||||
script.onreadystatechange = function () {
|
||||
if (this.readyState === 'complete') {
|
||||
loadGISEditor(value, field, type, input_name);
|
||||
loadGISEditor(value, field, type, inputName);
|
||||
}
|
||||
};
|
||||
script.onload = function () {
|
||||
loadGISEditor(value, field, type, input_name);
|
||||
loadGISEditor(value, field, type, inputName);
|
||||
};
|
||||
script.onerror = function () {
|
||||
loadGISEditor(value, field, type, input_name);
|
||||
loadGISEditor(value, field, type, inputName);
|
||||
};
|
||||
|
||||
script.src = 'js/vendor/openlayers/OpenLayers.js';
|
||||
@ -135,25 +140,25 @@ function loadJSAndGISEditor (value, field, type, input_name) {
|
||||
* @param value current value of the geometry field
|
||||
* @param field field name
|
||||
* @param type geometry type
|
||||
* @param input_name name of the input field
|
||||
* @param inputName name of the input field
|
||||
*/
|
||||
function loadGISEditor (value, field, type, input_name) {
|
||||
var $gis_editor = $('#gis_editor');
|
||||
function loadGISEditor (value, field, type, inputName) {
|
||||
var $gisEditor = $('#gis_editor');
|
||||
$.post('gis_data_editor.php', {
|
||||
'field' : field,
|
||||
'value' : value,
|
||||
'type' : type,
|
||||
'input_name' : input_name,
|
||||
'input_name' : inputName,
|
||||
'get_gis_editor' : true,
|
||||
'ajax_request': true,
|
||||
'server': PMA_commonParams.get('server')
|
||||
'server': CommonParams.get('server')
|
||||
}, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
$gis_editor.html(data.gis_editor);
|
||||
$gisEditor.html(data.gis_editor);
|
||||
initGISEditorVisualization();
|
||||
prepareJSVersion();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
@ -161,6 +166,7 @@ function loadGISEditor (value, field, type, input_name) {
|
||||
/**
|
||||
* Opens up the dialog for the GIS data editor.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function openGISEditor () {
|
||||
// Center the popup
|
||||
var windowWidth = document.documentElement.clientWidth;
|
||||
@ -170,22 +176,22 @@ function openGISEditor () {
|
||||
var popupOffsetTop = windowHeight / 2 - popupHeight / 2;
|
||||
var popupOffsetLeft = windowWidth / 2 - popupWidth / 2;
|
||||
|
||||
var $gis_editor = $('#gis_editor');
|
||||
var $gisEditor = $('#gis_editor');
|
||||
var $backgrouond = $('#popup_background');
|
||||
|
||||
$gis_editor.css({ 'top': popupOffsetTop, 'left': popupOffsetLeft, 'width': popupWidth, 'height': popupHeight });
|
||||
$gisEditor.css({ 'top': popupOffsetTop, 'left': popupOffsetLeft, 'width': popupWidth, 'height': popupHeight });
|
||||
$backgrouond.css({ 'opacity' : '0.7' });
|
||||
|
||||
$gis_editor.append(
|
||||
$gisEditor.append(
|
||||
'<div id="gis_data_editor">' +
|
||||
'<img class="ajaxIcon" id="loadingMonitorIcon" src="' +
|
||||
pmaThemeImage + 'ajax_clock_small.gif" alt=""/>' +
|
||||
pmaThemeImage + 'ajax_clock_small.gif" alt="">' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
// Make it appear
|
||||
$backgrouond.fadeIn('fast');
|
||||
$gis_editor.fadeIn('fast');
|
||||
$gisEditor.fadeIn('fast');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,14 +200,14 @@ function openGISEditor () {
|
||||
*/
|
||||
function insertDataAndClose () {
|
||||
var $form = $('form#gis_data_editor_form');
|
||||
var input_name = $form.find('input[name=\'input_name\']').val();
|
||||
var inputName = $form.find('input[name=\'input_name\']').val();
|
||||
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
$.post('gis_data_editor.php', $form.serialize() + argsep + 'generate=true' + argsep + 'ajax_request=true', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
$('input[name=\'' + input_name + '\']').val(data.result);
|
||||
$('input[name=\'' + inputName + '\']').val(data.result);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}, 'json');
|
||||
closeGISEditor();
|
||||
@ -244,17 +250,18 @@ AJAX.registerOnload('gis_data_editor.js', function () {
|
||||
*/
|
||||
$(document).on('change', '#gis_editor input[type=\'text\']', function () {
|
||||
var $form = $('form#gis_data_editor_form');
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
$.post('gis_data_editor.php', $form.serialize() + argsep + 'generate=true' + argsep + 'ajax_request=true', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
$('#gis_data_textarea').val(data.result);
|
||||
$('#placeholder').empty().removeClass('hasSVG').html(data.visualization);
|
||||
$('#openlayersmap').empty();
|
||||
/* TODO: the gis_data_editor should rather return JSON than JS code to eval */
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(data.openLayers);
|
||||
initGISEditorVisualization();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
@ -262,18 +269,18 @@ AJAX.registerOnload('gis_data_editor.js', function () {
|
||||
/**
|
||||
* Update the form on change of the GIS type.
|
||||
*/
|
||||
$(document).on('change', '#gis_editor select.gis_type', function (event) {
|
||||
var $gis_editor = $('#gis_editor');
|
||||
$(document).on('change', '#gis_editor select.gis_type', function () {
|
||||
var $gisEditor = $('#gis_editor');
|
||||
var $form = $('form#gis_data_editor_form');
|
||||
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
$.post('gis_data_editor.php', $form.serialize() + argsep + 'get_gis_editor=true' + argsep + 'ajax_request=true', function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
$gis_editor.html(data.gis_editor);
|
||||
$gisEditor.html(data.gis_editor);
|
||||
initGISEditorVisualization();
|
||||
prepareJSVersion();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
@ -318,21 +325,21 @@ AJAX.registerOnload('gis_data_editor.js', function () {
|
||||
var noOfLines = parseInt($noOfLinesInput.val(), 10);
|
||||
|
||||
// Add the new linesting of inner ring based on the type
|
||||
var html = '<br/>';
|
||||
var html = '<br>';
|
||||
var noOfPoints;
|
||||
if (type === 'MULTILINESTRING') {
|
||||
html += PMA_messages.strLineString + ' ' + (noOfLines + 1) + ':';
|
||||
html += Messages.strLineString + ' ' + (noOfLines + 1) + ':';
|
||||
noOfPoints = 2;
|
||||
} else {
|
||||
html += PMA_messages.strInnerRing + ' ' + noOfLines + ':';
|
||||
html += Messages.strInnerRing + ' ' + noOfLines + ':';
|
||||
noOfPoints = 4;
|
||||
}
|
||||
html += '<input type="hidden" name="' + prefix + '[' + noOfLines + '][no_of_points]" value="' + noOfPoints + '"/>';
|
||||
html += '<input type="hidden" name="' + prefix + '[' + noOfLines + '][no_of_points]" value="' + noOfPoints + '">';
|
||||
for (var i = 0; i < noOfPoints; i++) {
|
||||
html += addDataPoint(i, (prefix + '[' + noOfLines + ']'));
|
||||
}
|
||||
html += '<a class="addPoint addJs" name="' + prefix + '[' + noOfLines + '][add_point]" href="#">+ ' +
|
||||
PMA_messages.strAddPoint + '</a><br/>';
|
||||
Messages.strAddPoint + '</a><br>';
|
||||
|
||||
$a.before(html);
|
||||
$noOfLinesInput.val(noOfLines + 1);
|
||||
@ -351,17 +358,17 @@ AJAX.registerOnload('gis_data_editor.js', function () {
|
||||
var noOfPolygons = parseInt($noOfPolygonsInput.val(), 10);
|
||||
|
||||
// Add the new polygon
|
||||
var html = PMA_messages.strPolygon + ' ' + (noOfPolygons + 1) + ':<br/>';
|
||||
html += '<input type="hidden" name="' + prefix + '[' + noOfPolygons + '][no_of_lines]" value="1"/>' +
|
||||
'<br/>' + PMA_messages.strOuterRing + ':' +
|
||||
'<input type="hidden" name="' + prefix + '[' + noOfPolygons + '][0][no_of_points]" value="4"/>';
|
||||
var html = Messages.strPolygon + ' ' + (noOfPolygons + 1) + ':<br>';
|
||||
html += '<input type="hidden" name="' + prefix + '[' + noOfPolygons + '][no_of_lines]" value="1">' +
|
||||
'<br>' + Messages.strOuterRing + ':' +
|
||||
'<input type="hidden" name="' + prefix + '[' + noOfPolygons + '][0][no_of_points]" value="4">';
|
||||
for (var i = 0; i < 4; i++) {
|
||||
html += addDataPoint(i, (prefix + '[' + noOfPolygons + '][0]'));
|
||||
}
|
||||
html += '<a class="addPoint addJs" name="' + prefix + '[' + noOfPolygons + '][0][add_point]" href="#">+ ' +
|
||||
PMA_messages.strAddPoint + '</a><br/>' +
|
||||
Messages.strAddPoint + '</a><br>' +
|
||||
'<a class="addLine addJs" name="' + prefix + '[' + noOfPolygons + '][add_line]" href="#">+ ' +
|
||||
PMA_messages.strAddInnerRing + '</a><br/><br/>';
|
||||
Messages.strAddInnerRing + '</a><br><br>';
|
||||
|
||||
$a.before(html);
|
||||
$noOfPolygonsInput.val(noOfPolygons + 1);
|
||||
@ -377,15 +384,15 @@ AJAX.registerOnload('gis_data_editor.js', function () {
|
||||
var $noOfGeomsInput = $('input[name=\'' + prefix + '[geom_count]' + '\']');
|
||||
var noOfGeoms = parseInt($noOfGeomsInput.val(), 10);
|
||||
|
||||
var html1 = PMA_messages.strGeometry + ' ' + (noOfGeoms + 1) + ':<br/>';
|
||||
var html1 = Messages.strGeometry + ' ' + (noOfGeoms + 1) + ':<br>';
|
||||
var $geomType = $('select[name=\'gis_data[' + (noOfGeoms - 1) + '][gis_type]\']').clone();
|
||||
$geomType.attr('name', 'gis_data[' + noOfGeoms + '][gis_type]').val('POINT');
|
||||
var html2 = '<br/>' + PMA_messages.strPoint + ' :' +
|
||||
'<label for="x"> ' + PMA_messages.strX + ' </label>' +
|
||||
'<input type="text" name="gis_data[' + noOfGeoms + '][POINT][x]" value=""/>' +
|
||||
'<label for="y"> ' + PMA_messages.strY + ' </label>' +
|
||||
'<input type="text" name="gis_data[' + noOfGeoms + '][POINT][y]" value=""/>' +
|
||||
'<br/><br/>';
|
||||
var html2 = '<br>' + Messages.strPoint + ' :' +
|
||||
'<label for="x"> ' + Messages.strX + ' </label>' +
|
||||
'<input type="text" name="gis_data[' + noOfGeoms + '][POINT][x]" value="">' +
|
||||
'<label for="y"> ' + Messages.strY + ' </label>' +
|
||||
'<input type="text" name="gis_data[' + noOfGeoms + '][POINT][y]" value="">' +
|
||||
'<br><br>';
|
||||
|
||||
$a.before(html1);
|
||||
$geomType.insertBefore($a);
|
||||
|
||||
60
js/import.js
60
js/import.js
@ -13,10 +13,10 @@ function changePluginOpts () {
|
||||
$('#format_specific_opts').find('div.format_specific_options').each(function () {
|
||||
$(this).hide();
|
||||
});
|
||||
var selected_plugin_name = $('#plugins').find('option:selected').val();
|
||||
$('#' + selected_plugin_name + '_options').fadeIn('slow');
|
||||
if (selected_plugin_name === 'csv') {
|
||||
$('#import_notification').text(PMA_messages.strImportCSV);
|
||||
var selectedPluginName = $('#plugins').find('option:selected').val();
|
||||
$('#' + selectedPluginName + '_options').fadeIn('slow');
|
||||
if (selectedPluginName === 'csv') {
|
||||
$('#import_notification').text(Messages.strImportCSV);
|
||||
} else {
|
||||
$('#import_notification').text('');
|
||||
}
|
||||
@ -27,16 +27,16 @@ function changePluginOpts () {
|
||||
* in the plugin dropdown list according to the format of the selected file
|
||||
*/
|
||||
function matchFile (fname) {
|
||||
var fname_array = fname.toLowerCase().split('.');
|
||||
var len = fname_array.length;
|
||||
var fnameArray = fname.toLowerCase().split('.');
|
||||
var len = fnameArray.length;
|
||||
if (len !== 0) {
|
||||
var extension = fname_array[len - 1];
|
||||
var extension = fnameArray[len - 1];
|
||||
if (extension === 'gz' || extension === 'bz2' || extension === 'zip') {
|
||||
len--;
|
||||
}
|
||||
// Only toggle if the format of the file can be imported
|
||||
if ($('select[name=\'format\'] option').filterByValue(fname_array[len - 1]).length === 1) {
|
||||
$('select[name=\'format\'] option').filterByValue(fname_array[len - 1]).prop('selected', true);
|
||||
if ($('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).length === 1) {
|
||||
$('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).prop('selected', true);
|
||||
changePluginOpts();
|
||||
}
|
||||
}
|
||||
@ -56,39 +56,55 @@ AJAX.registerTeardown('import.js', function () {
|
||||
|
||||
AJAX.registerOnload('import.js', function () {
|
||||
// import_file_form validation.
|
||||
$(document).on('submit', '#import_file_form', function (event) {
|
||||
$(document).on('submit', '#import_file_form', function () {
|
||||
var radioLocalImport = $('#radio_local_import_file');
|
||||
var radioImport = $('#radio_import_file');
|
||||
var fileMsg = '<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error" /> ' + PMA_messages.strImportDialogMessage + '</div>';
|
||||
var fileMsg = '<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error"> ' + Messages.strImportDialogMessage + '</div>';
|
||||
var wrongTblNameMsg = '<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error">' + Messages.strTableNameDialogMessage + '</div>';
|
||||
var wrongDBNameMsg = '<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error">' + Messages.strDBNameDialogMessage + '</div>';
|
||||
|
||||
if (radioLocalImport.length !== 0) {
|
||||
// remote upload.
|
||||
|
||||
if (radioImport.is(':checked') && $('#input_import_file').val() === '') {
|
||||
$('#input_import_file').focus();
|
||||
PMA_ajaxShowMessage(fileMsg, false);
|
||||
$('#input_import_file').trigger('focus');
|
||||
Functions.ajaxShowMessage(fileMsg, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (radioLocalImport.is(':checked')) {
|
||||
if ($('#select_local_import_file').length === 0) {
|
||||
PMA_ajaxShowMessage('<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error" /> ' + PMA_messages.strNoImportFile + ' </div>', false);
|
||||
Functions.ajaxShowMessage('<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error"> ' + Messages.strNoImportFile + ' </div>', false);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($('#select_local_import_file').val() === '') {
|
||||
$('#select_local_import_file').focus();
|
||||
PMA_ajaxShowMessage(fileMsg, false);
|
||||
$('#select_local_import_file').trigger('focus');
|
||||
Functions.ajaxShowMessage(fileMsg, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// local upload.
|
||||
if ($('#input_import_file').val() === '') {
|
||||
$('#input_import_file').focus();
|
||||
PMA_ajaxShowMessage(fileMsg, false);
|
||||
$('#input_import_file').trigger('focus');
|
||||
Functions.ajaxShowMessage(fileMsg, false);
|
||||
return false;
|
||||
}
|
||||
if ($('#text_csv_new_tbl_name').length > 0) {
|
||||
var newTblName = $('#text_csv_new_tbl_name').val();
|
||||
if (newTblName.length > 0 && $.trim(newTblName).length === 0) {
|
||||
Functions.ajaxShowMessage(wrongTblNameMsg, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($('#text_csv_new_db_name').length > 0) {
|
||||
var newDBName = $('#text_csv_new_db_name').val();
|
||||
if (newDBName.length > 0 && $.trim(newDBName).length === 0) {
|
||||
Functions.ajaxShowMessage(wrongDBNameMsg, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// show progress bar.
|
||||
@ -100,15 +116,15 @@ AJAX.registerOnload('import.js', function () {
|
||||
changePluginOpts();
|
||||
|
||||
// Whenever the selected plugin changes, change the options displayed
|
||||
$('#plugins').change(function () {
|
||||
$('#plugins').on('change', function () {
|
||||
changePluginOpts();
|
||||
});
|
||||
|
||||
$('#input_import_file').change(function () {
|
||||
$('#input_import_file').on('change', function () {
|
||||
matchFile($(this).val());
|
||||
});
|
||||
|
||||
$('#select_local_import_file').change(function () {
|
||||
$('#select_local_import_file').on('change', function () {
|
||||
matchFile($(this).val());
|
||||
});
|
||||
|
||||
@ -120,7 +136,7 @@ AJAX.registerOnload('import.js', function () {
|
||||
$('#radio_import_file').prop('checked', true);
|
||||
$('#radio_local_import_file').prop('checked', false);
|
||||
});
|
||||
$('#select_local_import_file').focus(function () {
|
||||
$('#select_local_import_file').on('focus', function () {
|
||||
$('#radio_local_import_file').prop('checked', true);
|
||||
$('#radio_import_file').prop('checked', false);
|
||||
});
|
||||
|
||||
580
js/indexes.js
580
js/indexes.js
@ -8,70 +8,74 @@
|
||||
* @required js/functions.js
|
||||
*/
|
||||
|
||||
/* global fulltextIndexes:writable, indexes:writable, primaryIndexes:writable, spatialIndexes:writable, uniqueIndexes:writable */ // js/functions.js
|
||||
|
||||
var Indexes = {};
|
||||
|
||||
/**
|
||||
* Returns the array of indexes based on the index choice
|
||||
*
|
||||
* @param index_choice index choice
|
||||
* @param indexChoice index choice
|
||||
*/
|
||||
function PMA_getIndexArray (index_choice) {
|
||||
var source_array = null;
|
||||
Indexes.getIndexArray = function (indexChoice) {
|
||||
var sourceArray = null;
|
||||
|
||||
switch (index_choice.toLowerCase()) {
|
||||
switch (indexChoice.toLowerCase()) {
|
||||
case 'primary':
|
||||
source_array = primary_indexes;
|
||||
sourceArray = primaryIndexes;
|
||||
break;
|
||||
case 'unique':
|
||||
source_array = unique_indexes;
|
||||
sourceArray = uniqueIndexes;
|
||||
break;
|
||||
case 'index':
|
||||
source_array = indexes;
|
||||
sourceArray = indexes;
|
||||
break;
|
||||
case 'fulltext':
|
||||
source_array = fulltext_indexes;
|
||||
sourceArray = fulltextIndexes;
|
||||
break;
|
||||
case 'spatial':
|
||||
source_array = spatial_indexes;
|
||||
sourceArray = spatialIndexes;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return source_array;
|
||||
}
|
||||
return sourceArray;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hides/shows the inputs and submits appropriately depending
|
||||
* on whether the index type chosen is 'SPATIAL' or not.
|
||||
*/
|
||||
function checkIndexType () {
|
||||
Indexes.checkIndexType = function () {
|
||||
/**
|
||||
* @var Object Dropdown to select the index choice.
|
||||
*/
|
||||
var $select_index_choice = $('#select_index_choice');
|
||||
var $selectIndexChoice = $('#select_index_choice');
|
||||
/**
|
||||
* @var Object Dropdown to select the index type.
|
||||
*/
|
||||
var $select_index_type = $('#select_index_type');
|
||||
var $selectIndexType = $('#select_index_type');
|
||||
/**
|
||||
* @var Object Table header for the size column.
|
||||
*/
|
||||
var $size_header = $('#index_columns').find('thead tr th:nth-child(2)');
|
||||
var $sizeHeader = $('#index_columns').find('thead tr th:nth-child(2)');
|
||||
/**
|
||||
* @var Object Inputs to specify the columns for the index.
|
||||
*/
|
||||
var $column_inputs = $('select[name="index[columns][names][]"]');
|
||||
var $columnInputs = $('select[name="index[columns][names][]"]');
|
||||
/**
|
||||
* @var Object Inputs to specify sizes for columns of the index.
|
||||
*/
|
||||
var $size_inputs = $('input[name="index[columns][sub_parts][]"]');
|
||||
var $sizeInputs = $('input[name="index[columns][sub_parts][]"]');
|
||||
/**
|
||||
* @var Object Footer containg the controllers to add more columns
|
||||
*/
|
||||
var $add_more = $('#index_frm').find('.add_more');
|
||||
var $addMore = $('#index_frm').find('.add_more');
|
||||
|
||||
if ($select_index_choice.val() === 'SPATIAL') {
|
||||
if ($selectIndexChoice.val() === 'SPATIAL') {
|
||||
// Disable and hide the size column
|
||||
$size_header.hide();
|
||||
$size_inputs.each(function () {
|
||||
$sizeHeader.hide();
|
||||
$sizeInputs.each(function () {
|
||||
$(this)
|
||||
.prop('disabled', true)
|
||||
.parent('td').hide();
|
||||
@ -79,10 +83,10 @@ function checkIndexType () {
|
||||
|
||||
// Disable and hide the columns of the index other than the first one
|
||||
var initial = true;
|
||||
$column_inputs.each(function () {
|
||||
$column_input = $(this);
|
||||
$columnInputs.each(function () {
|
||||
var $columnInput = $(this);
|
||||
if (! initial) {
|
||||
$column_input
|
||||
$columnInput
|
||||
.prop('disabled', true)
|
||||
.parent('td').hide();
|
||||
} else {
|
||||
@ -91,34 +95,34 @@ function checkIndexType () {
|
||||
});
|
||||
|
||||
// Hide controllers to add more columns
|
||||
$add_more.hide();
|
||||
$addMore.hide();
|
||||
} else {
|
||||
// Enable and show the size column
|
||||
$size_header.show();
|
||||
$size_inputs.each(function () {
|
||||
$sizeHeader.show();
|
||||
$sizeInputs.each(function () {
|
||||
$(this)
|
||||
.prop('disabled', false)
|
||||
.parent('td').show();
|
||||
});
|
||||
|
||||
// Enable and show the columns of the index
|
||||
$column_inputs.each(function () {
|
||||
$columnInputs.each(function () {
|
||||
$(this)
|
||||
.prop('disabled', false)
|
||||
.parent('td').show();
|
||||
});
|
||||
|
||||
// Show controllers to add more columns
|
||||
$add_more.show();
|
||||
$addMore.show();
|
||||
}
|
||||
|
||||
if ($select_index_choice.val() === 'SPATIAL' ||
|
||||
$select_index_choice.val() === 'FULLTEXT') {
|
||||
$select_index_type.val('').prop('disabled', true);
|
||||
if ($selectIndexChoice.val() === 'SPATIAL' ||
|
||||
$selectIndexChoice.val() === 'FULLTEXT') {
|
||||
$selectIndexType.val('').prop('disabled', true);
|
||||
} else {
|
||||
$select_index_type.prop('disabled', false);
|
||||
$selectIndexType.prop('disabled', false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets current index information into form parameters.
|
||||
@ -128,13 +132,13 @@ function checkIndexType () {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_setIndexFormParameters (source_array, index_choice) {
|
||||
if (index_choice === 'index') {
|
||||
$('input[name="indexes"]').val(JSON.stringify(source_array));
|
||||
Indexes.setIndexFormParameters = function (sourceArray, indexChoice) {
|
||||
if (indexChoice === 'index') {
|
||||
$('input[name="indexes"]').val(JSON.stringify(sourceArray));
|
||||
} else {
|
||||
$('input[name="' + index_choice + '_indexes"]').val(JSON.stringify(source_array));
|
||||
$('input[name="' + indexChoice + '_indexes"]').val(JSON.stringify(sourceArray));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a column from an Index.
|
||||
@ -143,36 +147,36 @@ function PMA_setIndexFormParameters (source_array, index_choice) {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_removeColumnFromIndex (col_index) {
|
||||
Indexes.removeColumnFromIndex = function (colIndex) {
|
||||
// Get previous index details.
|
||||
var previous_index = $('select[name="field_key[' + col_index + ']"]')
|
||||
var previousIndex = $('select[name="field_key[' + colIndex + ']"]')
|
||||
.attr('data-index');
|
||||
if (previous_index.length) {
|
||||
previous_index = previous_index.split(',');
|
||||
var source_array = PMA_getIndexArray(previous_index[0]);
|
||||
if (source_array === null) {
|
||||
if (previousIndex.length) {
|
||||
previousIndex = previousIndex.split(',');
|
||||
var sourceArray = Indexes.getIndexArray(previousIndex[0]);
|
||||
if (sourceArray === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove column from index array.
|
||||
var source_length = source_array[previous_index[1]].columns.length;
|
||||
for (var i = 0; i < source_length; i++) {
|
||||
if (source_array[previous_index[1]].columns[i].col_index === col_index) {
|
||||
source_array[previous_index[1]].columns.splice(i, 1);
|
||||
var sourceLength = sourceArray[previousIndex[1]].columns.length;
|
||||
for (var i = 0; i < sourceLength; i++) {
|
||||
if (sourceArray[previousIndex[1]].columns[i].col_index === colIndex) {
|
||||
sourceArray[previousIndex[1]].columns.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove index completely if no columns left.
|
||||
if (source_array[previous_index[1]].columns.length === 0) {
|
||||
source_array.splice(previous_index[1], 1);
|
||||
if (sourceArray[previousIndex[1]].columns.length === 0) {
|
||||
sourceArray.splice(previousIndex[1], 1);
|
||||
}
|
||||
|
||||
// Update current index details.
|
||||
$('select[name="field_key[' + col_index + ']"]').attr('data-index', '');
|
||||
$('select[name="field_key[' + colIndex + ']"]').attr('data-index', '');
|
||||
// Update form index parameters.
|
||||
PMA_setIndexFormParameters(source_array, previous_index[0].toLowerCase());
|
||||
Indexes.setIndexFormParameters(sourceArray, previousIndex[0].toLowerCase());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a column to an Index.
|
||||
@ -184,40 +188,40 @@ function PMA_removeColumnFromIndex (col_index) {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_addColumnToIndex (source_array, array_index, index_choice, col_index) {
|
||||
if (col_index >= 0) {
|
||||
Indexes.addColumnToIndex = function (sourceArray, arrayIndex, indexChoice, colIndex) {
|
||||
if (colIndex >= 0) {
|
||||
// Remove column from other indexes (if any).
|
||||
PMA_removeColumnFromIndex(col_index);
|
||||
Indexes.removeColumnFromIndex(colIndex);
|
||||
}
|
||||
var index_name = $('input[name="index[Key_name]"]').val();
|
||||
var index_comment = $('input[name="index[Index_comment]"]').val();
|
||||
var key_block_size = $('input[name="index[Key_block_size]"]').val();
|
||||
var indexName = $('input[name="index[Key_name]"]').val();
|
||||
var indexComment = $('input[name="index[Index_comment]"]').val();
|
||||
var keyBlockSize = $('input[name="index[Key_block_size]"]').val();
|
||||
var parser = $('input[name="index[Parser]"]').val();
|
||||
var index_type = $('select[name="index[Index_type]"]').val();
|
||||
var indexType = $('select[name="index[Index_type]"]').val();
|
||||
var columns = [];
|
||||
$('#index_columns').find('tbody').find('tr').each(function () {
|
||||
// Get columns in particular order.
|
||||
var col_index = $(this).find('select[name="index[columns][names][]"]').val();
|
||||
var colIndex = $(this).find('select[name="index[columns][names][]"]').val();
|
||||
var size = $(this).find('input[name="index[columns][sub_parts][]"]').val();
|
||||
columns.push({
|
||||
'col_index': col_index,
|
||||
'col_index': colIndex,
|
||||
'size': size
|
||||
});
|
||||
});
|
||||
|
||||
// Update or create an index.
|
||||
source_array[array_index] = {
|
||||
'Key_name': index_name,
|
||||
'Index_comment': index_comment,
|
||||
'Index_choice': index_choice.toUpperCase(),
|
||||
'Key_block_size': key_block_size,
|
||||
sourceArray[arrayIndex] = {
|
||||
'Key_name': indexName,
|
||||
'Index_comment': indexComment,
|
||||
'Index_choice': indexChoice.toUpperCase(),
|
||||
'Key_block_size': keyBlockSize,
|
||||
'Parser': parser,
|
||||
'Index_type': index_type,
|
||||
'Index_type': indexType,
|
||||
'columns': columns
|
||||
};
|
||||
|
||||
// Display index name (or column list)
|
||||
var displayName = index_name;
|
||||
var displayName = indexName;
|
||||
if (displayName === '') {
|
||||
var columnNames = [];
|
||||
$.each(columns, function () {
|
||||
@ -236,13 +240,13 @@ function PMA_addColumnToIndex (source_array, array_index, index_choice, col_inde
|
||||
$name.html($text);
|
||||
});
|
||||
|
||||
if (col_index >= 0) {
|
||||
if (colIndex >= 0) {
|
||||
// Update index details on form.
|
||||
$('select[name="field_key[' + col_index + ']"]')
|
||||
.attr('data-index', index_choice + ',' + array_index);
|
||||
$('select[name="field_key[' + colIndex + ']"]')
|
||||
.attr('data-index', indexChoice + ',' + arrayIndex);
|
||||
}
|
||||
PMA_setIndexFormParameters(source_array, index_choice.toLowerCase());
|
||||
}
|
||||
Indexes.setIndexFormParameters(sourceArray, indexChoice.toLowerCase());
|
||||
};
|
||||
|
||||
/**
|
||||
* Get choices list for a column to create a composite index with.
|
||||
@ -252,48 +256,48 @@ function PMA_addColumnToIndex (source_array, array_index, index_choice, col_inde
|
||||
*
|
||||
* @return jQuery Object
|
||||
*/
|
||||
function PMA_getCompositeIndexList (source_array, col_index) {
|
||||
Indexes.getCompositeIndexList = function (sourceArray, colIndex) {
|
||||
// Remove any previous list.
|
||||
if ($('#composite_index_list').length) {
|
||||
$('#composite_index_list').remove();
|
||||
}
|
||||
|
||||
// Html list.
|
||||
var $composite_index_list = $(
|
||||
var $compositeIndexList = $(
|
||||
'<ul id="composite_index_list">' +
|
||||
'<div>' + PMA_messages.strCompositeWith + '</div>' +
|
||||
'<div>' + Messages.strCompositeWith + '</div>' +
|
||||
'</ul>'
|
||||
);
|
||||
|
||||
// Add each column to list available for composite index.
|
||||
var source_length = source_array.length;
|
||||
var already_present = false;
|
||||
for (var i = 0; i < source_length; i++) {
|
||||
var sub_array_len = source_array[i].columns.length;
|
||||
var column_names = [];
|
||||
for (var j = 0; j < sub_array_len; j++) {
|
||||
column_names.push(
|
||||
$('input[name="field_name[' + source_array[i].columns[j].col_index + ']"]').val()
|
||||
var sourceLength = sourceArray.length;
|
||||
var alreadyPresent = false;
|
||||
for (var i = 0; i < sourceLength; i++) {
|
||||
var subArrayLen = sourceArray[i].columns.length;
|
||||
var columnNames = [];
|
||||
for (var j = 0; j < subArrayLen; j++) {
|
||||
columnNames.push(
|
||||
$('input[name="field_name[' + sourceArray[i].columns[j].col_index + ']"]').val()
|
||||
);
|
||||
|
||||
if (col_index === source_array[i].columns[j].col_index) {
|
||||
already_present = true;
|
||||
if (colIndex === sourceArray[i].columns[j].col_index) {
|
||||
alreadyPresent = true;
|
||||
}
|
||||
}
|
||||
|
||||
$composite_index_list.append(
|
||||
$compositeIndexList.append(
|
||||
'<li>' +
|
||||
'<input type="radio" name="composite_with" ' +
|
||||
(already_present ? 'checked="checked"' : '') +
|
||||
(alreadyPresent ? 'checked="checked"' : '') +
|
||||
' id="composite_index_' + i + '" value="' + i + '">' +
|
||||
'<label for="composite_index_' + i + '">' + column_names.join(', ') +
|
||||
'<label for="composite_index_' + i + '">' + columnNames.join(', ') +
|
||||
'</lablel>' +
|
||||
'</li>'
|
||||
);
|
||||
}
|
||||
|
||||
return $composite_index_list;
|
||||
}
|
||||
return $compositeIndexList;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows 'Add Index' dialog.
|
||||
@ -303,50 +307,52 @@ function PMA_getCompositeIndexList (source_array, col_index) {
|
||||
* @param array target_columns Columns for an INDEX
|
||||
* @param string col_index Index of column on form
|
||||
* @param object index Index detail object
|
||||
* @param bool showDialog Whether to show index creation dialog or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_showAddIndexDialog (source_array, array_index, target_columns, col_index, index) {
|
||||
Indexes.showAddIndexDialog = function (sourceArray, arrayIndex, targetColumns, colIndex, index, showDialog) {
|
||||
var showDialogLocal = typeof showDialog !== 'undefined' ? showDialog : true;
|
||||
// Prepare post-data.
|
||||
var $table = $('input[name="table"]');
|
||||
var table = $table.length > 0 ? $table.val() : '';
|
||||
var post_data = {
|
||||
server: PMA_commonParams.get('server'),
|
||||
db: $('input[name="db"]').val(),
|
||||
table: table,
|
||||
ajax_request: 1,
|
||||
create_edit_table: 1,
|
||||
index: index
|
||||
var postData = {
|
||||
'server': CommonParams.get('server'),
|
||||
'db': $('input[name="db"]').val(),
|
||||
'table': table,
|
||||
'ajax_request': 1,
|
||||
'create_edit_table': 1,
|
||||
'index': index
|
||||
};
|
||||
|
||||
var columns = {};
|
||||
for (var i = 0; i < target_columns.length; i++) {
|
||||
var column_name = $('input[name="field_name[' + target_columns[i] + ']"]').val();
|
||||
var column_type = $('select[name="field_type[' + target_columns[i] + ']"]').val().toLowerCase();
|
||||
columns[column_name] = [column_type, target_columns[i]];
|
||||
for (var i = 0; i < targetColumns.length; i++) {
|
||||
var columnName = $('input[name="field_name[' + targetColumns[i] + ']"]').val();
|
||||
var columnType = $('select[name="field_type[' + targetColumns[i] + ']"]').val().toLowerCase();
|
||||
columns[columnName] = [columnType, targetColumns[i]];
|
||||
}
|
||||
post_data.columns = JSON.stringify(columns);
|
||||
postData.columns = JSON.stringify(columns);
|
||||
|
||||
var button_options = {};
|
||||
button_options[PMA_messages.strGo] = function () {
|
||||
var is_missing_value = false;
|
||||
var buttonOptions = {};
|
||||
buttonOptions[Messages.strGo] = function () {
|
||||
var isMissingValue = false;
|
||||
$('select[name="index[columns][names][]"]').each(function () {
|
||||
if ($(this).val() === '') {
|
||||
is_missing_value = true;
|
||||
isMissingValue = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (! is_missing_value) {
|
||||
PMA_addColumnToIndex(
|
||||
source_array,
|
||||
array_index,
|
||||
if (! isMissingValue) {
|
||||
Indexes.addColumnToIndex(
|
||||
sourceArray,
|
||||
arrayIndex,
|
||||
index.Index_choice,
|
||||
col_index
|
||||
colIndex
|
||||
);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(
|
||||
Functions.ajaxShowMessage(
|
||||
'<div class="error"><img src="themes/dot.gif" title="" alt=""' +
|
||||
' class="icon ic_s_error" /> ' + PMA_messages.strMissingColumn +
|
||||
' class="icon ic_s_error"> ' + Messages.strMissingColumn +
|
||||
' </div>', false
|
||||
);
|
||||
|
||||
@ -355,59 +361,93 @@ function PMA_showAddIndexDialog (source_array, array_index, target_columns, col_
|
||||
|
||||
$(this).dialog('close');
|
||||
};
|
||||
button_options[PMA_messages.strCancel] = function () {
|
||||
if (col_index >= 0) {
|
||||
buttonOptions[Messages.strCancel] = function () {
|
||||
if (colIndex >= 0) {
|
||||
// Handle state on 'Cancel'.
|
||||
var $select_list = $('select[name="field_key[' + col_index + ']"]');
|
||||
if (! $select_list.attr('data-index').length) {
|
||||
$select_list.find('option[value*="none"]').attr('selected', 'selected');
|
||||
var $selectList = $('select[name="field_key[' + colIndex + ']"]');
|
||||
if (! $selectList.attr('data-index').length) {
|
||||
$selectList.find('option[value*="none"]').attr('selected', 'selected');
|
||||
} else {
|
||||
var previous_index = $select_list.attr('data-index').split(',');
|
||||
$select_list.find('option[value*="' + previous_index[0].toLowerCase() + '"]')
|
||||
var previousIndex = $selectList.attr('data-index').split(',');
|
||||
$selectList.find('option[value*="' + previousIndex[0].toLowerCase() + '"]')
|
||||
.attr('selected', 'selected');
|
||||
}
|
||||
}
|
||||
$(this).dialog('close');
|
||||
};
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
$.post('tbl_indexes.php', post_data, function (data) {
|
||||
var $msgbox = Functions.ajaxShowMessage();
|
||||
$.post('tbl_indexes.php', postData, function (data) {
|
||||
if (data.success === false) {
|
||||
// in the case of an error, show the error message returned.
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
// Show dialog if the request was successful
|
||||
var $div = $('<div/>');
|
||||
$div
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: PMA_messages.strAddIndex,
|
||||
width: 450,
|
||||
minHeight: 250,
|
||||
open: function () {
|
||||
checkIndexName('index_frm');
|
||||
PMA_showHints($div);
|
||||
PMA_init_slider();
|
||||
$('#index_columns').find('td').each(function () {
|
||||
$(this).css('width', $(this).width() + 'px');
|
||||
});
|
||||
$('#index_columns').find('tbody').sortable({
|
||||
axis: 'y',
|
||||
containment: $('#index_columns').find('tbody'),
|
||||
tolerance: 'pointer'
|
||||
});
|
||||
// We dont need the slider at this moment.
|
||||
$(this).find('fieldset.tblFooters').remove();
|
||||
},
|
||||
modal: true,
|
||||
buttons: button_options,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
Functions.ajaxRemoveMessage($msgbox);
|
||||
var $div = $('<div></div>');
|
||||
if (showDialogLocal) {
|
||||
// Show dialog if the request was successful
|
||||
if ($('#addIndex').length > 0) {
|
||||
$('#addIndex').remove();
|
||||
}
|
||||
$div
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
title: Messages.strAddIndex,
|
||||
width: 450,
|
||||
minHeight: 250,
|
||||
open: function () {
|
||||
Functions.checkIndexName('index_frm');
|
||||
Functions.showHints($div);
|
||||
Functions.initSlider();
|
||||
$('#index_columns').find('td').each(function () {
|
||||
$(this).css('width', $(this).width() + 'px');
|
||||
});
|
||||
$('#index_columns').find('tbody').sortable({
|
||||
axis: 'y',
|
||||
containment: $('#index_columns').find('tbody'),
|
||||
tolerance: 'pointer'
|
||||
});
|
||||
// We dont need the slider at this moment.
|
||||
$(this).find('fieldset.tblFooters').remove();
|
||||
},
|
||||
modal: true,
|
||||
buttons: buttonOptions,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$div
|
||||
.append(data.message);
|
||||
$div.css({ 'display' : 'none' });
|
||||
$div.appendTo($('body'));
|
||||
$div.attr({ 'id' : 'addIndex' });
|
||||
var isMissingValue = false;
|
||||
$('select[name="index[columns][names][]"]').each(function () {
|
||||
if ($(this).val() === '') {
|
||||
isMissingValue = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (! isMissingValue) {
|
||||
Indexes.addColumnToIndex(
|
||||
sourceArray,
|
||||
arrayIndex,
|
||||
index.Index_choice,
|
||||
colIndex
|
||||
);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(
|
||||
'<div class="error"><img src="themes/dot.gif" title="" alt=""' +
|
||||
' class="icon ic_s_error"> ' + Messages.strMissingColumn +
|
||||
' </div>', false
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a advanced index type selection dialog.
|
||||
@ -418,82 +458,82 @@ function PMA_showAddIndexDialog (source_array, array_index, target_columns, col_
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_indexTypeSelectionDialog (source_array, index_choice, col_index) {
|
||||
var $single_column_radio = $('<input type="radio" id="single_column" name="index_choice"' +
|
||||
Indexes.indexTypeSelectionDialog = function (sourceArray, indexChoice, colIndex) {
|
||||
var $singleColumnRadio = $('<input type="radio" id="single_column" name="index_choice"' +
|
||||
' checked="checked">' +
|
||||
'<label for="single_column">' + PMA_messages.strCreateSingleColumnIndex + '</label>');
|
||||
var $composite_index_radio = $('<input type="radio" id="composite_index"' +
|
||||
'<label for="single_column">' + Messages.strCreateSingleColumnIndex + '</label>');
|
||||
var $compositeIndexRadio = $('<input type="radio" id="composite_index"' +
|
||||
' name="index_choice">' +
|
||||
'<label for="composite_index">' + PMA_messages.strCreateCompositeIndex + '</label>');
|
||||
var $dialog_content = $('<fieldset id="advance_index_creator"></fieldset>');
|
||||
$dialog_content.append('<legend>' + index_choice.toUpperCase() + '</legend>');
|
||||
'<label for="composite_index">' + Messages.strCreateCompositeIndex + '</label>');
|
||||
var $dialogContent = $('<fieldset id="advance_index_creator"></fieldset>');
|
||||
$dialogContent.append('<legend>' + indexChoice.toUpperCase() + '</legend>');
|
||||
|
||||
|
||||
// For UNIQUE/INDEX type, show choice for single-column and composite index.
|
||||
$dialog_content.append($single_column_radio);
|
||||
$dialog_content.append($composite_index_radio);
|
||||
$dialogContent.append($singleColumnRadio);
|
||||
$dialogContent.append($compositeIndexRadio);
|
||||
|
||||
var button_options = {};
|
||||
var buttonOptions = {};
|
||||
// 'OK' operation.
|
||||
button_options[PMA_messages.strGo] = function () {
|
||||
buttonOptions[Messages.strGo] = function () {
|
||||
if ($('#single_column').is(':checked')) {
|
||||
var index = {
|
||||
'Key_name': (index_choice === 'primary' ? 'PRIMARY' : ''),
|
||||
'Index_choice': index_choice.toUpperCase()
|
||||
'Key_name': (indexChoice === 'primary' ? 'PRIMARY' : ''),
|
||||
'Index_choice': indexChoice.toUpperCase()
|
||||
};
|
||||
PMA_showAddIndexDialog(source_array, (source_array.length), [col_index], col_index, index);
|
||||
Indexes.showAddIndexDialog(sourceArray, (sourceArray.length), [colIndex], colIndex, index);
|
||||
}
|
||||
|
||||
if ($('#composite_index').is(':checked')) {
|
||||
if ($('input[name="composite_with"]').length !== 0 && $('input[name="composite_with"]:checked').length === 0
|
||||
) {
|
||||
PMA_ajaxShowMessage(
|
||||
Functions.ajaxShowMessage(
|
||||
'<div class="error"><img src="themes/dot.gif" title=""' +
|
||||
' alt="" class="icon ic_s_error" /> ' +
|
||||
PMA_messages.strFormEmpty +
|
||||
' alt="" class="icon ic_s_error"> ' +
|
||||
Messages.strFormEmpty +
|
||||
' </div>',
|
||||
false
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
var array_index = $('input[name="composite_with"]:checked').val();
|
||||
var source_length = source_array[array_index].columns.length;
|
||||
var target_columns = [];
|
||||
for (var i = 0; i < source_length; i++) {
|
||||
target_columns.push(source_array[array_index].columns[i].col_index);
|
||||
var arrayIndex = $('input[name="composite_with"]:checked').val();
|
||||
var sourceLength = sourceArray[arrayIndex].columns.length;
|
||||
var targetColumns = [];
|
||||
for (var i = 0; i < sourceLength; i++) {
|
||||
targetColumns.push(sourceArray[arrayIndex].columns[i].col_index);
|
||||
}
|
||||
target_columns.push(col_index);
|
||||
targetColumns.push(colIndex);
|
||||
|
||||
PMA_showAddIndexDialog(source_array, array_index, target_columns, col_index,
|
||||
source_array[array_index]);
|
||||
Indexes.showAddIndexDialog(sourceArray, arrayIndex, targetColumns, colIndex,
|
||||
sourceArray[arrayIndex]);
|
||||
}
|
||||
|
||||
$(this).remove();
|
||||
};
|
||||
button_options[PMA_messages.strCancel] = function () {
|
||||
buttonOptions[Messages.strCancel] = function () {
|
||||
// Handle state on 'Cancel'.
|
||||
var $select_list = $('select[name="field_key[' + col_index + ']"]');
|
||||
if (! $select_list.attr('data-index').length) {
|
||||
$select_list.find('option[value*="none"]').attr('selected', 'selected');
|
||||
var $selectList = $('select[name="field_key[' + colIndex + ']"]');
|
||||
if (! $selectList.attr('data-index').length) {
|
||||
$selectList.find('option[value*="none"]').attr('selected', 'selected');
|
||||
} else {
|
||||
var previous_index = $select_list.attr('data-index').split(',');
|
||||
$select_list.find('option[value*="' + previous_index[0].toLowerCase() + '"]')
|
||||
var previousIndex = $selectList.attr('data-index').split(',');
|
||||
$selectList.find('option[value*="' + previousIndex[0].toLowerCase() + '"]')
|
||||
.attr('selected', 'selected');
|
||||
}
|
||||
$(this).remove();
|
||||
};
|
||||
var $dialog = $('<div/>').append($dialog_content).dialog({
|
||||
$('<div></div>').append($dialogContent).dialog({
|
||||
minWidth: 525,
|
||||
minHeight: 200,
|
||||
modal: true,
|
||||
title: PMA_messages.strAddIndex,
|
||||
title: Messages.strAddIndex,
|
||||
resizable: false,
|
||||
buttons: button_options,
|
||||
buttons: buttonOptions,
|
||||
open: function () {
|
||||
$('#composite_index').on('change', function () {
|
||||
if ($(this).is(':checked')) {
|
||||
$dialog_content.append(PMA_getCompositeIndexList(source_array, col_index));
|
||||
$dialogContent.append(Indexes.getCompositeIndexList(sourceArray, colIndex));
|
||||
}
|
||||
});
|
||||
$('#single_column').on('change', function () {
|
||||
@ -510,7 +550,7 @@ function PMA_indexTypeSelectionDialog (source_array, index_choice, col_index) {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
@ -537,42 +577,42 @@ AJAX.registerTeardown('indexes.js', function () {
|
||||
*/
|
||||
AJAX.registerOnload('indexes.js', function () {
|
||||
// Re-initialize variables.
|
||||
primary_indexes = [];
|
||||
unique_indexes = [];
|
||||
primaryIndexes = [];
|
||||
uniqueIndexes = [];
|
||||
indexes = [];
|
||||
fulltext_indexes = [];
|
||||
spatial_indexes = [];
|
||||
fulltextIndexes = [];
|
||||
spatialIndexes = [];
|
||||
|
||||
// for table creation form
|
||||
var $engine_selector = $('.create_table_form select[name=tbl_storage_engine]');
|
||||
if ($engine_selector.length) {
|
||||
PMA_hideShowConnection($engine_selector);
|
||||
var $engineSelector = $('.create_table_form select[name=tbl_storage_engine]');
|
||||
if ($engineSelector.length) {
|
||||
Functions.hideShowConnection($engineSelector);
|
||||
}
|
||||
|
||||
var $form = $('#index_frm');
|
||||
if ($form.length > 0) {
|
||||
showIndexEditDialog($form);
|
||||
Functions.showIndexEditDialog($form);
|
||||
}
|
||||
|
||||
$(document).on('click', '#save_index_frm', function (event) {
|
||||
event.preventDefault();
|
||||
var $form = $('#index_frm');
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var submitData = $form.serialize() + argsep + 'do_save_data=1' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
AJAX.source = $form;
|
||||
$.post($form.attr('action'), submitData, AJAX.responseHandler);
|
||||
});
|
||||
|
||||
$(document).on('click', '#preview_index_frm', function (event) {
|
||||
event.preventDefault();
|
||||
PMA_previewSQL($('#index_frm'));
|
||||
Functions.previewSql($('#index_frm'));
|
||||
});
|
||||
|
||||
$(document).on('change', '#select_index_choice', function (event) {
|
||||
event.preventDefault();
|
||||
checkIndexType();
|
||||
checkIndexName('index_frm');
|
||||
Indexes.checkIndexType();
|
||||
Functions.checkIndexName('index_frm');
|
||||
});
|
||||
|
||||
/**
|
||||
@ -582,40 +622,40 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
event.preventDefault();
|
||||
var $anchor = $(this);
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current field's row
|
||||
* @var $currRow Object containing reference to the current field's row
|
||||
*/
|
||||
var $curr_row = $anchor.parents('tr');
|
||||
var $currRow = $anchor.parents('tr');
|
||||
/** @var Number of columns in the key */
|
||||
var rows = $anchor.parents('td').attr('rowspan') || 1;
|
||||
/** @var Rows that should be hidden */
|
||||
var $rows_to_hide = $curr_row;
|
||||
for (var i = 1, $last_row = $curr_row.next(); i < rows; i++, $last_row = $last_row.next()) {
|
||||
$rows_to_hide = $rows_to_hide.add($last_row);
|
||||
var $rowsToHide = $currRow;
|
||||
for (var i = 1, $lastRow = $currRow.next(); i < rows; i++, $lastRow = $lastRow.next()) {
|
||||
$rowsToHide = $rowsToHide.add($lastRow);
|
||||
}
|
||||
|
||||
var question = escapeHtml(
|
||||
$curr_row.children('td')
|
||||
var question = Functions.escapeHtml(
|
||||
$currRow.children('td')
|
||||
.children('.drop_primary_key_index_msg')
|
||||
.val()
|
||||
);
|
||||
|
||||
PMA_confirmPreviewSQL(question, $anchor.attr('href'), function (url) {
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strDroppingPrimaryKeyIndex, false);
|
||||
var params = getJSConfirmCommonParam(this, $anchor.getPostData());
|
||||
Functions.confirmPreviewSql(question, $anchor.attr('href'), function (url) {
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strDroppingPrimaryKeyIndex, false);
|
||||
var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
var $table_ref = $rows_to_hide.closest('table');
|
||||
if ($rows_to_hide.length === $table_ref.find('tbody > tr').length) {
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
var $tableRef = $rowsToHide.closest('table');
|
||||
if ($rowsToHide.length === $tableRef.find('tbody > tr').length) {
|
||||
// We are about to remove all rows from the table
|
||||
$table_ref.hide('medium', function () {
|
||||
$tableRef.hide('medium', function () {
|
||||
$('div.no_indexes_defined').show('medium');
|
||||
$rows_to_hide.remove();
|
||||
$rowsToHide.remove();
|
||||
});
|
||||
$table_ref.siblings('div.notice').hide('medium');
|
||||
$tableRef.siblings('div.notice').hide('medium');
|
||||
} else {
|
||||
// We are removing some of the rows only
|
||||
$rows_to_hide.hide('medium', function () {
|
||||
$rowsToHide.hide('medium', function () {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
@ -626,17 +666,17 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
$('<div class="result_query"></div>')
|
||||
.html(data.sql_query)
|
||||
.prependTo('#structure_content');
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
Functions.highlightSql($('#page_content'));
|
||||
}
|
||||
PMA_commonActions.refreshMain(false, function () {
|
||||
$('a.ajax[href^=#indexes]').click();
|
||||
CommonActions.refreshMain(false, function () {
|
||||
$('a.ajax[href^=#indexes]').trigger('click');
|
||||
});
|
||||
PMA_reloadNavigation();
|
||||
Navigation.reload();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
Functions.ajaxShowMessage(Messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end $.PMA_confirm()
|
||||
});
|
||||
}); // end Drop Primary Key/Index
|
||||
|
||||
/**
|
||||
@ -648,7 +688,7 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
var title;
|
||||
if ($(this).find('a').length === 0) {
|
||||
// Add index
|
||||
var valid = checkFormElementInRange(
|
||||
var valid = Functions.checkFormElementInRange(
|
||||
$(this).closest('form')[0],
|
||||
'added_fields',
|
||||
'Column count has to be larger than zero.'
|
||||
@ -657,17 +697,17 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
return;
|
||||
}
|
||||
url = $(this).closest('form').serialize();
|
||||
title = PMA_messages.strAddIndex;
|
||||
title = Messages.strAddIndex;
|
||||
} else {
|
||||
// Edit index
|
||||
url = $(this).find('a').getPostData();
|
||||
title = PMA_messages.strEditIndex;
|
||||
title = Messages.strEditIndex;
|
||||
}
|
||||
url += PMA_commonParams.get('arg_separator') + 'ajax_request=true';
|
||||
indexEditorDialog(url, title, function () {
|
||||
url += CommonParams.get('arg_separator') + 'ajax_request=true';
|
||||
Functions.indexEditorDialog(url, title, function () {
|
||||
// refresh the page using ajax
|
||||
PMA_commonActions.refreshMain(false, function () {
|
||||
$('a.ajax[href^=#indexes]').click();
|
||||
CommonActions.refreshMain(false, function () {
|
||||
$('a.ajax[href^=#indexes]').trigger('click');
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -676,18 +716,19 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
* Ajax event handler for advanced index creation during table creation
|
||||
* and column addition.
|
||||
*/
|
||||
$('body').on('change', 'select[name*="field_key"]', function () {
|
||||
$('body').on('change', 'select[name*="field_key"]', function (e, showDialog) {
|
||||
var showDialogLocal = typeof showDialog !== 'undefined' ? showDialog : true;
|
||||
// Index of column on Table edit and create page.
|
||||
var col_index = /\d+/.exec($(this).attr('name'));
|
||||
col_index = col_index[0];
|
||||
var colIndex = /\d+/.exec($(this).attr('name'));
|
||||
colIndex = colIndex[0];
|
||||
// Choice of selected index.
|
||||
var index_choice = /[a-z]+/.exec($(this).val());
|
||||
index_choice = index_choice[0];
|
||||
var indexChoice = /[a-z]+/.exec($(this).val());
|
||||
indexChoice = indexChoice[0];
|
||||
// Array containing corresponding indexes.
|
||||
var source_array = null;
|
||||
var sourceArray = null;
|
||||
|
||||
if (index_choice === 'none') {
|
||||
PMA_removeColumnFromIndex(col_index);
|
||||
if (indexChoice === 'none') {
|
||||
Indexes.removeColumnFromIndex(colIndex);
|
||||
var id = 'index_name_' + '0' + '_8';
|
||||
var $name = $('#' + id);
|
||||
if ($name.length === 0) {
|
||||
@ -699,32 +740,31 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
}
|
||||
|
||||
// Select a source array.
|
||||
source_array = PMA_getIndexArray(index_choice);
|
||||
if (source_array === null) {
|
||||
sourceArray = Indexes.getIndexArray(indexChoice);
|
||||
if (sourceArray === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (source_array.length === 0) {
|
||||
if (sourceArray.length === 0) {
|
||||
var index = {
|
||||
'Key_name': (index_choice === 'primary' ? 'PRIMARY' : ''),
|
||||
'Index_choice': index_choice.toUpperCase()
|
||||
'Key_name': (indexChoice === 'primary' ? 'PRIMARY' : ''),
|
||||
'Index_choice': indexChoice.toUpperCase()
|
||||
};
|
||||
PMA_showAddIndexDialog(source_array, 0, [col_index], col_index, index);
|
||||
Indexes.showAddIndexDialog(sourceArray, 0, [colIndex], colIndex, index, showDialogLocal);
|
||||
} else {
|
||||
if (index_choice === 'primary') {
|
||||
var array_index = 0;
|
||||
var source_length = source_array[array_index].columns.length;
|
||||
var target_columns = [];
|
||||
for (var i = 0; i < source_length; i++) {
|
||||
target_columns.push(source_array[array_index].columns[i].col_index);
|
||||
if (indexChoice === 'primary') {
|
||||
var arrayIndex = 0;
|
||||
var sourceLength = sourceArray[arrayIndex].columns.length;
|
||||
var targetColumns = [];
|
||||
for (var i = 0; i < sourceLength; i++) {
|
||||
targetColumns.push(sourceArray[arrayIndex].columns[i].col_index);
|
||||
}
|
||||
target_columns.push(col_index);
|
||||
|
||||
PMA_showAddIndexDialog(source_array, array_index, target_columns, col_index,
|
||||
source_array[array_index]);
|
||||
targetColumns.push(colIndex);
|
||||
Indexes.showAddIndexDialog(sourceArray, arrayIndex, targetColumns, colIndex,
|
||||
sourceArray[arrayIndex], showDialogLocal);
|
||||
} else {
|
||||
// If there are multiple columns selected for an index, show advanced dialog.
|
||||
PMA_indexTypeSelectionDialog(source_array, index_choice, col_index);
|
||||
Indexes.indexTypeSelectionDialog(sourceArray, indexChoice, colIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -733,23 +773,23 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
e.preventDefault();
|
||||
|
||||
// Get index details.
|
||||
var previous_index = $(this).prev('select')
|
||||
var previousIndex = $(this).prev('select')
|
||||
.attr('data-index')
|
||||
.split(',');
|
||||
|
||||
var index_choice = previous_index[0];
|
||||
var array_index = previous_index[1];
|
||||
var indexChoice = previousIndex[0];
|
||||
var arrayIndex = previousIndex[1];
|
||||
|
||||
var source_array = PMA_getIndexArray(index_choice);
|
||||
if (source_array !== null) {
|
||||
var source_length = source_array[array_index].columns.length;
|
||||
var sourceArray = Indexes.getIndexArray(indexChoice);
|
||||
if (sourceArray !== null) {
|
||||
var sourceLength = sourceArray[arrayIndex].columns.length;
|
||||
|
||||
var target_columns = [];
|
||||
for (var i = 0; i < source_length; i++) {
|
||||
target_columns.push(source_array[array_index].columns[i].col_index);
|
||||
var targetColumns = [];
|
||||
for (var i = 0; i < sourceLength; i++) {
|
||||
targetColumns.push(sourceArray[arrayIndex].columns[i].col_index);
|
||||
}
|
||||
|
||||
PMA_showAddIndexDialog(source_array, array_index, target_columns, -1, source_array[array_index]);
|
||||
Indexes.showAddIndexDialog(sourceArray, arrayIndex, targetColumns, -1, sourceArray[arrayIndex]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -6,26 +6,28 @@
|
||||
*/
|
||||
(function ($) {
|
||||
'use strict';
|
||||
var formatByte = function (val, index) {
|
||||
var formatByte = function (value, index) {
|
||||
var val = value;
|
||||
var i = index;
|
||||
var units = [
|
||||
PMA_messages.strB,
|
||||
PMA_messages.strKiB,
|
||||
PMA_messages.strMiB,
|
||||
PMA_messages.strGiB,
|
||||
PMA_messages.strTiB,
|
||||
PMA_messages.strPiB,
|
||||
PMA_messages.strEiB
|
||||
Messages.strB,
|
||||
Messages.strKiB,
|
||||
Messages.strMiB,
|
||||
Messages.strGiB,
|
||||
Messages.strTiB,
|
||||
Messages.strPiB,
|
||||
Messages.strEiB
|
||||
];
|
||||
while (val >= 1024 && index <= 6) {
|
||||
while (val >= 1024 && i <= 6) {
|
||||
val /= 1024;
|
||||
index++;
|
||||
i++;
|
||||
}
|
||||
var format = '%.1f';
|
||||
if (Math.floor(val) === val) {
|
||||
format = '%.0f';
|
||||
}
|
||||
return $.jqplot.sprintf(
|
||||
format + ' ' + units[index], val
|
||||
format + ' ' + units[i], val
|
||||
);
|
||||
};
|
||||
/**
|
||||
@ -33,11 +35,12 @@
|
||||
* 0 for bytes, 1 for kilobytes and so on...
|
||||
*/
|
||||
$.jqplot.byteFormatter = function (index) {
|
||||
index = index || 0;
|
||||
return function (format, val) {
|
||||
var i = index || 0;
|
||||
return function (format, value) {
|
||||
var val = value;
|
||||
if (typeof val === 'number') {
|
||||
val = parseFloat(val) || 0;
|
||||
return formatByte(val, index);
|
||||
return formatByte(val, i);
|
||||
} else {
|
||||
return String(val);
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@ var ctrlKeyHistory = 0;
|
||||
*
|
||||
* @param object event data
|
||||
*/
|
||||
function onKeyDownArrowsHandler (e) {
|
||||
e = e || window.event;
|
||||
function onKeyDownArrowsHandler (event) {
|
||||
var e = event || window.event;
|
||||
|
||||
var o = (e.srcElement || e.target);
|
||||
if (!o) {
|
||||
@ -71,7 +71,7 @@ function onKeyDownArrowsHandler (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox/') > -1;
|
||||
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox/') > -1;
|
||||
|
||||
var id = 'field_' + y + '_' + x;
|
||||
|
||||
@ -92,12 +92,12 @@ function onKeyDownArrowsHandler (e) {
|
||||
|
||||
nO.focus();
|
||||
|
||||
if (is_firefox) {
|
||||
if (isFirefox) {
|
||||
var ffcheck = 0;
|
||||
var ffversion;
|
||||
for (ffversion = 3 ; ffversion < 25 ; ffversion++) {
|
||||
var is_firefox_v_24 = navigator.userAgent.toLowerCase().indexOf('firefox/' + ffversion) > -1;
|
||||
if (is_firefox_v_24) {
|
||||
var isFirefoxV24 = navigator.userAgent.toLowerCase().indexOf('firefox/' + ffversion) > -1;
|
||||
if (isFirefoxV24) {
|
||||
ffcheck = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
852
js/makegrid.js
852
js/makegrid.js
File diff suppressed because it is too large
Load Diff
@ -30,8 +30,8 @@
|
||||
$('#pma_navigation_resizer').css({ 'width': '0px' });
|
||||
}
|
||||
// Sets the image for the left and right scroll indicator
|
||||
$('.scrollindicator--left').html($(PMA_getImage('b_left').toString()));
|
||||
$('.scrollindicator--right').html($(PMA_getImage('b_right').toString()));
|
||||
$('.scrollindicator--left').html($(Functions.getImage('b_left').toString()));
|
||||
$('.scrollindicator--right').html($(Functions.getImage('b_right').toString()));
|
||||
|
||||
// Set the width of the navigation bar without scroll indicator
|
||||
$('.navigationbar').css({ 'width': widthCalculator.call($container) - 60 });
|
||||
@ -45,16 +45,16 @@
|
||||
});
|
||||
|
||||
// create submenu container
|
||||
var link = $('<a />', { href: '#', 'class': 'tab nowrap' })
|
||||
.text(PMA_messages.strMore)
|
||||
var link = $('<a></a>', { href: '#', 'class': 'tab nowrap' })
|
||||
.text(Messages.strMore)
|
||||
.on('click', false); // same as event.preventDefault()
|
||||
var img = $container.find('li img');
|
||||
if (img.length) {
|
||||
$(PMA_getImage('b_more').toString()).prependTo(link);
|
||||
$(Functions.getImage('b_more').toString()).prependTo(link);
|
||||
}
|
||||
var $submenu = $('<li />', { 'class': 'submenu' })
|
||||
var $submenu = $('<li></li>', { 'class': 'submenu' })
|
||||
.append(link)
|
||||
.append($('<ul />'))
|
||||
.append($('<ul></ul>'))
|
||||
.on('mouseenter', function () {
|
||||
if ($(this).find('ul .tabactive').length === 0) {
|
||||
$(this)
|
||||
@ -81,54 +81,53 @@
|
||||
var wmax = this.widthCalculator.call(this.$container);
|
||||
var windowWidth = $(window).width();
|
||||
var $submenu = this.$container.find('.submenu:last');
|
||||
var submenu_w = $submenu.outerWidth(true);
|
||||
var $submenu_ul = $submenu.find('ul');
|
||||
var submenuW = $submenu.outerWidth(true);
|
||||
var $submenuUl = $submenu.find('ul');
|
||||
var $li = this.$container.find('> li');
|
||||
var $li2 = $submenu_ul.find('li');
|
||||
var more_shown = $li2.length > 0;
|
||||
var $li2 = $submenuUl.find('li');
|
||||
var moreShown = $li2.length > 0;
|
||||
// Calculate the total width used by all the shown tabs
|
||||
var total_len = more_shown ? submenu_w : 0;
|
||||
var totalLen = moreShown ? submenuW : 0;
|
||||
var l = $li.length - 1;
|
||||
var i;
|
||||
for (i = 0; i < l; i++) {
|
||||
total_len += $($li[i]).outerWidth(true);
|
||||
totalLen += $($li[i]).outerWidth(true);
|
||||
}
|
||||
|
||||
var hasVScroll = document.body.scrollHeight > document.body.clientHeight;
|
||||
if (hasVScroll) {
|
||||
windowWidth += 15;
|
||||
}
|
||||
var navigationwidth = wmax;
|
||||
if (windowWidth < 768) {
|
||||
wmax = 2000;
|
||||
}
|
||||
|
||||
// Now hide menu elements that don't fit into the menubar
|
||||
var hidden = false; // Whether we have hidden any tabs
|
||||
while (total_len >= wmax && --l >= 0) { // Process the tabs backwards
|
||||
while (totalLen >= wmax && --l >= 0) { // Process the tabs backwards
|
||||
hidden = true;
|
||||
var el = $($li[l]);
|
||||
var el_width = el.outerWidth(true);
|
||||
el.data('width', el_width);
|
||||
if (! more_shown) {
|
||||
total_len -= el_width;
|
||||
el.prependTo($submenu_ul);
|
||||
total_len += submenu_w;
|
||||
more_shown = true;
|
||||
var elWidth = el.outerWidth(true);
|
||||
el.data('width', elWidth);
|
||||
if (! moreShown) {
|
||||
totalLen -= elWidth;
|
||||
el.prependTo($submenuUl);
|
||||
totalLen += submenuW;
|
||||
moreShown = true;
|
||||
} else {
|
||||
total_len -= el_width;
|
||||
el.prependTo($submenu_ul);
|
||||
totalLen -= elWidth;
|
||||
el.prependTo($submenuUl);
|
||||
}
|
||||
}
|
||||
// If we didn't hide any tabs, then there might be some space to show some
|
||||
if (! hidden) {
|
||||
// Show menu elements that do fit into the menubar
|
||||
for (i = 0, l = $li2.length; i < l; i++) {
|
||||
total_len += $($li2[i]).data('width');
|
||||
totalLen += $($li2[i]).data('width');
|
||||
// item fits or (it is the last item
|
||||
// and it would fit if More got removed)
|
||||
if (total_len < wmax ||
|
||||
(i === $li2.length - 1 && total_len - submenu_w < wmax)
|
||||
if (totalLen < wmax ||
|
||||
(i === $li2.length - 1 && totalLen - submenuW < wmax)
|
||||
) {
|
||||
$($li2[i]).insertBefore($submenu);
|
||||
} else {
|
||||
@ -144,7 +143,7 @@
|
||||
} else {
|
||||
$('.navigationbar').css({ 'width': 'auto' });
|
||||
$('.navigationbar').css({ 'overflow': 'visible' });
|
||||
if ($submenu_ul.find('li').length > 0) {
|
||||
if ($submenuUl.find('li').length > 0) {
|
||||
$submenu.addClass('shown');
|
||||
} else {
|
||||
$submenu.removeClass('shown');
|
||||
@ -153,10 +152,10 @@
|
||||
if (this.$container.find('> li').length === 1) {
|
||||
// If there is only the "More" tab left, then we need
|
||||
// to align the submenu to the left edge of the tab
|
||||
$submenu_ul.removeClass().addClass('only');
|
||||
$submenuUl.removeClass().addClass('only');
|
||||
} else {
|
||||
// Otherwise we align the submenu to the right edge of the tab
|
||||
$submenu_ul.removeClass().addClass('notonly');
|
||||
$submenuUl.removeClass().addClass('notonly');
|
||||
}
|
||||
if ($submenu.find('.tabactive').length) {
|
||||
$submenu
|
||||
137
js/messages.php
137
js/messages.php
@ -5,8 +5,13 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('TESTSUITE')) {
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (! defined('TESTSUITE')) {
|
||||
chdir('..');
|
||||
|
||||
// Send correct type:
|
||||
@ -20,17 +25,16 @@ if (!defined('TESTSUITE')) {
|
||||
// non-js-compatible stuff like DOCTYPE
|
||||
define('PMA_MINIMUM_COMMON', true);
|
||||
define('PMA_PATH_TO_BASEDIR', '../');
|
||||
define('PMA_NO_SESSION' , true);
|
||||
require_once './libraries/common.inc.php';
|
||||
define('PMA_NO_SESSION', true);
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
}
|
||||
|
||||
// But this one is needed for Sanitize::escapeJsString()
|
||||
use PhpMyAdmin\Sanitize;
|
||||
|
||||
|
||||
$buffer = PhpMyAdmin\OutputBuffering::getInstance();
|
||||
$buffer->start();
|
||||
if (!defined('TESTSUITE')) {
|
||||
if (! defined('TESTSUITE')) {
|
||||
register_shutdown_function(
|
||||
function () {
|
||||
echo PhpMyAdmin\OutputBuffering::getInstance()->getContents();
|
||||
@ -93,7 +97,7 @@ $js_messages['strChangeColumnCollation'] = __(
|
||||
. 'collation and refer to the tips at '
|
||||
)
|
||||
. '<a href="%s" target="garbled_data_wiki">' . __('Garbled Data') . '</a>.'
|
||||
. '<br/><br/>'
|
||||
. '<br><br>'
|
||||
. __('Are you sure you wish to change the collation and convert the data?');
|
||||
$js_messages['strChangeAllColumnCollationsWarning'] = __(
|
||||
'Through this operation, MySQL attempts to map the data values between '
|
||||
@ -103,7 +107,7 @@ $js_messages['strChangeAllColumnCollationsWarning'] = __(
|
||||
. 'column(s) editing feature (the "Change" Link) on the table structure page. '
|
||||
. '</b>'
|
||||
)
|
||||
. '<br/><br/>'
|
||||
. '<br><br>'
|
||||
. __(
|
||||
'Are you sure you wish to change all the column collations and convert the data?'
|
||||
);
|
||||
@ -141,7 +145,7 @@ $js_messages['strYValues'] = __('Y values');
|
||||
/* Database multi-table query */
|
||||
$js_messages['strEmptyQuery'] = __('Please enter the SQL query first.');
|
||||
|
||||
/* For server_privileges.js */
|
||||
/* For server/privileges.js */
|
||||
$js_messages['strHostEmpty'] = __('The host name is empty!');
|
||||
$js_messages['strUserEmpty'] = __('The user name is empty!');
|
||||
$js_messages['strPasswordEmpty'] = __('The password is empty!');
|
||||
@ -331,6 +335,10 @@ $js_messages['strImport'] = __('Import');
|
||||
$js_messages['strImportDialogTitle'] = __('Import monitor configuration');
|
||||
$js_messages['strImportDialogMessage']
|
||||
= __('Please select the file you want to import.');
|
||||
$js_messages['strTableNameDialogMessage']
|
||||
= __('Please enter a valid table name.');
|
||||
$js_messages['strDBNameDialogMessage']
|
||||
= __('Please enter a valid database name.');
|
||||
$js_messages['strNoImportFile'] = __('No files available on server for import!');
|
||||
|
||||
$js_messages['strAnalyzeQuery'] = __('Analyse query');
|
||||
@ -377,7 +385,7 @@ $js_messages['strAddingPrimaryKey'] = __('Adding primary key');
|
||||
$js_messages['strOK'] = __('OK');
|
||||
$js_messages['strDismiss'] = __('Click to dismiss this notification');
|
||||
|
||||
/* For db_operations.js */
|
||||
/* For database/operations.js */
|
||||
$js_messages['strRenamingDatabases'] = __('Renaming databases');
|
||||
$js_messages['strCopyingDatabase'] = __('Copying database');
|
||||
$js_messages['strChangingCharset'] = __('Changing charset');
|
||||
@ -389,7 +397,7 @@ $js_messages['strForeignKeyCheck'] = __('Enable foreign key checks');
|
||||
/* For db_stucture.js */
|
||||
$js_messages['strErrorRealRowCount'] = __('Failed to get real row count.');
|
||||
|
||||
/* For db_search.js */
|
||||
/* For database/search.js */
|
||||
$js_messages['strSearching'] = __('Searching');
|
||||
$js_messages['strHideSearchResults'] = __('Hide search results');
|
||||
$js_messages['strShowSearchResults'] = __('Show search results');
|
||||
@ -406,10 +414,10 @@ $js_messages['NoExportable']
|
||||
|
||||
/* For ENUM/SET editor*/
|
||||
$js_messages['enum_editor'] = __('ENUM/SET editor');
|
||||
$js_messages['enum_columnVals'] =__('Values for column %s');
|
||||
$js_messages['enum_columnVals'] = __('Values for column %s');
|
||||
$js_messages['enum_newColumnVals'] = __('Values for a new column');
|
||||
$js_messages['enum_hint'] =__('Enter each value in a separate field.');
|
||||
$js_messages['enum_addValue'] =__('Add %d value(s)');
|
||||
$js_messages['enum_hint'] = __('Enter each value in a separate field.');
|
||||
$js_messages['enum_addValue'] = __('Add %d value(s)');
|
||||
|
||||
/* For import.js */
|
||||
$js_messages['strImportCSV'] = __(
|
||||
@ -423,7 +431,8 @@ $js_messages['strEdit'] = __('Edit');
|
||||
$js_messages['strDelete'] = __('Delete');
|
||||
$js_messages['strNotValidRowNumber'] = __('%d is not valid row number.');
|
||||
$js_messages['strBrowseForeignValues'] = __('Browse foreign values');
|
||||
$js_messages['strNoAutoSavedQuery'] = __('No auto-saved query');
|
||||
$js_messages['strNoAutoSavedQuery'] = __('No previously auto-saved query is available. Loading default query.');
|
||||
$js_messages['strPreviousSaveQuery'] = __('You have a previously saved query. Click Get auto-saved query to load the query.');
|
||||
$js_messages['strBookmarkVariable'] = __('Variable %d:');
|
||||
|
||||
/* For Central list of columns */
|
||||
@ -437,7 +446,7 @@ $js_messages['strEmptyCentralList'] = __(
|
||||
$js_messages['seeMore'] = __('See more');
|
||||
$js_messages['confirmTitle'] = __('Are you sure?');
|
||||
$js_messages['makeConsistentMessage'] = __(
|
||||
'This action may change some of the columns definition.<br/>Are you sure you '
|
||||
'This action may change some of the columns definition.<br>Are you sure you '
|
||||
. 'want to continue?'
|
||||
);
|
||||
$js_messages['strContinue'] = __('Continue');
|
||||
@ -478,10 +487,10 @@ $js_messages['strConfirmTd'] = __('Confirm transitive dependencies');
|
||||
$js_messages['strSelectedTd'] = __('Selected dependencies are as follows:');
|
||||
$js_messages['strNoTdSelected'] = __('No dependencies selected!');
|
||||
|
||||
/* For server_variables.js */
|
||||
/* For server/variables.js */
|
||||
$js_messages['strSave'] = __('Save');
|
||||
|
||||
/* For tbl_select.js */
|
||||
/* For table/select.js */
|
||||
$js_messages['strHideSearchCriteria'] = __('Hide search criteria');
|
||||
$js_messages['strShowSearchCriteria'] = __('Show search criteria');
|
||||
$js_messages['strRangeSearch'] = __('Range search');
|
||||
@ -490,11 +499,11 @@ $js_messages['strColumnMin'] = __('Column minimum:');
|
||||
$js_messages['strMinValue'] = __('Minimum value:');
|
||||
$js_messages['strMaxValue'] = __('Maximum value:');
|
||||
|
||||
/* For tbl_find_replace.js */
|
||||
/* For table/find_replace.js */
|
||||
$js_messages['strHideFindNReplaceCriteria'] = __('Hide find and replace criteria');
|
||||
$js_messages['strShowFindNReplaceCriteria'] = __('Show find and replace criteria');
|
||||
|
||||
/* For tbl_zoom_plot_jqplot.js */
|
||||
/* For table/zoom_plot_jqplot.js */
|
||||
$js_messages['strDisplayHelp'] = '<ul><li>'
|
||||
. __('Each point represents a data row.')
|
||||
. '</li><li>'
|
||||
@ -515,7 +524,7 @@ $js_messages['strSameInputs'] = '<strong>'
|
||||
. '</strong>';
|
||||
$js_messages['strDataPointContent'] = __('Data point content');
|
||||
|
||||
/* For tbl_change.js */
|
||||
/* For table/change.js */
|
||||
$js_messages['strIgnore'] = __('Ignore');
|
||||
$js_messages['strCopy'] = __('Copy');
|
||||
$js_messages['strX'] = __('X');
|
||||
@ -592,13 +601,13 @@ $js_messages['strColOrderHint'] = __('Drag to reorder.');
|
||||
$js_messages['strSortHint'] = __('Click to sort results by this column.');
|
||||
$js_messages['strMultiSortHint'] = __(
|
||||
'Shift+Click to add this column to ORDER BY clause or to toggle ASC/DESC.'
|
||||
. '<br />- Ctrl+Click or Alt+Click (Mac: Shift+Option+Click) to remove column '
|
||||
. '<br>- Ctrl+Click or Alt+Click (Mac: Shift+Option+Click) to remove column '
|
||||
. 'from ORDER BY clause'
|
||||
);
|
||||
$js_messages['strColMarkHint'] = __('Click to mark/unmark.');
|
||||
$js_messages['strColNameCopyHint'] = __('Double-click to copy column name.');
|
||||
$js_messages['strColVisibHint'] = __(
|
||||
'Click the drop-down arrow<br />to toggle column\'s visibility.'
|
||||
'Click the drop-down arrow<br>to toggle column\'s visibility.'
|
||||
);
|
||||
$js_messages['strShowAllCol'] = __('Show all');
|
||||
$js_messages['strAlertNonUnique'] = __(
|
||||
@ -628,18 +637,18 @@ $js_messages['back'] = __('Back');
|
||||
|
||||
// this approach does not work when the parameter is changed via user prefs
|
||||
switch ($GLOBALS['cfg']['GridEditing']) {
|
||||
case 'double-click':
|
||||
$js_messages['strGridEditFeatureHint'] = __(
|
||||
'You can also edit most values<br />by double-clicking directly on them.'
|
||||
);
|
||||
break;
|
||||
case 'click':
|
||||
$js_messages['strGridEditFeatureHint'] = __(
|
||||
'You can also edit most values<br />by clicking directly on them.'
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'double-click':
|
||||
$js_messages['strGridEditFeatureHint'] = __(
|
||||
'You can also edit most values<br>by double-clicking directly on them.'
|
||||
);
|
||||
break;
|
||||
case 'click':
|
||||
$js_messages['strGridEditFeatureHint'] = __(
|
||||
'You can also edit most values<br>by clicking directly on them.'
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$js_messages['strGoToLink'] = __('Go to link:');
|
||||
$js_messages['strColNameCopyTitle'] = __('Copy column name.');
|
||||
@ -697,29 +706,31 @@ $js_messages['strTooManyInputs'] = __(
|
||||
|
||||
$js_messages['phpErrorsFound'] = '<div class="error">'
|
||||
. __('Some errors have been detected on the server!')
|
||||
. '<br/>'
|
||||
. '<br>'
|
||||
. __('Please look at the bottom of this window.')
|
||||
. '<div>'
|
||||
. '<input id="pma_ignore_errors_popup" type="submit" value="'
|
||||
. __('Ignore')
|
||||
. '" class="floatright message_errors_found">'
|
||||
. '" class="btn btn-secondary floatright message_errors_found">'
|
||||
. '<input id="pma_ignore_all_errors_popup" type="submit" value="'
|
||||
. __('Ignore All')
|
||||
. '" class="floatright message_errors_found">'
|
||||
. '" class="btn btn-secondary floatright message_errors_found">'
|
||||
. '</div></div>';
|
||||
|
||||
$js_messages['phpErrorsBeingSubmitted'] = '<div class="error">'
|
||||
. __('Some errors have been detected on the server!')
|
||||
. '<br/>'
|
||||
. '<br>'
|
||||
. __(
|
||||
'As per your settings, they are being submitted currently, please be '
|
||||
. 'patient.'
|
||||
)
|
||||
. '<br/>'
|
||||
. '<br>'
|
||||
. '<img src="'
|
||||
. ($GLOBALS['PMA_Theme']->getImgPath('ajax_clock_small.gif'))
|
||||
. '" width="16" height="16" alt="ajax clock"/>'
|
||||
. $GLOBALS['PMA_Theme']->getImgPath('ajax_clock_small.gif')
|
||||
. '" width="16" height="16" alt="ajax clock">'
|
||||
. '</div>';
|
||||
$js_messages['strCopyQueryButtonSuccess'] = __('Successfully copied!');
|
||||
$js_messages['strCopyQueryButtonFailure'] = __('Copying failed!');
|
||||
|
||||
// For console
|
||||
$js_messages['strConsoleRequeryConfirm'] = __('Execute this query again?');
|
||||
@ -756,25 +767,21 @@ $js_messages['strTableAlreadyExists'] = _pgettext('The table already exists in t
|
||||
$js_messages['strHide'] = __('Hide');
|
||||
$js_messages['strStructure'] = __('Structure');
|
||||
|
||||
echo "var PMA_messages = new Array();\n";
|
||||
echo "var Messages = [];\n";
|
||||
foreach ($js_messages as $name => $js_message) {
|
||||
Sanitize::printJsValue("PMA_messages['" . $name . "']", $js_message);
|
||||
Sanitize::printJsValue("Messages." . $name . "", $js_message);
|
||||
}
|
||||
|
||||
/* Calendar */
|
||||
echo "var themeCalendarImage = '" , $GLOBALS['pmaThemeImage']
|
||||
, 'b_calendar.png' , "';\n";
|
||||
|
||||
/* Image path */
|
||||
echo "var pmaThemeImage = '" , $GLOBALS['pmaThemeImage'] , "';\n";
|
||||
|
||||
echo "var mysql_doc_template = '" , PhpMyAdmin\Util::getMySQLDocuURL('%s')
|
||||
echo "var mysqlDocTemplate = '" , PhpMyAdmin\Util::getMySQLDocuURL('%s')
|
||||
, "';\n";
|
||||
|
||||
//Max input vars allowed by PHP.
|
||||
$maxInputVars = ini_get('max_input_vars');
|
||||
echo 'var maxInputVars = '
|
||||
, (false === $maxInputVars || '' == $maxInputVars ? 'false' : (int)$maxInputVars)
|
||||
, (false === $maxInputVars || '' == $maxInputVars ? 'false' : (int) $maxInputVars)
|
||||
, ';' . "\n";
|
||||
|
||||
echo "if ($.datepicker) {\n";
|
||||
@ -794,7 +801,7 @@ Sanitize::printJsValue(
|
||||
Sanitize::printJsValue("$.datepicker.regional['']['currentText']", __('Today'));
|
||||
Sanitize::printJsValue(
|
||||
"$.datepicker.regional['']['monthNames']",
|
||||
array(
|
||||
[
|
||||
__('January'),
|
||||
__('February'),
|
||||
__('March'),
|
||||
@ -806,12 +813,12 @@ Sanitize::printJsValue(
|
||||
__('September'),
|
||||
__('October'),
|
||||
__('November'),
|
||||
__('December')
|
||||
)
|
||||
__('December'),
|
||||
]
|
||||
);
|
||||
Sanitize::printJsValue(
|
||||
"$.datepicker.regional['']['monthNamesShort']",
|
||||
array(
|
||||
[
|
||||
/* l10n: Short month name */
|
||||
__('Jan'),
|
||||
/* l10n: Short month name */
|
||||
@ -835,24 +842,24 @@ Sanitize::printJsValue(
|
||||
/* l10n: Short month name */
|
||||
__('Nov'),
|
||||
/* l10n: Short month name */
|
||||
__('Dec')
|
||||
)
|
||||
__('Dec'),
|
||||
]
|
||||
);
|
||||
Sanitize::printJsValue(
|
||||
"$.datepicker.regional['']['dayNames']",
|
||||
array(
|
||||
[
|
||||
__('Sunday'),
|
||||
__('Monday'),
|
||||
__('Tuesday'),
|
||||
__('Wednesday'),
|
||||
__('Thursday'),
|
||||
__('Friday'),
|
||||
__('Saturday')
|
||||
)
|
||||
__('Saturday'),
|
||||
]
|
||||
);
|
||||
Sanitize::printJsValue(
|
||||
"$.datepicker.regional['']['dayNamesShort']",
|
||||
array(
|
||||
[
|
||||
/* l10n: Short week day name for Sunday */
|
||||
__('Sun'),
|
||||
/* l10n: Short week day name for Monday */
|
||||
@ -866,12 +873,12 @@ Sanitize::printJsValue(
|
||||
/* l10n: Short week day name for Friday */
|
||||
__('Fri'),
|
||||
/* l10n: Short week day name for Saturday */
|
||||
__('Sat')
|
||||
)
|
||||
__('Sat'),
|
||||
]
|
||||
);
|
||||
Sanitize::printJsValue(
|
||||
"$.datepicker.regional['']['dayNamesMin']",
|
||||
array(
|
||||
[
|
||||
/* l10n: Minimal week day name for Sunday */
|
||||
__('Su'),
|
||||
/* l10n: Minimal week day name for Monday */
|
||||
@ -885,8 +892,8 @@ Sanitize::printJsValue(
|
||||
/* l10n: Minimal week day name for Friday */
|
||||
__('Fr'),
|
||||
/* l10n: Minimal week day name for Saturday */
|
||||
__('Sa')
|
||||
)
|
||||
__('Sa'),
|
||||
]
|
||||
);
|
||||
/* l10n: Column header for week of the year in calendar */
|
||||
Sanitize::printJsValue("$.datepicker.regional['']['weekHeader']", __('Wk'));
|
||||
@ -896,7 +903,7 @@ Sanitize::printJsValue(
|
||||
/* l10n: Month-year order for calendar, use either "calendar-month-year"
|
||||
* or "calendar-year-month".
|
||||
*/
|
||||
(__('calendar-month-year') == 'calendar-year-month')
|
||||
__('calendar-month-year') == 'calendar-year-month'
|
||||
);
|
||||
/* l10n: Year suffix for calendar, "none" is empty. */
|
||||
$year_suffix = _pgettext('Year suffix', 'none');
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/* global GotoWhitelist */ // js/whitelist.php
|
||||
|
||||
/**
|
||||
* An implementation of a client-side page cache.
|
||||
* This object also uses the cache to provide a simple microhistory,
|
||||
* that is the ability to use the back and forward buttons in the browser
|
||||
*/
|
||||
PMA_MicroHistory = {
|
||||
var MicroHistory = {
|
||||
/**
|
||||
* @var int The maximum number of pages to keep in the cache
|
||||
*/
|
||||
@ -31,7 +34,7 @@ PMA_MicroHistory = {
|
||||
* @param array scripts A list of scripts that is required for the page
|
||||
* @param string menu A hash that links to a menu stored
|
||||
* in a dedicated menu cache
|
||||
* @param array params A list of parameters used by PMA_commonParams()
|
||||
* @param array params A list of parameters used by CommonParams()
|
||||
* @param string rel A relationship to the current page:
|
||||
* 'samepage': Forces the response to be treated as
|
||||
* the same page as the current one
|
||||
@ -44,7 +47,7 @@ PMA_MicroHistory = {
|
||||
* @return void
|
||||
*/
|
||||
add: function (hash, scripts, menu, params, rel) {
|
||||
if (this.pages.length > PMA_MicroHistory.MAX) {
|
||||
if (this.pages.length > MicroHistory.MAX) {
|
||||
// Trim the cache, to the maximum number of allowed entries
|
||||
// This way we will have a cached menu for every page
|
||||
for (var i = 0; i < this.pages.length - this.MAX; i++) {
|
||||
@ -72,7 +75,7 @@ PMA_MicroHistory = {
|
||||
menu: menu,
|
||||
params: params
|
||||
});
|
||||
PMA_SetUrlHash(this.current, hash);
|
||||
MicroHistory.setUrlHash(this.current, hash);
|
||||
this.current++;
|
||||
}
|
||||
},
|
||||
@ -85,25 +88,26 @@ PMA_MicroHistory = {
|
||||
* @return void
|
||||
*/
|
||||
navigate: function (index) {
|
||||
if (typeof this.pages[index] === 'undefined' ||
|
||||
typeof this.pages[index].content === 'undefined' ||
|
||||
typeof this.pages[index].menu === 'undefined' ||
|
||||
! PMA_MicroHistory.menus.get(this.pages[index].menu)
|
||||
var localIndex = index;
|
||||
if (typeof this.pages[localIndex] === 'undefined' ||
|
||||
typeof this.pages[localIndex].content === 'undefined' ||
|
||||
typeof this.pages[localIndex].menu === 'undefined' ||
|
||||
! MicroHistory.menus.get(this.pages[localIndex].menu)
|
||||
) {
|
||||
PMA_ajaxShowMessage(
|
||||
'<div class="error">' + PMA_messages.strInvalidPage + '</div>',
|
||||
Functions.ajaxShowMessage(
|
||||
'<div class="error">' + Messages.strInvalidPage + '</div>',
|
||||
false
|
||||
);
|
||||
} else {
|
||||
AJAX.active = true;
|
||||
var record = this.pages[index];
|
||||
var record = this.pages[localIndex];
|
||||
AJAX.scriptHandler.reset(function () {
|
||||
$('#page_content').html(record.content);
|
||||
$('#selflink').html(record.selflink);
|
||||
PMA_MicroHistory.menus.replace(PMA_MicroHistory.menus.get(record.menu));
|
||||
PMA_commonParams.setAll(record.params);
|
||||
MicroHistory.menus.replace(MicroHistory.menus.get(record.menu));
|
||||
CommonParams.setAll(record.params);
|
||||
AJAX.scriptHandler.load(record.scripts);
|
||||
PMA_MicroHistory.current = ++index;
|
||||
MicroHistory.current = ++localIndex;
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -151,7 +155,7 @@ PMA_MicroHistory = {
|
||||
* @return void
|
||||
*/
|
||||
add: function (hash, content) {
|
||||
if (this.size(this.data) > PMA_MicroHistory.MAX) {
|
||||
if (this.size(this.data) > MicroHistory.MAX) {
|
||||
// when the cache grows, we remove the oldest entry
|
||||
var oldest;
|
||||
var key;
|
||||
@ -202,7 +206,7 @@ PMA_MicroHistory = {
|
||||
}
|
||||
var menuHashesParam = menuHashes.join('-');
|
||||
if (menuHashesParam) {
|
||||
param = PMA_commonParams.get('arg_separator') + 'menuHashes=' + menuHashesParam;
|
||||
param = CommonParams.get('arg_separator') + 'menuHashes=' + menuHashesParam;
|
||||
}
|
||||
return param;
|
||||
},
|
||||
@ -216,7 +220,7 @@ PMA_MicroHistory = {
|
||||
// Remove duplicate wrapper
|
||||
// TODO: don't send it in the response
|
||||
.children().first().remove();
|
||||
$('#topmenu').menuResizer(PMA_mainMenuResizerCallback);
|
||||
$('#topmenu').menuResizer(Functions.mainMenuResizerCallback);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -225,7 +229,7 @@ PMA_MicroHistory = {
|
||||
* URL hash management module.
|
||||
* Allows direct bookmarking and microhistory.
|
||||
*/
|
||||
PMA_SetUrlHash = (function (jQuery, window) {
|
||||
MicroHistory.setUrlHash = (function (jQuery, window) {
|
||||
'use strict';
|
||||
/**
|
||||
* Indictaes whether we have already completed
|
||||
@ -283,17 +287,17 @@ PMA_SetUrlHash = (function (jQuery, window) {
|
||||
/**
|
||||
* Start initialisation
|
||||
*/
|
||||
var urlhash = window.location.hash;
|
||||
if (urlhash.substring(0, 8) === '#PMAURL-') {
|
||||
var urlHash = window.location.hash;
|
||||
if (urlHash.substring(0, 8) === '#PMAURL-') {
|
||||
// We have a valid hash, let's redirect the user
|
||||
// to the page that it's pointing to
|
||||
var colon_position = urlhash.indexOf(':');
|
||||
var questionmark_position = urlhash.indexOf('?');
|
||||
if (colon_position !== -1 && questionmark_position !== -1 && colon_position < questionmark_position) {
|
||||
var hash_url = urlhash.substring(colon_position + 1, questionmark_position);
|
||||
if (PMA_gotoWhitelist.indexOf(hash_url) !== -1) {
|
||||
window.location = urlhash.substring(
|
||||
colon_position + 1
|
||||
var colonPosition = urlHash.indexOf(':');
|
||||
var questionMarkPosition = urlHash.indexOf('?');
|
||||
if (colonPosition !== -1 && questionMarkPosition !== -1 && colonPosition < questionMarkPosition) {
|
||||
var hashUrl = urlHash.substring(colonPosition + 1, questionMarkPosition);
|
||||
if (GotoWhitelist.indexOf(hashUrl) !== -1) {
|
||||
window.location = urlHash.substring(
|
||||
colonPosition + 1
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -324,7 +328,7 @@ PMA_SetUrlHash = (function (jQuery, window) {
|
||||
var index = window.location.hash.substring(
|
||||
8, window.location.hash.indexOf(':')
|
||||
);
|
||||
PMA_MicroHistory.navigate(index);
|
||||
MicroHistory.navigate(index);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
*/
|
||||
|
||||
function captureURL (url) {
|
||||
var newUrl = '' + url;
|
||||
var URL = {};
|
||||
url = '' + url;
|
||||
// Exclude the url part till HTTP
|
||||
url = url.substr(url.search('sql.php'), url.length);
|
||||
newUrl = newUrl.substr(newUrl.search('sql.php'), newUrl.length);
|
||||
// The url part between ORDER BY and &session_max_rows needs to be replaced.
|
||||
URL.head = url.substr(0, url.indexOf('ORDER+BY') + 9);
|
||||
URL.tail = url.substr(url.indexOf('&session_max_rows'), url.length);
|
||||
URL.head = newUrl.substr(0, newUrl.indexOf('ORDER+BY') + 9);
|
||||
URL.tail = newUrl.substr(newUrl.indexOf('&session_max_rows'), newUrl.length);
|
||||
return URL;
|
||||
}
|
||||
|
||||
@ -28,10 +28,10 @@ function captureURL (url) {
|
||||
function removeColumnFromMultiSort (target, parent) {
|
||||
var URL = captureURL(target);
|
||||
var begin = target.indexOf('ORDER+BY') + 8;
|
||||
var end = target.indexOf(PMA_commonParams.get('arg_separator') + 'session_max_rows');
|
||||
var end = target.indexOf(CommonParams.get('arg_separator') + 'session_max_rows');
|
||||
// get the names of the columns involved
|
||||
var between_part = target.substr(begin, end - begin);
|
||||
var columns = between_part.split('%2C+');
|
||||
var betweenPart = target.substr(begin, end - begin);
|
||||
var columns = betweenPart.split('%2C+');
|
||||
// If the given column is not part of the order clause exit from this function
|
||||
var index = parent.find('small').length ? parent.find('small').text() : '';
|
||||
if (index === '') {
|
||||
@ -47,32 +47,33 @@ function removeColumnFromMultiSort (target, parent) {
|
||||
URL.head = head;
|
||||
// removing the last sort order should have priority over what
|
||||
// is remembered via the RememberSorting directive
|
||||
URL.tail += PMA_commonParams.get('arg_separator') + 'discard_remembered_sort=1';
|
||||
URL.tail += CommonParams.get('arg_separator') + 'discard_remembered_sort=1';
|
||||
}
|
||||
URL.head = URL.head.substring(URL.head.indexOf('?') + 1);
|
||||
var middle_part = columns.join('%2C+');
|
||||
params = URL.head + middle_part + URL.tail;
|
||||
var middlePart = columns.join('%2C+');
|
||||
var params = URL.head + middlePart + URL.tail;
|
||||
return params;
|
||||
}
|
||||
|
||||
AJAX.registerOnload('keyhandler.js', function () {
|
||||
$('th.draggable.column_heading.pointer.marker a').on('click', function (event) {
|
||||
var url = $(this).parent().find('input').val();
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var params;
|
||||
if (event.ctrlKey || event.altKey) {
|
||||
event.preventDefault();
|
||||
var params = removeColumnFromMultiSort(url, $(this).parent());
|
||||
params = removeColumnFromMultiSort(url, $(this).parent());
|
||||
if (params) {
|
||||
AJAX.source = $(this);
|
||||
PMA_ajaxShowMessage();
|
||||
Functions.ajaxShowMessage();
|
||||
params += argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
$.post('sql.php', params, AJAX.responseHandler);
|
||||
}
|
||||
} else if (event.shiftKey) {
|
||||
event.preventDefault();
|
||||
AJAX.source = $(this);
|
||||
PMA_ajaxShowMessage();
|
||||
var params = url.substring(url.indexOf('?') + 1);
|
||||
Functions.ajaxShowMessage();
|
||||
params = url.substring(url.indexOf('?') + 1);
|
||||
params += argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
$.post('sql.php', params, AJAX.responseHandler);
|
||||
}
|
||||
|
||||
575
js/navigation.js
575
js/navigation.js
File diff suppressed because it is too large
Load Diff
@ -6,22 +6,26 @@
|
||||
* @requires jQuery
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
/* global centralColumnList:writable */ // js/functions.js
|
||||
|
||||
/**
|
||||
* AJAX scripts for normalization.php
|
||||
*
|
||||
*/
|
||||
|
||||
var normalizeto = '1nf';
|
||||
var primary_key;
|
||||
var data_parsed = null;
|
||||
var primaryKey;
|
||||
var dataParsed = null;
|
||||
|
||||
function appendHtmlColumnsList () {
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'getColumns': true
|
||||
},
|
||||
function (data) {
|
||||
@ -31,36 +35,38 @@ function appendHtmlColumnsList () {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goTo3NFStep1 (newTables) {
|
||||
if (Object.keys(newTables).length === 1) {
|
||||
newTables = [PMA_commonParams.get('table')];
|
||||
var tables = newTables;
|
||||
if (Object.keys(tables).length === 1) {
|
||||
tables = [CommonParams.get('table')];
|
||||
}
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'tables': newTables,
|
||||
'db': CommonParams.get('db'),
|
||||
'server': CommonParams.get('server'),
|
||||
'tables': tables,
|
||||
'step': '3.1'
|
||||
}, function (data) {
|
||||
$('#page_content').find('h3').html(PMA_messages.str3NFNormalization);
|
||||
$('#page_content').find('h3').html(Messages.str3NFNormalization);
|
||||
$('#mainContent').find('legend').html(data.legendText);
|
||||
$('#mainContent').find('h4').html(data.headText);
|
||||
$('#mainContent').find('p').html(data.subText);
|
||||
$('#mainContent').find('#extra').html(data.extra);
|
||||
$('#extra').find('form').each(function () {
|
||||
var form_id = $(this).attr('id');
|
||||
var colname = $(this).data('colname');
|
||||
$('#' + form_id + ' input[value=\'' + colname + '\']').next().remove();
|
||||
$('#' + form_id + ' input[value=\'' + colname + '\']').remove();
|
||||
var formId = $(this).attr('id');
|
||||
var colName = $(this).data('colname');
|
||||
$('#' + formId + ' input[value=\'' + colName + '\']').next().remove();
|
||||
$('#' + formId + ' input[value=\'' + colName + '\']').remove();
|
||||
});
|
||||
$('#mainContent').find('#newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
|
||||
if (data.subText !== '') {
|
||||
$('<input/>')
|
||||
.attr({ type: 'button', value: PMA_messages.strDone })
|
||||
$('<input>')
|
||||
.attr({ type: 'button', value: Messages.strDone })
|
||||
.on('click', function () {
|
||||
processDependencies('', true);
|
||||
})
|
||||
@ -69,34 +75,35 @@ function goTo3NFStep1 (newTables) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goTo2NFStep1 () {
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'step': '2.1'
|
||||
}, function (data) {
|
||||
$('#page_content h3').html(PMA_messages.str2NFNormalization);
|
||||
$('#page_content h3').html(Messages.str2NFNormalization);
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
$('#mainContent h4').html(data.headText);
|
||||
$('#mainContent p').html(data.subText);
|
||||
$('#mainContent #extra').html(data.extra);
|
||||
$('#mainContent #newCols').html('');
|
||||
if (data.subText !== '') {
|
||||
var doneButton = $('<input />')
|
||||
.attr({ type: 'submit', value: PMA_messages.strDone, })
|
||||
$('<input>')
|
||||
.attr({ type: 'submit', value: Messages.strDone, })
|
||||
.on('click', function () {
|
||||
processDependencies(data.primary_key);
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
} else {
|
||||
if (normalizeto === '3nf') {
|
||||
$('#mainContent #newCols').html(PMA_messages.strToNextStep);
|
||||
$('#mainContent #newCols').html(Messages.strToNextStep);
|
||||
setTimeout(function () {
|
||||
goTo3NFStep1([PMA_commonParams.get('table')]);
|
||||
goTo3NFStep1([CommonParams.get('table')]);
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
@ -108,9 +115,9 @@ function goToFinish1NF () {
|
||||
goTo2NFStep1();
|
||||
return true;
|
||||
}
|
||||
$('#mainContent legend').html(PMA_messages.strEndStep);
|
||||
$('#mainContent legend').html(Messages.strEndStep);
|
||||
$('#mainContent h4').html(
|
||||
'<h3>' + PMA_sprintf(PMA_messages.strFinishMsg, escapeHtml(PMA_commonParams.get('table'))) + '</h3>'
|
||||
'<h3>' + Functions.sprintf(Messages.strFinishMsg, Functions.escapeHtml(CommonParams.get('table'))) + '</h3>'
|
||||
);
|
||||
$('#mainContent p').html('');
|
||||
$('#mainContent #extra').html('');
|
||||
@ -118,14 +125,15 @@ function goToFinish1NF () {
|
||||
$('.tblFooters').html('');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function goToStep4 () {
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'step4': true
|
||||
}, function (data) {
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
@ -134,8 +142,8 @@ function goToStep4 () {
|
||||
$('#mainContent #extra').html(data.extra);
|
||||
$('#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
for (var pk in primary_key) {
|
||||
$('#extra input[value=\'' + escapeJsString(primary_key[pk]) + '\']').attr('disabled','disabled');
|
||||
for (var pk in primaryKey) {
|
||||
$('#extra input[value=\'' + Functions.escapeJsString(primaryKey[pk]) + '\']').attr('disabled','disabled');
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -146,9 +154,9 @@ function goToStep3 () {
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'step3': true
|
||||
}, function (data) {
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
@ -157,9 +165,9 @@ function goToStep3 () {
|
||||
$('#mainContent #extra').html(data.extra);
|
||||
$('#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
primary_key = JSON.parse(data.primary_key);
|
||||
for (var pk in primary_key) {
|
||||
$('#extra input[value=\'' + escapeJsString(primary_key[pk]) + '\']').attr('disabled','disabled');
|
||||
primaryKey = JSON.parse(data.primary_key);
|
||||
for (var pk in primaryKey) {
|
||||
$('#extra input[value=\'' + Functions.escapeJsString(primaryKey[pk]) + '\']').attr('disabled','disabled');
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -170,9 +178,9 @@ function goToStep2 (extra) {
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'step2': true
|
||||
}, function (data) {
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
@ -182,8 +190,8 @@ function goToStep2 (extra) {
|
||||
$('.tblFooters').html('');
|
||||
if (data.hasPrimaryKey === '1') {
|
||||
if (extra === 'goToStep3') {
|
||||
$('#mainContent h4').html(PMA_messages.strPrimaryKeyAdded);
|
||||
$('#mainContent p').html(PMA_messages.strToNextStep);
|
||||
$('#mainContent h4').html(Messages.strPrimaryKeyAdded);
|
||||
$('#mainContent p').html(Messages.strToNextStep);
|
||||
}
|
||||
if (extra === 'goToFinish1NF') {
|
||||
goToFinish1NF();
|
||||
@ -205,11 +213,11 @@ function goTo2NFFinish (pd) {
|
||||
for (var dependson in pd) {
|
||||
tables[dependson] = $('#extra input[name="' + dependson + '"]').val();
|
||||
}
|
||||
datastring = {
|
||||
var datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'pd': JSON.stringify(pd),
|
||||
'newTablesName':JSON.stringify(tables),
|
||||
'createNewTables2NF':1 };
|
||||
@ -222,7 +230,7 @@ function goTo2NFFinish (pd) {
|
||||
if (data.success === true) {
|
||||
if (data.queryError === false) {
|
||||
if (normalizeto === '3nf') {
|
||||
$('#pma_navigation_reload').click();
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
goTo3NFStep1(tables);
|
||||
return true;
|
||||
}
|
||||
@ -232,11 +240,11 @@ function goTo2NFFinish (pd) {
|
||||
$('#mainContent #extra').html('');
|
||||
$('.tblFooters').html('');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.extra, false);
|
||||
Functions.ajaxShowMessage(data.extra, false);
|
||||
}
|
||||
$('#pma_navigation_reload').click();
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -252,10 +260,10 @@ function goTo3NFFinish (newTables) {
|
||||
}
|
||||
}
|
||||
}
|
||||
datastring = {
|
||||
var datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'server': CommonParams.get('server'),
|
||||
'newTables':JSON.stringify(newTables),
|
||||
'createNewTables3NF':1 };
|
||||
$.ajax({
|
||||
@ -272,39 +280,41 @@ function goTo3NFFinish (newTables) {
|
||||
$('#mainContent #extra').html('');
|
||||
$('.tblFooters').html('');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.extra, false);
|
||||
Functions.ajaxShowMessage(data.extra, false);
|
||||
}
|
||||
$('#pma_navigation_reload').click();
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var backup = '';
|
||||
function goTo2NFStep2 (pd, primary_key) {
|
||||
|
||||
function goTo2NFStep2 (pd, primaryKey) {
|
||||
$('#newCols').html('');
|
||||
$('#mainContent legend').html(PMA_messages.strStep + ' 2.2 ' + PMA_messages.strConfirmPd);
|
||||
$('#mainContent h4').html(PMA_messages.strSelectedPd);
|
||||
$('#mainContent p').html(PMA_messages.strPdHintNote);
|
||||
$('#mainContent legend').html(Messages.strStep + ' 2.2 ' + Messages.strConfirmPd);
|
||||
$('#mainContent h4').html(Messages.strSelectedPd);
|
||||
$('#mainContent p').html(Messages.strPdHintNote);
|
||||
var extra = '<div class="dependencies_box">';
|
||||
var pdFound = false;
|
||||
for (var dependson in pd) {
|
||||
if (dependson !== primary_key) {
|
||||
if (dependson !== primaryKey) {
|
||||
pdFound = true;
|
||||
extra += '<p class="displayblock desc">' + escapeHtml(dependson) + ' -> ' + escapeHtml(pd[dependson].toString()) + '</p>';
|
||||
extra += '<p class="displayblock desc">' + Functions.escapeHtml(dependson) + ' -> ' + Functions.escapeHtml(pd[dependson].toString()) + '</p>';
|
||||
}
|
||||
}
|
||||
if (!pdFound) {
|
||||
extra += '<p class="displayblock desc">' + PMA_messages.strNoPdSelected + '</p>';
|
||||
extra += '<p class="displayblock desc">' + Messages.strNoPdSelected + '</p>';
|
||||
extra += '</div>';
|
||||
} else {
|
||||
extra += '</div>';
|
||||
datastring = {
|
||||
var datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'pd': JSON.stringify(pd),
|
||||
'getNewTables2NF':1 };
|
||||
$.ajax({
|
||||
@ -316,44 +326,44 @@ function goTo2NFStep2 (pd, primary_key) {
|
||||
if (data.success === true) {
|
||||
extra += data.message;
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#mainContent #extra').html(extra);
|
||||
$('.tblFooters').html('<input type="button" value="' + PMA_messages.strBack + '" id="backEditPd"/><input type="button" id="goTo2NFFinish" value="' + PMA_messages.strGo + '"/>');
|
||||
$('#goTo2NFFinish').click(function () {
|
||||
$('.tblFooters').html('<input type="button" value="' + Messages.strBack + '" id="backEditPd"><input type="button" id="goTo2NFFinish" value="' + Messages.strGo + '">');
|
||||
$('#goTo2NFFinish').on('click', function () {
|
||||
goTo2NFFinish(pd);
|
||||
});
|
||||
}
|
||||
|
||||
function goTo3NFStep2 (pd, tablesTds) {
|
||||
$('#newCols').html('');
|
||||
$('#mainContent legend').html(PMA_messages.strStep + ' 3.2 ' + PMA_messages.strConfirmTd);
|
||||
$('#mainContent h4').html(PMA_messages.strSelectedTd);
|
||||
$('#mainContent p').html(PMA_messages.strPdHintNote);
|
||||
$('#mainContent legend').html(Messages.strStep + ' 3.2 ' + Messages.strConfirmTd);
|
||||
$('#mainContent h4').html(Messages.strSelectedTd);
|
||||
$('#mainContent p').html(Messages.strPdHintNote);
|
||||
var extra = '<div class="dependencies_box">';
|
||||
var pdFound = false;
|
||||
for (var table in tablesTds) {
|
||||
for (var i in tablesTds[table]) {
|
||||
dependson = tablesTds[table][i];
|
||||
var dependson = tablesTds[table][i];
|
||||
if (dependson !== '' && dependson !== table) {
|
||||
pdFound = true;
|
||||
extra += '<p class="displayblock desc">' + escapeHtml(dependson) + ' -> ' + escapeHtml(pd[dependson].toString()) + '</p>';
|
||||
extra += '<p class="displayblock desc">' + Functions.escapeHtml(dependson) + ' -> ' + Functions.escapeHtml(pd[dependson].toString()) + '</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pdFound) {
|
||||
extra += '<p class="displayblock desc">' + PMA_messages.strNoTdSelected + '</p>';
|
||||
extra += '<p class="displayblock desc">' + Messages.strNoTdSelected + '</p>';
|
||||
extra += '</div>';
|
||||
} else {
|
||||
extra += '</div>';
|
||||
datastring = {
|
||||
var datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'db': CommonParams.get('db'),
|
||||
'tables': JSON.stringify(tablesTds),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'server': CommonParams.get('server'),
|
||||
'pd': JSON.stringify(pd),
|
||||
'getNewTables3NF':1 };
|
||||
$.ajax({
|
||||
@ -362,49 +372,50 @@ function goTo3NFStep2 (pd, tablesTds) {
|
||||
data: datastring,
|
||||
async:false,
|
||||
success: function (data) {
|
||||
data_parsed = data;
|
||||
dataParsed = data;
|
||||
if (data.success === true) {
|
||||
extra += data_parsed.html;
|
||||
extra += dataParsed.html;
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#mainContent #extra').html(extra);
|
||||
$('.tblFooters').html('<input type="button" value="' + PMA_messages.strBack + '" id="backEditPd"/><input type="button" id="goTo3NFFinish" value="' + PMA_messages.strGo + '"/>');
|
||||
$('#goTo3NFFinish').click(function () {
|
||||
$('.tblFooters').html('<input type="button" value="' + Messages.strBack + '" id="backEditPd"><input type="button" id="goTo3NFFinish" value="' + Messages.strGo + '">');
|
||||
$('#goTo3NFFinish').on('click', function () {
|
||||
if (!pdFound) {
|
||||
goTo3NFFinish([]);
|
||||
} else {
|
||||
goTo3NFFinish(data_parsed.newTables);
|
||||
goTo3NFFinish(dataParsed.newTables);
|
||||
}
|
||||
});
|
||||
}
|
||||
function processDependencies (primary_key, isTransitive) {
|
||||
function processDependencies (primaryKey, isTransitive) {
|
||||
var pk = primaryKey;
|
||||
var pd = {};
|
||||
var tablesTds = {};
|
||||
var dependsOn;
|
||||
pd[primary_key] = [];
|
||||
pd[pk] = [];
|
||||
$('#extra form').each(function () {
|
||||
var tblname;
|
||||
if (isTransitive === true) {
|
||||
tblname = $(this).data('tablename');
|
||||
primary_key = tblname;
|
||||
pk = tblname;
|
||||
if (!(tblname in tablesTds)) {
|
||||
tablesTds[tblname] = [];
|
||||
}
|
||||
tablesTds[tblname].push(primary_key);
|
||||
tablesTds[tblname].push(pk);
|
||||
}
|
||||
var form_id = $(this).attr('id');
|
||||
$('#' + form_id + ' input[type=checkbox]:not(:checked)').prop('checked', false);
|
||||
var formId = $(this).attr('id');
|
||||
$('#' + formId + ' input[type=checkbox]:not(:checked)').prop('checked', false);
|
||||
dependsOn = '';
|
||||
$('#' + form_id + ' input[type=checkbox]:checked').each(function () {
|
||||
$('#' + formId + ' input[type=checkbox]:checked').each(function () {
|
||||
dependsOn += $(this).val() + ', ';
|
||||
$(this).attr('checked','checked');
|
||||
});
|
||||
if (dependsOn === '') {
|
||||
dependsOn = primary_key;
|
||||
dependsOn = pk;
|
||||
} else {
|
||||
dependsOn = dependsOn.slice(0, -2);
|
||||
}
|
||||
@ -425,7 +436,7 @@ function processDependencies (primary_key, isTransitive) {
|
||||
if (isTransitive === true) {
|
||||
goTo3NFStep2(pd, tablesTds);
|
||||
} else {
|
||||
goTo2NFStep2(pd, primary_key);
|
||||
goTo2NFStep2(pd, pk);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -434,22 +445,22 @@ function moveRepeatingGroup (repeatingCols) {
|
||||
var newTable = $('input[name=repeatGroupTable]').val();
|
||||
var newColumn = $('input[name=repeatGroupColumn]').val();
|
||||
if (!newTable) {
|
||||
$('input[name=repeatGroupTable]').focus();
|
||||
$('input[name=repeatGroupTable]').trigger('focus');
|
||||
return false;
|
||||
}
|
||||
if (!newColumn) {
|
||||
$('input[name=repeatGroupColumn]').focus();
|
||||
$('input[name=repeatGroupColumn]').trigger('focus');
|
||||
return false;
|
||||
}
|
||||
datastring = {
|
||||
var datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'repeatingColumns': repeatingCols,
|
||||
'newTable':newTable,
|
||||
'newColumn':newColumn,
|
||||
'primary_columns':primary_key.toString()
|
||||
'primary_columns':primaryKey.toString()
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -461,10 +472,10 @@ function moveRepeatingGroup (repeatingCols) {
|
||||
if (data.queryError === false) {
|
||||
goToStep3();
|
||||
}
|
||||
PMA_ajaxShowMessage(data.message, false);
|
||||
$('#pma_navigation_reload').click();
|
||||
Functions.ajaxShowMessage(data.message, false);
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -493,7 +504,7 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
}
|
||||
});
|
||||
|
||||
$('#splitGo').click(function () {
|
||||
$('#splitGo').on('click', function () {
|
||||
if (!selectedCol || selectedCol === '') {
|
||||
return false;
|
||||
}
|
||||
@ -502,9 +513,9 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'splitColumn': true,
|
||||
'numFields': numField
|
||||
},
|
||||
@ -514,12 +525,12 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
$('.default_value').hide();
|
||||
$('.enum_notice').hide();
|
||||
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', id: 'saveSplit', value: PMA_messages.strSave })
|
||||
$('<input>')
|
||||
.attr({ type: 'submit', id: 'saveSplit', value: Messages.strSave })
|
||||
.appendTo('.tblFooters');
|
||||
|
||||
var cancelSplitButton = $('<input />')
|
||||
.attr({ type: 'submit', id: 'cancelSplit', value: PMA_messages.strCancel })
|
||||
$('<input>')
|
||||
.attr({ type: 'submit', id: 'cancelSplit', value: Messages.strCancel })
|
||||
.on('click', function () {
|
||||
$('#newCols').html('');
|
||||
$(this).parent().html('');
|
||||
@ -531,13 +542,13 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
return false;
|
||||
});
|
||||
$('.tblFooters').on('click','#saveSplit', function () {
|
||||
central_column_list = [];
|
||||
centralColumnList = [];
|
||||
if ($('#newCols #field_0_1').val() === '') {
|
||||
$('#newCols #field_0_1').focus();
|
||||
$('#newCols #field_0_1').trigger('focus');
|
||||
return false;
|
||||
}
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
datastring = $('#newCols :input').serialize();
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
var datastring = $('#newCols :input').serialize();
|
||||
datastring += argsep + 'ajax_request=1' + argsep + 'do_save_data=1' + argsep + 'field_where=last';
|
||||
$.post('tbl_addfield.php', datastring, function (data) {
|
||||
if (data.success) {
|
||||
@ -545,12 +556,12 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
'sql.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'dropped_column': selectedCol,
|
||||
'purge' : 1,
|
||||
'sql_query': 'ALTER TABLE `' + PMA_commonParams.get('table') + '` DROP `' + selectedCol + '`;',
|
||||
'sql_query': 'ALTER TABLE `' + CommonParams.get('table') + '` DROP `' + selectedCol + '`;',
|
||||
'is_js_confirmed': 1
|
||||
},
|
||||
function (data) {
|
||||
@ -559,13 +570,13 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
$('#newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
selectedCol = '';
|
||||
}
|
||||
);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -575,9 +586,9 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'addNewPrimary': true
|
||||
},
|
||||
function (data) {
|
||||
@ -586,18 +597,18 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
$('.default_value').hide();
|
||||
$('.enum_notice').hide();
|
||||
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', id: 'saveNewPrimary', value: PMA_messages.strSave })
|
||||
$('<input>')
|
||||
.attr({ type: 'submit', id: 'saveNewPrimary', value: Messages.strSave })
|
||||
.appendTo('.tblFooters');
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', id: 'cancelSplit', value: PMA_messages.strCancel })
|
||||
$('<input>')
|
||||
.attr({ type: 'submit', id: 'cancelSplit', value: Messages.strCancel })
|
||||
.on('click', function () {
|
||||
$('#newCols').html('');
|
||||
$(this).parent().html('');
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -605,12 +616,12 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
});
|
||||
$('.tblFooters').on('click', '#saveNewPrimary', function () {
|
||||
var datastring = $('#newCols :input').serialize();
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
var argsep = CommonParams.get('arg_separator');
|
||||
datastring += argsep + 'field_key[0]=primary_0' + argsep + 'ajax_request=1' + argsep + 'do_save_data=1' + argsep + 'field_where=last';
|
||||
$.post('tbl_addfield.php', datastring, function (data) {
|
||||
if (data.success === true) {
|
||||
$('#mainContent h4').html(PMA_messages.strPrimaryKeyAdded);
|
||||
$('#mainContent p').html(PMA_messages.strToNextStep);
|
||||
$('#mainContent h4').html(Messages.strPrimaryKeyAdded);
|
||||
$('#mainContent p').html(Messages.strToNextStep);
|
||||
$('#mainContent #extra').html('');
|
||||
$('#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
@ -618,12 +629,12 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
goToStep3();
|
||||
}, 2000);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#extra').on('click', '#removeRedundant', function () {
|
||||
var dropQuery = 'ALTER TABLE `' + PMA_commonParams.get('table') + '` ';
|
||||
var dropQuery = 'ALTER TABLE `' + CommonParams.get('table') + '` ';
|
||||
$('#extra input[type=checkbox]:checked').each(function () {
|
||||
dropQuery += 'DROP `' + $(this).val() + '`, ';
|
||||
});
|
||||
@ -632,9 +643,9 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
'sql.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'sql_query': dropQuery,
|
||||
'is_js_confirmed': 1
|
||||
},
|
||||
@ -642,7 +653,7 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
if (data.success === true) {
|
||||
goToStep2('goToFinish1NF');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -656,21 +667,21 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
if (repeatingCols !== '') {
|
||||
var newColName = $('#extra input[type=checkbox]:checked:first').val();
|
||||
repeatingCols = repeatingCols.slice(0, -2);
|
||||
var confirmStr = PMA_sprintf(PMA_messages.strMoveRepeatingGroup, escapeHtml(repeatingCols), escapeHtml(PMA_commonParams.get('table')));
|
||||
confirmStr += '<input type="text" name="repeatGroupTable" placeholder="' + PMA_messages.strNewTablePlaceholder + '"/>' +
|
||||
'( ' + escapeHtml(primary_key.toString()) + ', <input type="text" name="repeatGroupColumn" placeholder="' + PMA_messages.strNewColumnPlaceholder + '" value="' + escapeHtml(newColName) + '">)' +
|
||||
var confirmStr = Functions.sprintf(Messages.strMoveRepeatingGroup, Functions.escapeHtml(repeatingCols), Functions.escapeHtml(CommonParams.get('table')));
|
||||
confirmStr += '<input type="text" name="repeatGroupTable" placeholder="' + Messages.strNewTablePlaceholder + '">' +
|
||||
'( ' + Functions.escapeHtml(primaryKey.toString()) + ', <input type="text" name="repeatGroupColumn" placeholder="' + Messages.strNewColumnPlaceholder + '" value="' + Functions.escapeHtml(newColName) + '">)' +
|
||||
'</ol>';
|
||||
$('#newCols').html(confirmStr);
|
||||
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', value: PMA_messages.strCancel })
|
||||
$('<input>')
|
||||
.attr({ type: 'submit', value: Messages.strCancel })
|
||||
.on('click', function () {
|
||||
$('#newCols').html('');
|
||||
$('#extra input[type=checkbox]').prop('checked', false);
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', value: PMA_messages.strGo })
|
||||
$('<input>')
|
||||
.attr({ type: 'submit', value: Messages.strGo })
|
||||
.on('click', function () {
|
||||
moveRepeatingGroup(repeatingCols);
|
||||
})
|
||||
@ -679,17 +690,18 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
});
|
||||
$('#mainContent p').on('click', '#createPrimaryKey', function (event) {
|
||||
event.preventDefault();
|
||||
var url = { create_index: 1,
|
||||
server: PMA_commonParams.get('server'),
|
||||
db: PMA_commonParams.get('db'),
|
||||
table: PMA_commonParams.get('table'),
|
||||
added_fields: 1,
|
||||
add_fields:1,
|
||||
index: { Key_name:'PRIMARY' },
|
||||
ajax_request: true
|
||||
var url = {
|
||||
'create_index': 1,
|
||||
'server': CommonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'added_fields': 1,
|
||||
'add_fields':1,
|
||||
'index': { 'Key_name':'PRIMARY' },
|
||||
'ajax_request': true
|
||||
};
|
||||
var title = PMA_messages.strAddPrimaryKey;
|
||||
indexEditorDialog(url, title, function () {
|
||||
var title = Messages.strAddPrimaryKey;
|
||||
Functions.indexEditorDialog(url, title, function () {
|
||||
// on success
|
||||
$('.sqlqueryresults').remove();
|
||||
$('.result_query').remove();
|
||||
@ -703,29 +715,29 @@ AJAX.registerOnload('normalization.js', function () {
|
||||
});
|
||||
$('#mainContent').on('click', '#showPossiblePd', function () {
|
||||
if ($(this).hasClass('hideList')) {
|
||||
$(this).html('+ ' + PMA_messages.strShowPossiblePd);
|
||||
$(this).html('+ ' + Messages.strShowPossiblePd);
|
||||
$(this).removeClass('hideList');
|
||||
$('#newCols').slideToggle('slow');
|
||||
return false;
|
||||
}
|
||||
if ($('#newCols').html() !== '') {
|
||||
$('#showPossiblePd').html('- ' + PMA_messages.strHidePd);
|
||||
$('#showPossiblePd').html('- ' + Messages.strHidePd);
|
||||
$('#showPossiblePd').addClass('hideList');
|
||||
$('#newCols').slideToggle('slow');
|
||||
return false;
|
||||
}
|
||||
$('#newCols').insertAfter('#mainContent h4');
|
||||
$('#newCols').html('<div class="center">' + PMA_messages.strLoading + '<br/>' + PMA_messages.strWaitForPd + '</div>');
|
||||
$('#newCols').html('<div class="center">' + Messages.strLoading + '<br>' + Messages.strWaitForPd + '</div>');
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'db': CommonParams.get('db'),
|
||||
'table': CommonParams.get('table'),
|
||||
'server': CommonParams.get('server'),
|
||||
'findPdl': true
|
||||
}, function (data) {
|
||||
$('#showPossiblePd').html('- ' + PMA_messages.strHidePd);
|
||||
$('#showPossiblePd').html('- ' + Messages.strHidePd);
|
||||
$('#showPossiblePd').addClass('hideList');
|
||||
$('#newCols').html(data.message);
|
||||
});
|
||||
|
||||
@ -10,11 +10,11 @@
|
||||
|
||||
function showSettings (selector) {
|
||||
var buttons = {};
|
||||
buttons[PMA_messages.strApply] = function () {
|
||||
$('.config-form').submit();
|
||||
buttons[Messages.strApply] = function () {
|
||||
$('.config-form').trigger('submit');
|
||||
};
|
||||
|
||||
buttons[PMA_messages.strCancel] = function () {
|
||||
buttons[Messages.strCancel] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
@ -22,7 +22,7 @@ function showSettings (selector) {
|
||||
var $clone = $(selector + ' .page_settings').clone(true);
|
||||
$(selector)
|
||||
.dialog({
|
||||
title: PMA_messages.strPageSettings,
|
||||
title: Messages.strPageSettings,
|
||||
width: 700,
|
||||
minHeight: 250,
|
||||
modal: true,
|
||||
|
||||
@ -1,29 +1,33 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* for server_replication.php
|
||||
* @fileoverview Javascript functions used in server replication page
|
||||
* @name Server Replication
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @requires js/functions.js
|
||||
*/
|
||||
|
||||
var random_server_id = Math.floor(Math.random() * 10000000);
|
||||
var conf_prefix = 'server-id=' + random_server_id + '\nlog_bin=mysql-bin\nlog_error=mysql-bin.err\n';
|
||||
var randomServerId = Math.floor(Math.random() * 10000000);
|
||||
var confPrefix = 'server-id=' + randomServerId + '\nlog_bin=mysql-bin\nlog_error=mysql-bin.err\n';
|
||||
|
||||
function update_config () {
|
||||
var conf_ignore = 'binlog_ignore_db=';
|
||||
var conf_do = 'binlog_do_db=';
|
||||
var database_list = '';
|
||||
function updateConfig () {
|
||||
var confIgnore = 'binlog_ignore_db=';
|
||||
var confDo = 'binlog_do_db=';
|
||||
var databaseList = '';
|
||||
|
||||
if ($('#db_select option:selected').size() === 0) {
|
||||
$('#rep').text(conf_prefix);
|
||||
if ($('#db_select option:selected').length === 0) {
|
||||
$('#rep').text(confPrefix);
|
||||
} else if ($('#db_type option:selected').val() === 'all') {
|
||||
$('#db_select option:selected').each(function () {
|
||||
database_list += conf_ignore + $(this).val() + '\n';
|
||||
databaseList += confIgnore + $(this).val() + '\n';
|
||||
});
|
||||
$('#rep').text(conf_prefix + database_list);
|
||||
$('#rep').text(confPrefix + databaseList);
|
||||
} else {
|
||||
$('#db_select option:selected').each(function () {
|
||||
database_list += conf_do + $(this).val() + '\n';
|
||||
databaseList += confDo + $(this).val() + '\n';
|
||||
});
|
||||
$('#rep').text(conf_prefix + database_list);
|
||||
$('#rep').text(confPrefix + databaseList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,44 +49,44 @@ AJAX.registerTeardown('replication.js', function () {
|
||||
});
|
||||
|
||||
AJAX.registerOnload('replication.js', function () {
|
||||
$('#rep').text(conf_prefix);
|
||||
$('#db_type').change(update_config);
|
||||
$('#db_select').change(update_config);
|
||||
$('#rep').text(confPrefix);
|
||||
$('#db_type').on('change', updateConfig);
|
||||
$('#db_select').on('change', updateConfig);
|
||||
|
||||
$('#master_status_href').click(function () {
|
||||
$('#master_status_href').on('click', function () {
|
||||
$('#replication_master_section').toggle();
|
||||
});
|
||||
$('#master_slaves_href').click(function () {
|
||||
$('#master_slaves_href').on('click', function () {
|
||||
$('#replication_slaves_section').toggle();
|
||||
});
|
||||
$('#slave_status_href').click(function () {
|
||||
$('#slave_status_href').on('click', function () {
|
||||
$('#replication_slave_section').toggle();
|
||||
});
|
||||
$('#slave_control_href').click(function () {
|
||||
$('#slave_control_href').on('click', function () {
|
||||
$('#slave_control_gui').toggle();
|
||||
});
|
||||
$('#slave_errormanagement_href').click(function () {
|
||||
$('#slave_errormanagement_href').on('click', function () {
|
||||
$('#slave_errormanagement_gui').toggle();
|
||||
});
|
||||
$('#slave_synchronization_href').click(function () {
|
||||
$('#slave_synchronization_href').on('click', function () {
|
||||
$('#slave_synchronization_gui').toggle();
|
||||
});
|
||||
$('#db_reset_href').click(function () {
|
||||
$('#db_reset_href').on('click', function () {
|
||||
$('#db_select option:selected').prop('selected', false);
|
||||
$('#db_select').trigger('change');
|
||||
});
|
||||
$('#db_select_href').click(function () {
|
||||
$('#db_select_href').on('click', function () {
|
||||
$('#db_select option').prop('selected', true);
|
||||
$('#db_select').trigger('change');
|
||||
});
|
||||
$('#reset_slave').click(function (e) {
|
||||
$('#reset_slave').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $anchor = $(this);
|
||||
var question = PMA_messages.strResetSlaveWarning;
|
||||
$anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
|
||||
PMA_ajaxShowMessage();
|
||||
var question = Messages.strResetSlaveWarning;
|
||||
$anchor.confirm(question, $anchor.attr('href'), function (url) {
|
||||
Functions.ajaxShowMessage();
|
||||
AJAX.source = $anchor;
|
||||
var params = getJSConfirmCommonParam({
|
||||
var params = Functions.getJsConfirmCommonParam({
|
||||
'ajax_page_request': true,
|
||||
'ajax_request': true
|
||||
}, $anchor.getPostData());
|
||||
|
||||
237
js/rte.js
237
js/rte.js
@ -13,7 +13,7 @@ var RTE = {
|
||||
* Construct for the object that provides the
|
||||
* functionality for Routines, Triggers and Events
|
||||
*/
|
||||
object: function (type) {
|
||||
Object: function (type) {
|
||||
$.extend(this, RTE.COMMON);
|
||||
this.editorType = type;
|
||||
|
||||
@ -31,10 +31,11 @@ var RTE = {
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @var string param_template Template for a row in the routine editor
|
||||
* @var {string} paramTemplate Template for a row in the routine editor
|
||||
*/
|
||||
param_template: ''
|
||||
paramTemplate: ''
|
||||
};
|
||||
|
||||
/**
|
||||
@ -77,8 +78,8 @@ RTE.COMMON = {
|
||||
// and the definition must be provided for an item
|
||||
$elm = $('table.rte_table').last().find('input[name=item_name]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.focus();
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
$elm = $('table.rte_table').find('textarea[name=item_definition]');
|
||||
@ -86,9 +87,9 @@ RTE.COMMON = {
|
||||
if (this.syntaxHiglighter !== null) {
|
||||
this.syntaxHiglighter.focus();
|
||||
} else {
|
||||
$('textarea[name=item_definition]').last().focus();
|
||||
$('textarea[name=item_definition]').last().trigger('focus');
|
||||
}
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
// The validation has so far passed, so now
|
||||
@ -114,25 +115,25 @@ RTE.COMMON = {
|
||||
}, // end postDialogShow()
|
||||
|
||||
exportDialog: function ($this) {
|
||||
var $msg = PMA_ajaxShowMessage();
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
if ($this.hasClass('mult_submit')) {
|
||||
var combined = {
|
||||
success: true,
|
||||
title: PMA_messages.strExport,
|
||||
title: Messages.strExport,
|
||||
message: '',
|
||||
error: ''
|
||||
};
|
||||
// export anchors of all selected rows
|
||||
var export_anchors = $('input.checkall:checked').parents('tr').find('.export_anchor');
|
||||
var count = export_anchors.length;
|
||||
var exportAnchors = $('input.checkall:checked').parents('tr').find('.export_anchor');
|
||||
var count = exportAnchors.length;
|
||||
var returnCount = 0;
|
||||
|
||||
// No routine is exportable (due to privilege issues)
|
||||
if (count === 0) {
|
||||
PMA_ajaxShowMessage(PMA_messages.NoExportable);
|
||||
Functions.ajaxShowMessage(Messages.NoExportable);
|
||||
}
|
||||
|
||||
export_anchors.each(function () {
|
||||
exportAnchors.each(function () {
|
||||
$.get($(this).attr('href'), { 'ajax_request': true }, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
@ -153,17 +154,17 @@ RTE.COMMON = {
|
||||
} else {
|
||||
$.get($this.attr('href'), { 'ajax_request': true }, showExport);
|
||||
}
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
|
||||
function showExport (data) {
|
||||
if (data.success === true) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
/**
|
||||
* @var button_options Object containing options
|
||||
* for jQueryUI dialog buttons
|
||||
*/
|
||||
var button_options = {};
|
||||
button_options[PMA_messages.strClose] = function () {
|
||||
var buttonOptions = {};
|
||||
buttonOptions[Messages.strClose] = function () {
|
||||
$(this).dialog('close').remove();
|
||||
};
|
||||
/**
|
||||
@ -172,7 +173,7 @@ RTE.COMMON = {
|
||||
data.message = '<textarea cols="40" rows="15" class="all100">' + data.message + '</textarea>';
|
||||
var $ajaxDialog = $('<div>' + data.message + '</div>').dialog({
|
||||
width: 500,
|
||||
buttons: button_options,
|
||||
buttons: buttonOptions,
|
||||
title: data.title
|
||||
});
|
||||
// Attach syntax highlighted editor to export dialog
|
||||
@ -181,38 +182,38 @@ RTE.COMMON = {
|
||||
* to the Export textarea.
|
||||
*/
|
||||
var $elm = $ajaxDialog.find('textarea');
|
||||
PMA_getSQLEditor($elm);
|
||||
Functions.getSqlEditor($elm);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
} // end showExport()
|
||||
}, // end exportDialog()
|
||||
editorDialog: function (is_new, $this) {
|
||||
editorDialog: function (isNew, $this) {
|
||||
var that = this;
|
||||
/**
|
||||
* @var $edit_row jQuery object containing the reference to
|
||||
* the row of the the item being edited
|
||||
* from the list of items
|
||||
*/
|
||||
var $edit_row = null;
|
||||
var $editRow = null;
|
||||
if ($this.hasClass('edit_anchor')) {
|
||||
// Remeber the row of the item being edited for later,
|
||||
// so that if the edit is successful, we can replace the
|
||||
// row with info about the modified item.
|
||||
$edit_row = $this.parents('tr');
|
||||
$editRow = $this.parents('tr');
|
||||
}
|
||||
/**
|
||||
* @var $msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = PMA_ajaxShowMessage();
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
$.get($this.attr('href'), { 'ajax_request': true }, function (data) {
|
||||
if (data.success === true) {
|
||||
// We have successfully fetched the editor form
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// Now define the function that is called when
|
||||
// the user presses the "Go" button
|
||||
that.buttonOptions[PMA_messages.strGo] = function () {
|
||||
that.buttonOptions[Messages.strGo] = function () {
|
||||
// Move the data from the codemirror editor back to the
|
||||
// textarea, where it can be used in the form submission.
|
||||
if (typeof CodeMirror !== 'undefined') {
|
||||
@ -224,20 +225,20 @@ RTE.COMMON = {
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $('form.rte_form').last().serialize();
|
||||
$msg = PMA_ajaxShowMessage(
|
||||
PMA_messages.strProcessingRequest
|
||||
$msg = Functions.ajaxShowMessage(
|
||||
Messages.strProcessingRequest
|
||||
);
|
||||
var url = $('form.rte_form').last().attr('action');
|
||||
$.post(url, data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Item created successfully
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
PMA_slidingMessage(data.message);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
that.$ajaxDialog.dialog('close');
|
||||
// If we are in 'edit' mode, we must
|
||||
// remove the reference to the old row.
|
||||
if (mode === 'edit' && $edit_row !== null) {
|
||||
$edit_row.remove();
|
||||
if (mode === 'edit' && $editRow !== null) {
|
||||
$editRow.remove();
|
||||
}
|
||||
// Sometimes, like when moving a trigger from
|
||||
// a table to another one, the new row should
|
||||
@ -320,14 +321,14 @@ RTE.COMMON = {
|
||||
$('table.data').show('slow');
|
||||
});
|
||||
}
|
||||
PMA_reloadNavigation();
|
||||
Navigation.reload();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
} // end "if (that.validate())"
|
||||
}; // end of function that handles the submission of the Editor
|
||||
that.buttonOptions[PMA_messages.strClose] = function () {
|
||||
that.buttonOptions[Messages.strClose] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
/**
|
||||
@ -344,12 +345,12 @@ RTE.COMMON = {
|
||||
if ($('#rteDialog').parents('.ui-dialog').height() > $(window).height()) {
|
||||
$('#rteDialog').dialog('option', 'height', $(window).height());
|
||||
}
|
||||
$(this).find('input[name=item_name]').focus();
|
||||
$(this).find('input[name=item_name]').trigger('focus');
|
||||
$(this).find('input.datefield').each(function () {
|
||||
PMA_addDatepicker($(this).css('width', '95%'), 'date');
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'date');
|
||||
});
|
||||
$(this).find('input.datetimefield').each(function () {
|
||||
PMA_addDatepicker($(this).css('width', '95%'), 'datetime');
|
||||
Functions.addDatepicker($(this).css('width', '95%'), 'datetime');
|
||||
});
|
||||
$.datepicker.initialized = false;
|
||||
},
|
||||
@ -373,12 +374,12 @@ RTE.COMMON = {
|
||||
var $elm = $('textarea[name=item_definition]').last();
|
||||
var linterOptions = {};
|
||||
linterOptions[that.editorType + '_editor'] = true;
|
||||
that.syntaxHiglighter = PMA_getSQLEditor($elm, {}, null, linterOptions);
|
||||
that.syntaxHiglighter = Functions.getSqlEditor($elm, {}, null, linterOptions);
|
||||
|
||||
// Execute item-specific code
|
||||
that.postDialogShow(data);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
},
|
||||
@ -387,28 +388,28 @@ RTE.COMMON = {
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $curr_row = $this.parents('tr');
|
||||
var $currRow = $this.parents('tr');
|
||||
/**
|
||||
* @var question String containing the question to be asked for confirmation
|
||||
*/
|
||||
var question = $('<div/>').text(
|
||||
$curr_row.children('td').children('.drop_sql').html()
|
||||
var question = $('<div></div>').text(
|
||||
$currRow.children('td').children('.drop_sql').html()
|
||||
);
|
||||
// We ask for confirmation first here, before submitting the ajax request
|
||||
$this.PMA_confirm(question, $this.attr('href'), function (url) {
|
||||
$this.confirm(question, $this.attr('href'), function (url) {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
var params = getJSConfirmCommonParam(this, $this.getPostData());
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
var params = Functions.getJsConfirmCommonParam(this, $this.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success === true) {
|
||||
/**
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $curr_row.parent();
|
||||
var $table = $currRow.parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
@ -422,7 +423,7 @@ RTE.COMMON = {
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$curr_row.hide('slow', function () {
|
||||
$currRow.hide('slow', function () {
|
||||
$(this).remove();
|
||||
// Now we have removed the row from the list, but maybe
|
||||
// some row classes are wrong now. So we will itirate
|
||||
@ -444,39 +445,39 @@ RTE.COMMON = {
|
||||
});
|
||||
}
|
||||
// Get rid of the "Loading" message
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// Show the query that we just executed
|
||||
PMA_slidingMessage(data.sql_query);
|
||||
PMA_reloadNavigation();
|
||||
Functions.slidingMessage(data.sql_query);
|
||||
Navigation.reload();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end $.PMA_confirm()
|
||||
});
|
||||
},
|
||||
|
||||
dropMultipleDialog: function ($this) {
|
||||
// We ask for confirmation here
|
||||
$this.PMA_confirm(PMA_messages.strDropRTEitems, '', function (url) {
|
||||
$this.confirm(Messages.strDropRTEitems, '', function () {
|
||||
/**
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
|
||||
|
||||
// drop anchors of all selected rows
|
||||
var drop_anchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
|
||||
var dropAnchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
|
||||
var success = true;
|
||||
var count = drop_anchors.length;
|
||||
var count = dropAnchors.length;
|
||||
var returnCount = 0;
|
||||
|
||||
drop_anchors.each(function () {
|
||||
dropAnchors.each(function () {
|
||||
var $anchor = $(this);
|
||||
/**
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $curr_row = $anchor.parents('tr');
|
||||
var params = getJSConfirmCommonParam(this, $anchor.getPostData());
|
||||
var $currRow = $anchor.parents('tr');
|
||||
var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData());
|
||||
$.post($anchor.attr('href'), params, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
@ -484,7 +485,7 @@ RTE.COMMON = {
|
||||
* @var $table Object containing reference
|
||||
* to the main list of elements
|
||||
*/
|
||||
var $table = $curr_row.parent();
|
||||
var $table = $currRow.parent();
|
||||
// Check how many rows will be left after we remove
|
||||
// the one that the user has requested us to remove
|
||||
if ($table.find('tr').length === 3) {
|
||||
@ -498,7 +499,7 @@ RTE.COMMON = {
|
||||
$('#nothing2display').show('slow');
|
||||
});
|
||||
} else {
|
||||
$curr_row.hide('fast', function () {
|
||||
$currRow.hide('fast', function () {
|
||||
$(this).remove();
|
||||
// Now we have removed the row from the list, but maybe
|
||||
// some row classes are wrong now. So we will itirate
|
||||
@ -522,21 +523,21 @@ RTE.COMMON = {
|
||||
if (returnCount === count) {
|
||||
if (success) {
|
||||
// Get rid of the "Loading" message
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
$('#rteListForm_checkall').prop({ checked: false, indeterminate: false });
|
||||
}
|
||||
PMA_reloadNavigation();
|
||||
Navigation.reload();
|
||||
}
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
success = false;
|
||||
if (returnCount === count) {
|
||||
PMA_reloadNavigation();
|
||||
Navigation.reload();
|
||||
}
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end drop_anchors.each()
|
||||
}); // end $.PMA_confirm()
|
||||
});
|
||||
}
|
||||
}; // end RTE namespace
|
||||
|
||||
@ -554,16 +555,16 @@ RTE.EVENT = {
|
||||
// The interval field must not be empty for recurring events
|
||||
$elm = this.$ajaxDialog.find('input[name=item_interval_value]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.focus();
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// The execute_at field must not be empty for "once off" events
|
||||
$elm = this.$ajaxDialog.find('input[name=item_execute_at]');
|
||||
if ($elm.val() === '') {
|
||||
$elm.focus();
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
$elm.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -582,7 +583,7 @@ RTE.ROUTINE = {
|
||||
*/
|
||||
postDialogShow: function (data) {
|
||||
// Cache the template for a parameter table row
|
||||
RTE.param_template = data.param_template;
|
||||
RTE.paramTemplate = data.paramTemplate;
|
||||
var that = this;
|
||||
// Make adjustments in the dialog to make it AJAX compatible
|
||||
$('td.routine_param_remove').show();
|
||||
@ -610,7 +611,7 @@ RTE.ROUTINE = {
|
||||
$('.routine_params_table tbody').sortable({
|
||||
containment: '.routine_params_table tbody',
|
||||
handle: '.dragHandle',
|
||||
stop: function (event, ui) {
|
||||
stop: function () {
|
||||
that.reindexParameters();
|
||||
},
|
||||
});
|
||||
@ -672,7 +673,7 @@ RTE.ROUTINE = {
|
||||
inputname.substr(0, 15) === 'item_param_name' ||
|
||||
inputname.substr(0, 15) === 'item_param_type') {
|
||||
if ($(this).val() === '') {
|
||||
$(this).focus();
|
||||
$(this).trigger('focus');
|
||||
isSuccess = false;
|
||||
return false;
|
||||
}
|
||||
@ -683,7 +684,7 @@ RTE.ROUTINE = {
|
||||
}
|
||||
});
|
||||
if (! isSuccess) {
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
this.$ajaxDialog.find('table.routine_params_table').last().find('tr').each(function () {
|
||||
@ -694,14 +695,14 @@ RTE.ROUTINE = {
|
||||
if (($inputtyp.val() === 'ENUM' || $inputtyp.val() === 'SET' || $inputtyp.val().substr(0, 3) === 'VAR') &&
|
||||
$inputlen.val() === ''
|
||||
) {
|
||||
$inputlen.focus();
|
||||
$inputlen.trigger('focus');
|
||||
isSuccess = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (! isSuccess) {
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
if (this.$ajaxDialog.find('select[name=item_type]').find(':selected').val() === 'FUNCTION') {
|
||||
@ -712,8 +713,8 @@ RTE.ROUTINE = {
|
||||
if (($returntyp.val() === 'ENUM' || $returntyp.val() === 'SET' || $returntyp.val().substr(0, 3) === 'VAR') &&
|
||||
$returnlen.val() === ''
|
||||
) {
|
||||
$returnlen.focus();
|
||||
alert(PMA_messages.strFormEmpty);
|
||||
$returnlen.trigger('focus');
|
||||
alert(Messages.strFormEmpty);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -721,7 +722,7 @@ RTE.ROUTINE = {
|
||||
// A function must contain a RETURN statement in its definition
|
||||
if (this.$ajaxDialog.find('table.rte_table').find('textarea[name=item_definition]').val().toUpperCase().indexOf('RETURN') < 0) {
|
||||
this.syntaxHiglighter.focus();
|
||||
alert(PMA_messages.MissingReturn);
|
||||
alert(Messages.MissingReturn);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -749,13 +750,13 @@ RTE.ROUTINE = {
|
||||
* to an element to be displayed when no
|
||||
* options are available
|
||||
*/
|
||||
var $no_opts = $text.parent().parent().find('.no_opts');
|
||||
var $noOpts = $text.parent().parent().find('.no_opts');
|
||||
/**
|
||||
* @var no_len a jQuery object containing the reference
|
||||
* to an element to be displayed when no
|
||||
* "length/values" field is available
|
||||
*/
|
||||
var $no_len = $len.parent().parent().find('.no_len');
|
||||
var $noLen = $len.parent().parent().find('.no_len');
|
||||
|
||||
// Process for parameter options
|
||||
switch ($type.val()) {
|
||||
@ -770,7 +771,7 @@ RTE.ROUTINE = {
|
||||
case 'REAL':
|
||||
$text.parent().hide();
|
||||
$num.parent().show();
|
||||
$no_opts.hide();
|
||||
$noOpts.hide();
|
||||
break;
|
||||
case 'TINYTEXT':
|
||||
case 'TEXT':
|
||||
@ -782,12 +783,12 @@ RTE.ROUTINE = {
|
||||
case 'ENUM':
|
||||
$text.parent().show();
|
||||
$num.parent().hide();
|
||||
$no_opts.hide();
|
||||
$noOpts.hide();
|
||||
break;
|
||||
default:
|
||||
$text.parent().hide();
|
||||
$num.parent().hide();
|
||||
$no_opts.show();
|
||||
$noOpts.show();
|
||||
break;
|
||||
}
|
||||
// Process for parameter length
|
||||
@ -803,7 +804,7 @@ RTE.ROUTINE = {
|
||||
case 'LONGTEXT':
|
||||
$text.closest('tr').find('a:first').hide();
|
||||
$len.parent().hide();
|
||||
$no_len.show();
|
||||
$noLen.show();
|
||||
break;
|
||||
default:
|
||||
if ($type.val() === 'ENUM' || $type.val() === 'SET') {
|
||||
@ -812,7 +813,7 @@ RTE.ROUTINE = {
|
||||
$text.closest('tr').find('a:first').hide();
|
||||
}
|
||||
$len.parent().show();
|
||||
$no_len.hide();
|
||||
$noLen.hide();
|
||||
break;
|
||||
}
|
||||
},
|
||||
@ -822,37 +823,37 @@ RTE.ROUTINE = {
|
||||
* @var msg jQuery object containing the reference to
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = PMA_ajaxShowMessage();
|
||||
var params = getJSConfirmCommonParam($this[0], $this.getPostData());
|
||||
var $msg = Functions.ajaxShowMessage();
|
||||
var params = Functions.getJsConfirmCommonParam($this[0], $this.getPostData());
|
||||
$.post($this.attr('href'), params, function (data) {
|
||||
if (data.success === true) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
// If 'data.dialog' is true we show a dialog with a form
|
||||
// to get the input parameters for routine, otherwise
|
||||
// we just show the results of the query
|
||||
if (data.dialog) {
|
||||
// Define the function that is called when
|
||||
// the user presses the "Go" button
|
||||
that.buttonOptions[PMA_messages.strGo] = function () {
|
||||
that.buttonOptions[Messages.strGo] = function () {
|
||||
/**
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $('form.rte_form').last().serialize();
|
||||
$msg = PMA_ajaxShowMessage(
|
||||
PMA_messages.strProcessingRequest
|
||||
$msg = Functions.ajaxShowMessage(
|
||||
Messages.strProcessingRequest
|
||||
);
|
||||
$.post('db_routines.php', data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Routine executed successfully
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
PMA_slidingMessage(data.message);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
$ajaxDialog.dialog('close');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
};
|
||||
that.buttonOptions[PMA_messages.strClose] = function () {
|
||||
that.buttonOptions[Messages.strClose] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
/**
|
||||
@ -867,12 +868,12 @@ RTE.ROUTINE = {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
$ajaxDialog.find('input[name^=params]').first().focus();
|
||||
$ajaxDialog.find('input[name^=params]').first().trigger('focus');
|
||||
/**
|
||||
* Attach the datepickers to the relevant form fields
|
||||
*/
|
||||
$ajaxDialog.find('input.datefield, input.datetimefield').each(function () {
|
||||
PMA_addDatepicker($(this).css('width', '95%'));
|
||||
Functions.addDatepicker($(this).css('width', '95%'));
|
||||
});
|
||||
/*
|
||||
* Define the function if the user presses enter
|
||||
@ -884,29 +885,29 @@ RTE.ROUTINE = {
|
||||
* @var data Form data to be sent in the AJAX request
|
||||
*/
|
||||
var data = $(this).serialize();
|
||||
$msg = PMA_ajaxShowMessage(
|
||||
PMA_messages.strProcessingRequest
|
||||
$msg = Functions.ajaxShowMessage(
|
||||
Messages.strProcessingRequest
|
||||
);
|
||||
var url = $(this).attr('action');
|
||||
$.post(url, data, function (data) {
|
||||
if (data.success === true) {
|
||||
// Routine executed successfully
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
PMA_slidingMessage(data.message);
|
||||
Functions.ajaxRemoveMessage($msg);
|
||||
Functions.slidingMessage(data.message);
|
||||
$('form.rte_form').off('keyup');
|
||||
$ajaxDialog.remove();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Routine executed successfully
|
||||
PMA_slidingMessage(data.message);
|
||||
Functions.slidingMessage(data.message);
|
||||
}
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
Functions.ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}); // end $.post()
|
||||
}
|
||||
@ -931,7 +932,7 @@ $(function () {
|
||||
} else {
|
||||
type = '';
|
||||
}
|
||||
var dialog = new RTE.object(type);
|
||||
var dialog = new RTE.Object(type);
|
||||
dialog.editorDialog($(this).hasClass('add_anchor'), $(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
@ -940,7 +941,7 @@ $(function () {
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.exec_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
var dialog = new RTE.object('routine');
|
||||
var dialog = new RTE.Object('routine');
|
||||
dialog.executeDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
@ -949,13 +950,13 @@ $(function () {
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.export_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
var dialog = new RTE.object();
|
||||
var dialog = new RTE.Object();
|
||||
dialog.exportDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
$(document).on('click', '#rteListForm.ajax .mult_submit[value="export"]', function (event) {
|
||||
event.preventDefault();
|
||||
var dialog = new RTE.object();
|
||||
var dialog = new RTE.Object();
|
||||
dialog.exportDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
@ -965,13 +966,13 @@ $(function () {
|
||||
*/
|
||||
$(document).on('click', 'a.ajax.drop_anchor', function (event) {
|
||||
event.preventDefault();
|
||||
var dialog = new RTE.object();
|
||||
var dialog = new RTE.Object();
|
||||
dialog.dropDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
$(document).on('click', '#rteListForm.ajax .mult_submit[value="drop"]', function (event) {
|
||||
event.preventDefault();
|
||||
var dialog = new RTE.object();
|
||||
var dialog = new RTE.Object();
|
||||
dialog.dropMultipleDialog($(this));
|
||||
}); // end $(document).on()
|
||||
|
||||
@ -999,7 +1000,7 @@ $(function () {
|
||||
* a row in the routine parameters table
|
||||
*/
|
||||
var $row = $(this).parents('tr').first();
|
||||
var rte = new RTE.object('routine');
|
||||
var rte = new RTE.Object('routine');
|
||||
rte.setOptionsForParameter(
|
||||
$row.find('select[name^=item_param_type]'),
|
||||
$row.find('input[name^=item_param_length]'),
|
||||
@ -1014,7 +1015,7 @@ $(function () {
|
||||
* if any, are shown when changing the function return type type
|
||||
*/
|
||||
$(document).on('change', 'select[name=item_returntype]', function () {
|
||||
var rte = new RTE.object('routine');
|
||||
var rte = new RTE.Object('routine');
|
||||
var $table = $(this).closest('table.rte_table');
|
||||
rte.setOptionsForParameter(
|
||||
$table.find('select[name=item_returntype]'),
|
||||
@ -1033,14 +1034,14 @@ $(function () {
|
||||
* @var routine_params_table jQuery object containing the reference
|
||||
* to the routine parameters table
|
||||
*/
|
||||
var $routine_params_table = $(this).closest('div.ui-dialog').find('.routine_params_table');
|
||||
var $routineParamsTable = $(this).closest('div.ui-dialog').find('.routine_params_table');
|
||||
/**
|
||||
* @var new_param_row A string containing the HTML code for the
|
||||
* new row for the routine parameters table
|
||||
*/
|
||||
var new_param_row = RTE.param_template.replace(/%s/g, $routine_params_table.find('tr').length - 1);
|
||||
var newParamRow = RTE.paramTemplate.replace(/%s/g, $routineParamsTable.find('tr').length - 1);
|
||||
// Append the new row to the parameters table
|
||||
$routine_params_table.append(new_param_row);
|
||||
$routineParamsTable.append(newParamRow);
|
||||
// Make sure that the row is correctly shown according to the type of routine
|
||||
if ($(this).closest('div.ui-dialog').find('table.rte_table select[name=item_type]').val() === 'FUNCTION') {
|
||||
$('tr.routine_return_row').show();
|
||||
@ -1052,7 +1053,7 @@ $(function () {
|
||||
*/
|
||||
var $newrow = $(this).closest('div.ui-dialog').find('table.routine_params_table').find('tr').has('td').last();
|
||||
// Enable/disable the 'options' dropdowns for parameters as necessary
|
||||
var rte = new RTE.object('routine');
|
||||
var rte = new RTE.Object('routine');
|
||||
rte.setOptionsForParameter(
|
||||
$newrow.find('select[name^=item_param_type]'),
|
||||
$newrow.find('input[name^=item_param_length]'),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user