Exemple #1
0
 public function getPage($createIfNotExist = false)
 {
     if (!isset($this->page)) {
         $this->page = \Rebond\Cms\Page\Data::loadById($this->pageId, $createIfNotExist);
     }
     return $this->page;
 }
Exemple #2
0
 public function navigation()
 {
     $tpl = new Util\Template(Util\Template::MODULE, ['app', 'plugin']);
     $page = \Rebond\Cms\Page\Data::loadByUrl($this->app->url());
     $nav = \Rebond\Cms\Page\Data::buildSideNav($page->getId(), 0);
     $tpl->set('nav', \Rebond\Cms\Page\Service::renderNav($nav, $page->getFullUrl()));
     return $tpl->render('navigation');
 }
Exemple #3
0
 public function validateFriendlyurl()
 {
     $v = Util\Validate::validate('friendlyUrl', $this->getModel()->getFriendlyUrl(), $this->friendlyUrlValidator);
     if ($v->getResult() == ResultType::ERROR) {
         return $v;
     }
     $options = [];
     $options['where'][] = ['page.friendly_url = ?', $this->getModel()->getFriendlyUrl()];
     $options['where'][] = ['page.id != ?', $this->getModel()->getId()];
     $options['where'][] = 'page.status IN (0,1)';
     $exist = Data::count($options);
     if ($exist >= 1) {
         $v->setResult(ResultType::ERROR);
         $v->setMessage('a page already exists with this url friendly title');
     }
     return $v;
 }
Exemple #4
0
 public static function readCmsRequest($uri = '')
 {
     if (stripos($uri, '?') !== false) {
         $uri = strstr($uri, '?', true);
     }
     $request = explode('/', $uri, 2);
     $action = count($request) >= 2 && $request[1] != '' ? $request[1] : null;
     if (!isset($action)) {
         $page = \Rebond\Cms\Page\Data::loadById(1);
         if (!isset($page)) {
             Error::kill(Error::PAGE_NOT_FOUND, 'id: 1', __FILE__, __LINE__);
         }
         $action = $page->getFriendlyUrl();
     }
     // return cleaned friendly url
     return '/' . rtrim(strtolower($action), '/');
 }
Exemple #5
0
 public function buildParent()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Cms\Page\Data::getList(['id', 'title']);
     $models = \Rebond\Cms\Page\Data::loadAll($options);
     return Util\Form::buildDropdownList('parentId' . $this->unique, $models, 'id', 'title', $this->getModel()->getParentId(), $this->parentValidator['foreignKey']);
 }
Exemple #6
0
 protected static function mapper(array $row, $alias = 'gadget')
 {
     $model = new \Rebond\Cms\Gadget\Model(false);
     if (isset($row[$alias . 'Id'])) {
         $model->setId($row[$alias . 'Id']);
     }
     if (isset($row[$alias . 'PageId'])) {
         $model->setPageId($row[$alias . 'PageId']);
         $model->setPage(\Rebond\Cms\Page\Data::join($row, $alias . '_page'));
     }
     if (isset($row[$alias . 'ComponentId'])) {
         $model->setComponentId($row[$alias . 'ComponentId']);
         $model->setComponent(\Rebond\Cms\Component\Data::join($row, $alias . '_component'));
     }
     if (isset($row[$alias . 'Col'])) {
         $model->setCol($row[$alias . 'Col']);
     }
     if (isset($row[$alias . 'FilterId'])) {
         $model->setFilterId($row[$alias . 'FilterId']);
         $model->setFilter(\Rebond\Cms\Filter\Data::join($row, $alias . '_filter'));
     }
     if (isset($row[$alias . 'CustomFilter'])) {
         $model->setCustomFilter($row[$alias . 'CustomFilter']);
     }
     if (isset($row[$alias . 'DisplayOrder'])) {
         $model->setDisplayOrder($row[$alias . 'DisplayOrder']);
     }
     if (isset($row[$alias . 'Status'])) {
         $model->setStatus($row[$alias . 'Status']);
     }
     if (isset($row[$alias . 'CreatedDate'])) {
         $model->setCreatedDate($row[$alias . 'CreatedDate']);
     }
     if (isset($row[$alias . 'ModifiedDate'])) {
         $model->setModifiedDate($row[$alias . 'ModifiedDate']);
     }
     return $model;
 }
Exemple #7
0
 protected static function mapper(array $row, $alias = 'page')
 {
     $model = new \Rebond\Cms\Page\Model(false);
     if (isset($row[$alias . 'Id'])) {
         $model->setId($row[$alias . 'Id']);
     }
     if (isset($row[$alias . 'ParentId'])) {
         $model->setParentId($row[$alias . 'ParentId']);
         $model->setParent(\Rebond\Cms\Page\Data::join($row, $alias . '_parent'));
     }
     if (isset($row[$alias . 'TemplateId'])) {
         $model->setTemplateId($row[$alias . 'TemplateId']);
         $model->setTemplate(\Rebond\Cms\Template\Data::join($row, $alias . '_template'));
     }
     if (isset($row[$alias . 'LayoutId'])) {
         $model->setLayoutId($row[$alias . 'LayoutId']);
         $model->setLayout(\Rebond\Cms\Layout\Data::join($row, $alias . '_layout'));
     }
     if (isset($row[$alias . 'Title'])) {
         $model->setTitle($row[$alias . 'Title']);
     }
     if (isset($row[$alias . 'Css'])) {
         $model->setCss($row[$alias . 'Css']);
     }
     if (isset($row[$alias . 'Js'])) {
         $model->setJs($row[$alias . 'Js']);
     }
     if (isset($row[$alias . 'InNavHeader'])) {
         $model->setInNavHeader($row[$alias . 'InNavHeader']);
     }
     if (isset($row[$alias . 'InNavSide'])) {
         $model->setInNavSide($row[$alias . 'InNavSide']);
     }
     if (isset($row[$alias . 'InSitemap'])) {
         $model->setInSitemap($row[$alias . 'InSitemap']);
     }
     if (isset($row[$alias . 'InBreadcrumb'])) {
         $model->setInBreadcrumb($row[$alias . 'InBreadcrumb']);
     }
     if (isset($row[$alias . 'InNavFooter'])) {
         $model->setInNavFooter($row[$alias . 'InNavFooter']);
     }
     if (isset($row[$alias . 'FriendlyUrlPath'])) {
         $model->setFriendlyUrlPath($row[$alias . 'FriendlyUrlPath']);
     }
     if (isset($row[$alias . 'FriendlyUrl'])) {
         $model->setFriendlyUrl($row[$alias . 'FriendlyUrl']);
     }
     if (isset($row[$alias . 'Redirect'])) {
         $model->setRedirect($row[$alias . 'Redirect']);
     }
     if (isset($row[$alias . 'Class'])) {
         $model->setClass($row[$alias . 'Class']);
     }
     if (isset($row[$alias . 'Permission'])) {
         $model->setPermission($row[$alias . 'Permission']);
     }
     if (isset($row[$alias . 'DisplayOrder'])) {
         $model->setDisplayOrder($row[$alias . 'DisplayOrder']);
     }
     if (isset($row[$alias . 'Status'])) {
         $model->setStatus($row[$alias . 'Status']);
     }
     if (isset($row[$alias . 'CreatedDate'])) {
         $model->setCreatedDate($row[$alias . 'CreatedDate']);
     }
     if (isset($row[$alias . 'ModifiedDate'])) {
         $model->setModifiedDate($row[$alias . 'ModifiedDate']);
     }
     return $model;
 }
Exemple #8
0
 public function gadget()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.page.gadget', true, '/page');
     // check
     $id = Converter::int('id');
     $save = Converter::int('save', 'post');
     $page = \Rebond\Cms\Page\Data::loadById($id);
     if (!isset($page)) {
         header('Location: /page');
         exit;
     }
     $gadget = new \Rebond\Cms\Gadget\Model();
     $gadget->setPageId($page->getId());
     $form = new \Rebond\Cms\Gadget\Form($gadget);
     // action
     if (isset($save)) {
         Auth::isAdminAuthorized($this->signedUser, 'admin.page.gadget.edit', true, '/page/gadget?id=' . $id);
         if ($form->setFromPost()->validate()->isValid()) {
             $gadget->save();
             Session::adminSuccess('saved', '/page/gadget?id=' . $id);
         } else {
             Session::set('adminError', $form->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     // form
     $layout = \Rebond\Cms\Layout\Data::loadById($page->getLayoutId());
     $columns = $layout->getColumns();
     $columnOptions = [];
     for ($i = 1; $i <= $columns; $i++) {
         $columnOptions[$i] = Lang::lang('column') . ' ' . $i;
     }
     $tplForm = new Template(Template::MODULE, ['cms', 'gadget']);
     $tplForm->set('item', $form);
     $tplForm->set('title', Lang::lang('manageGadgetOf', [$page->getTitle()]));
     $tplForm->set('columnOptions', $columnOptions);
     $tplForm->set('selectedColumn', $gadget->getCol());
     // active listing
     $options = [];
     $options['join'][] = 'cms_page page ON page.id = gadget.page_id';
     $options['join'][] = 'cms_component component ON component.id = gadget.component_id';
     $options['join'][] = 'cms_module module ON module.id = component.module_id';
     $options['where'][] = ['page.id = ?', $page->getId()];
     $options['where'][] = 'module.status = 1';
     $options['where'][] = 'component.status = 1';
     $options['order'][] = 'gadget.col';
     $options['order'][] = 'gadget.display_order';
     $gadgets = \Rebond\Cms\Gadget\Data::loadAll($options);
     if ($gadgets) {
         foreach ($gadgets as $g) {
             $g->prepareFilter();
         }
     }
     // inactive listing
     $options = [];
     $options['join'][] = 'cms_page page ON page.id = gadget.page_id';
     $options['join'][] = 'cms_component component ON component.id = gadget.component_id';
     $options['join'][] = 'cms_module module ON module.id = component.module_id';
     $options['where'][] = ['page.id = ?', $page->getId()];
     $options['where'][] = 'module.status = 0 OR component.status = 0';
     $options['order'][] = 'gadget.col';
     $options['order'][] = 'gadget.display_order';
     $inactiveGadgets = \Rebond\Cms\Gadget\Data::loadAll($options);
     if ($inactiveGadgets) {
         foreach ($inactiveGadgets as $g) {
             $g->prepareFilter();
         }
     }
     $tplListing = new Template(Template::MODULE, ['cms', 'gadget']);
     $tplListing->set('items', $gadgets);
     $tplListing->set('inactiveItems', $inactiveGadgets);
     $tplListing->set('columnOptions', $columnOptions);
     // layout
     $this->tplLayout->add('column1', $tplForm->render('editor-selector'));
     $this->tplLayout->add('column2', $tplListing->render('listing'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-row'));
     $this->tplMaster->set('jsLauncher', 'pageGadget');
     return $this->tplMaster->render('tpl-default');
 }
Exemple #9
0
 public static function renderList()
 {
     $options = [];
     $options['where'][] = 'page.status IN (0,1)';
     $options['order'][] = 'page.display_order, page.title';
     $pages = Data::loadAll($options);
     $list = [];
     self::buildList($pages, 0, 0, $list);
     return $list;
 }
Exemple #10
0
 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());
 }
Exemple #11
0
 public function updateStatus()
 {
     if (!$this->hasPrivilege(null)) {
         return $this->noPrivilege('admin');
     }
     $json = [];
     $json['result'] = ResultType::ERROR;
     // check
     $package = Converter::string('package', 'post');
     $entity = Converter::string('entity', 'post');
     $id = Converter::int('id', 'post');
     $id2 = Converter::int('id2', 'post');
     $status = Converter::int('status', 'post');
     if (!isset($package) || !isset($entity) || !isset($id) || !isset($status)) {
         $json['message'] = Lang::lang('errorInvalidParameters');
         return json_encode($json);
     }
     $update = 'saved';
     // check item
     $genericData = '\\Rebond\\' . $package . '\\' . $entity . '\\Data';
     $newStatus = StatusType::INACTIVE;
     // active
     if ($status == StatusType::INACTIVE) {
         $newStatus = StatusType::ACTIVE;
         // inactive
     } else {
         if ($status == StatusType::ACTIVE) {
             $newStatus = StatusType::INACTIVE;
             // undelete
         } else {
             if ($status == StatusType::DELETED) {
                 $newStatus = StatusType::INACTIVE;
                 // delete
             } else {
                 if ($status === 3) {
                     $newStatus = StatusType::DELETED;
                 }
             }
         }
     }
     // update status
     // single id table
     if ($id2 == 0) {
         // update
         if ($newStatus == StatusType::INACTIVE || $newStatus == StatusType::ACTIVE) {
             if (!$this->hasPrivilege('admin.status')) {
                 return $this->noPrivilege('admin.status');
             }
             $genericData::updateStatus($id, $newStatus);
         } else {
             if ($newStatus == StatusType::DELETED) {
                 $update = 'deleted';
                 switch ($entity) {
                     case 'Component':
                         if (!$this->hasPrivilege('admin.cms.component.edit')) {
                             return $this->noPrivilege('admin.cms.component.edit');
                         }
                         \Rebond\Cms\Gadget\Data::deleteByComponentId($id);
                         $genericData::updateStatus($id, $newStatus);
                         break;
                     case 'Feedback':
                         if (!$this->hasPrivilege('admin.dev')) {
                             return $this->noPrivilege('admin.dev');
                         }
                         $genericData::deleteById($id);
                         break;
                     case 'Filter':
                         if (!$this->hasPrivilege('admin.cms.filter.edit')) {
                             return $this->noPrivilege('admin.cms.filter.edit');
                         }
                         \Rebond\Cms\Content\Data::clearFilter($id);
                         $genericData::deleteById($id);
                         break;
                     case 'Gadget':
                         if (!$this->hasPrivilege('admin.page.gadget.edit')) {
                             return $this->noPrivilege('admin.page.gadget.edit');
                         }
                         $genericData::deleteById($id);
                         break;
                     case 'Layout':
                         if (!$this->hasPrivilege('admin.cms.layout.edit')) {
                             return $this->noPrivilege('admin.cms.layout.edit');
                         }
                         $options = [];
                         $options['clearSelect'] = true;
                         $options['select'][] = \Rebond\Cms\Page\Data::getList(['id']);
                         $options['join'][] = 'cms_layout layout ON layout.id = page.layout_id';
                         $options['where'][] = ['layout.id = ?', $id];
                         $pages = \Rebond\Cms\Page\Data::loadAll($options);
                         if (isset($pages) && count($pages) > 0) {
                             $json['result'] = ResultType::ERROR;
                             $json['message'] = 'The layout could not be deleted because ' . count($pages) . ' pages still use it';
                             return json_encode($json);
                         }
                         $genericData::deleteById($id);
                         break;
                     case 'Log':
                         if (!$this->hasPrivilege('admin.tools.log.edit')) {
                             return $this->noPrivilege('admin.tools.log.edit');
                         }
                         $genericData::deleteById($id);
                         break;
                     case 'Module':
                         if (!$this->hasPrivilege('admin.cms.module.edit')) {
                             return $this->noPrivilege('admin.cms.module.edit');
                         }
                         $options = [];
                         $options['clearSelect'] = true;
                         $options['select'][] = \Rebond\Cms\Component\Data::getList(['id']);
                         $options['where'][] = ['component.module_id = ?', $id];
                         $components = \Rebond\Cms\Component\Data::loadAll($options);
                         if (count($components) > 0) {
                             foreach ($components as $component) {
                                 \Rebond\Cms\Component\Data::updateStatus($component->getComponentId(), $newStatus);
                                 \Rebond\Cms\Gadget\Data::deleteByComponentId($component->getComponentId());
                             }
                         }
                         $genericData::updateStatus($id, $newStatus);
                         break;
                     case 'ModuleMedia':
                         if (!$this->hasPrivilege('admin.cms.media-link.edit')) {
                             return $this->noPrivilege('admin.cms.media-link.edit');
                         }
                         $genericData::deleteById($id);
                         break;
                     case 'Permission':
                         if (!$this->hasPrivilege('admin.user.permission.edit')) {
                             return $this->noPrivilege('admin.user.permission.edit');
                         }
                         \Rebond\Core\RolePermission\Data::deleteByPermissionId($id);
                         $genericData::deleteById($id);
                         break;
                     case 'Role':
                         if (!$this->hasPrivilege('admin.user.role.edit')) {
                             return $this->noPrivilege('admin.user.role.edit');
                         }
                         $userRoles = \Rebond\Core\UserRole\Data::loadAllByRoleId($id);
                         if (isset($userRoles) && count($userRoles) > 0) {
                             $json['result'] = ResultType::ERROR;
                             $json['message'] = 'The role could not be deleted because ' . count($userRoles) . ' users still use it';
                             return json_encode($json);
                         }
                         \Rebond\Core\UserRole\Data::deleteByRoleId($id);
                         \Rebond\Core\RolePermission\Data::deleteByRoleId($id);
                         $genericData::deleteById($id);
                         break;
                     case 'Template':
                         if (!$this->hasPrivilege('admin.cms.template.edit')) {
                             return $this->noPrivilege('admin.cms.template.edit');
                         }
                         $options = [];
                         $options['clearSelect'] = true;
                         $options['select'][] = \Rebond\Cms\Page\Data::getList(['id']);
                         $options['join'][] = 'cms_template template ON template.id = page.template_id';
                         $options['where'][] = ['template.id = ?', $id];
                         $pages = \Rebond\Cms\Page\Data::loadAll($options);
                         if (isset($pages) && count($pages) > 0) {
                             $json['result'] = ResultType::ERROR;
                             $json['message'] = 'The template could not be deleted because ' . count($pages) . ' pages still use it';
                             return json_encode($json);
                         }
                         $genericData::deleteById($id);
                         break;
                     case 'User':
                         if (!$this->hasPrivilege('admin.user.edit')) {
                             return $this->noPrivilege('admin.user.edit');
                         }
                         $genericData::updateStatus($id, $newStatus);
                         break;
                     default:
                         Log::log(Error::ITEM_NOT_FOUND, 'entity: ' . $entity, __FILE__, __LINE__);
                         if (!$this->hasPrivilege('admin.status')) {
                             return $this->noPrivilege('admin.status');
                         }
                         $genericData::deleteById($id);
                         break;
                 }
             }
         }
         // double id table
     } else {
         if ($newStatus == StatusType::DELETED) {
             if (!$this->hasPrivilege('admin.status.relation')) {
                 return $this->noPrivilege('admin.status.relation');
             }
             $genericData::deleteByIds($id, $id2);
             $update = 'deleted';
         } else {
             if (!$this->hasPrivilege('admin.status')) {
                 return $this->noPrivilege('admin.status');
             }
             $genericData::updateStatus($id, $id2, $newStatus);
         }
     }
     // result
     $json['result'] = ResultType::SUCCESS;
     $json['message'] = Lang::lang($update);
     return json_encode($json);
 }