/**
 * Formats notifications that have defined template
 * 
 * @param string                           $hook         "format"
 * @param string                           $type         "notification"
 * @param \Elgg\Notifications\Notification $notification Notification
 * @param array                            $params       Hook params
 * @return \Elgg\Notifications\Notification
 */
function notifications_editor_format_notification($hook, $type, $notification, $params)
{
    $language = $notification->language;
    if (empty($notification->params['template'])) {
        return;
    }
    $template = notifications_editor_get_template_entity($notification->params['template'], $language);
    if (!$template) {
        return;
    }
    $event = elgg_extract('event', $params);
    if ($event instanceof \Elgg\Notifications\Event) {
        $action = $event->getAction();
        $actor = $event->getActor();
        $object = $event->getObject();
        if ($object instanceof ElggEntity) {
            $target = $object->getContainerEntity();
        } else {
            if ($object instanceof ElggRelationship) {
                $target = array('subject' => get_entity($object->guid_one), 'object' => get_entity($object->guid_two));
            } else {
                if ($object instanceof ElggAnnotation) {
                    $target = $object->getEntity();
                }
            }
        }
    }
    $template_params = array('action' => $action, 'actor' => $actor, 'object' => $object, 'target' => $target, 'recipient' => $notification->getRecipient(), 'sender' => $notification->getSender(), 'language' => $language, 'site' => elgg_get_site_entity(), 'params' => $notification->params);
    elgg_push_context('widgets');
    if ($template->subject) {
        $notification->subject = mustache()->render($template->subject, $template_params);
    }
    if ($template->body) {
        $notification->body = mustache()->render($template->body, $template_params);
    }
    if ($template->summary) {
        $notification->summary = mustache()->render($template->summary, $template_params);
    }
    elgg_pop_context();
    return $notification;
}
Esempio n. 2
0
<?php

require_once "./libs/dompdf/dompdf_config.inc.php";
$id = $_GET["id"];
$invoice = query("SELECT DATE_FORMAT(invoices.start_date, '%c/%e/%Y') AS startDate, DATE_FORMAT(invoices.end_date, '%c/%e/%Y') AS endDate, projects.name AS project, projects.bill_to_name AS name, projects.bill_to_address AS address, projects.bill_to_department AS department, projects.bill_to_campus AS campus, CONCAT('\$', FORMAT(invoices.rate, 2)) AS rate, SUM(logs.hours) AS hours, CONCAT('\$', FORMAT(SUM(logs.hours) * invoices.rate, 2)) AS total, invoices.description AS description, MAX(logs.date) AS lastDate\r\n  FROM invoices JOIN projects ON invoices.project_id = projects.id JOIN logs ON invoices.project_id=logs.project_id AND logs.date >= invoices.start_date AND logs.date <= invoices.end_date\r\n  WHERE invoices.id=:id\r\n  ", [":id" => $id]);
$dompdf = new DOMPDF();
$dompdf->load_html(mustache("invoice", $invoice[0]));
$dompdf->render();
$dompdf->stream("invoice.pdf", ["Attachment" => 0]);
Esempio n. 3
0
function render($viewPath, $values = [])
{
    echo mustache($viewPath, $values);
}