1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
include.php
См. документацию.
1<?php
2
4 'workflow',
5 [
6 'CWorkflow' => 'classes/general/workflow.php',
7 'CWorkflowStatus' => 'classes/general/status.php',
8 ],
9);
10
12{
13 return '<' . "?\n"
14 . "require(\$_SERVER[\"DOCUMENT_ROOT\"].\"/bitrix/modules/main/include/prolog_before.php\");\n"
15 . '$APPLICATION->SetTitle("' . EscapePHPString($title) . "\");\n"
16 . "require(\$_SERVER[\"DOCUMENT_ROOT\"].\"/bitrix/modules/main/include/prolog_after.php\");\n"
17 . '?' . ">\n";
18}
19
21{
22 return "\n<" . '?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog.php");?' . '>';
23}
24
25function PathToWF($text, $DOCUMENT_ID)
26{
27 return preg_replace("'(<img[^>]+?src\\s*=\\s*\")(\\S+)(\"[^>]*>)'i", "\\1/bitrix/admin/workflow_get_file.php?did=" . $DOCUMENT_ID . "&fname=\\2\\3", $text);
28}
29
30function convert_image($img='', $query='', $param='')
31{
32 if (is_array($img))
33 {
34 $param = $img[3];
35 $query = $img[2];
36 $img = $img[1];
37 }
38 else
39 {
40 $param = stripslashes($param);
41 $query = stripslashes($query);
42 $img = stripslashes($img);
43 }
44 $params = [];
46
47 return $img . $params['fname'] . $param;
48}
49
50function WFToPath($text)
51{
52 return preg_replace_callback("'(<img[^>]+?src\\s*=\\s*[\"\'])/bitrix/admin/workflow_get_file.php\\?([^>]+)([\"\'][^>]*>)'i", 'convert_image', $text);
53}
54
55function SavePreviewContent($abs_path, $strContent)
56{
58 $fd = fopen($abs_path, 'wb');
59 if (is_resource($fd))
60 {
61 $result = fwrite($fd, $strContent);
62 fclose($fd);
63 chmod($abs_path, BX_FILE_PERMISSIONS);
64
65 return $result > 0;
66 }
67 else
68 {
69 return false;
70 }
71}
72
73//http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
74//function LCS(X[1..m], Y[1..n])
76{
77// m_start := 1
78 $m_start = 0;
79// m_end := m
80 $m_end = count($X) - 1;
81// n_start := 1
82 $n_start = 0;
83// n_end := n
84 $n_end = count($Y) - 1;
85// C = array(m_start-1..m_end, n_start-1..n_end)
86 $C = [];
87// for($i = $m_start-1; $i <= $m_end; $i++)
88// {
89// $C[$i] = array();
90// for($j = $n_start-1; $j <= $n_end; $j++)
91// {
92// $C[$i][$j] = 0;
93// }
94// }
95// for i := m_start..m_end
96 for ($i = $m_start; $i <= $m_end; $i++)
97 {
98// for j := n_start..n_end
99 for ($j = $n_start; $j <= $n_end; $j++)
100 {
101// if X[i] = Y[j]
102 if ($X[$i] == $Y[$j])
103 {
104// C[i, j] := C[i-1, j-1] + 1
105 $C[$i][$j] = $C[$i - 1][$j - 1] + 1;
106 }
107// else:
108 else
109 {
110 $k = max($C[$i][$j - 1], $C[$i - 1][$j]);
111// C[i, j] := max(C[i, j-1], C[i-1, j])
112 if ($k != 0)
113 {
114 $C[$i][$j] = $k;
115 //Clean up to the left
116 if ($C[$i][$j - 1] < $k)
117 {
118 for ($jj = $j - 1;$jj >= $n_start;$jj--)
119 {
120 if (is_array($C[$i]) && array_key_exists($jj, $C[$i]))
121 {
122 unset($C[$i][$jj]);
123 }
124 else
125 {
126 break;
127 }
128 }
129 }
130 }
131 }
132 }
133 //Clean up to the up
134 if ($i > $m_start)
135 {
136 $ii = $i - 1;
137 if (is_array($C[$ii]))
138 {
139 for ($j = $n_end; $j > $n_start && array_key_exists($j, $C[$ii]); $j--)
140 {
141 if ($C[$i][$j] > $C[$ii][$j])
142 {
143 unset($C[$ii][$j]);
144 }
145 }
146 }
147 }
148 }
149
150// return C[m, n]
151 return $C;
152}
153
154//function printDiff(C[0..m, 0..n], X[1..m], Y[1..n], i, j)
155// if i > 0 and j > 0 and X[i] = Y[j]
156// printDiff(C, X, Y, i-1, j-1)
157// print " " + X[i]
158// else
159// if j > 0 and (i = 0 or C[i, j-1] >= C[i-1, j])
160// printDiff(C, X, Y, i, j-1)
161// print "+ " + Y[j]
162// else if i > 0 and (j = 0 or C[i, j-1] < C[i-1, j])
163// printDiff(C, X, Y, i-1, j)
164// print "- " + X[i]
165
166function printDiff($C, $X, $Y, $Xt, $Yt, $i, $j)
167{
168 $a = [];
169 while ($i >= 0 || $j >= 0)
170 {
171 if ( ($i >= 0) && ($j >= 0) && ($Xt[$i] == $Yt[$j]) )
172 {
173 array_unshift($a, $X[1][$i] . $X[2][$i]);
174 $i--; $j--;
175 }
176 elseif ( ($j >= 0) && ($i <= 0 || ($C[$i][$j - 1] >= $C[$i - 1][$j])) )
177 {
178 array_unshift($a, $Y[1][$j] . '<b style="color:green">', $Y[2][$j], '</b >');
179 $j--;
180 }
181 elseif ( ($i >= 0) && ($j <= 0 || ($C[$i][$j - 1] < $C[$i - 1][$j])) )
182 {
183 array_unshift($a, $X[1][$i] . '<s style="color:red">', $X[2][$i], '</s >');
184 $i--;
185 }
186 }
187 echo implode('', $a);
188}
189
190function getDiff($X, $Y)
191{
192
193 preg_match_all('/(<.*?>\s*|\s+)([^\s<]*)/', ' ' . $X, $Xmatch);
194 preg_match_all('/(<.*?>\s*|\s+)([^\s<]*)/', ' ' . $Y, $Ymatch);
195
196 //Determine common beginning
197 $sHTMLStart = '';
198 while ( count($Xmatch[0]) && count($Ymatch[0]) && (trim($Xmatch[2][0]) == trim($Ymatch[2][0])) )
199 {
200 $sHTMLStart .= $Xmatch[0][0];
201 array_shift($Xmatch[0]);array_shift($Xmatch[1]);array_shift($Xmatch[2]);
202 array_shift($Ymatch[0]);array_shift($Ymatch[1]);array_shift($Ymatch[2]);
203 }
204
205 //Find common ending
206 $X_end = count($Xmatch[0]) - 1;
207 $Y_end = count($Ymatch[0]) - 1;
208 $sHTMLEnd = '';
209 while ( ($X_end >= 0) && ($Y_end >= 0) && (trim($Xmatch[2][$X_end]) == trim($Ymatch[2][$Y_end])) )
210 {
211 $sHTMLEnd = $Xmatch[0][$X_end] . $sHTMLEnd;
212 unset($Xmatch[0][$X_end]);unset($Xmatch[1][$X_end]);unset($Xmatch[2][$X_end]);
213 unset($Ymatch[0][$Y_end]);unset($Ymatch[1][$Y_end]);unset($Ymatch[2][$Y_end]);
214 $X_end--;
215 $Y_end--;
216 }
217
218 //What will actually diff
219 $Xmatch_trimmed = [];
220 foreach ($Xmatch[2] as $i => $match)
221 {
222 $Xmatch_trimmed[] = trim($match);
223 }
224
225 $Ymatch_trimmed = [];
226 foreach ($Ymatch[2] as $i => $match)
227 {
228 $Ymatch_trimmed[] = trim($match);
229 }
230
231 ob_start();
232 printDiff(
233 LongestCommonSubsequence($Xmatch_trimmed, $Ymatch_trimmed),
234 $Xmatch,
235 $Ymatch,
236 $Xmatch_trimmed,
237 $Ymatch_trimmed,
238 count($Xmatch_trimmed) - 1,
239 count($Ymatch_trimmed) - 1,
240 );
241 $sHTML = ob_get_contents();
242 ob_end_clean();
243
244 $sHTML = preg_replace('#</b >(\s*)<b style="color:green">#', '\\1', $sHTML);
245 $sHTML = preg_replace('#<b style="color:green">(\s*)</b >#', '\\1', $sHTML);
246 $sHTML = preg_replace('#</s >(\s*)<s style="color:red">#', '\\1', $sHTML);
247 $sHTML = preg_replace('#<s style="color:red">(\s*)</s >#', '\\1', $sHTML);
248
249 return $sHTMLStart . $sHTML . $sHTMLEnd;
250}
static AddAutoloadClasses($module, $arParams=[])
Определения module.php:27
$abs_path
Определения component_props2.php:76
$result
Определения get_property_values.php:14
$query
Определения get_search.php:11
EscapePHPString($str, $encloser='"')
Определения tools.php:4917
CheckDirPath($path)
Определения tools.php:2707
htmlspecialcharsback($str)
Определения tools.php:2693
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$text
Определения template_pdf.php:79
$i
Определения factura.php:643
</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($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
else $a
Определения template.php:137
$title
Определения pdf.php:123
$k
Определения template_pdf.php:567
GetDefaultProlog($title)
Определения include.php:11
SavePreviewContent($abs_path, $strContent)
Определения include.php:55
printDiff($C, $X, $Y, $Xt, $Yt, $i, $j)
Определения include.php:166
LongestCommonSubsequence($X, $Y)
Определения include.php:75
PathToWF($text, $DOCUMENT_ID)
Определения include.php:25
getDiff($X, $Y)
Определения include.php:190
GetDefaultEpilog()
Определения include.php:20
convert_image($img='', $query='', $param='')
Определения include.php:30
WFToPath($text)
Определения include.php:50