PluginProbe
Import Social Events / 1.8.5
Import Social Events v1.8.5
1.9.1 1.9.0 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 All 61 releases
import-facebook-events / includes / lib / icalcreator / src / Traits / REQUEST_STATUStrait.php

REQUEST_STATUStrait.php in Import Social Events 1.8.5, at includes/lib/icalcreator/src/Traits/REQUEST_STATUStrait.php

184 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * iCalcreator, the PHP class package managing iCal (rfc2445/rfc5445) calendar information.
4 *
5 * copyright (c) 2007-2021 Kjell-Inge Gustafsson, kigkonsult, All rights reserved
6 * Link https://kigkonsult.se
7 * Package iCalcreator
8 * Version 2.30
9 * License Subject matter of licence is the software iCalcreator.
10 * The above copyright, link, package and version notices,
11 * this licence notice and the invariant [rfc5545] PRODID result use
12 * as implemented and invoked in iCalcreator shall be included in
13 * all copies or substantial portions of the iCalcreator.
14 *
15 * iCalcreator is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License as published
17 * by the Free Software Foundation, either version 3 of the License,
18 * or (at your option) any later version.
19 *
20 * iCalcreator is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public License
26 * along with iCalcreator. If not, see <https://www.gnu.org/licenses/>.
27 *
28 * This file is a part of iCalcreator.
29 */
30
31 namespace Kigkonsult\Icalcreator\Traits;
32
33 use Kigkonsult\Icalcreator\Util\StringFactory;
34 use Kigkonsult\Icalcreator\Util\Util;
35 use Kigkonsult\Icalcreator\Util\ParameterFactory;
36 use InvalidArgumentException;
37
38 use function number_format;
39 use function filter_var;
40 use function sprintf;
41 use function var_export;
42
43 /**
44 * REQUEST-STATUS property functions
45 *
46 * @author Kjell-Inge Gustafsson, kigkonsult <[email protected]>
47 * @since 2.29.14 2019-09-03
48 */
49 trait REQUEST_STATUStrait
50 {
51 /**
52 * @var array component property REQUEST-STATUS value
53 */
54 protected $requeststatus = null;
55
56 /**
57 * Return formatted output for calendar component property request-status
58 *
59 * @return string
60 * @since 2.29.9 2019-08-05
61 */
62 public function createRequeststatus()
63 {
64 if( empty( $this->requeststatus )) {
65 return null;
66 }
67 $output = null;
68 $lang = $this->getConfig( self::LANGUAGE );
69 foreach( $this->requeststatus as $rx => $rStat ) {
70 if( empty( $rStat[Util::$LCvalue][self::STATCODE] )) {
71 if( $this->getConfig( self::ALLOWEMPTY )) {
72 $output .= StringFactory::createElement( self::REQUEST_STATUS );
73 }
74 continue;
75 }
76 $content =
77 $rStat[Util::$LCvalue][self::STATCODE] .
78 Util::$SEMIC .
79 StringFactory::strrep( $rStat[Util::$LCvalue][self::STATDESC] );
80 if( isset( $rStat[Util::$LCvalue][self::EXTDATA] )) {
81 $content .= Util::$SEMIC .
82 StringFactory::strrep( $rStat[Util::$LCvalue][self::EXTDATA] );
83 }
84 $output .= StringFactory::createElement(
85 self::REQUEST_STATUS,
86 ParameterFactory::createParams(
87 $rStat[Util::$LCparams],
88 [ self::LANGUAGE ],
89 $lang
90 ),
91 $content
92 );
93 } // end foreach
94 return $output;
95 }
96
97 /**
98 * Delete calendar component property request-status
99 *
100 * @param int $propDelIx specific property in case of multiply occurrence
101 * @return bool
102 * @since 2.27.1 - 2018-12-15
103 */
104 public function deleteRequeststatus( $propDelIx = null )
105 {
106 if( empty( $this->requeststatus )) {
107 unset( $this->propDelIx[self::REQUEST_STATUS] );
108 return false;
109 }
110 return $this->deletePropertyM(
111 $this->requeststatus,
112 self::REQUEST_STATUS,
113 $propDelIx
114 );
115 }
116
117 /**
118 * Get calendar component property request-status
119 *
120 * @param int $propIx specific property in case of multiply occurrence
121 * @param bool $inclParam
122 * @return bool|array
123 * @since 2.29.9 2019-08-05
124 */
125 public function getRequeststatus( $propIx = null, $inclParam = false )
126 {
127 if( empty( $this->requeststatus )) {
128 unset( $this->propIx[self::REQUEST_STATUS] );
129 return false;
130 }
131 return $this->getPropertyM(
132 $this->requeststatus,
133 self::REQUEST_STATUS,
134 $propIx,
135 $inclParam
136 );
137 }
138
139 /**
140 * Set calendar component property request-status
141 *
142 * @param array|float $statCode 1*DIGIT 1*2("." 1*DIGIT)
143 * @param string $text
144 * @param string $extData
145 * @param array $params
146 * @param integer $index
147 * @return static
148 * @throws InvalidArgumentException
149 * @since 2.29.14 2019-09-03
150 */
151 public function setRequeststatus(
152 $statCode = null,
153 $text = null,
154 $extData = null,
155 $params = null,
156 $index = null
157 ) {
158 static $ERR = 'Invalid %s status code value %s';
159 if( empty( $statCode ) || empty( $text )) {
160 $this->assertEmptyValue( Util::$SP0, self::REQUEST_STATUS );
161 $statCode = $text = Util::$SP0;
162 $params = [];
163 }
164 else {
165 if( false === ( $cmp = filter_var( $statCode, FILTER_VALIDATE_FLOAT ))) {
166 throw new InvalidArgumentException(
167 sprintf( $ERR, self::REQUEST_STATUS, var_export( $statCode, true ) )
168 );
169 }
170 Util::assertString( $text, self::REQUEST_STATUS );
171 }
172 $input = [
173 self::STATCODE => number_format( (float) $statCode, 2, Util::$DOT, null ),
174 self::STATDESC => StringFactory::trimTrailNL( $text ),
175 ];
176 if( ! empty( $extData )) {
177 Util::assertString( $extData, self::REQUEST_STATUS );
178 $input[self::EXTDATA] = StringFactory::trimTrailNL( $extData );
179 }
180 $this->setMval( $this->requeststatus, $input, $params, null, $index );
181 return $this;
182 }
183 }
184