}
/**
- * Get the messages document
+ * Get the messages document (either from the cache or by downloading)
*
* @return NULL|array
*/
$document['expires'] = CRM_Utils_Time::getTimeRaw() + $document['ttl'];
}
else {
+ // keep the old messages for now, try again later
$document['expires'] = CRM_Utils_Time::getTimeRaw() + $document['retry'];
}
$isChanged = TRUE;
}
/**
- * Pick one message
+ * Pick a message to display
*
- * @param callable $permChecker
- * @param array $components
* @return NULL|array
*/
public function pick() {
* @return string
*/
public static function evalMarkup($markup) {
- throw new Exception('not implemented');
+ $config = CRM_Core_Config::singleton();
+ $vals = array(
+ 'resourceUrl' => rtrim($config->resourceBase, '/'),
+ 'ver' => CRM_Utils_System::version(),
+ 'uf' => $config->userFramework,
+ 'php' => phpversion(),
+ 'sid' => md5('sid_' . (defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : '') . '_' . $config->userFrameworkBaseURL),
+ 'baseUrl' => $config->userFrameworkBaseURL,
+ 'lang' => $config->lcMessages,
+ 'co' => $config->defaultContactCountry,
+ );
+ $vars = array();
+ foreach ($vals as $k => $v) {
+ $vars['%%'.$k.'%%'] = $v;
+ $vars['{{'.$k.'}}'] = urlencode($v);
+ }
+ return strtr($markup, $vars);
}
/**
$this->assertEquals($trials, $freq['<h1>Two</h1>']);
}
+ function testEvalMarkup() {
+ $communityMessages = new CRM_Core_CommunityMessages(
+ $this->cache,
+ $this->expectNoHttpRequest()
+ );
+ $this->assertEquals('cms=UnitTests cms=UnitTests', $communityMessages->evalMarkup('cms=%%uf%% cms={{uf}}'));
+ }
+
/**
* Generate a mock HTTP client with the expectation that it is never called.
*