遇到错误消息显示严重性:通知消息:

时间:2015-04-17 01:14:24

标签: codeigniter

在我的控制器上进行开发我在控制器的开始php标签下面添加了 error_reporting(0); 。所以不会显示一些错误。

进入实时模式并删除或注释掉添加的error_reporting(0);我收到了一些错误

  

遇到PHP错误严重性:通知消息:未定义   变量:other_sub文件名:common / Filemanager.php

     

遇到PHP错误严重性:通知消息:未定义   变量:histSub文件名:common / Filemanager.php

问题:我定义了那些变量并不确定错误显示的原因?

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

//error_reporting(0);

class Filemanager extends MX_Controller {

public function __construct() {
parent::__construct();
    $this->load->library('pagination');
    $this->lang->load('admin/common/filemanager', 'english');
    $this->load->model('admin/tool/model_tool_image');
}

public function index() {
$directory = FCPATH . 'image/catalog/';

$element = $this->input->get('element'); // Element
$input = $this->input->get('input'); // Target
$sub_get = $this->input->get("sub"); // Sub Folders

$end_url = '?';
$end_url .= 'input='.$input;
$end_url .= '&element='.$element;
$endHist = $end_url;
$uris = $this->uri->segment_array();

$sub_folder = "";        

if ($sub_get) {
    $sub_folder = $sub_get;
}  

if ($sub_folder) { 

    $end_url .= '&sub=' .$sub_folder;

    if (sizeof($uris) >3 ) {

    for ($i=3; $i < sizeof($uris); $i++) { 

        $directory .= $uris[$i].'/';    
        $other_sub .= $uris[$i].'/';

    }

        $directory .= $sub_folder.'/';
        $other_sub .= $sub_folder.'/';

    } else {           

        $directory .= $sub_folder.'/';
        $other_sub = $sub_folder.'/';

    }
}

$data['images'] = array();

// Get directories
$directories = glob($directory . '*', GLOB_ONLYDIR);

if (!$directories) {
$directories = array();
}

// Get files
$files = glob($directory.'*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE);

if (!$files) {
$files = array();
}

// Merge directories and files
$images = array_merge($directories, $files);

// Get total number of files and directories
$image_total = count($images);

$per_page = 8;
$segment = $this->input->get('per_page');
$segment += $per_page;

foreach ($images as $key => $image) {           

if ($key < $segment && $key >= $segment-$per_page) {            

$name = str_split(basename($image), 18);                 

if (is_dir($image)) {

$data['images'][] = array(
    'thumb' => '',
    'name' => implode(' ', $name),
    'type' => 'directory',                        
    'path' => utf8_substr($image, utf8_strlen(FCPATH .'image/')),
    'href' => site_url('admin/filemanager') .'/'. utf8_substr($image, utf8_strlen(FCPATH . 'image/catalog/')),  
);

} elseif (is_file($image)) {

$subDirect = 'catalog/'.$other_sub;

$data['images'][] = array(
    'thumb' => $this->model_tool_image->resize(utf8_substr($image, utf8_strlen(DIR_IMAGE)), 100, 100),
    'name' => implode(' ', $name),
    'type' => 'image',
    'path' => $subDirect.utf8_substr($image, utf8_strlen($directory)), 
    'href' => base_url() . 'image/' . utf8_substr($image, utf8_strlen(FCPATH . 'image/catalog/'))
);                 

}

}

}

$data['title'] = "Image Manager";
$data['heading_title'] = "Image Manager";

if (isset($sub_folder)) {
$data['directory'] = $this->uri->segment(3) .'/'. $this->uri->segment(4);
} else {
$data['directory'] = '';
}

if ($element) {
    $data['element'] = $element;
} else {
    $data['element'] = "";
}

if ($input) {
    $data['target'] = $input;
} else {
    $data['target'] = "";
}

$endRep = $end_url == '?' ? '' : rtrim($end_url,'&');

// Sets go to previous parent folder.
if ($other_sub) {
    $arraySub = explode('/', rtrim($other_sub,'/'));    
    unset($arraySub[sizeof($arraySub) -1]);
    $histSub = "";
    foreach ($arraySub as $one) {
        $histSub .= $one.'/';
    }

    $endHist .= "&sub=".$arraySub[sizeof($arraySub) - 1];        
}

// Parent folder link         
$data['parent'] = site_url('admin/filemanager') .'/'. $histSub . $endHist;

// Refesh current Page
$data['refresh'] =  current_url().$endRep;

$config['base_url'] = base_url('admin/filemanager/') .'/'. $other_sub.$endRep;
$config['end_url'] = $end_url == '?' ? '' : rtrim($end_url,'&');
$config['total_rows'] = $image_total;  
$config['per_page'] = $per_page;
$config['page_query_string'] = TRUE;
$config['num_links'] = "16";
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";

$this->pagination->initialize($config);

$data['pagination'] = $this->pagination->create_links();

return $this->load->view('template/common/filemanager_view', $data);
}

}

1 个答案:

答案 0 :(得分:0)

问题现在解决了我必须改变一些事情并使输入 - >设置更简单现在工作正常。

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Filemanager extends MX_Controller {

public function __construct() {
    parent::__construct();
    $this->load->library('pagination');
    $this->lang->load('admin/common/filemanager', 'english');
    $this->load->model('admin/tool/model_tool_image');
}

public function index() {

    $input_get_directory = $this->input->get('directory');
    $input_get_page = $this->input->get('page');
    $input_get_filter = $this->input->get('filter_name');
    $input_get_target = $this->input->get('target');
    $input_get_thumb = $this->input->get('thumb');

    if (isset($input_get_filter)) {
        $filter_name = $input_get_filter .'/';
    } else {
        $filter_name = null;
    }

    // Make sure we have the correct directory
    if (isset($input_get_directory)) {

        $directory = FCPATH . 'image/catalog/' . $input_get_directory;

    } else {

        // Do not add extra tralier slash at end /
        $directory = FCPATH . 'image/catalog'; 
    }

    if (isset($input_get_page)) {
        $page = $input_get_page;
    } else {
        $page = 1;
    }

    $data['images'] = array();

    // Get directories
    $directories = glob($directory . '/' . $filter_name  . '*', GLOB_ONLYDIR);

    if (!$directories) {
        $directories = array();
    }

    // Get files
    $files = glob($directory . '/' . $filter_name . '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE);

    if (!$files) {
        $files = array();
    }

    // Merge directories and files
    $images = array_merge($directories, $files);

    // Get total number of files and directories
    $image_total = count($images);

    // Split the array based on current page number and max number of items per page of 10
    $images = array_splice($images, ($page - 1) * 16, 16);

    foreach ($images as $image) {
        $name = str_split(basename($image), 14);

        if (is_dir($image)) {

            $url = '';

            if (isset($input_get_target)) {
                $url .= '&target=' . $input_get_target;
            }

            if (isset($input_get_thumb)) {
                $url .= '&thumb=' . $input_get_thumb;
            }

            $data['images'][] = array(
                'thumb' => '',
                'name'  => implode(' ', $name),
                'type'  => 'directory',
                'path'  => utf8_substr($image, utf8_strlen(FCPATH . 'image/')),
                'href'  => site_url('admin/common/filemanager' . '?&token=' . $this->session->userdata('token') . '?&directory=' . utf8_substr($image, utf8_strlen(FCPATH . 'image/' . 'catalog/')) . $url)
            );

        } elseif (is_file($image)) {

            $data['images'][] = array(
                'thumb' => $this->model_tool_image->resize(utf8_substr($image, utf8_strlen(FCPATH . 'image/')), 100, 100),
                'name'  => implode(' ', $name),
                'type'  => 'image',
                'path'  => utf8_substr($image, utf8_strlen(FCPATH . 'image/')),
                'href'  => base_url() . 'image/' . utf8_substr($image, utf8_strlen(FCPATH . 'image/'))
            );
        }
    }

    $data['heading_title'] = "Image Manager";

    $data['text_no_results'] = "No Results";
    $data['text_confirm'] = "Are You Sure";

    $data['entry_search'] = "Search..";
    $data['entry_folder'] = "New Folder";

    $data['button_parent'] = "Parent";
    $data['button_refresh'] = "Refresh";
    $data['button_upload'] = "Upload";
    $data['button_folder'] = "New Folder";
    $data['button_delete'] = "Delete";
    $data['button_search'] = "Search";

    // Session token for ajax
    $data['token'] = $this->session->userdata('token');

    if (isset($input_get_directory)) {
        $data['directory'] = $input_get_directory;
    } else {
        $data['directory'] = '';
    }

    // Return the filter name
    if (isset($input_get_filter)) {
        $data['filter_name'] = $input_get_filter;
    } else {
        $data['filter_name'] = '';
    }

    // Return the target ID for the file manager to set the value
    if (isset($input_get_target)) {
        $data['target'] = $input_get_target;
    } else {
        $data['target'] = '';
    }

    // Return the thumbnail for the file manager to show a thumbnail
    if (isset($input_get_thumb)) {
        $data['thumb'] = $input_get_thumb;
    } else {
        $data['thumb'] = '';
    }

    // Parent
    $url = '';

    if (isset($input_get_directory)) {
        $pos = strrpos($input_get_directory, '/');

        if ($pos) {
            $url .= '?&directory=' . substr($input_get_directory, 0, $pos);
        }
    }

    $data['parent'] = site_url('admin/common/filemanager' .'?&token='. $this->session->userdata('token') . $url);

    // Refresh
    $url = '';

    if (isset($input_get_directory)) {
        $url .= '?&directory=' . $input_get_directory;
    }

    $data['refresh'] = site_url('admin/common/filemanager' .'?&token='. $this->session->userdata('token') . $url);

    $this->load->view('template/common/filemanager_view', $data);
}
}