more work on form building, added images, CRM-12965
authorKurund Jalmi <kurund@civicrm.org>
Thu, 4 Jul 2013 10:27:38 +0000 (15:57 +0530)
committerKurund Jalmi <kurund@civicrm.org>
Thu, 4 Jul 2013 10:27:38 +0000 (15:57 +0530)
CRM/Badge/Form/Layout.php
templates/CRM/Badge/Form/Layout.js [new file with mode: 0644]
templates/CRM/Badge/Form/Layout.tpl

index b851e6b35801f02ec2d7e31fb8bec16a1ed0cf0d..cf285186abfb83f00cebcc96fb60f44d53eeb066 100644 (file)
@@ -53,6 +53,15 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
       return;
     }
 
+    $config = CRM_Core_Config::singleton();
+    $resources = CRM_Core_Resources::singleton();
+    $resources->addSetting(
+      array(
+        'kcfinderPath' => $config->userFrameworkResourceURL .'packages' .DIRECTORY_SEPARATOR
+      )
+    );
+    $resources->addScriptFile('civicrm', 'templates/CRM/Badge/Form/Layout.js');
+
     $this->applyFilter('__ALL__', 'trim');
 
     $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'), true);
@@ -87,6 +96,13 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     unset($textAlignment['J']);
     $this->add('select', "barcode_alignment", ts('Alignment'), $textAlignment);
 
+    $attributes = array(
+      'readonly'=> true,
+      'value' => ts('click here and select a file double clicking on it'),
+    );
+    $this->add('text', 'image_1', ts('Image 1'), $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
+    $this->add('text', 'image_2', ts('Image 2'), $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
+
     $this->add('checkbox', 'is_default', ts('Default?'));
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     $this->add('checkbox', 'is_reserved', ts('Reserved?'));
@@ -119,6 +135,9 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     $defaults['add_barcode'] = CRM_Utils_Array::value('add_barcode', $data);
     $defaults['barcode_alignment'] = CRM_Utils_Array::value('barcode_alignment', $data);
 
+    $defaults['image_1'] = CRM_Utils_Array::value('image_1', $data);
+    $defaults['image_2'] = CRM_Utils_Array::value('image_2', $data);
+
     if ($this->_action == CRM_Core_Action::DELETE && isset($defaults['title'])) {
       $this->assign('delName', $defaults['title']);
     }
diff --git a/templates/CRM/Badge/Form/Layout.js b/templates/CRM/Badge/Form/Layout.js
new file mode 100644 (file)
index 0000000..bbc88b2
--- /dev/null
@@ -0,0 +1,20 @@
+// http://civicrm.org/licensing
+cj(function ($) {
+  function openKCFinder(field) {
+    window.KCFinder = {
+      callBack: function(url) {
+        field.val(url);
+        window.KCFinder = null;
+      }
+    };
+
+    window.open(CRM.kcfinderPath + 'kcfinder/browse.php?cms=civicrm&type=images', 'kcfinder_textbox',
+      'status=0, toolbar=0, location=0, menubar=0, directories=0, ' +
+        'resizable=1, scrollbars=0, width=800, height=600'
+    );
+  }
+
+  $('input[id^="image_"]').click(function(){
+    openKCFinder($(this));
+  });
+});
index 122114a17f854795f0952b380132ef43b54acafb..b56b3414157c2f6e2ab7fe8c39136a9f21f5f689 100644 (file)
 
         </td>
       </tr>
+      <tr class="crm-badge-layout-form-block-image_1">
+        <td class="label">{$form.image_1.label}</td>
+        <td>{$form.image_1.html}<br/><span class="description">{ts}This image will displayed on top left{/ts}</span></td>
+      </tr>
+      <tr class="crm-badge-layout-form-block-image_2">
+        <td class="label">{$form.image_2.label}</td>
+        <td>{$form.image_2.html}<br/><span class="description">{ts}This image will displayed on top right{/ts}</span></td>
+      </tr>
       <tr class="crm-badge-layout-form-block-add_barcode">
         <td class="label">{$form.add_barcode.label}</td>
         <td>{$form.add_barcode.html}&nbsp;&nbsp;&nbsp;{ts}on{/ts}&nbsp;&nbsp;&nbsp;{$form.barcode_alignment.html}</td>