From d87c3006418529c37fa4273447c68d4eea7612b2 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Thu, 4 Jul 2013 15:57:38 +0530 Subject: [PATCH] more work on form building, added images, CRM-12965 --- CRM/Badge/Form/Layout.php | 19 +++++++++++++++++++ templates/CRM/Badge/Form/Layout.js | 20 ++++++++++++++++++++ templates/CRM/Badge/Form/Layout.tpl | 8 ++++++++ 3 files changed, 47 insertions(+) create mode 100644 templates/CRM/Badge/Form/Layout.js diff --git a/CRM/Badge/Form/Layout.php b/CRM/Badge/Form/Layout.php index b851e6b358..cf285186ab 100644 --- a/CRM/Badge/Form/Layout.php +++ b/CRM/Badge/Form/Layout.php @@ -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 index 0000000000..bbc88b2fc5 --- /dev/null +++ b/templates/CRM/Badge/Form/Layout.js @@ -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)); + }); +}); diff --git a/templates/CRM/Badge/Form/Layout.tpl b/templates/CRM/Badge/Form/Layout.tpl index 122114a17f..b56b341415 100644 --- a/templates/CRM/Badge/Form/Layout.tpl +++ b/templates/CRM/Badge/Form/Layout.tpl @@ -75,6 +75,14 @@ + + {$form.image_1.label} + {$form.image_1.html}
{ts}This image will displayed on top left{/ts} + + + {$form.image_2.label} + {$form.image_2.html}
{ts}This image will displayed on top right{/ts} + {$form.add_barcode.label} {$form.add_barcode.html}   {ts}on{/ts}   {$form.barcode_alignment.html} -- 2.25.1