Esempio n. 1
0
 /**
  * @param string $key
  */
 public function delete($key)
 {
     $menuMapper = new \Modules\Admin\Mappers\Menu();
     $menuMapper->deleteItemsByModuleKey($key);
     $this->db()->delete('modules')->where(array('key' => $key))->execute();
     $this->db()->delete('modules_content')->where(array('key' => $key))->execute();
 }
Esempio n. 2
0
 /**
  * Gets the menu for the given position.
  *
  * @param integer $menu
  * @param string $html
  * @return string
  */
 public function getMenu($args)
 {
     $menuId = $args[0];
     $helperMapper = new \Ilch\Layout\Helper\Menu\Mapper($this->layout);
     $menuMapper = new \Modules\Admin\Mappers\Menu();
     $menu = $helperMapper->getMenu($menuMapper->getMenuIdForPosition($menuId));
     if (isset($args[1]) && isset($args[2])) {
         return $menu->getItems($args[1], $args[2]);
     }
     if (isset($args[1])) {
         return $menu->getItems($args[1]);
     }
     return $menu->getItems();
 }
Esempio n. 3
0
 public function configAction()
 {
     $errors = array();
     if ($this->getRequest()->isPost()) {
         $_SESSION['install']['usage'] = $this->getRequest()->getPost('usage');
         $_SESSION['install']['modulesToInstall'][$_SESSION['install']['usage']] = $this->getRequest()->getPost('modulesToInstall');
         $_SESSION['install']['adminName'] = $this->getRequest()->getPost('adminName');
         $_SESSION['install']['adminPassword'] = $this->getRequest()->getPost('adminPassword');
         $_SESSION['install']['adminPassword2'] = $this->getRequest()->getPost('adminPassword2');
         $_SESSION['install']['adminEmail'] = $this->getRequest()->getPost('adminEmail');
         if (empty($_SESSION['install']['adminName'])) {
             $errors['adminName'] = 'fieldEmpty';
         }
         if (empty($_SESSION['install']['adminPassword'])) {
             $errors['adminPassword'] = '******';
         }
         if ($_SESSION['install']['adminPassword'] !== $_SESSION['install']['adminPassword2']) {
             $errors['adminPassword2'] = 'fieldDiffersPassword';
         }
         if (empty($_SESSION['install']['adminEmail'])) {
             $errors['adminEmail'] = 'fieldEmpty';
         } elseif (!filter_var($_SESSION['install']['adminEmail'], FILTER_VALIDATE_EMAIL)) {
             $errors['adminEmail'] = 'fieldEmail';
         }
         if (empty($errors)) {
             /*
              * Write install config.
              */
             $fileConfig = new \Ilch\Config\File();
             $fileConfig->set('dbEngine', $_SESSION['install']['dbEngine']);
             $fileConfig->set('dbHost', $_SESSION['install']['dbHost']);
             $fileConfig->set('dbUser', $_SESSION['install']['dbUser']);
             $fileConfig->set('dbPassword', $_SESSION['install']['dbPassword']);
             $fileConfig->set('dbName', $_SESSION['install']['dbName']);
             $fileConfig->set('dbPrefix', $_SESSION['install']['dbPrefix']);
             $fileConfig->saveConfigToFile(CONFIG_PATH . '/config.php');
             /*
              * Initialize install database.
              */
             $dbFactory = new \Ilch\Database\Factory();
             $db = $dbFactory->getInstanceByConfig($fileConfig);
             \Ilch\Registry::set('db', $db);
             $modulesToInstall = $_SESSION['install']['modulesToInstall'][$_SESSION['install']['usage']];
             if (!empty($modulesToInstall)) {
                 $modulesToInstall = array_merge(array('admin', 'article', 'user', 'page', 'media', 'comment', 'imprint', 'contact', 'privacy', 'statistic'), $modulesToInstall);
             } else {
                 $modulesToInstall = array('admin', 'article', 'user', 'page', 'media', 'comment', 'imprint', 'contact', 'privacy', 'statistic');
             }
             $moduleMapper = new \Modules\Admin\Mappers\Module();
             /*
              * Clear old tables.
              */
             $db->dropTablesByPrefix($db->getPrefix());
             foreach ($modulesToInstall as $module) {
                 $configClass = '\\Modules\\' . ucfirst($module) . '\\Config\\config';
                 $config = new $configClass($this->getTranslator());
                 $config->install();
                 if (!empty($config->config)) {
                     $moduleModel = new \Modules\Admin\Models\Module();
                     $moduleModel->setKey($config->config['key']);
                     if (isset($config->config['author'])) {
                         $moduleModel->setAuthor($config->config['author']);
                     }
                     if (isset($config->config['languages'])) {
                         foreach ($config->config['languages'] as $key => $value) {
                             $moduleModel->addContent($key, $value);
                         }
                     }
                     if (isset($config->config['system_module'])) {
                         $moduleModel->setSystemModule(true);
                     }
                     $moduleModel->setIconSmall($config->config['icon_small']);
                     $moduleMapper->save($moduleModel);
                 }
             }
             $menuMapper = new \Modules\Admin\Mappers\Menu();
             $menu1 = new \Modules\Admin\Models\Menu();
             $menu1->setId(1);
             $menu1->setTitle('Hauptmenü');
             $menuMapper->save($menu1);
             $menu2 = new \Modules\Admin\Models\Menu();
             $menu2->setId(2);
             $menu2->setTitle('Hauptmenü 2');
             $menuMapper->save($menu2);
             $sort = 0;
             $menuItem = new \Modules\Admin\Models\MenuItem();
             $menuItem->setMenuId(1);
             $menuItem->setParentId(0);
             $menuItem->setTitle('Menü');
             $menuItem->setType(0);
             $menuMapper->saveItem($menuItem);
             /*
              * Will not linked in menu
              */
             foreach ($modulesToInstall as $module) {
                 if (in_array($module, array('comment', 'shoutbox', 'admin', 'media', 'page', 'newsletter', 'statistic'))) {
                     continue;
                 }
                 $configClass = '\\Modules\\' . ucfirst($module) . '\\Config\\config';
                 $config = new $configClass($this->getTranslator());
                 $menuItem = new \Modules\Admin\Models\MenuItem();
                 $menuItem->setMenuId(1);
                 $menuItem->setSort($sort);
                 $menuItem->setParentId(1);
                 $menuItem->setType(3);
                 $menuItem->setModuleKey($config->config['key']);
                 $menuItem->setTitle($config->config['languages'][$this->getTranslator()->getLocale()]['name']);
                 $menuMapper->saveItem($menuItem);
                 $sort += 10;
             }
             $boxes = "INSERT INTO `[prefix]_menu_items` (`menu_id`, `sort`, `parent_id`, `page_id`, `box_id`, `box_key`, `type`, `title`, `href`, `module_key`) VALUES\n                        (1, 80, 0, 0, 0, 'user_login', 4, 'Login', '', ''),\n                        (1, 90, 0, 0, 0, 'admin_layoutswitch', 4, 'Layout', '', ''),\n                        (1, 100, 0, 0, 0, 'statistic_stats', 4, 'Statistik', '', ''),\n                        (1, 110, 0, 0, 0, 'statistic_online', 4, 'Online', '', ''),\n                        (2, 10, 0, 0, 0, 'admin_langswitch', 4, 'Sprache', '', ''),\n                        (2, 20, 0, 0, 0, 'article_article', 4, 'Letzte Artikel', '', ''),\n                        (2, 30, 0, 0, 0, 'article_categories', 4, 'Kategorien', '', ''),\n                        (2, 40, 0, 0, 0, 'article_archive', 4, 'Archive', '', '')";
             $db->queryMulti($boxes);
             unset($_SESSION['install']);
             $this->redirect(array('action' => 'finish'));
         }
         $this->getView()->set('errors', $errors);
     }
     foreach (array('modulesToInstall', 'usage', 'adminName', 'adminPassword', 'adminPassword2', 'adminEmail') as $name) {
         if (!empty($_SESSION['install'][$name])) {
             $this->getView()->set($name, $_SESSION['install'][$name]);
         }
     }
 }
Esempio n. 4
0
 /**
  * Gets the menu items as html-string.
  *
  * @param \Modules\Admin\Models\MenuItem $item
  * @param array $options
  * @return string
  */
 protected function recGetItems($item, $locale, $options = array())
 {
     $menuMapper = new \Modules\Admin\Mappers\Menu();
     $pageMapper = new \Modules\Page\Mappers\Page();
     $subItems = $menuMapper->getMenuItemsByParent($item->getMenuId(), $item->getId());
     $html = '';
     if (in_array($item->getType(), array(1, 2, 3))) {
         $html = '<li>';
     }
     if ($item->getType() == 1) {
         $html .= '<a href="' . $item->getHref() . '">' . $item->getTitle() . '</a>';
     } elseif ($item->getType() == 2) {
         $page = $pageMapper->getPageByIdLocale($item->getSiteId(), $locale);
         $html .= '<a href="' . $this->layout->getUrl($page->getPerma()) . '">' . $item->getTitle() . '</a>';
     } elseif ($item->getType() == 3) {
         $html .= '<a href="' . $this->layout->getUrl(array('module' => $item->getModuleKey(), 'action' => 'index', 'controller' => 'index')) . '">' . $item->getTitle() . '</a>';
     }
     if (!empty($subItems)) {
         if (isset($options['class_ul'])) {
             $html .= '<ul class="' . $options['class_ul'] . '">';
         } else {
             $html .= '<ul class="list-unstyled ilch_menu_ul">';
         }
         foreach ($subItems as $subItem) {
             $html .= $this->recGetItems($subItem, $locale, $options);
         }
         $html .= '</ul>';
     }
     if (in_array($item->getType(), array(1, 2, 3))) {
         $html .= '</li>';
     }
     return $html;
 }