升级speedphp 3 beta 3 之后报“类未定义”- 函数spAddViewFunction?

#1 小双

类定义不存在,请检查。
  • E:\Apache\htdocs\web_afusa\SpeedPHP\spFunctions.php on line 158
153.
}
154.
if(FALSE != $has_define){
155.         $GLOBALS['G_SP']["inst_class"][$class_name] = new $class_name($args);
156.
return $GLOBALS['G_SP']["inst_class"][$class_name];
157.
}
158.     spError($class_name."类定义不存在,请检查。");

159.
}
160.
161.
162.
* spError 框架定义的系统级错误提示
163.
*  

2010-05-06 13:10:03

#2 小双

  • E:\Apache\htdocs\web_afusa\SpeedPHP\Core\spView.php on line 75
70.
public function addfuncs()
71.
{
72.
if( is_array($GLOBALS['G_SP']["view_registered_functions"]) &&  
73.             method_exists($this->engine, 'register_function') ){
74.
foreach( $GLOBALS['G_SP']["view_registered_functions"] as $alias => $func ){
75.
if( is_array($func) )$func = array(spClass($func[0]),$func[1]);

76.                 $this->engine->register_function($alias, $func);
77.
}
78.
}
79.
}
80.

  • E:\Apache\htdocs\web_afusa\SpeedPHP\Core\spView.php on line 50
45.
* 输出页面
46.
* @param tplname 模板文件路径
47.
*/
48.
public function display($tplname)
49.
{
50.         $this->addfuncs();

51.         $this->displayed = TRUE;
52.
if($GLOBALS['G_SP']['view']['debugging'] && SP_DEBUG)$this->engine->debugging = TRUE;
53.         $this->engine->display($tplname);
54.
}
55.


2010-05-06 13:10:23

#3 小双

E:\Apache\htdocs\web_afusa\SpeedPHP\Core\spController.php on line 107
102.       * @param $output   是否直接显示模板,设置成FALSE将返回HTML而不输出
103.       */
104.      public function display($tplname, $output = TRUE)
105.      {
106.          if(TRUE == $GLOBALS['G_SP']['view']['enabled']){

107.              $this->v->display($tplname);

108.          }else{
109.              extract($this->__template_vals);
110.              require($tplname);
111.          }
112.          if( TRUE != $output )return ob_get_clean();

E:\Apache\htdocs\web_afusa\controller\general.php on line 80
75.          // 侧栏
76.          $this->template_sidebar = $this->sidebar();
77.          // 页面title
78.          $this->template_title = $this->title. ( ($this->title != "") ? " - " : "" );
79.  

80.          parent::display($this->defined["template"]."/".$tplname, $output);

81.      }
82.  
83.       84.       * 错误提示程序  应用程序的控制器类可以覆盖该函数以使用自定义的错误提示
85.       * @param $msg   错误提示需要的相关信息

E:\Apache\htdocs\web_afusa\controller\main.php on line 20
15.          $this->sendinfo = spClass("lib_send")->findAll(NULL,"id DESC",NULL,20);
16.           
17.          //问题解答
18.          $this->askinfo = spClass("lib_note")->findAll(array('sta'=>2),"ptime DESC",NULL,5);
19.               

20.            $this->display("main_index.html");         

21.      }
22.  
23.  }
24.  ?>
E:\Apache\htdocs\web_afusa\SpeedPHP\spFunctions.php on line 30
25.          eval($GLOBALS['G_SP']["dispatcher_error"]);
26.          exit;
27.      }
28.  
29.      // 路由并执行用户代码

30.      $handle_controller->$__action();

31.  
32.      // 控制器程序运行完毕,进行模板的自动输出
33.      if(FALSE != $GLOBALS['G_SP']['view']['auto_display']){
34.          $__tplname = $__controller.$GLOBALS['G_SP']['view']['auto_display_sep'].
35.                  $__action.$GLOBALS['G_SP']['view']['auto_display_suffix'];

E:\Apache\htdocs\web_afusa\index.php on line 49
44.          'file_root_name' => 'html', // 静态文件生成的根目录名称,设置为空则是直接在入口文件的同级目录生成  
45.      ),   
46.  );
47.  require(APP_PATH.'/model/functions.php');
48.  require(SP_PATH."/SpeedPHP.php");  

49.  spRun();

2010-05-06 13:10:27

#4 jake

能否把程序配置也贴出来看看:handshake,我想应该是配置方面有问题。

2010-05-06 13:25:45

#5 小双

define("SP_PATH",dirname(__FILE__)."/SpeedPHP");
define("APP_PATH",dirname(__FILE__));

date_default_timezone_set('PRC');//其他东八去时间表示均可

$spConfig = array(
        "db" => array( // 数据库设置
                'host' => 'localhost',
                'login' => 'root',
                'password' => 'root',
                'database' => '',
                'prefix' => '',
        ),
        // 网站配置               
        'shopzc_defined' => array(
        //'sitename' => '',  // 网站名称
        'siteintro' => '',    // 网站介绍
        'template' => 'default',     // 默认模板
        //'copyright' => '',   // 版权信息
        ),
        'view' => array(
                'enabled' => TRUE, // 开启视图
                'config' =>array(
                        'template_dir' => APP_PATH.'/template', // 模板目录
                        'compile_dir' => APP_PATH.'/tmp', // 编译目录
                        'cache_dir' => APP_PATH.'/tmp', // 缓存目录
                        'left_delimiter' => '<{',  // smarty左限定符
                        'right_delimiter' => '}>', // smarty右限定符
                ),
                //'auto_display' => TRUE, // 使用自动输出模板功能
                //'auto_display_sep' => "_", // 自动输出模板的拼装模式,/为按目录方式拼装,_为按下划线方式,这里用下划线
        ),
        'launch' => array(
                 'router_prefilter' => array(
                        array('lib_domain','enter'), // 二级域名转向
                        //array('spAcl','mincheck') // 开启有限的权限控制
                        //array('spAcl','maxcheck') // 开启强制的权限控制
                 )
         ),        
         'html' => array(  // HTML生成配置
                'enabled' => TRUE, // 开启HTML生成功能
                'safe_check_file_exists' => TRUE, // 获取URL时,检查物理HTML文件是否存在,如文件不存在,则返回安全的动态地址                 
                'file_root_name' => 'html', // 静态文件生成的根目录名称,设置为空则是直接在入口文件的同级目录生成
        ),  
);
require(APP_PATH.'/model/functions.php');
require(SP_PATH."/SpeedPHP.php");
spRun();

2010-05-06 13:29:19

#6 小双

得到jake老大的细心帮助,上面的问题,我已经解决了,问题出在model文件夹里的lib_domain.php文件,里面
spAddViewFunction('cutwin', array( $this, 'cutwin'));
这里是引用截取字符函数的方法,里面的 $this 改成 'lib_domain' 就可以了。
spAddViewFunction('cutwin', array( 'lib_domain', 'cutwin'));
另外要注意改了以后把原tmp里面的缓存删掉以后在浏览页面就OK啦!

2010-05-06 14:20:21