本文整理汇总了PHP中string_format函数的典型用法代码示例。如果您正苦于以下问题:PHP string_format函数的具体用法?PHP string_format怎么用?PHP string_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了string_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* This method implements the run function of RunnableSchedulerJob and handles processing a SchedulersJob
*
* @param Mixed $data parameter passed in from the job_queue.data column when a SchedulerJob is run
* @return bool true on success, false on error
*/
public function run($data)
{
global $app_strings, $language;
$app_strings = return_application_language($language);
$admin = BeanFactory::getBean('Administration');
$config = $admin->getConfigForModule('Forecasts', 'base');
$timeperiodInterval = $config['timeperiod_interval'];
$timeperiodLeafInterval = $config['timeperiod_leaf_interval'];
$parentTimePeriod = TimePeriod::getLatest($timeperiodInterval);
$latestTimePeriod = TimePeriod::getLatest($timeperiodLeafInterval);
$currentTimePeriod = TimePeriod::getCurrentTimePeriod($timeperiodLeafInterval);
if (empty($latestTimePeriod)) {
$GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . '[latest]');
return false;
} else {
if (empty($currentTimePeriod)) {
$GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [current]');
return false;
} else {
if (empty($parentTimePeriod)) {
$GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [parent]');
return false;
}
}
}
$timedate = TimeDate::getInstance();
//We run the rebuild command if the latest TimePeriod is less than the specified configuration interval
//from the current TimePeriod
$correctStartDate = $timedate->fromDbDate($currentTimePeriod->start_date);
$latestStartDate = $timedate->fromDbDate($latestTimePeriod->start_date);
$shownForward = $config['timeperiod_shown_forward'];
//Move the current start date forward by the leaf period amounts
for ($x = 0; $x < $shownForward; $x++) {
$correctStartDate->modify($parentTimePeriod->next_date_modifier);
}
$leafCycle = $latestTimePeriod->leaf_cycle;
//If the current start data that was modified according to the shown forward period is past the latest
//leaf period we need to build more timeperiods
while ($correctStartDate > $latestStartDate) {
//We need to keep creating leaf periods until we are in sync.
//If the leaf period we need to create is the start of the leaf cycle
//then we should also create the parent TimePeriod record.
$startDate = $latestStartDate->modify($latestTimePeriod->next_date_modifier);
$leafCycle = $leafCycle == $parentTimePeriod->leaf_periods ? 1 : $leafCycle + 1;
if ($leafCycle == 1) {
$parentTimePeriod = TimePeriod::getByType($timeperiodInterval);
$parentTimePeriod->setStartDate($startDate->asDbDate());
$parentTimePeriod->name = $parentTimePeriod->getTimePeriodName($leafCycle);
$parentTimePeriod->save();
}
$leafTimePeriod = TimePeriod::getByType($timeperiodLeafInterval);
$leafTimePeriod->setStartDate($startDate->asDbDate());
$leafTimePeriod->name = $leafTimePeriod->getTimePeriodName($leafCycle, $parentTimePeriod);
$leafTimePeriod->leaf_cycle = $leafCycle;
$leafTimePeriod->parent_id = $parentTimePeriod->id;
$leafTimePeriod->save();
}
$this->job->succeedJob();
return true;
}
示例2: get_recently_viewed
function get_recently_viewed($user_id, $modules = '')
{
$path = 'modules/Trackers/BreadCrumbStack.php';
if (defined('TEMPLATE_URL')) {
$path = SugarTemplateUtilities::getFilePath($path);
}
require_once $path;
if (empty($_SESSION['breadCrumbs'])) {
$breadCrumb = new BreadCrumbStack($user_id, $modules);
$_SESSION['breadCrumbs'] = $breadCrumb;
$GLOBALS['log']->info(string_format($GLOBALS['app_strings']['LBL_BREADCRUMBSTACK_CREATED'], array($user_id)));
} else {
$breadCrumb = $_SESSION['breadCrumbs'];
$module_query = '';
if (!empty($modules)) {
$history_max_viewed = 10;
$module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','", $modules) . '\')' : ' AND module_name = \'' . $modules . '\'';
} else {
$history_max_viewed = !empty($GLOBALS['sugar_config']['history_max_viewed']) ? $GLOBALS['sugar_config']['history_max_viewed'] : 50;
}
$query = 'SELECT item_id, item_summary, module_name, id FROM ' . $this->table_name . ' WHERE id = (SELECT MAX(id) as id FROM ' . $this->table_name . ' WHERE user_id = \'' . $user_id . '\' AND deleted = 0 AND visible = 1' . $module_query . ')';
$result = $this->db->limitQuery($query, 0, $history_max_viewed, true, $query);
while ($row = $this->db->fetchByAssoc($result)) {
$breadCrumb->push($row);
}
}
$list = $breadCrumb->getBreadCrumbList($modules);
$GLOBALS['log']->info("Tracker: retrieving " . count($list) . " items");
return $list;
}
示例3: run
/**
* This method implements the run function of RunnableSchedulerJob and handles processing a SchedulersJob
*
* @param Mixed $data parameter passed in from the job_queue.data column when a SchedulerJob is run
* @return bool true on success, false on error
*/
public function run($data)
{
// Searches across modules for rate update scheduler jobs and executes them.
// Each module that has currency rates in its model(s) *must* have a scheduler
// job defined in order to update its rates when a currency rate is updated.
$globPaths = array('custom/modules/*/jobs/Custom*CurrencyRateUpdate.php', 'modules/*/jobs/*CurrencyRateUpdate.php');
foreach ($globPaths as $entry) {
$jobFiles = glob($entry, GLOB_NOSORT);
if (!empty($jobFiles)) {
foreach ($jobFiles as $jobFile) {
$jobClass = basename($jobFile, '.php');
require_once $jobFile;
if (!class_exists($jobClass)) {
$GLOBALS['log']->error(string_format($GLOBALS['app_strings']['ERR_DB_QUERY'], array(get_class($this), 'uknown class: ' . $jobClass)));
continue;
}
$jobObject = new $jobClass();
$data = $this->job->data;
$jobObject->run($data);
}
}
}
$this->job->succeedJob();
return true;
}
示例4: display
function display()
{
global $mod_strings, $export_module, $current_language, $theme, $current_user, $dashletData, $sugar_flavor;
if ($this->checkPostMaxSizeError()) {
$this->errors[] = $GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT'];
$contentLength = $_SERVER['CONTENT_LENGTH'];
$maxPostSize = ini_get('post_max_size');
if (stripos($maxPostSize, "k")) {
$maxPostSize = (int) $maxPostSize * pow(2, 10);
} elseif (stripos($maxPostSize, "m")) {
$maxPostSize = (int) $maxPostSize * pow(2, 20);
}
$maxUploadSize = ini_get('upload_max_filesize');
if (stripos($maxUploadSize, "k")) {
$maxUploadSize = (int) $maxUploadSize * pow(2, 10);
} elseif (stripos($maxUploadSize, "m")) {
$maxUploadSize = (int) $maxUploadSize * pow(2, 20);
}
$max_size = min($maxPostSize, $maxUploadSize);
$errMessage = string_format($GLOBALS['app_strings']['UPLOAD_MAXIMUM_EXCEEDED'], array($contentLength, $max_size));
$this->errors[] = '* ' . $errMessage;
$this->displayErrors();
}
include 'modules/Home/index.php';
}
示例5: testStringFormatDontReturnsEmptyValue
public function testStringFormatDontReturnsEmptyValue()
{
$sourceString = "SELECT accounts.name FROM accounts WHERE id IN";
$string = "{$sourceString} ({0})";
$args = array('');
$this->assertEquals("{$sourceString} ('')", string_format($string, $args));
}
示例6: processMaxPostErrors
function processMaxPostErrors()
{
if ($this->checkPostMaxSizeError()) {
$this->errors[] = $GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT'];
$contentLength = $_SERVER['CONTENT_LENGTH'];
$maxPostSize = ini_get('post_max_size');
if (stripos($maxPostSize, "k")) {
$maxPostSize = (int) $maxPostSize * pow(2, 10);
} elseif (stripos($maxPostSize, "m")) {
$maxPostSize = (int) $maxPostSize * pow(2, 20);
}
$maxUploadSize = ini_get('upload_max_filesize');
if (stripos($maxUploadSize, "k")) {
$maxUploadSize = (int) $maxUploadSize * pow(2, 10);
} elseif (stripos($maxUploadSize, "m")) {
$maxUploadSize = (int) $maxUploadSize * pow(2, 20);
}
$max_size = min($maxPostSize, $maxUploadSize);
if ($contentLength > $max_size) {
$errMessage = string_format($GLOBALS['app_strings']['UPLOAD_MAXIMUM_EXCEEDED'], array($contentLength, $max_size));
} else {
$errMessage = $GLOBALS['app_strings']['UPLOAD_REQUEST_ERROR'];
}
$this->errors[] = '* ' . $errMessage;
$this->displayErrors();
}
}
示例7: doCustomUpdateUsDollarRate
/**
* doCustomUpdateUsDollarRate
*
* Return true to skip updates for this module.
* Return false to do default update of amount * base_rate = usdollar
* To custom processing, do here and return true.
*
* @access public
* @param string $tableName
* @param string $usDollarColumn
* @param string $amountColumn
* @param string $currencyId
* @return boolean true if custom processing was done
*/
public function doCustomUpdateUsDollarRate($tableName, $usDollarColumn, $amountColumn, $currencyId)
{
// setup SQL statement
$query = sprintf("UPDATE %s SET %s = %s / base_rate\n WHERE quote_stage NOT LIKE ('%%Closed%%')\n AND currency_id = '%s'", $tableName, $usDollarColumn, $amountColumn, $currencyId);
// execute
$result = $this->db->query($query, true, string_format($GLOBALS['app_strings']['ERR_DB_QUERY'], array('QuotesCurrencyRateUpdate', $query)));
return !empty($result);
}
示例8: getModuleTitle
/**
* Return the "breadcrumbs" to display at the top of the page
*
* @param bool $show_help optional, true if we show the help links
* @return HTML string containing breadcrumb title
*/
public function getModuleTitle($show_help = true)
{
global $app_list_strings, $mod_strings;
$warningText = string_format($mod_strings['LBL_LIST_WARNING'], array($app_list_strings['moduleList']['Forecasts'], $app_list_strings['moduleList'][$this->module]));
$float = SugarThemeRegistry::current()->directionality == 'rtl' ? 'right' : 'left';
$title = '<div><div class="moduleTitle"><h2>' . $app_list_strings['moduleList'][$this->module] . '</h2></div>';
$title .= "<div class='overdueTask' style='float:{$float}; padding-bottom:10px;'>{$warningText}</div></div>";
return $title;
}
示例9: getTimePeriodName
/**
* getTimePeriodName
*
* Returns the timeperiod name. The TimePeriod base implementation simply returns the $count argument passed
* in from the code
*
* @param $count The timeperiod series count
* @return string The formatted name of the timeperiod
*/
public function getTimePeriodName($count)
{
$timedate = TimeDate::getInstance();
$year = $timedate->fromDbDate($this->start_date);
if (isset($this->currentSettings['timeperiod_fiscal_year']) && $this->currentSettings['timeperiod_fiscal_year'] == 'next_year') {
$year->modify('+1 year');
}
return string_format($this->name_template, array($year->format('Y')));
}
示例10: doCustomUpdateUsDollarRate
/**
* doCustomUpdateUsDollarRate
*
* Return true to skip updates for this module.
* Return false to do default update of amount * base_rate = usdollar
* To custom processing, do here and return true.
*
* @access public
* @param string $tableName
* @param string $usDollarColumn
* @param string $amountColumn
* @param string $currencyId
* @return boolean true if custom processing was done
*/
public function doCustomUpdateUsDollarRate($tableName, $usDollarColumn, $amountColumn, $currencyId)
{
$stages = $this->getClosedStages();
// setup SQL statement
$query = sprintf("UPDATE %s SET %s = %s / base_rate\n WHERE sales_stage NOT IN ('%s')\n AND currency_id = '%s'", $tableName, $usDollarColumn, $amountColumn, implode("','", $stages), $currencyId);
// execute
$result = $this->db->query($query, true, string_format($GLOBALS['app_strings']['ERR_DB_QUERY'], array('OpportunitiesCurrencyRateUpdate', $query)));
return !empty($result);
}
示例11: testCheckQuery
/**
* @dataProvider getQueries
* @outputBuffering disabled
*/
public function testCheckQuery($where, $order_by, $ok)
{
$helper = new SugarSQLValidate();
$res = $helper->validateQueryClauses($where, $order_by);
$params = array($where, $order_by);
if ($ok) {
$this->assertTrue($res, string_format("Failed asserting that where: {0} and order by: {1} is valid", $params));
} else {
$this->assertFalse($res, string_format("Failed asserting that where: {0} and order by: {1} is invalid", $params));
}
}
示例12: initialize
public function initialize($leadId)
{
$this->defs = $this->getVarDefs();
if (empty($this->defs)) {
throw new Exception('Could not retrieve lead convert metadata.');
}
$this->lead = BeanFactory::getBean('Leads', $leadId, array('strict_retrieve' => true));
if (empty($this->lead)) {
$errorMessage = string_format('Could not find record: {0} in module: Leads', $leadId);
throw new Exception($errorMessage);
}
}
示例13: setMessage
/**
* Sets the user locale appropriate message that is suitable for clients to display to end users.
* Message is based upon the message label provided when this SugarApiException was constructed.
*
* If the message label isn't found in app_strings or mod_strings, we'll use the label itself as the message.
*
* @param string $messageLabel required Label for error message. Used to load the appropriate translated message.
* @param array $msgArgs optional set of arguments to substitute into error message string
* @param string|null $moduleName Provide module name if $messageLabel is a module string, leave empty if
* $messageLabel is in app strings.
*/
public function setMessage($messageLabel, $msgArgs = null, $moduleName = null)
{
// If no message label, don't bother looking it up
if (empty($messageLabel)) {
$this->message = null;
return;
}
$message = translate($messageLabel, $moduleName);
// If no arguments provided, return message.
// If there are arguments, insert into message then return formatted message
if (empty($msgArgs)) {
$this->message = $message;
} else {
$this->message = string_format($message, $msgArgs);
}
}
示例14: listViewProcess
function listViewProcess()
{
if (!($eapmBean = EAPM::getLoginInfo('LotusLive', true))) {
$smarty = new Sugar_Smarty();
echo $smarty->fetch('include/externalAPI/LotusLive/LotusLiveSignup.' . $GLOBALS['current_language'] . '.tpl');
return;
}
$apiName = 'LotusLive';
$api = ExternalAPIFactory::loadAPI($apiName, true);
$api->loadEAPM($eapmBean);
$quickCheck = $api->quickCheckLogin();
if (!$quickCheck['success']) {
$errorMessage = string_format(translate('LBL_ERR_FAILED_QUICKCHECK', 'EAPM'), array('LotusLive'));
$errorMessage .= '<form method="POST" target="_EAPM_CHECK" action="index.php">';
$errorMessage .= '<input type="hidden" name="module" value="EAPM">';
$errorMessage .= '<input type="hidden" name="action" value="Save">';
$errorMessage .= '<input type="hidden" name="record" value="' . $eapmBean->id . '">';
$errorMessage .= '<input type="hidden" name="active" value="1">';
$errorMessage .= '<input type="hidden" name="closeWhenDone" value="1">';
$errorMessage .= '<input type="hidden" name="refreshParentWindow" value="1">';
$errorMessage .= '<br><input type="submit" value="' . $GLOBALS['app_strings']['LBL_EMAIL_OK'] . '"> ';
$errorMessage .= '<input type="button" onclick="lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" value="' . $GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL'] . '">';
$errorMessage .= '</form>';
echo $errorMessage;
return;
}
$this->processSearchForm();
$this->params['orderBy'] = 'meetings.date_start';
$this->params['overrideOrder'] = true;
$this->lv->searchColumns = $this->searchForm->searchColumns;
$this->lv->show_action_dropdown = false;
$this->lv->multiSelect = false;
unset($this->searchForm->searchdefs['layout']['advanced_search']);
if (!$this->headers) {
return;
}
if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
$this->lv->ss->assign("SEARCH", false);
if (!isset($_REQUEST['name_basic'])) {
$_REQUEST['name_basic'] = '';
}
$this->lv->ss->assign('DCSEARCH', $_REQUEST['name_basic']);
$this->lv->setup($this->seed, 'include/ListView/ListViewDCMenu.tpl', $this->where, $this->params);
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name'];
echo $this->lv->display();
}
}
示例15: sendNotificationOfDisabledReport
/**
* Notify the report owner of deactivated report schedule.
*
* @param int $report_id
* @param User $owner
* @param User $subscriber
*
* @throws MailerException Allows exceptions to bubble up for the caller to report if desired.
*/
public function sendNotificationOfDisabledReport($report_id, User $owner = null, User $subscriber = null)
{
$recipients = array($owner, $subscriber);
$recipients = array_filter($recipients);
// return early in case there are no recipients specified
if (!$recipients) {
return;
}
$mod_strings = return_module_language($this->language, 'Reports');
$subject = $mod_strings['ERR_REPORT_DEACTIVATED_SUBJECT'];
$body = string_format($mod_strings['ERR_REPORT_DEACTIVATED'], array($report_id));
// make sure that the same user doesn't receive the notification twice
$unique = array();
foreach ($recipients as $recipient) {
$unique[$recipient->id] = $recipient;
}
foreach ($unique as $recipient) {
$this->sendNotificationOfReport($recipient, $subject, $body);
}
}