Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
private $modules_permissions = array(
//сначала пусть идут основные модули, а потом
//разрешения для модуля статей
'ArticleAdmin' => 'articles',
'ArticlesAdmin' => 'articles',
'ArticleCategoryAdmin' => 'articles',
'ArticleCategoriesAdmin' => 'articles'
);
<?php
require_once('api/Newcms.php');
############################################
# Class Category - Edit the good gategory
############################################
class ArticlesCategoryAdmin extends Newcms
{
private $allowed_image_extentions = array('png', 'gif', 'jpg', 'jpeg', 'ico');
function fetch()
{
if($this->request->method('post'))
{
$category->id = $this->request->post('id', 'integer');
$category->parent_id = $this->request->post('parent_id', 'integer');
$category->name = $this->request->post('name');
$category->visible = $this->request->post('visible', 'boolean');
$category->url = $this->request->post('url', 'string');
$category->meta_title = $this->request->post('meta_title');
$category->meta_keywords = $this->request->post('meta_keywords');
$category->meta_description = $this->request->post('meta_description');
$category->description = $this->request->post('description');
// Не допустить одинаковые URL разделов.
if(($c = $this->articles_categories->get_articles_category($category->url)) && $c->id!=$category->id)
{
$this->design->assign('message_error', 'url_exists');
}
else
{
if(empty($category->id))
{
$category->id = $this->articles_categories->add_articles_category($category);
$this->design->assign('message_success', 'added');
}
else
{
$this->articles_categories->update_articles_category($category->id, $category);
$this->design->assign('message_success', 'updated');
}
// Удаление изображения
if($this->request->post('delete_image'))
{
$this->articles_categories->delete_image($category->id);
}
// Загрузка изображения
$image = $this->request->files('image');
if(!empty($image['name']) && in_array(strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)), $this->allowed_image_extentions))
{
$this->articles_categories->delete_image($category->id);
move_uploaded_file($image['tmp_name'], $this->root_dir.$this->config->categories_images_dir.$image['name']);
$this->articles_categories->update_articles_category($category->id, array('image'=>$image['name']));
}
$category = $this->articles_categories->get_articles_category(intval($category->id));
}
}
else
{
$category->id = $this->request->get('id', 'integer');
$category = $this->articles_categories->get_articles_category($category->id);
}
$articles_categories = $this->articles_categories->get_articles_categories_tree();
$this->design->assign('category', $category);
$this->design->assign('articles_categories', $articles_categories);
return $this->design->fetch('articles_category.tpl');
}
}
<?PHP
require_once('api/Newcms.php');
class ArticleAdmin extends Newcms
{
public function fetch()
{
if($this->request->method('post'))
{
$post->id = $this->request->post('id', 'integer');
$post->name = $this->request->post('name');
$post->date = date('Y-m-d', strtotime($this->request->post('date')));
$post->visible = $this->request->post('visible', 'boolean');
$post->category_id = $this->request->post('category_id', 'integer');
$post->url = $this->request->post('url', 'string');
$post->meta_title = $this->request->post('meta_title');
$post->meta_keywords = $this->request->post('meta_keywords');
$post->meta_description = $this->request->post('meta_description');
$post->annotation = $this->request->post('annotation');
$post->text = $this->request->post('body');
// Не допустить одинаковые URL разделов.
if(($a = $this->articles->get_article($post->url)) && $a->id!=$post->id)
{
$this->design->assign('message_error', 'url_exists');
}
else
{
if(empty($post->id))
{
$post->id = $this->articles->add_article($post);
$post = $this->articles->get_article($post->id);
$this->design->assign('message_success', 'added');
}
else
{
$this->articles->update_article($post->id, $post);
$post = $this->articles->get_article($post->id);
$this->design->assign('message_success', 'updated');
}
}
}
else
{
$post->id = $this->request->get('id', 'integer');
$post = $this->articles->get_article(intval($post->id));
}
if(empty($post->date))
$post->date = date($this->settings->date_format, time());
$this->design->assign('post', $post);
// Категории
$articles_categories = $this->articles_categories->get_articles_categories_tree();
$this->design->assign('articles_categories', $articles_categories);
return $this->design->fetch('article.tpl');
}
}
$category = new stdClass();