当前位置: 首页>>代码示例>>PHP>>正文


PHP UserManager::returnUser方法代码示例

本文整理汇总了PHP中UserManager::returnUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::returnUser方法的具体用法?PHP UserManager::returnUser怎么用?PHP UserManager::returnUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserManager的用法示例。


在下文中一共展示了UserManager::returnUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 public function process($parameters)
 {
     //do control panela maju pristup len prihlaseny uzivatelia
     $this->checkUser();
     //hlavicka stranky
     $this->head['title'] = 'Ovládací panel';
     $userManager = new UserManager();
     $validation = new Validation();
     //zadane URL pre odhlasenie
     if (!empty($parameters[0]) && $parameters[0] == 'odhlasit') {
         $userManager->logOut();
         $this->redirect('prihlasenie');
     }
     //data pre sablonu
     $user = $userManager->returnUser();
     $this->data['admin'] = $user['admin'];
     $this->data['userRank'] = $validation->returnUserRank($user['admin']);
     $this->data['user'] = $user['name'];
     $this->data['avatar'] = $user['avatar'];
     $this->data['registrationDate'] = $user['registration_date'];
     $this->data['lastVisit'] = $user['last_visit'];
     $this->data['comments'] = $user['comments'];
     $this->data['articles'] = $user['articles'];
     $this->data['sex'] = $user['sex'];
     $this->data['email'] = $user['email'];
     //nastavenie sablony
     $this->view = 'controlPanel';
 }
开发者ID:tomas3093,项目名称:MVC,代码行数:28,代码来源:PanelController.php

示例2: route

 public function route($params)
 {
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     if (!$user) {
         $this->redirect("login");
     }
     switch ($user['role']) {
         case 2:
             $this->view = 'admin_dashboard';
             break;
         case 1:
             $reviewManager = new ReviewManager();
             $this->data['no_reviewed'] = $reviewManager->return_no_reviewed($user['id_user']);
             $this->data['reviewed'] = $reviewManager->return_reviewed($user['id_user']);
             $this->view = 'reviewer_dashboard';
             break;
         case 0:
         default:
             $this->view = 'author_dashboard';
             break;
     }
     $header_menu = 'login_bar';
     $this->data['title_html'] = 'Hlavní panel';
     $this->head['title_html'] = $this->data['title_html'];
     $this->header_menu = $header_menu;
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:27,代码来源:DashboardController.php

示例3: checkUser

 public function checkUser($admin = false)
 {
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     if (!$user || $admin && $user['admin'] != '1') {
         $this->createMessage('Nemáte dostatočné oprávnenie.', 'info');
         $this->redirect('prihlasenie');
     }
 }
开发者ID:tomas3093,项目名称:cms-blog,代码行数:9,代码来源:Controller.php

示例4: route

 public function route($params)
 {
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     $header_menu = "unlogin_bar";
     if ($user) {
         $header_menu = 'login_bar';
     }
     // Hlavička stránky
     http_response_code(404);
     $this->head['title_html'] = 'Stránka nenalezena';
     $this->header_menu = $header_menu;
     $this->view = 'error';
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:14,代码来源:ErrorController.php

示例5: route

 public function route($params)
 {
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     $header_menu = 'login_bar';
     if (!$user) {
         $this->addMessage("Pro tuto akci je nutné se přihlásit");
         $this->redirect("login");
     }
     $this->header_menu = $header_menu;
     $this->head['title_html'] = 'Správa uživatelů';
     $this->checkUser(2);
     //oveření, zda jde o administrátora
     switch ($params[0]) {
         case 'my':
             $this->redirect("user");
         case 'add':
             $article = DBmodel::fromPOST(Article::class);
             // ověřím vyplnění zaslaných dat
             if ($article) {
                 $articleManager->add_new_article($article);
                 $this->addMessage("Článek byl úspěšně přidán");
             } else {
                 $this->addMessage("Článek nebyl přidán kvůlu nevyplněným údajům");
             }
             $this->view = 'new_article';
             break;
         default:
             $this->data['users'] = $userManager->return_all_users();
             foreach ($this->data['users'] as $user) {
                 if ($user['role'] == 0) {
                     $user['color'] = "green";
                 } else {
                     if ($user['role'] == 1) {
                         $user['color'] = "purple";
                     } else {
                         $user['color'] = "red";
                     }
                 }
             }
             $this->view = 'users';
             break;
     }
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:44,代码来源:UserController.php

示例6: process

 public function process($parameters)
 {
     $userManager = new UserManager();
     if ($userManager->returnUser()) {
         $this->redirect('panel');
     }
     //hlavicka stranky
     $this->data['title'] = 'Prihlásenie';
     if ($_POST) {
         try {
             $userManager->logIn($_POST['name'], $_POST['password']);
             $this->createMessage('Boli ste úspešne prihlásený.', 'success');
             $this->redirect('panel');
         } catch (UserError $error) {
             $this->createMessage($error->getMessage(), 'warning');
         }
     }
     //nastavenie sablony
     $this->view = 'logIn';
 }
开发者ID:tomas3093,项目名称:MVC,代码行数:20,代码来源:PrihlasenieController.php

示例7: process

 public function process($parameters)
 {
     $userManager = new UserManager();
     $articleManager = new ArticleManager();
     $parsedURL = $this->parseURL($parameters[0]);
     //predanie URL do funkcie
     //zobrazenie uvodnej stranky
     if (empty($parsedURL[0])) {
         $frontPageContentManager = new frontPageContentManager();
         $this->data['user'] = $userManager->returnUserName();
         $this->data['title'] = 'Coding - Programovanie, Novinky, Software, Hardware';
         $this->data['key_words'] = 'Programovanie, Novinky, Software, Hardware, Blog, Spravodajstvo';
         $this->data['description'] = 'blog, články o programovaní, novinky zo sveta IT, rôzne zaujímavosti';
         $this->data['messages'] = $this->returnMessages();
         $this->data['topArticles'] = $articleManager->returnTopArticles();
         $this->data['topArticlesTiles'] = $frontPageContentManager->returnLastArticles();
         $this->view = 'frontPage';
     } else {
         $controllerClass = $this->camelCase(array_shift($parsedURL)) . 'Controller';
         //spracovanie URL na parametre, volanie pozadovaneho kontroleru
         if (file_exists('controllers/' . $controllerClass . '.php')) {
             //ak existuje kontroler z URL
             $this->controller = new $controllerClass();
         } else {
             $this->redirect('chyba');
         }
         //ak neexistuje, presmeruj na chybove hlasenie
         $this->controller->process($parsedURL);
         //spracovanie ostatnych parametrov vo vnorenom kontroleri
         //predanie premennych do hlavnej sablony
         $this->data['user'] = $userManager->returnUserName();
         $this->data['loggedUser'] = $userManager->returnUser();
         $this->data['title'] = $this->controller->head['title'];
         $this->data['key_words'] = $this->controller->head['key_words'];
         $this->data['description'] = $this->controller->head['description'];
         $this->data['messages'] = $this->returnMessages();
         $this->data['topArticles'] = $articleManager->returnTopArticles();
         $this->view = 'layout';
         //nastavenie hlavnej sablony
     }
 }
开发者ID:tomas3093,项目名称:cms-blog,代码行数:41,代码来源:RouterController.php

示例8: route

 public function route($params)
 {
     $userManager = new UserManager();
     if ($userManager->returnUser()) {
         $this->redirect('dashboard');
     }
     $header_menu = "login_bar_none";
     $this->header_menu = $header_menu;
     // Hlavička stránky
     $this->head['title_html'] = 'Přihlášení do konferečního systému';
     if ($_POST) {
         try {
             $userManager->login($_POST['jmeno'], $_POST['heslo']);
             $this->redirect('dashboard');
         } catch (Exception $chyba) {
             $this->addMessage("Špatně zadané údaje");
         }
     }
     // Nastavení šablony
     $this->view = 'login';
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:21,代码来源:LoginController.php

示例9: route

 public function route($params)
 {
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     if ($user) {
         $this->redirect("dashboard");
     }
     $header_menu = 'login_bar_none';
     $this->head['title_html'] = 'Registrace';
     if ($_POST) {
         $new_user = DBmodel::fromPOST(NewUser::class);
         // ověřím vyplnění zaslaných dat
         if ($new_user) {
             if (!filter_var($new_user->email, FILTER_VALIDATE_EMAIL)) {
                 $this->addMessage("Zadaný email má neplatný formát");
             } else {
                 if ($new_user->password != $new_user->password2) {
                     $this->addMessage("Zadaná hesla se neshodují");
                 } else {
                     $userManager = new UserManager();
                     $exist = $userManager->return_users_by_login($new_user->username);
                     if ($exist) {
                         $this->addMessage("Účet se zadaným loginem již existuje");
                     } else {
                         $userManager->register($new_user);
                         $this->addMessage("Registrace proběhla úspěšně, nyní se můžete přihlásit");
                         $this->redirect("login");
                     }
                 }
             }
         } else {
             $this->addMessage("Registrace selhala kvůli nevyplněným údajům");
         }
     } else {
         $_POST = NULL;
     }
     $this->header_menu = $header_menu;
     $this->view = 'registration';
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:39,代码来源:RegistrationController.php

示例10: route

 public function route($params)
 {
     $webManager = new WebManager();
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     $header_menu = "login_bar_none";
     if ($user) {
         $header_menu = 'login_bar';
     }
     // echo $user['user'];
     $this->side_menu = $webManager->return_all_pages();
     // Je zadáno URL článku ke smazání
     if (!empty($params[1]) && $params[1] == 'odstranit') {
         $this->checkUser(true);
         $webManager->odstranClanek($params[0]);
         $this->addMessage('Článek byl úspěšně odstraněn');
         $this->redirect('clanek');
     } else {
         if (!empty($params[0])) {
             // Získání článku podle URL
             $webPage = $webManager->return_page($params[0]);
             if (!$webPage) {
                 $this->redirect('chyba');
             }
             // Hlavička stránky
             $this->head = array('title_html' => $webPage['title'], 'key_words' => $webPage['key_words'], 'description' => $webPage['description']);
             // Naplnění proměnných pro šablonu
             $this->data['title'] = $webPage['title'];
             $this->data['obsah'] = $webPage['content'];
             $this->header_menu = $header_menu;
             $this->view = 'webpage';
         } else {
             $this->redirect('web/home');
         }
     }
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:36,代码来源:WebController.php

示例11: checkUser

 public function checkUser($authority)
 {
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     if ($user['role'] != $authority) {
         $this->addMessage('Nedostatečná oprávnění.');
         $this->redirect('login');
     }
 }
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:9,代码来源:Controller.php

示例12: process

 public function process($parameters)
 {
     $articleManager = new ArticleManager();
     $userManager = new UserManager();
     $commentManager = new CommentManager();
     $validation = new Validation();
     $user = $userManager->returnUser();
     $this->data['admin'] = $user['admin'];
     //ak je zadane URL pre clanok, uloz clanok do premennej $article
     if (!empty($parameters[0]) && $parameters[0] != 'page' && $parameters[0] != 'unpublished') {
         $article = $articleManager->returnArticle($parameters[0]);
     }
     //nie je zadane url clanku, tak vypise zoznam clankov
     if (empty($parameters[0])) {
         $articles = $articleManager->returnPublicArticles(0);
         $this->data['articles'] = $validation->statusOfArticles($articles);
         //zisti pocet clankov, a pripravi pocet stran
         $countArticles = sizeof($articles);
         $modulo = $countArticles % 5;
         if ($modulo == 0) {
             $this->data['pages'] = $countArticles / 5;
         } else {
             $this->data['pages'] = intval($countArticles / 5 + 1);
         }
         $this->data['currentPage'] = 1;
         //aktualna strana
         $this->view = 'articles';
     }
     //ak je zadane URL pre zobrazenie nepublikovanych clankov
     if (!empty($parameters[0]) && $parameters[0] == 'unpublished') {
         $articles = $articleManager->returnUnpublishedArticles();
         $this->data['articles'] = $validation->statusOfArticles($articles);
         $this->view = 'articles';
     }
     //ak je zadane URL pre zobrazenie konkretnej strany
     if (!empty($parameters[0]) && $parameters[0] == 'page') {
         //ak je zadane cislo strany
         if (!empty($parameters[1]) && is_numeric($parameters[1])) {
             if ($parameters[1] == 1) {
                 $offset = 0;
             } else {
                 $offset = $parameters[1] * 5 - 5;
             }
             //zisti pocet clankov, a pripravi pocet stran
             $articles = $articleManager->returnPublicArticles(0);
             //vsetky clanky
             $countArticles = sizeof($articles);
             $modulo = $countArticles % 5;
             if ($modulo == 0) {
                 $this->data['pages'] = $countArticles / 5;
             } else {
                 $this->data['pages'] = intval($countArticles / 5 + 1);
             }
             $this->data['currentPage'] = $parameters[1];
             //aktualna strana
             //vratenie clankov s pozadovanym offsetom
             $articles = $articleManager->returnPublicArticles($offset);
             $this->data['articles'] = $validation->statusOfArticles($articles);
             $this->view = 'articles';
         } else {
             $this->redirect('clanky');
         }
     }
     //ak je zadane URL pre zmazanie clanku
     if (!empty($parameters[1]) && $parameters[1] == 'odstranit' && $parameters[0] != 'page') {
         //overi ci clanok z URL existuje
         if (!$article) {
             $this->redirect('chyba');
         }
         //overi ci je prihlaseny admin
         $this->checkUser(true);
         $articleManager->deleteArticle($parameters[0]);
         $this->createMessage('Článok bol odstránený', 'success');
         $this->redirect('clanky');
     }
     //ak je zadane URL pre zmazanie komentara
     if (!empty($parameters[0]) && !empty($parameters[1]) && $parameters[1] == 'odstranit-komentar' && !empty($parameters[2])) {
         //overi ci clanok z URL existuje
         if (!$article) {
             $this->redirect('chyba');
         }
         $this->checkUser(true);
         //overi ci je prihlaseny admin
         $commentManager->deleteComment($parameters[2]);
         $this->createMessage('Komentár bol odstránený', 'success');
     }
     //ak je zadane URL clanku
     if (!empty($parameters[0]) && $parameters[0] != 'page' && $parameters[0] != 'unpublished') {
         //ak nebol clanok na zadanej URL najdeny
         //alebo ak uzivatel nie je admin a clanok nie je publikovany
         //presmeruj na chybove hlasenie
         if (!$article || $user['admin'] != '1' && $article['public'] == '0') {
             $this->redirect('chyba');
         }
         //ak bol odoslany komentar
         if ($_POST) {
             //ak bol spravne vyplneny antispam
             if ($_POST['year'] == date('Y')) {
                 //vyber udajov z $_POST a ich ulozenie do premennej $comment
                 $keys = array('article_id', 'comment', 'author');
//.........这里部分代码省略.........
开发者ID:tomas3093,项目名称:MVC,代码行数:101,代码来源:ClankyController.php

示例13: process

 public function process($parameters)
 {
     $articleManager = new ArticleManager();
     $userManager = new UserManager();
     $validation = new Validation();
     $this->checkUser();
     $loggedUser = $userManager->returnUser();
     //editor je pristupny iba pre admina a redaktorov
     if ($loggedUser['admin'] == 1 || $loggedUser['admin'] == 2) {
         $article = array('article_id' => '', 'title' => '', 'thumbnail_img' => '', 'content' => '', 'url' => '', 'category' => '', 'description' => '', 'key_words' => '', 'author' => '');
         //ak je odoslany formular
         if ($_POST) {
             //ziskanie clanku z $_POST
             $keys = array('article_id', 'title', 'thumbnail_img', 'content', 'url', 'category', 'description', 'key_words', 'author', 'public');
             $article = array_intersect_key($_POST, array_flip($keys));
             //upload a spracovanie suboru
             $imageUpload = new upload($_FILES['image_field'], 'sk_SK');
             //nastavenie ID noveho clanku
             if (empty($article['article_id'])) {
                 $article['article_id'] = $articleManager->returnLastArticleId() + 1;
             }
             $targetDirectory = 'img/articles/' . $article['article_id'] . '/';
             $filePath = $targetDirectory . 'thumbnail.png';
             try {
                 //vytvori novy adresar podla ID noveho clanku
                 if (!file_exists($targetDirectory)) {
                     mkdir($targetDirectory, '0777', true);
                 }
                 //ak bol obrazok nahraty
                 if ($imageUpload->uploaded) {
                     $imageUpload->allowed = array('image/*');
                     //povolene formaty
                     $imageUpload->mime_check = true;
                     //kontrola formatu zapnuta
                     $imageUpload->file_new_name_body = 'thumbnail';
                     //novy nazov suboru
                     $imageUpload->image_resize = true;
                     //zmensenie
                     $imageUpload->image_convert = 'png';
                     //konvertovanie na png
                     $imageUpload->image_x = 120;
                     //vysledna sirka 120px
                     $imageUpload->image_ratio_y = true;
                     //vyska: auto
                     //zmazanie existujuceho nahladoveho obrazka
                     if (file_exists($filePath)) {
                         unlink($filePath);
                     }
                     $imageUpload->process($targetDirectory);
                     //uloz vysledny obrazok
                     //ak bol obrazok ulozeny
                     if ($imageUpload->processed) {
                         //uloz cestu k obrazku do '$article'
                         $article['thumbnail_img'] = $filePath;
                         $imageUpload->clean();
                     } else {
                         throw new UserError($imageUpload->error);
                     }
                 }
             } catch (UserError $error) {
                 $this->createMessage($error->getMessage(), 'warning');
             }
             //ulozenie clanku do databazy
             try {
                 //vytvorenie URL adresy z pola title
                 $article['url'] = $validation->checkUrl($article['title']);
                 //ulozenie clanku do databazy
                 $articleManager->saveArticle($_POST['article_id'], $article);
                 $this->createMessage('Článok bol úspešne uložený', 'success');
                 //presmeruj na clanok
                 $this->redirect('clanky/' . $article['url']);
             } catch (UserError $error) {
                 $this->createMessage($error->getMessage(), 'warning');
                 $this->redirect('editor');
             }
         }
         //ak je zadana URL adresa clanku na jeho editaciu
         if (!empty($parameters[0])) {
             $loadedArticle = $articleManager->returnArticle($parameters[0]);
             if ($loadedArticle) {
                 $article = $loadedArticle;
             } else {
                 $this->createMessage('Článok sa nenašiel', 'warning');
                 $this->redirect('chyba');
             }
             $this->data['article'] = $article;
             //hlavicka stranky
             $this->head = array('title' => 'Editor - ' . $article['title'], 'key_words' => 'coding.wz.sk - editor', 'description' => 'Editor článkov');
             $this->view = 'editor';
         } else {
             $article['author'] = $userManager->returnUser()['name'];
             $this->data['article'] = $article;
             //hlavicka stranky
             $this->head = array('title' => 'Editor - Nový článok', 'key_words' => 'coding.wz.sk - editor', 'description' => 'Editor článkov');
             $this->view = 'editor';
         }
     }
 }
开发者ID:tomas3093,项目名称:cms-blog,代码行数:98,代码来源:EditorController.php

示例14: route

 public function route($params)
 {
     $articleManager = new ArticleManager();
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     $this->data['title_html'] = "";
     $header_menu = 'login_bar';
     if (!$user) {
         $this->addMessage("Pro tuto akci je nutné se přihlásit");
         $this->redirect("login");
     }
     $this->header_menu = $header_menu;
     if (empty($params[0])) {
         $this->redirect("dashboard");
     }
     switch ($params[0]) {
         case 'new':
             $this->checkUser(0);
             $_POST = NULL;
             $this->data['title_html'] = 'Nový článek';
             $this->view = 'new_article';
             break;
         case 'my':
             $this->data['title_html'] = 'Mé články';
             $this->checkUser(0);
             if (isset($params[1])) {
                 $article = $articleManager->return_article($params[1]);
                 //var_dump($article);
                 $this->data['id_article'] = $article['id_article'];
                 $this->data['title'] = $article['title'];
                 $this->data['authors'] = $article['authors'];
                 $this->data['notes'] = $article['notes'];
                 $this->data['link_pdf'] = $article['link_pdf'];
                 $this->view = 'my_article';
             } else {
                 //$this->data['articles'] = $articleManager->return_all_articles();
                 $this->data['articles'] = $articleManager->return_my_articles($user['id_user']);
                 $this->view = 'my_articles';
             }
             break;
         case 'add':
             $this->checkUser(0);
             $this->data['title'] = $_POST['title'];
             $article = DBmodel::fromPOST(Article::class);
             // ověřím vyplnění zaslaných dat
             if ($article) {
                 $articleManager = new ArticleManager();
                 $res = $articleManager->get_last_id()->fetch();
                 $id = "_1";
                 if ($res) {
                     $id = "_" . ($res['id_article'] + 1);
                 }
                 $file_ok = 0;
                 $target_dir = "pdf/";
                 $target_name = explode(".", $_FILES["link_pdf"]["name"])[0] . $id;
                 $target_extension = explode(".", $_FILES["link_pdf"]["name"])[1];
                 $target_file = $target_dir . $target_name . "." . $target_extension;
                 if ($target_extension != "pdf") {
                     $this->addMessage("Nahraný dokument není ve formátu pdf");
                 } else {
                     // je to pdf
                     if (move_uploaded_file($_FILES["link_pdf"]["tmp_name"], $target_file)) {
                         $this->addMessage("Dokument byl úspěšně nahrán na server");
                         $file_ok = 1;
                     } else {
                         $file_ok = 0;
                         $this->addMessage("Chyba při nahrávání dokumentu na server");
                     }
                 }
                 if ($file_ok) {
                     $article->link_pdf = $target_file;
                     $articleManager->add_new_article($article, $user['id_user']);
                     $this->addMessage("Článek byl úspěšně přidán");
                 } else {
                     $this->addMessage("PDF dokument se nepodařilo nahrát na server <b>" . $_FILES["link_pdf"]["name"] . "</b>");
                 }
                 $this->redirect("article/my");
             } else {
                 $this->addMessage("Článek nebyl přidán kvůli nevyplněným údajům");
             }
             $this->data['title'] = $_POST['title'];
             $this->view = 'new_article';
             break;
         case 'remove':
             $this->checkUser(0);
             $articleManager->delete_article_database($params[1], $user['id_user']);
             $this->redirect("article/my");
             break;
         case 'manager':
             $this->data['title_html'] = 'Správa článků';
             $this->checkUser(2);
             $articles = $articleManager->return_all_articles_w_reviews();
             // final articles
             $fa = array();
             foreach ($articles as $key => $a) {
                 if (!isset($fa[$a['id_article']])) {
                     $fa[$a['id_article']] = $a->toArray();
                     $fa[$a['id_article']]['reviews'] = [];
                 }
                 if ($a['id_review'] != null) {
//.........这里部分代码省略.........
开发者ID:Eflyax,项目名称:KIVWEB,代码行数:101,代码来源:ArticleController.php

示例15: process

 public function process($parameters)
 {
     $articleManager = new ArticleManager();
     $userManager = new UserManager();
     $commentManager = new CommentManager();
     $validation = new Validation();
     $user = $userManager->returnUser();
     $this->data['admin'] = $user['admin'];
     //ak je zadane URL pre clanok, uloz clanok do premennej $article
     if (!empty($parameters[0]) && $parameters[0] != 'page' && $parameters[0] != 'unpublished') {
         $article = $articleManager->returnArticle($parameters[0]);
     }
     //nie je zadane url clanku, tak vypise zoznam clankov
     if (empty($parameters[0])) {
         $articles = $articleManager->returnPublicArticles(0);
         $this->data['articles'] = $validation->statusOfArticles($articles);
         if (sizeof($articles) == 0) {
             $this->createMessage('Žiadne články na zobrazenie', 'info');
         }
         //zisti pocet clankov, a pripravi pocet stran
         $countArticles = sizeof($articles);
         $modulo = $countArticles % 5;
         if ($modulo == 0) {
             $this->data['pages'] = $countArticles / 5;
         } else {
             $this->data['pages'] = intval($countArticles / 5 + 1);
         }
         $this->data['currentPage'] = 1;
         //aktualna strana
         //hlavicka stranky
         $this->head = array('title' => 'Zverejnené články', 'key_words' => 'coding.wz.sk - články', 'description' => 'Zverejnené články');
         $this->view = 'articles';
     }
     //ak je zadane URL pre zobrazenie nepublikovanych clankov
     if (!empty($parameters[0]) && $parameters[0] == 'unpublished') {
         $articles = $articleManager->returnUnpublishedArticles();
         $this->data['articles'] = $validation->statusOfArticles($articles);
         if (sizeof($articles) == 0) {
             $this->createMessage('Žiadne články na zobrazenie', 'info');
         }
         //hlavicka stranky
         $this->head = array('title' => 'Nezverejnené články', 'key_words' => 'coding.wz.sk', 'description' => 'Nezverejnené články');
         $this->view = 'articles';
     }
     //ak je zadane URL pre zobrazenie konkretnej strany
     if (!empty($parameters[0]) && $parameters[0] == 'page') {
         //ak je zadane cislo strany
         if (!empty($parameters[1]) && is_numeric($parameters[1])) {
             if ($parameters[1] == 1) {
                 $offset = 0;
             } else {
                 $offset = $parameters[1] * 5 - 5;
             }
             //zisti pocet clankov, a pripravi pocet stran
             $articles = $articleManager->returnPublicArticles(0);
             //vsetky clanky
             $countArticles = sizeof($articles);
             $modulo = $countArticles % 5;
             if ($modulo == 0) {
                 $this->data['pages'] = $countArticles / 5;
             } else {
                 $this->data['pages'] = intval($countArticles / 5 + 1);
             }
             $this->data['currentPage'] = $parameters[1];
             //aktualna strana
             //vratenie clankov s pozadovanym offsetom
             $articles = $articleManager->returnPublicArticles($offset);
             $this->data['articles'] = $validation->statusOfArticles($articles);
             if (sizeof($articles) == 0) {
                 $this->createMessage('Žiadne články na zobrazenie', 'info');
             }
             //hlavicka stranky
             $this->head = array('title' => 'Zverejnené články - Strana ' . $parameters[1], 'key_words' => 'coding.wz.sk - články', 'description' => 'Zverejnené články');
             $this->view = 'articles';
         } else {
             $this->redirect('clanky');
         }
     }
     //ak je zadane URL pre zmazanie clanku
     if (!empty($parameters[1]) && $parameters[1] == 'odstranit' && $parameters[0] != 'page') {
         //overi ci clanok z URL existuje
         if (!$article) {
             $this->redirect('chyba');
         }
         //ak je clanok nepublikovany a je prihlaseny autor tohoto clanku
         if ($article['public'] == 0 && $article['author'] == $user['name']) {
             $articleManager->deleteArticle($parameters[0]);
         } else {
             //overi ci je prihlaseny admin
             $this->checkUser(true);
             $articleManager->deleteArticle($parameters[0]);
         }
         $this->createMessage('Článok bol odstránený', 'success');
         $this->redirect('clanky');
     }
     //ak je zadane URL pre publikovanie clanku
     if (!empty($parameters[1]) && $parameters[1] == 'publikovat' && $parameters[0] != 'page') {
         //overi ci clanok z URL existuje
         if (!$article) {
             $this->redirect('chyba');
//.........这里部分代码省略.........
开发者ID:tomas3093,项目名称:cms-blog,代码行数:101,代码来源:ClankyController.php


注:本文中的UserManager::returnUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。