diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/config.inc.php | 8 | ||||
-rw-r--r-- | tools/convert_language_to_2.1.pl | 184 | ||||
-rw-r--r-- | tools/convert_template_to_2.1.pl | 48 | ||||
-rw-r--r-- | tools/index.php | 2 | ||||
-rwxr-xr-x | tools/key2value.php | 126 | ||||
-rw-r--r-- | tools/metadata.php | 2 | ||||
-rw-r--r-- | tools/release_creation.readme | 50 | ||||
-rwxr-xr-x | tools/replace.php | 53 | ||||
-rw-r--r-- | tools/replace_language_keys.pl | 60 | ||||
-rw-r--r-- | tools/replace_language_values.pl | 61 | ||||
-rw-r--r-- | tools/translation_analysis.php | 2 | ||||
-rw-r--r-- | tools/triggers_list.php | 99 | ||||
-rw-r--r-- | tools/ws.htm | 251 |
13 files changed, 197 insertions, 749 deletions
diff --git a/tools/config.inc.php b/tools/config.inc.php deleted file mode 100644 index 6e74538fb..000000000 --- a/tools/config.inc.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -// this file is provided as an example. It does not modify the configuration -// as long as it remains in "tools" directory. Move it to "include" -// directory if you want to modify default configuration. - -$conf['prefix_thumbnail'] = 'thumb_'; -$conf['show_gt'] = true; -?>
\ No newline at end of file diff --git a/tools/convert_language_to_2.1.pl b/tools/convert_language_to_2.1.pl deleted file mode 100644 index b78547a33..000000000 --- a/tools/convert_language_to_2.1.pl +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/perl - -# Here is the way I finally used this script: -# -# for language in ar_SA cz_CZ da_DK de_DE es_AR es_ES hr_HR hu_HU it_IT ja_JP nl_NL pl_PL pt_BR pt_PT ru_RU sr_RS vi_VN zh_CN -# do -# export PWG_LANG=$language -# rm -rf language/$PWG_LANG -# cp -r ../branches/2.0/language/$PWG_LANG language/ -# perl tools/convert_language_to_2.1.pl language/$PWG_LANG -# done - -use strict; -use warnings; - -my $language_dir = $ARGV[0]; - -my @file_codes = qw/upgrade install admin common/; - -my %ignore_keys = ( - 'user_status_admin' => '', - 'user_status_generic' => '', - 'user_status_guest' => '', - 'user_status_normal' => '', - 'user_status_webmaster' => '', - 'Level 0' => '', - 'Level 1' => '', - 'Level 2' => '', - 'Level 4' => '', - 'Level 8' => '', - 'ACCESS_0' => '', - 'ACCESS_1' => '', - 'ACCESS_2' => '', - 'ACCESS_3' => '', - 'ACCESS_4' => '', - 'ACCESS_5' => '', - 'month' => '', - 'day' => '', - 'chronology_monthly_calendar' => '', - 'chronology_monthly_list' => '', - 'chronology_weekly_list' => '', -); - -my %remove_keys = ( - common => { - "You can\\'t upload pictures in this category" => '', - 'display pictures added on' => '', - 'Email address is missing' => '', - 'Delete: %s' => '', - 'All tags must match' => '', - 'Validate: %s' => '', - 'Upgrade from %s to %s' => '', - }, - admin => { - 'nbm_content_goto_2' => '', - 'nbm_content_hello_2' => '', - 'nbm_redirect_msg' => '', - - 'username' => '', - 'No tag defined. Use Administration>Pictures>Tags' => '', - 'Remote site url must start by http or https and must only contain characters among "/", "a-zA-Z0-9", "-" or "_"' => '', - 'path' => '', - 'Unable to retrieve server informations since allow_url_fopen is disabled.' => '', - 'The following tag were deleted' => '', - 'Remote site' => '', - 'Piwigo home' => '', - 'Move up' => '', - 'Instructions' => '', - 'Hits' => '', - 'General' => '', - 'Gallery description' => '', - 'Extensions' => '', - 'Demo' => '', - 'Categories ascending alphanumerically ordered' => '', - 'Categories descending alphanumerically ordered' => '', - 'Categories sorted in ascending order ⇓' => '', - 'Categories sorted in ascending order ⇓' => '', - 'Categories sorted in descending order ⇑' => '', - 'Categories sorted in descending order ⇑' => '', - 'Bugs' => '', - 'Automatic installation' => '', - 'Upgrade from version %s to %s' => '', - 'Upgrade from %s to %s' => '', - 'Upload Form' => '', - }, - upgrade => { - 'Are you sure?' => '', - 'In <i>%s</i>, before <b>?></b>, insert:' => '', - }, - install => { - 'Parameters are correct' => '', - 'Installation finished' => '', - 'The next step of the installation is now possible' => '', - 'next step' => '', - } -); - -my %to_copy = (); - -# load the replacements -my %replace_by = (); -foreach my $file_code (@file_codes) { - open(my $ifh_rep, '<language/templates/'.$file_code.'.lang.php'); - while (<$ifh_rep>) { - if (m/^\$lang\['(.*)'\] \s* = \s* (['"])(.*)\2;/x) { - if ($1 ne $3 and length($1) > 0) { - $replace_by{$1} = $3; - } - } - } -} -# use Data::Dumper; print Dumper(\%replace_by); exit(); - -my $append_to_common = ''; - -foreach my $file_code (@file_codes) { - my $filename = $language_dir.'/'.$file_code.'.lang.php'; - print $filename; - if (not -f $filename) { - print ' is missing', "\n"; - next; - } - print ' is under process', "\n"; - - if ($file_code eq 'admin') { - %to_copy = ( - 'Are you sure?' => '', - 'Email address is missing. Please specify an email address.' => '', - 'delete this comment' => '', - 'validate this comment' => '', - ); - } - else { - %to_copy = (); - } - - my $file_content = ''; - my $copy_content = ''; - - open(my $ifh, '<'.$language_dir.'/'.$file_code.'.lang.php'); - while (my $line = <$ifh>) { - if ($line =~ m/^\$lang\['(.*)'\] \s* =/x) { - if (defined $remove_keys{$file_code}{$1}) { - next; - } - elsif (defined $ignore_keys{$1}) { - $file_content.= $line; - } - elsif (defined $to_copy{$1}) { - $append_to_common.= $line; - } - elsif (defined $replace_by{$1}) { - my $search = quotemeta($1); - my $replace = $replace_by{$1}; - - $line =~ s{$search}{$replace}; - - if (defined $to_copy{$replace}) { - $append_to_common.= $line; - } - else { - $file_content.= $line; - } - } - else { - $file_content.= $line; - } - } - elsif ($line =~ m/^?>/) { - if ('common' eq $file_code) { - $file_content.= $append_to_common; - } - $file_content.= $line; - } - else { - $file_content.= $line; - } - } - close($ifh); - - open(my $ofh, '>'.$language_dir.'/'.$file_code.'.lang.php'); - print {$ofh} $file_content; - close($ofh); -} diff --git a/tools/convert_template_to_2.1.pl b/tools/convert_template_to_2.1.pl deleted file mode 100644 index a838e8f8b..000000000 --- a/tools/convert_template_to_2.1.pl +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/perl - -# perl tools/convert_template_to_2.1.pl /path/to/tpl/files/directory - -use strict; -use warnings; - -use File::Find; - -my $base_dir = $ARGV[0]; - -# load the replacements -my @file_codes = qw/upgrade install admin common/; -my %replace_by = (); -foreach my $file_code (@file_codes) { - open(my $ifh_rep, '<language/templates/'.$file_code.'.lang.php'); - while (<$ifh_rep>) { - if (m/^\$lang\['(.*)'\] \s* = \s* (['"])(.*)\2;/x) { - if ($1 ne $3 and length($1) > 0) { - $replace_by{$1} = $3; - } - } - } -} -# use Data::Dumper; print Dumper(\%replace_by); exit(); - -find(\&replace_keys, $base_dir); - -sub replace_keys { - if ($File::Find::name !~ m/tpl$/) { - return 0; - } - - my $file_content = ''; - open(my $fhi, '<', $File::Find::name); - while (<$fhi>) { - foreach my $from (keys %replace_by) { - my $to = $replace_by{$from}; - s/{'$from'\|\@translate/{'$to'|\@translate/g; - } - $file_content.= $_; - } - close($fhi); - - open(my $fho, '>', $File::Find::name); - print {$fho} $file_content; - close($fho); -} diff --git a/tools/index.php b/tools/index.php index 41732f2fd..c8de97f60 100644 --- a/tools/index.php +++ b/tools/index.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | // +-----------------------------------------------------------------------+ diff --git a/tools/key2value.php b/tools/key2value.php deleted file mode 100755 index cda02d9bc..000000000 --- a/tools/key2value.php +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/php -qn -<?php -if (isset($_SERVER['argc']) && $_SERVER['argc']<=1) -{ - help(); -} - -$language = trim($_SERVER['argv'][1]); -if (!is_dir("language/$language")) -{ - help(); -} - -$Files = array('common', 'admin', 'install', 'upgrade'); -$exclude_keys = array('user_status_admin', 'user_status_generic', - 'user_status_guest', 'user_status_normal', - 'user_status_webmaster', 'Level 0', - 'Level 1', 'Level 2', 'Level 4', 'Level 8', - 'chronology_monthly_calendar', 'chronology_monthly_list', - 'chronology_weekly_list'); - -foreach ($Files as $file) -{ - $lang_file = sprintf('language/%s/%s.lang.php', $language, $file); - $en_file = sprintf('language/en_UK/%s.lang.php', $file); - include $lang_file; - $source_lang = $lang; - unset($lang); - include $en_file; - - try - { - $fh = fopen($lang_file, 'w+'); - - fwrite($fh, copyright()); - - if ($file == 'common') - { - foreach ($lang_info as $key => $value) - { - fwrite($fh, sprintf("\$lang_info['%s'] = \"%s\";\n", - $key, - $value - ) - ); - } - } - fwrite($fh, "\n\n"); - - foreach ($lang as $key => $value) - { - if (is_array($value)) - { - foreach ($value as $k => $v) - { - fwrite($fh, sprintf("\$lang['%s'][%s] = \"%s\";\n", - str_replace("'", "\'", trim($key)), - trim($k), - str_replace('"', '\"', trim($source_lang[$key][$k])) - ) - ); - } - } - elseif (in_array($key, $exclude_keys)) - { - fwrite($fh, sprintf("\$lang['%s'] = \"%s\";\n", - str_replace("'", "\'", trim($key)), - str_replace('"', '\"', trim($source_lang[$key])) - ) - ); - } - else - { - fwrite($fh, sprintf("\$lang['%s'] = \"%s\";\n", - str_replace("'", "\'", trim($value)), - str_replace('"', '\"', trim($source_lang[$key])) - ) - ); - } - } - fwrite($fh, '?>'); - fclose($fh); - } - catch (Exception $e) - { - print $e->getMessage(); - } -} - -function help() -{ - echo "\n"; - echo 'usage : ', basename($_SERVER['argv'][0]), " <LANGUAGE CODE>\n"; - echo "\n"; - exit(1); -} - -function copyright() -{ - return -'<?php -// +-----------------------------------------------------------------------+ -// | Piwigo - a PHP based photo gallery | -// +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | -// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | -// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | -// +-----------------------------------------------------------------------+ -// | This program is free software; you can redistribute it and/or modify | -// | it under the terms of the GNU General Public License as published by | -// | the Free Software Foundation | -// | | -// | This program is distributed in the hope that it will be useful, but | -// | WITHOUT ANY WARRANTY; without even the implied warranty of | -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | -// | General Public License for more details. | -// | | -// | You should have received a copy of the GNU General Public License | -// | along with this program; if not, write to the Free Software | -// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | -// | USA. | -// +-----------------------------------------------------------------------+ - -'; -} -?>
\ No newline at end of file diff --git a/tools/metadata.php b/tools/metadata.php index 16e2a2bb7..c0b390f43 100644 --- a/tools/metadata.php +++ b/tools/metadata.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | // +-----------------------------------------------------------------------+ diff --git a/tools/release_creation.readme b/tools/release_creation.readme deleted file mode 100644 index a8b4f6f52..000000000 --- a/tools/release_creation.readme +++ /dev/null @@ -1,50 +0,0 @@ -===================================== - Piwigo release creation guide -===================================== - -Technical creation -================== - -I take release 1.7.0 as an example. In URLs "plg" is my personnal Gna! -username, so use yours. - -- tag creation tags/release-1_7_0 : - -$ svn copy \ - -r 1999 \ - -m "Create release 1.7.0 from branch 1.7 r1999" \ - svn+ssh://plg@svn.gna.org/svn/phpwebgallery/branch/branch-1_7 \ - svn+ssh://plg@svn.gna.org/svn/phpwebgallery/tags/release-1_7_0 - -- checkout new Subversion release 1.7.0 - -$ svn co svn+ssh://plg@svn.gna.org/svn/phpwebgallery/tags/release-1_7_0 1.7.0 -$ cd 1.7.0 - -- in include/config_default.inc.php, change the following parameters: - - $conf['check_upgrade_feed'] = false; - - $conf['show_version'] = false; - - $conf['show_gt'] = false; - - $conf['die_on_sql_error'] = false; - -- in include/constants.php, change the PHPWG_VERSION to 1.7.0 - -- commit your changes to tags/release-1_7_0, with the following comment: - -> New version 1.7.0 hard coded. -> -> Stable release required modifications: don't show version and generation -> time in footer, don't check the upgrade feed, don't die on sql errors. - -$ svn commit - -- create the release (pwg_rel_create.sh is in tools directory) - -$ mkdir /tmp/1.7.0 -$ cd /tmp/1.7.0 -$ pwg_rel_create.sh release-1_7_0 1.7.0 -$ md5sum p* > MD5SUMS - -- upload the release to Gna! download area - -$ scp -r /tmp/1.7.0 plg@download.gna.org:/upload/phpwebgallery/release/1.7/ diff --git a/tools/replace.php b/tools/replace.php deleted file mode 100755 index 0596ca064..000000000 --- a/tools/replace.php +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/php -qn -<?php -if (isset($_SERVER['argc']) && $_SERVER['argc']<=1) -{ - echo "\n"; - echo 'usage : ', basename($_SERVER['argv'][0]), " <filename>\n"; - echo "\n"; - exit(1); -} - -$filename = trim($_SERVER['argv'][1]); -$lines = file($filename); -$content = file_get_contents($filename); - -$n = 0; -$nbLines = count($lines); - -$pattern = "`(.*{')(.*)('\|@translate}.*)`Um"; -$replace = "'{\''.keyReplace('\\1').'\'|@translate}'"; - -include "language/templates/common.lang.php"; -include "language/templates/admin.lang.php"; -include "language/templates/upgrade.lang.php"; -include "language/templates/install.lang.php"; - -while ($n < $nbLines) { - preg_match_all($pattern, $lines[$n], $matches); - echo str_replace($matches[2], keyReplace($matches[2]), $lines[$n]); - $n++; -} - -function keyReplace($key) { - global $lang; - - if (is_array($key)) { - $translation = array(); - foreach ($key as $i => $k) { - if (isset($lang[$k])) { - $translation = addslashes($lang[$k]); - } else { - $translation = "$k"; - } - } - } else { - if (isset($lang[$key])) { - $translation = addslashes($lang[$key]); - } else { - $translation = "$key"; - } - } - return $translation; -} -?>
\ No newline at end of file diff --git a/tools/replace_language_keys.pl b/tools/replace_language_keys.pl deleted file mode 100644 index 822b3e1cc..000000000 --- a/tools/replace_language_keys.pl +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -my $replacement_file = $ARGV[0]; -my $language_dir = $ARGV[1]; - -# load the replacements -my %replace_by = (); -open(my $ifh_rep, '<'.$replacement_file); -while (<$ifh_rep>) { - if (m/^\$lang\['(.*)'\] \s* = \s* (['"])(.*)\2;/x) { - if ($1 ne $3 and length($1) > 0) { - $replace_by{$1} = $3; - } - } -} -# use Data::Dumper; print Dumper(\%replace_by); exit(); - -my $append_to_common = ''; - -foreach my $file_code (qw/upgrade install admin common plugin/) { - my $filename = $language_dir.'/'.$file_code.'.lang.php'; - # print $filename; - if (not -f $filename) { - # print ' is missing', "\n"; - next; - } - print $filename.' is under process', "\n"; - - my $file_content = ''; - - open(my $ifh, '<'.$filename); - while (my $line = <$ifh>) { - if ($line =~ m/^\$lang\['(.*)'\] \s* =/x) { - if (defined $replace_by{$1}) { - my $search = quotemeta($1); - my $replace = $replace_by{$1}; - - $line =~ s{$search}{$replace}; - $file_content.= $line; - } - else { - $file_content.= $line; - } - } - elsif ($line =~ m/^?>/) { - $file_content.= $line; - } - else { - $file_content.= $line; - } - } - close($ifh); - - open(my $ofh, '>'.$filename); - print {$ofh} $file_content; - close($ofh); -} diff --git a/tools/replace_language_values.pl b/tools/replace_language_values.pl deleted file mode 100644 index f901e1140..000000000 --- a/tools/replace_language_values.pl +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -my $replacement_file = $ARGV[0]; -my $language_dir = $ARGV[1]; - -# load the new values for given keys -my %new_value_of = (); -open(my $ifh_rep, '<'.$replacement_file); -while (<$ifh_rep>) { - if (m/^\$lang\['(.*)'\] \s* = \s* (.*);/x) { - $new_value_of{$1} = $2; - } -} -# use Data::Dumper; print Dumper(\%new_value_of); exit(); - -my %replacement_performed_for = (); - -foreach my $file_code (qw/upgrade install admin common plugin/) { - my $filename = $language_dir.'/'.$file_code.'.lang.php'; - # print $filename; - if (not -f $filename) { - # print ' is missing', "\n"; - next; - } - print $filename.' is under process', "\n"; - - my $file_content = ''; - - open(my $ifh, '<'.$filename); - while (my $line = <$ifh>) { - if ($line =~ m/^\$lang\['(.*)'\] \s* =/x) { - if (defined $new_value_of{$1}) { - $file_content.= '$lang[\''.$1.'\'] = '.$new_value_of{$1}.';'."\n"; - $replacement_performed_for{$1}++; - } - else { - $file_content.= $line; - } - } - elsif ($line =~ m/^?>/) { - $file_content.= $line; - } - else { - $file_content.= $line; - } - } - close($ifh); - - open(my $ofh, '>'.$filename); - print {$ofh} $file_content; - close($ofh); -} - -foreach my $new_value (keys %new_value_of) { - if (not defined $replacement_performed_for{$new_value}) { - print 'no replacement performed on: ', $new_value, "\n"; - } -} diff --git a/tools/translation_analysis.php b/tools/translation_analysis.php index 40fc51caa..3fb120d2c 100644 --- a/tools/translation_analysis.php +++ b/tools/translation_analysis.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | // +-----------------------------------------------------------------------+ diff --git a/tools/triggers_list.php b/tools/triggers_list.php index ab54ebcc7..d327da72d 100644 --- a/tools/triggers_list.php +++ b/tools/triggers_list.php @@ -41,7 +41,7 @@ array( array( 'name' => 'combined_css', 'type' => 'trigger_event', - 'vars' => array('string', 'href', 'int', 'file_ver0', 'int', 'file_ver1'), + 'vars' => array('string', 'href', 'Combinable', '$combinable'), 'files' => array('include\template.class.php (Template::flush)'), ), array( @@ -232,6 +232,13 @@ array( 'infos' => 'New in 2.4', ), array( + 'name' => 'get_webmaster_mail_address', + 'type' => 'trigger_event', + 'vars' => array('string', 'email'), + 'files' => array('include\functions.inc.php (get_webmaster_mail_address)'), + 'infos' => 'New in 2.6', +), +array( 'name' => 'init', 'type' => 'trigger_action', 'vars' => array(), @@ -245,6 +252,13 @@ array( 'files' => array('admin\include\functions.inc.php (invalidate_user_cache)'), ), array( + 'name' => 'load_conf', + 'type' => 'trigger_action', + 'vars' => array('string', 'condition'), + 'files' => array('include\functions.inc.php (load_conf_from_db)'), + 'infos' => 'New in 2.6. <b>Warning:</b> you can\'t trigger the first call done une common.inc.php. Use <i>init</i> instead.', +), +array( 'name' => 'list_check_integrity', 'type' => 'trigger_action', 'vars' => array('object', 'this'), @@ -554,12 +568,6 @@ array( 'files' => array('include\functions_user.inc.php (auto_login, try_log_user)'), ), array( - 'name' => 'mail_group_assign_vars', - 'type' => 'trigger_event', - 'vars' => array('array', 'assign_vars'), - 'files' => array('include\functions_mail.inc.php (pwg_mail_group)'), -), -array( 'name' => 'nbm_event_handler_added', 'type' => 'trigger_action', 'vars' => array(), @@ -658,8 +666,8 @@ array( array( 'name' => 'render_element_description', 'type' => 'trigger_event', - 'vars' => array('string', 'element_secription'), - 'files' => array('picture.php'), + 'vars' => array('string', 'element_description', 'string', 'action'), + 'files' => array('picture.php', 'include\functions_html.inc.php (render_element_description)'), ), array( 'name' => 'render_lost_password_mail_content', @@ -676,14 +684,14 @@ array( array( 'name' => 'render_tag_name', 'type' => 'trigger_event', - 'vars' => array('string', 'tag_name'), - 'files' => array('admin\include\functions.php (get_taglist)', 'admin\tags.php', 'include\functions_tag.inc.php (get_available_tags, get_all_tags, get_common_tags)', 'index.php'), + 'vars' => array('string', 'tag_name', 'array', 'tag'), + 'files' => array('admin\include\functions.php (get_taglist)', 'admin\tags.php', 'admin\history.php', 'include\functions_tag.inc.php (get_available_tags, get_all_tags, get_common_tags)', 'include\functions_html.inc.php (get_tags_content_title)', 'include\functions_search.inc.php (get_qsearch_tags)'), ), array( 'name' => 'render_tag_url', 'type' => 'trigger_event', 'vars' => array('string', 'tag_name'), - 'files' => array('include\functions.php (tag_id_from_tag_name, create_tag)', 'admin\tags.php'), + 'files' => array('admin\include\functions.php (tag_id_from_tag_name, create_tag)', 'admin\tags.php'), ), array( 'name' => 'save_profile_from_post', @@ -692,33 +700,15 @@ array( 'files' => array('profile.php (save_profile_from_post)'), ), array( - 'name' => 'send_mail', - 'type' => 'trigger_event', - 'vars' => array('bool', 'result', 'string', 'mail_to', 'string', 'mail_subject', 'string', 'mail_content', 'array', 'mail_headers'), - 'files' => array('include\functions_mail.inc.php (pwg_mail)'), -), -array( - 'name' => 'send_mail_content', - 'type' => 'trigger_event', - 'vars' => array('string', 'content'), - 'files' => array('include\functions_mail.inc.php (pwg_mail)'), -), -array( - 'name' => 'send_mail_headers', + 'name' => 'before_send_mail', 'type' => 'trigger_event', - 'vars' => array('array', 'headers'), + 'vars' => array('bool', 'result', 'mixed', 'to', 'array', 'arguments', 'PHPMailer', 'mail'), 'files' => array('include\functions_mail.inc.php (pwg_mail)'), ), array( - 'name' => 'send_mail_subject', - 'type' => 'trigger_event', - 'vars' => array('string', 'cvt_subject'), - 'files' => array('include\functions_mail.inc.php (pwg_mail)'), -), -array( - 'name' => 'send_mail_to', - 'type' => 'trigger_event', - 'vars' => array('string', 'to'), + 'name' => 'before_parse_mail_template', + 'type' => 'trigger_action', + 'vars' => array('string', 'cache_key', 'string', 'content_type'), 'files' => array('include\functions_mail.inc.php (pwg_mail)'), ), array( @@ -796,19 +786,42 @@ array( 'type' => 'trigger_action', 'vars' => array('int', 'user_id'), 'files' => array('include\functions_user.inc.php (logout_user)'), + 'infos' => 'New in 2.5', ), array( 'name' => 'user_login', 'type' => 'trigger_action', 'vars' => array('int', 'user_id'), 'files' => array('include\functions_user.inc.php (log_user)'), + 'infos' => 'New in 2.5', ), array( 'name' => 'try_log_user', 'type' => 'trigger_event', 'vars' => array('boolean', 'success', 'string', 'username', 'string', 'password', 'bool', 'remember_me'), 'files' => array('include\functions_user.inc.php (try_log_user)'), - 'infos' => 'Used by identification form to check user credentials and log user. If success is true, another login method already succeed. Return true if your method succeed.', + 'infos' => 'New in 2.5. Used by identification form to check user credentials and log user. If <i>success</i> is <i>true</i>, another login method already succeed. Return <i>true</i> if your method succeed.', +), +array( + 'name' => 'combinable_preparse', + 'type' => 'trigger_action', + 'vars' => array('Template', 'template', 'Combinable', '$combinable', 'FileCombiner', '$combiner'), + 'files' => array('include\template.class.php (FileCombiner::process_combinable)'), + 'infos' => 'New in 2.6.', +), +array( + 'name' => 'user_list_columns', + 'type' => 'trigger_event', + 'vars' => array('string[]', 'aColumns'), + 'files' => array('admin\user_list_backend.php'), + 'infos' => 'New in 2.6.', +), +array( + 'name' => 'after_render_user_list', + 'type' => 'trigger_event', + 'vars' => array('array', 'output'), + 'files' => array('admin\user_list_backend.php'), + 'infos' => 'New in 2.6.', ), ); ?> @@ -820,8 +833,6 @@ array( <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css"> <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables_themeroller.css"> - <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> - <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> <style type="text/css"> /* BEGIN CSS RESET @@ -843,13 +854,10 @@ array( html {font-family:"Corbel","Lucida Grande","Verdana",sans-serif;color:#222;font-size:13px;} a {color:#247EBF;text-decoration:none;} - a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted; - text-shadow:1px 1px 0 #ddd;-moz-text-shadow:1px 1px 0 #ddd;-webkit-text-shadow:1px 1px 0 #ddd; - } + a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted;text-shadow:1px 1px 0 #ddd;} - h1 {color:#fff;font-size:26px;padding:10px 15px; - text-shadow:1px 1px 0 #999;-moz-text-shadow:1px 1px 0 #999;-webkit-text-shadow:1px 1px 0 #999; - background:#45484d;background:-moz-linear-gradient(top, #45484d 0%, #333333 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#45484d), color-stop(100%,#333333));background:-webkit-linear-gradient(top, #45484d 0%,#333333 100%);background:-o-linear-gradient(top, #45484d 0%,#333333 100%);background:-ms-linear-gradient(top, #45484d 0%,#333333 100%);background:linear-gradient(to bottom, #45484d 0%,#333333 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#333333',GradientType=0 ); + h1 {color:#fff;font-size:26px;padding:10px 15px;text-shadow:1px 1px 0 #999; + background:#45484d;background:linear-gradient(to bottom, #45484d 0%,#333333 100%); } #the_header {border-bottom:1px solid #cdcdcd;margin-bottom:1px;} @@ -934,6 +942,9 @@ array( Copyright © 2002-2013 <a href="http://piwigo.org">Piwigo Team</a> </div> <!-- the_footer --> + +<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> +<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> <script type="text/javascript"> var oTable = $('#list').dataTable({ diff --git a/tools/ws.htm b/tools/ws.htm index f77d9ba59..1c55b59cb 100644 --- a/tools/ws.htm +++ b/tools/ws.htm @@ -1,20 +1,18 @@ <!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr"> +<html lang="en" dir="ltr"> <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta charset="utf-8"> <title>Piwigo web API (web-services) explorer</title> - - <link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css"> - <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> - <script type="text/javascript" src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script> - - <style type="text/css"> + + <link rel="stylesheet" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css"> + + <style> /* BEGIN CSS RESET http://meyerweb.com/eric/tools/css/reset v2.0 | 20110126 | License: none (public domain) */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, - fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, + fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline;} @@ -28,29 +26,25 @@ html {font-family:"Corbel","Lucida Grande","Verdana",sans-serif;color:#222;font-size:13px;} a {color:#247EBF;text-decoration:none;} - a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted; - text-shadow:1px 1px 0 #ddd;-moz-text-shadow:1px 1px 0 #ddd;-webkit-text-shadow:1px 1px 0 #ddd; - } + a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted;text-shadow:1px 1px 0 #ddd;} + blockquote {border:1px solid #cdcdcd;background:#F9F9F9;padding:8px;} hr {margin:10px 30px;color:#fff;} ul {margin-left:25px;} p {margin:8px 0;} - h1 {color:#fff;font-size:26px;padding:10px 15px; - text-shadow:1px 1px 0 #999;-moz-text-shadow:1px 1px 0 #999;-webkit-text-shadow:1px 1px 0 #999; - background:#45484d;background:-moz-linear-gradient(top, #45484d 0%, #333333 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#45484d), color-stop(100%,#333333));background:-webkit-linear-gradient(top, #45484d 0%,#333333 100%);background:-o-linear-gradient(top, #45484d 0%,#333333 100%);background:-ms-linear-gradient(top, #45484d 0%,#333333 100%);background:linear-gradient(to bottom, #45484d 0%,#333333 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#333333',GradientType=0 ); + h1 {color:#fff;font-size:26px;padding:10px 15px;text-shadow:1px 1px 0 #999; + background:#45484d;background:linear-gradient(to bottom, #45484d 0%,#333333 100%); } - h2 {color:#fff;font-size:20px;padding:5px 10px; - text-shadow:1px 1px 0 #555;-moz-text-shadow:1px 1px 0 #555;-webkit-text-shadow:1px 1px 0 #555; - background:#f2a841;background:-moz-linear-gradient(top, #f2a841 0%, #ef6b13 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#f2a841), color-stop(100%,#ef6b13));background:-webkit-linear-gradient(top, #f2a841 0%,#ef6b13 100%);background:-o-linear-gradient(top, #f2a841 0%,#ef6b13 100%);background:-ms-linear-gradient(top, #f2a841 0%,#ef6b13 100%);background:linear-gradient(to bottom, #f2a841 0%,#ef6b13 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#f2a841', endColorstr='#ef6b13',GradientType=0 ); + h2 {color:#fff;font-size:20px;padding:5px 10px;text-shadow:1px 1px 0 #555; + background:#f2a841;background:linear-gradient(to bottom, #f2a841 0%,#ef6b13 100%); } h2#errorWrapper {color:#F42C00;font-weight:normal; - background:#eaeaea;background:-moz-linear-gradient(top, #eaeaea 0%, #afafaf 100%);background:-webkit-gradient(linear, lefttop, leftbottom, color-stop(0%,#eaeaea), color-stop(100%,#afafaf));background:-webkit-linear-gradient(top, #eaeaea 0%, #afafaf 100%);background:-o-linear-gradient(top, #eaeaea 0%, #afafaf 100%);background:-ms-linear-gradient(top, #eaeaea 0%, #afafaf 100%);background:linear-gradient(tobottom, #eaeaea 0%, #afafaf 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eaeaea', endColorstr='#afafaf', GradientType=0); + background:#eaeaea;background:linear-gradient(to bottom, #eaeaea 0%, #afafaf 100%); } h3 {display:inline-block;padding:5px 10px;color:#555;font-weight:bold;text-align:center; - border-radius:8px 8px 0 0;-moz-border-radius:8px 8px 0 0;-webkit-border-radius:8px 8px 0 0; - text-shadow:1px 1px 0 #bbb;-moz-text-shadow:1px 1px 0 #bbb;-webkit-text-shadow:1px 1px 0 #bbb; - background:#f2f2f2;background:-moz-linear-gradient(top, #f2f2f2 0%, #cecece 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#f2f2f2), color-stop(100%,#cecece));background:-webkit-linear-gradient(top, #f2f2f2 0%,#cecece 100%);background:-o-linear-gradient(top, #f2f2f2 0%,#cecece 100%);background:-ms-linear-gradient(top, #f2f2f2 0%,#cecece 100%);background:linear-gradient(to bottom, #f2f2f2 0%,#cecece 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#f2f2f2', endColorstr='#cecece',GradientType=0 ); + border-radius:8px 8px 0 0;text-shadow:1px 1px 0 #bbb; + background:#f2f2f2;background:linear-gradient(to bottom, #f2f2f2 0%,#cecece 100%); } #the_header {border-bottom:1px solid #cdcdcd;margin-bottom:1px;} @@ -59,14 +53,14 @@ #the_methods {width:250px;float:left;border-style:solid;border-color:#cdcdcd;border-width:1px 1px 0 0; background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAIAAADZSiLoAAAAH0lEQVQImSXHMQEAMAwCMOrfK0jIjuVL2gLBzyHJtgd7wBdU3Vt/7AAAAABJRU5ErkJggg==); } - #the_methods ul {font-size:1.1em;margin:5px 0 10px 10px;list-style:none;} - #the_methods li:before {content:"\203A\00A0";font-weight:bold;color:#EB9C39;font-size:1.1em;} - #the_methods li:hover:before {content:"\00A0\203A";} + #methodsList {font-size:1.1em;margin:5px 0 10px 10px;list-style:none;} + #methodsList li:before {content:"\203A\00A0";font-weight:bold;color:#EB9C39;font-size:1.1em;} + #methodsList li:hover:before {content:"\00A0\203A";} #the_page {margin-left:252px;border-style:solid;border-color:#cdcdcd;border-width:1px 0 0 1px;} #the_content {padding:10px;} - #methodParams {display:inline-block;} + #methodParams {margin-right:230px;} #methodParams thead td {background:#DEE3E9;font-weight:bold;padding:2px 5px;} #methodParams td {padding:2px;border:1px solid #cdcdcd;vertical-align:middle;} #methodParams tbody tr:nth-child(even) {background:#f7f7f7;} @@ -74,36 +68,39 @@ #methodParams td.mini {width:0px;text-align:center;} #methodParams tfoot {font-size:0.95em;} #methodParams td.input {text-align:center;} - #methodParams td.input input[type="text"] {width:97%;font-size:0.9em;background:#f7f7f7;border:1px solid #ccc; - border-radius:2px;-moz-border-radius:2px;-webkit-border-radius:2px; - } + #methodParams td.input input[type="text"] {width:97%;font-size:0.9em;background:#f7f7f7;border:1px solid #ccc;border-radius:2px;} #methodParams td.input input[type="text"]:hover, #methodParams td.input input[type="text"]:focus {border-color:#C7E2F1;border-top-color:#96BCD7;background:#fff;} + #methodParams .type {display:inline-block;width:16px;height:16px;font-size:12px;line-height:16px;background:#ddd;border-radius:8px;font-weight:bold;text-align:center;color:#222;} + #methodParams .subtype {vertical-align:super;} - #testForm {display:inline-block;margin-left:15px;} + #testForm {float:right;} #testForm td {padding:2px 0;} #testForm tr:last-child td {padding:8px 0 5px 0;} #testForm blockquote {width:200px;} - + #introMessage {font-size:1.1em;} #urlForm {margin-bottom:10px;} a.button {color:#fff;padding:3px 8px;border:1px solid #91bb5c;font-size:0.9em;margin-right:3px;display:inline-block; - border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; - text-shadow:1px 1px 0 #666;-moz-text-shadow:1px 1px 0 #666;-webkit-text-shadow:1px 1px 0 #666; - background:#84bb3c;background:-moz-linear-gradient(top, #84bb3c 0%, #3f5a1d 100%);background:-webkit-gradient(linear, lefttop, leftbottom, color-stop(0%,#84bb3c), color-stop(100%,#3f5a1d));background:-webkit-linear-gradient(top, #84bb3c 0%, #3f5a1d 100%);background:-o-linear-gradient(top, #84bb3c 0%, #3f5a1d 100%);background:-ms-linear-gradient(top, #84bb3c 0%, #3f5a1d 100%);background:linear-gradient(tobottom, #84bb3c 0%, #3f5a1d 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#84bb3c', endColorstr='#3f5a1d', GradientType=0); + border-radius:5px;text-shadow:1px 1px 0 #666; + background:#84bb3c;background:linear-gradient(to bottom, #84bb3c 0%, #3f5a1d 100%); } a.button:hover {color:#E5FF00;} - + .methodInfo {float:right;display:inline-block;width:16px;height:16px;font-size:12px;line-height:16px;background:#555;border-radius:8px;font-family:"Times New Roman",sans-serif;font-style:italic;font-weight:bold;text-align:center;color:#fff;} .methodInfo:hover {border:none;text-shadow:none;background:#888;cursor:pointer;color:#fff;} - + #tiptip_content { font-size:12px; } + #iframeWrapper {width:100%;height:300px;padding:3px 3px 20px 3px;background:#F9F9F9;border:1px solid #cdcdcd;overflow:hidden;position:relative;} iframe {width:100%;height:100%;background:#fff;} + + div.onlys {background:#faa;color:#fff;border:1px solid #f22;padding:.25em .5em;display:table;border-radius:4px;margin-bottom:0.5em;} </style> - + </head> <body> +<a name="top"></a> <div id="the_header"> <h1>Piwigo web API (web-services) explorer</h1> @@ -111,7 +108,7 @@ <div id="the_methods"> <h2>Available methods</h2> - + <ul id="methodsList"> </ul> </div> <!-- the_methods --> @@ -119,13 +116,13 @@ <div id="the_page"> <h2 id="methodName" style="display:none;"></h2> <h2 id="errorWrapper" style="display:none;"></h2> - + <div id="the_content"> <form id="urlForm" style="display:none;"> <input type="text" name="ws_url" size="60"> <input type="submit" value="Go!"> </form> - + <blockquote id="introMessage"> <p> <b>API = Application Programming Interface.</b><br> @@ -156,30 +153,7 @@ </blockquote> <br> </div> <!-- methodDescription --> - - <div id="methodParams"> - <h3>Method parameters</h3> - <table> - <thead> - <tr> - <td style="width:150px;">Name</td> - <td class="mini">Extra</td> - <td style="width:300px;">Value</td> - <td class="mini">Send</td> - </tr> - </thead> - - <tbody> - </tbody> - - <tfoot> - <tr> - <td colspan="4"><b>*</b>: required parameter, <b>?</b>: optional parameter, <b>[]</b>: parameter can be an array (use a pipe | to split values)</td> - </tr> - </tfoot> - </table> - </div> <!-- methodParams --> - + <div id="testForm"> <h3>Test</h3> <blockquote> @@ -188,7 +162,7 @@ <td>Request format :</td> <td> <select id="requestFormat"> - <option value="get" selected="selected">GET</option> + <option value="get" selected>GET</option> <option value="post">POST</option> </select> </td> @@ -197,7 +171,7 @@ <td>Response format :</td> <td> <select id="responseFormat"> - <option value="rest" selected="selected">REST (xml)</option> + <option value="rest" selected>REST (xml)</option> <option value="json">JSON</option> <option value="php">PHP serial</option> <option value="xmlrpc">XML RPC</option> @@ -213,20 +187,48 @@ </table> </blockquote> </div> <!-- testForm --> - + + <div id="methodParams"> + <h3>Method parameters</h3> + <table> + <thead> + <tr> + <td style="width:150px;">Name</td> + <td class="mini">Extra</td> + <td class="mini">Type</td> + <td style="width:300px;">Value</td> + <td class="mini">Send</td> + </tr> + </thead> + + <tbody> + </tbody> + + <tfoot> + <tr> + <td colspan="5"> + <b>*</b>: required, <b>?</b>: optional, <b>[]</b>: can be an array (use a pipe | to split values)<br> + <b>B</b>: boolean, <b>I</b>: integer, <b>F</b>: float, <b>+</b>: positive, <b>ø</b>: not null + </td> + </tr> + </tfoot> + </table> + </div> <!-- methodParams --> + <br><br> - + <h3>Result</h3> <div id="iframeWrapper"> <iframe src="" id="invokeFrame" name="invokeFrame"></iframe> - <a href="#bottom" id="increaseIframe"><b>↓</b> increase height</a> • <a href="#bottom" id="decreaseIframe"><b>↑</b> decrease height</a> - <a name="bottom"></a> + <a href="#iframe-bottom" id="increaseIframe"><b>↓</b> increase height</a> • + <a href="#iframe-bottom" id="decreaseIframe"><b>↑</b> decrease height</a> + <a name="iframe-bottom"></a> </div> </form> <!-- iframeWrapper --> - + <!-- hidden form for POST submition --> <form method="post" action="" target="" id="invokeForm" style="display:none;"></form> - + </div> <!-- the_content --> </div> <!-- the_page --> @@ -235,8 +237,10 @@ Copyright © 2002-2013 <a href="http://piwigo.org">Piwigo Team</a> </div> <!-- the_footer --> +<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> +<script src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script> -<script type="text/javascript"> +<script> // global vars var cachedMethods = new Array; var ws_url = "http://"; @@ -286,6 +290,7 @@ function resetDisplay() { $("#methodWrapper").hide(); $("#methodName").hide(); $("#urlForm").hide(); + $("#methodDescription blockquote").empty(); $("#methodDescription").hide(); $("#invokeFrame").attr('src',''); } @@ -295,10 +300,10 @@ function adaptHeight() { $("#the_page").css('height', 'auto'); $("#the_methods").css('height', 'auto'); - + min_h = $(window).height()-$("#the_header").outerHeight()-$("#the_footer").outerHeight()-3; h = Math.max(min_h, Math.max($("#the_methods").height(), $("#the_page").height())); - + $("#the_page").css('height', h); $("#the_methods").css('height', h); } @@ -312,11 +317,11 @@ function displayError(error) { // display ws_url form function askForUrl() { + displayError("can't contact web-services, please give absolute url to 'ws.php'"); if ($("#urlForm input[name='ws_url']").val() == "") { $("#urlForm input[name='ws_url']").val(ws_url); } $("#urlForm").show(); - displayError("can't contact web-services, please give absolute url to 'ws.php'"); } // parse Piwigo JSON @@ -331,37 +336,36 @@ function parsePwgJSON(json) { displayError("unable to parse JSON string"); resp = {"stat": "ko", "result": "null"}; } - + return resp.result; } // fetch methods list function getMethodList() { resetDisplay(); - + $.ajax({ type: "GET", url: ws_url, data: { format: "json", method: "reflection.getMethodList" } }).done(function(result) { result = parsePwgJSON(result); - + if (result!=null) { methods = result.methods; - + var ml = ''; for (var i=0; i<methods.length; i++) { - ml += '<li><a href="#">'+ methods[i]+'</a></li>'; + ml += '<li><a href="#top">'+ methods[i]+'</a></li>'; } $("#methodsList").html(ml).show(); - + adaptHeight(); - + // trigger method selection $("#methodsList li a").click(function() { selectMethod($(this).html()); - return false; }); } }).error(function(jqXHR, textStatus, errorThrown) { @@ -372,7 +376,8 @@ function getMethodList() { // select method function selectMethod(methodName) { $("#introMessage").hide(); - + $("#tiptip_holder").fadeOut(200); + if (cachedMethods[ methodName ]) { fillNewMethod(methodName); } @@ -381,10 +386,22 @@ function selectMethod(methodName) { type: "GET", url: ws_url, data: { format: "json", method: "reflection.getMethodDetails", methodName: methodName } - }).done(function(result) { + }).done(function(result) { result = parsePwgJSON(result); - + if (result!=null) { + if (result.options.post_only || result.options.admin_only) { + var onlys = '<div class="onlys">'; + if (result.options.post_only) { + onlys+= 'POST only. '; + } + if (result.options.admin_only) { + onlys+= 'Admin only. '; + } + onlys+= '</div>'; + + result.description = onlys + result.description; + } cachedMethods[ methodName ] = result; fillNewMethod(methodName); } @@ -397,32 +414,43 @@ function selectMethod(methodName) { // display method details function fillNewMethod(methodName) { resetDisplay(); - + method = cachedMethods[ methodName ]; - + $("#methodName").html(method.name).show(); - + if (method.description != "") { $("#methodDescription blockquote").html(method.description); $("#methodDescription").show(); } - + + $("#requestFormat").val(method.options.post_only ? 'post' : 'get'); + var methodParams = ''; if (method.params && method.params.length>0) { for (var i=0; i<method.params.length; i++) { - var isOptional = method.params[i].optional; - var acceptArray = method.params[i].acceptArray; - var defaultValue = method.params[i].defaultValue == null ? '' : method.params[i].defaultValue; - var info = method.params[i].info == null ? '' : '<a class="methodInfo" title="'+ method.params[i].info + '">i</a>'; - + var param = method.params[i], + isOptional = param.optional, + acceptArray = param.acceptArray, + defaultValue = param.defaultValue == null ? '' : param.defaultValue, + info = param.info == null ? '' : '<a class="methodInfo" title="'+ param.info.replace(/"/g, '"') + '">i</a>', + type = ''; + + if (param.type.match(/bool/)) type+= '<span class=type>B</span>'; + if (param.type.match(/int/)) type+= '<span class=type>I</span>'; + if (param.type.match(/float/)) type+= '<span class=type>F</span>'; + if (param.type.match(/positive/)) type+= '<span class=subtype>+</span>'; + if (param.type.match(/notnull/)) type+= '<span class=subtype>ø</span>'; + // if an array is direclty printed, the delimiter is a comma where we use a pipe if (typeof defaultValue == 'object') { defaultValue = defaultValue.join('|'); } methodParams+= '<tr>'+ - '<td>'+ method.params[i].name + info +'</td>'+ + '<td>'+ param.name + info +'</td>'+ '<td class="mini">'+ (isOptional ? '?':'*') + (acceptArray ? ' []':'') +'</td>'+ + '<td class="mini">'+ type +'</td>'+ '<td class="input"><input type="text" class="methodParameterValue" data-id="'+ i +'" value="'+ defaultValue +'"></td>'+ '<td class="mini"><input type="checkbox" class="methodParameterSend" data-id="'+ i +'" '+ (isOptional ? '':'checked="checked"') +'></td>'+ '</tr>'; @@ -431,20 +459,19 @@ function fillNewMethod(methodName) { else { methodParams = '<tr><td colspan="4">This method takes no parameters</td></tr>'; } - + $("#methodParams tbody").html(methodParams); - $("#methodWrapper").show(); - + $("#methodWrapper").show(); + adaptHeight(); - + // trigger field modification $("input.methodParameterValue").change(function() { $("input.methodParameterSend[data-id='"+ $(this).data('id') +"']").attr('checked', 'checked'); }); - + // tiptip $(".methodInfo").tipTip({ - activation:"click", maxWidth:"300px", defaultPosition:"right", delay:0 @@ -456,18 +483,18 @@ function invokeMethod(methodName, newWindow) { var method = cachedMethods[ methodName ]; var reqUrl = ws_url +"?format="+ $("#responseFormat").val(); - + // GET if ($("#requestFormat").val() == 'get') { reqUrl+= "&method="+ methodName; - + for (var i=0; i<method.params.length; i++) { if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) { continue; } var paramValue = $("input.methodParameterValue[data-id='"+ i +"']").val(); - + var paramSplitted = paramValue.split('|'); if (method.params[i].acceptArray && paramSplitted.length > 1) { $.each(paramSplitted, function(v) { @@ -478,7 +505,7 @@ function invokeMethod(methodName, newWindow) { reqUrl+= '&'+ method.params[i].name +'='+ paramValue; } } - + if (newWindow) { window.open(reqUrl); } @@ -490,9 +517,9 @@ function invokeMethod(methodName, newWindow) { else { var form = $("#invokeForm"); form.attr('action', reqUrl); - + var t = '<input type="hidden" name="method" value="'+ methodName +'">'; - + for (var i=0; i<method.params.length; i++) { if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) { continue; @@ -510,15 +537,15 @@ function invokeMethod(methodName, newWindow) { t+= '<input type="hidden" name="'+ method.params[i].name +'" value="'+ paramValue +'">'; } } - + form.html(t); form.attr('target', newWindow ? "_blank" : "invokeFrame"); form.submit(); } - + return false; } </script> </body> -</html> +</html>
\ No newline at end of file |