| [ 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: ViewReferers.class.php 29 2006-08-18 07:35:21Z matthieu_ $ 11 12 13 require_once INCLUDE_PATH."/core/include/ViewModule.class.php"; 14 require_once INCLUDE_PATH."/libs/Xml/Serializer.php"; 15 require_once INCLUDE_PATH."/plugins/xmlapi/include/CallFunction.class.php"; 16 require_once INCLUDE_PATH."/plugins/xmlapi/include/CallFunctionParameter.class.php"; 17 18 class ViewXmlapi extends ViewModule 19 { 20 var $viewTemplate = "xmlapi/viewxmlapi.tpl"; 21 22 /** 23 * Constructor 24 */ 25 function ViewXmlapi() 26 { 27 parent::ViewModule( "pages"); 28 } 29 30 31 function returnQueryXML ($p_query, $p_query2 = "") { 32 $r = query($p_query); 33 $allElem = array(); 34 while($l = mysql_fetch_assoc($r)) 35 { 36 $l['idcategory'] = "c".$l['idcategory']; 37 $allElem[] = $l; 38 } 39 if ($p_query2 != "") { 40 $r = query($p_query2); 41 while($l = mysql_fetch_assoc($r)) 42 { 43 if (isPrefixTag($l['name'])) { 44 $l['idpage'] = "f".$l['idpage']; 45 } 46 else { 47 $l['idpage'] = "p".$l['idpage']; 48 } 49 $allElem[] = $l; 50 } 51 } 52 return $allElem; 53 } 54 55 function returnAllElemXML ($allElem, $p_request) { 56 // An array of serializer options 57 $serializer_options = array ( 58 'addDecl' => TRUE, 59 'encoding' => 'UTF-8', 60 'indent' => ' ', 61 'rootName' => 'XmlApi', 62 'defaultTagName' => 'item', 63 'rootAttributes' => array ( 'version' => '1.0', 'request' => $p_request), 64 ); 65 66 $Serializer = &new XML_Serializer($serializer_options); 67 // Serialize the data structure 68 $Serializer->setOption("keyAttribute", "rdf:about"); 69 70 $status = $Serializer->serialize($allElem); 71 72 $allData = $Serializer->getSerializedData(); 73 74 // Display the XML document 75 header('Content-type: text/xml'); 76 print($allData); 77 exit; 78 } 79 80 function initFunctionTab () { 81 $tmpTab = array(); 82 $tmp = new CallFunction("getViewPage", "Get visit to pages", "getPagesZoom", "sum.1"); 83 $tmp->addParameter("cat", "Categorie id (sample : c1697 or c1697>c1701)", "");//sample : c1697 => c_id_zoom in url 84 $tmpTab[$tmp->fctApiName] = $tmp; 85 86 $tmp = new CallFunction("getTimePages", "Get time by pages", "getPagesZoom", "sumtime"); 87 $tmp->addParameter("cat", "Categorie id (sample : c1697 or c1697>c1701)", "");//sample : c1697 => c_id_zoom in url 88 $tmpTab[$tmp->fctApiName] = $tmp; 89 90 $tmp = new CallFunction("getVisitsStatistics", "Get visit statisitics", "getVisitsStatistics", ""); //one_page_rate 91 $tmpTab[$tmp->fctApiName] = $tmp; 92 93 return $tmpTab; 94 95 } 96 /** 97 * Data processing method 98 * only called if template is not cached 99 */ 100 function process() 101 { 102 $request = getRequestVar ('request', "", 'string'); 103 $tab = $this->initFunctionTab (); 104 105 if ($request == "") { 106 107 $this->tpl->assign("XmlapiFunctionTab", $tab); 108 $this->tpl->assign("PHPMV_URL", PHPMV_URL); 109 } 110 else { 111 // Get function element 112 $fct = $tab[$request]; 113 114 // Get parameter from url 115 $tabParam = array(); 116 foreach ($fct->fctParameters as $key => $elem) { 117 $tabParam[$elem->fctParamName] = html_entity_decode(getRequestVar ($elem->fctParamName, 118 $elem->fctParamDefaultValue, 'string')); 119 //echo "test : " . $tabParam[$elem->fctParamName] . "<br>"; 120 } 121 122 // Call function with parameters 123 //$data = $this->data->{$fct->fctCodeName}(); 124 $data = call_user_func_array(array(& $this->data, $fct->fctCodeName), $tabParam); 125 126 // Get anly specific detail 127 if ($fct->fctResultDetail != "") { 128 $resultTab = split("[/.-]", $fct->fctResultDetail); 129 foreach ($resultTab as $key => $elem) { 130 $data = $data[$elem]; 131 } 132 } 133 134 // Return xml 135 $this->returnAllElemXML($data, $fct->fctApiName); 136 } 137 } 138 } 139 ?>
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 |
|