public function buildModule() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'title']); $options['where'][] = 'module.status = 1'; $items = \Rebond\Cms\Module\Data::loadAll($options); return Util\Form::buildDropdownList('moduleId' . $this->unique, $items, 'id', 'title', $this->getModel()->getModuleId()); }
public function module() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module', true, '/cms'); // action $add = Converter::string('add', 'post'); if (isset($add)) { Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module.edit', true, '/cms/module'); $moduleId = Converter::int('moduleId', 'post'); $module = \Rebond\Cms\Module\Data::loadById($moduleId); if (isset($module)) { $module->setStatus(\Rebond\Core\StatusType::ACTIVE); $module->save(); Session::adminSuccess('added', '/cms/module'); } else { Session::set('adminError', Lang::lang('mustSelectModule')); } } $options = []; $options['where'][] = 'module.status IN (0,1)'; $activeModules = \Rebond\Cms\Module\Data::loadAll($options); // view $this->setTpl(); // filter $tplFilter = new Template(Template::MODULE, ['cms', 'module']); $tplFilter->set('count', count($activeModules)); if (Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module.edit', false)) { $options = []; $options['where'][] = 'module.status = 2'; $newModules = \Rebond\Cms\Module\Data::loadAll($options); $tplFilter->set('items', $newModules); } // main $tplMain = new Template(Template::MODULE, ['cms', 'module']); $tplMain->set('items', $activeModules); // layout if (Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module.edit', false)) { $this->tplLayout->set('column1', $tplFilter->render('filter')); $this->tplLayout->set('column2', $tplMain->render('listing')); } else { $this->tplLayout->set('column1', $tplFilter->render('filter-config')); $this->tplLayout->set('column2', $tplMain->render('listing-config')); } // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-row')); return $this->tplMaster->render('tpl-default'); }
public function buildModule() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'has_content', 'title']); $options['where'][] = 'module.status = 1'; $options['order'][] = 'module.title'; $items = \Rebond\Cms\Module\Data::loadAll($options); $form = '<select class="input" name="moduleId" id="moduleId">'; if ($items) { foreach ($items as $item) { $selected = $item->getId() == $this->getModel()->getModuleId() ? ' selected="selected"' : ''; $form .= '<option value="' . $item->getId() . '" data-app=' . $item->getHasContent() . $selected . '>' . $item->getTitle() . '</option>'; } } $form .= '</select>'; return $form; }
public function index() { // auth if (!\Rebond\Util\Auth::isAdminAuthorized($this->signedUser, null, false)) { header('Location: /profile/sign-in'); exit; } // view $this->setTpl(); // main $tplMain = new Template(Template::SITE, ['admin']); $tplMain->set('title', $this->app->site()->getTitle()); // right $tplRight = new Template(Template::SITE, ['admin']); $pendingItems = []; if ($this->app->site()->getIsCms()) { $options = []; $options['where'][] = 'module.status = 1'; $options['where'][] = 'module.has_content = 1'; $modules = \Rebond\Cms\Module\Data::loadAll($options); if ($modules) { foreach ($modules as $module) { $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data'; $items = $appData::loadByVersion('pending'); if (count($items) > 0) { $pendingItems[] = $items; } } } } $tplRight->set('items', $pendingItems); $tplRight->set('title', \Rebond\Util\Lang::lang('pendingItems')); // layout $this->tplLayout->set('column1', $tplMain->render('index')); $this->tplLayout->set('column2', $tplRight->render('pending')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-col')); return $this->tplMaster->render('tpl-default'); }
public function index() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.content', true, '/'); // view $this->setTpl(); // header $options = []; $options['where'][] = 'module.status = 1'; $options['where'][] = 'module.has_content = 1'; $options['order'][] = 'module.title'; $modules = \Rebond\Cms\Module\Data::loadAll($options); $tplHeader = new Template(Template::SITE, ['admin', 'content']); $tplHeader->set('modules', $modules); // main $tplMain = new Template(Template::SITE, ['admin', 'content']); // layout $this->tplLayout->set('column1', $tplHeader->render('selector')); $this->tplLayout->set('column2', $tplMain->render('index')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-row')); $this->tplMaster->set('jsLauncher', 'contentList'); return $this->tplMaster->render('tpl-default'); }
public function buildModule() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'title']); $models = \Rebond\Cms\Module\Data::loadAll($options); return Util\Form::buildDropdownList('moduleId' . $this->unique, $models, 'id', 'title', $this->getModel()->getModuleId(), $this->moduleValidator['foreignKey']); }
public function bin() { // auth Util\Auth::isAdminAuthorized($this->signedUser, 'admin.dev', true, '/'); // check $result = ''; $empty = Util\Converter::bool('empty'); $contentItems = []; // content items $options = []; $options['where'][] = 'module.has_content = 1'; $modules = \Rebond\Cms\Module\Data::loadAll($options); $options = []; $options['where'][] = ['content.version IN (?)', [4, 5]]; $options['order'][] = 'content.modified_date'; foreach ($modules as $module) { $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data'; $items = $appData::loadAll($options); if (count($items) > 0) { if ($empty) { foreach ($items as $item) { $item->delete(); } } else { $contentItems[$module->getTitle()] = $items; } } } // CSS $filePath = \Rebond\Config::getPath('siteFolder') . '/css/skin/'; $skins = Util\File::getFolders($filePath); $cssFiles = []; foreach ($skins as $skin) { $cssFiles[$skin] = []; $path = $filePath . $skin . '/'; $files = Util\File::getFiles($path); foreach ($files as $file) { if (Util\File::getExtension($file) == 'css') { continue; } if ($empty) { Util\File::delete($path, $file); } else { $date = Util\Format::date(filemtime(FULL_PATH . $path . $file), 'smart'); $cssFiles[$skin][] = ['name' => $file, 'date' => $date]; } } } // Main Templates $path = 'views/' . \Rebond\Config::getPath('siteFolder') . '/'; $templates = Util\File::getFiles($path); $mainTpl = []; foreach ($templates as $tpl) { if (Util\File::getExtension($tpl) == 'tpl') { continue; } if ($empty) { Util\File::delete($path, $tpl); } else { $date = Util\Format::date(filemtime(FULL_PATH . $path . $tpl), 'smart'); $mainTpl[] = ['name' => $tpl, 'date' => $date]; } } // App Templates $appFolders = Util\File::getFolders('Rebond/App/'); $appTpl = []; foreach ($appFolders as $app) { $appTpl[$app] = []; $path = 'Rebond/App/' . $app . '/template/'; $templates = Util\File::getFiles($path); foreach ($templates as $tpl) { if (Util\File::getExtension($tpl) == 'tpl') { continue; } if ($empty) { Util\File::delete($path, $tpl); } else { $date = Util\Format::date(filemtime(FULL_PATH . $path . $tpl), 'smart'); $appTpl[$app][] = ['name' => $tpl, 'date' => $date]; } } } if ($empty) { $result = '<p class="bg-success">' . Util\Lang::lang('binEmptied') . '</p>'; } // view $this->setTpl(); // main $tplMain = new Util\Template(Util\Template::SITE, ['admin', 'dev']); $tplMain->set('contentItems', $contentItems); $tplMain->set('cssFiles', $cssFiles); $tplMain->set('mainTpl', $mainTpl); $tplMain->set('appTpl', $appTpl); $tplMain->set('result', $result); // layout $this->tplLayout->set('column1', $tplMain->render('bin')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'dev'); return $this->tplMaster->render('tpl-default'); }
public function search() { if (!$this->hasPrivilege('admin.content.search')) { return $this->noPrivilege('admin.content.search'); } $json = []; $json['result'] = ResultType::ERROR; // check $search = Converter::string('search', 'post'); if (!isset($search)) { $json['message'] = Lang::lang('errorInvalidParameters'); return json_encode($json); } $searchResults = []; // search and build views $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'title']); $options['where'][] = 'module.status = 1'; $options['where'][] = 'module.has_content = 1'; $modules = \Rebond\Cms\Module\Data::loadAll($options); $options2 = []; $options2['clearSelect'] = true; $options2['where'][] = ['LOWER(content.title) LIKE ?', '%' . strtolower($search) . '%']; $options2['where'][] = ['content.version IN (?)', [0, 1, 3]]; $options2['limit'][] = '0, 10'; foreach ($modules as $module) { $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data'; $options2['select'][] = $appData::getList(['app_id']); $options2['select'][] = \Rebond\Cms\Content\Data::getList(['title', 'version']); $items = $appData::loadAll($options2); if (isset($items) && count($items) > 0) { foreach ($items as $item) { $result = new \Rebond\Cms\Search(); $result->setType($module->getTitle()); $result->setAppId($item->getAppId()); $result->setTitle($item->getTitle()); $result->setVersion($item->getVersion()); $result->setVersionValue($item->getVersionValue()); $result->setLink('/content/edit/?module=' . $module->getTitle() . '&id=' . $item->getAppId()); $searchResults[] = $result; } } } // view $tpl = new Template(Template::SITE, ['admin']); $tpl->set('search', $search); $tpl->set('results', $searchResults); $json['result'] = ResultType::SUCCESS; $json['message'] = $tpl->render('search'); return json_encode($json); }