protected function footer() { $tpl = Response::getObject()->appendTemplate("/Cms/admin/footer"); $tpl->assign('menu', $this->menu, false); $tpl->output(); parent::footer(); }
private function contact() { $isSent = Request::get(0, VAR_URI) == 'send'; $options = array('name' => array(Validator::MESSAGE => 'Der Name muss mindestens 5 und darf maximal 150 Zeichen lang sein.', Validator::MIN_LENGTH => 5, Validator::MAX_LENGTH => 150), 'email' => array(Validator::MESSAGE => 'Die E-Mail-Adresse ist nicht korrekt.', Validator::CALLBACK => Validator::CB_MAIL), 'message' => array(Validator::MESSAGE => 'Die Nachricht entspricht nicht den Vorgaben (mindestens 10 Zeichen, maximal 1000 Zeichen).', Validator::MIN_LENGTH => 10, Validator::MAX_LENGTH => 1000), 'title' => array(Validator::MESSAGE => 'Der Titel entspricht nicht den Vorgaben (mindestens 5 Zeichen, maximal 100 Zeichen).', Validator::MIN_LENGTH => 5, Validator::MAX_LENGTH => 100)); $this->enableClientFormValidation($options); // Don't validate the captcha via ajax as the session would end if (Config::get('captcha.enable')) { Core::loadClass('Core.Security.ReCaptcha'); $options['recaptcha_response_field'] = array(Validator::MESSAGE => 'Der Sicherheitscode wurde nicht korrekt eingegeben.', Validator::CALLBACK => 'cb_captcha_check'); } $data = array_fill_keys(array_keys($options), ''); $data['name'] = iif(Me::get()->loggedIn(), Me::get()->getName()); $data['email'] = iif(Me::get()->loggedIn(), Me::get()->getEmail()); $this->breadcrumb->add('Kontakt'); $this->header(); if ($isSent) { extract(Validator::checkRequest($options)); if (count($error) > 0) { CmsPage::error($error); } else { CmsTools::sendMail(Config::get('general.email'), $data['title'], $data['message'], $data['email'], $data['name']); CmsPage::ok('Die Anfrage wurde erfolgreich verschickt. Vielen Dank!'); $data['title'] = ''; $data['message'] = ''; } } $tpl = Response::getObject()->appendTemplate('Cms/contact/contact'); $tpl->assign('data', $data); if (Config::get('captcha.enable')) { $tpl->assign('captcha', recaptcha_get_html(Config::get('captcha.public_key')), false); } $tpl->output(); $this->footer(); }
protected function setCookie($email = '', $pw = '') { if (empty($email) || empty($pw)) { Response::getObject()->sendCookie('udata', "", 0, true); } else { // Cookie-Laufzeit: 365 Tage Response::getObject()->sendCookie('udata', "{$email}|{$pw}", 60 * 60 * 24 * 365, true); } }
public static function ok($message, $url = null) { if (!is_array($message)) { $message = array($message); } $tpl = Response::getObject()->appendTemplate('/Cms/ok'); $tpl->assign('url', $url); $tpl->assign('message', $message); $tpl->output(); }
protected function show() { $db = Database::getObject(); $tpl = Response::getObject()->appendTemplate("Airlines/admin/airports"); $country = Request::get('country', VAR_NONE, 'Schweiz'); $tpl->assign('country', $country); $db->query("SELECT * FROM <p>airports " . iif(!empty($country), "WHERE land = <country>") . " ORDER BY land, stadt, flughafen", compact("country")); $tpl->assign('data', $db->fetchAll()); $db->query("SELECT DISTINCT land FROM <p>airports ORDER BY land"); $tpl->assign('countries', $db->fetchAll(null, null, 'land')); $tpl->output(); }
public function serverinfo() { ob_start(); phpinfo(); preg_match("~<body.*?>(.+?)</body>~is", ob_get_contents(), $match_body); ob_end_clean(); $this->breadcrumb->Add("Serverinfo"); $this->header(); $tpl = Response::getObject()->getTemplate("/Cms/admin/serverinfo"); $tpl->assign('content', $match_body[0], false); $tpl->output(); $this->footer(); }
public function suggest() { $data = array(); $id = Request::get(1, VAR_INT); $q = Request::get('q'); $q = SystemEnvironment::fromUtf8($q); $db = Database::getObject(); $db->query("SELECT * FROM <p>fields WHERE id = <id:int>", compact("id")); if ($db->numRows() == 1) { $field = CustomField::constructObject($db->fetchAssoc()); if ($field instanceof CustomAutoCompleteTextField) { $data = $field->getList($q); } } Response::getObject()->sendHeader('Content-Type: text/plain; charset=' . Config::get('intl.charset')); echo implode("\n", $data); }
protected function airline($id) { $this->breadcrumb->resetUrl(); $this->header(); // Airline details $this->airlinePage->detail($id, '/Airlines/airline'); // Airline average ratings $avgFields = CustomRating::getAverageFields($this->flightPage->getPosition(), array('airline' => $id, 'published' => 1)); $tpl = Response::getObject()->appendTemplate('/Airlines/airline_avg'); $tpl->assign('data', $avgFields, false); $tpl->output(); // Evaluated flights $filter = new CustomDataFilter($this->flightPage->getPosition()); $filter->field('title'); $filter->fieldCalculation('rating', '(vdr_rating+bord_rating+service_rating)/3'); $filter->condition('airline', $id); $filter->condition('published', 1); $filter->orderBy('date'); $this->flightPage->overview('/Airlines/flights', Config::get('pagination.evaluations'), $filter); $this->footer(); }
protected function output(CustomFieldData $field, $label) { if ($field == null) { return ''; } else { $tpl = Response::getObject()->getTemplate($this->getOutputTemplate()); $tpl->assign('field', $field, false); $tpl->assign('output', $field->getOutputCode(), false); $tpl->assign('label', $label, false); return $tpl->parse(); } }
public function overview($tpl = null, $pagination = 0, CustomDataFilter $filter = null) { if ($filter === null) { $filter = new CustomDataFilter($this->position); foreach ($this->mainFields as $field) { $filter->field($field); } $filter->orderBy(reset($this->mainFields)); } $pages = ''; if ($pagination > 0) { $pg = new Pagination($pagination, $filter->getAmount()); $pg->setUri($this->baseUri); $pg->parsePage(); $filter->limit($pg->getPerPage(), $pg->getOffset()); $pages = $pg->build(); } $tpl = Response::getObject()->appendTemplate($tpl ? $tpl : "/Cms/fields/data_categories"); $tpl->assign('pages', $pages, false); $tpl->assign('list', $filter->retrieveList(), false); $tpl->assign('baseUri', $this->baseUri); $tpl->output(); }
protected function overview() { foreach ($this->getPositions() as $p) { $cache = Core::getObject('Core.Cache.CacheServer')->load('fields'); $tpl = Response::getObject()->appendTemplate("/Cms/admin/fields"); $tpl->assign("data", $cache->getFields($p), false); $tpl->assign('baseUri', $this->getBaseURI()); $tpl->output(); } }
public static function getStarOutputCode($data, $min = 0, $max = 5, $step = 0.5) { $nearest = self::findNearestStep($data, $min, $max, $step); $fullStars = intval($nearest); $halfStar = $nearest != $fullStars; $tpl = Response::getObject()->getTemplate('/Cms/bits/rating/output'); $tpl->assignMultiple(compact("fullStars", "halfStar", "data", "min", "max")); return $tpl->parse(); }
private function setSID($sid) { $this->sid = $sid; Response::getObject()->sendCookie('sid', $sid, 60 * Config::get('security.session_lifetime'), true); }
protected function footer() { $tpl = Response::getObject()->appendTemplate('/Cms/footer'); $tpl->assign('breadcrumb', $this->breadcrumb, false); $tpl->output(); }
protected function getCodeImpl($file, $additionalVars = array()) { $tpl = Response::getObject()->getTemplate($file); $tpl->assign('fieldId', $this->getId()); $tpl->assign('field', $this->getFieldName()); $tpl->assign('title', $this->getName()); $tpl->assign('description', $this->getDescription()); $tpl->assign('params', $this->getParamsData()); $tpl->assignMultiple($additionalVars); return $tpl->parse(); }
protected function members() { $db = Database::getObject(); $db->query("SELECT COUNT(*) FROM <p>user"); $pp = Config::get('pagination.admin'); $pg = new Pagination($pp, $db->fetchOne()); $pg->parsePage(); $pg->setUri(Uri::build('/Cms/admin/members')); $offset = $pg->getOffset(); $db->query("SELECT * FROM <p>user ORDER BY surname, forename LIMIT <offset:int>, <pp:int>", compact("offset", "pp")); $data = array(); while ($row = $db->fetchAssoc()) { $row['group'] = UserUtils::getGroupName($row['group_id']); $data[] = $row; } $tpl = Response::getObject()->appendTemplate("Cms/admin/members"); $tpl->assign("pages", $pg->build(), false); $tpl->assign("data", $data); $tpl->output(); }
public function pwremind() { $action = Request::get(1, VAR_URI); $this->breadcrumb->add('Neues Passwort anfordern'); $this->header(); $tpl = Response::getObject()->appendTemplate('Cms/user/pwremind'); if (Me::get()->loggedIn()) { CmsPage::error('Sie sind bereits angemeldet!'); } else { if ($action == 'send') { $mail = Request::get("email"); $user = UserUtils::getByEmail($mail); if ($user !== null) { if (!$user->isActive()) { CmsPage::error("Ihr Benutzerkonto ist leider noch nicht freigeschaltet."); } else { $data = array('hash' => Hash::getRandom(), 'id' => $user->getId(), 'name' => UserUtils::getSalutation($user->getGender(), $user->getForeName(), $user->getSurName())); $db = Database::getObject(); $db->query("UPDATE <p>user SET verification = <hash> WHERE id = <id:int> AND active = 1", $data); $tpl = Response::getObject()->getTemplate('Cms/mails/pwremind_verify'); $tpl->assign('data', $data, false); CmsTools::sendMail($user->getEmail(), Config::get('general.title') . ': Bestätigung deiner Passwortanfrage', $tpl->parse()); CmsPage::ok("Wir haben Ihnen eine E-Mail geschickt. Bitte folgen Sie den dortigen Anweisungen."); } } else { CmsPage::error("Die von Ihnen angegebene E-Mail-Adresse wurde leider nicht gefunden."); $tpl->output(); } } else { $tpl->output(); } } $this->footer(); }
/** * Gives out html formatted page numbers. * * @return string HTML formatted page numbers and prefix */ public function build($tpl = null) { $p = $this->getPage(); $count = $this->getPages(); $pages = array(); if ($count > 10) { $show = array_unique(array(1, $p - 2, $p - 1, $p, $p + 1, $p + 2, $count)); foreach ($show as $num) { if ($num >= 1 && $num <= $count) { continue; // Page is outside page range } if ($num > 1 && !in_array($num - 1, $show)) { // Add separator when page numbers are missing $pages[$num - 1] = array('type' => self::PAGES_SEPARATOR, 'url' => null); } $pages[$num] = array('type' => iif($num == $p, self::PAGES_CURRENT, self::PAGES_NUM), 'url' => $this->createUri($num)); } } else { for ($i = 1; $i <= $count; $i++) { $pages[$i] = array('type' => iif($i == $p, self::PAGES_CURRENT, self::PAGES_NUM), 'url' => $this->createUri($i)); } } ksort($pages); $tpl = Response::getObject()->getTemplate($tpl ? $tpl : '/Cms/bits/pages'); $tpl->assign('pageCount', $count); $tpl->assign('pages', $pages); return $tpl->parse(); }
protected function docs() { $db = Database::getObject(); $db->query("SELECT id, title, uri FROM <p>page ORDER BY title"); $tpl = Response::getObject()->appendTemplate("Cms/admin/docs"); $tpl->assign("data", $db->fetchAll()); $tpl->output(); }