當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Url::generateUrl方法代碼示例

本文整理匯總了PHP中helpers\Url::generateUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::generateUrl方法的具體用法?PHP Url::generateUrl怎麽用?PHP Url::generateUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在helpers\Url的用法示例。


在下文中一共展示了Url::generateUrl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: edit

 public function edit($id)
 {
     $data['title'] = 'Edit Category';
     $data['token'] = Csrf::makeToken();
     $data['row'] = $this->model->get_category($id);
     $data['categories'] = $this->model->get_categories();
     if (isset($_POST['submit'])) {
         if ($_POST['token'] != Session::get('token')) {
             Url::redirect('admin/login');
         }
         $category_name = $_POST['category_name'];
         $category_id_parent = $_POST['category_id_parent'];
         $category_description = $_POST['category_description'];
         if ($category_name == '') {
             $error[] = 'Name is required';
         }
         if (!$error) {
             $postdata = array('category_name' => $category_name, 'category_id_parent' => $category_id_parent, 'category_description' => $category_description);
             $where = array('category_id' => $id);
             $this->model->update_category($postdata, $where);
             Session::set('message', 'Category Updated');
             Url::redirect('admin/categories/edit/' . $id . '');
         }
     }
     if (isset($_POST['seo'])) {
         if ($_POST['token'] != Session::get('token')) {
             Url::redirect('admin/login');
         }
         $category_title = $_POST['category_title'];
         $category_meta_desc = $_POST['category_meta_desc'];
         $category_meta_robots = $_POST['category_meta_robots'];
         $category_url = $_POST['category_url'];
         if ($category_url == '') {
             $error[] = 'Url is required';
         }
         if (!$error) {
             $postdata = array('category_title' => $category_title, 'category_meta_desc' => $category_meta_desc, 'category_meta_robots' => $category_meta_robots, 'category_url' => Url::generateUrl($category_url));
             $where = array('category_id' => $id);
             $this->model->update_category($postdata, $where);
             Session::set('message', 'SEO Informations Updated');
             Url::redirect('admin/categories/edit/' . $id . '');
         }
     }
     if (isset($_POST['image'])) {
         if ($_POST['token'] != Session::get('token')) {
             Url::redirect('admin/login');
         }
         if ($_FILES['category_image']['size'] > 0) {
             if (!is_dir('images/categories/' . $id . '')) {
                 mkdir('images/categories/' . $id . '');
             }
             $extension_img = substr($_FILES['category_image']['name'], -4);
             $name_without_extension = substr($_FILES['category_image']['name'], 0, -4);
             $image_name = Url::generateUrl($name_without_extension) . $extension_img;
             //var_dump($_FILES['brand_image']['name']); exit;
             $file = 'images/categories/' . $id . '/' . $image_name;
             $file_mini = 'images/categories/' . $id . '/m-' . $image_name;
             move_uploaded_file($_FILES['category_image']['tmp_name'], $file);
             move_uploaded_file($_FILES['category_image']['tmp_name'], $file_mini);
             $img = new SimpleImage($file);
             $img->save($file, 70);
             $img_mini = new SimpleImage($file);
             $img_mini->load($file)->fit_to_width(300)->fit_to_height(300)->save($file_mini);
             $postdata = array('category_image' => $file);
             $where = array('category_id' => $id);
             $this->model->update_category($postdata, $where);
             Session::set('message', 'Image Updated');
             Url::redirect('admin/categories/edit/' . $id . '');
         }
     }
     View::renderadmintemplate('header', $data);
     View::render('admin/categories/edit', $data, $error);
     View::renderadmintemplate('footer', $data);
 }
開發者ID:T-PHP,項目名稱:Simple-MVC-Blog,代碼行數:74,代碼來源:Categories.php

示例2: edit

 public function edit($id)
 {
     $data['title'] = 'Edit Post';
     $data['token'] = Csrf::makeToken();
     $data['row'] = $this->posts->get_post($id);
     $data['posts'] = $this->posts->get_posts();
     $data['categories'] = $this->categories->get_all_categories();
     if (isset($_POST['submit'])) {
         if ($_POST['token'] != Session::get('token')) {
             Url::redirect('admin/login');
         }
         $post_name = $_POST['post_name'];
         $post_category_id = $_POST['post_category_id'];
         $post_short_description = $_POST['post_short_description'];
         $post_long_description = $_POST['post_long_description'];
         if ($post_name == '') {
             $error[] = 'Name is required';
         }
         if (!$error) {
             $postdata = array('post_name' => $post_name, 'post_category_id' => $post_category_id, 'post_short_description' => $post_short_description, 'post_long_description' => $post_long_description, 'post_modified' => (new \DateTime())->format('Y-m-d H:i:s'));
             $where = array('post_id' => $id);
             $this->posts->update_post($postdata, $where);
             Session::set('message', 'Post Updated');
             Url::redirect('admin/posts/edit/' . $id . '');
         }
     }
     if (isset($_POST['seo'])) {
         if ($_POST['token'] != Session::get('token')) {
             Url::redirect('admin/login');
         }
         $post_title = $_POST['post_title'];
         $post_meta_description = $_POST['post_meta_description'];
         $post_meta_robots = $_POST['post_meta_robots'];
         $post_url = $_POST['post_url'];
         if ($post_url == '') {
             $error[] = 'Url is required';
         }
         if (!$error) {
             $postdata = array('post_title' => $post_title, 'post_meta_description' => $post_meta_description, 'post_meta_robots' => $post_meta_robots, 'post_url' => Url::generateUrl($post_url), 'post_modified' => (new \DateTime())->format('Y-m-d H:i:s'));
             $where = array('post_id' => $id);
             $this->posts->update_post($postdata, $where);
             Session::set('message', 'SEO Informations Updated');
             Url::redirect('admin/posts/edit/' . $id . '');
         }
     }
     if (isset($_POST['image'])) {
         if ($_POST['token'] != Session::get('token')) {
             Url::redirect('admin/login');
         }
         if ($_FILES['post_image']['size'] > 0) {
             if (!is_dir('images/posts/' . $id . '')) {
                 mkdir('images/posts/' . $id . '');
             }
             $extension_img = substr($_FILES['post_image']['name'], -4);
             $name_without_extension = substr($_FILES['post_image']['name'], 0, -4);
             $image_name = Url::generateUrl($name_without_extension) . $extension_img;
             //var_dump($_FILES['brand_image']['name']); exit;
             $file = 'images/posts/' . $id . '/' . $image_name;
             $file_mini = 'images/posts/' . $id . '/m-' . $image_name;
             move_uploaded_file($_FILES['post_image']['tmp_name'], $file);
             move_uploaded_file($_FILES['post_image']['tmp_name'], $file_mini);
             $img = new SimpleImage($file);
             $img->save($file, 70);
             $img_mini = new SimpleImage($file);
             $img_mini->load($file)->fit_to_width(850)->fit_to_height(355)->save($file_mini);
             $postdata = array('post_image' => $image_name, 'post_modified' => (new \DateTime())->format('Y-m-d H:i:s'));
             $where = array('post_id' => $id);
             $this->posts->update_post($postdata, $where);
             Session::set('message', 'Image Updated');
             Url::redirect('admin/posts/edit/' . $id . '');
         }
     }
     View::renderadmintemplate('header', $data);
     View::render('admin/posts/edit', $data, $error);
     View::renderadmintemplate('footer', $data);
 }
開發者ID:T-PHP,項目名稱:Simple-MVC-Blog,代碼行數:76,代碼來源:Posts.php


注:本文中的helpers\Url::generateUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。