本文整理汇总了PHP中DevblocksPlatform::getTemplateBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP DevblocksPlatform::getTemplateBuilder方法的具体用法?PHP DevblocksPlatform::getTemplateBuilder怎么用?PHP DevblocksPlatform::getTemplateBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DevblocksPlatform
的用法示例。
在下文中一共展示了DevblocksPlatform::getTemplateBuilder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run(Model_Alert $alert, $sensors)
{
@($to = DevblocksPlatform::parseCsvString($alert->actions[self::EXTENSION_ID]['to']));
@($template_subject = $alert->actions[self::EXTENSION_ID]['template_subject']);
@($template_body = $alert->actions[self::EXTENSION_ID]['template_body']);
$logger = DevblocksPlatform::getConsoleLog();
// Assign template variables
$tpl = DevblocksPlatform::getTemplateService();
$tpl->clear_all_assign();
$tpl->assign('alert', $alert);
$tpl->assign('sensors', $sensors);
$tpl->assign('num_sensors', count($sensors));
// Build template
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$errors = array();
// Subject
if (false == ($subject = $tpl_builder->build($template_subject))) {
$errors += $tpl_builder->getErrors();
}
// Body
if (false == ($body = $tpl_builder->build($template_body))) {
$errors += $tpl_builder->getErrors();
}
if (!empty($errors)) {
$logger->err(sprintf("Errors in mail template (skipping): %s", implode("<br>\r\n", $errors)));
return false;
}
if (is_array($to)) {
foreach ($to as $address) {
$logger->info(sprintf("Sending mail to %s about %d sensors", $address, count($sensors)));
PortSensorMail::quickSend($address, $subject, $body);
}
}
}
示例2: run
function run(Model_Alert $alert, $sensors)
{
@($to = DevblocksPlatform::parseCsvString($alert->actions[self::EXTENSION_ID]['to']));
@($template_msg = $alert->actions[self::EXTENSION_ID]['template_msg']);
$result = true;
$logger = DevblocksPlatform::getConsoleLog();
$settings = DevblocksPlatform::getPluginSettingsService();
// Assign template variables
$tpl = DevblocksPlatform::getTemplateService();
$tpl->clear_all_assign();
$tpl->assign('alert', $alert);
$tpl->assign('sensors', $sensors);
$tpl->assign('num_sensors', count($sensors));
// Build template
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$errors = array();
// Body
if (false == ($text = $tpl_builder->build($template_msg))) {
$errors += $tpl_builder->getErrors();
}
if (!empty($errors)) {
$logger->err(sprintf("Errors in SMS template (skipping): %s", implode("<br>\r\n", $errors)));
return false;
}
// Truncate message to 155 chars
if (155 <= strlen($text)) {
$text = substr($text, 0, 152) . '...';
}
// Clickatell SMS gateways
$user = $settings->get('portsensor.sms', 'clickatell_username', '');
$password = $settings->get('portsensor.sms', 'clickatell_password', '');
$api_id = $settings->get('portsensor.sms', 'clickatell_api_id', '');
if (empty($user) || empty($password) || empty($api_id)) {
return;
}
if (is_array($to)) {
foreach ($to as $phone) {
$logger->info(sprintf("Sending SMS to %s about %d sensors", $phone, count($sensors)));
$url = sprintf("http://api.clickatell.com/http/sendmsg?user=%s&password=%s&api_id=%s&to=%s&text=%s", urlencode($user), urlencode($password), urlencode($api_id), urlencode($phone), urlencode($text));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$out = curl_exec($ch);
curl_close($ch);
$result = 0 == strcasecmp("ID:", substr($out, 0, 3));
}
}
return $result;
}
示例3: doBulkUpdate
function doBulkUpdate($filter, $do, $ids = array())
{
@set_time_limit(600);
// [TODO] Temp!
$change_fields = array();
$custom_fields = array();
// Make sure we have actions
if (empty($do)) {
return;
}
// Make sure we have checked items if we want a checked list
if (0 == strcasecmp($filter, "checks") && empty($ids)) {
return;
}
if (is_array($do)) {
foreach ($do as $k => $v) {
switch ($k) {
case 'status':
switch (strtolower($v)) {
case 'open':
$change_fields[DAO_CrmOpportunity::IS_CLOSED] = 0;
$change_fields[DAO_CrmOpportunity::IS_WON] = 0;
$change_fields[DAO_CrmOpportunity::CLOSED_DATE] = 0;
break;
case 'won':
$change_fields[DAO_CrmOpportunity::IS_CLOSED] = 1;
$change_fields[DAO_CrmOpportunity::IS_WON] = 1;
$change_fields[DAO_CrmOpportunity::CLOSED_DATE] = time();
break;
case 'lost':
$change_fields[DAO_CrmOpportunity::IS_CLOSED] = 1;
$change_fields[DAO_CrmOpportunity::IS_WON] = 0;
$change_fields[DAO_CrmOpportunity::CLOSED_DATE] = time();
break;
}
break;
case 'closed_date':
$change_fields[DAO_CrmOpportunity::CLOSED_DATE] = intval($v);
break;
case 'worker_id':
$change_fields[DAO_CrmOpportunity::WORKER_ID] = intval($v);
break;
default:
// Custom fields
if (substr($k, 0, 3) == "cf_") {
$custom_fields[substr($k, 3)] = $v;
}
}
}
}
$pg = 0;
if (empty($ids)) {
do {
list($objects, $null) = DAO_CrmOpportunity::search(array(), $this->params, 100, $pg++, SearchFields_CrmOpportunity::ID, true, false);
$ids = array_merge($ids, array_keys($objects));
} while (!empty($objects));
}
// Broadcast?
if (isset($do['broadcast'])) {
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$params = $do['broadcast'];
if (!isset($params['worker_id']) || empty($params['worker_id']) || !isset($params['subject']) || empty($params['subject']) || !isset($params['message']) || empty($params['message'])) {
break;
}
$is_queued = isset($params['is_queued']) && $params['is_queued'] ? true : false;
if (is_array($ids)) {
foreach ($ids as $opp_id) {
try {
CerberusContexts::getContext(CerberusContexts::CONTEXT_OPPORTUNITY, $opp_id, $tpl_labels, $tpl_tokens);
$subject = $tpl_builder->build($params['subject'], $tpl_tokens);
$body = $tpl_builder->build($params['message'], $tpl_tokens);
$fields = array(DAO_MailQueue::TYPE => Model_MailQueue::TYPE_COMPOSE, DAO_MailQueue::TICKET_ID => 0, DAO_MailQueue::WORKER_ID => $params['worker_id'], DAO_MailQueue::UPDATED => time(), DAO_MailQueue::HINT_TO => $tpl_tokens['email_address'], DAO_MailQueue::SUBJECT => $subject, DAO_MailQueue::BODY => $body, DAO_MailQueue::PARAMS_JSON => json_encode(array('to' => $tpl_tokens['email_address'], 'group_id' => $params['group_id'])));
if ($is_queued) {
$fields[DAO_MailQueue::IS_QUEUED] = 1;
}
$draft_id = DAO_MailQueue::create($fields);
} catch (Exception $e) {
// [TODO] ...
}
}
}
}
$batch_total = count($ids);
for ($x = 0; $x <= $batch_total; $x += 100) {
$batch_ids = array_slice($ids, $x, 100);
DAO_CrmOpportunity::update($batch_ids, $change_fields);
// Custom Fields
self::_doBulkSetCustomFields(CrmCustomFieldSource_Opportunity::ID, $custom_fields, $batch_ids);
unset($batch_ids);
}
unset($ids);
}