Changeset 2566:9bf417837888 for inc/core/class.dc.settings.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.settings.php
r1179 r2566 25 25 protected $table; ///< <b>string</b> Settings table name 26 26 protected $blog_id; ///< <b>string</b> Blog ID 27 27 28 28 protected $namespaces = array(); ///< <b>array</b> Associative namespaces array 29 29 30 30 protected $ns; ///< <b>string</b> Current namespace 31 31 32 32 /** 33 33 Object constructor. Retrieves blog settings and puts them in $namespaces 34 34 array. Local (blog) settings have a highest priority than global settings. 35 35 36 36 @param core <b>dcCore</b> dcCore object 37 37 @param blog_id <b>string</b> Blog ID … … 44 44 $this->loadSettings(); 45 45 } 46 47 /** 48 Retrieves all namespaces (and their settings) from database, with one query. 46 47 /** 48 Retrieves all namespaces (and their settings) from database, with one query. 49 49 */ 50 50 private function loadSettings() … … 61 61 trigger_error(__('Unable to retrieve namespaces:').' '.$this->con->error(), E_USER_ERROR); 62 62 } 63 63 64 64 /* Prevent empty tables (install phase, for instance) */ 65 65 if ($rs->isEmpty()) { 66 66 return; 67 67 } 68 68 69 69 do { 70 70 $ns = trim($rs->f('setting_ns')); … … 77 77 } while(!$rs->isStart()); 78 78 } 79 80 79 80 81 81 /** 82 82 Create a new namespace. If the namespace already exists, return it without modification. 83 83 84 84 @param ns <b>string</b> Namespace name 85 85 @return <b>dcNamespace</b> The namespace created … … 139 139 return true; 140 140 } 141 141 142 142 /** 143 143 Returns full namespace with all settings pertaining to it. 144 144 145 145 @param ns <b>string</b> Namespace name 146 146 @return <b>dcNamespace</b> … … 150 150 return $this->namespaces[$ns]; 151 151 } 152 152 153 153 /** 154 154 Magic __get method. … … 165 165 return $this->get($n); 166 166 } 167 167 168 168 /** 169 169 Magic __set method. … … 174 174 $this->set($n,$v); 175 175 } 176 176 177 177 /** 178 178 Returns $namespaces property content. 179 179 180 180 @return <b>array</b> 181 181 */ … … 184 184 return $this->namespaces; 185 185 } 186 187 /** 188 Raises a E_USER_NOTICE errror for deprecated functions. 186 187 /** 188 Raises a E_USER_NOTICE errror for deprecated functions. 189 189 This allows the developer to know he's been using deprecated functions. 190 190 191 191 @param name <b>string</b> Name of the deprecated function that was called. 192 192 */ … … 202 202 } 203 203 } 204 204 205 205 /** 206 206 @deprecated Please set your settings via $core->blog->settings->{namespace}->{setting} 207 207 208 208 Sets a setting in $settings property. This sets the setting for script 209 209 execution time only and if setting exists. 210 210 211 211 @param n <b>string</b> Setting name 212 212 @param v <b>mixed</b> Setting value … … 217 217 // a setting directly, without passing via a namespace. 218 218 $this->raiseDeprecated('old_style_set'); 219 219 220 220 if (!$this->ns) { 221 221 throw new Exception(__('No namespace specified')); 222 222 } 223 223 224 224 if (isset($this->namespaces[$this->ns]->$n)) { 225 225 $this->namespaces[$this->ns]->$n['value'] = $v; … … 234 234 } 235 235 } 236 236 237 237 /** 238 238 @deprecated Please access your settings via $core->blog->settings->{namespace}->... 239 239 240 240 Sets a working namespace. You should do this before accessing any setting. 241 241 242 242 @param ns <b>string</b> Namespace name 243 243 */ … … 251 251 } 252 252 } 253 253 254 254 /** 255 255 @deprecated Please set your settings via $core->blog->settings->{namespace}->put() 256 256 257 257 Creates or updates a setting. 258 258 259 259 $type could be 'string', 'integer', 'float', 'boolean' or null. If $type is 260 260 null and setting exists, it will keep current setting type. 261 261 262 262 $value_change allow you to not change setting. Useful if you need to change 263 263 a setting label or type and don't want to change its value. 264 264 265 265 Don't forget to set namespace before calling this method. 266 266 267 267 @param id <b>string</b> Setting ID 268 268 @param value <b>mixed</b> Setting value … … 284 284 $this->namespaces[$this->ns]->put($id, $value, $type, $label, $value_change, $global); 285 285 } 286 286 287 287 /** 288 288 @deprecated Please get your settings via $core->blog->settings->{namespace}->{setting} 289 289 290 290 Returns setting value if exists. 291 291 292 292 @param n <b>string</b> Setting name 293 293 @return <b>mixed</b> … … 307 307 } 308 308 } 309 309 310 310 return null; 311 311 } 312 312 313 313 /** 314 314 @deprecated Please get your settings via $core->blog->settings->{namespace}->dumpSettings 315 315 316 316 Returns all settings content. 317 317 318 318 @return <b>array</b> 319 319 */ … … 323 323 // the settings directly, without passing via a namespace. 324 324 $this->raiseDeprecated('dumpSettings'); 325 325 326 326 $settings = array(); 327 327 // Parse all the namespaces … … 329 329 $settings = array_merge($settings, $this->namespaces[$ns]->dumpSettings()); 330 330 } 331 331 332 332 return $settings; 333 333 } 334 334 335 335 /** 336 336 @deprecated Please get your settings via $core->blog->settings->{namespace}->dumpGlobalSettings 337 337 338 338 Returns all global settings content. 339 339 340 340 @return <b>array</b> 341 341 */ … … 345 345 // the settings directly, without passing via a namespace. 346 346 $this->raiseDeprecated('dumpGlobalSettings'); 347 347 348 348 $settings = array(); 349 349 // Parse all the namespaces … … 351 351 $settings = array_merge($settings, $this->namespaces[$ns]->dumpGlobalSettings()); 352 352 } 353 353 354 354 return $settings; 355 355 } … … 359 359 <b>$params</b> is an array taking the following 360 360 optionnal parameters: 361 361 362 362 - ns : retrieve setting from given namespace 363 363 - id : retrieve only settings corresponding to the given id 364 364 365 365 @param params <b>array</b> Parameters 366 @return <b>record</b> A record 366 @return <b>record</b> A record 367 367 */ 368 368 public function getGlobalSettings($params=array()) … … 392 392 /** 393 393 Updates a setting from a given record 394 394 395 395 @param rs <b>record</b> the setting to update 396 396 */ 397 public function updateSetting($rs) 397 public function updateSetting($rs) 398 398 { 399 399 $cur = $this->con->openCursor($this->table); … … 411 411 $cur->update($where."AND setting_id = '".$this->con->escape($cur->setting_id)."' AND setting_ns = '".$this->con->escape($cur->setting_ns)."' "); 412 412 } 413 413 414 414 /** 415 415 Drops a setting from a given record 416 416 417 417 @param rs <b>record</b> the setting to drop 418 418 @return int number of deleted records (0 if setting does not exist) … … 429 429 } 430 430 } 431 ?>
Note: See TracChangeset
for help on using the changeset viewer.