[PATCH] Puntuación y ayuda a la catalogación

Juan Romay Sieira juan.sieira at xercode.es
Fri Jan 21 06:26:35 NZDT 2011


---
 C4/Biblio.pm                                       |    2 +-
 admin/marc_subfields_structure.pl                  |   17 ++++--
 cataloguing/addbiblio.pl                           |   11 ++++
 installer/data/mysql/kohastructure.sql             |    2 +
 installer/data/mysql/updatedatabase.pl             |    9 +++
 koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css  |    5 ++
 koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js |   55 ++++++++++++++++++++
 .../en/modules/admin/marc_subfields_structure.tmpl |   36 +++++++------
 .../prog/en/modules/cataloguing/addbiblio.tmpl     |    9 +++
 9 files changed, 123 insertions(+), 23 deletions(-)

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index c8cbdc8..ffadde8 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -998,7 +998,7 @@ sub GetMarcStructure {
     );
 
     my $ressubfields = $dbh->selectall_hashref(
-"SELECT frameworkcode,tagfield,tagsubfield,$lib as lib,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue 
+"SELECT frameworkcode,tagfield,tagsubfield,$lib as lib,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,punctuation,help  
          FROM   marc_subfield_structure 
          ORDER BY frameworkcode,tagfield,tagsubfield",
         [ "frameworkcode", "tagfield", "tagsubfield" ],
diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl
index 373228b..be93e09 100755
--- a/admin/marc_subfields_structure.pl
+++ b/admin/marc_subfields_structure.pl
@@ -171,6 +171,8 @@ if ( $op eq 'add_form' ) {
     while ( $data = $sth->fetchrow_hashref ) {
         my %row_data;                                                                                           # get a fresh hash for the row data
         $row_data{defaultvalue} = $data->{defaultvalue};
+        $row_data{punctuation}	= $data->{'punctuation'};
+        $row_data{help}	= CGI::escapeHTML( $data->{'help'} );
         $row_data{tab}          = CGI::scrolling_list(
             -name   => 'tab',
             -id     => "tab$i",
@@ -370,13 +372,13 @@ if ( $op eq 'add_form' ) {
 #     );
     my $sth_insert = $dbh->prepare(
         qq{
-        insert into marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue)
-        values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+        insert into marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue, punctuation, help)
+        values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
     }
     );
     my $sth_update = $dbh->prepare(
         qq{
-        update marc_subfield_structure set tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, authtypecode=?, value_builder=?, hidden=?, isurl=?, frameworkcode=?,  link=?, defaultvalue=?
+        update marc_subfield_structure set tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, authtypecode=?, value_builder=?, hidden=?, isurl=?, frameworkcode=?,  link=?, defaultvalue=?, punctuation=?, help=?
         where tagfield=? and tagsubfield=? and frameworkcode=?
     }
     );
@@ -392,6 +394,8 @@ if ( $op eq 'add_form' ) {
     my @value_builder     = $input->param('value_builder');
     my @link              = $input->param('link');
     my @defaultvalue      = $input->param('defaultvalue');
+    my @punctuation       = $input->param('punctuation');
+    my @help      		  = $input->param('help');
 
     for ( my $i = 0 ; $i <= $#tagsubfield ; $i++ ) {
         my $tagfield    = $input->param('tagfield');
@@ -412,18 +416,21 @@ if ( $op eq 'add_form' ) {
         my $isurl            = $input->param("isurl$i") ? 1 : 0;
         my $link             = $link[$i];
         my $defaultvalue     = $defaultvalue[$i];
+        my $punctuation      = $punctuation[$i];
+        my $help     		 = $help[$i];
 
         if ($liblibrarian) {
             unless ( C4::Context->config('demo') eq 1 ) {
                 if ( marc_subfield_structure_exists( $tagfield, $tagsubfield, $frameworkcode ) ) {
                     $sth_update->execute( $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $seealso, $authorised_value, $authtypecode,
-                        $value_builder, $hidden, $isurl, $frameworkcode, $link, $defaultvalue, ( $tagfield, $tagsubfield, $frameworkcode, ),
+                        $value_builder, $hidden, $isurl, $frameworkcode, $link, $defaultvalue, $punctuation, $help, ( $tagfield, $tagsubfield, $frameworkcode, ),
                     );
                 } else {
                     $sth_insert->execute(
                         $tagfield,  $tagsubfield, $liblibrarian,  $libopac,          $repeatable,   $mandatory,
                         $kohafield, $tab,         $seealso,       $authorised_value, $authtypecode, $value_builder,
-                        $hidden,    $isurl,       $frameworkcode, $link,             $defaultvalue,
+                        $hidden,    $isurl,       $frameworkcode, $link,             $defaultvalue,	$punctuation,
+                        $help
                     );
                 }
             }
diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
index 2b2528f..f302b54 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -317,6 +317,8 @@ sub create_input {
         mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
         repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
         kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
+        punctuation    => $tagslib->{$tag}->{$subfield}->{punctuation},
+        help     	   => $tagslib->{$tag}->{$subfield}->{help},
         index          => $index_tag,
         id             => "tag_" . $tag . "_subfield_" . $id_subfield . "_" . $index_tag . "_" . $index_subfield,
         value          => $value,
@@ -477,11 +479,20 @@ sub create_input {
                         name=\"" . $subfield_data{id} . "\"
                         value=\"$value\"
                         tabindex=\"1\"
+                        punctuation=\"".$subfield_data{punctuation}."\"
                         size=\"67\"
                         maxlength=\"$max_length\"
                         class=\"input_marceditor\"
+                        onfocus=\"javascript:GetPunctuation(this);\"
+                        onblur=\"javascript:CheckPunctuation(this);\"
                 \/>
                 ";
+            if ($subfield_data{help}){
+                $subfield_data{marc_value} .= "
+                &nbsp;<a class=\"showhelp\" href=\"#help_" . $subfield_data{id} . "\">Show help</a>
+                <div class=\"divsubfieldhelp\" id=\"help_" . $subfield_data{id} . "\" style=\"display:none; clear: both\">&nbsp;<i>" . $subfield_data{help} . "</i></div>
+                ";
+        	}
         }
     }
     $subfield_data{'index_subfield'} = $index_subfield;
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index f119dc3..1f5cb7a 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1177,6 +1177,8 @@ CREATE TABLE `marc_subfield_structure` (
   `seealso` varchar(1100) default NULL,
   `link` varchar(80) default NULL,
   `defaultvalue` text default NULL,
+  `punctuation` varchar(5) default NULL,
+  `help` varchar(255) default NULL,
   PRIMARY KEY  (`frameworkcode`,`tagfield`,`tagsubfield`),
   KEY `kohafield_2` (`kohafield`),
   KEY `tab` (`frameworkcode`,`tab`),
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 8e7698d..63898fd 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5065,6 +5065,15 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.02.00.0592";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("
+	ALTER TABLE `marc_subfield_structure` ADD `punctuation` VARCHAR( 5 ) NULL , ADD `help` VARCHAR( 255 ) NULL;
+    ");
+    print "Upgrade to $DBversion done (Punctuation and cataloguing help)\n";
+    SetVersion($DBversion);
+}
+
 
 =item DropAllForeignKeys($table)
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css b/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css
index 0377cca..755c769 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css
@@ -90,6 +90,11 @@ a.tagnum {
 	text-align:right;
 }
 
+.divsubfieldhelp {
+	background-color: #F0FFEF; 
+	border: #EFEFEF 1px solid;
+}
+
 .subfieldcode {
 	display: block;
 	float: left;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js
index c2e6fba..5c70cef 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js
+++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js
@@ -90,3 +90,58 @@ function checkEnter(e){ //e is event object passed from function invocation
 		return true;
 	}
 }
+
+/*
+ * Place punctuation when cataloguing
+ */
+
+function trim(s) {
+  while (s.length>0 && (s[0]==' '||s[0]=='\n')) s=s.substring(1, s.length);
+  while (s.length>0 && (s[s.length-1]==' '||s[s.length-1]=='\n')) s=s.substring(0, s.length-1);
+  while (s.search (" ") != -1){
+	s = s.replace (" ","");
+	}
+  return s; 
+}
+
+/*
+	Place the cursor in a determinate place into a textbox
+*/
+
+function placePositionTextbox(elem, myPos) {
+
+    if(elem != null) {
+        if(elem.createTextRange) {
+            var range = elem.createTextRange();
+            range.move('character', myPos);
+            range.select();
+        }
+        else {
+            if(elem.selectionStart) {
+                elem.focus();
+                elem.setSelectionRange(myPos, myPos);
+            }
+            else
+                elem.focus();
+        }
+    }
+}
+
+function GetPunctuation(field){
+	var val = field.value;
+	if (trim(val) == ""){
+		field.value = field.getAttribute('punctuation');
+		placePositionTextbox(field,field.value.length);
+	}
+}
+
+function CheckPunctuation(field){
+	var val = field.value;
+	if (val == field.getAttribute('punctuation')){
+		field.value = "";
+	}
+}
+
+/*
+ * END - Place punctuation when cataloguing
+ */
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tmpl
index 5b36ae9..fe56f75 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tmpl
@@ -104,24 +104,26 @@
 			
             <a class="displaymore" href="#more<!-- TMPL_VAR NAME="urisubfieldcode" -->">display more constraints</a>
             <div id="more<!-- TMPL_VAR NAME="urisubfieldcode" -->" style="display:none; clear: both">
-             <fieldset class="rows" style="float:none;">
+			<fieldset class="rows" style="float:none;">
 				<legend>Advanced constraints:</legend>
-                <ol><li><label for="defaultvalue<!-- TMPL_VAR NAME="row" -->">Default value:</label>
-                    <input type="text" name="defaultvalue" id="defaultvalue<!-- TMPL_VAR NAME="row" -->" value="<!-- TMPL_VAR NAME="defaultvalue" -->" /></li>
-                <li><label for="hidden<!-- TMPL_VAR NAME="row" -->">hidden</label><input type="text" id="hidden<!-- TMPL_VAR NAME="row" -->" name="hidden" value="<!-- TMPL_VAR name="hidden" -->" size="2" /> (see online help)</li>
-                <li><label for="isurl<!-- TMPL_VAR NAME="row" -->">Is a URL:</label><!-- TMPL_VAR NAME="isurl" --> (if checked, it means that the subfield is a URL and can be clicked)</li>
-                <li><label for="link<!-- TMPL_VAR NAME="row" -->">Link:</label><input type="text" id="link<!-- TMPL_VAR NAME="row" -->" name="link" value="<!-- TMPL_VAR NAME="link" -->" size="10" maxlength="80" /> (e.g., Title or Local-Number) <span class="error"><em>Warning: This value should not change after data has been added to your catalog</em></span></li>
-                <li><label for="kohafield<!-- TMPL_VAR NAME="row" -->">Koha link:</label><!-- TMPL_VAR NAME="kohafield" --></li>
-			</ol>
-	</fieldset>
-	 <fieldset class="rows" style="float:none;">
-                <legend>Other Options: (choose one)</legend>
-                    	<ol>
-                    		<li><label for="authorised_value<!-- TMPL_VAR NAME="row" -->">Authorized value:</label><!-- TMPL_VAR NAME="authorised_value" --></li>
-                    		<li><label for="authtypecode<!-- TMPL_VAR NAME="row" -->">Thesaurus:</label><!-- TMPL_VAR NAME="authtypes" --></li>
-                    		<li><label for="value_builder<!-- TMPL_VAR NAME="row" -->">Plugin:</label><!-- TMPL_VAR NAME="value_builder" --></li>
-                    	</ol>
-				</fieldset>
+                <ol>
+                	<li><label for="defaultvalue<!-- TMPL_VAR NAME="row" -->">Default value:</label><input type="text" name="defaultvalue" id="defaultvalue<!-- TMPL_VAR NAME="row" -->" value="<!-- TMPL_VAR NAME="defaultvalue" -->" /></li>
+					<li><label for="punctuation<!-- TMPL_VAR NAME="row" -->">Punctuation:</label><input type="text" name="punctuation" id="punctuation<!-- TMPL_VAR NAME="row" -->" value="<!-- TMPL_VAR NAME="punctuation" -->" /></li>
+					<li><label for="help<!-- TMPL_VAR NAME="row" -->">Help:</label><br/><textarea type="text" name="help" id="help<!-- TMPL_VAR NAME="row" -->" cols="40"><!-- TMPL_VAR NAME="help" --></textarea></li>
+                	<li><label for="hidden<!-- TMPL_VAR NAME="row" -->">hidden</label><input type="text" id="hidden<!-- TMPL_VAR NAME="row" -->" name="hidden" value="<!-- TMPL_VAR name="hidden" -->" size="2" /> (see online help)</li>
+                	<li><label for="isurl<!-- TMPL_VAR NAME="row" -->">Is a URL:</label><!-- TMPL_VAR NAME="isurl" --> (if checked, it means that the subfield is a URL and can be clicked)</li>
+                	<li><label for="link<!-- TMPL_VAR NAME="row" -->">Link:</label><input type="text" id="link<!-- TMPL_VAR NAME="row" -->" name="link" value="<!-- TMPL_VAR NAME="link" -->" size="10" maxlength="80" /> (e.g., Title or Local-Number) <span class="error"><em>Warning: This value should not change after data has been added to your catalog</em></span></li>
+                	<li><label for="kohafield<!-- TMPL_VAR NAME="row" -->">Koha link:</label><!-- TMPL_VAR NAME="kohafield" --></li>
+				</ol>
+			</fieldset>
+			<fieldset class="rows" style="float:none;">
+				<legend>Other Options: (choose one)</legend>
+				<ol>
+					<li><label for="authorised_value<!-- TMPL_VAR NAME="row" -->">Authorized value:</label><!-- TMPL_VAR NAME="authorised_value" --></li>
+					<li><label for="authtypecode<!-- TMPL_VAR NAME="row" -->">Thesaurus:</label><!-- TMPL_VAR NAME="authtypes" --></li>
+					<li><label for="value_builder<!-- TMPL_VAR NAME="row" -->">Plugin:</label><!-- TMPL_VAR NAME="value_builder" --></li>
+				</ol>
+			</fieldset>
             </div><br class="clear" /><!-- /more  -->
         </div><!-- /content_sub -->
         <!-- /TMPL_LOOP -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl
index 786b4cf..2784d61 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl
@@ -26,6 +26,15 @@
                 fields_in_use[field_id] = 1;
             }
         });
+		
+		$("a.showhelp").click(function(){
+			$("#"+$(this).attr("href").replace("#","")).toggle();
+			if($(this).html() == "Show help"){
+				$(this).html("Hide help");
+			} else {
+				$(this).html("Show help");
+			}
+		});
 	 });
 	 
 	 $('#header_search > ul').tabs().bind('show.ui-tabs', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
-- 
1.6.5.1


--------------030208040404060205010109--


More information about the Koha mailing list