function addItem_postInsertion() { /* controllare reload */ $mail = new Template(Settings::getSkin() . "/user.mail"); $mail->setContent("name", $_REQUEST['name']); $mail->setContent("username", $_REQUEST['username']); $mail->setContent("password", $_REQUEST['password']); $mail->setContent("message", $_REQUEST['message']); mail("{$_REQUEST['email']}", "{Config::getInstance()->getConfigurations()['website']['name']} Login data", $mail->get(), "From: {{Config::getInstance()->getConfigurations()['website']['email']}}"); }
function addItem_postInsertion() { /* controllare reload */ $mail = new Template("dtml/user.mail"); $mail->setContent("name", $_REQUEST['name']); $mail->setContent("username", $_REQUEST['username']); $mail->setContent("password", $_REQUEST['password']); $mail->setContent("message", $_REQUEST['message']); mail("{$_REQUEST['email']}", "{$GLOBALS['config']['website']['name']} Login data", $mail->get(), "From: {{$GLOBALS['config']['website']['email']}}"); }
function loadTemplate() { import("view.Template"); $template = new Template($this->view); $template->setData($this->data); //$template->setLanguage($this->language); $template->setContent(implode("", file($this->view))); return $template->render(); }
function tabs($name, $data, $pars) { /* $data is 'parent' */ global $newsEntity, $newsCatEntity; $content = new Template("skins/aqua/dtml/tabs.html"); if (isset($data)) { if ($data == 0) { return ""; } else { $parent = $data; } } else { if (isset($pars['parent'])) { $parent = $pars['parent']; } else { return ""; } } if (isset($pars['title'])) { $content->setContent("name", $pars['title']); } else { $content->setContent("name", "Tidbits"); } $oid = mysql_query("\n\t\t\t\tSELECT id, name\n\t\t\t\tFROM newscat \n\t\t\t\tWHERE parent = {$parent}\n\t\t\t\tORDER BY position \n\t\t\t\tLIMIT {$pars['count']}\n\t\t\t"); $index = 0; do { $cat = mysql_fetch_assoc($oid); if ($cat) { $index++; $content->setContent("category", $cat['name']); $content->setContent("index", $index); $content->setContent("catindex", $index); $content->setContent("newscat_id", $cat['id']); $oid2 = mysql_query("\n\t\t\t\t\t\tSELECT news.id, \n\t\t\t\t\t\t news.title, \n\t\t\t\t\t\t news.body, \n\t\t\t\t\t\t\t news.date,\n\t\t\t\t\t\t news.category \n\t\t\t\t\t\tFROM news \n\t\t\t\t\t\tLEFT JOIN newscat \n\t\t\t\t\t\tON newscat.id = news.category \n\t\t\t\t\t\tWHERE newscat.id = {$cat['id']}\n\t\t\t\t\t\tORDER BY news.date DESC\n\t\t\t\t\t\tLIMIT 4\n\t\t\t\t\t"); do { $data = mysql_fetch_assoc($oid2); if ($data) { $content->setContent("title", $data['title']); $content->setContent("id", $data['id']); } } while ($data); } } while ($cat); return $content->get(); }
public static function error($code, $number = null, $string = null, $file = null, $line = null) { $error = new Template(); $error->setContent(file_get_contents(__DIR__ . "/../../error/error.html")); if (Aegis::$debugging) { $error->data["description"] = "<p><b>OS:</b> " . PHP_OS . "</p>"; $error->data["description"] .= "<p><b>PHP Version:</b> " . PHP_VERSION . "</p>"; $error->data["description"] .= "<p><b>Aegis Version:</b> " . Aegis::$version . "</p>"; if ($number != null) { $error->data["description"] = "<p><b>Error Code:</b> {$number}</p>"; $error->data["description"] .= "<p><b>Message:</b> {$string}</p>"; $error->data["description"] .= "<p><b>File:</b> {$file}</p>"; $error->data["description"] .= "<p><b>Line:</b> {$line}</p>"; } } switch ($code) { case 404: header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found", true, 404); $error->data["title"] = "Page Not Found"; $error->data["message"] = "Sorry, the page you are trying to access does not exist."; break; case 500: header($_SERVER["SERVER_PROTOCOL"] . " 500 Internal Server Error", true, 500); $error->data["title"] = "Server Error"; $error->data["message"] = "Sorry, it seems there's been an error. Please try later."; break; } if (Aegis::$debugging) { $error->data["description"] = "<div>" . $error->data["description"] . "</div>"; } else { $error->data["description"] = ""; } $error->compile(); echo $error; die; }
private function modify($input, $mods) { if (!($mods = trim($mods))) { return $input; } $mods = explode(',', $mods); foreach ($mods as $mod) { $parts = explode(":", $mod); $mod = array_shift($parts); $fmt = array_shift($parts); switch ($mod) { // Parse the contents of a template as a template itself. case 'parse': $template = new Template(); $template->setContent($input); $input = $template->fetch(); break; // Transform BB-code-like syntax to HTML. // Transform BB-code-like syntax to HTML. case 'markup': $input = Misc::markup($input); break; case 'date': $input = date($fmt, $input); break; // Insert formatting contents between base part and extension in an image URL. // Insert formatting contents between base part and extension in an image URL. case 'thumb': list($base, $ext) = Storage::splitExtension($input); $input = "{$base}.{$fmt}.{$ext}"; break; // Creates a summary of $fmt paragraphs. // Creates a summary of $fmt paragraphs. case 'summary': $input = Misc::textSummary($input, $fmt, true); break; case 'escape': $input = htmlentities($input, ENT_COMPAT, mb_internal_encoding()); break; case 'i18n': $input = _($input); break; case 'trim': $input = trim($input); break; case 'strip': $input = strip_tags($input); break; case 'lower': $input = strtolower($input); break; case 'count': $input = count($input); break; case 'dump': $input = "<pre>" . print_r($input, true) . "</pre>"; break; default: } } return $input; }
function getComments($id) { $comments = new Template("dtml/comments.html"); $data = aux::getResult("\n\t\t\tSELECT * \n\t\t FROM comments\n\t\t LEFT JOIN users\n\t\t ON users.username = comments.username\n\t\t WHERE entityname = '{$this->entity->name}'\n\t\t AND itemid = '{$id}'\n\t\t AND comments.active = '*'\n\t\t AND users.active = '*'\n\t\t ORDER BY creation DESC"); if (count($data) > 0) { foreach ($data as $item) { foreach ($item as $k => $v) { switch ($k) { case "creation": $comments->setContent($k, aux::formatDate($v, EXTENDED)); break; default: $comments->setContent($k, $v); break; } } } } else { $comments->setContent("username", ""); $comments->setContent("creation", ""); $comments->setContent("body", aux::lingual("Non ci sono commenti", "No comments", "Nemo para commentares")); } return $comments->get(); }
case LOGIN_ERROR: $body = new Skinlet("error"); $body->setContent("message", "Username or password unknown."); unset($_SESSION['user']); $_SESSION['HTTP_LOGIN'] = false; break; case PRIVILEDGE_ERROR: $body = new Skinlet("error"); $body->setContent("message", "Warning: you are not permitted to use this service!"); break; case DATAFILTERING_ERROR: $body = new Skinlet("error"); $body->setContent("message", "Warning: you are not permitted to modify this item!"); break; case "pageNotFound": $body = new Template(Settings::getSkin() . "/error.html"); $body->setContent("message", "Warning: page not found!"); break; case NOTIFICATION: $main = new Skin("orange"); $body = new Skinlet("password_notification"); break; case NOTIFICATION_ERROR: $main = new Skin("handling"); $body = new Skinlet("password_notification_error"); $body->setContent("ip", $_SERVER['REMOTE_ADDR']); break; } session_destroy(); $main->setContent("body", $body->get()); $main->close();
/** * This method is used to output template with data inside indexed with position data, * it returns the compiled html code, it uses getRaw to retrieve data * @param unknown_type $key * @return string */ function getIndexed() { $this->enableRequest(); if (!$this->template) { echo "Warning: you need to specify a template for the indexed mode in {$this->entity_name} content."; exit; } $template = new Template("skins/{Config::getInstance()->getConfigurations()['skin']}/dtml/{$this->template}.html"); $id = uniqid(time()); $order_clause = $this->getOrderClause(); $join_clause = $this->getJoinClause(); $where_clause = $this->getWhereConditions(); $limit_clause = $this->getLimitClause(); $fields = $this->getEntityFields(); $data = $this->getRaw(); $index = 0; if (is_array($data)) { foreach ($data as $item) { $index++; foreach ($item as $k => $v) { $template->setContent("{$k}_{$index}", $v); } } } $config = Config::getInstance()->getConfigurations(); $template->setContent("skin", $config['skin']); if (is_array($this->values)) { foreach ($this->values as $k => $v) { $template->setContent($k, $v); } } $this->disableRequest(); return $template->get(); }
function livereport($name, $entityName, $pars) { $item = new Template("dtml/liveReport.html"); $length = $pars['length']; $index = false; foreach ($_SESSION['user']['services'] as $k => $v) { if ($v['script'] == basename($_SERVER['SCRIPT_FILENAME'])) { $index = $k; break; } } if (!$index) { $item->setContent("title", "Report"); } else { $item->setContent("title", $_SESSION['user']['services'][$index]['serviceName']); } $entity = $GLOBALS['database']->getEntityByName($entityName); $count = $entity->getReference(COUNT); #$data = aux::getResult("SELECT COUNT(*) AS count FROM {$entityName}"); $item->setContent("length", $length); #$item->setContent("total", $data[0]['count']); $item->setContent("total", $count); $item->setContent("entity", $entityName); $item->setContent("script", basename($_SERVER['SCRIPT_FILENAME'])); $item->setContent("query", aux::encrypt($GLOBALS['currentform']->reportQuery)); return $item->get(); }
function livereport($name, $entityName, $pars) { $item = new Template(Settings::getSkin() . "/liveReport.html"); $length = $pars['length']; $index = false; foreach ($_SESSION['user']['services'] as $k => $v) { if ($v['script'] == basename($_SERVER['SCRIPT_FILENAME'])) { $index = $k; break; } } if (!$index) { $item->setContent("title", "Report"); } else { $item->setContent("title", $_SESSION['user']['services'][$index]['serviceName']); } $entity = DB::getInstance()->getEntityByName($entityName); /* echo "var dump di COUNT in report.inc <br>"; var_dump(COUNT); */ $count = $entity->getReference(COUNT); #$data = Parser::getResult("SELECT COUNT(*) AS count FROM {$entityName}"); $item->setContent("length", $length); #$item->setContent("total", $data[0]['count']); $item->setContent("total", $count); $item->setContent("entity", $entityName); $item->setContent("script", basename($_SERVER['SCRIPT_FILENAME'])); $item->setContent("query", Parser::encrypt($GLOBALS['currentform']->reportQuery)); return $item->get(); }
$template->openContent(); $template->setContent('<p>This app rolls a given number of dices</p> <form action="rollDice.php" method="post"> <table> <tr> <td>Number of Dices:</td> <td><input name="numberOfDices" placeholder="Default is 1"/></td> </tr> </table> <table> <tr> <td><label><input type="radio" name="dice" value="d4"/><img src="img/d4.png" alt="d4"/></label></td> <td><label><input type="radio" name="dice" value="d6"/><img src="img/d6.png" alt="d6"/></label></td> <td><label><input type="radio" name="dice" value="d8"/><img src="img/d8.png" alt="d8"/></label></td> </tr> <tr> <td/> <td><label><input type="radio" name="dice" value="d10"/><img src="img/d10.png" alt="d10"/></label></td> <td/> </tr> <tr> <td><label><input type="radio" name="dice" value="d12"/><img src="img/d12.png" alt="d12"/></label></td> <td><label><input type="radio" name="dice" value="d20"/><img src="img/d20.png" alt="d20"/></label></td> <td><label><input type="radio" name="dice" value="d100"/><img src="img/d100.png" alt="d100"/></label></td> </tr> </table> <p><input type="submit" value="roll"/> <input type="reset" value="reset"/></p> </form>'); $template->closeContent();
public function testTemplateSetContent() { $obj = new Template(); $subject = <<<EOD { "template": { "data": [ { "name": "last", "value": "Smith", "prompt": "Last name" }, { "name": "devices", "value": [ { "id": "02FFFF00", "type": 2 } ] } ] } } EOD; $return = $obj->setContent($subject); $this->assertInstanceOf('\\AKlump\\Http\\CollectionJson\\Template', $return); $dataArray = $obj->getDataArray(); $this->assertCount(2, $dataArray); $this->assertInstanceOf('\\AKlump\\Http\\CollectionJson\\Data', $dataArray[0]); $this->assertSame('last', $dataArray[0]->getName()); $this->assertSame('Smith', $dataArray[0]->getValue()); $this->assertSame('Last name', $dataArray[0]->getPrompt()); $this->assertSame('devices', $dataArray[1]->getName()); $control = array((object) array('id' => '02FFFF00', 'type' => 2)); $this->assertEquals($control, $dataArray[1]->getValue()); $this->assertSame('{"template":{"data":[{"name":"last","prompt":"Last name","value":"Smith"},{"name":"devices","value":[{"id":"02FFFF00","type":2}]}]}}', (string) $obj); }
/** erzeugt die Email aus den Formular-daten * und deren Auswertung * * $rechung enthält eine durchs Template bestimmte Form */ function generate_mail($daten, $rechnung) { $adresse = $daten["mail"]; $t = 0; if ($adresse) { $betreff = SUBJECT; $from = FROM; $empfaenger = $adresse; //der text wird mit Hilfe eines Template erstellt $tmp = new Template('./mail.htm'); //name einfügen $tmp->setContent('NAME', $daten["name"] . " "); //Rechnung $tmp->setContent('RECHNUNG', $rechnung . " "); //Timestamp $tmp->setContent('TIMESTAMP', $daten["timestamp"] . " "); //Event name $tmp->setContent('EVENT', EVENT . " "); //den mail text um speichern: $text = $tmp->vorlage; $t = 1; mail($empfaenger, $betreff, $text, "From: " . $from . "\nContent-Type: text/html; charset=utf8") or $t = ''; } if ($t == 1) { return 'Die Bestätigungsmail wurde erfolgreich versendet<br>'; } else { return 'Es ist ein Fehler beim senden der Anmeldungs-Bestätigungs-Mail aufgetrehten<br>'; } }
function getIndexed() { $this->enableParameters(); if (!$this->template) { echo "Warning: you need to specify a template for the indexed mode in {$this->entity_name} content."; exit; } $template = new Template("skins/{$GLOBALS['config']['skin']}/dtml/{$this->template}.html"); $id = uniqid(time()); $order_clause = $this->getOrderClause(); $join_clause = $this->getJoinClause(); $where_clause = $this->getWhereClause(); $limit_clause = $this->getLimitClause(); $fields = $this->getEntityFields(); $data = aux::getResult("SELECT " . $this->getEntityFields() . " \n\t\t\t\t FROM {$this->entity_name}\n\t\t\t\t {$join_clause}\n\t\t\t\t {$where_clause}\n\t\t\t\t {$order_clause}\n\t\t\t\t {$limit_clause}"); $index = 0; if (is_array($data)) { foreach ($data as $item) { $index++; foreach ($item as $k => $v) { $template->setContent("{$k}_{$index}", $v); } } } $template->setContent("skin", $GLOBALS['config']['skin']); if (is_array($this->values)) { foreach ($this->values as $k => $v) { $template->setContent($k, $v); } } $this->disableParameters(); return $template->get(); }