From c68d158b7c8fba8b7dbe3f5f9da0223b55ef09b6 Mon Sep 17 00:00:00 2001 From: Manoj K Date: Thu, 16 Oct 2014 18:52:26 +0530 Subject: [PATCH] #29801 - Fix for hard coded path to widget controller and template. --- CRM/Wci/Form/CreateWidget.php | 10 +++++++++- CRM/Wci/Form/ProgressBar.php | 2 +- extern/wciwidget.php | 3 ++- templates/CRM/Wci/Form/CreateWidget.tpl | 2 +- wci-helper-functions.php | 16 ++++++++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CRM/Wci/Form/CreateWidget.php b/CRM/Wci/Form/CreateWidget.php index aa40ab5..8f29ae7 100644 --- a/CRM/Wci/Form/CreateWidget.php +++ b/CRM/Wci/Form/CreateWidget.php @@ -213,8 +213,16 @@ where w.id=" . $this->_id; 'custom_template' => $cust_templ)); } } + $widget_controller_path = getWciWidgetControllerPath(); + $emb_code = " -"; + +$( document ).ready(function() { +$('#widgetwci').html(wciwidgetcode); +}); + +
+
"; $this->getElement('embd_code')->setValue($emb_code); } else { diff --git a/CRM/Wci/Form/ProgressBar.php b/CRM/Wci/Form/ProgressBar.php index 0a453fe..012d6f5 100644 --- a/CRM/Wci/Form/ProgressBar.php +++ b/CRM/Wci/Form/ProgressBar.php @@ -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', 'F3/sites/all/modules/civicrm/extensions/civicrm-wci/addmore.js'); + CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'addmore.js'); parent::preProcess(); } function fillData() { diff --git a/extern/wciwidget.php b/extern/wciwidget.php index 9dcf43a..50b820d 100644 --- a/extern/wciwidget.php +++ b/extern/wciwidget.php @@ -38,6 +38,7 @@ */ require_once '../../../civicrm.config.php'; +require_once '../wci-helper-functions.php'; require_once 'CRM/Core/Config.php'; require_once 'CRM/Contribute/BAO/Widget.php'; require_once 'CRM/Utils/Request.php'; @@ -59,7 +60,7 @@ if (isset($embed) && (true == $embed)) { $data = CRM_Wci_BAO_Widget::getWidgetData($widgetId); $template->assign('wciform', $data); - $template->template_dir[] = $_SERVER['DOCUMENT_ROOT'] . "/F3/sites/all/modules/civicrm/extensions/civicrm-wci/templates/CRM/Wci/Page"; + $template->template_dir[] = getWciWidgetTemplatePath(); $wcidata = $template->fetch('wciwidget.tpl'); $output = 'var wciwidgetcode = ' . json_encode($wcidata) . ';'; echo $output; diff --git a/templates/CRM/Wci/Form/CreateWidget.tpl b/templates/CRM/Wci/Form/CreateWidget.tpl index 1a4ca1b..e404678 100644 --- a/templates/CRM/Wci/Form/CreateWidget.tpl +++ b/templates/CRM/Wci/Form/CreateWidget.tpl @@ -21,7 +21,7 @@ $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"; + $template->template_dir[] = getWciWidgetTemplatePath(); $wcidata = $template->fetch('wciwidget.tpl'); } {/php} diff --git a/wci-helper-functions.php b/wci-helper-functions.php index c38981b..2828fa0 100644 --- a/wci-helper-functions.php +++ b/wci-helper-functions.php @@ -12,3 +12,19 @@ return $options; } + + function getExtensionRootPath() { + return '//' . $_SERVER['SERVER_NAME'] . str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__); + } + + function getWciWidgetControllerPath() { + $widget_controller_path = getExtensionRootPath() . '/extern/wciwidget.php'; + + return $widget_controller_path; + } + + function getWciWidgetTemplatePath() { + $widget_tpl_path = getExtensionRootPath() . '/templates/CRM/Wci/Page'; + + return $widget_tpl_path; + } \ No newline at end of file -- 2.25.1