이것을 내 PHP 프로젝트에 통합하려고합니다 : https://github.com/bastianallgeier/gantti
calendar.php와 gantii.php를 애플리케이션 / 라이브러리에 복사했습니다.
제어 장치:
<?php
class summary extends CI_Controller {
function index() {
$this->load->library('gantti');
$gantti = new Gantti($data, array(
'title' => '',
'cellwidth' => 25,
'cellheight' => 35,
'today' => true
));
$this->load->view('summary_view', $gantti);
}
}
전망:
<?php
require('lib/gantti.php');
require('controllers/summary.php');
date_default_timezone_set('UTC');
setlocale(LC_ALL, 'en_US');
?>
<!DOCTYPE html>
<html>
<head>
<title>Summary</title>
<meta charset="utf-8" />
<link href="<?php echo base_url(); ?>assets/css/gantti.css" rel="stylesheet" media="screen">
<link href="<?php echo base_url(); ?>assets/css/metro-bootstrap.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery-1.10.2.js"></script>
</head>
<body>
<div class="page-header">
<h1>Summary</h1>
</div>
<?php echo $gantti ?>
</body>
</html>
하지만 페이지를 보는 대신 아래와 같이 오류 (404)가 표시됩니다.
A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Gantti::__construct(), called in C:\xampp\htdocs\wwww\system\core\Loader.php on line 1099 and defined
Filename: libraries/gantti.php
Line Number: 18
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: libraries/gantti.php
Line Number: 29
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: libraries/gantti.php
Line Number: 41
Fatal error: Call to a member function month() on a non-object in C:\xampp\htdocs\www\application\libraries\gantti.php on line 58
load-> library` 라이브러리를 CI에로드하려면 자동으로 생성자를 호출합니다.이 라이브러리에서 발생하는 것과 동일한 일이 발생하지만 라이브러리에 적어도 하나의 매개 변수를 전달해야하므로 오류가 발생합니다. 매개 변수를 하나만 전달할 수 있습니다. CI 로더를 사용하는 라이브러리
$this->load->library('gantti',$data);
하지만이 라이브러리에 설정하기위한 두 번째 매개 변수를 설정할 수는 없지만이 라이브러리의 모든 변수는 공용입니다. 이렇게 호출하여 설정할 수 있습니다.
$this->gantti->options = array(
'title' => '',
'cellwidth' => 25,
'cellheight' => 35,
'today' => true
)
완전한 솔루션
$this->load->library('gantti',$data); //first load library and pass data
$this->gantti->options = array(
'title' => '',
'cellwidth' => 25,
'cellheight' => 35,
'today' => true
);
$data['gantti'] = $this->gantti->__toString();
또 다른 솔루션은 사용자 정의 라이브러리를 만들고 Gantti 라이브러리로 확장하여 라이브러리 디렉토리 아래의 gantti lib 디렉토리를 복사하는 것입니다.
커스텀 라이브러리
<?php
require_once APPPATH.'libraries/lib/gantti.php';
class cigantti extends Gantti {
//put your code here
public function __construct() {
}
public function generate($data = array(), $params = array()){
parent::__construct($data, $params);
return $this->render();
}
}
?>
컨트롤러에서
$this->load->library('cigantti');
$data['gantti'] = $this->cigantti->generate($data, array(
'title' => 'Demo',
'cellwidth' => 25,
'cellheight' => 35,
'today' => true
));
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다