#29759 template take from db if override checked. updated template
authorJagadedes <jagadees.pillai@zyxware.com>
Tue, 21 Oct 2014 10:28:53 +0000 (15:58 +0530)
committerJagadedes <jagadees.pillai@zyxware.com>
Tue, 21 Oct 2014 10:28:53 +0000 (15:58 +0530)
CRM/Wci/BAO/Widget.php
CRM/Wci/Form/CreateWidget.php
extern/wciwidget.php
templates/CRM/Wci/Form/CreateWidget.tpl
templates/CRM/Wci/Page/wciwidget.tpl

index 1d35044a3a12426fecf3a55b1d6cb3e477baf24e..4f6f0f4b6fdb7fdd79d3b8772a566af4e1b79dac 100644 (file)
@@ -154,8 +154,10 @@ class CRM_Wci_BAO_Widget extends CRM_Wci_DAO_Widget {
       $data["color_button_bg"] = $dao->color_button_bg;
       $data['style_rules'] = $dao->style_rules;
       $data["pb_percentage"] = CRM_Wci_BAO_ProgressBar::getProgressbarPercentage($dao->progress_bar_id);
+      $data["custom_template"] = $dao->custom_template;
+      $data["widgetId"] = $widgetId;
+      $data["override"] = $dao->override;
     }
-
     return $data;
   }
 }
index 0b8273a1418d149b587164adaaf0c3b8a8889237..4315bd5779893800e12d8d2748f7e8e5c0ea66ad 100644 (file)
@@ -228,7 +228,7 @@ where w.id=" . $this->_id;
     }
     else {
       /** Keep template in civicrm-wci/templates folder*/
-      $output = file_get_contents('templates/CRM/Wci/Page/Widget.tpl',FILE_USE_INCLUDE_PATH);
+      $output = file_get_contents('templates/CRM/Wci/Page/wciwidget.tpl',FILE_USE_INCLUDE_PATH);
       $elem = $this->getElement('custom_template');
       $elem->setValue($output); 
     }
index a44ea7184e8ef568208210e8a4ac961a46fd07ce..bf5500e6d669e7128c828facb71d0d0cfd3259d4 100644 (file)
@@ -58,11 +58,17 @@ if (isset($embed) && (true == $embed)) {
 
 } else {
   $data = CRM_Wci_BAO_Widget::getWidgetData($widgetId);
+
   $template->assign('wciform', $data);
   $template->assign('cpageId', $data['button_link_to']);
 
-  $template->template_dir[] = getWciWidgetTemplatePath();
-  $wcidata = $template->fetch('wciwidget.tpl');
+  if ($data["override"] == '0') {
+    $template->template_dir[] = getWciWidgetTemplatePath();
+    $wcidata = $template->fetch('wciwidget.tpl');
+  } else {
+
+        $wcidata = $template->fetch('string:' . base64_decode($data['custom_template']));
+  }
   $output = 'var wciwidgetcode =  ' . json_encode($wcidata) . ';';
   echo $output;
 
index 52db603f4edac32b265c67937175a9e31d75703e..943e826825069b4d3ea9f80cb2bac61fae17926d 100644 (file)
       $data = CRM_Wci_BAO_Widget::getWidgetData($wid_id);
       $template = CRM_Core_Smarty::singleton();
       $template->assign('wciform', $data);
-      $template->template_dir[] = getWciWidgetTemplatePath();
-      $wcidata = $template->fetch('wciwidget.tpl');
+      if($data["override"] == 0) {
+        $template->template_dir[] = getWciWidgetTemplatePath();
+        $wcidata = $template->fetch('wciwidget.tpl');
+      } else {
+      echo "hi";
+        $wcidata = $template->fetch('string:' . base64_decode($wid_page[$dao->id]['custom_template']));
+      }
       $widget_controller_path = getWciWidgetControllerPath();
     }
   {/php}
   </div>
   <div class="crm-section">
     <div class="content">
-    {include file="CRM/Wci/Page/wciwidget.tpl"}
+   {* {include file="CRM/Wci/Page/wciwidget.tpl"} *}
+
+<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
+<script type="text/javascript" src="{php}echo $widget_controller_path;{/php}?widgetId={php}echo $wid_id;{/php}"></script>
+<script>
+  $( document ).ready(function()  {ldelim} 
+    $('#widgetwci').html(wciwidgetcode);
+   {rdelim} );
+</script>
+<div id='widgetwci'></div>
+
     </div>
   </div>
 {/if}
index 84e63c6e64e8ac221ea9e4558acc7fb0d77ea7e8..7c3afebed6ee75c3b04acbc2f55f1f4cf859c46c 100644 (file)
@@ -9,6 +9,9 @@
         -khtml-border-radius:   4px;
         border-radius:      4px;
         border:1px solid #96C0E7;
+        background-color: {/literal}{$wciform.color_widget_bg}{literal}; /* background color */
+        border-color:{/literal}{$wciform.color_border}{literal}; /* border color */
+        background:  {/literal}{if $wciform.image}url('{$wciform.image}'){/if}{literal}; /* background image */
     }
     
     .crm-wci-widget.thin {
@@ -32,7 +35,9 @@
         -webkit-border-radius:   4px;
         -khtml-border-radius:   4px;
         border-radius:      4px;
-    }
+        color: {/literal}{$wciform.color_title}{literal};
+        background-color: {/literal}{$wciform.color_title_bg}{literal};
+    } /* title */
 
     .crm-wci-widget .crm-amounts {
         height:1em;
@@ -49,7 +54,7 @@
         margin:0px 30%;
         text-align:center;
     }
-    .crm-wci-widget .crm-amount-bar {
+    .crm-wci-widget .crm-amount-bar { /* progress bar */
         background-color:#FFF;
         width:100%;
         display:block;
@@ -60,6 +65,9 @@
         border-radius:      4px;
         margin-bottom:.8em;
         text-align:left;
+        
+        background-color:{/literal}{$wciform.color_bar}{literal};
+        border-color:#CECECE;
     }
     .crm-wci-widget .crm-amount-fill {
         background-color:#2786C2;
@@ -77,6 +85,7 @@
     }
     .crm-wci-widget .crm-amount-raised {
         font-weight:bold;
+        color:#000;
     }
 
     .crm-wci-widget .crm-logo {
@@ -88,6 +97,7 @@
     .crm-wci-widget .crm-campaign {
         font-size:11px;
         margin-bottom:.8em;
+        color:{/literal}{$wciform.color_description}{literal} /* other color*/
     }
 
     .crm-wci-widget .crm-wci-button {
     .crm-wci-widget .crm-home-url {
         text-decoration:none;
         border:0px;
+        color:{/literal}{$wciform.color_homepage_link}{literal} /* home page link color*/
     }
 
-</style>
-<style>
-    .crm-wci-widget {
-        background-color: {/literal}{$wciform.color_widget_bg}{literal}; /* background color */
-        border-color:{/literal}{$wciform.color_border}{literal}; /* border color */
-        background:  {/literal}{if $wciform.image}url('{$wciform.image}'){else}none{/if}{literal}; /* background image */
-    }
-
-    .crm-wci-widget h5 {
-        color: {/literal}{$wciform.color_title}{literal};
-        background-color: {/literal}{$wciform.color_title_bg}{literal};
-    } /* title */
-
-    .crm-wci-widget .crm-amount-raised { color:#000; }
-    .crm-wci-widget .crm-amount-bar  /* progress bar */
-        background-color:{/literal}{$wciform.color_bar}{literal};
-        border-color:#CECECE;
-    }
-    .crm-wci-widget .crm-amount-fill { background-color:#2786C2; }
-
     .crm-wci-widget a.crm-wci-button { /* button color */
         background-color:{/literal}{$wciform.color_button_bg}{literal};
     }
         color:{/literal}{$wciform.color_button}{literal};
     }
 
-    .crm-wci-widget .crm-comments,
-    .crm-wci-widget .crm-donors,
-    .crm-wci-widget .crm-campaign {
-        color:{/literal}{$wciform.color_description}{literal} /* other color*/
-    }
-
-    .crm-wci-widget .crm-home-url {
-        color:{/literal}{$wciform.color_homepage_link}{literal} /* home page link color*/
-    }
-
 </style>
+
 <style>
 {/literal}
   {$wciform.style_rules}
 </style>
 {/literal}
 
-<div id="crm_wid_{$widgetId}" class="crm-wci-widget {$wciform.size_variant}">
-    <h5 id="crm_wid_{$widgetId}_title">
+<div id="crm_wid_{$wciform.widgetId}" class="crm-wci-widget {$wciform.size_variant}">
+    <h5 id="crm_wid_{$wciform.widgetId}_title">
       {if $wciform.logo_image}
         <span class="crm-logo">
           <img src="{$wciform.logo_image}" alt={ts}Logo{/ts}>
       {$wciform.title}
     </h5>
     <div class="crm-amounts">
-        <div id="crm_wid_{$widgetId}_amt_hi" class="crm-amount-high"></div>
-        <div id="crm_wid_{$widgetId}_amt_low" class="crm-amount-low"></div>
-        <div id="crm_wid_{$widgetId}_percentage" class="crm-percentage"></div>
+        <div id="crm_wid_{$wciform.widgetId}_amt_hi" class="crm-amount-high"></div>
+        <div id="crm_wid_{$wciform.widgetId}_amt_low" class="crm-amount-low"></div>
+        <div id="crm_wid_{$wciform.widgetId}_percentage" class="crm-percentage"></div>
     </div>
     <div class="crm-amount-bar">
-        <div class="crm-amount-fill" id="crm_wid_{$widgetId}_amt_fill"></div>
+        <div class="crm-amount-fill" id="crm_wid_{$wciform.widgetId}_amt_fill"></div>
     </div>
-    <div id="crm_wid_{$widgetId}_donors" class="crm-donors">
+    <div id="crm_wid_{$wciform.widgetId}_donors" class="crm-donors">
     </div>
-    <div id="crm_wid_{$widgetId}_comments" class="crm-comments">
+    <div id="crm_wid_{$wciform.widgetId}_comments" class="crm-comments">
       {$wciform.description}
     </div>
-    <div id="crm_wid_{$widgetId}_campaign" class="crm-campaign">
+    <div id="crm_wid_{$wciform.widgetId}_campaign" class="crm-campaign">
     </div>
-    <div class="crm-wci-button-wrapper" id="crm_wid_{$widgetId}_button">
-        <a href='{crmURL p="civicrm/contribute/transact" q="reset=1&id=$cpageId" h=0 a=1 fe=1}' class="crm-wci-button"><span class="crm-wci-button-inner" id="crm_wid_{$widgetId}_btn_txt">{$wciform.button_title}</span></a>
+    <div class="crm-wci-button-wrapper" id="crm_wid_{$wciform.widgetId}_button">
+        <a href='{crmURL p="civicrm/contribute/transact" q="reset=1&id=$cpageId" h=0 a=1 fe=1}' class="crm-wci-button"><span class="crm-wci-button-inner" id="crm_wid_{$wciform.widgetId}_btn_txt">{$wciform.button_title}</span></a>
     </div>
 </div>