1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
clearnpath.php
См. документацию.
1<?php
2
3interface ILearnPath
4{
10 public function __construct();
11
16 public function SetPath();
17
21 public function SetPathFromArray($arPath);
22
26 public function ImportUrlencoded($str);
27
31 public function ExportUrlencoded();
32
36 public function GetPathAsArray();
37
41 public function GetTop();
42
46 public function GetBottom();
47
52 public function PopBottom();
53
58 public function ShiftTop();
59
60
64 public function Count();
65
66
75 public function GetPathAsHumanReadableString($delimiter = ' / ', $pattern = '#NAME#');
76}
77
78class CLearnPath implements ILearnPath
79{
80 const DELIMITER = '.';
81 protected $arPath = array();
82
83 public function __construct ()
84 {
85 $this->_SetPath (func_get_args());
86 }
87
88 public function SetPath ()
89 {
90 $this->_SetPath (func_get_args());
91 }
92
93 protected function _SetPath ($args)
94 {
95 // If only one arguments and it's an array => set path from array.
96 if ( (count($args) == 1) && (is_array($args[0])) )
97 {
98 $this->_SetPath ($args[0]);
99 return;
100 }
101
102 $this->arPath = array();
103
104 foreach ($args as $key => $lessonId)
105 {
106 if (
107 ( ! is_numeric($lessonId) )
108 || ( ! is_int($lessonId + 0) )
109 )
110 {
111 $this->arPath = array();
112 return;
113 }
114
115 $this->arPath[] = (int) ($lessonId);
116 }
117 }
118
119 public function SetPathFromArray($arPath)
120 {
121 $this->_SetPath ($arPath);
122 }
123
124 // returns true if $str is path with two or more elements
125 public static function IsUrlencodedPath ($str)
126 {
127 $tmp = urldecode($str);
128
129 if (mb_strpos($tmp, self::DELIMITER) !== false)
130 return (true);
131 else
132 return (false);
133 }
134
135
136 public function ImportUrlencoded($str)
137 {
138 $this->arPath = array();
139
140 $tmp = urldecode($str);
141 if ($tmp == '')
142 {
143 return;
144 }
145
146 $arPath = explode(self::DELIMITER, $tmp);
147 if ( ! is_array($arPath) )
148 {
149 return;
150 }
151
152 $this->_SetPath($arPath);
153 }
154
155 public function GetPathAsArray()
156 {
157 return ($this->arPath);
158 }
159
160 public function ExportUrlencoded()
161 {
162 return (urlencode(implode(self::DELIMITER, $this->arPath)));
163 }
164
165 public function GetTop()
166 {
167 if ( ! isset($this->arPath[0]) )
168 return (false);
169
170 return ($this->arPath[0]);
171 }
172
173 public function GetBottom()
174 {
175 $count = count ($this->arPath);
176 if ( ! isset($this->arPath[$count - 1]) )
177 return (false);
178
179 return ($this->arPath[$count - 1]);
180 }
181
182
183 public function PopBottom()
184 {
185 $popped = array_pop ($this->arPath);
186
187 // If there is no elements was in path
188 if ($popped === NULL)
189 return (false);
190
191 return ($popped);
192 }
193
194
195 public function ShiftTop()
196 {
197 $shifted = array_shift ($this->arPath);
198
199 // If there is no elements was in path
200 if ($shifted === NULL)
201 return (false);
202
203 return ($shifted);
204 }
205
206
207 public function GetPathAsHumanReadableString($delimiter = ' / ', $pattern = '#NAME#')
208 {
209 $arHumanReadablePath = array();
210 foreach ($this->arPath as $lessonId)
211 {
212 $rc = CLearnLesson::GetByID($lessonId);
213 $rc = $rc->Fetch();
214 $id = '???';
215 $name = '???';
216 if (isset($rc['LESSON_ID']))
217 $id = $rc['LESSON_ID'];
218
219 if (isset($rc['NAME']))
220 $name = htmlspecialcharsbx($rc['NAME']);
221
222 $txt = $pattern;
223 $txt = str_replace('#LESSON_ID#', $id, $txt);
224 $txt = str_replace('#NAME#', $name, $txt);
225
226 $arHumanReadablePath[] = $txt;
227 }
228
229 return (implode($delimiter, $arHumanReadablePath));
230 }
231
232
233 public function Count()
234 {
235 return (count($this->arPath));
236 }
237}
$count
Определения admin_tab.php:4
static GetByID($id)
Определения clearnlesson.php:1148
Определения clearnpath.php:79
__construct()
Определения clearnpath.php:83
PopBottom()
Определения clearnpath.php:183
GetPathAsHumanReadableString($delimiter='/', $pattern='#NAME#')
Определения clearnpath.php:207
SetPath()
Определения clearnpath.php:88
GetPathAsArray()
Определения clearnpath.php:155
_SetPath($args)
Определения clearnpath.php:93
ShiftTop()
Определения clearnpath.php:195
$arPath
Определения clearnpath.php:81
Count()
Определения clearnpath.php:233
GetTop()
Определения clearnpath.php:165
ImportUrlencoded($str)
Определения clearnpath.php:136
GetBottom()
Определения clearnpath.php:173
const DELIMITER
Определения clearnpath.php:80
SetPathFromArray($arPath)
Определения clearnpath.php:119
static IsUrlencodedPath($str)
Определения clearnpath.php:125
ExportUrlencoded()
Определения clearnpath.php:160
$str
Определения commerceml2.php:63
if(!is_array($prop["VALUES"])) $tmp
Определения component_props.php:203
$arPath
Определения file_edit.php:72
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения clearnpath.php:4
GetPathAsHumanReadableString($delimiter='/', $pattern='#NAME#')
ImportUrlencoded($str)
SetPathFromArray($arPath)
ExportUrlencoded()
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
$name
Определения menu_edit.php:35
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if(!Loader::includeModule('sale')) $pattern
Определения index.php:20