diff --git a/.gitignore b/.gitignore index 0e4e49f4c..790bc9548 100644 --- a/.gitignore +++ b/.gitignore @@ -1,76 +1,79 @@ Makefile Makefile.in configure config.cache config.log config.status config.nice config.guess config.sub install-sh missing autom4te.cache aclocal.m4 TAGS invenio-autotools.conf po/POTFILES po/POTFILES-py po/POTFILES-webdoc po/stamp-po po/*.gmo po/*.mo po/*.sed *~ *.pyc *.clisp.mem *.cmucl.core *.sbcl.core *.fas *.fasl *.lib *.x86f modules/bibclassify/bin/bibclassify modules/bibconvert/bin/bibconvert modules/bibedit/bin/bibedit modules/bibedit/bin/refextract modules/bibedit/bin/xmlmarc2textmarc modules/bibedit/bin/xmlmarclint modules/bibexport/bin/bibexport modules/bibformat/bin/bibreformat modules/bibharvest/bin/bibharvest modules/bibharvest/bin/oaiarchive modules/bibharvest/bin/oaiharvest modules/bibharvest/bin/oairepositoryupdater modules/bibindex/bin/bibindex modules/bibindex/bin/bibstat modules/bibmatch/bin/bibmatch modules/bibrank/bin/bibrank modules/bibrank/bin/bibrankgkb modules/bibrank/etc/bibrankgkb.cfg modules/bibrank/etc/demo_jif.cfg modules/bibrank/etc/template_single_tag_rank_method.cfg modules/bibsched/bin/bibsched modules/bibsched/bin/bibtaskex modules/bibupload/bin/bibupload modules/elmsubmit/bin/elmsubmit modules/elmsubmit/etc/elmsubmit.cfg modules/miscutil/bin/dbdump modules/miscutil/bin/dbexec modules/miscutil/bin/inveniocfg modules/miscutil/lib/build modules/webaccess/bin/authaction modules/webaccess/bin/webaccessadmin modules/webalert/bin/alertengine modules/webmessage/bin/webmessageadmin modules/websearch/bin/webcoll modules/websession/bin/inveniogc modules/webstat/bin/webstat modules/webstat/bin/webstatadmin modules/webstyle/bin/webdoc modules/websubmit/bin/bibdocfile tags config.rpath config.status.lineno configure.lineno *.kdevelop *.kdevses +.project +.settings +.pydevproject diff --git a/Makefile.am b/Makefile.am index 6a5af56c1..4d5155f0d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,394 +1,407 @@ ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio 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; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. confignicedir = $(sysconfdir)/build confignice_SCRIPTS=config.nice SUBDIRS = po config modules EXTRA_DIST = UNINSTALL THANKS RELEASE-NOTES configure-tests.py config.nice.in # current jsMath version and packages JSMV = 3.6b JSMFV = 1.3 JSMATH = jsMath-$(JSMV).zip JSMATHFONTS = jsMath-fonts-$(JSMFV).zip # current FCKeditor version FCKV = 2.6.6 FCKEDITOR = FCKeditor_$(FCKV).zip all: @echo "****************************************************" @echo "** CDS Invenio has been successfully built. **" @echo "** **" @echo "** You may proceed to 'make install' now. **" @echo "****************************************************" check-custom-templates: $(PYTHON) $(top_srcdir)/modules/webstyle/lib/template.py --check-custom-templates $(top_srcdir) kwalitee-check: @$(PYTHON) $(top_srcdir)/modules/miscutil/lib/kwalitee.py --stats $(top_srcdir) kwalitee-check-errors-only: @find $(top_srcdir) -name '*.py' -exec pylint -e {} \; 2> /dev/null kwalitee-check-variables: @find $(top_srcdir) -name '*.py' -exec pylint --reports=n --enable-checker=variables {} \; 2> /dev/null kwalitee-check-indentation: @find $(top_srcdir) -name '*.py' -exec pylint --reports=n --enable-checker=format {} 2> /dev/null \; | grep -E '(^\*|indentation)' kwalitee-check-sql-queries: @echo "* Listing potentially dangerous SQL queries:" @echo "** SQL SELECT queries without explicit column list:" @find $(top_srcdir) -name '*.py' -exec grep -HEin 'SELECT \* FROM' {} \; 2> /dev/null @echo "** SQL INSERT queries without explicit column list:" @find $(top_srcdir) -name '*.py' -exec grep -HEin 'INSERT INTO ([[:alnum:]]|_)+[[:space:]]*VALUES' {} \; 2> /dev/null @find $(top_srcdir) -name '*.py' -exec grep -HEin 'INSERT INTO ([[:alnum:]]|_)+[[:space:]]*$$' {} \; 2> /dev/null @echo "** SQL queries using charset-ignorant escape_string():" @find $(top_srcdir) -name '*.py' -exec grep -HEin 'escape_string' {} \; 2> /dev/null @echo "** SQL queries using literal '%s':" @find $(top_srcdir) -name '*.py' -exec grep -HEin "run_sql.*'%[dfis]'" {} \; 2> /dev/null @find $(top_srcdir) -name '*.py' -exec grep -HEin 'run_sql.*"%[dfis]"' {} \; 2> /dev/null @echo "** SQL queries with potentially unescaped arguments:" @find $(top_srcdir) -name '*.py' -exec grep -HEin 'run_sql.* % ' {} \; 2> /dev/null @echo "* Done." etags: \rm -f $(top_srcdir)/TAGS (cd $(top_srcdir) && find $(top_srcdir) -name "*.py" -print | xargs etags) install-data-local: for d in / /cache /log /tmp /data /run ; do \ mkdir -p $(localstatedir)$$d ; \ done @echo "************************************************************" @echo "** CDS Invenio software has been successfully installed! **" @echo "** **" @echo "** You may proceed to customizing your installation now. **" @echo "************************************************************" install-jsmath-plugin: @echo "***********************************************************" @echo "** Installing jsMath plugin, please wait... **" @echo "***********************************************************" rm -rf /tmp/invenio-jsmath-plugin mkdir /tmp/invenio-jsmath-plugin (cd /tmp/invenio-jsmath-plugin && \ wget 'http://downloads.sourceforge.net/jsmath/$(JSMATH)' && \ wget 'http://downloads.sourceforge.net/jsmath/$(JSMATHFONTS)' && \ wget 'http://www.math.union.edu/~dpvc/jsMath/download/extra-fonts/msam10/msam10.zip' && \ wget 'http://www.math.union.edu/~dpvc/jsMath/download/extra-fonts/msbm10/msbm10.zip' && \ unzip -u -d ${prefix}/var/www $(JSMATH) && \ unzip -u -d ${prefix}/var/www $(JSMATHFONTS) && \ unzip -u -d ${prefix}/var/www/jsMath/fonts msam10.zip && \ unzip -u -d ${prefix}/var/www/jsMath/fonts msbm10.zip) rm -fr /tmp/invenio-jsmath-plugin @echo "* Installing Invenio-specific jsMath config..." (cd $(top_srcdir)/modules/webstyle/etc && make install) + @echo "***********************************************************" @echo "** The jsMath plugin was successfully installed. **" @echo "** Please do not forget to properly set the option **" @echo "** CFG_WEBSEARCH_USE_JSMATH_FOR_FORMATS in invenio.conf. **" @echo "***********************************************************" uninstall-jsmath-plugin: @rm -rvf ${prefix}/var/www/jsMath @echo "***********************************************************" @echo "** The jsMath plugin was successfully uninstalled. **" @echo "***********************************************************" install-jscalendar-plugin: @echo "***********************************************************" @echo "** Installing jsCalendar plugin, please wait... **" @echo "***********************************************************" rm -rf /tmp/invenio-jscalendar-plugin mkdir /tmp/invenio-jscalendar-plugin (cd /tmp/invenio-jscalendar-plugin && \ wget 'http://www.dynarch.com/static/jscalendar-1.0.zip' && \ unzip -u jscalendar-1.0.zip && \ mkdir -p ${prefix}/var/www/jsCalendar && \ cp jscalendar-1.0/img.gif ${prefix}/var/www/jsCalendar/jsCalendar.gif && \ cp jscalendar-1.0/calendar.js ${prefix}/var/www/jsCalendar/ && \ cp jscalendar-1.0/calendar-setup.js ${prefix}/var/www/jsCalendar/ && \ cp jscalendar-1.0/lang/calendar-en.js ${prefix}/var/www/jsCalendar/ && \ cp jscalendar-1.0/calendar-blue.css ${prefix}/var/www/jsCalendar/) rm -fr /tmp/invenio-jscalendar-plugin @echo "***********************************************************" @echo "** The jsCalendar plugin was successfully installed. **" @echo "***********************************************************" uninstall-jscalendar-plugin: @rm -rvf ${prefix}/var/www/jsCalendar @echo "***********************************************************" @echo "** The jsCalendar plugin was successfully uninstalled. **" @echo "***********************************************************" install-jquery-plugins: uninstall-jquery-plugins @echo "***********************************************************" @echo "** Installing various jQuery plugins, please wait... **" @echo "***********************************************************" mkdir -p ${prefix}/var/www/js (cd ${prefix}/var/www/js && \ wget http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js && \ mv jquery-1.3.1.min.js jquery.min.js && \ wget http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/jquery.effects.core.min.js && \ wget http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/jquery.effects.highlight.min.js && \ wget http://www.appelsiini.net/download/jquery.jeditable.mini.js && \ wget http://plugins.jquery.com/files/jquery.autogrow-1.2.2.zip && \ wget http://tablesorter.com/jquery.tablesorter.zip && \ unzip jquery.tablesorter.zip && \ rm jquery.tablesorter.zip && \ unzip jquery.autogrow-1.2.2.zip jquery.autogrow.js && \ rm jquery.autogrow-1.2.2.zip && \ wget -O json2.js.tmp http://json.org/json2.js && \ grep -v 'alert.*IMPORTANT: Remove this line' json2.js.tmp > json2.js && \ rm json2.js.tmp && \ wget http://jquery-ui.googlecode.com/svn/tags/1.7.2/ui/minified/ui.datepicker.min.js && \ - wget -O jquery.hotkeys.min.js http://js-hotkeys.googlecode.com/files/jquery.hotkeys-0.7.8-packed.js) + wget -O jquery.hotkeys.min.js http://js-hotkeys.googlecode.com/files/jquery.hotkeys-0.7.8-packed.js && \ + wget http://plugins.jquery.com/files/jquery.treeview_3.zip && \ + unzip jquery.treeview_3.zip && \ + rm jquery.treeview_3.zip && \ + wget http://plugins.jquery.com/files/jquery.ajaxPager.js_5.txt && \ + mv jquery.ajaxPager.js_5.txt jquery.ajaxPager.js && \ + wget http://jqueryui.com/download/jquery-ui-1.7.2.custom.zip && \ + unzip jquery-ui-1.7.2.custom.zip development-bundle/ui/ui.core.js && \ + mv development-bundle/ui/ui.core.js ui.core.js && \ + rm -rf development-bundle) mkdir -p ${prefix}/var/www/img && \ (cd ${prefix}/var/www/img && \ wget http://jquery-ui.googlecode.com/svn/tags/1.7.2/themes/redmond/jquery-ui.css && \ wget http://jquery-ui.googlecode.com/svn/tags/1.7.2/demos/images/calendar.gif && \ wget -r -np -nH --cut-dirs=5 -A "png" http://jquery-ui.googlecode.com/svn/tags/1.7.2/themes/redmond/images/) @echo "***********************************************************" @echo "** The jQuery plugins were successfully installed. **" @echo "***********************************************************" uninstall-jquery-plugins: (cd ${prefix}/var/www/js && \ rm -f jquery.min.js && \ rm -f jquery.effects.core.min.js && \ rm -f jquery.effects.highlight.min.js && \ rm -f jquery.jeditable.mini.js && \ rm -f jquery.tablesorter.js && \ rm -f jquery.tablesorter.pager.js && \ rm -f ui.datepicker.min.js && \ rm -f jquery.autogrow.js && \ rm -f json2.js && \ rm -rf tablesorter && \ - rm -f jquery.hotkeys.min.js) + rm -f jquery.hotkeys.min.js && \ + rm -rf jquery-treeview && \ + rm -f jquery.ajaxPager.js && \ + rm -f ui.core.js) @echo "***********************************************************" @echo "** The jquery plugins were successfully uninstalled. **" @echo "***********************************************************" install-fckeditor-plugin: @echo "***********************************************************" @echo "** Installing FCKeditor plugin, please wait... **" @echo "***********************************************************" rm -rf ${prefix}/lib/python/invenio/fckeditor/ rm -rf /tmp/invenio-fckeditor-plugin mkdir /tmp/invenio-fckeditor-plugin (cd /tmp/invenio-fckeditor-plugin && \ wget 'http://downloads.sourceforge.net/fckeditor/$(FCKEDITOR)' && \ unzip -u -d ${prefix}/var/www $(FCKEDITOR)) && \ mkdir -p ${prefix}/lib/python/invenio/fckeditor/editor/filemanager/connectors/py && \ mv -f ${prefix}/var/www/fckeditor/fckeditor.py ${prefix}/lib/python/invenio/fckeditor/ && \ mv -f ${prefix}/var/www/fckeditor/editor/filemanager/connectors/py/*.py ${prefix}/lib/python/invenio/fckeditor/editor/filemanager/connectors/py/ && \ rm -f ${prefix}/var/www/fckeditor/editor/filemanager/connectors/py/upload.py && \ rm -f ${prefix}/var/www/fckeditor/editor/filemanager/connectors/py/zope.py && \ find ${prefix}/lib/python/invenio/fckeditor -type d -exec touch {}/__init__.py \; && \ find ${prefix}/var/www/fckeditor/ -depth -name '_*' -exec rm -rf {} \; && \ rm -r ${prefix}/var/www/fckeditor/editor/filemanager/connectors && \ find ${prefix}/var/www/fckeditor/fckeditor* -maxdepth 0 -exec rm -r {} \; && \ rm -fr /tmp/invenio-fckeditor-plugin @echo "* Installing Invenio-specific FCKeditor config..." (cd $(top_srcdir)/modules/webstyle/etc && make install) @echo "***********************************************************" @echo "** The FCKeditor plugin was successfully installed. **" @echo "** Please do not forget to properly set the option **" @echo "** CFG_WEBCOMMENT_USE_RICH_TEXT_EDITOR in invenio.conf. **" @echo "***********************************************************" uninstall-fckeditor-plugin: @rm -rvf ${prefix}/var/www/fckeditor @rm -rvf ${prefix}/lib/python/invenio/fckeditor @echo "***********************************************************" @echo "** The FCKeditor plugin was successfully uninstalled. **" @echo "***********************************************************" update-v0.3.0-tables update-v0.3.1-tables: echo "ALTER TABLE idxINDEXNAME CHANGE id_idxINDEX id_idxINDEX mediumint(9) unsigned NOT NULL FIRST;" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkMETHODNAME CHANGE id_rnkMETHOD id_rnkMETHOD mediumint(9) unsigned NOT NULL FIRST;" | ${prefix}/bin/dbexec echo "ALTER TABLE collectionname CHANGE id_collection id_collection mediumint(9) unsigned NOT NULL FIRST;" | ${prefix}/bin/dbexec echo "ALTER TABLE formatname CHANGE id_format id_format mediumint(9) unsigned NOT NULL FIRST;" | ${prefix}/bin/dbexec echo "ALTER TABLE fieldname CHANGE id_field id_field mediumint(9) unsigned NOT NULL FIRST;" | ${prefix}/bin/dbexec echo "INSERT INTO accACTION (id,name,description,allowedkeywords,optional) VALUES (NULL,'runbibrank','run BibRank','','no');" | ${prefix}/bin/dbexec echo "INSERT INTO accACTION (id,name,description,allowedkeywords,optional) VALUES (NULL,'cfgbibrank','configure BibRank','','no');" | ${prefix}/bin/dbexec update-v0.3.2-tables: echo "ALTER TABLE sbmCOLLECTION_sbmDOCTYPE CHANGE id_son id_son char(10) NOT NULL default '0';" | ${prefix}/bin/dbexec update-v0.3.3-tables: ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "ALTER TABLE flxLINKTYPEPARAMS CHANGE pname pname varchar(78) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkMETHOD DROP star_category_ranges;" | ${prefix}/bin/dbexec echo "DROP TABLE rnkSET;" | ${prefix}/bin/dbexec echo "ALTER TABLE schTASK CHANGE arguments arguments LONGTEXT;" | ${prefix}/bin/dbexec echo "ALTER TABLE schTASK CHANGE status status varchar(50);" | ${prefix}/bin/dbexec update-v0.5.0-tables: ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "ALTER TABLE session ADD INDEX uid (uid);" | ${prefix}/bin/dbexec echo "UPDATE idxINDEXNAME SET ln='cs' WHERE ln='cz';" | ${prefix}/bin/dbexec echo "UPDATE rnkMETHODNAME SET ln='cs' WHERE ln='cz';" | ${prefix}/bin/dbexec echo "UPDATE collectionname SET ln='cs' WHERE ln='cz';" | ${prefix}/bin/dbexec echo "UPDATE collection_portalbox SET ln='cs' WHERE ln='cz';" | ${prefix}/bin/dbexec echo "UPDATE formatname SET ln='cs' WHERE ln='cz';" | ${prefix}/bin/dbexec echo "UPDATE fieldname SET ln='cs' WHERE ln='cz';" | ${prefix}/bin/dbexec echo "UPDATE idxINDEXNAME SET ln='sv' WHERE ln='se';" | ${prefix}/bin/dbexec echo "UPDATE rnkMETHODNAME SET ln='sv' WHERE ln='se';" | ${prefix}/bin/dbexec echo "UPDATE collectionname SET ln='sv' WHERE ln='se';" | ${prefix}/bin/dbexec echo "UPDATE collection_portalbox SET ln='sv' WHERE ln='se';" | ${prefix}/bin/dbexec echo "UPDATE formatname SET ln='sv' WHERE ln='se';" | ${prefix}/bin/dbexec echo "UPDATE fieldname SET ln='sv' WHERE ln='se';" | ${prefix}/bin/dbexec update-v0.7.1-tables: echo "DROP TABLE oaiHARVEST;" | ${prefix}/bin/dbexec ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "INSERT INTO accACTION (id,name,description,allowedkeywords,optional) VALUES (NULL,'cfgbibharvest','configure BibHarvest','','no');" | ${prefix}/bin/dbexec echo "INSERT INTO accACTION (id,name,description,allowedkeywords,optional) VALUES (NULL,'runoaiharvest','run BibHarvest oaiharvest','','no');" | ${prefix}/bin/dbexec echo "INSERT INTO accACTION (id,name,description,allowedkeywords,optional) VALUES (NULL,'cfgwebcomment','configure WebComment','','no');" | ${prefix}/bin/dbexec echo "INSERT INTO accACTION (id,name,description,allowedkeywords,optional) VALUES (NULL,'runoaiarchive','run BibHarvest oaiarchive','','no');" | ${prefix}/bin/dbexec echo "INSERT INTO accACTION (id,name,description,allowedkeywords,optional) VALUES (NULL,'runbibedit','run BibEdit','','no');" | ${prefix}/bin/dbexec echo "ALTER TABLE user ADD nickname varchar(255) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE user ADD last_login datetime NOT NULL default '0000-00-00 00:00:00';" | ${prefix}/bin/dbexec echo "ALTER TABLE user ADD INDEX nickname (nickname);" | ${prefix}/bin/dbexec echo "ALTER TABLE sbmFIELD CHANGE subname subname varchar(13) default NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE user_query_basket CHANGE alert_name alert_name varchar(30) NOT NULL default '';" | ${prefix}/bin/dbexec echo "TRUNCATE TABLE session;" | ${prefix}/bin/dbexec @echo "**********************************************************" @echo "** Do not forget to run the basket migration now: **" @echo "** @PYTHON@ modules/webbasket/lib/webbasket_migration_kit.py " @echo "** Please see the RELEASE-NOTES for details. **" @echo "**********************************************************" @echo "INSERT INTO oaiARCHIVE (id, setName, setSpec, setDescription, setDefinition, setRecList) SELECT id, setName, setSpec, CONCAT_WS('', setDescription), setDefinition, setRecList FROM oaiSET;" update-v0.90.0-tables: ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "ALTER TABLE format ADD COLUMN (description varchar(255) default '');" | ${prefix}/bin/dbexec echo "ALTER TABLE format ADD COLUMN (content_type varchar(255) default '');" | ${prefix}/bin/dbexec update-v0.90.1-tables: ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "ALTER TABLE schTASK ADD INDEX status (status);" | ${prefix}/bin/dbexec echo "ALTER TABLE schTASK ADD INDEX runtime (runtime);" | ${prefix}/bin/dbexec echo "ALTER TABLE sbmCATEGORIES ADD COLUMN score TINYINT UNSIGNED NOT NULL DEFAULT 0;" | ${prefix}/bin/dbexec echo "ALTER TABLE sbmCATEGORIES ADD PRIMARY KEY (doctype, sname);" | ${prefix}/bin/dbexec echo "ALTER TABLE sbmCATEGORIES ADD KEY doctype (doctype);" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiHARVEST ADD COLUMN setspecs TEXT NOT NULL DEFAULT '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE setDescription setDescription text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE p1 p1 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE f1 f1 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE m1 m1 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE p2 p2 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE f2 f2 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE m2 m2 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE p3 p3 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE f3 f3 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiARCHIVE CHANGE m3 m3 text NOT NULL default '';" | ${prefix}/bin/dbexec echo "UPDATE bibdoc SET status=0 WHERE status='';" | ${prefix}/bin/dbexec echo "UPDATE bibdoc SET status=1 WHERE status='deleted';" | ${prefix}/bin/dbexec echo "ALTER TABLE fmtKNOWLEDGEBASES add COLUMN kbtype char default NULL;" | ${prefix}/bin/dbexec update-v0.92.0-tables: echo "UPDATE bibdoc SET status=0 WHERE status='';" | ${prefix}/bin/dbexec echo "UPDATE bibdoc SET status=1 WHERE status='deleted';" | ${prefix}/bin/dbexec echo "ALTER TABLE schTASK CHANGE arguments arguments mediumblob;" | ${prefix}/bin/dbexec echo "UPDATE user SET note=1 WHERE nickname='admin' AND note IS NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE usergroup CHANGE name name varchar(255) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE usergroup ADD login_method varchar(255) NOT NULL default 'INTERNAL';" | ${prefix}/bin/dbexec echo "ALTER TABLE usergroup ADD UNIQUE KEY login_method_name (login_method(70), name);" | ${prefix}/bin/dbexec echo "ALTER TABLE user CHANGE settings settings blob default NULL;" | ${prefix}/bin/dbexec echo "INSERT INTO sbmALLFUNCDESCR VALUES ('Get_Recid', 'This function gets the recid for a document with a given report-number (as stored in the global variable rn).');" | ${prefix}/bin/dbexec update-v0.92.1-tables: echo "DROP TABLE rnkCITATIONDATA;" | ${prefix}/bin/dbexec ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "UPDATE bibdoc SET status='DELETED' WHERE status='1';" | ${prefix}/bin/dbexec echo "UPDATE bibdoc SET status='' WHERE status='0';" | ${prefix}/bin/dbexec echo "ALTER TABLE bibrec ADD KEY creation_date (creation_date);" | ${prefix}/bin/dbexec echo "ALTER TABLE bibrec ADD KEY modification_date (modification_date);" | ${prefix}/bin/dbexec echo "ALTER TABLE bibdoc ADD KEY creation_date (creation_date);" | ${prefix}/bin/dbexec echo "ALTER TABLE bibdoc ADD KEY modification_date (modification_date);" | ${prefix}/bin/dbexec echo "ALTER TABLE bibdoc ADD KEY docname (docname);" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiHARVEST CHANGE postprocess postprocess varchar(20) NOT NULL default 'h';" | ${prefix}/bin/dbexec echo "ALTER TABLE oaiHARVEST ADD COLUMN bibfilterprogram varchar(255) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE idxINDEXNAME CHANGE ln ln char(5) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE idxINDEX ADD COLUMN stemming_language VARCHAR(10) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkMETHODNAME CHANGE ln ln char(5) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkDOWNLOADS CHANGE id_bibdoc id_bibdoc mediumint(9) unsigned default NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkDOWNLOADS CHANGE file_format file_format varchar(10) NULL default NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE collectionname CHANGE ln ln char(5) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE collection_portalbox CHANGE ln ln char(5) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE format ADD COLUMN visibility TINYINT NOT NULL default 1;" | ${prefix}/bin/dbexec echo "ALTER TABLE formatname CHANGE ln ln char(5) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE fieldname CHANGE ln ln char(5) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE accROLE ADD COLUMN firerole_def_ser blob NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE accROLE ADD COLUMN firerole_def_src text NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE user_accROLE ADD COLUMN expiration datetime NOT NULL default '9999-12-31 23:59:59';" | ${prefix}/bin/dbexec echo "ALTER TABLE user DROP INDEX id, ADD PRIMARY KEY id (id);" | ${prefix}/bin/dbexec echo -e 'from invenio.dbquery import run_sql;\ map(lambda index_id: run_sql("ALTER TABLE idxPHRASE%02dF CHANGE term term TEXT NULL DEFAULT NULL, DROP INDEX term, ADD INDEX term (term (50))" % index_id[0]), run_sql("select id from idxINDEX"))' | $(PYTHON) echo "INSERT INTO rnkCITATIONDATA VALUES (1,'citationdict','','');" | ${prefix}/bin/dbexec echo "INSERT INTO rnkCITATIONDATA VALUES (2,'reversedict','','');" | ${prefix}/bin/dbexec echo "INSERT INTO rnkCITATIONDATA VALUES (3,'selfcitdict','','');" | ${prefix}/bin/dbexec update-v0.99.0-tables: ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "ALTER TABLE bibdoc ADD COLUMN more_info mediumblob NULL default NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE schTASK ADD COLUMN priority tinyint(4) NOT NULL default 0;" | ${prefix}/bin/dbexec echo "ALTER TABLE schTASK ADD KEY priority (priority);" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkCITATIONDATA DROP PRIMARY KEY;" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkCITATIONDATA ADD PRIMARY KEY (id);" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkCITATIONDATA CHANGE id id mediumint(8) unsigned NOT NULL auto_increment;" | ${prefix}/bin/dbexec echo "ALTER TABLE rnkCITATIONDATA ADD UNIQUE KEY object_name (object_name);" | ${prefix}/bin/dbexec echo "ALTER TABLE sbmPARAMETERS CHANGE value value text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE sbmAPPROVAL ADD note text NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE hstDOCUMENT CHANGE docsize docsize bigint(15) unsigned NOT NULL;" | ${prefix}/bin/dbexec echo "ALTER TABLE cmtACTIONHISTORY CHANGE client_host client_host int(10) unsigned default NULL;" | ${prefix}/bin/dbexec update-v0.99.1-tables: echo "RENAME TABLE oaiARCHIVE TO oaiREPOSITORY;" | ${prefix}/bin/dbexec ${prefix}/bin/dbexec < $(top_srcdir)/modules/miscutil/sql/tabcreate.sql echo "INSERT INTO knwKB (id,name,description,kbtype) SELECT id,name,description,'' FROM fmtKNOWLEDGEBASES;" | ${prefix}/bin/dbexec echo "INSERT INTO knwKBRVAL (id,m_key,m_value,id_knwKB) SELECT id,m_key,m_value,id_fmtKNOWLEDGEBASES FROM fmtKNOWLEDGEBASEMAPPINGS;" | ${prefix}/bin/dbexec echo "ALTER TABLE sbmPARAMETERS CHANGE name name varchar(40) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE bibdoc CHANGE docname docname varchar(250) COLLATE utf8_bin NOT NULL default 'file';" | ${prefix}/bin/dbexec echo "ALTER TABLE collection DROP COLUMN restricted;" | ${prefix}/bin/dbexec echo "ALTER TABLE schTASK CHANGE host host varchar(255) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE hstTASK CHANGE host host varchar(255) NOT NULL default '';" | ${prefix}/bin/dbexec echo "ALTER TABLE bib85x DROP INDEX kv, ADD INDEX kv (value(100));" | ${prefix}/bin/dbexec echo "UPDATE clsMETHOD SET location='http://cdsware.cern.ch/download/invenio-demo-site-files/HEP.rdf' WHERE name='HEP' AND location='';" | ${prefix}/bin/dbexec echo "UPDATE clsMETHOD SET location='http://cdsware.cern.ch/download/invenio-demo-site-files/NASA-subjects.rdf' WHERE name='NASA-subjects' AND location='';" | ${prefix}/bin/dbexec echo "UPDATE accACTION SET name='runoairepository', description='run oairepositoryupdater task' WHERE name='runoaiarchive';" | ${prefix}/bin/dbexec echo "UPDATE accACTION SET name='cfgoaiharvest', description='configure OAI Harvest' WHERE name='cfgbibharvest';" | ${prefix}/bin/dbexec echo "ALTER TABLE accARGUMENT CHANGE value value varchar(255);" | ${prefix}/bin/dbexec echo "UPDATE accACTION SET allowedkeywords='doctype,act,categ' WHERE name='submit';" | ${prefix}/bin/dbexec echo "INSERT INTO accARGUMENT(keyword,value) VALUES ('categ','*');" | ${prefix}/bin/dbexec echo "INSERT INTO accROLE_accACTION_accARGUMENT(id_accROLE,id_accACTION,id_accARGUMENT,argumentlistid) SELECT DISTINCT raa.id_accROLE,raa.id_accACTION,accARGUMENT.id,raa.argumentlistid FROM accROLE_accACTION_accARGUMENT as raa JOIN accACTION on id_accACTION=accACTION.id,accARGUMENT WHERE accACTION.name='submit' and accARGUMENT.keyword='categ' and accARGUMENT.value='*';" | ${prefix}/bin/dbexec echo "UPDATE accACTION SET allowedkeywords='name,with_editor_rights' WHERE name='cfgwebjournal';" | ${prefix}/bin/dbexec echo "INSERT INTO accARGUMENT(keyword,value) VALUES ('with_editor_rights','yes');" | ${prefix}/bin/dbexec echo "INSERT INTO accROLE_accACTION_accARGUMENT(id_accROLE,id_accACTION,id_accARGUMENT,argumentlistid) SELECT DISTINCT raa.id_accROLE,raa.id_accACTION,accARGUMENT.id,raa.argumentlistid FROM accROLE_accACTION_accARGUMENT as raa JOIN accACTION on id_accACTION=accACTION.id,accARGUMENT WHERE accACTION.name='cfgwebjournal' and accARGUMENT.keyword='with_editor_rights' and accARGUMENT.value='yes';" | ${prefix}/bin/dbexec echo "ALTER TABLE bskEXTREC CHANGE id id int(15) unsigned NOT NULL auto_increment;" | ${prefix}/bin/dbexec echo "ALTER TABLE bskEXTREC ADD external_id int(15) NOT NULL default '0';" | ${prefix}/bin/dbexec echo "ALTER TABLE bskEXTREC ADD collection_id int(15) unsigned NOT NULL default '0';" | ${prefix}/bin/dbexec echo "ALTER TABLE bskEXTREC ADD original_url text;" | ${prefix}/bin/dbexec CLEANFILES = *~ *.pyc *.tmp diff --git a/modules/bibedit/lib/Makefile.am b/modules/bibedit/lib/Makefile.am index 5cd13131d..d741077d4 100644 --- a/modules/bibedit/lib/Makefile.am +++ b/modules/bibedit/lib/Makefile.am @@ -1,53 +1,54 @@ ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio 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; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. pylibdir = $(libdir)/python/invenio pylib_DATA = bibrecord_config.py \ bibrecord.py \ bibrecord_tests.py \ refextract_config.py \ refextract.py \ xmlmarc2textmarclib.py \ bibedit_config.py \ bibeditold_dblayer.py \ bibedit_dblayer.py \ bibeditold_engine.py \ bibedit_engine.py \ bibedit_regression_tests.py \ bibeditold_templates.py \ bibedit_templates.py \ bibeditcli.py \ bibeditold_utils.py \ bibedit_utils.py \ bibedit_webinterface.py \ bibeditmulti_templates.py \ bibeditmulti_webinterface.py \ bibeditmulti_engine.py jsdir=$(localstatedir)/www/js js_DATA = bibedit_display.js \ bibedit_engine.js \ bibedit_keys.js \ bibedit_menu.js \ - bibeditmulti.js + bibeditmulti.js \ + bibedit_holdingpen.js EXTRA_DIST = $(pylib_DATA) \ $(js_DATA) CLEANFILES = *~ *.tmp *.pyc diff --git a/modules/bibedit/lib/bibedit_config.py b/modules/bibedit/lib/bibedit_config.py index 0efd91e26..05c4151d7 100644 --- a/modules/bibedit/lib/bibedit_config.py +++ b/modules/bibedit/lib/bibedit_config.py @@ -1,145 +1,160 @@ ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio 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; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """BibEdit Configuration.""" __revision__ = "$Id$" from invenio.config import CFG_ETCDIR import os ## CFG_BIBEDIT_FILENAME - default filename for BibEdit files. CFG_BIBEDIT_FILENAME = "bibedit_record" ## The CFG_BIBEDIT_JS_* constants are passed on and used by the BibEdit ## Javascript engine. ## CFG_BIBEDIT_JS_HASH_CHECK_INTERVAL - interval (in ms) between checking if ## hash has changed. CFG_BIBEDIT_JS_HASH_CHECK_INTERVAL = 250 ## CFG_BIBEDIT_JS_CHECK_SCROLL_INTERVAL - interval (in ms) between menu ## repositioning. CFG_BIBEDIT_JS_CHECK_SCROLL_INTERVAL = 250 ## CFG_BIBEDIT_JS_STATUS_INFO_TIME - display status info messages for how long ## (in ms). CFG_BIBEDIT_JS_STATUS_INFO_TIME = 1000 ## CFG_BIBEDIT_JS_STATUS_ERROR_TIME - display status error messages for how long ## (in ms). CFG_BIBEDIT_JS_STATUS_ERROR_TIME = 2000 ## CFG_BIBEDIT_JS_CLONED_RECORD_COLOR - Color of cloned record ID highlighting. CFG_BIBEDIT_JS_CLONED_RECORD_COLOR = 'yellow' ## CFG_BIBEDIT_JS_CLONED_RECORD_COLOR_FADE_DURATION - Duration (in ms) for the ## fading of cloned record ID highlighting. CFG_BIBEDIT_JS_CLONED_RECORD_COLOR_FADE_DURATION = 5000 ## CFG_BIBEDIT_JS_NEW_ADD_FIELD_FORM_COLOR - Color of new field forms' ## highlighting. CFG_BIBEDIT_JS_NEW_ADD_FIELD_FORM_COLOR = 'lightblue' ## CFG_BIBEDIT_JS_NEW_ADD_FIELD_FORM_COLOR_FADE_DURATION - Duration (in ms) for ## the fading of new field forms' highlighting. CFG_BIBEDIT_JS_NEW_ADD_FIELD_FORM_COLOR_FADE_DURATION = 2000 ## CFG_BIBEDIT_JS_NEW_FIELDS_COLOR - Color of new fields' highlighting CFG_BIBEDIT_JS_NEW_FIELDS_COLOR = 'lightgreen' ## CFG_BIBEDIT_JS_NEW_FIELDS_COLOR_FADE_DURATION - Duration (in ms) for the ## fading of new fields' highlighting. CFG_BIBEDIT_JS_NEW_FIELDS_COLOR_FADE_DURATION = 2000 ## CFG_BIBEDIT_JS_NEW_CONTENT_HIGHLIGHT_DELAY - Duration (in ms) before ## highlighting newly modified content. ## WARNING: If set to low, the Jeditable plugin won't have time to update the ## cell with the new content (recommended: >50). CFG_BIBEDIT_JS_NEW_CONTENT_HIGHLIGHT_DELAY = 50 ## CFG_BIBEDIT_JS_NEW_FIELDS_COLOR - Color of new fields' highlighting CFG_BIBEDIT_JS_NEW_CONTENT_COLOR = 'lightgreen' ## CFG_BIBEDIT_JS_NEW_FIELDS_COLOR_FADE_DURATION - Duration (in ms) for the ## fading of new fields' highlighting. CFG_BIBEDIT_JS_NEW_CONTENT_COLOR_FADE_DURATION = 2000 ## CFG_BIBEDIT_JS_TICKET_REFRESH_DELAY - Duration (in ms) before refreshing ## a record's tickets after the user clicks on the link to create a new one. ## WARNING: If set to low, the request for RT to generate the ticket won't have ## time to finish (recommended: >2000). CFG_BIBEDIT_JS_TICKET_REFRESH_DELAY = 5000 ## CFG_BIBEDIT_AJAX_RESULT_CODES - dictionary of result codes and messages used ## by the Ajax engine. + +CFG_BIBEDIT_AJAX_RESULT_CODES_REV= { +#TODO: all the result codes should be accessible through the constants rather than +# a direct number ! some parts of the bibedit_engine.py are not readable because +# of using the numbers +# The dictionary is convenient at this place because it can be imported with one command +# unlike a number of constants + 'editor_modifications_changed': 33, + 'disabled_hp_changeset' : 34, + 'wrong_cache_file_format' : 111 +} + CFG_BIBEDIT_AJAX_RESULT_CODES = { 0: '', 1: 'Search completed', 2: 'Tag format changed', 3: 'Record loaded', 4: 'Record submitted', 5: 'Cancelled', 6: 'Record created (new)', 7: 'Record created (from template)', 8: 'Record created (from existing)', 9: 'Record cloned', 10: 'Record deleted', 11: 'Cache deleted', 12: 'Record ready for merge', 20: 'Added controlfield', 21: 'Added field', 22: 'Added subfield', 23: 'Added subfields', 24: 'Content modified', 25: 'Subfield moved', 26: 'Field deleted', 27: 'Fields deleted', 28: 'Subfield deleted', 29: 'Subfields deleted', 30: 'Selection deleted', 31: 'Tickets retrieved', 32: 'Field moved', + 33: 'Modifications updates', + 34: 'Disabled a changeset', 100: 'Error: Not logged in', 101: 'Error: Permission denied', 102: 'Error: Non-existent record', 103: 'Error: Deleted record', 104: 'Error: Record locked by user', 105: 'Error: Record locked by queue', 106: 'Error: Cache file missing', 107: 'Error: Cache file changed', 108: 'Error: Template file missing', 109: 'Error: Invalid template file', - 110: 'Error: Invalid content in record' + 110: 'Error: Invalid content in record', + 111: 'Error: Wrong cache file format' } ## CFG_BIBEDIT_MAX_SEARCH_RESULTS CFG_BIBEDIT_MAX_SEARCH_RESULTS = 99 ## CFG_BIBEDIT_TAG_FORMAT - default format to use when displaying MARC tags. CFG_BIBEDIT_TAG_FORMAT = 'MARC' ## CFG_BIBEDIT_TO_MERGE_SUFFIX - default filename suffix for XML file to be ## merged. Filename will then be constructed like this: ## ___.xml CFG_BIBEDIT_TO_MERGE_SUFFIX = 'merge' # CFG_BIBEDIT_RECORD_TEMPLATES_PATH - path to record template directory CFG_BIBEDIT_RECORD_TEMPLATES_PATH = "%s%sbibedit%srecord_templates" % (CFG_ETCDIR, os.sep, os.sep) CFG_BIBEDIT_FIELD_TEMPLATES_PATH = "%s%sbibedit%sfield_templates" % (CFG_ETCDIR, os.sep, os.sep) diff --git a/modules/bibedit/lib/bibedit_dblayer.py b/modules/bibedit/lib/bibedit_dblayer.py index e72be266b..9e5367353 100644 --- a/modules/bibedit/lib/bibedit_dblayer.py +++ b/modules/bibedit/lib/bibedit_dblayer.py @@ -1,67 +1,80 @@ ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio 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; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # pylint: disable-msg=C0103 """BibEdit Database Layer.""" __revision__ = "$Id$" from invenio.dbquery import run_sql def get_name_tags_all(): """Return a dictionary of all MARC tag's textual names.""" result = run_sql("SELECT name, value FROM tag") # Collect names in a dictionary with field codes as keys. nametags = {} for el in result: nametags[el[1]] = el[0] return nametags def get_bibupload_task_opts(task_ids): """Return a list with all set options for list of task IDs TASK_IDS.""" res = [] for task_id in task_ids: res.append(run_sql("SELECT arguments FROM schTASK WHERE id=%s" % task_id)) return res def get_marcxml_of_record_revision(recid, job_date): """Return MARCXML string of record revision specified by RECID and JOB_DATE. """ return run_sql("""SELECT marcxml FROM hstRECORD WHERE id_bibrec=%s AND job_date=%s""", (recid, job_date)) def get_record_revisions(recid): """Return dates for all known revisions of record RECID.""" return run_sql("""SELECT id_bibrec, DATE_FORMAT(job_date, '%%Y%%m%%d%%H%%i%%s') FROM hstRECORD WHERE id_bibrec=%s ORDER BY job_date DESC""" % recid) def get_record_last_modification_date(recid): """Return last modification date, as timetuple, of record RECID.""" return run_sql('SELECT modification_date FROM bibrec WHERE id=%s' % recid)[0][0].timetuple() def reserve_record_id(): """Reserve a new record ID in the bibrec table.""" return run_sql("""INSERT INTO bibrec (creation_date, modification_date) VALUES (NOW(), NOW())""") + +def get_related_hp_changesets(recId): + """ + A function returning the changesets saved in the Holding Pen, related + to the given record. + """ + return run_sql("""SELECT changeset_id, changeset_date FROM bibHOLDINGPEN WHERE id_bibrec='%(identifier)s' ORDER BY changeset_date""" % {"identifier" : recId}) + +def get_hp_update_xml(changeId): + return run_sql("""SELECT changeset_xml, id_bibrec from bibHOLDINGPEN where changeset_id=%s""", (str(changeId),))[0] + +def delete_hp_change(changeId): + return run_sql("""delete from bibHOLDINGPEN where changeset_id=%i""" % (changeId, )) diff --git a/modules/bibedit/lib/bibedit_display.js b/modules/bibedit/lib/bibedit_display.js index 194d442a6..8442542aa 100644 --- a/modules/bibedit/lib/bibedit_display.js +++ b/modules/bibedit/lib/bibedit_display.js @@ -1,642 +1,978 @@ /* * This file is part of CDS Invenio. * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 2009 CERN. * * CDS Invenio 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; either version 2 of the * License, or (at your option) any later version. * * CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ /* * This is the BibEdit Javascript for generation of webpage elements and HTML. */ function displayRecord(){ /* * Create the main content table. */ var table = '' + '' + '' + '' + '' + '' + '' + '' + // Create a dummy row to hack layout in like FF.. '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + ''; var tags = getTagsSorted(), tag, fields; // For each controlfield, create row. for (var i=0, n=tags.length; i' + '' + '' + + input('checkbox', 'boxField_' + fieldID, 'bibEditBoxField', + {onclick: 'onFieldBoxClick(this)', tabindex: -1}) + + '' + '' + - '' + - '' + - '' + + getFieldTag(tag) + + '' + + '' + + '' + + '' + '' + ''; } function createField(tag, field, fieldPosition){ /* * Create field row(s). */ var subfields = field[0], ind1 = field[1], ind2 = field[2]; var fieldID = tag + '_' + fieldPosition; ind1 = (ind1 != ' ' && ind1 != '') ? ind1 : '_'; ind2 = (ind2 != ' ' && ind2 != '') ? ind2 : '_'; var protectedField = fieldIsProtected(tag + ind1 + ind2); var subfieldsLength = subfields.length; var result = ''; for (var i=0, n=subfields.length; i'; } function createRow(tag, ind1, ind2, subfieldCode, subfieldValue, fieldID, - subfieldIndex, subfieldsLength, protectedField){ + subfieldIndex, subfieldsLength, protectedField){ /* * Create single row (not controlfield). */ var MARC = tag + ind1 + ind2 + subfieldCode; var protectedSubfield = (protectedField) ? true : fieldIsProtected(MARC); var subfieldID = fieldID + '_' + subfieldIndex; var boxField = '', cellFieldTagAttrs = 'class="bibEditCellField"', fieldTagToPrint = '', cellContentClass = 'bibEditCellContentProtected', cellContentTitle='', cellContentOnClick = ''; if (!protectedField){ // Enable features for unprotected fields. if (!protectedSubfield){ cellContentClass = 'bibEditCellContent'; cellContentTitle = 'title="Click to edit" '; cellContentOnClick = 'onclick="onContentClick(this)" '; } } cellContentAdditionalClass = ""; if (subfieldValue.substring(0,9) == "VOLATILE:"){ subfieldValue = subfieldValue.substring(9); cellContentAdditionalClass += " bibEditVolatileSubfield"; } var boxSubfield = input('checkbox', 'boxSubfield_' + subfieldID, 'bibEditBoxSubfield', {onclick: 'onSubfieldBoxClick(this)', tabindex: -1}); var subfieldTagToPrint = getSubfieldTag(MARC); var btnAddSubfield = ''; // If first subfield, add tag and selection box, remove up arrow. if (subfieldIndex == 0){ boxField = input('checkbox', 'boxField_' + fieldID, 'bibEditBoxField', {onclick: 'onFieldBoxClick(this)', tabindex: -1}); cellFieldTagAttrs = 'id="fieldTag_' + fieldID + '" class="bibEditCellFieldTag"'; fieldTagToPrint = getFieldTag(MARC); } // If last subfield, remove down arrow, add 'Add subfield' button. if (subfieldIndex == subfieldsLength - 1){ if (!protectedField) btnAddSubfield = img('/img/add.png', 'btnAddSubfield_' + fieldID, '', {title: 'Add subfield', onclick: 'onAddSubfieldsClick(this)'}); } return '' + '' + '' + '' + '' + '' + '' + '' + ''; } -function redrawFields(tag){ +function redrawFields(tag, skipAddFileds){ /* * Redraw all fields for a given tag. + * skipAddFileds - forces to skip drawing the controls corresponding to the + * change of adding a field */ var rowGroup = $('#rowGroup_' + tag + '_0'), prevRowGroup; if (rowGroup.length){ // Remove the fields from view. prevRowGroup = rowGroup.prev(); prevRowGroup.nextAll('[id^=rowGroup_' + tag + ']').remove(); } else{ // New tag. Determine previous sibling. var prevTag = getPreviousTag(tag); prevRowGroup = $('#rowGroup_' + prevTag + '_0'); } // Redraw all fields and append to table. if (gRecord[tag]){ var fields = gRecord[tag]; var result = '', i, n; if (validMARC.reControlTag.test(tag)){ for (i=0, n=fields.length; i"; +} + +function getRejectChangeButton(changeNo){ + /*The button allowing to reject the change - and remove the control from the user interface*/ + result = ""; + return result; +} + +function getAddInsteadOfChangeButton(functionName, changeNo){ + /*The button allowing to reject the change - and remove the control from the user interface*/ + result = ""; + return result; +} + +function addSubfieldChangedControl(changeNo){ + fieldId = gHoldingPenChanges[changeNo]["tag"]; + fieldPos = gHoldingPenChanges[changeNo]["field_position"]; + sfPos = gHoldingPenChanges[changeNo]["subfield_position"]; + content = gHoldingPenChanges[changeNo]["subfield_content"]; + + applyButton = getApplyChangeButton("applySubfieldChanged", changeNo); + rejectButton = getRejectChangeButton(changeNo); + addButton = getAddInsteadOfChangeButton("applyFieldAdded", changeNo); // apply the change as if it was adding the subfield ( the data is the same) + + /*adds a control allowing to change the subfield content*/ + + newel = "
New value: " + content + + "  " + + applyButton + + rejectButton + + addButton + + "
"; + + $("#content_" + fieldId + "_" + fieldPos + "_" + sfPos).append(newel); +} + +function addSubfieldAddedControl(changeNo){ + /*adds a control allowing to add a new subfield using the holding pen*/ + + fieldId = gHoldingPenChanges[changeNo].tag; + fieldPos = gHoldingPenChanges[changeNo].field_position; + subfieldCode = gHoldingPenChanges[changeNo].subfield_code; + subfieldContent = gHoldingPenChanges[changeNo].subfield_content; + + applyButton = getApplyChangeButton("applySubfieldAdded", changeNo); + rejectButton = getRejectChangeButton(changeNo); + + subfieldPreview = "$$" + subfieldCode + "   " + subfieldContent; + newel = "
"; + + $("#rowGroup_" + fieldId + "_" + fieldPos).append(newel); +} + +function addSubfieldRemovedControl(changeNo){ + /*adds a control allowing to apply the change of removing the subfield */ + fieldId = gHoldingPenChanges[changeNo]["tag"]; + fieldPos = gHoldingPenChanges[changeNo]["field_position"]; + sfPos = gHoldingPenChanges[changeNo]["subfield_position"]; + + applyButton = getApplyChangeButton("applySubfieldRemoved", changeNo); + rejectButton = getRejectChangeButton(changeNo); + + newel = "
The subfield has been removed " + + "" + applyButton + rejectButton + "
"; + $("#content_" + fieldId + "_" + fieldPos + "_" + sfPos).append(newel); +} + +function addFieldRemovedControl(changeNo){ + /*adds a control allowing the change of removing the Field*/ + + fieldId = gHoldingPenChanges[changeNo]["tag"]; + fieldPos = gHoldingPenChanges[changeNo]["field_position"]; + + applyButton = getApplyChangeButton("applyFieldRemoved", changeNo); + rejectButton = getRejectChangeButton(changeNo); + + newel = ""; + + $("#rowGroup_" + fieldId + "_" + fieldPos).append(newel); +} + +function addFieldChangedControl(changeNo){ + /*adds a control allowing the change of removing the Field*/ + + fieldId = gHoldingPenChanges[changeNo]["tag"]; + indicators = gHoldingPenChanges[changeNo]["indicators"]; + fieldPos = gHoldingPenChanges[changeNo]["field_position"]; + fieldContent = gHoldingPenChanges[changeNo]["field_content"]; + + applyButton = getApplyChangeButton("applyFieldChanged", changeNo); + rejectButton = getRejectChangeButton(changeNo); + addButton = getAddInsteadOfChangeButton("applyFieldAdded", changeNo); + + fieldPreview = createFieldPreview(fieldId, indicators, fieldContent); + + newel = ""; + + $("#rowGroup_" + fieldId + "_" + fieldPos).append(newel); +} + + +function addFieldAddedControl(changeNo){ +/*adds a control allowing the change of adding the Field*/ + + fieldId = gHoldingPenChanges[changeNo]["tag"]; + indicators = gHoldingPenChanges[changeNo]["indicators"]; + field = gHoldingPenChanges[changeNo]["field_content"]; + fieldContent = createFieldPreview(fieldId, indicators, field); + //fieldContent = returnASummaryOfTheField(fieldId, field); + applyButton = getApplyChangeButton("applyFieldAdded", changeNo); + rejectButton = getRejectChangeButton(changeNo); + + content = "
" + + "
A field has been added in the Holding Pen entry
" + + "
" + fieldContent + "
" + + "
" + + applyButton + rejectButton + + "
"; + + $('#bibEditContent').append(content); +} + +function addChangeControl(changeNum, skipAddedField){ + // creates a web controls responsible for applying a particular change + // changeNum is the number of the change - it is the same as the index in gHoldingPenChanges + // global array + changeType = gHoldingPenChanges[changeNum]["change_type"]; + if ( changeType == "field_added" && skipAddedField != true){ + addFieldAddedControl(changeNum); + } + if ( changeType == "subfield_changed"){ + addSubfieldChangedControl(changeNum); + } + if ( changeType == "subfield_removed"){ + addSubfieldRemovedControl(changeNum); + } + if ( changeType == "subfield_added"){ + addSubfieldAddedControl(changeNum); + } + if ( changeType == "field_removed"){ + addFieldRemovedControl(changeNum); + } + if ( changeType == "field_changed"){ + addFieldChangedControl(changeNum); + } +} + + +/// the functions for creating the previews + +function createFieldPreviewCore(tag, indicators, subfields){ + /** A function creating a viewable preview of the records*/ + + headerData = tag + indicators + "   "; + result = ""; + + for (subfield in subfields){ + result += ""; + headerData = ""; + } + return result; +} + +function createFieldPreview(tag, indicators, subfields){ + /*Creating a preview of a single field*/ + return "
' + - input('checkbox', 'boxField_' + fieldID, 'bibEditBoxField', - {onclick: 'onFieldBoxClick(this)', tabindex: -1}) + - '' + - getFieldTag(tag) + - '' + escapeHTML(field[3]) + - '' + escapeHTML(field[3]) + + '
' + boxField + '' + fieldTagToPrint + '' + boxSubfield + '' + - subfieldTagToPrint + + '" class="bibEditCellSubfieldTag">' + + subfieldTagToPrint + '' + - subfieldValue + + cellContentTitle + cellContentOnClick + 'tabindex="0">' + + subfieldValue + '' + btnAddSubfield + '
" + + "
Subfield added: " + subfieldPreview + "" + + "
" + applyButton + rejectButton +"
Field has been removed in the Holding Pen. " + + applyButton + rejectButton + + "
Field structure has changed. New value: " + + fieldPreview + "
" + applyButton + rejectButton + addButton + + "
" + + headerData + + "$$" + + subfields[subfield][0] + + "   " + + subfields[subfield][1] + + "
" + createFieldPreviewCore(tag, indicators, subfields) + "
"; +} + +function createRecordPreview(recordData){ + /**A function creating a preview of the record*/ + + // 1) sorting Tags + unsortedTags = []; + for (tag in recordData){ + unsortedTags.push(tag); + } + tags = unsortedTags.sort(); + + result = ""; + for (tagIndex in tags){ + tag = tags[tagIndex]; + // now we have to sort the fields by the indicators + unsortedIndicators = []; + indicatorLists = {}; + + for (field in recordData[tag]){ + indicators = (recordData[tag][field][1] == ' ' ? '_' : recordData[tag][field][1] ) + + (recordData[tag][field][2] == ' ' ? '_' : recordData[tag][field][2] ); + if (indicatorLists[indicators] == undefined){ + indicatorLists[indicators] = []; + unsortedIndicators.push(indicators); + } + indicatorLists[indicators].push(field); + } + sortedIndicators = unsortedIndicators.sort(); + + // traversing all the fields in previously indicated order + + for (indicatorsInd in sortedIndicators){ + indicators = sortedIndicators[indicatorsInd]; + for (fieldInd in indicatorLists[indicators]){ + field = indicatorLists[indicators][fieldInd]; + result += createFieldPreviewCore(tag, indicators, recordData[tag][field][0]); + } + } + } + result += "
"; + return result; +} + +/// the entries on the left, in the panel + +function createHoldingPenChangePreview(record){ + /** A function creating the content + * + * Parameters: + * record - A content of the record that should be previewed + */ + + return createRecordPreview(record) + + "
"; +} + +function createHoldingPenPanelEntry(changesetNumber, changesetDatetime){ + /** + * A function creating the panel entry describing one changeset + * Parameters: + * + * changesetNumber - the internal changeset number ( from the Holding Pen ) + * changesetDatetime - the data of harvesting the changeset + * + * Returns: The HTML code of the control + */ + + manipulationControlsSection = //"
" + + button("", + id = ("bibeditHPApplyChange" + changesetNumber), + _class = "bibeditHPControl", + attrs = { + "onClick" : + ("return holdingPenPanelApplyChangeSet("+ changesetNumber + ");") + }) + + button("", + id = ("bibeditHPRemoveChange" + changesetNumber), + _class = "bibeditHPControl", + attrs = { + "onClick" : + ("return holdingPenPanelRemoveChangeSet("+ changesetNumber + ");") + }); + //"
"; + + numberSection = "
No" + changesetNumber + "
"; + + datetimeSection = "
" + changesetDatetime + "
"; + + previewOpener = "
+
"; + + previewLayer = "
" + + "Loading...
" + + "
"; // a toggle button ; + + previewSection = previewOpener + previewLayer + + result = "
" + + "
" + + "
" + numberSection + previewSection + "
" + + "
" + datetimeSection + "
" + + "
"+ manipulationControlsSection + "
" + + "
"; + + return result; + //informationsSection = "
" + numberSection + previewSection + datetimeSection + "
"; + + //return "
" + informationsSection + manipulationControlsSection + "
"; +} + +function createGeneralControlsPanel(){ + /** Generating a panel that allows to perform global operations on the previewed changes*/ + result = "
"; + result += ""; + result += ""; + result += "
"; + + return result; } +/// end of the Holding Pen Connected functions function createAddFieldForm(fieldTmpNo, fieldTemplateNo){ /* * Create an 'Add field' form. * fieldTmpNo - temporary field number * fieldTemplateNo - a number of template that should be selected by default */ fieldTemplatesData = [] for (templatePos in fieldTemplates){ fieldTemplatesData.push({"value" : templatePos , "description": fieldTemplates[templatePos].name}); } return '' + '' + '' + '' + 'New' + '' + '' + '
Add field: ' + select('selectAddFieldTemplate_' + fieldTmpNo, fieldTemplatesData, fieldTemplateNo) + '
Add ' + input('text', 'selectAddFieldTemplateTimes_' + fieldTmpNo, "addFieldAddSimilarInput", {"maxlength" : 4, "size": 1}) + button('similar', 'selectAddSimilarFields_' + fieldTmpNo, "", {}) + '
' + '' + img('/img/add.png', 'btnAddFieldAddSubfield_' + fieldTmpNo, '', { title: 'Add subfield'}) + '' + '' + createAddFieldRow(fieldTmpNo, 0) + // adding a row used to insert at the end without repositioning the tag and indicators '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; } function createAddFieldRow(fieldTmpNo, subfieldTmpNo, defaultCode, defaultValue){ /* * Create a row in the 'Add field' form. * optional parameters: * defaultCode - the subfield code displayed by default * defaultValue - the subfield value displayed by default */ var fieldCode = ""; var fieldValue = ""; if (defaultCode != undefined && defaultCode != " "){ fieldCode = defaultCode; } if (defaultValue != undefined && defaultValue != " "){ fieldValue = defaultValue; } var isVolatile = (defaultValue != undefined && defaultValue.substring(0, 9) == "VOLATILE:"); var additionalClass = ""; if (isVolatile){ additionalClass = " bibEditVolatileSubfield"; fieldValue = fieldValue.substring(9); } var txtAddFieldTag = '', txtAddFieldInd1 = '', txtAddFieldInd2 = '', btnAddFieldRemove = ''; if (subfieldTmpNo == 0){ txtAddFieldTag = input('text', 'txtAddFieldTag_' + fieldTmpNo, - 'bibEditTxtTag', {maxlength: 3}); + 'bibEditTxtTag', {maxlength: 3}); txtAddFieldInd1 = input('text', 'txtAddFieldInd1_' + fieldTmpNo, - 'bibEditTxtInd', {maxlength: 1}); + 'bibEditTxtInd', {maxlength: 1}); txtAddFieldInd2 = input('text', 'txtAddFieldInd2_' + fieldTmpNo, - 'bibEditTxtInd', {maxlength: 1}); + 'bibEditTxtInd', {maxlength: 1}); } else btnAddFieldRemove = img('/img/delete.png', 'btnAddFieldRemove_' + fieldTmpNo + '_' + subfieldTmpNo, '', {title: 'Remove subfield'}); return '' + '' + '' + '' + - txtAddFieldTag + txtAddFieldInd1 + txtAddFieldInd2 + + txtAddFieldTag + txtAddFieldInd1 + txtAddFieldInd2 + '' + '' + '' + input('text', 'txtAddFieldSubfieldCode_' + fieldTmpNo + '_' + subfieldTmpNo, 'bibEditTxtSubfieldCode', {maxlength: 1, value: fieldCode}) + '' + '' + input('text', 'txtAddFieldValue_' + fieldTmpNo + '_' + subfieldTmpNo, 'bibEditTxtValue' + additionalClass, {value : fieldValue}) + '' + '' + btnAddFieldRemove + '' + ''; } function createAddSubfieldsForm(fieldID){ /* * Create an 'Add subfields' form. */ return '' + createAddSubfieldsRow(fieldID, 0) + '' + '' + '' + '' + '' + '' + '' + '' + ''; } function createAddSubfieldsRow(fieldID, subfieldTmpNo){ /* * Create a row in the 'Add subfields' form. */ var subfieldID = fieldID + '_' + subfieldTmpNo; var btnRemove = (subfieldTmpNo == 0) ? '' : img('/img/delete.png', 'btnAddSubfieldsRemove_' + subfieldID, '', {title: 'Remove subfield'}); return '' + '' + '' + '' + '' + '' + - input('text', 'txtAddSubfieldsCode_' + subfieldID, - 'bibEditTxtSubfieldCode', {maxlength: 1}) + + input('text', 'txtAddSubfieldsCode_' + subfieldID, + 'bibEditTxtSubfieldCode', {maxlength: 1}) + '' + '' + - input('text', 'txtAddSubfieldsValue_' + subfieldID, 'bibEditTxtValue') + + input('text', 'txtAddSubfieldsValue_' + subfieldID, 'bibEditTxtValue') + '' + '' + btnRemove + '' + ''; } function displayMessage(msgCode, keepContent, args){ /* * Display message in the main work area. Messages codes returned from the * server (positive integers) are as specified in the BibEdit configuration. */ var msg; switch (msgCode){ case -1: msg = 'Search term did not match any records.'; break; case 0: msg = 'A server error has occured. Please contact your system ' + - 'administrator.
' + - 'Error code: ' + msgCode + ''; + 'administrator.
' + + 'Error code: ' + msgCode + ''; break; case 4: msg = 'Your modifications have now been submitted. ' + - 'They will be processed as soon as the task queue is empty.'; + 'They will be processed as soon as the task queue is empty.'; break; case 6: msg = 'The record will be deleted as soon as the task queue is empty.'; break; case 101: msg = 'Could not access record. Permission denied.'; break; case 102: msg = 'This record does not exist. Please try another record ID.'; break; case 103: msg = 'Cannot edit deleted record.'; break; case 104: msg = 'This record is currently being edited by another user. Please ' + - 'try again later.'; + 'try again later.'; break; case 105: msg = 'This record cannot be safely edited at the moment. Please ' + - 'try again in a few minutes.'; + 'try again in a few minutes.'; break; case 106: msg = 'A server error has occured. You may have lost your changes to ' + - 'this record.
' + - 'Error code: ' + msgCode + ' (missing cache file)'; + 'this record.
' + + 'Error code: ' + msgCode + ' (missing cache file)'; break; case 107: msg = 'It appears that you have opened this record in another editor, ' + - 'perhaps in a different window or on a different computer. A record ' + - 'can only be edited in one place at the time.
' + - 'Do you want to ' + - 'reopen the record here?'; - break; + 'perhaps in a different window or on a different computer. A record ' + + 'can only be edited in one place at the time.
' + + 'Do you want to ' + + 'reopen the record here?'; + break; case 108: msg = 'Could not find record template file. Please notify your system ' + - 'administrator.'; + 'administrator.'; break; case 109: msg = 'The record template file is invalid. Please notify your system ' + - 'administrator'; + 'administrator'; break; case 110: msg = 'The record contains invalid content. Remove the invalid content ' + - 'and resubmit the record.
' + - 'Errors: ' + args[0] + '

'; + 'and resubmit the record.
' + + 'Errors: ' + args[0] + '

'; break; default: msg = 'Result code: ' + msgCode + ''; } if (!keepContent) $('#bibEditContent').html('
' + msg + '
'); else $('#bibEditContent').prepend('
' + msg + '
'); } function displayNewRecordScreen(){ /* * Display options for creating a new record: An empty record or a template * selected from a list of templates. */ var msg = '
  • ' + 'Empty record
  • ' + '
  • Use record template:' + ''; var templatesCount = gRECORD_TEMPLATES.length; if (!templatesCount) msg += ''; else{ for (var i=0, n=templatesCount; i' + - '' + - gRECORD_TEMPLATES[i][1] + '' + - ''; + '' + + ''; } msg += '
    No record templates found' + '
    ' + - '' + gRECORD_TEMPLATES[i][2] + '
    ' + + '' + + gRECORD_TEMPLATES[i][1] + '' + + '' + gRECORD_TEMPLATES[i][2] + '
  • '; $('#bibEditContent').html(msg); } function displayCacheOutdatedScreen(requestType){ /* * Display options to resolve the outdated cache scenario (DB record updated * during editing). Options differ depending on wether the situation was * discovered when fetching or when submitting the record. */ $('#bibEditMessage').remove(); var recordURL = gSITE_URL + '/record/' + gRecID + '/'; var viewMARCURL = recordURL + '?of=hm'; var viewMARCXMLURL = recordURL + '?of=xm'; var msg = ''; if (requestType == 'submit') msg = 'Someone has changed this record while you were editing. ' + 'You can:
      ' + '
    • View (HTML,' + ' MARC,' + ' MARCXML' + ') the latest version
    • ' + '
    • Merge your changes ' + 'with the latest version by using the merge interface
    • ' + '
    • Force your changes ' + '(Warning: overwrites the latest version)
    • ' + '
    • HTML,' + ' MARC,' + ' MARCXML' + ') the latest version
    • ' + '
    • Merge your changes ' + 'with the latest version by using the merge interface
    • ' + '
    • Get the latest version' + ' (Warning: discards your changes)
    • ' + '
    • Keep editing. When submitting you will be offered to overwrite ' + 'the latest version. Click here' + ' to remove this message.
    • ' + '
    '; $('#bibEditContent').prepend('
    ' + msg + '
    '); } function displayAlert(msgType, args){ /* * Display pop-up of type alert or confirm. * args can be an array with additional arguments. */ var msg; var popUpType = 'alert'; switch (msgType){ case 'confirmClone': msg = 'Clone this record?\n\n'; popUpType = 'confirm'; break; case 'confirmSubmit': msg = 'Submit your changes to this record?\n\n'; popUpType = 'confirm'; break; case 'confirmCancel': msg = 'You have unsubmitted changes to this record.\n\n' + - 'Discard your changes?'; + 'Discard your changes?'; popUpType = 'confirm'; break; case 'confirmDeleteRecord': msg = 'Really delete this record?\n\n'; popUpType = 'confirm'; break; case 'confirmInvalidOrEmptyInput': msg = 'WARNING: Some subfields contain invalid MARC or are empty. \n' + - 'Click Cancel to go back and correct. \n' + - 'Click OK to ignore and continue (only valid subfields will be saved).'; + 'Click Cancel to go back and correct. \n' + + 'Click OK to ignore and continue (only valid subfields will be saved).'; popUpType = 'confirm'; break; case 'confirmLeavingChangedRecord': msg = '******************** WARNING ********************\n' + - ' You have unsubmitted changes.\n\n' + - 'You should go back to the record and click either:\n' + - ' * Submit (to save your changes permanently)\n or\n' + - ' * Cancel (to discard your changes)\n\n' + - 'Press OK to continue, or Cancel to stay on the current record.'; + ' You have unsubmitted changes.\n\n' + + 'You should go back to the record and click either:\n' + + ' * Submit (to save your changes permanently)\n or\n' + + ' * Cancel (to discard your changes)\n\n' + + 'Press OK to continue, or Cancel to stay on the current record.'; popUpType = 'confirm'; break; case 'alertCriticalInput': msg = 'ERROR: Your input had critical errors. Please go back and ' + - 'correct any fields with invalid MARC (red border) or fields that ' + - 'should not be empty.'; + 'correct any fields with invalid MARC (red border) or fields that ' + + 'should not be empty.'; break; case 'alertAddProtectedField': msg = 'ERROR: Cannot add protected field ' + args[0] + '.'; break; case 'alertAddProtectedSubfield': msg = 'ERROR: Cannot add protected subfield ' + args[0] + '.'; break; case 'alertEmptySubfieldsList': msg = "The field has to contain at least one non-empty subfield."; break; case 'alertDeleteProtectedField': msg = 'ERROR: Cannot delete protected field ' + args[0] + '.'; break; default: msg = msgType; } if (popUpType == 'confirm') return confirm(msg); else alert(msg); } function notImplemented(event){ /* * Handle unimplemented function. */ alert('Sorry, this function is not implemented yet!'); event.preventDefault(); } function button(value, id, _class, attrs){ /* * Create a button tag with specified attributes. */ value = (value != undefined) ? value : ''; id = id ? 'id="' + id + '" ' : ''; _class = _class ? 'class="' + _class + '" ' : ''; var strAttrs = ''; for (var attr in attrs){ strAttrs += attr + '="' + attrs[attr] + '" '; } return ''; } function img(src, id, _class, attrs){ /* * Create an image tag with specified attributes. */ src = 'src="' + src + '" '; id = id ? 'id="' + id + '" ' : ''; _class = _class ? 'class="' + _class + '" ' : ''; var strAttrs = ''; for (var attr in attrs){ strAttrs += attr + '="' + attrs[attr] + '" '; } return ''; } function input(type, id, _class, attrs){ /* * Create an input tag with specified attributes. */ type = 'type="' + type + '" '; id = id ? 'id="' + id + '" ' : ''; _class = _class ? 'class="' + _class + '" ' : ''; var strAttrs = ''; for (var attr in attrs){ strAttrs += attr + '="' + attrs[attr] + '" '; } return ''; } function select(id, options, selectedOption){ /* * Create the select input -> it has a different structure than most of the * inputs * options: a list of options appearing under the same id. Each option is a * dictionary describing the value associated and the description * a sample entry of the options : {value: "1", description: "option1"} */ optionsHTML = ""; for (optionNr in options){ optionsHTML += "