XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
XCube_Property.class.php
1<?php
14
22 public function __construct( $name ) {
23 }
24
31 public function set( $value ) {
32 }
33
39 public function get() {
40 }
41
48 public function setValue( $arg0 = null, $arg1 = null ) {
49 $this->set( $arg0, $arg1 );
50 }
51
58 public function getValue( $arg0 = null ) {
59 return $this->get( $arg0 );
60 }
61
67 public function isArray() {
68 }
69
75 public function isNull() {
76 }
77
83 public function toNumber() {
84 }
85
91 public function toString() {
92 }
93
100 public function toHTML() {
101 }
102
108 public function hasFetchControl() {
109 }
110
117 public function fetch( &$form ) {
118 }
119}
120
130 public $mName;
131
136 public $mValue;
137
144 public function __construct( $name ) {
145 parent::__construct( $name );
146 //parent::XCube_PropertyInterface($name);
147 $this->mName = $name;
148 }
149
156 public function set( $value ) {
157 $this->mValue = $value;
158 }
159
168 public function get( $index = null ) {
169 return $this->mValue;
170 }
171
181 public function isArray() {
182 return false;
183 }
184
190 public function isNull() {
191 return null === $this->mValue || (is_string($this->mValue) && trim($this->mValue) === '');
192 }
193
199 public function toNumber() {
200 return $this->mValue;
201 }
202
208 public function toString() {
209 return $this->mValue;
210 }
211
218 public function toHTML() {
219 return htmlspecialchars( $this->toString(), ENT_QUOTES );
220 }
221
227 public function hasFetchControl() {
228 return false;
229 }
230}
231
244 public $mName;
245
250 public $mProperties = [];
251
259
267
268 public function __construct( $classname, $name ) {
269 $this->mPropertyClassName = $classname;
270 $this->mName = $name;
271 }
272
288 public function set( $arg1, $arg2 = null ) {
289 if ( is_array( $arg1 ) && $arg2 === null ) {
290 $this->reset();
291 foreach ( $arg1 as $t_key => $t_value ) {
292 $this->_set( $t_key, $t_value );
293 }
294 } elseif ( $arg1 === null && $arg2 === null ) { //ex) all checkbox options are off
295 $this->reset();
296 } elseif ( $arg1 !== null && $arg2 !== null ) {
297 $this->_set( $arg1, $arg2 );
298 }
299 }
300
308 public function add( $arg1, $arg2 = null ) {
309 if ( is_array( $arg1 ) && $arg2 === null ) {
310 foreach ( $arg1 as $t_key => $t_value ) {
311 $this->_set( $t_key, $t_value );
312 }
313 } elseif ( $arg1 !== null && $arg2 !== null ) {
314 $this->_set( (string) $arg1, $arg2 );
315 }
316 }
317
327 public function _set( $index, $value ) {
328 if ( ! isset( $this->mProperties[ $index ] ) ) {
329 $this->mProperties[ $index ] = new $this->mPropertyClassName( $this->mName );
330 }
331 $this->mProperties[ $index ]->set( $value );
332 }
333
342 public function get( $index = null ) {
343 if ( null === $index ) {
344 $ret = [];
345
346 foreach ( $this->mProperties as $t_key => $t_value ) {
347 $ret[ $t_key ] = $t_value->get();
348 }
349
350 return $ret;
351 }
352
353 return isset( $this->mProperties[ $index ] ) ? $this->mProperties[ $index ]->get() : null;
354 }
355
360 public function reset() {
361 unset( $this->mProperties );
362 $this->mProperties = [];
363 }
364
374 public function isArray() {
375 return true;
376 }
377
383 public function isNull() {
384 return ( 0 === count( $this->mProperties ) );
385 }
386
392 public function toNumber() {
393 return null;
394 }
395
401 public function toString() {
402 return 'Array';
403 }
404
411 public function toHTML() {
412 return htmlspecialchars( $this->toString(), ENT_QUOTES );
413 }
414
420 public function hasFetchControl() {
421 return false;
422 }
423}
424
430 public function __construct( $name ) {
431 parent::__construct( $this->mPropertyClassName, $name );
432 //parent::XCube_GenericArrayProperty($this->mPropertyClassName, $name);
433 }
434}
435
441 public function set( $value ) {
442 $this->mValue = (int) $value ? 1 : 0;
443 }
444}
445
452 public function __construct( $name ) {
453 parent::__construct( 'XCube_BoolProperty', $name );
454 }
455}
456
462 public function set($value) {
463 $this->mValue = (null !== $value && '' !== (string)$value) ? (int)$value : null;
464 }
465}
466
473 public function __construct( $name ) {
474 parent::__construct( 'XCube_IntProperty', $name );
475 }
476}
477
483 public function set( $value ) {
484 $this->mValue = '' !== trim( $value ) ? (float) $value : null;
485 }
486}
487
494 public function __construct( $name ) {
495 parent::__construct( 'XCube_FloatProperty', $name );
496 }
497}
498
507 public function set( $value ) {
508 // if (preg_match_all("/[\\x00-\\x1f]/", $value, $matches, PREG_PATTERN_ORDER)) {
509 // die("Get control code :" . ord($matches[0][0]));
510 // }
511
512 //$this->mValue = preg_replace( "/[\\x00-\\x1f]/", '', $value );
513 // v2.5.0 PHP8.2
514 $this->mValue = filter_var($value, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
515 }
516
517 public function toNumber() {
518 return (int) $this->mValue;
519 }
520}
521
528 public function __construct( $name ) {
529 parent::__construct( 'XCube_StringProperty', $name );
530 }
531}
532
541 public function set( $value ) {
542 $matches = [];
543
544 // if (preg_match_all("/[\\x00-\\x08]|[\\x0b-\\x0c]|[\\x0e-\\x1f]/", $value, $matches,PREG_PATTERN_ORDER)) {
545 // die("Get control code :" . ord($matches[0][0]));
546 // }
547
548 $this->mValue = preg_replace( "/[\\x00-\\x08]|[\\x0b-\\x0c]|[\\x0e-\\x1f]/", '', $value );
549 }
550
551 public function toNumber() {
552 return (int) $this->mValue;
553 }
554}
555
562 public function __construct( $name ) {
563 parent::__construct( 'XCube_TextProperty', $name );
564 }
565}
566
579 public $mIndex;
580
581 public function __construct( $name ) {
582 parent::__construct( $name );
583 $this->mValue = new XCube_FormFile( $name );
584 }
585
586 public function hasFetchControl() {
587 return true;
588 }
589
590 public function fetch( &$form ) {
591 if ( ! is_object( $this->mValue ) ) {
592 return false;
593 }
594
595 if ( null !== $this->mIndex ) {
596 $this->mValue->mKey = $this->mIndex;
597 }
598
599 $this->mValue->fetch();
600
601 if ( ! $this->mValue->hasUploadFile() ) {
602 $this->mValue = null;
603 }
604 }
605
606 public function isNull() {
607 if ( ! is_object( $this->mValue ) ) {
608 return true;
609 }
610
611 return ! $this->mValue->hasUploadFile();
612 }
613
614 public function toString() {
615 return null;
616 }
617
618 public function toNumber() {
619 return null;
620 }
621}
622
629 public function __construct( $name ) {
630 parent::__construct( 'XCube_FileProperty', $name );
631 }
632
633 public function hasFetchControl() {
634 return true;
635 }
636
637 public function fetch( &$form ) {
638 unset( $this->mProperties );
639 $this->mProperties = [];
640 if ( isset( $_FILES[ $this->mName ] ) && is_array( $_FILES[ $this->mName ]['name'] ) ) {
641 foreach ( $_FILES[ $this->mName ]['name'] as $_key => $_val ) {
642 $this->mProperties[ $_key ] = new $this->mPropertyClassName( $this->mName );
643 $this->mProperties[ $_key ]->mIndex = $_key;
644 $this->mProperties[ $_key ]->fetch( $form );
645 }
646 }
647 }
648}
649
656 public function __construct( $name ) {
657 parent::__construct( $name );
658 $this->mValue = new XCube_FormImageFile( $name );
659 }
660}
661
668 public function __construct( $name ) {
669 parent::__construct( 'XCube_ImageFileProperty', $name );
670 }
671}
[Abstract] The base class which implements XCube_PropertyInterface, for all properties.
isArray()
Gets a value indicating whether this object expresses Array.
toNumber()
Gets a value as integer.
isNull()
Gets a value indicating whether this object is null.
toString()
Gets a value as string.
__construct( $name)
Constructor.
hasFetchControl()
Gets a value indicating whether this object has a fetch control.
toHTML()
Gets a value as encoded HTML code.
Represents bool[] property. XCube_GenericArrayProperty<XCube_BoolProperty>.
__construct( $name)
Constructor.
Represents bool property.
Represents the special property[] which handles uploaded file. XCube_GenericArrayProperty<XCube_FileP...
__construct( $name)
Constructor.
hasFetchControl()
Gets a value indicating whether this object has a fetch control.
Represents the special property which handles uploaded file.
toNumber()
Gets a value as integer.
$mIndex
mixed - ID for XCube_FileArrayProperty.
isNull()
Gets a value indicating whether this object is null.
toString()
Gets a value as string.
__construct( $name)
Constructor.
hasFetchControl()
Gets a value indicating whether this object has a fetch control.
Represents float[] property. XCube_GenericArrayProperty<XCube_FloatProperty>.
Represents float property.
[Abstract] Defines common array property class which implements XCube_PropertyInterface.
isArray()
Gets a value indicating whether this object expresses Array.
toNumber()
Gets a value as integer — but, gets null always.
reset()
Resets all properties of this.
isNull()
Gets a value indicating whether this object is null.
toString()
Gets a value as string — but, gets 'Array' always.
__construct( $classname, $name)
Constructor.
$mProperties
XCube_AbstractProperty[] - std::map<mixed_key, mixed_value>
hasFetchControl()
Gets a value indicating whether this object has a fetch control.
_set( $index, $value)
This member function helps set().
toHTML()
Gets a value as encoded HTML code — but, gets 'Array' always.
XCube_GenericArrayProperty<XCube_ImageFileProperty>.
This is extended XCube_FileProperty and limits uploaded files by image files.
__construct( $name)
Constructor.
Represents int[] property. XCube_GenericArrayProperty<XCube_IntProperty>.
__construct( $name)
Constructor.
Represents int property.
isArray()
[Abstract] Gets a value indicating whether this object expresses Array.
toNumber()
[Abstract] Gets a value as integer.
isNull()
[Abstract] Gets a value indicating whether this object is null.
setValue( $arg0=null, $arg1=null)
toString()
[Abstract] Gets a value as string.
__construct( $name)
Constructor.
hasFetchControl()
[Abstract] Gets a value indicating whether this object has a fetch control.
toHTML()
[Abstract] Gets a value as encoded HTML code.
Represents string[] property. XCube_GenericArrayProperty<XCube_StringProperty>.
Represents string property.
toNumber()
Gets a value as integer.
Represents string[] property which allows CR and LF. XCube_GenericArrayProperty<XCube_TextProperty>.
__construct( $name)
Constructor.
Represents string property which allows CR and LF.
toNumber()
Gets a value as integer.