2016-10-10 13 views
0

CodeIgniter 1.7.2バージョンでは動作しません。フック==> display_overrideが動作していないのは非常に奇妙です。

私は他のフック==> pre_controller、pre_controllerをテストしていましたが、このフックに問題があるかどうか==> display_overrideは機能しません。

私は呼び出していないフックのコールバック関数にdie()を挿入するためにこのフックをテストしました。 (コールバック関数の出力())

私は以下のようにHTMLの最適化に取り組んでいます。任意のアイデアを喜ば

ディレクトリ: -

1) アプリケーション/設定/ config.phpの

$config['enable_hooks'] = TRUE; 

=================== ===================== 2) アプリケーション/設定/ hooks.php

$hook['display_override'][] = array(
    'class' => 'Minifyhtml', 
    'function' => 'output', 
    'filename' => 'Minifyhtml.php', 
    'filepath' => 'hooks', 
    'params' => array() 
); 

=========== =====================

3) アプリケーション/フック/ Minifyhtml.php

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

/** 
* Minifyhtml Class 
* Will Minify the HTML. Reducing network latency, enhancing compression, and faster browser loading and execution. 
* 
* @category Output 
* @author  John Gerome 
* @link  https://github.com/johngerome/CodeIgniter-Minifyhtml-hooks 
*/ 

class Minifyhtml { 

    /** 
    * Responsible for sending final output to browser 
    */ 

    function output() 
    { 
     $CI =& get_instance(); 
     $buffer = $CI->output->get_output(); 
     $re = '%   # Collapse ws everywhere but in blacklisted elements. 
      (?>    # Match all whitespans other than single space. 
       [^\S ]\s*  # Either one [\t\r\n\f\v] and zero or more ws, 
      | \s{2,}  # or two or more consecutive-any-whitespace. 
      ) # Note: The remaining regex consumes no text at all... 
      (?=    # Ensure we are not in a blacklist tag. 
       (?:   # Begin (unnecessary) group. 
       (?:   # Zero or more of... 
        [^<]++ # Either one or more non-"<" 
       | <   # or a < starting a non-blacklist tag. 
        (?!/?(?:textarea|pre)\b) 
       )*+   # (This could be "unroll-the-loop"ified.) 
      )    # End (unnecessary) group. 
       (?:   # Begin alternation group. 
       <   # Either a blacklist start tag. 
       (?>textarea|pre)\b 
       | \z   # or end of file. 
      )    # End alternation group. 
      ) # If we made it here, we are not in a blacklist tag. 
      %ix'; 
     $buffer = preg_replace($re, " ", $buffer); 
     $CI->output->set_output($buffer); 
     $CI->output->_display(); 
    } 
} 
?> 

私を助けてください。

答えて

0

CodeIgniter 3バージョンを使用するのは時間がかかります。

$hook['display_override'] = ... 
:あなたのexempleで

は、おそらく余分な括弧[]は このコードを試してみてください存在します