File cms/CMS.class.php

Last commit: Thu Nov 7 22:23:10 2019 +0100	Jan Dankert	New: Delete objects.
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 projectAdd($name) 55 { 56 $result = $this->call(CMS_WRITE,'projectlist','add',array('name'=>$name) ); 57 58 return $result; 59 } 60 61 function folder($id) 62 { 63 $content = $this->call(CMS_READ,'folder','edit',array('id'=>$id) ); 64 $prop = $this->call(CMS_READ,'folder','info',array('id'=>$id) ); 65 66 return( array( 'content'=>$content, 'properties'=>$prop ) ); 67 } 68 69 function folderAdd($parentid,$name) 70 { 71 $result = $this->call(CMS_WRITE,'folder','createfolder',array('id'=>$parentid,'name'=>$name) ); 72 73 return $result; 74 } 75 76 function page($id) 77 { 78 $result = $this->call(CMS_READ,'page','edit',array('id'=>$id) ); 79 80 return $result; 81 } 82 83 function link($id) 84 { 85 $result = $this->call(CMS_READ,'link','edit',array('id'=>$id) ); 86 87 return $result; 88 } 89 90 function file($id) 91 { 92 $result = $this->call(CMS_READ,'file','edit',array('id'=>$id) ); 93 94 return $result; 95 } 96 97 function projectDelete($id) 98 { 99 $result = $this->call(CMS_WRITE,'project','remove',array('id'=>$id,'delete'=>'true') ); 100 return $result; 101 102 103 } 104 105 function folderDelete($id) 106 { 107 $result = $this->call(CMS_WRITE,'folder','remove',array('id'=>$id,'delete'=>'true','withChildren'=>'true') ); 108 109 return $result; 110 } 111 112 113 function pageDelete($id) 114 { 115 $result = $this->call(CMS_WRITE,'page','remove',array('id'=>$id,'delete'=>'true') ); 116 117 return $result; 118 } 119 function fileDelete($id) 120 { 121 $result = $this->call(CMS_WRITE,'file','remove',array('id'=>$id,'delete'=>'true') ); 122 123 return $result; 124 } 125 126 function imageDelete($id) 127 { 128 $result = $this->call(CMS_WRITE,'image','remove',array('id'=>$id,'delete'=>'true') ); 129 130 return $result; 131 } 132 133 function textDelete($id) 134 { 135 $result = $this->call(CMS_WRITE,'text','remove',array('id'=>$id,'delete'=>'true') ); 136 137 return $result; 138 } 139 140 function filevalue($id) 141 { 142 $result = $this->call(CMS_READ,'file','show',array('id'=>$id) ); 143 144 return $result; 145 } 146 147 148 public function fileWrite($id,$value) 149 { 150 $result = $this->call(CMS_WRITE,'file','edit',array('id'=>$id,'value'=>$value) ); 151 152 return $result; 153 } 154 155 public function fileAdd($parentid,$filename,$value) 156 { 157 $result = $this->call(CMS_WRITE,'folder','createfile',array('id'=>$parentid,'filename'=>$filename,'value'=>$value) ); 158 159 return $result; 160 } 161 162 163 protected function call( $method,$action,$subaction,$parameter=array() ) 164 { 165 Logger::trace( "Executing $method $action/$subaction"."\n".$this->__toString() ); 166 167 $result = $this->client->call( $method,$action,$subaction,$parameter ); 168 169 Logger::trace( "API-Result of $method $action/$subaction:"."\n".$this->__toString()."\n".print_r($result,true)); 170 171 return $result; 172 } 173 174 public function __toString() 175 { 176 return print_r( get_object_vars($this),true); 177 } 178 179 }
Download cms/CMS.class.php
History Thu, 7 Nov 2019 22:23:10 +0100 Jan Dankert New: Delete objects. Thu, 7 Nov 2019 22:05:43 +0100 Jan Dankert Fix: Needing a filename for a new file. Thu, 7 Nov 2019 21:54:48 +0100 Jan Dankert Fix: Uploading files. Thu, 7 Nov 2019 01:07:03 +0100 Jan Dankert No direct calls any more. All data of the CMS is transferred via the API within an array. Wed, 6 Nov 2019 23:55:30 +0100 Jan Dankert Fixes for uploading files. Wed, 6 Nov 2019 23:21:38 +0100 Jan Dankert Fix: Enable creation of projects and folders. Mon, 4 Nov 2019 23:03:10 +0100 Jan Dankert Refactoring: Cleaned up the folder structure.