public static function resetFiles() { $sitePath = \Rebond\Config::getPath('site'); $adminPath = \Rebond\Config::getPath('admin'); // www $cmsPath = $sitePath . 'index_cms.php'; $noCmsPath = $sitePath . 'index_nocms.php'; $installPath = $sitePath . 'index_install.php'; if (file_exists($cmsPath)) { rename($sitePath . 'index.php', $noCmsPath); rename($installPath, $sitePath . 'index.php'); } else { if (file_exists($noCmsPath)) { rename($sitePath . 'index.php', $cmsPath); rename($installPath, $sitePath . 'index.php'); } else { return false; } } // admin $adminMainPath = $adminPath . 'index_admin.php'; $adminInstallPath = $adminPath . 'index_install.php'; if (file_exists($adminInstallPath)) { rename($adminPath . 'index.php', $adminMainPath); rename($adminInstallPath, $adminPath . 'index.php'); } else { return false; } return true; }
protected function setBaseTpl() { if ($this->app->site()->getKeywords() != '') { $this->tplMaster->addMeta('keywords', $this->app->site()->getKeywords()); } if ($this->app->site()->getDescription() != '') { $this->tplMaster->addMeta('description', $this->app->site()->getDescription()); } $this->tplMaster->set('site', $this->app->site()->getTitle()); $this->tplMaster->set('title', $this->app->site()->getTitle()); $ga = \Rebond\Core\Site\Service::renderGoogleAnalytics($this->app->site()->getGoogleAnalytics()); $this->tplMaster->set('footer', $ga); $this->tplMaster->set('siteUrl', \Rebond\Config::getPath('siteUrl')); $this->tplMaster->addJs('//code.jquery.com/jquery-2.1.3.min.js'); $this->tplMaster->addJs('/js/jquery-ui.js'); $this->tplMaster->addJs('/js/lang-' . $this->app->lang() . '.js'); $this->tplMaster->addCss('/css/rebond-ui/jquery-ui.css'); if ($this->app->env() == \Rebond\Config::ENV_PROD) { $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/min.css'); $this->tplMaster->addJs('/js/min.js'); } else { $this->tplMaster->addCss('/css/normalize.css'); $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/rebond.css'); $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/custom.css'); $this->tplMaster->addJs('/js/rebond.js'); $this->tplMaster->addJs('/js/custom.js'); } }
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 static function checkCssAndJs($env, $skin) { if ($env == \Rebond\Config::ENV_LOCAL) { return; } $ran = false; $sitePath = \Rebond\Config::getPath('site'); $rebondCss = $sitePath . 'css/skin/' . $skin . '/rebond.css'; $customCss = $sitePath . 'css/skin/' . $skin . '/custom.css'; $minCss = $sitePath . 'css/skin/' . $skin . '/min.css'; if (!file_exists($minCss) || filemtime($rebondCss) > filemtime($minCss) || filemtime($customCss) > filemtime($minCss)) { $css = []; $css[] = $sitePath . 'css/normalize.css'; $css[] = $rebondCss; $css[] = $customCss; self::compact($css, $minCss); $ran = true; } $rebondJs = $sitePath . 'js/rebond.js'; $customJs = $sitePath . 'js/custom.js'; $minJs = $sitePath . 'js/min.js'; if (!file_exists($minJs) || filemtime($rebondJs) > filemtime($minJs) || filemtime($customJs) > filemtime($minJs)) { $js = []; $js[] = $rebondJs; $js[] = $customJs; self::compact($js, $minJs); $ran = true; } if ($ran) { \Rebond\Util\Log::log(Error::MIN_GENERATED, 'Generation of minified css and js files', __FILE__, __LINE__); } }
public static function export(\Rebond\Core\ModelInterface $module) { $exportPath = \Rebond\Config::path('export'); $tempPath = \Rebond\Config::path('temp'); // TODO add XML model node // generate data script $dataScriptPath = $tempPath . 'data.sql'; $table = 'app_' . strtolower($module->getTitle()); $db = new Util\Data(); $result = $db->select('SELECT * FROM ' . $table); $script = $db->backupData($table, $result); $result = $db->select('SELECT * FROM cms_content WHERE module_id = ?', [$module->getId()]); $script .= $db->backupData('cms_content', $result); File::save($dataScriptPath, 'w', $script); // create zip $zipFile = $module->getTitle() . '.zip'; $zip = new \ZipArchive(); $res = $zip->open($exportPath . $zipFile, \ZIPARCHIVE::OVERWRITE); if (!$res) { return $res; } $modulePath = FULL_PATH . 'Rebond/App/' . $module->getTitle() . '/'; $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($modulePath)); foreach ($iterator as $file) { $filename = str_replace($modulePath, '', str_replace('\\', '/', $file)); if (file_exists($file) && substr($filename, -1) != '.') { $zip->addFile($file, $filename); } } $zip->addFile($dataScriptPath, 'data.sql'); $zip->close(); return $zipFile; }
protected function setBaseTpl($format) { $this->tplLayout = new Util\Template(Util\Template::SITE, ['www']); if ($format == \Rebond\Core\Format::JSON) { return; } $this->tplMaster = new Util\Template(Util\Template::SITE, ['www']); if ($this->app->site()->getKeywords() != '') { $this->tplMaster->addMeta('keywords', $this->app->site()->getKeywords()); } if ($this->app->site()->getDescription() != '') { $this->tplMaster->addMeta('description', $this->app->site()->getDescription()); } $this->tplMaster->set('site', $this->app->site()->getTitle()); $this->tplMaster->set('title', $this->app->site()->getTitle()); $ga = \Rebond\Core\Site\Service::renderGoogleAnalytics($this->app->site()->getGoogleAnalytics()); $this->tplMaster->set('footer', $ga); $this->tplMaster->set('siteUrl', \Rebond\Config::getPath('siteUrl')); $this->tplMaster->addJs('/static/jquery/dist/jquery.min.js'); $this->tplMaster->addJs('/static/jquery-ui/jquery-ui.min.js'); $this->tplMaster->addJs('/js/lang-' . $this->app->lang() . '.js'); $this->tplMaster->addCss('/static/jquery-ui/themes/smoothness/jquery-ui.min.css'); if (!$this->app->isDebug()) { $this->tplMaster->addCss('/css/min-' . $this->app->skin() . '.css'); $this->tplMaster->addJs('/js/min.js', false); } else { $this->tplMaster->addCss('/static/normalize-css/normalize.css'); $this->tplMaster->addCss('/static/rebond/css/rebond.css'); $this->tplMaster->addCss('/static/rebond-www/css/rebond-site.css'); $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/own.css'); $this->tplMaster->addJs('/static/rebond/js/rebond.js', false); $this->tplMaster->addJs('/static/rebond-www/js/rebond-site.js', false); $this->tplMaster->addJs('/js/own.js', false); } }
public static function send($playerId, $notification) { $options = []; $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'user_id', 'username']); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'email'], 'player_user'); $options['join'][] = 'core_user player_user ON player_user.id = player.user_id'; $options['where'][] = 'send_notification_email = 1'; $options['where'][] = ['player.id = ?', $playerId]; $player = \Own\Bus\Player\Data::load($options); if (!isset($player)) { return false; } // send email $app = \Rebond\App::instance(); $tpl = new Util\Template(Util\Template::MODULE, ['bus', 'notification']); $tpl->set('url', 'http://' . \Rebond\Config::getPath('siteUrl')); $tpl->set('player', $player); $tpl->set('notification', $notification); $tplMail = new Util\Template(Util\Template::SITE, ['mail']); $tplMail->set('title', Util\Lang::lang('notification')); $tplMail->set('site', $app->site()->getTitle()); $tplMail->set('url', 'http://' . \Rebond\Config::getPath('siteUrl')); $tplMail->set('layout', $tpl->render('notification')); $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($app->site()->getTitle() . ' - ' . Util\Lang::lang('notification'))->setFrom(\Rebond\Config::getMail('email'))->setTo($player->getUser()->getEmail())->setBody($tplMail->render('tpl-default')); return Util\Mail::send($message); }
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 function buildSkin() { $skins = Util\File::getFolders(\Rebond\Config::getPath('siteFolder') . '/css/skin'); $list = []; foreach ($skins as $skin) { $list[$skin] = $skin; } return Util\Form::buildDropDown('skin' . $this->unique, $list, $this->getModel()->getSkin()); }
public function facebookPage() { $fbPage = \Rebond\Config::getKey('facebook'); if (!isset($fbPage)) { $fbPage = 'vincium'; } $tpl = new Util\Template(Util\Template::MODULE, ['app', 'plugin']); $tpl->set('fbPage', $fbPage); return $tpl->render('facebook-page'); }
private function setBaseTpl() { $this->tplMaster->set('siteUrl', \Rebond\Config::getPath('siteUrl')); if ($this->app->env() == \Rebond\Config::ENV_PROD) { $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/min.css'); } else { $this->tplMaster->addCss('/css/normalize.css'); $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/rebond.css'); $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/custom.css'); } }
public function generate() { $configFile = FULL_PATH . '/files/config.xml'; if (!file_exists($configFile)) { Util\Error::kill(Util\Error::XML_CONFIG_NOT_FOUND, $configFile, __FILE__, __LINE__); } $conf = simplexml_load_string(file_get_contents($configFile)); $configTpl = new Util\Template(Util\Template::SITE, ['generator', 'config']); foreach ($conf->servers->server as $server) { if (strpos($_SERVER['HTTP_HOST'], $server->attributes()->host->__toString()) === false) { continue; } $configTpl->set('httpHost', $server->attributes()->host); $configTpl->set('siteFolder', $server->siteFolder); $configTpl->set('adminFolder', $server->adminFolder); $configTpl->set('dbHost', $server->db->host); $configTpl->set('dbPort', $server->db->port); $configTpl->set('dbUsername', $server->db->username); $configTpl->set('dbPassword', $server->db->password); $configTpl->set('dbName', $server->db->name); $configTpl->set('type', $server->mail->type); $configTpl->set('email', $server->mail->email); if ($server->mail->type == 'smtp') { $configTpl->set('host', $server->mail->host); $configTpl->set('port', $server->mail->port); $configTpl->set('option', $server->mail->option); $configTpl->set('password', $server->mail->password); } else { $configTpl->set('host', ''); $configTpl->set('port', ''); $configTpl->set('option', ''); $configTpl->set('password', ''); } break; } $langs = []; foreach ($conf->languages->language as $language) { $tpl = new Util\Template(Util\Template::SITE, ['generator', 'config']); $tpl->set('lang', $language->attributes()->lang); $tpl->set('locale', $language->locale); $langs[] = $tpl->render('lang'); } $configTpl->set('lang', implode('', $langs)); $settings = []; foreach ($conf->settings->setting as $setting) { $tpl = new Util\Template(Util\Template::SITE, ['generator', 'config']); $tpl->set('key', $setting->attributes()->key); $tpl->set('value', $setting); $settings[] = $tpl->render('setting'); } $configTpl->set('key', implode('', $settings)); $configPath = \Rebond\Config::getPath('rebond') . 'Cache/Config.php'; Util\File::save($configPath, 'w', str_replace('<#php', '<?php', $configTpl->render('config'))); }
private function setBaseTpl() { $this->tplMaster->set('siteUrl', \Rebond\Config::getPath('siteUrl')); if (!$this->app->isDebug()) { $this->tplMaster->addCss('/css/min-' . $this->app->skin() . '.css'); } else { $this->tplMaster->addCss('/static/normalize-css/normalize.css'); $this->tplMaster->addCss('/static/rebond/css/rebond.css'); $this->tplMaster->addCss('/static/rebond-www/css/rebond-site.css'); $this->tplMaster->addCss('/css/skin/' . $this->app->skin() . '/own.css'); } }
public static function send($message) { if (\Rebond\Config::getMail('type') == 'smtp') { $transport = \Swift_SmtpTransport::newInstance(\Rebond\Config::getMail('host'), \Rebond\Config::getMail('port'), \Rebond\Config::getMail('option'))->setUsername(\Rebond\Config::getMail('email'))->setPassword(\Rebond\Config::getMail('password')); } else { if (\Rebond\Config::getMail('type') == 'mail') { $transport = \Swift_MailTransport::newInstance(); } } $mailer = \Swift_Mailer::newInstance($transport); return $mailer->send($message); }
public function edit() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.page', true, '/page'); // check $id = Converter::int('id'); $pid = Converter::int('pid', 'get', 1); $page = \Rebond\Cms\Page\Data::loadById($id); if (!isset($page)) { $page = new \Rebond\Cms\Page\Model(); $title = Lang::lang('newPage'); } else { $title = Lang::lang('edit') . ' ' . $page->getTitle(); } if ($page->getId() != 1 && $page->getParentId() == 1) { $page->setParentId($pid); } $form = new \Rebond\Cms\Page\Form($page); // action $save = Converter::string('save', 'post'); if (isset($save)) { Auth::isAdminAuthorized($this->signedUser, 'admin.page.edit', true, '/page'); if ($form->setFromPost()->validate()->isValid()) { // set new friendly url hidden $page->setFriendlyUrl(strtolower($page->getFriendlyUrl())); $fuh = \Rebond\Cms\Page\Data::fullFriendlyUrl($page->getParentId()); $page->setFriendlyUrlPath($fuh); $page->save(); // update children pages \Rebond\Cms\Page\Data::updateChildrenFriendlyUrl($page->getId(), $page->getFriendlyUrlPath(), $page->getFriendlyUrl()); Session::adminSuccess('saved', '/page'); } else { Session::set('adminError', $form->getValidation()->getMessage()); } } // view $this->setTpl(); // main $tplMain = new Template(Template::MODULE, ['cms', 'page']); $tplMain->set('title', $title); $tplMain->set('siteUrl', 'http://' . \Rebond\Config::getPath('siteUrl')); $tplMain->set('item', $form); // layout if (Auth::isAdminAuthorized($this->signedUser, 'admin.page.edit', false)) { $this->tplLayout->set('column1', $tplMain->render('editor')); } else { $this->tplLayout->set('column1', $tplMain->render('view')); } // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'page'); return $this->tplMaster->render('tpl-default'); }
private function produceService() { // Service template $serviceTpl = new Template(Template::SITE, ['generator', 'service']); $serviceTpl->set('package', $this->package); $serviceTpl->set('entity', $this->entity); $servicePath = \Rebond\Config::getPath('rebond') . $this->package . '/' . $this->entity . '/Service.php'; if (!file_exists($servicePath)) { $render = str_replace('<#php', '<?php', $serviceTpl->render('service')); \Rebond\Util\File::save($servicePath, 'w', $render); $this->info[] = '<div>Service created.</div>'; } else { $this->info[] = '<div class="exist">Service already exists.</div>'; } }
public static function resetPassword($siteTitle, \Rebond\Core\User\Model $user) { $userSecure = \Rebond\Core\UserSecurity\Service::saveSecure($user->getId(), \Rebond\Core\UserSecurity\Model::RESET); $tpl = new Util\Template(Util\Template::SITE, ['mail']); $tpl->set('url', \Rebond\Config::getPath('siteUrl')); $tpl->set('site', $siteTitle); $tpl->set('item', $user); $tpl->set('reset', $userSecure->getSecure()); $tplMail = new Util\Template(Util\Template::SITE, ['mail']); $tplMail->set('title', Util\Lang::lang('resetPassword')); $tplMail->set('site', $siteTitle); $tplMail->set('url', \Rebond\Config::getPath('siteUrl')); $tplMail->set('layout', $tpl->render('reset-password')); $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($siteTitle . ' - ' . Util\Lang::lang('resetPassword'))->setFrom(\Rebond\Config::getMail('email'))->setTo($user->getEmail())->setBody($tplMail->render('tpl-default')); return Util\Mail::send($message); }
public static function locale($value, $params = []) { if ($value == '') { return $value; } $text = null; $log = false; $app = \Rebond\App::instance(); $lang = ucfirst($app->lang()); $xmlFilename = $app->currentSite() == \Rebond\Config::SITE_ADMIN ? 'Rebond' : 'Custom'; $cachedFile = \Rebond\Config::getPath('rebond') . 'Cache/' . $xmlFilename . $lang . '.php'; if (file_exists($cachedFile)) { $className = '\\Rebond\\Cache\\' . $xmlFilename . $lang; $text = $className::get($value); $log = true; } // try to look in admin localization if not found in front if (!isset($text) && $app->currentSite() == \Rebond\Config::SITE_WWW) { $cachedFile = \Rebond\Config::getPath('rebond') . 'Cache/Rebond' . $lang . '.php'; if (file_exists($cachedFile)) { $className = '\\Rebond\\Cache\\Rebond' . $lang; $text = $className::get($value); $log = true; } } // try to look in site localization if not found in admin if (!isset($text) && $app->currentSite() == \Rebond\Config::SITE_ADMIN) { $cachedFile = \Rebond\Config::getPath('rebond') . 'Cache/Custom' . $lang . '.php'; if (file_exists($cachedFile)) { $className = '\\Rebond\\Cache\\Custom' . $lang; $text = $className::get($value); $log = true; } } if (!isset($text)) { if ($log) { Log::log(Error::LANG_NOT_FOUND, 'lang: ' . $lang . ', site: ' . $app->currentSite() . ', value: ' . $value, __FILE__, __LINE__); } return trim($value) . '~'; } $count = count($params); for ($i = 0; $i < $count; $i++) { $text = str_replace('{' . $i . '}', $params[$i], $text); } $text = trim(preg_replace('/{\\d+}/', '', $text)); return $text; }
public static function error($siteTitle, $emails, $code, $message, $file, $line) { $tpl = new Util\Template(Util\Template::MODULE, ['app', 'error']); $tpl->set('url', \Rebond\Config::getPath('siteUrl')); $tpl->set('site', $siteTitle); $tpl->set('code', Util\Code::value($code)); $tpl->set('message', $message); $tpl->set('file', $file); $tpl->set('line', $line); $tplMail = new Util\Template(Util\Template::SITE, ['mail']); $tplMail->set('title', Util\Lang::lang('log')); $tplMail->set('site', $siteTitle); $tplMail->set('url', \Rebond\Config::getPath('siteUrl')); $tplMail->set('layout', $tpl->render('mail')); $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($siteTitle . ' - ' . Util\Lang::lang('log'))->setFrom(\Rebond\Config::getMail('email'))->setTo($emails)->setBody($tplMail->render('tpl-default')); return Util\Mail::send($message); }
public static function log($code, $message, $file, $line) { $app = \Rebond\App::instance(); $d = new \DateTime(); $message = self::textify($message); if ($app->step() != \Rebond\Config::STEP_RUNNING) { $log = \Rebond\Config::getPath('log') . 'log.txt'; $file = str_replace(FULL_PATH, '/', str_replace('\\', '/', $file)); $trace = stripos($file, 'SplClassLoader') !== false ? self::textify(debug_backtrace()) : ''; // date # code # message # trace # file # line $message = $d->format('Y-m-d H:i:s') . '#' . Error::value($code) . '#' . str_replace(FULL_PATH, '/', $message) . '#' . $trace . '#' . $file . '#' . $line . PHP_EOL; \Rebond\Util\File::save($log, 'a', $message); } else { if (!in_array($code, [Error::LANG_NOT_FOUND, Error::PAGE_NOT_FOUND]) && $app->env() == \Rebond\Config::ENV_PROD && $app->site()->getSendMailOnError()) { $emails = $app->site()->getMailListOnError(); if ($emails != '') { $emails = explode(',', $emails); \Rebond\App\Error\Mail::error($app->site()->getTitle(), $emails, $code, $message, $file, $line); } } $log = null; if ($code == Error::LANG_NOT_FOUND) { $options = []; $options['where'][] = ['log.request_uri = ?', $_SERVER['REQUEST_URI']]; $options['where'][] = ['log.message = ?', $message]; $log = \Rebond\Core\Log\Data::load($options); } if (!isset($log)) { $log = new \Rebond\Core\Log\Model(); $log->setCode($code); $log->setMessage($message); $log->setRequestUri($_SERVER['REQUEST_URI']); } $log->setUserId($app->userId()); $log->setFile($file); $log->setLine($line); $log->setTrace(self::textify(debug_backtrace())); $log->setIp($_SERVER['REMOTE_ADDR']); $log->setReferer(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); return $log->save(); } return 0; }
public function detail() { if (!$this->app->isDebug()) { return self::generic(); } $logId = Util\Converter::toInt('id'); if ($logId == 0) { return self::generic(); } $log = \Rebond\Core\Log\Data::loadById($logId); if (!isset($log)) { return self::generic(); } $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; // main $tpl = new Util\Template(Util\Template::MODULE, ['app', 'error']); $tpl->set('log', $log); $tpl->set('referer', $referer); $tpl->set('adminUrl', \Rebond\Config::getPath('adminUrl')); return $tpl->render('detail'); }
private function setBaseTpl($isConfig = false) { if (!$isConfig) { $this->signedUser = $this->app->user(); $this->tplMaster->set('site', $this->app->site()->getTitle()); } $this->tplMain->set('title', Lang::lang('error')); $this->tplMaster->set('title', Lang::lang('error')); $this->tplMaster->set('siteUrl', \Rebond\Config::getPath('siteUrl')); // from site if ($this->isSite) { $this->tplMain->setPath(Template::MODULE, ['app', 'error']); $this->tplMaster->setPath(Template::SITE, ['www']); $this->tplMaster->addCss('/css/normalize.css'); $this->tplMaster->addCss('/css/skin/default/rebond.css'); $this->tplMaster->addCss('/css/skin/default/custom.css'); } else { $this->tplMaster->addCss('/css/normalize.css'); $this->tplMaster->addCss('/css/rebond.css'); $this->tplMaster->addCss('/css/custom.css'); } }
public function cache() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.config.cache', true, '/configuration'); // view $this->setTpl(); // main $files = \Rebond\Util\File::getFiles('files/cache'); $tplMain = new Template(Template::SITE, ['admin', 'configuration']); $tplMain->set('files', $files); $tplMain->set('cache', $this->app->site()->getCacheTime()); $tplMain->set('cachePath', \Rebond\Config::getPath('cache')); // layout $this->tplLayout->set('column1', $tplMain->render('cache')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'configCache'); return $this->tplMaster->render('tpl-default'); }
public function gmap() { $tpl = new Util\Template(Util\Template::MODULE, ['app', 'plugin']); $tpl->set('address', \Rebond\Config::getKey('gmap')); return $tpl->render('gmap'); }
public function sign_in() { // auth if (Auth::isAdminAuthorized($this->signedUser)) { Session::redirect('/'); } // action $form = new \Rebond\Core\User\Form($this->signedUser); $form->signIn(); if (Auth::isAdmin($form->getModel())) { Session::redirect('/'); } if (Auth::isAuth($form->getModel())) { Session::setAndRedirect('siteError', Lang::lang('accessNonAuthorized'), 'http://' . \Rebond\Config::getPath('siteUrl')); } // view $this->setTpl(); // main $tplMain = new Template(Template::MODULE, ['core', 'user']); $tplMain->set('item', $form); // master $this->tplMaster->set('column1', $tplMain->render('sign-in')); $this->tplMaster->set('jsLauncher', 'profile'); return $this->tplMaster->render('tpl-signin'); }
<?php require '../vendor/autoload.php'; $app = \Rebond\Config::start(); $app->launch(\Rebond\Config::SITE_ADMIN); // read request uri list($module, $action) = \Rebond\Util\Nav::readRequest($_SERVER['REQUEST_URI']); $file = \Rebond\Config::getPath('rebond') . 'Controller/Admin/' . $module . '.php'; $fileOwn = \Rebond\Config::getPath('own') . 'Controller/Admin/' . $module . '.php'; // check controller $request = '\\Rebond\\Controller\\Admin\\' . $module; if (file_exists($fileOwn)) { $request = '\\Own\\Controller\\Admin\\' . $module; } else { if (!file_exists($file)) { \Rebond\Util\Error::kill(\Rebond\Util\Code::ADMIN_PAGE_NOT_FOUND, $module . '/' . $action, __FILE__, __LINE__); } } // call controller $controller = new $request($app); // check method if (!method_exists($controller, $action)) { \Rebond\Util\Error::kill(\Rebond\Util\Code::ADMIN_PAGE_NOT_FOUND, $module . '/' . $action, __FILE__, __LINE__); } // call method echo $controller->{$action}();
private function produceData() { $dataTplName = 'data'; // Data class $dataTpl = new Template(Template::SITE, ['generator', 'data']); $dataTpl->set('package', $this->package); $dataTpl->set('entity', $this->entity); $dataPath = \Rebond\Config::getPath('rebond') . $this->package . '/' . $this->entity . '/Data.php'; if (!file_exists($dataPath)) { if ($this->package == 'App') { $dataTplName = 'data-app'; } $render = str_replace('<#php', '<?php', $dataTpl->render($dataTplName)); \Rebond\Util\File::save($dataPath, 'w', $render); $this->info[] = '<div>Data created.</div>'; } else { $this->info[] = '<div class="exist">Data already exists.</div>'; } }
public function produceScript() { $scriptTpl = new Template(Template::SITE, ['generator', 'mysql']); $scriptTpl->set('table', $this->table); $fieldList = []; $multipleKey = []; foreach ($this->xmlProperties as $property) { if ($this->ignoreColumn($property)) { continue; } $type = $property->getAttribute('type'); $propertyName = $property->getAttribute('name'); $sqlType = $this->getDefaultMysqlType($property->getAttribute('mysql'), $type); $maxLength = $this->maxLength; $validations = $property->getElementsByTagName('validation'); foreach ($validations as $validation) { if ($validation->getAttribute('condition') == 'maxLength') { $maxLength = $validation->getAttribute('value'); break; } } if ($type == 'primaryKey') { $propertyName = $this->package == 'App' ? 'app_id' : 'id'; $primaryKey = $propertyName; $scriptTpl->set('primaryKey', $primaryKey); } if ($type == 'multipleKey') { $multipleKey[] = $propertyName . '_id'; } $fieldList[] = $this->fieldList('field', $propertyName, $type, $sqlType, $maxLength); } $scriptTpl->set('multipleKey', implode(', ', $multipleKey)); $scriptTpl->set('fieldList', implode(',', $fieldList)); $scriptPath = \Rebond\Config::getPath('rebond') . $this->package . '/' . $this->entity . '/mysql.sql'; \Rebond\Util\File::save($scriptPath, 'w', $scriptTpl->render('table')); $this->info[] = '<div>SQL scripts created.</div>'; $existQuery = 'SHOW TABLES LIKE \'?\''; $exist = count($this->db->selectOne($existQuery, [$this->table])); if ($exist == 0) { $this->db->runScript('Rebond/' . $this->package . '/' . $this->entity . '/', 'mysql.sql'); $this->info[] = '<div>SQL table created.</div>'; } else { if ($exist > 0 && $this->db->count('SELECT COUNT(*) FROM ' . $this->table) == 0) { $this->db->execute('DROP TABLE ' . $this->table); $this->db->runScript('Rebond/' . $this->package . '/' . $this->entity . '/', 'mysql.sql'); $this->info[] = '<div>SQL table recreated.</div>'; } else { $sqlCols = $this->db->select('SHOW COLUMNS FROM ' . $this->table)->fetchAll(); $updated = self::updateColumns($sqlCols); if ($updated) { $sqlCols = $this->db->select('SHOW COLUMNS FROM ' . $this->table)->fetchAll(); } self::removeColumns($sqlCols); self::addColumns($sqlCols); $this->info[] = '<div>SQL table updated.</div>'; } } }
<?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 function text_editor() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.media.image', true, '/media'); // check $info = null; $generate = Converter::bool('generate'); $imageListPath = \Rebond\Config::getPath('admin') . 'js/tinymce/imageList.js'; // action if ($generate) { $url = \Rebond\Config::getPath('siteUrl') . \Rebond\Config::getPath('mediaFolder'); $list = '['; $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\Media\Data::getList(['id', 'title', 'path', 'upload']); $options['where'][] = 'media.status = 1'; $options['where'][] = 'media.extension IN ("png", "gif", "jpg", "jpeg")'; $options['order'][] = 'media.title'; $medium = \Rebond\Core\Media\Data::loadAll($options); foreach ($medium as $media) { $list .= '{title:"' . $media->getTitle() . '", value:"http://' . $url . $media->getPath() . $media->getUpload() . '"},' . chr(10); } if (count($medium) > 0) { $list = substr($list, 0, -2); } $list .= ']'; File::save($imageListPath, 'w', $list); $info = '<p class="bg-success">' . count($medium) . ' ' . Lang::lang('photosGenerated') . '</p>'; } // view $this->setTpl(); // main $tplMain = new Template(Template::SITE, ['admin', 'media']); $tplMain->set('info', $info); if (file_exists($imageListPath)) { $tplMain->set('date', \Rebond\Util\Format::smartDate(filemtime($imageListPath))); $tplMain->set('link', '/js/tinymce/imageList.js'); } else { $tplMain->set('date', 'n/a'); } // layout $this->tplLayout->set('column1', $tplMain->render('text-editor')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); return $this->tplMaster->render('tpl-default'); }