Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Update smartdebit.civix.php, small tweaks to settings functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Nov 24, 2017
1 parent f3069eb commit 88e8d7f
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 8 deletions.
6 changes: 4 additions & 2 deletions CRM/Smartdebit/Form/Settings.php
Expand Up @@ -23,6 +23,8 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+-------------------------------------------------------------------*/

use CRM_Smartdebit_ExtensionUtil as E;

/**
* Form controller class
*
Expand All @@ -45,7 +47,7 @@ function buildQuickForm() {
$this->assign('apiStatus', 'No Smartdebit payment processors are configured yet!');
}

CRM_Utils_System::setTitle(ts('Smart Debit - Settings'));
CRM_Utils_System::setTitle(CRM_Smartdebit_Settings::TITLE . ' - ' . E::ts('Settings'));

$settings = $this->getFormSettings();

Expand Down Expand Up @@ -168,7 +170,7 @@ function setDefaultValues() {
$settings = $this->getFormSettings(FALSE);
$defaults = array();

$existing = CRM_Smartdebit_Settings::get($settings);
$existing = CRM_Smartdebit_Settings::get(array_keys($settings));
if ($existing) {
foreach ($existing as $name => $value) {
$defaults[$name] = $value;
Expand Down
6 changes: 3 additions & 3 deletions CRM/Smartdebit/Settings.php
Expand Up @@ -68,10 +68,10 @@ public static function getValue($name) {
public static function get($settings) {
$domainID = CRM_Core_Config::domainID();

foreach ($settings as $name => $value) {
$prefixedSettings[self::getName($name, TRUE)] = $value;
foreach ($settings as $name) {
$prefixedSettings[] = self::getName($name, TRUE);
}
$settingsResult = civicrm_api3('setting', 'get', array('return' => array_keys($prefixedSettings)));
$settingsResult = civicrm_api3('setting', 'get', array('return' => $prefixedSettings));
if (isset($settingsResult['values'][$domainID])) {
foreach ($settingsResult['values'][$domainID] as $name => $value) {
$unprefixedSettings[self::getName($name)] = $value;
Expand Down
83 changes: 80 additions & 3 deletions smartdebit.civix.php
Expand Up @@ -2,6 +2,83 @@

// AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file

/**
* The ExtensionUtil class provides small stubs for accessing resources of this
* extension.
*/
class CRM_Smartdebit_ExtensionUtil {
const SHORT_NAME = "smartdebit";
const LONG_NAME = "org.civicrm.smartdebit";
const CLASS_PREFIX = "CRM_Smartdebit";

/**
* Translate a string using the extension's domain.
*
* If the extension doesn't have a specific translation
* for the string, fallback to the default translations.
*
* @param string $text
* Canonical message text (generally en_US).
* @param array $params
* @return string
* Translated text.
* @see ts
*/
public static function ts($text, $params = array()) {
if (!array_key_exists('domain', $params)) {
$params['domain'] = array(self::LONG_NAME, NULL);
}
return ts($text, $params);
}

/**
* Get the URL of a resource file (in this extension).
*
* @param string|NULL $file
* Ex: NULL.
* Ex: 'css/foo.css'.
* @return string
* Ex: 'http://example.org/sites/default/ext/org.example.foo'.
* Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'.
*/
public static function url($file = NULL) {
if ($file === NULL) {
return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/');
}
return CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME, $file);
}

/**
* Get the path of a resource file (in this extension).
*
* @param string|NULL $file
* Ex: NULL.
* Ex: 'css/foo.css'.
* @return string
* Ex: '/var/www/example.org/sites/default/ext/org.example.foo'.
* Ex: '/var/www/example.org/sites/default/ext/org.example.foo/css/foo.css'.
*/
public static function path($file = NULL) {
// return CRM_Core_Resources::singleton()->getPath(self::LONG_NAME, $file);
return __DIR__ . ($file === NULL ? '' : (DIRECTORY_SEPARATOR . $file));
}

/**
* Get the name of a class within this extension.
*
* @param string $suffix
* Ex: 'Page_HelloWorld' or 'Page\\HelloWorld'.
* @return string
* Ex: 'CRM_Foo_Page_HelloWorld'.
*/
public static function findClass($suffix) {
return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix);
}

}

use CRM_Smartdebit_ExtensionUtil as E;

/**
* (Delegated) Implements hook_civicrm_config().
*
Expand Down Expand Up @@ -190,7 +267,7 @@ function _smartdebit_civix_civicrm_managed(&$entities) {
$es = include $file;
foreach ($es as $e) {
if (empty($e['module'])) {
$e['module'] = 'org.civicrm.smartdebit';
$e['module'] = E::LONG_NAME;
}
$entities[] = $e;
if (empty($e['params']['version'])) {
Expand Down Expand Up @@ -222,7 +299,7 @@ function _smartdebit_civix_civicrm_caseTypes(&$caseTypes) {
// throw new CRM_Core_Exception($errorMessage);
}
$caseTypes[$name] = array(
'module' => 'org.civicrm.smartdebit',
'module' => E::LONG_NAME,
'name' => $name,
'file' => $file,
);
Expand All @@ -248,7 +325,7 @@ function _smartdebit_civix_civicrm_angularModules(&$angularModules) {
$name = preg_replace(':\.ang\.php$:', '', basename($file));
$module = include $file;
if (empty($module['ext'])) {
$module['ext'] = 'org.civicrm.smartdebit';
$module['ext'] = E::LONG_NAME;
}
$angularModules[$name] = $module;
}
Expand Down
1 change: 1 addition & 0 deletions smartdebit.php
Expand Up @@ -24,6 +24,7 @@
+-------------------------------------------------------------------*/

require_once 'smartdebit.civix.php';
use CRM_Smartdebit_ExtensionUtil as E;

/**
* Implements hook_civicrm_config().
Expand Down

0 comments on commit 88e8d7f

Please sign in to comment.