cakephpでpearを使う2

たとえば、pearへのインクルードパスが指定できる。とか、.htaccessでインクルードパスを変えれる時に
cakephppear を使う場合はそのまま使えないのかと思いました。
(いろいろ参考にしてるとvendorsの中に入れるみたいで・・・)

で、実験してみました。
ヘルパーでpearCalendarを使ってみました。


//カレンダーの読み込み
require_once 'Calendar/Month/Weekdays.php';
require_once("Calendar/Month.php");
require_once("Calendar/Week.php");
require_once("Calendar/Day.php");
require_once("Calendar/Hour.php");


class ScheduleTableHelper extends Helper {

var $helpers = array('Html');



//月の表示
function month($schedules=null, $times=null) {
$month = new Calendar_Month_Weekdays(date('Y',$times['from_time']), date('n',$times['from_time']), 0);
$month->build();
echo '';
echo '';
echo '';
while ($Day = $month->fetch()) {
//classの設定
$class='df';
if($Day->isFirst()){$class="sun";}
if($Day->isLast()){$class="sat";}
if ($Day->isFirst()) {
echo "\n";
}
if ($Day->isEmpty()) {
echo ''."\n";
}else{
echo '\n";
}
if ($Day->isLast()) {
echo "\n";
}
}
echo '
'.$month->year.'年'.$month->month.'月
'.''.$Day->thisDay().'';
echo '
    ';
    foreach($schedules as $schedule){
    //開始日~終了日までを表示
    if($Day->day >= date('d',strtotime($schedule['FeatureSchedule']['start_time']))
    && $Day->day <= date('d',strtotime($schedule['FeatureSchedule']['end_time']))){
    echo '
  • ';
    echo $this->Html->link($schedule['FeatureCat']['name'],'/config/edit/FeatureCat/'.$schedule['FeatureSchedule']['feature_id']);
    echo $this->Html->link('編集','/config/edit/FeatureSchedule/'.$schedule['FeatureSchedule']['id']);
    echo '
  • ';
    }
    }
    echo '
';
echo "
';

}

//週の表示
function week($schedules=null, $times=null){
$week = new Calendar_Week(date('Y',$times['from_time']), date('m',$times['from_time']),date('d',$times['from_time']), 0);
$week->build();
echo '';
echo '';
echo '';
echo "\n";
while ($Day = $week->fetch()) {
//classの設定
$class='df';
if($Day->isFirst()){$class="sun";}
if($Day->isLast()){$class="sat";}
if ($Day->isEmpty()) {
echo ''."\n";
}
else{
echo '\n";
echo '
'.$week->year.'/'.$week->month.'
'.''.$Day->thisDay().'';
echo '
    ';
    foreach($schedules as $schedule){
    //開始日~終了日までを表示
    if($Day->day >= date('d',strtotime($schedule['FeatureSchedule']['start_time']))
    && $Day->day <= date('d',strtotime($schedule['FeatureSchedule']['end_time']))){
    echo '
  • ';
    echo $this->Html->link($schedule['FeatureCat']['name'],'/config/edit/FeatureCat/'.$schedule['FeatureSchedule']['feature_id']);
    echo '';
    echo '開始日時';
    echo date('m/d',strtotime($schedule['FeatureSchedule']['start_time']));
    echo date('h:i',strtotime($schedule['FeatureSchedule']['start_time']));
    echo '
    ';
    echo '';
    echo '終了日時';
    echo date('m/d',strtotime($schedule['FeatureSchedule']['end_time']));
    echo date('h:i',strtotime($schedule['FeatureSchedule']['end_time']));
    echo '
    ';
    echo $this->Html->link('編集','/config/edit/FeatureSchedule/'.$schedule['FeatureSchedule']['id']);
    echo '
  • ';
    }
    echo '
';
}
}
}
echo "
';

}

//日の表示
function day($schedules=null, $times=null){
}

function dayLink($time) {
$out = strftime('%m/%d', $time).__(strftime('(%a)', $time), true);
$out = $this->Html->link($out, array('action'=>'index', 'id'=>'day', date('Y/m/d',$time)));
return $out;
}


//***************************************************************
// 表示別ナビゲーション
//***************************************************************
function navi($controller, $scope, $current) {
$method = $scope.'_navi';
return $this->$method($controller, $current);
}
//月の場合
function month_navi($controller, $current) {
$url = $this->params['controller'].'/'.$this->params['action'];
list($year, $month, $day) = split('/',$current);
//先月
echo $this->Html->link('先月','/'.$url.'/month/'.date('Y/m/',mktime(0,0,0,$month-1,1,$year)),array('id'=>'btn','class'=>'lastmonth'));
//今月
echo $this->Html->link('今月','/'.$url.'/month/'.date('Y/m/'),array('id'=>'btn','class'=>'thismonth'));
//翌月
echo $this->Html->link('翌月','/'.$url.'/month/'.date('Y/m/',mktime(0,0,0,$month+1,1,$year)),array('id'=>'btn','class'=>'nextmonth'));
}
//週の場合
function week_navi($controller, $current) {
$url = $this->params['controller'].'/'.$this->params['action'];
list($year, $month, $day) = split('/', $current);
//先週
echo $this->Html->link('先週','/'.$url.'/week/'.date('Y/m/d', mktime(0,0,0,$month,$day-7,$year)),array('id'=>'btn','class'=>'lastweek'));
//今週
echo $this->Html->link('今週','/'.$url.'/week/'.date('Y/m/d'),array('id'=>'btn','class'=>'thisweek'));
//翌週
echo $this->Html->link('翌週','/'.$url.'/week/'.date('Y/m/d', mktime(0,0,0,$month,$day+7,$year)),array('id'=>'btn','class'=>'nextweek'));
}
//日の場合
function day_navi($controller, $current) {
$out = '
    ';
    list($year, $month, $day) = split('/', $current);
    $out .= sprintf('
  • %s
  • ',
    $controller,
    date('Y/m/d', mktime(0,0,0,$month,$day-1,$year)),
    __('Previous day', true));
    $out .= sprintf('
  • %s
  • ',
    $controller,
    date('Y/m/d'),
    __('Today', true));
    $out .= sprintf('
  • %s
  • ',
    $controller,
    date('Y/m/d', mktime(0,0,0,$month,$day+1,$year)),
    __('Next day', true));
    $out .= '
';
return $out;
}


}
?>


という感じで上手くいきました。
クラスとかがもっと理解できれば・・・。と思いますが、今度pearのpagerを使ったページ送りを試してみたいと思います。