Codeigniter最大控制器长度

时间:2015-07-13 12:21:56

标签: php codeigniter

codeigniter中是否有最大长度的控制器类? 对我来说一个控制器没有工作,但当我删除一些行时,相同的代码开始工作。有谁知道发生了什么事?

工作代码:

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class C_Object_details extends CI_Controller {

    function __construct() {
        parent::__construct();
        respoti_profiler();
        $this->load->library('session');
        $this->load->model('m_object_details');
        $this->params['set_tag'] = array();
        $this->params['title_auto'] = true;
    }
    protected function convert_meta_results($result_meta) {
        $meta_list = array();
        foreach ($result_meta as $value) {
            $meta_list[$value['meta_key']] = $value['meta_value'];
        }
        return $meta_list;
    }

    public function index() {
        $id = (int) $this->uri->segment(2);

        $object = $this->m_object_details->get_object($id);

        if (empty($object)) {
            show_404(sprintf('Brak obiektu o id: %s', $id));
        }
        $result_meta = $this->m_object_details->get_object_meta($id);
        $meta_list = $this->convert_meta_results($result_meta);
        unset($result_meta);

        $rooms = array();
        if ($object['post_url'] === 'hotel') {
            $room_list = $this->m_object_details->get_room_list($object['post_code']);

            foreach ($room_list as $key => $val) {
                $where_in[] = $val['room_id'];
            }

            /* pobranie danych meta pokoi */
            $room_meta_list = $this->m_object_details->get_room_meta($where_in);

            foreach ($room_meta_list as $key => $value) {
                $rooms[$value['metaroom_room_id']]['meta'][$value['metaroom_key']] = $value['metaroom_value'];
            }

            foreach ($room_list as $key => $val) {
                $rooms[$val['room_id']]['room'] = $val;
            }

            unset($room_list, $room_meta_list);
        }

        //wygenerowanie listy atrybutow pokoi
        $rooms_pref = array();
        foreach ($rooms as $value) {
            if (isset($value['meta'])) {
                foreach ($value['meta'] as $key1 => $value) {
                    if (strpos($key, 'pref-') === false) {
                        continue;
                    }
                    $rooms_pref[$key1] = $value;
                }
            }
        }

        ## OPINIE ##
        $count = 0;
        $opinia = 0;

        $arr_opinion = array();

        if (isset($meta_list['obj_booking_opinion'])) {
            $arr_opinion[] = $meta_list['obj_booking_opinion'];
        }

        if (isset($meta_list['obj_google_opinion'])) {
            $arr_opinion[] = $meta_list['obj_google_opinion'];
        }

        if (isset($meta_list['obj_hrs_opinion'])) {
            $arr_opinion[] = $meta_list['obj_hrs_opinion'];
        }

        if (isset($meta_list['obj_ta_opinion'])) {
            $arr_opinion[] = $meta_list['obj_ta_opinion'];
        }

        foreach ($arr_opinion as $value) {
            $tmp_value = 0 + ( str_replace(',', '.', $value) );
            if ($tmp_value > 0) {
                $count++;
                $opinia += $tmp_value;
            }
        }

        if ($count === 0) {
            $opinia = 0;
        } else {
            $opinia = round($opinia / $count, 1);
        }

        if ($opinia < 10) {
            $opinia = number_format($opinia, 1, '.', '');
        }


        $arr_opinioncount = array();
        if (isset($meta_list['obj_booking_opinioncount'])) {
            $arr_opinioncount[] = $meta_list['obj_booking_opinioncount'];
        }

        if (isset($meta_list['obj_hrs_opinioncount'])) {
            $arr_opinioncount[] = $meta_list['obj_hrs_opinioncount'];
        }

        if (isset($meta_list['obj_google_opinioncount'])) {
            $arr_opinioncount[] = $meta_list['obj_google_opinioncount'];
        }

        if (isset($meta_list['obj_ta_opinioncount'])) {
            $arr_opinioncount[] = $meta_list['obj_ta_opinioncount'];
        }

        $ilosc_opini = 0;
        foreach ($arr_opinioncount as $value) {
            $ilosc_opini += $value;
        }


        ## KONIEC OPINI ##
        ## LINKI DO GALERI ##
        $link_thumb = 'http://exifex.pl/system/uploads/300/';
        $link_full = 'http://exifex.pl/system/uploads/';

        $gallery_thumb = glob(sprintf("/home/respoti/domains/exifex.pl/public_html/system/uploads/300/%s*", $object['post_code']));
        $gallery_full = glob(sprintf("/home/respoti/domains/exifex.pl/public_html/system/uploads/%s*", $object['post_code']));
        ## KONIEC LINKI DO GALERII ##
        ## hotele wyciag 



        if (isset($meta_list['attraction_price'])) {
            $atr_price = $meta_list['attraction_price'];
        } else
            $atr_price = null;
        if (isset($meta_list['rest_pricerange'])) {
            $rest_price_range = $meta_list['rest_pricerange'];
        } else {
            $rest_price_range = null;
        }


//dodane dzis
        if (isset($meta_list['attraction_eventsorganized'])) {
            $attr_type = $meta_list['attraction_eventsorganized'];
        } else {
            $attr_type = null;
        }

        if (isset($meta_list['rest_openhoursrange_start'])) {
            $pn_pt = $meta_list['rest_openhoursrange_start'];
        } else {
            $pn_pt = null;
        }
        if (isset($meta_list['rest_openhoursrange_end'])) {
            $pn_pt_e = $meta_list['rest_openhoursrange_end'];
        } else {
            $pn_pt_e = null;
        }

        if (isset($meta_list['rest_openhoursweekend_start'])) {
            $pt = $meta_list['rest_openhoursweekend_start'];
        } else {
            $pt = null;
        }
        if (isset($meta_list['rest_openhoursweekend_end'])) {
            $pt_e = $meta_list['rest_openhoursweekend_end'];
        } else {
            $pt_e = null;
        }

        if (isset($meta_list['rest_openhourssunday_start'])) {
            $sun = $meta_list['rest_openhourssunday_start'];
        } else {
            $sun = null;
        }
        if (isset($meta_list['rest_openhourssunday_end'])) {
            $sun_e = $meta_list['rest_openhourssunday_end'];
        } else {
            $sun_e = null;
        }


        if (isset($meta_list['nightlife_openhourssunday_start'])) {
            $n_sun = $meta_list['nightlife_openhourssunday_start'];
        } else {
            $n_sun = null;
        }
        if (isset($meta_list['nightlife_openhourssunday_end'])) {
            $n_sun_e = $meta_list['nightlife_openhourssunday_end'];
        } else {
            $n_sun_e = null;
        }

        if (isset($meta_list['nightlife_openhoursweekend_start'])) {
            $n_pt = $meta_list['nightlife_openhoursweekend_start'];
        } else {
            $n_pt = null;
        }
        if (isset($meta_list['nightlife_openhoursweekend_end'])) {
            $n_pt_e = $meta_list['nightlife_openhoursweekend_end'];
        } else {
            $n_pt_e = null;
        }

        if (isset($meta_list['nightlife_openhoursrange_start'])) {
            $n_pn_pt = $meta_list['nightlife_openhoursrange_start'];
        } else {
            $n_pn_pt = null;
        }
        if (isset($meta_list['nightlife_openhoursrange_end'])) {
            $n_pn_pt_e = $meta_list['nightlife_openhoursrange_end'];
        } else {
            $n_pn_pt_e = null;
        }

        if (isset($meta_list['nightlife_open_1_start'])) {
            $pn_1 = $meta_list['nightlife_open_1_start'];
        } else
            $pn_1 = null;
        if (isset($meta_list['nightlife_open_1_end'])) {
            $pn_2 = $meta_list['nightlife_open_1_end'];
        } else
            $pn_2 = null;
        if (isset($meta_list['nightlife_open_2_start'])) {
            $wt_1 = $meta_list['nightlife_open_2_start'];
        } else
            $wt_1 = null;
        if (isset($meta_list['nightlife_open_2_end'])) {
            $wt_2 = $meta_list['nightlife_open_2_end'];
        } else
            $wt_2 = null;
        if (isset($meta_list['nightlife_open_3_start'])) {
            $sr_1 = $meta_list['nightlife_open_3_start'];
        } else
            $sr_1 = null;
        if (isset($meta_list['nightlife_open_3_end'])) {
            $sr_2 = $meta_list['nightlife_open_3_end'];
        } else
            $sr_2 = null;

        if (isset($meta_list['nightlife_open_4_start'])) {
            $czw_1 = $meta_list['nightlife_open_4_start'];
        } else
            $czw_1 = null;
        if (isset($meta_list['nightlife_open_4_end'])) {
            $czw_2 = $meta_list['nightlife_open_4_end'];
        } else
            $czw_2 = null;

        if (isset($meta_list['nightlife_open_5_start'])) {
            $pt_1 = $meta_list['nightlife_open_5_start'];
        } else
            $pt_1 = null;
        if (isset($meta_list['nightlife_open_5_end'])) {
            $pt_2 = $meta_list['nightlife_open_5_end'];
        } else
            $pt_2 = null;


        if (isset($meta_list['nightlife_open_6_start'])) {
            $sob_1 = $meta_list['nightlife_open_6_start'];
        } else
            $sob_1 = null;
        if (isset($meta_list['nightlife_open_6_end'])) {
            $sob_2 = $meta_list['nightlife_open_6_end'];
        } else
            $sob_2 = null;


        if (isset($meta_list['nightlife_open_7_start'])) {
            $nd_1 = $meta_list['nightlife_open_7_start'];
        } else
            $nd_1 = null;
        if (isset($meta_list['nightlife_open_7_end'])) {
            $nd_2 = $meta_list['nightlife_open_7_end'];
        } else
            $nd_2 = null;


//rest
        if (isset($meta_list['rest_open_1_start'])) {
            $r_pn_1 = $meta_list['rest_open_1_start'];
        } else
            $r_pn_1 = null;
        if (isset($meta_list['rest_open_1_end'])) {
            $r_pn_2 = $meta_list['rest_open_1_end'];
        } else
            $r_pn_2 = null;

        if (isset($meta_list['rest_open_2_start'])) {
            $r_wt_1 = $meta_list['rest_open_2_start'];
        } else
            $r_wt_1 = null;
        if (isset($meta_list['rest_open_2_end'])) {
            $r_wt_2 = $meta_list['rest_open_2_end'];
        } else
            $r_wt_2 = null;

        if (isset($meta_list['rest_open_3_start'])) {
            $r_sr_1 = $meta_list['rest_open_3_start'];
        } else
            $r_sr_1 = null;
        if (isset($meta_list['rest_open_3_end'])) {
            $r_sr_2 = $meta_list['rest_open_3_end'];
        } else
            $r_sr_2 = null;
        if (isset($meta_list['rest_open_4_start'])) {
            $r_czw_1 = $meta_list['rest_open_4_start'];
        } else
            $r_czw_1 = null;
        if (isset($meta_list['rest_open_4_end'])) {
            $r_czw_2 = $meta_list['rest_open_4_end'];
        } else $r_czw_2 = null;

        if (isset($meta_list['rest_open_5_start'])) {
            $r_pt_1 = $meta_list['rest_open_5_start'];
        } else $r_pt_1 = null;
        if (isset($meta_list['rest_open_5_end'])) {
            $r_pt_2 = $meta_list['rest_open_5_end'];
        } else
            $r_pt_2 = null;

        if (isset($meta_list['rest_open_6_start'])) {
            $r_sob_1 = $meta_list['rest_open_6_start'];
        } else
            $r_sob_1 = null;
        if (isset($meta_list['rest_open_6_end'])) {
            $r_sob_2 = $meta_list['rest_open_6_end'];
        } else
            $r_sob_2 = null;


        if (isset($meta_list['rest_open_7_start'])) {
            $r_nd_1 = $meta_list['rest_open_7_start'];
        } else
            $r_nd_1 = null;
        if (isset($meta_list['rest_open_7_end'])) {
            $r_nd_2 = $meta_list['rest_open_7_end'];
        } else
            $r_nd_2 = null;
        $params = array(
            'object' => $object,'meta' => $meta_list,'rooms' => $rooms,
            'rooms_pref' => $rooms_pref,'opinia' => $opinia,'opinia_opisowa' => config('opinia_opisowa'),
            'ilosc_opini' => $ilosc_opini,
            'link_thumb' => $link_thumb,
            'link_full' => $link_full,
            'gallery_thumb' => $gallery_thumb,
            'gallery_full' => $gallery_full,
            'title' => $object['post_title'],
            'email' => $meta_list['email_object'],
            'web' => $meta_list['obj_site'],
            'phone' => $meta_list['obj_phone'],
            'typ' => $object['post_url'], 
            'adres' => $object['post_address'],
            'post_code' => $object['post_post'],
            'fb' => $meta_list['obj_fb'],
            'pref' => $this->m_object_details->get_pref($id),
            'typ_hot' => $object['post_object_type'],
            'kuchnia' => $this->m_object_details->get_kitchen($id),
            'rcena' => $rest_price_range,
            'acena' => $atr_price,
            'typ_obj' => $this->m_object_details->get_smth($id, 'attraction_eventsorganized'),
            'pn_pt' => $pn_pt,'pn_pt_e' => $pn_pt_e,'pt' => $pt,'pt_e' => $pt_e,'sun' => $sun,
            'sun_e' => $sun_e,'n_pn_pt' => $n_pn_pt,
            'n_pn_pt_e' => $n_pn_pt_e,'n_pt' => $n_pt,
            'n_pt_e' => $n_pt_e,'n_sun' => $n_sun,'n_sun_e' => $n_sun_e,
            'attr_type' => $attr_type,'pn_1' => $pn_1,'pn_2' => $pn_2,
            'wt_1' => $wt_1,'wt_2' => $wt_2,'sr_1' => $sr_1,'sr_2' => $sr_2,
            'czw_1' => $czw_1,'czw_2' => $czw_2,'pt_1' => $pt_1, 'pt_2' => $pt_2,
            'sob_1' => $sob_1,'sob_2' => $sob_2,
            'nd_1' => $nd_1,'nd_2' => $nd_2,'r_pn_1' => $r_pn_1,'r_pn_2' => $r_pn_2,'r_wt_1' => $r_wt_1,
            'r_wt_2' => $r_wt_2,'r_sr_1' => $r_sr_1,'r_sr_2' => $r_sr_2,
            'r_czw_1' => $r_czw_1,'r_czw_2' => $r_czw_2,
            'r_pt_1' => $r_pt_1,'r_pt_2' => $r_pt_2,'r_sob_1' => $r_sob_1,
            'r_sob_2' => $r_sob_2,'r_nd_1' => $r_nd_1,'r_nd_2' => $r_nd_2
        );

        $hotel_data = array(
            'hotel_adres' => $object['post_address'],
            'hotel_email' => $meta_list['email_object'],
            'hotel_telefon' => $meta_list['obj_phone'],
            'hotel_post_code' => $object['post_post'],
            'hotel_gps_lat' => $meta_list['lat'],
            'hotel_gps_lng' => $meta_list['lng'],
            'hotel_name' => $object['post_title'],
        );
        //$this->session->set_userdata('hotel_adres',$adres);
        $this->session->set_userdata($hotel_data);
        $this->params = array_merge($this->params, $params);
        $this->load->view('object_details/index', $this->params);
    }

}

没有工作添加了这个:

$email = $meta_list['email_object'];
        $web = $meta_list['obj_site'];
        $telefon = $meta_list['obj_phone'];
        $adres = $object['post_address'];
        $post_code = $object['post_post'];
        $typ = $object['post_url'];
        $typ_hot = $object['post_object_type'];
        $fb = $meta_list['obj_fb'];
        $moc = $this->m_object_details->get_all_meta_key();
        $kuchnia = $this->m_object_details->get_kitchen($id);


     body is limited to 30 k chars ::<

1 个答案:

答案 0 :(得分:0)

Codeigntier对类/函数代码长度没有任何规则。与PHP相同。

据我所知,PHP对clasname或函数长度没有任何限制。所以CI没有任何限制。

但是如果你犯了错误就很难调试这么长的代码。