[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /* 3 * phpMyVisites : website statistics and audience measurements 4 * Copyright (C) 2002 - 2006 5 * http://www.phpmyvisites.net/ 6 * phpMyVisites is free software (license GNU/GPL) 7 * Authors : phpMyVisites team 8 */ 9 10 // $Id: ViewModule.class.php 29 2006-08-18 07:35:21Z matthieu_ $ 11 12 13 require_once INCLUDE_PATH."/core/include/DataModel.class.php"; 14 require_once INCLUDE_PATH."/core/include/Site.class.php"; 15 require_once INCLUDE_PATH."/core/include/Archive.class.php"; 16 17 18 19 class ViewModule extends Module 20 { 21 var $partName; 22 23 //the datamodel 24 var $data; 25 26 27 /** 28 * ViewModule constructor 29 * @param $name string the partName 30 * @param $o_data object , datas to render 31 * 32 * @return void 33 */ 34 function ViewModule($name = "", $o_data = null) 35 { 36 37 $this->partName = $name; 38 $this->data = $o_data; 39 40 parent::Module(); 41 } 42 43 44 /** 45 * initialize module with request datas 46 * 47 * @param object request 48 * @return void 49 */ 50 function init(&$request, $o_tpl = null, $o_archive = null) 51 { 52 if(!is_a($o_tpl, "TemplateEngine")) 53 { 54 $o_tpl = null; 55 } 56 parent::init($request, $o_tpl); 57 58 $date = $this->request->getDate(); 59 60 if(is_null($this->data)) 61 { 62 if(is_null($o_archive)) 63 { 64 $o_archive = DataModel::getArchive($this->site, $date, $this->request->getPeriod() ); 65 } 66 67 $this->data = new DataModel( $o_archive , $this->request); 68 } 69 70 $d = new Date( getDateFromTimestamp( time() ) ); 71 if(($this->data->archive->date->get() == $d->get() || isset($this->disableCache)) 72 && is_a($this->tpl, "TemplateEngine")) 73 { 74 printDebug("Current date asked is today's date, cache not activated<br>"); 75 $this->tpl->caching = 0; 76 } 77 } 78 79 80 function getDataMethod($methods, $returnPlease = false) 81 { 82 $return = array(); 83 84 // foreach method that we have to call for getting data 85 foreach( $methods as $key => $methodsuffix ) 86 { 87 // case we have parameters to pass to the method 88 if(is_array($methodsuffix)) 89 { 90 $method_name = "get".$this->partName.$key; 91 92 // call the method on the object DataModel, with correct arguments 93 $value = call_user_func_array(array(&$this->data , $method_name), $methodsuffix ); 94 95 if(!$returnPlease) 96 { 97 $this->tpl->assign( $key, $value); 98 } 99 else 100 { 101 $return[$key] = $value; 102 } 103 } 104 } 105 106 if($returnPlease) 107 { 108 return $return; 109 } 110 return true; 111 } 112 113 /** 114 * Main job method overided in each view plugin 115 * this method should take care of obtaining and processing datas 116 * 117 * @return void 118 */ 119 function process() 120 { 121 echo('please override me...'); 122 } 123 124 125 /** 126 * default display method for all views 127 * 128 * @return void 129 */ 130 function showAll() 131 { 132 // set mod to view because of specific elements in this case (period_selection.tpl) 133 $this->tpl->assign('mod', 'view'); 134 135 if (!$this->isCached()) 136 { 137 $this->process(); 138 } 139 140 $this->display(); 141 } 142 143 } 144 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |