public function render(array $appData, $templateName, \Core\Application $app, \Core\Registry $registry) { $site_root = $registry->get(REG_SITE_ROOT); $nav_items = array(array('caption' => 'Book It!', 'link' => $site_root . BOOK_URL)); if ($app->isAdmin()) { $nav_items[] = array('caption' => 'Employee List', 'link' => $site_root . EMPLOYEE_LIST_URL); } return (new \Utility\Template())->parse($templateName, array('nav_items' => $nav_items)); }
public function render(array $appData, $templateName, \Core\Application $app, \Core\Registry $registry) { $cur_per = $app->getCurrentPeriod(); $period_now = $cur_per->format('F Y'); $first_day = (new \DateTime())->setDate($cur_per->format('Y'), $cur_per->format('n'), 1); $next_per = (new \DateTime())->setTimeStamp($first_day->getTimestamp()); $next_per->add(new \DateInterval('P1M')); $prev_per = (new \DateTime())->setTimeStamp($first_day->getTimestamp()); $prev_per->sub(new \DateInterval('P1M')); return (new \Utility\Template())->parse($templateName, array('period_navigator_now' => $period_now, 'period_left_link' => $registry->get(REG_SITE_ROOT) . BROWSE_URL . "?year=" . $prev_per->format('Y') . "&month=" . $prev_per->format('n'), 'period_right_link' => $registry->get(REG_SITE_ROOT) . BROWSE_URL . "?year=" . $next_per->format('Y') . "&month=" . $next_per->format('n'))); }
public function render(array $appData, $templateName, \Core\Application $app, \Core\Database $db, \DBMappers\RoomItem $roomMapper, \Core\Registry $registry) { $rooms = $roomMapper->getAll($db); $nav_items = array(); foreach ($rooms as $room) { $nav_items[] = array('caption' => $room->getRoomName(), 'link' => $registry->get(REG_SITE_ROOT) . BROWSE_URL . "/room/" . $room->getId(), 'selected' => false); } $nav_items[] = array('caption' => 'Settings', 'link' => $registry->get(REG_SITE_ROOT) . 'employee/edit/' . $app->getEmpId(), 'selected' => false); $nav_items[] = array('caption' => 'Logout', 'link' => $registry->get(REG_SITE_ROOT) . LOGIN_URL, 'selected' => false); return (new \Utility\Template())->parse($templateName, array('nav_items' => $nav_items)); }
public function render(array $appData, $templateName, \Core\Database $db, \Core\Registry $registry, \DBMappers\EmpItem $empMapper) { $emp_list = $empMapper->getAll($db); $item_list = array(); $site_root = $registry->get(REG_SITE_ROOT); foreach ($emp_list as $emp) { $item = array(); $item['emp'] = $emp; $item['remove_link'] = $site_root . EMPLOYEE_URL . '/remove/' . $emp->getId(); $item['edit_link'] = $site_root . EMPLOYEE_URL . '/edit/' . $emp->getId(); $item_list[] = $item; } return (new \Utility\Template())->parse($templateName, array('item_list' => $item_list, 'emp_msg' => isset($appData['emp_msg']) ? $appData['emp_msg'] : '', 'emp_add_link' => $site_root . EMPLOYEE_URL . '/add')); }
public function __construct() { $registry = \Core\Registry::getInstance(); $this->config = $registry->get('config'); $this->db = $registry->get('db'); $this->request = $registry->get('request'); $this->session = $registry->get('session'); if (isset($this->session->data['customer_id'])) { $customer_query = $this->db->query("SELECT * FROM #__customer WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND status = '1'"); if ($customer_query->num_rows) { $this->customer_id = $customer_query->row['customer_id']; $this->firstname = $customer_query->row['firstname']; $this->lastname = $customer_query->row['lastname']; $this->email = $customer_query->row['email']; $this->telephone = $customer_query->row['telephone']; $this->fax = $customer_query->row['fax']; $this->newsletter = $customer_query->row['newsletter']; $this->customer_group_id = $customer_query->row['customer_group_id']; $this->address_id = $customer_query->row['address_id']; $query = $this->db->query("SELECT * FROM #__customer_ip WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "'"); if (!$query->num_rows) { $this->db->query("INSERT INTO #__customer_ip SET customer_id = '" . (int) $this->session->data['customer_id'] . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', date_added = NOW()"); } } else { $this->logout(); } } }
/** * @param $responseType string * @return IResponse */ public function getResponseObject($responseType) { $responseClassName = Registry::get('config')->get('responseNameSpace') . $responseType . "Response"; if (in_array($responseType, Registry::get('config')->get('allowed_responses')->toArray())) { return new $responseClassName(); } else { throw new \Exception("Response type invalid"); } }
protected function _init() { Registry::set('app', $this); $this->request = new Request(); $this->response = new Response($this->request); $this->request->parseUri(); $this->front = new FrontController($this->request, $this->response); $this->_initLayout(); }
protected function _setcategories($data) { $return = array(); $categories = json_decode($data['content']); foreach ($categories as $category) { $category = $this->loadParent($category)->toArray(); $category['href'] = \Core\Registry::getInstance()->get('url')->link('blog/category', 'ams_page_id=' . $category['id']); $return[] = $category; } return $return; }
public function render() { $responseFactory = ResponseFactory::getInstance(); $responseObj = $responseFactory->getResponseObject(Registry::get('ENV')->get('responseType')); if ($responseObj instanceof HtmlResponse) { $responseObj->setTemplateName($this->getTemplateName() . ".html"); } if ($this->getTemplateVariables() != null && count($this->getTemplateVariables()) > 0) { $responseObj->setData($this->getTemplateVariables()); } echo $responseObj->getResponse(); }
/** * Configures ENV variable for ajax request and response type */ public static function configureFromRequestHeader() { $env = Registry::get('ENV'); if (self::checkAjax()) { $env->set('ajax', true); $respType = self::getResponseType(); $env->set('responseType', $respType); } else { $env->set('ajax', false); $env->set('responseType', 'html'); } Registry::set('ENV', $env); }
public function send($result) { if (!$result) { $result = array(); } $type = $this->request->type; if ($type == 'json') { return $this->sendJson($result); } if ($type == 'html' || $type == 'ajax') { $layout = Registry::get('app')->layout; $view = new View(); $view->setData($result); $content = $view->render('modules/' . $this->request->module . '/views/' . $this->request->controller . '/' . $this->request->action); if ($layout->isLayout()) { $layout->content = $content; $content = $layout->render(); } echo $content; return $content; } return null; }
/** * Constructor * * @access public * @param \Core\Registry $registry */ public function __construct(\Core\Registry $registry) { $this->acl = $registry->acl; $this->action = $registry->action; $this->board = $registry->board; $this->config = $registry->config; $this->project = $registry->project; $this->task = $registry->task; $this->user = $registry->user; $this->comment = $registry->comment; $this->rememberMe = $registry->rememberMe; $this->lastLogin = $registry->lastLogin; $this->google = $registry->google; $this->event = $registry->shared('event'); }
private function loadTwig() { $loader = new \Twig_Loader_Filesystem(Registry::get('config')->get('USER_FOLDERS')->get('templates')); $this->twig = new \Twig_Environment($loader); }
public function render(array $appData, $templateName, \Core\Registry $registry, \Core\Application $app, \Core\Database $db, \DBMappers\AppointmentItem $appMapper) { $schedule = $this->getAppointmentCalendar($app->getCurrentPeriod(), $appData['browse_room_item'], $db, $appMapper); return (new \Utility\Template())->parse($templateName, array('browse_calendar' => $schedule, 'browse_first_day' => $app->getFirstDay(), 'browse_hour_mode' => $app->getHourMode(), 'browse_period' => $app->getCurrentPeriod(), 'site_root' => $registry->get(REG_SITE_ROOT))); }
function registry($key = false) { if ($key) { return \Core\Registry::getInstance()->get($key); } return \Core\Registry::getInstance(); }
public function output() { if ($this->output) { $output = $this->output; //Lets Replace all Instances of <!--{{MODULE POST}}--> preg_match_all('/<!--{{(.*)}}-->/Uis', $output, $matches, PREG_SET_ORDER); if ($matches) { foreach ($matches as $match) { $res = $this->getChild('common/custom_position', $match[1]); if ($res) { $output = str_replace($match[0], $res, $output); } } } $output = \Core\Shortcode::doShortcode($output); $doc = \Core\Registry::getInstance()->get('document'); $scripts = $doc->getScripts(); if ($scripts) { $html = ''; foreach ($scripts as $script) { $html .= '<script type="text/javascript" src="' . $script . '"></script>'; } $output = str_replace('<!-- Custom JS -->', $html, $output); } $styles = $doc->getStyles(); if ($styles) { $html = ''; foreach ($styles as $style) { $html .= '<link rel="' . $style['rel'] . '" type="text/css" href="' . $style['href'] . '" media="' . $style['media'] . '" />'; } $output = str_replace('<!-- Custom CSS -->', $html, $output); } $metas = $doc->getMeta(); if ($metas) { $html = ''; foreach ($metas as $meta) { $html .= '<meta ' . $meta['meta'] . '="' . $meta['key'] . '" content="' . $meta['value'] . '" />' . "\n"; } $output = str_replace('<!-- Custom META -->', $html, $output); } \Core\Registry::getInstance()->get('event')->trigger('before.render', $output); if ($this->level) { $output = $this->compress($output, $this->level); $this->addHeader('Content-Length: ' . strlen($output)); } if (!headers_sent()) { foreach ($this->headers as $header) { header($header, true); } } echo $output; } }
public function render(array $appData, $templateName, \Core\Registry $registry, \Core\Database $db, \DBMappers\EmpItem $empMapper) { $emps = $empMapper->getAll($db); return (new \Utility\Template())->parse($templateName, array('details_errors' => $appData['details_errors'], 'details_values' => $appData['details_values'], 'is_chain' => $appData['is_chain'], 'details_emps' => $emps, 'can_modify' => $appData['can_modify'], 'site_root' => $registry->get(REG_SITE_ROOT), 'appointment_id' => $appData['details_appointment']->getId())); }
/** * Constructor * * @access public * @param \Core\Registry $registry Registry instance */ public function __construct(Registry $registry) { $this->registry = $registry; $this->db = $this->registry->shared('db'); }
/** * Returns the name of the next Controller to be called, depending on the given $route * @param $route string The route path * @return string */ protected function getNextControllerName($route) { $routeClass = Registry::get('config')->get('USER_FOLDERS')->get('controllers') . DIRECTORY_SEPARATOR . $route . "Controller"; return $routeClass; }