/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (auth()->check()) { return cms()->redirect('/'); } return $next($request); }
protected function listenRoutes() { $this->app->booted(function ($app) { $router = $app['router']; $router->group(['prefix' => cms()->prefix(), 'middleware' => config('cms.middleware')], function () use($router) { event('backend.routes', $router); }); }); }
/** * Bootstrap the application services. * * @return void */ public function boot() { View::addNamespace("theme", cms('theme')); require __DIR__ . '/../menu.php'; $this->publishesConfig(); $this->publishesRoutes(); $this->publishesThemeFolder(); $this->publishesAssets(); }
public function store(Request $request) { $data = $request->all(); $data['user_id'] = $request->user()->id; if ($request->has('save_as_draft')) { $data['published_at'] = null; } else { $data['published_at'] = Carbon::now(); } $post = $this->repository->create($data); return cms()->redirect('posts'); }
/** * Получить материал * @see CMS::material * @param string $selector Значение для поиска материала * @param CMSMaterial $cmsmat Переменная в коротую будет возвращен найденный материал * @param string $field Имя поля по которому выполняется поиск * @return boolean Найден ли материал или нет */ function ifcmsmat($selector, &$cmsmat = NULL, $field = 'Url') { // Get CMS reference and make it static static $_c; $_c = isset($_c) ? $_c : cms(); // Get material $cmsmat = $_c->material($selector, $field); // If we did not get cmsmaterial if ($cmsmat === null) { return false; } // Everything is ok return true; }
/** * Override to report to CMS log * * {@inheritdoc} */ public function report(Exception $e) { if ($this->shouldReport($e)) { cms()->log($e); } }
<?php $namespace = 'Pingpong\\Cms\\Core\\Http\\Controllers'; Route::group(['namespace' => $namespace . '\\Auth'], function () { Route::controller('auth', 'AuthController', ['getLogin' => 'login.index', 'postLogin' => 'login.store', 'getRegister' => 'register.index', 'postRegister' => 'register.store', 'getLogout' => 'logout', 'getConfirmation' => 'user.confirmation']); Route::controller('password', 'PasswordController', ['getEmail' => 'password.email.index', 'postEmail' => 'password.email.store', 'getReset' => 'password.reset.index', 'postReset' => 'password.reset.store']); }); Route::group(['prefix' => cms()->prefix(), 'middleware' => config('cms.middleware'), 'namespace' => $namespace], function () { Route::get('/', ['as' => 'admin.index', 'uses' => 'CoreController@index']); });
/** * Constructor * @param Navigation $nav Parent CMSNav to filter materials * @param string $search Keywords to search in materials * @param string $page Current table page number * @param \samson\core\IViewable $renderer Table renderer */ public function __construct(Navigation &$nav = null, $search = null, $page = null, $renderer = null) { // Save parent cmsnav $this->nav =& $nav; // Set current module or use passed renderer $this->renderer = isset($renderer) ? $renderer : m(); // Save search keywords $this->search = $search; $prefix = $this->setPagerPrefix(); // Create pager $this->pager = new \samson\pager\Pager($page, self::ROWS_COUNT, $prefix); // Collection of filtered material identifiers $filteredIDs = array(); $searchOrStructureFlag = false; // If search filter is set - add search condition to query if (isset($this->search[0]) && $this->search != '0') { // Create additional fields query $searchQuery = dbQuery('materialfield')->join('material'); // Create or condition $searchCondition = new Condition('OR'); // Iterate all possible material fields foreach (cms()->material_fields as $f) { // Create special condition for additional field $cg = new Condition('AND'); $cg->add(new Argument('FieldID', $f->FieldID))->add(new Argument('Value', '%' . $search . '%', dbRelation::LIKE)); // Add new condition to group $searchCondition->add($cg); } // Add all search conditions from material table foreach ($this->search_fields as $item) { $searchCondition->add(new Argument('material_' . $item, '%' . $search . '%', dbRelation::LIKE)); } // Set condition $searchQuery->cond($searchCondition); // Get filtered identifiers $filteredIDs = $searchQuery->fieldsNew('MaterialID'); $searchOrStructureFlag = true; } // Create DB query object $this->query = dbQuery('\\samson\\activerecord\\material')->cond('parent_id', 0)->cond('Draft', 0)->cond('Active', 1)->own_order_by('Modyfied', 'DESC'); // Perform query by structure-material and get material ids $ids = array(); if (isset($nav) && dbQuery('samson\\cms\\CMSNavMaterial')->cond('StructureID', $nav->id)->cond('Active', 1)->fields('MaterialID', $ids)) { // Set corresponding material ids related to specified navigation if (sizeof($filteredIDs)) { $filteredIDs = array_intersect($filteredIDs, $ids); } else { $filteredIDs = $ids; } $searchOrStructureFlag = true; } // If we have filtration identifiers if (sizeof($filteredIDs)) { // Add the, to query $this->query->id($filteredIDs); } elseif ($searchOrStructureFlag) { $this->query->id(0); } $this->queryHandler(); // Call parent constructor parent::__construct($this->query, $this->pager, $this->renderer); }
<?php /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | This file is where you may define all of the routes that are handled | by your application. Just tell Laravel the URIs it should respond | to using a Closure or controller method. Build something great! | */ Route::get('/', cms('routes.root')); Route::get('post', function () { return view('theme::post'); }); Route::get('about', function () { return view('theme::about'); }); Route::get('contact', function () { return view('theme::contact'); }); Route::get('/home', 'HomeController@index');
<?php Menu::create('sidebar', function ($menu) { $menu->setPresenter('Pingpong\\Cms\\Core\\Presenters\\Menus\\SidebarPresenter'); $menu->setPrefixUrl(cms()->prefix()); $menu->enableOrdering(); $menu->header('MAIN NAVIGATION'); $menu->url('/', 'Dashboard', 1, ['icon' => 'fa fa-dashboard']); });
/** * Get array of CMSNavigation object for this material * @return array Collection of CMSNav objects */ public function cmsnavs() { // Perfrom DB request to get all connected cmsnavs $cmsnavs = array(); if (dbQuery('samson\\cms\\CMSNavMaterial')->MaterialID($this->id)->exec($db_nms)) { // Gather CMSNavs object to array foreach ($db_nms as $db_nm) { $cmsnavs[] = cms()->navigation($db_nm->StructureID, 'id'); } } return $cmsnavs; }
/** * @param ModuleInterface $module * @return array */ public function transform(ModuleInterface $module) { return ['key' => $module->getKey(), 'name' => $module->getName(), 'version' => $module->getVersion(), 'class' => $module->getAssociatedClass(), 'links' => [['rel' => 'self', 'uri' => cms()->apiRoute('modules.show', [$module->getKey()])]]]; }