목록

2021.02.15 10:46
조회 1,213
0
CMS/프레임워크 Rhymix 2.0
개발 언어 PHP 8.0
<?php /* Copyright (C) cydemo <https://www.xetown.com> */ /**  * @class  ap_template  * @author cydemo (cydemo@gmail.com)  * @brief Template Component  */ class ap_template extends EditorHandler { // editor_sequence from the editor must attend mandatory wearing .... var $editor_sequence = 0; var $component_path = ''; var $template_path = ''; /**  * @brief editor_sequence and components out of the path  */ function __construct($editor_sequence, $component_path) { $this->editor_sequence = $editor_sequence; $this->component_path = $component_path; $this->template_path = sprintf('%s%s', preg_replace('/^\.\//i', '', $this->component_path), 'templates'); } /**  * @brief popup window to display in popup window request is to add content  */ function getPopupContent() { // Bringing a list of templates directory $template_dir = FileHandler::readDir($this->template_path); $template_list = array(); foreach ( $template_dir as $key => $template ) { $xml= FileHandler::readFile($this->template_path . '/' . $template . '/info.xml'); //$parser = new XMLParser(); //$xml_info = $parser->parse($xml)->template; $stream = fopen('$xml', 'r'); $parser = xml_parser_create(); // set up the handlers here while (($data = fread($stream, 16384))) {      xml_parse($parser, $data); // parse the current chunk   }        xml_parse($parser, '', true); // finalize parsing  xml_parser_free($parser); fclose($stream); if ( ( Context::get('logged_info')->is_admin !== 'Y' &&  $xml_info->admin->body === 'Y' ) || ( Context::get('type') === 'full_page' && $xml_info->type->full_page->body !== 'Y' ) || ( Context::get('type') === 'header' && $xml_info->type->header->body !== 'Y' ) || ( Context::get('type') === 'section' && $xml_info->type->section->body !== 'Y' ) || ( Context::get('type') === 'footer' && $xml_info->type->footer->body !== 'Y' ) ) { continue; } $template_list[$key] = new stdClass; $template_list[$key]->dir = $template; $template_list[$key]->title = $xml_info->title->body; $template_list[$key]->desc = $xml_info->description->body; $template_list[$key]->version = $xml_info->version->body; $template_list[$key]->date = $xml_info->date->body; $template_list[$key]->author = $xml_info->author->name->body; $template_list[$key]->email = $xml_info->author->attrs->email_address; $template_list[$key]->link = $xml_info->author->attrs->link; $template_list[$key]->admin = $xml_info->admin->body; $template_list[$key]->full_page = $xml_info->type->full_page->body; $template_list[$key]->header = $xml_info->type->header->body; $template_list[$key]->section = $xml_info->type->section->body; $template_list[$key]->footer = $xml_info->type->footer->body; $template_list[$key]->thumb = $this->template_path . '/' . $template . '/thumb.jpg'; } // Set Page Navigation $list_count = 10; $total_count = count($template_list); $total_page = ceil($total_count / $list_count); $page = Context::get('page') ? Context::get('page') : 1; if ( !Context::get('page') ) { Context::set('page', 1); } $page = abs(Context::get('page')); if ( $page > $total_page ) { $page = $total_page; } if ( $total_page > 1 ) { $page_navigation = new PageHandler($total_page, $total_page, $page, $page_count = 5); } Context::set('page_navigation', $page_navigation); // Slice of Template List $template_list = array_slice($template_list, $list_count*($page-1), $list_count, true); Context::set('template_list', $template_list); // Bringing editor skin information in the current module $oModuleModel = getModel('module'); $module_info = $oModuleModel->getModuleInfoByMid(Context::get('mid')); $oEditorModel = getModel('editor'); $editor_config = $oEditorModel->getEditorConfig($module_info->module_srl); Context::set('editor_skin', $editor_config->editor_skin); // Pre-compiled source code to compile template return to $tpl_path = $this->component_path.'tpl'; $tpl_file = 'popup.html'; $oTemplate = &TemplateHandler::getInstance(); return $oTemplate->compile($tpl_path, $tpl_file); } function getTemplate() { $template = Context::get('template'); $template_path = sprintf('%s/%s', $this->template_path, $template); $template_file = 'index.html'; $oTemplate = &TemplateHandler::getInstance(); $this->add('template', $oTemplate->compile($template_path, $template_file)); } } /* End of file ap_template.class.php */ /* Location: ./modules/editor/components/ap_template/ap_template.class.php */

 

 

템플릿 컴포넌트 입니다.

에디터 내에 지정된 템플릿을 로드합니다.

php 8.0 대응을 어떻게 할지 고민입니다.

 

서버 오류

Error #0 "Cannot directly construct XMLParser, use xml_parser_create() or xml_parser_create_ns() instead" in C:\websites\4880net\modules\editor\components\ap_template\ap_template.class.php on line 36

 

이걸 어떻게 바꿔야 하나요? 

 

댓글 8

  • 와, 저는 하나도 모르겠네요.
    라이선스를 GPL v2로 바꿨으니 뜻있는 분들은 해당 오류 부분을 수정 배포해주시면 감사하겠습니다!
  • 말씀하신 에러가 뜨는곳은 //$parser = new XMLParser(); 인데

    실제 에러는 $parser = xml_parser_create(); 여기 인것 같은데요..

    원래코드가 어땠는지 되돌려보시고 해당 원래코드에서 다시 실행시 어떤 에러가 뜨는지 알려주세요.
  • 36줄이 주석처리되어 있는데 36줄에서 에러가 나는 건가요?

    아니면 에러를 해결하려고 이것저것 건드려 놓은 상태의 소스인가요?

     

    1. XE에서 사용해 온 XmlParser 클래스를 PHP 8.0에서는 더이상 사용할 수 없습니다.

    2. xml_parser_create() 함수는 new XmlParser() 의 대용품이 아닙니다.

    3. 라이믹스 2.0에서는 XmlParser를 XeXmlParser로 바꿔주시면 간단하게 해결됩니다.

  • @기진곰

    원판에는

    $xml = FileHandler::readFile($this->template_path . '/' . $template . '/info.xml'); $oXmlParser = new XmlParser(); $xml_info = $oXmlParser->parse($xml)->template;

    로 되어 있는데


    36행의 $oXmlParser = new XmlParser();를 $oXmlParser = new XeXmlParser(); 로 바꾸면 된다는 거죠?

  • @윤삼
    넵 그렇게 바꿔주시면 될 것 같습니다.
  • 오우 감사합니다. 함수가 있었군요 !!!
  • @이성민
    해당 부분 수정 후 8.0에서도 잘 작동하나요?
  • @윤삼
    네 잘작동합니다. ㅎㅎ