public function index() { Util\Auth::isAdminAuthorized($this->signedUser, 'member', true, '/'); $page = Util\Converter::toInt('page', 'get', 1); // get user settings $userSettings = $this->signedUser->getUserSettings(); $maxByPage = isset($userSettings) ? (int) $userSettings->getPagingValue() : 10; $countItems = \Own\Bus\Player\Data::count(); $page = Util\Nav::getCurrentPage($page, $countItems, $maxByPage); $options = []; $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'credits', 'level']); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'firstname', 'lastname', 'status'], 'player_id'); $options['join'][] = 'core_user player_id ON player_id.id = player.id'; $options['order'][] = 'player_id.username'; $options['limit'][] = ($page - 1) * $maxByPage . ', ' . $maxByPage; $items = \Own\Bus\Player\Data::loadAll($options); // main $tplFilter = new Util\Template(Util\Template::SITE, ['admin']); $tplFilter->set('paging', Util\Nav::renderPaging($countItems, '/own/index?page=', $maxByPage, $page)); $tplFilter->set('itemsPerPage', Util\Nav::renderItemsPerPage($maxByPage)); $tplPlayer = new Util\Template(Util\Template::SITE, ['admin']); $tplPlayer->set('items', $items); return $this->response('tpl-default', ['title' => Util\Lang::lang('own'), 'jsLauncher' => 'own'], 'layout-1-col', ['column1' => [$tplFilter->render('players-filter'), $tplPlayer->render('players')]]); }
public static function loadBySecure($secure, $type) { $db = new Util\Data(); $db->buildQuery('select', self::getList()); $db->buildQuery('from', 'core_user_security user_security'); $db->buildQuery('where', ['secure = ?', $secure]); $user = self::map($db); if (isset($user)) { if ($type == Model::CONFIRM) { $user->getUser()->setStatus(1); $user->getUser()->save(); self::deleteSecure($user->getUserId(), $type); } else { if ($type == Model::RESET) { self::deleteSecure($user->getUserId(), $type); } else { if ($type == Model::REMEMBER) { $expire = time() + 60 * 60 * 24 * 7; // 7 days setcookie('signedUser', $secure, $expire, '/', Util\Nav::removePort(\Rebond\Config::getPath('siteUrl'))); } } } return $user->getUser(); } return null; }
public function generate() { \Rebond\Util\Log::log(Error::LANG_GENERATED, 'Generation of language files', __FILE__, __LINE__); \Rebond\Util\Nav::createFolder(\Rebond\Config::getPath('rebond') . 'Cache/'); $this->generatePhp('Rebond', $this->xmlRebondLang); $this->generatePhp('Custom', $this->xmlCustomLang); $this->generateJavascript(array($this->xmlRebondLang, $this->xmlCustomLang)); }
public static function signOut(\Rebond\Core\User\Model $user) { Data::deleteSecure($user->getId()); setcookie('signedUser', '', time() - 3600, '/', Util\Nav::removePort(\Rebond\Config::getPath('siteUrl'))); session_destroy(); session_write_close(); header('Location: /'); exit; }
public static function renderNav($nav, $currentUrl = null, $depth = 1) { $html = ''; foreach ($nav as $loop) { $selected = isset($currentUrl) && \Rebond\Util\Nav::isActive($currentUrl, $loop['friendlyurl']) !== false && $loop['id'] != 1 ? ' class="active"' : ''; if (isset($loop['children']) && count($loop['children']) > 0) { $html .= '<li class="has-dropdown"><a href="' . $loop['url'] . '">' . $loop['title'] . '</a>'; $html .= '<ul class="dropdown sub-nav">'; $html .= self::renderNav($loop['children'], $currentUrl, $depth + 1); $html .= '</ul>'; } else { $html .= '<li' . $selected . '><a href="' . $loop['url'] . '">' . $loop['title'] . '</a></li>'; } } return $html; }
<?php require '../Rebond/Config.php'; $app = \Rebond\Config::start(); $app->launch(); // read request uri list($module, $action) = \Rebond\Util\Nav::readRequest($_SERVER['REQUEST_URI']); $file = '../Rebond/Controller/Site/' . $module . '.php'; // check controller if (!file_exists($file)) { \Rebond\Util\Error::kill(\Rebond\Util\Error::PAGE_NOT_FOUND, $module . '/' . $action, __FILE__, __LINE__); } // call controller $request = '\\Rebond\\Controller\\Site\\' . $module; $controller = new $request($app); // check method if (!method_exists($controller, $action)) { \Rebond\Util\Error::kill(\Rebond\Util\Error::PAGE_NOT_FOUND, $module . '/' . $action, __FILE__, __LINE__); } // call method echo $controller->{$action}();
public static function loadByVersion($version = 'published', $onSite = true, array $options = []) { $db = new Util\Data(); $db->buildQuery('select', self::getList()); $db->buildQuery('from', 'app_standard x'); if (Util\Nav::isPreview()) { $version = 'preview'; } if ($onSite && $version != 'preview') { self::condition($db, 'expiration'); } self::condition($db, $version); Content::autoJoin($db, 'Standard'); $db->extendQuery($options); return self::mapList($db); }
<?php require '../Rebond/Config.php'; $app = \Rebond\Config::start(); $app->launch(); $controller = new \Rebond\Controller\Cms(); $friendlyUrl = \Rebond\Util\Nav::readCmsRequest($_SERVER['REQUEST_URI']); echo $controller->run($app, $friendlyUrl);
public function run() { $entities = $this->xmlModel->getElementsByTagName('entity'); foreach ($entities as $ent) { $sqlEntity = $ent->getAttribute('name'); $entity = Converter::toCamelCase($sqlEntity, true); $main = $ent->getAttribute('main-property'); $enabled = $ent->getAttribute('enabled') == 'true' ? true : false; $hasContent = $ent->getAttribute('has-content') == 'false' ? false : true; $isPersistent = $ent->getAttribute('persistent') == 'false' ? false : true; $this->info[] = '<h2>' . $entity . '</h2>'; if (!$enabled) { $this->info[] = '<div class="orange">' . $entity . ' skipped.</div>'; continue; } if (!$this->validPackage($this->package)) { $this->info[] = '<div class="error">Invalid package: ' . $this->package . '. It must be one of the following: core, cms, bus, app.</div>'; continue; } if (!$this->validEntity($sqlEntity)) { $this->info[] = '<div class="error">Invalid entity: ' . $sqlEntity . '. It must start with a letter and contains alphanumeric characters.</div>'; continue; } $properties = $ent->getElementsByTagName('property'); $views = $ent->getElementsByTagName('view'); if (!$this->validProperties($properties)) { $this->info[] = '<div class="error">Invalid properties. Please check the manual.</div>'; continue; } if (!$this->validViews($views)) { $this->info[] = '<div class="error">Invalid views. Please check the manual.</div>'; continue; } $modelFolder = \Rebond\Config::getPath('rebond') . $this->package . '/' . $entity; if (!is_dir($modelFolder)) { $this->info[] = '<div>' . $entity . ' created.</div>'; } else { $this->info[] = '<div>' . $entity . ' updated.</div>'; } \Rebond\Util\Nav::createFolder($modelFolder . '/template'); \Rebond\Util\Nav::createFolder($modelFolder . '/Base'); // For App with content, Cms, Core, Bus if ($hasContent) { $model = new \Rebond\Generator\Model($this->package, $entity, $main, $isPersistent, $properties); $model->produce(); $this->info = array_merge($this->info, $model->getInfo()); $form = new \Rebond\Generator\Form($this->package, $entity, $properties); $form->produce(); $this->info = array_merge($this->info, $form->getInfo()); $service = new \Rebond\Generator\Service($this->package, $entity); $service->produce(); $this->info = array_merge($this->info, $service->getInfo()); if ($isPersistent) { $mysql = new \Rebond\Generator\Mysql($this->package, $sqlEntity, $properties); $mysql->produce(); $this->info = array_merge($this->info, $mysql->getInfo()); $view = new \Rebond\Generator\View($this->package, $entity, $main, $properties, $views, $this->generate); $view->produce(); $this->info = array_merge($this->info, $view->getInfo()); $data = new \Rebond\Generator\Data($this->package, $sqlEntity, $properties); $data->produce(); $this->info = array_merge($this->info, $data->getInfo()); } } if ($this->package == 'App') { $module = Module\Data::loadByTitle($entity); if (!isset($module)) { $module = new Module\Model(); $module->setTitle($entity); $module->setSummary($entity . ' summary'); $module->setStatus(StatusType::DELETED); $module->setHasContent($hasContent); $module->save(); } $gadget = new \Rebond\Generator\Gadget($entity, $views, $hasContent, $module->getId()); $gadget->produce(); $this->info = array_merge($this->info, $gadget->getInfo()); } } return implode('', $this->info); }
public function run($app, $friendlyUrl) { // is site active if ($app->site()->getStatus() == 0) { $friendlyUrl = '/inactive'; } // retrieve page $page = \Rebond\Cms\Page\Data::loadByUrl($friendlyUrl); // this should never occur if (!isset($page)) { Error::kill(Error::PAGE_NOT_FOUND, $friendlyUrl, __FILE__, __LINE__); } // redirection if ($page->getRedirect() != '' && $page->getRedirect() != $friendlyUrl) { $friendlyUrl = Nav::readCmsRequest($page->getRedirect()); echo $this->run($app, $friendlyUrl); return; } // permission Auth::isAuthorized($app->user(), $page->getPermission(), true, $app->site()->getSignInUrl()); $app->setUrl($friendlyUrl); // layout $layout = \Rebond\Cms\Layout\Data::loadById($page->getLayoutId()); $tplLayout = new Template(Template::SITE, ['www']); // page components $options = []; $options['where'][] = 'gadget.status = 1'; $options['order'][] = 'gadget.display_order'; $gadgets = \Rebond\Cms\Gadget\Data::loadAllByPageId($page->getId(), $options); $cacheTime = $app->site()->getCacheTime(); if ($gadgets) { $this->app = $app; $this->gadgets = []; foreach ($gadgets as $gadget) { if ($gadget->getComponent()->getId() == 0) { Log::log(Error::COMPONENT_NOT_FOUND, 'title: ' . $gadget->getTitle() . ', componentId: ' . $gadget->getComponentId(), __FILE__, __LINE__); continue; } $component = $gadget->getComponent(); $appGadget = '\\Rebond\\App\\' . $component->getModule()->getTitle() . '\\Gadget'; $appMethod = $component->getMethod(); if (!method_exists($appGadget, $appMethod)) { Log::log(Error::GADGET_NOT_FOUND, 'gadget: ' . $appGadget . ', method: ' . $appMethod, __FILE__, __LINE__); continue; } if ($component->getStatus() !== StatusType::ACTIVE) { continue; } if ($component->getModule()->getStatus() !== StatusType::ACTIVE) { continue; } $name = $component->getModule()->getTitle() . '_' . $component->getMethod(); // look for cache if ($cacheTime > 0) { $html = Cache::getGadgetCache($name, $cacheTime); if (isset($html)) { $tplLayout->add('column' . $gadget->getCol(), $html); continue; } } $gadgetClass = $this->getGadget($appGadget); // get filter if ($component->getType() == ComponentType::SINGLE_ITEM || $component->getType() == ComponentType::FILTERED_LISTING) { if ($gadget->getFilterId() == 0) { Log::log(Error::EMPTY_FILTER, $name, __FILE__, __LINE__); continue; } else { $render = $gadgetClass->{$appMethod}($gadget->getFilterId()); } } else { if ($component->getType() == ComponentType::CUSTOM_LISTING) { $render = $gadgetClass->{$appMethod}($gadget->getCustomFilter()); } else { $render = $gadgetClass->{$appMethod}(); } } $tplLayout->add('column' . $gadget->getCol(), $render); // save cache if ($cacheTime > 0) { Cache::saveGadgetCache($name, $cacheTime, $render); } } } // check for empty columns $columns = $layout->getColumns(); $noComponent = '<div class="no-component">' . Lang::lang('noComponent') . '</div>'; $emptyValue = $app->logLevel() == 0 ? $noComponent : ''; for ($i = 1; $i <= $columns; $i++) { if ($tplLayout->varIsSet('column' . $i) === false) { $tplLayout->set('column' . $i, $emptyValue); } } // template $template = \Rebond\Cms\Template\Data::loadById($page->getTemplateId()); $tplMaster = new Template(Template::SITE, ['www']); // navHeader $isMenuCached = false; if ($template->getMenu() != \Rebond\Cms\MenuType::NONE) { // Get cache if ($cacheTime > 0) { $navHeader = Cache::getCache('navHeader', $template->getMenu() . '_' . $template->getMenuLevel(), $cacheTime); if (isset($navHeader)) { $isMenuCached = true; } } if (!$isMenuCached) { $navHeader = \Rebond\Cms\Page\Data::buildHeaderNav($template->getMenuLevel(), $template->getMenu()); // Save cache if ($cacheTime > 0) { Cache::saveCache('navHeader', $template->getMenu() . '_' . $template->getMenuLevel(), $cacheTime, $navHeader); } } $tpl = new Template(Template::SITE, ['www']); $tpl->set('title', $app->site()->getTitle()); $tpl->set('nav', \Rebond\Cms\Page\Service::renderNav($navHeader, $page->getFullUrl())); $tplMaster->set('navHeader', $tpl->render('nav-header')); } // breacrumb $isMenuCached = false; if ($template->getInBreadcrumb()) { // Get cache if ($cacheTime > 0) { $breadcrumb = Cache::getCache('breadcrumb', $page->getId(), $cacheTime); if (isset($breadcrumb)) { $isMenuCached = true; } } if (!$isMenuCached) { $breadcrumb = \Rebond\Cms\Page\Service::renderBreadcrumb($page->getId()); // Save cache if ($cacheTime > 0) { Cache::saveCache('breadcrumb', $page->getId(), $cacheTime, $breadcrumb); } } $tplMaster->set('breadcrumb', $breadcrumb); } // navSide $isMenuCached = false; if ($template->getSideNav() != \Rebond\Cms\SideNavType::NONE) { // Get cache if ($cacheTime > 0) { $navSide = Cache::getCache('navSide', $template->getSideNav() . '_' . $template->getSideNavLevel(), $cacheTime); if (isset($navSide)) { $isMenuCached = true; } } if (!$isMenuCached) { switch ($template->getSideNav()) { case \Rebond\Cms\SideNavType::PARENT_1: $currentId = $page->getParentId(); break; case \Rebond\Cms\SideNavType::CHILDREN: $currentId = $page->getId(); break; case \Rebond\Cms\SideNavType::HOME: $currentId = 1; break; case \Rebond\Cms\SideNavType::PARENT_2: $currentId = \Rebond\Cms\Page\Data::loadByParent($page->getParentId(), 1); break; case \Rebond\Cms\SideNavType::PARENT_3: $currentId = \Rebond\Cms\Page\Data::loadByParent($page->getParentId(), 2); break; } $navSide = \Rebond\Cms\Page\Data::buildSideNav($currentId, $template->getSideNavLevel()); // Save cache if ($cacheTime > 0) { Cache::saveCache('navSide', $template->getSideNav() . '_' . $template->getSideNavLevel(), $cacheTime, $navSide); } } $tpl = new Template(Template::SITE, ['www']); $tpl->set('nav', \Rebond\Cms\Page\Service::renderNav($navSide, $page->getFullUrl())); $tplMaster->set('navSide', $tpl->render('nav-side')); } // navFooter $isMenuCached = false; if ($template->getInFooter() != 0) { // Get cache if ($cacheTime > 0) { $navFooter = Cache::getCache('navFooter', $template->getFooterLevel(), $cacheTime); if (isset($navFooter)) { $isMenuCached = true; } } if (!$isMenuCached) { $navFooter = \Rebond\Cms\Page\Data::buildFooterNav($template->getFooterLevel()); // Save cache if ($cacheTime > 0) { Cache::saveCache('navFooter', $template->getFooterLevel(), $cacheTime, $navFooter); } } $tpl = new Template(Template::SITE, ['www']); $tpl->set('nav', \Rebond\Cms\Page\Service::renderNav($navFooter, $page->getFullUrl())); $tplMaster->set('navFooter', $tpl->render('nav-footer')); } $tplMaster->set('layout', $tplLayout->render($layout->getFilename())); // master // head if ($app->site()->getKeywords() != '') { $tplMaster->addMeta('keywords', $app->site()->getKeywords()); } if ($app->site()->getDescription() != '') { $tplMaster->addMeta('description', $app->site()->getDescription()); } $tplMaster->set('title', $page->getTitle()); $tplMaster->set('site', $app->site()->getTitle()); $tplMaster->set('skin', $app->skin()); $tplMaster->set('siteUrl', \Rebond\Config::getPath('siteUrl')); // bodyClass $tplMaster->set('bodyClass', $page->getClass()); // footer $ga = \Rebond\Core\Site\Service::renderGoogleAnalytics($app->site()->getGoogleAnalytics()); $tplMaster->set('footer', $ga); $tplMaster->addJs('//code.jquery.com/jquery-2.1.4.min.js'); $tplMaster->addJs('/js/lang-' . $app->lang() . '.js'); if ($app->site()->getJs() != '') { $jsList = explode(',', $app->site()->getJs()); foreach ($jsList as $js) { $tplMaster->addJs($js); } } if ($page->getJs() != '') { $jsList = explode(',', $page->getJs()); foreach ($jsList as $js) { $tplMaster->addJs($js); } } if ($app->env() == \Rebond\Config::ENV_PROD) { $tplMaster->addCss('/css/skin/' . $app->skin() . '/min.css'); $tplMaster->addJs('/js/min.js'); } else { $tplMaster->addCss('/css/normalize.css'); $tplMaster->addCss('/css/skin/' . $app->skin() . '/rebond.css'); $tplMaster->addCss('/css/skin/' . $app->skin() . '/custom.css'); $tplMaster->addJs('/js/rebond.js'); $tplMaster->addJs('/js/custom.js'); } if ($app->site()->getCss() != '') { $cssList = explode(',', $app->site()->getCss()); foreach ($cssList as $css) { $tplMaster->addCss($css); } } if ($page->getCss() != '') { $cssList = explode(',', $page->getCss()); foreach ($cssList as $css) { $tplMaster->addCss($css); } } return $tplMaster->render($template->getFilename()); }