Exemple #1
0
 public function __construct(\Ilch\Layout\Base $layout, \Ilch\View $view, \Ilch\Request $request, \Ilch\Router $router, \Ilch\Translator $translator)
 {
     parent::__construct($layout, $view, $request, $router, $translator);
     $this->getLayout()->set('menu', array());
     $this->getLayout()->setFile('modules/admin/layouts/index');
     $moduleMapper = new \Modules\Admin\Mappers\Module();
     $this->getLayout()->set('modules', $moduleMapper->getModules());
 }
Exemple #2
0
    public function indexAction()
    {
        $moduleMapper = new \Modules\Admin\Mappers\Module();
        $pageMapper = new \Modules\Page\Mappers\Page();
        $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('systemSettings'), array('action' => 'index'));
        if ($this->getRequest()->isPost()) {
            $this->getConfig()->set('multilingual_acp', $this->getRequest()->getPost('multilingualAcp'));
            $this->getConfig()->set('content_language', $this->getRequest()->getPost('contentLanguage'));
            $this->getConfig()->set('description', $this->getRequest()->getPost('description'));
            $this->getConfig()->set('page_title', $this->getRequest()->getPost('pageTitle'));
            $this->getConfig()->set('start_page', $this->getRequest()->getPost('startPage'));
            $this->getConfig()->set('mod_rewrite', (int) $this->getRequest()->getPost('modRewrite'));
            $this->getConfig()->set('standardMail', $this->getRequest()->getPost('standardMail'));
            $this->getConfig()->set('timezone', $this->getRequest()->getPost('timezone'));
            $this->getConfig()->set('locale', $this->getRequest()->getPost('locale'));
            if ($this->getRequest()->getPost('navbarFixed') === '1') {
                $this->getConfig()->set('admin_layout_top_nav', 'navbar-fixed-top');
            }
            if ($this->getRequest()->getPost('navbarFixed') === '0') {
                $this->getConfig()->set('admin_layout_top_nav', '');
            }
            if ((int) $this->getRequest()->getPost('modRewrite')) {
                $htaccess = <<<'HTACCESS'
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase %1$s/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %%{REQUEST_FILENAME} !-f
    RewriteCond %%{REQUEST_FILENAME} !-d
    RewriteRule . %1$s/index.php [L]
</IfModule>
HTACCESS;
                file_put_contents(APPLICATION_PATH . '/../.htaccess', sprintf($htaccess, REWRITE_BASE));
            } elseif (file_exists(APPLICATION_PATH . '/../.htaccess')) {
                file_put_contents(APPLICATION_PATH . '/../.htaccess', '');
            }
            $this->addMessage('saveSuccess');
        }
        $this->getView()->set('languages', $this->getTranslator()->getLocaleList());
        $this->getView()->set('multilingualAcp', $this->getConfig()->get('multilingual_acp'));
        $this->getView()->set('contentLanguage', $this->getConfig()->get('content_language'));
        $this->getView()->set('description', $this->getConfig()->get('description'));
        $this->getView()->set('pageTitle', $this->getConfig()->get('page_title'));
        $this->getView()->set('startPage', $this->getConfig()->get('start_page'));
        $this->getView()->set('modRewrite', $this->getConfig()->get('mod_rewrite'));
        $this->getView()->set('standardMail', $this->getConfig()->get('standardMail'));
        $this->getView()->set('timezones', \DateTimeZone::listIdentifiers());
        $this->getView()->set('timezone', $this->getConfig()->get('timezone'));
        $this->getView()->set('locale', $this->getConfig()->get('locale'));
        $this->getView()->set('modules', $moduleMapper->getModules());
        $this->getView()->set('pages', $pageMapper->getPageList());
        $this->getView()->set('navbarFixed', $this->getConfig()->get('admin_layout_top_nav'));
    }
Exemple #3
0
 public function deleteAction()
 {
     $modules = new \Modules\Admin\Mappers\Module();
     $key = $this->getRequest()->getParam('key');
     if ($this->getRequest()->isSecure()) {
         $configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\config';
         $config = new $configClass($this->getTranslator());
         $config->uninstall();
         $modules->delete($key);
         removeDir(APPLICATION_PATH . '/modules/' . $this->getRequest()->getParam('key'));
         $this->addMessage('deleteSuccess');
     }
     $this->redirect(array('action' => 'index'));
 }
Exemple #4
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]);
         }
     }
 }
Exemple #5
0
 public function indexAction()
 {
     $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menu'), array('action' => 'index'));
     $menuId = 1;
     if ($this->getRequest()->getParam('menu')) {
         $menuId = (int) $this->getRequest()->getParam('menu');
     }
     $menuMapper = new MenuMapper();
     $pageMapper = new PageMapper();
     /*
      * Saves the item tree to database.
      */
     if ($this->getRequest()->isPost()) {
         if ($this->getRequest()->getPost('save')) {
             $sortItems = json_decode($this->getRequest()->getPost('hiddenMenu'));
             $items = $this->getRequest()->getPost('items');
             $oldItems = $menuMapper->getMenuItems($menuId);
             /*
              * Deletes old entries from database.
              */
             if (!empty($oldItems)) {
                 foreach ($oldItems as $oldItem) {
                     if (!isset($items[$oldItem->getId()])) {
                         $menuMapper->deleteItem($oldItem);
                     }
                 }
             }
             if ($items) {
                 $sortArray = array();
                 foreach ($sortItems as $sortItem) {
                     if ($sortItem->item_id !== null) {
                         $sortArray[$sortItem->item_id] = (int) $sortItem->parent_id;
                     }
                 }
                 foreach ($items as $item) {
                     $menuItem = new MenuItem();
                     if (strpos($item['id'], 'tmp_') !== false) {
                         $tmpId = str_replace('tmp_', '', $item['id']);
                     } else {
                         $menuItem->setId($item['id']);
                     }
                     $menuItem->setMenuId($menuId);
                     $menuItem->setType($item['type']);
                     $menuItem->setSiteId($item['siteid']);
                     $menuItem->setHref($item['href']);
                     $menuItem->setTitle($item['title']);
                     if ((int) $item['boxkey'] > 0) {
                         $menuItem->setBoxId($item['boxkey']);
                     } else {
                         $menuItem->setBoxKey($item['boxkey']);
                     }
                     $menuItem->setModuleKey($item['modulekey']);
                     $newId = $menuMapper->saveItem($menuItem);
                     if (isset($tmpId)) {
                         foreach ($sortArray as $id => $parentId) {
                             if ($id == $tmpId) {
                                 unset($sortArray[$id]);
                                 $sortArray[$newId] = $parentId;
                             }
                             if ($parentId == $tmpId) {
                                 $sortArray[$id] = $newId;
                             }
                         }
                     }
                 }
                 $sort = 0;
                 foreach ($sortArray as $id => $parent) {
                     $menuItem = new MenuItem();
                     $menuItem->setId($id);
                     $menuItem->setSort($sort);
                     $menuItem->setParentId($parent);
                     $menuMapper->saveItem($menuItem);
                     $sort += 10;
                 }
             }
             $menu = new MenuModel();
             $menu->setId($menuId);
             $menuMapper->save($menu);
         }
         if ($this->getRequest()->getPost('delete')) {
             $id = (int) $this->getRequest()->getParam('menu');
             $menuMapper->delete($id);
             $this->redirect(array('action' => 'index'));
         }
         $this->addMessage('saveSuccess');
     }
     $menuItems = $menuMapper->getMenuItemsByParent($menuId, 0);
     $menu = $menuMapper->getMenu($menuId);
     $menus = $menuMapper->getMenus();
     $moduleMapper = new \Modules\Admin\Mappers\Module();
     $boxMapper = new \Modules\Admin\Mappers\Box();
     $locale = '';
     if ((bool) $this->getConfig()->get('multilingual_acp')) {
         if ($this->getTranslator()->getLocale() != $this->getConfig()->get('content_language')) {
             $locale = $this->getTranslator()->getLocale();
         }
     }
     $this->getView()->set('menu', $menu);
     $this->getView()->set('menus', $menus);
     $this->getView()->set('menuItems', $menuItems);
     $this->getView()->set('menuMapper', $menuMapper);
     $this->getView()->set('pages', $pageMapper->getPageList($locale));
     $this->getView()->set('boxes', (array) $boxMapper->getBoxList($locale));
     $this->getView()->set('modules', $moduleMapper->getModules());
 }
Exemple #6
0
foreach ($this->get('userOnlineList') as $userOnlineList) {
    ?>
                <?php 
    $userMapper = new \Modules\User\Mappers\User();
    ?>
                <?php 
    $user = $userMapper->getUserById($userOnlineList->getUserId());
    ?>
                <?php 
    $moduleKey = implode('/', array_slice(explode('/', $userOnlineList->getSite()), 1, 1));
    ?>
                <?php 
    if ($moduleKey != '') {
        ?>
                    <?php 
        $modulesMapper = new \Modules\Admin\Mappers\Module();
        ?>
                    <?php 
        $module = $modulesMapper->getModulesByKey($moduleKey, $this->getTranslator()->getLocale());
        ?>
                    <?php 
        $moduleName = $module->getName();
        ?>
                <?php 
    } else {
        ?>
                    <?php 
        $moduleName = '';
        ?>
                <?php 
    }
Exemple #7
0
                        <th><?php 
    echo $this->getTrans('commentLink');
    ?>
</th>
                        <th><?php 
    echo $this->getTrans('commentText');
    ?>
</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
    $userMapper = new \Modules\User\Mappers\User();
    ?>
                    <?php 
    $modulesMapper = new \Modules\Admin\Mappers\Module();
    ?>
                    <?php 
    foreach ($this->get('comments') as $comment) {
        ?>
                        <?php 
        $user = $userMapper->getUserById($comment->getUserId());
        ?>
                        <?php 
        $date = new \Ilch\Date($comment->getDateCreated());
        ?>
                        <?php 
        $commentKey = preg_replace("#[/].*#", "", $comment->getKey());
        ?>
                        <?php 
        $modules = $modulesMapper->getModulesByKey($commentKey, $locale);