CMS.class.php (2537B)
1 <?php 2 3 define('CMS_READ' ,'GET' ); 4 define('CMS_WRITE' ,'POST'); 5 6 class CMS 7 { 8 var $login = false; 9 var $token; 10 11 public $client; 12 13 public function __construct() 14 { 15 $this->client = new Client(); 16 $this->client->useCookies = true; 17 18 } 19 20 function login($user, $password,$dbid ) 21 { 22 23 // Erster Request der Sitzung muss ein GET-Request sein. 24 // Hier wird auch der Token gelesen. 25 $result = $this->call(CMS_READ,'login','login' ); 26 27 $result = $this->call(CMS_WRITE,'login','login',array('login_name'=>$user,'login_password'=>$password,'dbid'=>$dbid) ); 28 29 if ( ! $this->client->success ) { 30 throw new Exception( 'Login failed.',true ); 31 } 32 33 $this->login = true; 34 35 return $this->login; 36 } 37 38 39 function projectlist() 40 { 41 $result = $this->call(CMS_READ,'projectlist','edit' ); 42 43 return $result; 44 } 45 46 47 function project($projectid) 48 { 49 $result = $this->call(CMS_READ,'project','prop',array('id'=>$projectid) ); 50 51 return $result; 52 } 53 54 function folder($id) 55 { 56 $content = $this->call(CMS_READ,'folder','edit',array('id'=>$id) ); 57 $prop = $this->call(CMS_READ,'folder','info',array('id'=>$id) ); 58 59 return( array( 'content'=>$content, 'properties'=>$prop ) ); 60 } 61 62 function page($id) 63 { 64 $result = $this->call(CMS_READ,'page','edit',array('id'=>$id) ); 65 66 return $result; 67 } 68 69 function link($id) 70 { 71 $result = $this->call(CMS_READ,'link','edit',array('id'=>$id) ); 72 73 return $result; 74 } 75 76 function file($id) 77 { 78 $result = $this->call(CMS_READ,'file','edit',array('id'=>$id) ); 79 80 return $result; 81 } 82 83 function filevalue($id) 84 { 85 $result = $this->call(CMS_READ,'file','show',array('id'=>$id),true ); 86 87 return $result; 88 } 89 90 91 public function fileWrite($id,$value) 92 { 93 $result = $this->call(CMS_WRITE,'file','save',array('id'=>$id,'value'=>$value) ); 94 95 return $result; 96 } 97 98 public function fileAdd($value) 99 { 100 $result = $this->call(CMS_WRITE,'file','save',array('value'=>$value) ); 101 102 return $result; 103 } 104 105 106 protected function call( $method,$action,$subaction,$parameter=array(),$direct=false ) 107 { 108 Logger::trace( "Executing $method $action/$subaction"."\n".$this->__toString() ); 109 110 $result = $this->client->call( $method,$action,$subaction,$parameter,false ); 111 112 Logger::trace( "API-Result of $method $action/$subaction:"."\n".$this->__toString()."\n".print_r($result,true)); 113 114 return $result; 115 } 116 117 public function __toString() 118 { 119 return print_r( get_object_vars($this),true); 120 } 121 122 }