public function loadModule() { if (!isset($module)) { $this->module = \Rebond\Cms\Module\Data::loadByTitle('Slideshow'); $this->moduleId = $this->module->getId(); } }
private function hasFilter() { $module = \Rebond\Cms\Module\Data::loadByTitle('Standard'); if (!isset($module)) { Util\Error::kill(Util\Code::ITEM_NOT_FOUND, 'Standard module not found', __FILE__, __LINE__); } return $module->getHasFilter(); }
protected static function autoJoin(Util\Data $db, $moduleName, $select = true) { $module = \Rebond\Cms\Module\Data::loadByTitle($moduleName); if (!isset($module)) { Util\Error::kill(Util\Error::ITEM_NOT_FOUND, 'module ' . $module . ' not found', __FILE__, __LINE__); } if ($select) { $db->buildQuery('select', \Rebond\Cms\Content\Data::getList()); $db->buildQuery('select', \Rebond\Cms\Module\Data::getList([], 'content_module')); if ($module->getHasFilter()) { $db->buildQuery('select', \Rebond\Cms\Filter\Data::getList([], 'content_filter')); } } $db->buildQuery('join', 'cms_content content ON x.app_id = content.app_id'); $db->buildQuery('join', 'cms_module content_module ON content_module.id = content.module_id'); if ($module->getHasFilter()) { $db->buildQuery('leftJoin', 'cms_filter content_filter ON content_filter.id = content.filter_id'); } $db->buildQuery('where', ['content.module_id = ?', $module->getId()]); }
private function findModule($moduleName) { if ($moduleName == '') { header('Location: /content/'); exit; } $module = \Rebond\Cms\Module\Data::loadByTitle($moduleName); if (!isset($module)) { Session::adminError('itemNotFound', [$moduleName], '/content/'); } return $module; }
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 listContent() { if (!$this->hasPrivilege('admin.content')) { return $this->noPrivilege('admin.content'); } $json = []; $json['result'] = ResultType::ERROR; // check $hashParam = Converter::string('hash', 'post'); $hash = explode('/', $hashParam); $moduleName = isset($hash[0]) && $hash[0] != '' ? $hash[0] : ''; $version = isset($hash[1]) && $hash[1] != '' ? $hash[1] : 'published'; $page = isset($hash[2]) && $hash[2] != '' ? (int) $hash[2] : 1; $order = isset($hash[3]) && $hash[3] != '' ? $hash[3] : 'published_date'; $orderType = isset($hash[4]) && $hash[4] != '' ? $hash[4] : 'desc'; if ($moduleName == '') { $tplMain = new Template(Template::SITE, ['admin', 'content']); $json['result'] = ResultType::NO_CHANGE; $json['html'] = $tplMain->render('index'); return json_encode($json); } $module = \Rebond\Cms\Module\Data::loadByTitle($moduleName); if (!isset($module)) { $tplMain = new Template(Template::SITE, ['admin', 'content']); $json['result'] = ResultType::NO_CHANGE; $json['html'] = $tplMain->render('index'); return json_encode($json); } if (!in_array($order, ['title', 'published_date', 'created_date'])) { $order = 'created_date'; } if (!in_array($orderType, ['asc', 'desc'])) { $orderType = 'desc'; } // check $appData = '\\Rebond\\App\\' . $moduleName . '\\Data'; // get user settings $userSettings = \Rebond\Cms\UserSettings\Data::loadByUserId($this->signedUser->getId()); $contentListCount = 10; if (isset($userSettings)) { $contentListCount = (int) $userSettings->getContentPagingValue(); } $countItems = $appData::countByVersion($version); if ($page < 1) { $page = 1; } if ($page > ceil($countItems / $contentListCount)) { $page = (int) ceil($countItems / $contentListCount); } if ($page == 0) { $page = 1; } $options = []; $options['limit'][] = ($page - 1) * $contentListCount . ', ' . $contentListCount; $options['order'][] = 'content.' . $order . ' ' . $orderType; $genericModels = $appData::loadByVersion($version, false, $options); // view // filter $tplFilter = new Template(Template::SITE, ['admin', 'content']); $tplFilter->set('current', $page); $tplFilter->set('maxByPage', $contentListCount); $tplFilter->set('count', $countItems); $tplFilter->set('module', $moduleName); $tplFilter->set('order', $order . '_' . $orderType); $tplFilter->set('url', '#!/' . $moduleName . '/' . $version . '/'); $tplFilter->set('sort', '/' . $order . '/' . $orderType); // content $tpl = new Template(Template::MODULE, ['app', $moduleName]); $tpl->set('items', $genericModels); $tpl->set('version', $version); $tpl->set('filter', $module->getHasFilter()); $json['result'] = ResultType::SUCCESS; $json['tabon'] = $version; $json['module'] = $moduleName; $json['message'] = Lang::lang('listUpdated') . ' (' . count($genericModels) . ')'; $json['html'] = $tplFilter->render('filter') . $tpl->render('admin-listing'); return json_encode($json); }