本文整理汇总了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);
}
示例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);
}