Помощь Проблемы с модулем статей!

Sysfaray

Гуру форума
Регистрация
7 Окт 2007
Сообщения
175
Реакции
88
У кого установлено данный модуль, выложите пожалуйста содержание 2х файлов (api\managers.php и admin\IndexAdmin.php)
Зарание благодарю!
 
В api\managers.php в массиве $permissions_list должен быть элемент articles
В admin\IndexAdmin.php в массиве $modules_permissions должно быть так:

PHP:
private $modules_permissions = array(
        //сначала пусть идут основные модули, а потом
        //разрешения для модуля статей
        'ArticleAdmin'        => 'articles',
        'ArticlesAdmin'        => 'articles',
        'ArticleCategoryAdmin'        => 'articles',
        'ArticleCategoriesAdmin'        => 'articles'
);
 
пара ошибок:
Strict standards: Creating default object from empty value in G:\OpenServer\domains\localhost\admin\ArticlesCategoryAdmin.php on line 64
Код:
<?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');
    }
}

Strict standards: Creating default object from empty value in G:\OpenServer\domains\localhost\admin\ArticleAdmin.php on line 51

Код:
<?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');
    }
}


Собственно 64 и 51 строка этих файлов :

$category->id = $this->request->get('id', 'integer');
 
Это происходит потому, что объекты $category и $post создаются не заранее, а при присвоении им свойства. Чтобы такого не происходило, нужно предварительно их создать:
PHP:
$category = new stdClass();
Однако в коде симплы такое происходит сплошь и рядом. Поэтому проще отключить вывод ошибок уровня E_STRICT
 
заменил
Код:
$category->id = $this->request->get('id', 'integer');
на
Код:
$category = new stdClass();
$category->id = $this->request->get('id', 'integer');

Проблема решилась!
 
Назад
Сверху