#29764 Widget embedding code, #29767 Widget preview in widget creation form., #29763...
authorJagadedes <jagadees.pillai@zyxware.com>
Thu, 16 Oct 2014 11:28:13 +0000 (16:58 +0530)
committerJagadedes <jagadees.pillai@zyxware.com>
Thu, 16 Oct 2014 11:28:13 +0000 (16:58 +0530)
CRM/Wci/BAO/ProgressBar.php
CRM/Wci/BAO/Widget.php
CRM/Wci/Form/CreateWidget.php
CRM/Wci/Form/ProgressBar.php
extern/wciwidget.php
templates/CRM/Wci/Form/CreateWidget.tpl
templates/CRM/Wci/Page/WidgetList.tpl [new file with mode: 0644]
templates/CRM/Wci/Page/wciwidget.tpl [new file with mode: 0644]

index ff1a677fb720180a3c8fa1af0143bacfebde39d3..e07ee3770c1fc4db18f5da61a8e8d2ed44bc6ef7 100644 (file)
@@ -170,7 +170,7 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
       $sa = $con_page[$dao->id]['starting_amount'];
       $ga = $con_page[$dao->id]['goal_amount'];
     }
-     
     $query = "SELECT * FROM civicrm_wci_progress_bar_formula WHERE progress_bar_id =" . $idPB;
     $params = array();
 
index a098a5c4e4f3a97d5cb3f3cc2a9b3ecbe141737e..bc84161d35bf7ff1ceeee56fa097bc1c3bd465a6 100644 (file)
@@ -150,6 +150,7 @@ class CRM_Wci_BAO_Widget extends CRM_Wci_DAO_Widget {
       $data["color_border"] = $dao->color_border;
       $data["color_button"] = $dao->color_button;
       $data["color_button_bg"] = $dao->color_button_bg;
+      $data["pb_percentage"] = CRM_Wci_BAO_ProgressBar::getProgressbarPercentage($dao->progress_bar_id);
     }
 
     return $data;
index c5a404f8c1b840ae7fce089347bd201de6da0a53..aa40ab57b19abf6161123a853c2707e8e80321b3 100644 (file)
@@ -13,11 +13,23 @@ cj(function ( $ ) {
     }
     else {
       $('#custom_template').attr("disabled",true);
-    }  
+    }
+    if( $('#title').val() != "") {
+      $('#embd_code').parent().parent().parent().show();    
+    } else {
+      $('#embd_code').parent().parent().parent().hide();
+    }
+//    $('#embd_code').attr("disabled",true);
   }
   $(document).ready(setState)
   $('#override').click(setState);
 
+/*  
+  $("input[name='_qf_CreateWidget_savenprev']").on('click', function( e ) {
+    e.preventDefault();
+    alert( document.title );
+
+  });*/
 });
 </script>
 
@@ -75,7 +87,7 @@ class CRM_Wci_Form_CreateWidget extends CRM_Core_Form {
       'color_button' => array(ts('Widget button text color'),
         'text',
         FALSE,
-        '#96C0E7',
+        '#000000',
       ),
       'color_button_bg' => array(ts('Widget button background color'),
         'text',
@@ -124,18 +136,24 @@ class CRM_Wci_Form_CreateWidget extends CRM_Core_Form {
     $this->add('checkbox', 'override', ts('Override default template'));
     $this->add('textarea', 'custom_template', ts('Custom template:<br><SMALL><font color="red">Please customize the smarty v2 template only if you know what you are doing</font></SMALL>'));
 
+    $this->addElement('submit','preview','name="Save and Preview" id="preview"');
     $this->addButtons(array(
       array(
         'type' => 'submit',
         'name' => ts('Save'),
         'isDefault' => TRUE,
       ),
+        array(
+          'type' => 'savenprev',
+          'name' => ts('Save & Preview'),
+        ),
     ));
-
+    
+    $this->add('textarea', 'embd_code', ts('Code to embed:'));
+    
     // export form elements
     $this->assign('elementNames', $this->getRenderableElementNames());
 
-    $smarty = CRM_Core_Smarty::singleton();
     if (isset($this->_id)) {  
       /** Updating existing widget*/
 
@@ -195,6 +213,9 @@ where w.id=" . $this->_id;
               'custom_template' => $cust_templ));
         }
       }
+      $emb_code = "<script src=\"http://code.jquery.com/jquery-1.9.1.min.js\"></script>
+<script type=\"text/javascript\" src=\"http://localhost/F3/sites/all/modules/civicrm/extensions/civicrm-wci/extern/wciwidget.php?widgetId=" . $this->_id . "\"></script>";
+      $this->getElement('embd_code')->setValue($emb_code);
     }
     else {
       /** Keep template in civicrm-wci/templates folder*/
index 012d6f5183552154a78ccca1d8fc1fe2f890e2f8..0a453fe2db2e8f2925282ae8818f9017960a2f52 100644 (file)
@@ -14,7 +14,7 @@ class CRM_Wci_Form_ProgressBar extends CRM_Core_Form {
   private $_id;  
   function preProcess() {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'REQUEST');
-    CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'addmore.js');
+    CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'F3/sites/all/modules/civicrm/extensions/civicrm-wci/addmore.js');
     parent::preProcess();
   }
   function fillData() {
index a96273b718ada5b8484a1a5b978c8e42f5e976dd..9dcf43a1d19532cb49e0db41031632fae9dc751e 100644 (file)
@@ -57,7 +57,7 @@ if (isset($embed) && (true == $embed)) {
 
 } else {
   $data = CRM_Wci_BAO_Widget::getWidgetData($widgetId);
-  $template->assign('form', $data);
+  $template->assign('wciform', $data);
 
   $template->template_dir[] = $_SERVER['DOCUMENT_ROOT'] . "/F3/sites/all/modules/civicrm/extensions/civicrm-wci/templates/CRM/Wci/Page";
   $wcidata = $template->fetch('wciwidget.tpl');
index c99bb1f08e51437b96be2bdc42ae14e018c71fbc..1a4ca1bef65370a7ba392476947a6e4cc88f006d 100644 (file)
   </div>
 {/foreach}
 
+{if $form.title.value != ""}
+  {php} 
+    if(isset($_REQUEST['id'])) {
+      $wid_id = $_REQUEST['id'];
+      $data = CRM_Wci_BAO_Widget::getWidgetData($wid_id);
+      $template = CRM_Core_Smarty::singleton();
+      $template->assign('wciform', $data);
+      $template->template_dir[] = $_SERVER['DOCUMENT_ROOT'] . "/F3/sites/all/modules/civicrm/extensions/civicrm-wci/templates/CRM/Wci/Page";
+      $wcidata = $template->fetch('wciwidget.tpl');
+    }
+  {/php}
+
+  <div class="crm-section">
+    <div class="content">
+    {include file="CRM/Wci/Page/wciwidget.tpl"}
+    </div>
+  </div>
+{/if}
+
 {* FIELD EXAMPLE: OPTION 2 (MANUAL LAYOUT)
 
   <div>
@@ -22,6 +41,8 @@
   </div>
 
 {* FOOTER *}
+
 <div class="crm-submit-buttons">
 {include file="CRM/common/formButtons.tpl" location="bottom"}
 </div>
+
diff --git a/templates/CRM/Wci/Page/WidgetList.tpl b/templates/CRM/Wci/Page/WidgetList.tpl
new file mode 100644 (file)
index 0000000..e98724c
--- /dev/null
@@ -0,0 +1,93 @@
+{* 
+<h3>This new page is generated by CRM/Wci/Page/WidgetList.php</h3>
+*}
+{* Example: Display a variable directly 
+<p>The current time is {$currentTime}</p>
+*}
+{* Example: Display a translated string -- which happens to include a variable 
+<p>{ts 1=$currentTime}(In your native language) The current time is %1.{/ts}</p>
+*}
+
+    {if $rows}
+      <div id="configure_contribution_page">
+             {strip}
+
+       {include file="CRM/common/pager.tpl" location="top"}
+             {include file="CRM/common/pagerAToZ.tpl"}
+             {* handle enable/disable actions *}
+             {include file="CRM/common/enableDisable.tpl"}
+       {include file="CRM/common/jsortable.tpl"}
+             <table id="options" class="display">
+               <thead>
+               <tr>
+                 <th id="sortable">{ts}Title{/ts}</th>
+                 <th>{ts}Description{/ts}</th>
+               {*<th>{ts}Enabled?{/ts}</th>*}
+               {*
+             {if call_user_func(array('CRM_Campaign_BAO_Campaign','isCampaignEnable'))}
+             <th>{ts}Campaign{/ts}</th>
+            {/if} *}
+            <th></th>
+               </tr>
+               </thead>
+               {foreach from=$rows item=row}
+                 <tr id="row_{$row.id}" >   {* class="{if NOT $row.is_active} disabled{/if}" *}
+                     <td><strong>{$row.title}</strong></td>
+                     <td>{$row.description}</td>
+{*                     <td id="row_{$row.id}_status">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
+          {if call_user_func(array('CRM_Campaign_BAO_Campaign','isCampaignEnable'))}
+          <td>{$row.campaign}</td> 
+          {/if} *}
+          <td class="crm-contribution-page-actions right nowrap">
+
+       {if $row.configureActionLinks}
+         <div class="crm-contribution-page-configure-actions">
+                  {$row.configureActionLinks|replace:'xx':$row.id}
+         </div>
+             {/if}
+
+            {if $row.contributionLinks}
+        <div class="crm-contribution-online-contribution-actions">
+                  {$row.contributionLinks|replace:'xx':$row.id}
+        </div>
+        {/if}
+
+        {if $row.onlineContributionLinks}
+        <div class="crm-contribution-search-contribution-actions">
+                  {$row.onlineContributionLinks|replace:'xx':$row.id}
+        </div>
+        {/if}
+
+        <div class="crm-contribution-page-more">
+                    {$row.action|replace:'xx':$row.id}
+            </div>
+
+      </td>
+
+         </tr>
+         {/foreach}
+      </table>
+
+        {/strip}
+      </div>
+    {else}
+  {if $isSearch eq 1}
+      <div class="status messages">
+                <img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"/>
+                {capture assign=browseURL}{crmURL p='civicrm/contribute/manage' q="reset=1"}{/capture}
+                    {ts}No available Contribution Pages match your search criteria. Suggestions:{/ts}
+                    <div class="spacer"></div>
+                    <ul>
+                    <li>{ts}Check your spelling.{/ts}</li>
+                    <li>{ts}Try a different spelling or use fewer letters.{/ts}</li>
+                    <li>{ts}Make sure you have enough privileges in the access control system.{/ts}</li>
+                    </ul>
+                    {ts 1=$browseURL}Or you can <a href='%1'>browse all available Contribution Pages</a>.{/ts}
+      </div>
+      {else}
+      <div class="messages status no-popup">
+             <div class="icon inform-icon"></div> &nbsp;
+             {ts 1=$newPageURL}No contribution pages have been created yet. Click <a accesskey="N" href='%1'>here</a> to create a new contribution page.{/ts}
+      </div>
+        {/if}
+    {/if}
diff --git a/templates/CRM/Wci/Page/wciwidget.tpl b/templates/CRM/Wci/Page/wciwidget.tpl
new file mode 100644 (file)
index 0000000..9bae716
--- /dev/null
@@ -0,0 +1,188 @@
+{literal}
+<style>
+    .crm-wci-widget {
+        font-size:12px;
+        font-family:Helvetica, Arial, sans;
+        padding:6px;
+        -moz-border-radius:       4px;
+        -webkit-border-radius:   4px;
+        -khtml-border-radius:   4px;
+        border-radius:      4px;
+        border:1px solid #96C0E7;
+    }
+    
+    .crm-wci-widget.thin {
+      width: 150px;
+    }
+    
+    .crm-wci-widget.normal {
+      width: 200px;
+    }
+    
+    .crm-wci-widget.wide {
+      width: 250px;
+    }
+    
+    .crm-wci-widget h5 {
+        font-size:14px;
+        padding:3px;
+        margin: 0px;
+        text-align:center;
+        -moz-border-radius:   4px;
+        -webkit-border-radius:   4px;
+        -khtml-border-radius:   4px;
+        border-radius:      4px;
+    }
+
+    .crm-wci-widget .crm-amounts {
+        height:1em;
+        margin:.8em 0px;
+        font-size:13px;
+    }
+    .crm-wci-widget .crm-amount-low {
+        float:left;
+    }
+    .crm-wci-widget .crm-amount-high {
+        float:right;
+    }
+    .crm-wci-widget .crm-percentage {
+        margin:0px 30%;
+        text-align:center;
+    }
+    .crm-wci-widget .crm-amount-bar {
+        background-color:#FFF;
+        width:100%;
+        display:block;
+        border:1px solid #CECECE;
+        -moz-border-radius:   4px;
+        -webkit-border-radius:   4px;
+        -khtml-border-radius:   4px;
+        border-radius:      4px;
+        margin-bottom:.8em;
+        text-align:left;
+    }
+    .crm-wci-widget .crm-amount-fill {
+        background-color:#2786C2;
+        height:1em;
+        display:block;
+        -moz-border-radius:   4px 0px 0px 4px;
+        -webkit-border-radius:   4px 0px 0px 4px;
+        -khtml-border-radius:   4px 0px 0px 4px;
+        border-radius:      4px 0px 0px 4px;
+        text-align:left;
+        width: {/literal}{$wciform.pb_percentage}{literal}%; /* progress bar percentage */
+    }
+    .crm-wci-widget .crm-amount-raised-wrapper {
+        margin-bottom:.8em;
+    }
+    .crm-wci-widget .crm-amount-raised {
+        font-weight:bold;
+    }
+
+    .crm-wci-widget .crm-logo {
+        text-align:center;
+    }
+
+    .crm-wci-widget .crm-comments,
+    .crm-wci-widget .crm-donors,
+    .crm-wci-widget .crm-campaign {
+        font-size:11px;
+        margin-bottom:.8em;
+    }
+
+    .crm-wci-widget .crm-wci-button {
+        display:block;
+        background-color:#CECECE;
+        -moz-border-radius:       4px;
+        -webkit-border-radius:   4px;
+        -khtml-border-radius:   4px;
+        border-radius:      4px;
+        text-align:center;
+        margin:0px 10% .8em 10%;
+        text-decoration:none;
+        color:#556C82;
+        padding:2px;
+        font-size:13px;
+    }
+
+    .crm-wci-widget .crm-home-url {
+        text-decoration:none;
+        border:0px;
+    }
+
+</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};
+    }
+
+    .crm-wci-widget .crm-wci-button-inner { /* button text color */
+        padding:2px;
+        display:block;
+        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}
+{literal}
+</style>
+{/literal}
+
+<div id="crm_wid_{$widgetId}" class="crm-wci-widget {$wciform.size_variant}">
+    <h5 id="crm_wid_{$widgetId}_title">
+      {if $wciform.logo_image}
+        <span class="crm-logo">
+          <img src="{$wciform.logo_image}" alt={ts}Logo{/ts}>
+        </span>
+      {/if}
+      {$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>
+    <div class="crm-amount-bar">
+        <div class="crm-amount-fill" id="crm_wid_{$widgetId}_amt_fill"></div>
+    </div>
+    <div id="crm_wid_{$widgetId}_donors" class="crm-donors">
+    </div>
+    <div id="crm_wid_{$widgetId}_comments" class="crm-comments">
+      {$wciform.description}
+    </div>
+    <div id="crm_wid_{$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=$wciform.button_link_to" 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>
+</div>