svn commit: r1225452 - in /ofbiz/trunk: applications/product/webapp/catalog/WEB-INF/ applications/product/widget/catalog/ specialpurpose/ecommerce/config/ specialpurpose/ecommerce/data/ specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1225452 - in /ofbiz/trunk: applications/product/webapp/catalog/WEB-INF/ applications/product/widget/catalog/ specialpurpose/ecommerce/config/ specialpurpose/ecommerce/data/ specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/...

hansbak-2
Author: hansbak
Date: Thu Dec 29 07:05:42 2011
New Revision: 1225452

URL: http://svn.apache.org/viewvc?rev=1225452&view=rev
Log:
add a tagcloud demo to the ecommerce home page, contribution of tom of antwebsystems.com

Added:
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy   (with props)
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl   (with props)
Modified:
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
    ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml
    ofbiz/trunk/specialpurpose/ecommerce/config/ecommerce.properties
    ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml
    ofbiz/trunk/specialpurpose/ecommerce/widget/CatalogScreens.xml
    ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?rev=1225452&r1=1225451&r2=1225452&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Thu Dec 29 07:05:42 2011
@@ -3035,8 +3035,8 @@ under the License.
 
     <request-map uri="updateProductTag">
         <security https="true" auth="true"/>
-        <event type="service" path="" invoke="updateProductKeyword"/>
-        <response name="success" type="view" value="EditProductTag"/>
+        <event type="service-multi" path="" invoke="updateProductKeyword"/>
+        <response name="success" type="request-redirect" value="EditProductTag"/>
         <response name="error" type="view" value="EditProductTag"/>
     </request-map>
     <!-- end of request mappings -->

Modified: ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml?rev=1225452&r1=1225451&r2=1225452&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml Thu Dec 29 07:05:42 2011
@@ -2200,8 +2200,8 @@ under the License.
         <field name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
 
-    <form name="ListProductTag" type="list" target="updateProductTag" title="" list-name=""
-        odd-row-style="alternate-row" default-table-style="basic-table" paginate-target="EditProductTag">
+    <form name="ListProductTag" type="multi" target="updateProductTag" title="" list-name=""
+        odd-row-style="alternate-row" default-table-style="basic-table" paginate-target="EditProductTag" separate-columns="true">
         <actions>
             <entity-condition entity-name="ProductKeyword">
                 <condition-list combine="and">
@@ -2213,12 +2213,12 @@ under the License.
             </entity-condition>
         </actions>
         <field name="keywordTypeId"><hidden/></field>
-        <field name="productId" sort-field="true">
-            <hyperlink also-hidden="false" description="${productId}" target="EditProduct">
+        <field name="productId">
+            <hyperlink target="EditProduct" description="${productId}">
                 <parameter param-name="productId"/>
             </hyperlink>
         </field>
-        <field name="keyword" title="${uiLabelMap.ProductTag}" sort-field="true"><display/></field>
+        <field name="keyword" title="${uiLabelMap.ProductTag}"><display/></field>
         <field name="statusId">
             <drop-down allow-empty="true">
                 <entity-options entity-name="StatusItem" key-field-name="statusId" description="${description}">
@@ -2227,6 +2227,7 @@ under the License.
                 </entity-options>
             </drop-down>
         </field>
+        <field name="_rowSubmit" title="${uiLabelMap.CommonSelect}"><check/></field>
         <field name="submitButton" title="${uiLabelMap.CommonUpdate}"><submit button-type="button"/></field>
     </form>
  </forms>

Modified: ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml?rev=1225452&r1=1225451&r2=1225452&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/config/EcommerceUiLabels.xml Thu Dec 29 07:05:42 2011
@@ -3369,6 +3369,9 @@
         <value xml:lang="zh">调查</value>
         <value xml:lang="zh_TW">調查</value>
     </property>
+    <property key="EcommerceTags">
+        <value xml:lang="en">Tag Cloud</value>
+    </property>
     <property key="EcommerceTakeSurvey">
         <value xml:lang="da">Foretag rundspørge</value>
         <value xml:lang="de">An Befragung teilnehmen</value>

Modified: ofbiz/trunk/specialpurpose/ecommerce/config/ecommerce.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/config/ecommerce.properties?rev=1225452&r1=1225451&r2=1225452&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/config/ecommerce.properties (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/config/ecommerce.properties Thu Dec 29 07:05:42 2011
@@ -38,3 +38,8 @@ janrain.baseUrl=
 
 # -- Janrain application name
 janrain.appName=
+
+# Tag Cloud
+tagcloud.min.fontsize = 8
+tagcloud.max.fontsize = 14
+tagcloud.limit = 99

Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml?rev=1225452&r1=1225451&r2=1225452&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml Thu Dec 29 07:05:42 2011
@@ -1662,4 +1662,29 @@ under the License.
     <ProductFacilityLocation productId="RentalShip" facilityId="WebStoreWarehouse" locationSeqId="TLTLTLUL01" minimumStock="5" moveQuantity="20"/>
     <InventoryItem facilityId="WebStoreWarehouse" inventoryItemId="InventoryRentalShip" inventoryItemTypeId="NON_SERIAL_INV_ITEM" datetimeReceived="2008-08-01 08:00:00.000" productId="RentalShip" ownerPartyId="Company" currencyUomId="USD" unitCost="2.4"/>
     <InventoryItemDetail inventoryItemId="InventoryRentalShip" inventoryItemDetailSeqId="0001" effectiveDate="2011-09-01 12:00:00.0" availableToPromiseDiff="10" quantityOnHandDiff="10" accountingQuantityDiff="10"/>
+    
+    <!-- Demo product tags -->
+    <ProductKeyword productId="GZ-1000" keyword="gizmos" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-1001" keyword="gizmos" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-2002" keyword="gizmos" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-2644" keyword="gizmos" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-5005" keyword="gizmos" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="WG-1111" keyword="red" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-1004" keyword="red" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-2644" keyword="red" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="SV-1001" keyword="demonstration" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="SV-1000" keyword="demonstration" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="CFSV1001" keyword="demonstration" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="WG-5569" keyword="widget" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="WG-9943" keyword="widget" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-1000" keyword="small" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-2644" keyword="small" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="SV-1001" keyword="service" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="CFSV1001" keyword="service" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-1000" keyword="tiny" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-8544" keyword="big" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="WG-9943" keyword="black" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="WG-1111" keyword="chrome" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    <ProductKeyword productId="GZ-1006" keyword="standard" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
+    
 </entity-engine-xml>

Added: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy?rev=1225452&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy (added)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy Thu Dec 29 07:05:42 2011
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.List;
+import org.ofbiz.entity.*;
+import org.ofbiz.entity.condition.*;
+import org.ofbiz.entity.util.*;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.transaction.*
+import org.ofbiz.base.util.*;
+import org.ofbiz.base.util.string.*;
+import org.ofbiz.content.content.*;
+import org.apache.commons.lang.StringEscapeUtils;
+
+int minFontSize = Integer.parseInt(UtilProperties.getPropertyValue("ecommerce.properties", "tagcloud.min.fontsize"));
+int maxFontSize = Integer.parseInt(UtilProperties.getPropertyValue("ecommerce.properties", "tagcloud.max.fontsize"));
+int limitTagCloud = Integer.parseInt(UtilProperties.getPropertyValue("ecommerce.properties", "tagcloud.limit"));
+
+tagCloudList = [] as LinkedList;
+tagList = [] as LinkedList;
+
+keywordConditions = EntityCondition.makeCondition([keywordTypeId : "KWT_TAG", statusId : "KW_APPROVED"], EntityOperator.AND);
+keywordOrder = ["keyword"];
+keywordFields = ["keyword", "keywordTypeId", "statusId"] as Set;
+keywordFindOptions = new EntityFindOptions();
+keywordFindOptions.setDistinct(true);
+productKeywords = delegator.findList("ProductKeyword", keywordConditions, keywordFields, keywordOrder, keywordFindOptions, false);
+
+if (UtilValidate.isNotEmpty(productKeywords)) {
+    productKeywords.each { productKeyword ->
+        productTags = delegator.findByAnd("ProductKeyword", ["keyword": productKeyword.keyword, "keywordTypeId" : "KWT_TAG", "statusId" : "KW_APPROVED"]);
+        searchResult = [:];
+        searchResult.tag = productKeyword.keyword;
+        searchResult.countTag = productTags.size();
+        tagList.add(searchResult);
+    }
+}
+
+if (tagList) {
+    int tag = 0;
+    tagList.sort{ a,b -> b.countTag <=> a.countTag };
+    if (tagList.size() < limitTagCloud) {
+        limitTagCloud = tagList.size();
+    }
+    int maxResult = tagList[0].countTag;
+    int minResult = tagList[limitTagCloud - 1].countTag;
+    tagList.each { tagCloud ->
+        if (tag < limitTagCloud) {
+            tagCloudOfbizInfo = [:];
+            double weight = 0;
+            if ((maxResult - minResult) > 0) {
+                weight = (tagCloud.countTag - minResult) / (maxResult - minResult);
+            }
+            double fontSize = minFontSize + ((maxFontSize - minFontSize) * weight);
+            tagCloudOfbizInfo.tag = tagCloud.tag;
+            tagCloudOfbizInfo.fontSize = fontSize;
+            tagCloudList.add(tagCloudOfbizInfo);
+            tag++;
+        }
+    }
+}
+
+tagCloudList = tagCloudList.sort{it.tag}
+
+context.tagCloudList = tagCloudList;

Propchange: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl?rev=1225452&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl (added)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl Thu Dec 29 07:05:42 2011
@@ -0,0 +1,34 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<#if tagCloudList?has_content>
+  <div id="populartags" class="screenlet">
+    <div class="screenlet-title-bar">
+      <ul>
+        <li class="h3">${uiLabelMap.EcommerceTags}</li>
+      </ul>
+      <br class="clear"/>
+    </div>
+    <div class="screenlet-body">
+      <#list tagCloudList as tagCloud>
+          <a style="font-size: ${tagCloud.fontSize}pt;" href="<@ofbizUrl>tagsearch?SEARCH_STRING=${tagCloud.tag}&amp;keywordTypeId=KWT_TAG&amp;statusId=KW_APPROVED</@ofbizUrl>">${tagCloud.tag}</a>
+      </#list>
+    </div>
+  </div>
+</#if>

Propchange: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/populartags.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/CatalogScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/CatalogScreens.xml?rev=1225452&r1=1225451&r2=1225452&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/widget/CatalogScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/widget/CatalogScreens.xml Thu Dec 29 07:05:42 2011
@@ -588,4 +588,16 @@ under the License.
             </widgets>
         </section>
     </screen>
+
+    <screen name="populartags">
+        <section>
+            <actions>
+                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
+                <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/catalog/PopularTags.groovy"/>
+            </actions>
+            <widgets>
+                <platform-specific><html><html-template location="component://ecommerce/webapp/ecommerce/catalog/populartags.ftl"/></html></platform-specific>
+            </widgets>
+        </section>
+    </screen>
 </screens>

Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml?rev=1225452&r1=1225451&r2=1225452&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/widget/CommonScreens.xml Thu Dec 29 07:05:42 2011
@@ -132,6 +132,7 @@ under the License.
                     <include-screen name="minilastviewedproducts" location="component://ecommerce/widget/CatalogScreens.xml"/>
                     <include-screen name="minilastproductsearches" location="component://ecommerce/widget/CatalogScreens.xml"/>
                     <include-screen name="recentlyviewed" location="component://ecommerce/widget/ContentScreens.xml"/>
+                    <include-screen name="populartags" location="component://ecommerce/widget/CatalogScreens.xml"/>
             </widgets>
         </section>
     </screen>