Ejemplo n.º 1
0
 protected function showMenu($selected = FALSE)
 {
     $menu = $this->model->showMenu($selected);
     $this->buffer(\View\AdminCP::showMenu($menu), "LEFT");
     if (isset($menu[$this->moduleBase]['sub']) and sizeof($menu[$this->moduleBase]['sub']) > 0) {
         \Base::instance()->set('accessSub', TRUE);
     }
 }
Ejemplo n.º 2
0
 protected function editChapter(array $params, array $storyInfo)
 {
     $chapterList = $this->model->loadChapterList($storyInfo['sid']);
     if ($params['chapter'] == "new") {
         $chapterInfo = ["sid" => $storyInfo['sid'], "chapid" => "new", "title" => "", "notes" => "", "validated" => 0, "rating" => 0, "chaptertext" => ""];
     } else {
         $chapterInfo = $this->model->getChapter($storyInfo['sid'], (int) $params['chapter']);
     }
     $chapterInfo['storytitle'] = $storyInfo['title'];
     $plain = @$params['style'] == "plain";
     $this->buffer(\View\AdminCP::storyChapterEdit($chapterInfo, $chapterList, $plain));
 }
Ejemplo n.º 3
0
 protected function profile(\Base $f3, $params)
 {
     $this->response->addTitle($f3->get('LN__AdminMenu_Profile'));
     $f3->set('title_h3', $f3->get('LN__AdminMenu_Profile'));
     if (isset($params[2])) {
         $params = $this->parametric($params[2]);
     }
     if (isset($params['edit']) and is_numeric($params['edit'])) {
         return TRUE;
     }
     // Get all available user fields
     $fields = $this->model->listUserFields();
     // Group array by field type
     foreach ($fields as $field) {
         $data[$field['field_type']][] = $field;
     }
     $this->buffer(\View\AdminCP::listUserFields($data));
 }
Ejemplo n.º 4
0
 protected function layout(\Base $f3, $params)
 {
     $f3->set('title_h3', $f3->get('LN__AdminMenu_Layout'));
     $layoutConfig = $this->model->getLayoutConfig();
     // Folder list with ***x cleanup - anyone with a windows server, is this working?
     $entries = array_diff(scandir("./template/frontend"), array('..', '.'));
     foreach ($entries as $entry) {
         if (is_dir("./template/frontend/{$entry}")) {
             $data = (array) simplexml_load_file("./template/frontend/{$entry}/info.xml");
             $data['active'] = array_key_exists($data['folder'], $layoutConfig['layout_available']);
             $layoutFiles[] = $data;
         }
     }
     return \View\AdminCP::layout($layoutFiles, $layoutConfig);
 }
Ejemplo n.º 5
0
 protected function categories(\Base $f3, $params)
 {
     if (isset($params[2])) {
         $params = $this->parametric($params[2]);
     }
     $this->response->addTitle($f3->get('LN__AdminMenu_Categories'));
     $f3->set('title_h3', $f3->get('LN__AdminMenu_Categories'));
     if (isset($params['move'])) {
         $parent = $this->model->moveCategory($params['move'][1], $params['move'][0]);
         \Model\Routines::instance()->cacheCategories($parent);
     } elseif (isset($params['add'])) {
         $parent_cid = (isset($params['add']) and $params['add'] !== TRUE) ? (int) $params['add'] : 0;
         if (isset($_POST['form_data'])) {
             $newID = $this->model->addCategory($parent_cid, $f3->get('POST.form_data'));
         }
         if (empty($newID)) {
             // Attempted to add category, but failed
             if (@$newID === FALSE) {
                 $errors = '__failAddCategory';
             }
             $parent_info = $this->model->loadCategory($parent_cid);
             // Non-existent category, go back to overview
             if ($parent_info === FALSE) {
                 $f3->reroute('/adminCP/archive/categories', false);
             }
             // Form
             $data = ['errors' => @$errors, 'changes' => @$changes, 'id' => $parent_cid, 'info' => @$parent_info];
             $this->buffer(\View\AdminCP::addCategory($f3, $data));
             // Leave function without creating further forms or mishap
             return TRUE;
         } else {
             $f3->set('changes', 1);
         }
     } elseif (isset($params['delete'])) {
         $data = $this->model->loadCategory((int) $params['delete']);
         if (isset($data['category'])) {
             $data['stats'] = json_decode($data['stats'], TRUE);
             if ($data['stats']['sub'] === NULL and $data['stats']['count'] == 0) {
                 if (FALSE === $this->model->deleteCategory((int) $params['delete'])) {
                     $errors = $f3->get('ACP_Categories_Error_DBError', $data['category']);
                 } else {
                     $changes = $f3->get('ACP_Categories_Success_Deleted', $data['category']);
                 }
             } else {
                 $errors = $f3->get('ACP_Categories_Error_notEmpty', $data['category']);
             }
         } else {
             $errors = $f3->get('ACP_Categories_Error_badID');
         }
     } elseif (isset($_POST) and sizeof($_POST) > 0) {
         if (isset($_POST['form_data'])) {
             $changes = $this->model->saveCategory($params['id'], $f3->get('POST.form_data'));
         }
     }
     if (isset($params['id'])) {
         $data = $this->model->loadCategory($params['id']);
         $data['move'] = $this->model->loadCategoryPossibleParents($params['id']);
         if ($data['leveldown'] > 1) {
             $parent = $this->model->loadCategory($data['move'][0]['parent_cid']);
             $data['move'] = array_merge([["cid" => $parent['id'], "parent_cid" => $parent['parent_cid'], "leveldown" => $parent['leveldown'] - 1, "category" => $parent['category'] . " (one level up)"]], $data['move']);
         }
         $data['move'] = array_merge([["cid" => 0, "parent_cid" => 0, "leveldown" => -1, "category" => "__Category_MainCategory"]], $data['move']);
         $data['stats'] = json_decode($data['stats'], TRUE);
         $data['errors'] = @$errors;
         $data['changes'] = @$changes;
         $this->buffer(\View\AdminCP::editCategory($data));
         return TRUE;
     }
     $data = $this->model->categoriesListFlat();
     $feedback['errors'] = @$errors;
     $feedback['changes'] = @$changes;
     $this->buffer(\View\AdminCP::listCategories($data, $feedback));
 }
Ejemplo n.º 6
0
 protected function news(\Base $f3, array $params)
 {
     $this->response->addTitle($f3->get('LN__AdminMenu_News'));
     $f3->set('title_h3', $f3->get('LN__AdminMenu_News'));
     if (isset($params[2])) {
         $params = $this->parametric($params[2]);
     }
     if (isset($params['delete'])) {
         if ($this->model->deleteNews((int) $params['delete'])) {
             $f3->reroute('/adminCP/home/news', false);
         } else {
             $f3->set('form_error', "__failedDelete");
         }
     } elseif (isset($_POST) and sizeof($_POST) > 0) {
         if (isset($_POST['form_data'])) {
             //$changes = $this->model->saveCustompage($params['id'], $f3->get('POST.form_data') );
         } elseif (isset($_POST['newHeadline'])) {
             $newID = $this->model->addNews($f3->get('POST.newHeadline'));
             if ($newID !== FALSE) {
                 $f3->reroute('/adminCP/home/news/id=' . $newID, false);
             }
         }
     }
     if (isset($params['id'])) {
         if (NULL !== ($data = $this->model->loadNews($params['id']))) {
             $data['raw'] = @$params['raw'];
             $data['errors'] = @$errors;
             $data['changes'] = @$changes;
             $this->buffer(\View\AdminCP::editNews($data));
             return TRUE;
         } else {
             $f3->set('form_error', "__failedLoad");
         }
     }
     // page will always be an integer > 0
     $page = empty((int) @$params['page']) || (int) $params['page'] < 0 ?: (int) $params['page'];
     // search/browse
     $allow_order = array("id" => "nid", "date" => "date", "title" => "headline", "author" => "author");
     // sort order
     $sort["link"] = isset($allow_order[@$params['order'][0]]) ? $params['order'][0] : "date";
     $sort["order"] = $allow_order[$sort["link"]];
     $sort["direction"] = isset($params['order'][1]) && $params['order'][1] == "asc" ? "asc" : "desc";
     $data = $this->model->listNews($page, $sort);
     $this->buffer(\View\AdminCP::listNews($data, $sort));
 }