LP1431055 Content Cafe optionally opens in new tab user/ldw/LP1431055
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Fri, 30 May 2014 23:24:32 +0000 (16:24 -0700)
committerLiam Whalen <liam.whalen@bc.libraries.coop>
Thu, 9 Apr 2015 17:48:00 +0000 (10:48 -0700)
Currently, when a user clicks on the Reviews & More links in the search
results, a new window is opened that displays the Content Cafe data.
This is a problem for two reasons.  1. The Content Cafe username and
password are contained in the URL of the window that is opened.  2. Some
libraries hvae touch screen systems, and when a new window is opened it
interferes with the touch screen interface.

This modification allows Reviews & More links from the search results
to be opened in a new tab.  To do this, a new boolean org unit
setting has been created.

The new setting is opac.reviews_and_more_new_tab.

The ctx.get_org_setting(org_id, setting) function returns the current
value of opac.reviews_and_more_new_tab.  If that setting is set to
true, then the TPAC inserts target='_blank' into the URL.  Or in the
case of the staff client, it opens in a new Staff Client window.
In the case of touchscreen kiosks, libraries would have this setting
at false, so their touch screen system keeps operating in the current
window when users touch the Reviews & More links.

In order to get the correct org_id for ctx.get_org_setting() call when
using the Staff Client, I had to add a ctx.ws_ou variable to
EGCatLoader.pm.  This uses the value taken from the staff client login.
The Staff Client cannot use the physical_loc variable because it is based
on an Apache ENV variable set in the /etc/apache2/includes/ TPAC skin
files, and unless the host used in the staff client has the relevant short
name appended to it, the physical_loc value will be set to 1 for the
consortia.

Additionally, when there is no isbn or upc for Content Cafe to identify
the item, the Summaries & More drop down is not displayed.  This is
confusing for users who click the Reviews & More link in the search
results because it takes them to a page without any information
pertaining to the link they clicked.

If Apache has the OILS_CONTENT_CAFE_USER environment variable set in
eg_vhost.conf, then this commit displays the Summaries and More tab
with the following localized comment: 'There are currently no reviews
available for this title'.  Otherwise, the Summaries and More tab is
ommited from the record details.

Furthermore, the summaries for an item are stored in attrs.summaries.
The code in summaryplus.tt2 was checking for the existence of
attrs.summary, which does not exist, so it was always excluding
summaries from the record details under the Summaries & More tab.

This commit fixes that typo, which allows summaries to be
displayed.

However, only the first value in a 520 field is being passed as a
summary for records to display in the Abstract field and the Summaries
& More tab.  But, the Summaries & More tab is expecting to display
all the 520 values.

So, this commit also modifies misc_util.tt2 to return all 520 values
when any are present.  Currently, it only returns the first 520 value
when any are present.

Next, the Abstract field in summary.tt2 is modified to only display the
first 520 to keep that information brief.

This allows summaryplus.tt2 to display all the 520 values in the
Summaries & More tab.

Additionally, the Summaries & More tab has been renamed Reviews & More,
so that it is consistent with the link in the results page.  Reviews &
More was chosen because it is shorter than Summaries & More.

Finally, by default no 520 values are displayed in Summaries & More.
However, the code to do so is included in comments in case a library
wishes to display all 520 values.

Signed-off-by: Liam Whalen <liam.whalen@bc.libraries.coop>
Conflicts:

Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/summary.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

The occurance of Reviews & More was displaying as Reviews &amp; More.
This has been corrected.  The TT2 localization seems to properly display
& now without needing to use the HTML code for it.  In fact, it appears
that the TT2 localization no longer translates the HTML code for &.

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Conflicts:
Open-ILS/src/templates/opac/parts/record/extras.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting.reviews_and_more_new_tab.sql [new file with mode: 0644]
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/extras.tt2
Open-ILS/src/templates/opac/parts/record/summaryplus.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

index bac8cfc..8b53be9 100644 (file)
@@ -14263,3 +14263,26 @@ INSERT INTO config.org_unit_setting_type
              'coust', 'description'),
          'bool');
 
+
+INSERT INTO config.org_unit_setting_type
+    (name, label, datatype, description, grp, update_perm, view_perm) 
+VALUES (
+    'opac.reviews_and_more_new_tab',
+    oils_i18n_gettext(
+        'opac.reviews_and_more_new_tab',
+        'Open Reviews & More in a new tab',
+        'coust',
+        'label'
+    ),
+    'bool',
+    oils_i18n_gettext(
+        'opac.reviews_and_more_new_tab',
+        'Allows the Reviews & More links in the search results to be opened in a new tab',
+        'coust',
+        'description'
+    ),
+    'opac',
+    93,
+    192
+);
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting.reviews_and_more_new_tab.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting.reviews_and_more_new_tab.sql
new file mode 100644 (file)
index 0000000..11ff2ef
--- /dev/null
@@ -0,0 +1,26 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type
+    (name, label, datatype, description, grp, update_perm, view_perm) 
+VALUES (
+    'opac.reviews_and_more_new_tab',
+    oils_i18n_gettext(
+        'opac.reviews_and_more_new_tab',
+        'Open Reviews & More in a new tab',
+        'coust',
+        'label'
+    ),
+    'bool',
+    oils_i18n_gettext(
+        'opac.reviews_and_more_new_tab',
+        'Allows the Reviews & More links in the search results to be opened in a new tab',
+        'coust',
+        'description'
+    ),
+    'opac',
+    93,
+    192
+);
+COMMIT;
index 0af121c..4446d6d 100644 (file)
         FOR sub IN xml.findnodes('//*[@tag="520"]/*[@code="a"]');
             args.summaries.push(sub.textContent);
         END;
-        args.summary = (args.summaries.size) ? args.summaries.0 : '';
+        args.summary = (args.summaries.size) ? args.summaries : '';
 
         # 250 gets pride of place for edition statement, and is the
         # only logical choice for 880 graphic fields
index 04cdd14..3c6a8ae 100644 (file)
@@ -54,7 +54,7 @@
         END;
 
         extras = [
-            {name => 'summaryplus',  label => l('Summaries & More'), hide => hide_summary},
+            {name => 'summaryplus',  label => l('Reviews & More'), hide => hide_summary}, 
             {name => 'annotation', label => l('Annotation'), hide => 1}, 
             {name => 'awards',  label => l('Awards, Reviews, & Suggested Reads')}, 
             {name => 'excerpt',  label => l('Excerpt'), hide => 1},
         ];
 
         FOREACH extra IN extras;
-            IF extra.hide; NEXT; END; 
+            IF extra.hide;
+                IF extra.name != 'summaryplus';
+                    NEXT;
+                ELSIF NOT ENV.OILS_CONTENT_CAFE_USER;
+                    #If we are going to hide summaryplus because no
+                    #conetent could be retrieved and we are not a
+                    #Content Cafe user, then hide it.
+                    #Otherwise show the summaryplus tab because
+                    #it is confusing to click the Reviews & More links
+                    #in the search results and not be taken to the
+                    #Reviews and More tab.
+                    NEXT;
+                END;
+            END;
             name = extra.name;
         %]
         <div class="rdetail_extras">
index 23e21ea..ec2872c 100644 (file)
@@ -1,20 +1,26 @@
 <div class='rdetail_extras_div'> 
-    [%- IF attrs.summary %]
-    <div class='rdetail-extras-summary'>
-        <strong>[% l('Summary: ') %]</strong>
-        [% FOR sum IN attrs.summaries %]
-            [% IF !loop.first; '<br/>'; END %]
-            <span>[% sum | html %] </span>
-        [% END %]
-    </div>
-    [%- END %]
-    [%- IF ENV.OILS_CONTENT_CAFE_USER %]
-    <!-- Embedded content cafe iframe -->
-    [% ident = attrs.isbn_clean || attrs.upc %]
-    <iframe width="100%" height="400" frameborder="0" 
-        src="[% ctx.ext_proto %]://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=[%- 
-            ENV.OILS_CONTENT_CAFE_USER %]&amp;Password=[% ENV.OILS_CONTENT_CAFE_PASS %]&amp;ItemKey=[% ident | uri %]&amp;Options=Y" >
-    </iframe>
-    [%- END %]
+    [% #Sitka does not want summaries in the Reviews & More tab %] 
+    [%- IF attrs.summaries.0 AND 0 == 1 %] 
+        <div class='rdetail-extras-summary'>
+            <strong>[% l('Summary: ') %]</strong>
+            [% FOR sum IN attrs.summaries %]
+                [% IF !loop.first; '<br/>'; END %]
+                <span>[% sum | html %] </span>
+            [% END %]
+        </div>
+    [% END %]
+    [% IF ENV.OILS_CONTENT_CAFE_USER %]
+        [% ident = attrs.isbn_clean || attrs.upc %]
+        [% IF ident %]
+            <!-- Embedded content cafe iframe -->
+            <iframe width="100%" height="400" frameborder="0" 
+                src="[% ctx.ext_proto %]://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=[%- 
+                    ENV.OILS_CONTENT_CAFE_USER %]&amp;Password=[% ENV.OILS_CONTENT_CAFE_PASS %]&amp;ItemKey=[% ident | uri %]&amp;Options=Y" >
+            </iframe>
+        [% ELSE %]
+            <div class='rdetail-extras-summary'>
+                [% l('There are currently no reviews available for this title.') %]
+            </div>
+        [%- END %]
+    [% END %]
 </div>
-
index 6cbe41e..789acbd 100644 (file)
@@ -402,15 +402,38 @@ END;
                                                             </a>
                                                             [% END %]
                                                         </div>
-                                                        [% IF ENV.OILS_CONTENT_CAFE_USER %]
-                                                        [% ident = attrs.isbn_clean || attrs.upc %]
+                                                        [% IF ENV.OILS_CONTENT_CAFE_USER;
+                                                            IF NOT ctx.is_staff;
+                                                                tpac_ou = ctx.physical_loc;
+                                                            ELSE;
+                                                                tpac_ou = ctx.ws_ou;
+                                                            END;
+                                                            new_window = ctx.get_org_setting(tpac_ou, 'opac.reviews_and_more_new_tab');
+                                                            record = ctx.opac_root _ '/record/' _ rec.id;
+                                                            name = 'summaryplus';
+                                                            href = mkurl(record, {expand => name}) _ '#' _ name; 
+                                                        %]
                                                         <div class="results_aux_utils result_util">
-                                                            <a target='_blank' 
-                                                               [% html_text_attr('title', l('Reviews and More for [_1]', attrs.title)) %]
-                                                                href="[% ctx.ext_proto %]://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=[%- 
-                                                                    ENV.OILS_CONTENT_CAFE_USER %]&amp;Password=[%-
-                                                                    ENV.OILS_CONTENT_CAFE_PASS %]&amp;ItemKey=[% ident | uri %]&amp;Options=Y" rel="nofollow" vocab="">
-                                                                <img src='[% ctx.media_prefix %]/images/starz.png' alt="[% l('Ratings Icon') %]"/> 
+                                                            <a title="[% l('Reviews and More') %]"
+                                                                [% IF new_window; %]
+                                                                    [% IF NOT ctx.is_staff %]
+                                                                        target='_blank'
+                                                                    [% ELSE %]
+                                                                        target='_blank'
+                                                                        [%
+                                                                        #this code will open up the Content Cafe data in a new tab as opposed to target='_blank', which opens it in new window in
+                                                                        #in the staff client.  When opening Content Cafe data in a new tab, there is a problem if the user has set a preferred 
+                                                                        #search location via the staff client Admin menu.  If this is the case, then the tab is not focused on the review and 
+                                                                        #the user has to scroll down to see it.  There is a fix on user/lwhalen/rt16523_with_staff_client_fix, but it requires a
+                                                                        #new staff client, so support has opted to go with opening in a new window until a staff client can be released.
+                                                                        #I am keeping this code in the source to make it esay to implement whenever support would like to change the behaviour from
+                                                                        #opening in a new window to opening in a new tab.
+                                                                        #href = "javascript:xulG.new_tab(xulG.urls.XUL_OPAC_WRAPPER, {}, {'opac_url' : 'oils://remote" _ href _ "'});void(0);" 
+                                                                        %]
+                                                                    [% END %]
+                                                                [% END %]
+                                                                href="[% href %]">
+                                                                <img src='[% ctx.media_prefix %]/images/starz.png'/> 
                                                                 <span class="results_reviews">[% l('Reviews &amp; More') %]</span>
                                                             </a>
                                                         </div>