@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * @return mixed |
|
| 72 | + * @return string |
|
| 73 | 73 | */ |
| 74 | 74 | public function getCut() |
| 75 | 75 | { |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | /** |
| 150 | 150 | * @param $resource |
| 151 | 151 | * @param $truncLen |
| 152 | - * @param $truncOffset |
|
| 153 | - * @param $truncChars |
|
| 152 | + * @param integer $truncOffset |
|
| 153 | + * @param boolean $truncChars |
|
| 154 | 154 | * @param string $splitter |
| 155 | 155 | * @return array|mixed|string |
| 156 | 156 | */ |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | /** |
| 244 | 244 | * @param $string |
| 245 | - * @param $limit |
|
| 245 | + * @param integer $limit |
|
| 246 | 246 | * @param string $break |
| 247 | 247 | * @return string |
| 248 | 248 | */ |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | - * @param $str |
|
| 268 | + * @param string $str |
|
| 269 | 269 | * @return mixed |
| 270 | 270 | */ |
| 271 | 271 | protected function rTriming($str) |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | - * @param $id |
|
| 61 | + * @param integer $id |
|
| 62 | 62 | * @return bool |
| 63 | 63 | */ |
| 64 | 64 | protected static function _checkObj($id){ |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | - * @param $field |
|
| 71 | - * @param $id |
|
| 70 | + * @param string $field |
|
| 71 | + * @param integer $id |
|
| 72 | 72 | * @return mixed |
| 73 | 73 | */ |
| 74 | 74 | protected static function _getValue($field, $id){ |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * @param $callback |
|
| 95 | + * @param \Closure $callback |
|
| 96 | 96 | * @return array|mixed |
| 97 | 97 | */ |
| 98 | 98 | protected static function _workValue($callback){ |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @param $email |
| 14 | 14 | * @param bool $dns |
| 15 | - * @return bool |
|
| 15 | + * @return false|string |
|
| 16 | 16 | */ |
| 17 | 17 | public function emailValidate($email, $dns = true) |
| 18 | 18 | { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | - * @param $flag |
|
| 156 | + * @param boolean $flag |
|
| 157 | 157 | * @return $this |
| 158 | 158 | */ |
| 159 | 159 | public function setDebug($flag){ |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | - * @param $name |
|
| 179 | + * @param string $name |
|
| 180 | 180 | * @param null $default |
| 181 | 181 | * @return mixed |
| 182 | 182 | */ |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | - * @param $name |
|
| 232 | + * @param string $name |
|
| 233 | 233 | * @param array $data |
| 234 | 234 | * @param bool $flag |
| 235 | 235 | * @return $this |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | - * @param $name |
|
| 247 | + * @param string $name |
|
| 248 | 248 | * @param array $data |
| 249 | 249 | * @param null $flag |
| 250 | 250 | * @return mixed |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
| 343 | - * @param $id |
|
| 343 | + * @param integer $id |
|
| 344 | 344 | * @return MODxAPI |
| 345 | 345 | */ |
| 346 | 346 | public function switchObject($id){ |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | /** |
| 451 | 451 | * @param $IDs |
| 452 | 452 | * @param string $sep |
| 453 | - * @param array $ignore |
|
| 453 | + * @param integer[] $ignore |
|
| 454 | 454 | * @return array |
| 455 | 455 | * @throws Exception |
| 456 | 456 | */ |
@@ -608,8 +608,8 @@ discard block |
||
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
| 611 | - * @param $table |
|
| 612 | - * @param $field |
|
| 611 | + * @param string $table |
|
| 612 | + * @param string $field |
|
| 613 | 613 | * @param string $PK |
| 614 | 614 | * @return bool |
| 615 | 615 | */ |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | - * @param $version |
|
| 717 | + * @param string $version |
|
| 718 | 718 | * @param bool $dmi3yy |
| 719 | 719 | * @return bool |
| 720 | 720 | */ |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
| 739 | - * @param $name |
|
| 739 | + * @param string $name |
|
| 740 | 740 | * @return bool|mixed |
| 741 | 741 | */ |
| 742 | 742 | protected function eraseField($name) |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | /** |
| 810 | 810 | * Получить список не запакованных полей |
| 811 | - * @return array |
|
| 811 | + * @return DLCollection |
|
| 812 | 812 | */ |
| 813 | 813 | public function getNoEncodeFields(){ |
| 814 | 814 | return $this->_decodedFields->filter(function($value){ |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | 820 | * Получить список не распакованных полей |
| 821 | - * @return array |
|
| 821 | + * @return DLCollection |
|
| 822 | 822 | */ |
| 823 | 823 | public function getNoDecodeFields(){ |
| 824 | 824 | return $this->_decodedFields->filter(function($value){ |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | * Запаковывает конкретное поле в JSON |
| 886 | 886 | * @param string $field Имя поля |
| 887 | 887 | * @param bool $store обновить запакованное поле |
| 888 | - * @return array json строка |
|
| 888 | + * @return string|null json строка |
|
| 889 | 889 | */ |
| 890 | 890 | public function encodeField($field, $store = false){ |
| 891 | 891 | $out = null; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * @param $id |
|
| 25 | + * @param integer $id |
|
| 26 | 26 | * @return bool |
| 27 | 27 | */ |
| 28 | 28 | protected static function checkObj($id) |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * @param $field |
|
| 36 | - * @param $id |
|
| 35 | + * @param string $field |
|
| 36 | + * @param integer $id |
|
| 37 | 37 | * @return mixed |
| 38 | 38 | */ |
| 39 | 39 | protected static function _getValue($field, $id) |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | - * @param $id |
|
| 165 | + * @param integer $id |
|
| 166 | 166 | */ |
| 167 | 167 | protected static function deleteCity($id) |
| 168 | 168 | { |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * @param $id |
|
| 174 | + * @param integer $id |
|
| 175 | 175 | */ |
| 176 | 176 | protected static function deleteStreet($id) |
| 177 | 177 | { |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | /** |
| 406 | 406 | * @param $name |
| 407 | 407 | * @param $table |
| 408 | - * @param $alias |
|
| 409 | - * @return mixed |
|
| 408 | + * @param string $alias |
|
| 409 | + * @return string |
|
| 410 | 410 | */ |
| 411 | 411 | public function TableAlias($name, $table, $alias) |
| 412 | 412 | { |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | /** |
| 471 | 471 | * Разбор JSON строки при помощи json_decode |
| 472 | 472 | * |
| 473 | - * @param $json string строка c JSON |
|
| 473 | + * @param string $json string строка c JSON |
|
| 474 | 474 | * @param array $config ассоциативный массив с настройками для json_decode |
| 475 | 475 | * @param bool $nop создавать ли пустой объект запрашиваемого типа |
| 476 | 476 | * @return array|mixed|xNop |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | * Удаление определенных данных из массива |
| 546 | 546 | * |
| 547 | 547 | * @param array $data массив с данными |
| 548 | - * @param mixed $val значение которые необходимо удалить из массива |
|
| 548 | + * @param string $val значение которые необходимо удалить из массива |
|
| 549 | 549 | * @return array отчищеный массив с данными |
| 550 | 550 | */ |
| 551 | 551 | private function unsetArrayVal($data, $val) |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | /** |
| 844 | 844 | * Получение строки из языкового пакета |
| 845 | 845 | * |
| 846 | - * @param $name имя записи в языковом пакете |
|
| 846 | + * @param string $name имя записи в языковом пакете |
|
| 847 | 847 | * @param string $def Строка по умолчанию, если запись в языковом пакете не будет обнаружена |
| 848 | 848 | * @return string строка в соответствии с текущими языковыми настройками |
| 849 | 849 | */ |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | |
| 1135 | 1135 | /** |
| 1136 | 1136 | * @param array $item |
| 1137 | - * @param null $extSummary |
|
| 1137 | + * @param summary_DL_Extender $extSummary |
|
| 1138 | 1138 | * @param string $introField |
| 1139 | 1139 | * @param string $contentField |
| 1140 | 1140 | * @return mixed|string |
@@ -1189,7 +1189,7 @@ discard block |
||
| 1189 | 1189 | /** |
| 1190 | 1190 | * Вытащить экземпляр класса экстендера из общего массива экстендеров |
| 1191 | 1191 | * |
| 1192 | - * @param $name имя экстендера |
|
| 1192 | + * @param string $name имя экстендера |
|
| 1193 | 1193 | * @param bool $autoload Если экстендер не загружен, то пытаться ли его загрузить |
| 1194 | 1194 | * @param bool $nop если экстендер не загружен, то загружать ли xNop |
| 1195 | 1195 | * @return null|xNop |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * DLCollection constructor. |
| 16 | - * @param array $modx |
|
| 16 | + * @param DocumentParser|null $modx |
|
| 17 | 17 | * @param array $data |
| 18 | 18 | */ |
| 19 | 19 | public function __construct($modx, $data = array()){ |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * @param $q |
|
| 40 | + * @param resource $q |
|
| 41 | 41 | * @param bool $exec |
| 42 | 42 | * @return int |
| 43 | 43 | */ |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | // Parser: Preparation, cleaning and checkup |
| 121 | 121 | /** |
| 122 | 122 | * @param string $template |
| 123 | - * @return mixed|string |
|
| 123 | + * @return string |
|
| 124 | 124 | */ |
| 125 | 125 | public function Parse($template = '') |
| 126 | 126 | { |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | // Parser: modifier detection and eXtended processing if needed |
| 269 | 269 | /** |
| 270 | 270 | * @param $input |
| 271 | - * @param $modifiers |
|
| 271 | + * @param string $modifiers |
|
| 272 | 272 | * @return mixed|null|string |
| 273 | 273 | */ |
| 274 | 274 | public function Filter($input, $modifiers) |
@@ -600,8 +600,8 @@ discard block |
||
| 600 | 600 | // positive userid = manager, negative integer = webuser |
| 601 | 601 | /** |
| 602 | 602 | * @param $userid |
| 603 | - * @param $field |
|
| 604 | - * @return mixed |
|
| 603 | + * @param string $field |
|
| 604 | + * @return string |
|
| 605 | 605 | */ |
| 606 | 606 | public function ModUser($userid, $field) |
| 607 | 607 | { |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | // Returns the value of a PHx/MODx placeholder. |
| 658 | 658 | /** |
| 659 | - * @param $name |
|
| 659 | + * @param string $name |
|
| 660 | 660 | * @return mixed |
| 661 | 661 | */ |
| 662 | 662 | public function getPHxVariable($name) |
@@ -684,9 +684,9 @@ discard block |
||
| 684 | 684 | |
| 685 | 685 | //mbstring |
| 686 | 686 | /** |
| 687 | - * @param $str |
|
| 688 | - * @param $s |
|
| 689 | - * @param null $l |
|
| 687 | + * @param string $str |
|
| 688 | + * @param integer $s |
|
| 689 | + * @param integer $l |
|
| 690 | 690 | * @return string |
| 691 | 691 | */ |
| 692 | 692 | public function substr($str, $s, $l = null) |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | /** |
| 699 | - * @param $str |
|
| 699 | + * @param string $str |
|
| 700 | 700 | * @return int |
| 701 | 701 | */ |
| 702 | 702 | public function strlen($str) |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
| 709 | - * @param $str |
|
| 709 | + * @param string $str |
|
| 710 | 710 | * @return string |
| 711 | 711 | */ |
| 712 | 712 | public function strtolower($str) |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
| 719 | - * @param $str |
|
| 719 | + * @param string $str |
|
| 720 | 720 | * @return string |
| 721 | 721 | */ |
| 722 | 722 | public function strtoupper($str) |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
| 729 | - * @param $str |
|
| 729 | + * @param string $str |
|
| 730 | 730 | * @return string |
| 731 | 731 | */ |
| 732 | 732 | public function ucfirst($str) |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | /** |
| 740 | - * @param $str |
|
| 740 | + * @param string $str |
|
| 741 | 741 | * @return string |
| 742 | 742 | */ |
| 743 | 743 | public function lcfirst($str) |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | /** |
| 751 | - * @param $str |
|
| 751 | + * @param string $str |
|
| 752 | 752 | * @return string |
| 753 | 753 | */ |
| 754 | 754 | public function ucwords($str) |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /** |
| 762 | - * @param $str |
|
| 762 | + * @param string $str |
|
| 763 | 763 | * @return string |
| 764 | 764 | */ |
| 765 | 765 | public function strrev($str) |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
| 772 | - * @param $str |
|
| 772 | + * @param string $str |
|
| 773 | 773 | * @return string |
| 774 | 774 | */ |
| 775 | 775 | public function str_shuffle($str) |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | - * @param $str |
|
| 783 | + * @param string $str |
|
| 784 | 784 | * @return int |
| 785 | 785 | */ |
| 786 | 786 | public function str_word_count($str) |
@@ -25,65 +25,65 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @var string |
| 27 | 27 | */ |
| 28 | - public $name = 'PHx'; |
|
| 28 | + public $name = 'PHx'; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @var string |
| 32 | 32 | */ |
| 33 | - public $version = '2.2.0'; |
|
| 33 | + public $version = '2.2.0'; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @var array |
| 37 | 37 | */ |
| 38 | - public $user = array(); |
|
| 38 | + public $user = array(); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @var array |
| 42 | 42 | */ |
| 43 | - public $cache = array( |
|
| 44 | - 'cm' => array(), |
|
| 45 | - 'ui' => array(), |
|
| 46 | - 'mo' => array() |
|
| 47 | - ); |
|
| 43 | + public $cache = array( |
|
| 44 | + 'cm' => array(), |
|
| 45 | + 'ui' => array(), |
|
| 46 | + 'mo' => array() |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @var array |
| 51 | 51 | */ |
| 52 | - public $safetags = array( |
|
| 53 | - array('~(?<![\[]|^\^)\[(?=[^\+\*\(\[]|$)~s', '~(?<=[^\+\*\)\]]|^)\](?=[^\]]|$)~s'), |
|
| 54 | - array('&_PHX_INTERNAL_091_&', '&_PHX_INTERNAL_093_&'), |
|
| 55 | - array('[', ']') |
|
| 56 | - ); |
|
| 52 | + public $safetags = array( |
|
| 53 | + array('~(?<![\[]|^\^)\[(?=[^\+\*\(\[]|$)~s', '~(?<=[^\+\*\)\]]|^)\](?=[^\]]|$)~s'), |
|
| 54 | + array('&_PHX_INTERNAL_091_&', '&_PHX_INTERNAL_093_&'), |
|
| 55 | + array('[', ']') |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @var array |
| 60 | 60 | */ |
| 61 | - public $console = array(); |
|
| 61 | + public $console = array(); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @var bool|int |
| 65 | 65 | */ |
| 66 | - public $debug = false; |
|
| 66 | + public $debug = false; |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * @var bool |
| 70 | 70 | */ |
| 71 | - public $debugLog = false; |
|
| 71 | + public $debugLog = false; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @var int |
| 75 | 75 | */ |
| 76 | - public $curPass = 0; |
|
| 76 | + public $curPass = 0; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @var int |
| 80 | 80 | */ |
| 81 | - public $maxPasses = 50; |
|
| 81 | + public $maxPasses = 50; |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @var array |
| 85 | 85 | */ |
| 86 | - public $swapSnippetCache = array(); |
|
| 86 | + public $swapSnippetCache = array(); |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * DLphx constructor. |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $this->user["usrid"] = isset($_SESSION['webInternalKey']) ? intval($_SESSION['webInternalKey']) : 0; |
| 98 | 98 | $this->user["id"] = ($this->user["usrid"] > 0) ? (-$this->user["usrid"]) : $this->user["mgrid"]; |
| 99 | 99 | |
| 100 | - $this->debug = ($debug != '') ? $debug : 0; |
|
| 100 | + $this->debug = ($debug != '') ? $debug : 0; |
|
| 101 | 101 | |
| 102 | 102 | $this->maxPasses = ($maxpass != '') ? $maxpass : 50; |
| 103 | 103 | |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | $var_search = array(); |
| 177 | 177 | $var_replace = array(); |
| 178 | 178 | for ($i = 0; $i < $count; $i++) { |
| 179 | - $var_search[] = $matches[0][$i]; |
|
| 180 | - $input = $matches[1][$i]; |
|
| 181 | - $this->Log('MODX Chunk: ' . $input); |
|
| 179 | + $var_search[] = $matches[0][$i]; |
|
| 180 | + $input = $matches[1][$i]; |
|
| 181 | + $this->Log('MODX Chunk: ' . $input); |
|
| 182 | 182 | $input = $modx->mergeChunkContent('{{' . $input . '}}'); |
| 183 | 183 | $var_replace[] = $this->Filter($input, $matches[2][$i]); |
| 184 | 184 | } |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | case "eq": |
| 297 | 297 | $condition[] = intval(($output == $modifier_value[$i])); |
| 298 | 298 | break; |
| 299 | - case "empty": |
|
| 300 | - $condition[] = intval(empty($output)); |
|
| 301 | - break; |
|
| 299 | + case "empty": |
|
| 300 | + $condition[] = intval(empty($output)); |
|
| 301 | + break; |
|
| 302 | 302 | case "notequals": |
| 303 | 303 | case "isnot": |
| 304 | 304 | case "isnt": |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | if (!$isvalid) { |
| 344 | 344 | $output = NULL; |
| 345 | 345 | } |
| 346 | - break; |
|
| 346 | + break; |
|
| 347 | 347 | case "then": |
| 348 | 348 | $conditional = implode(' ', $condition); |
| 349 | 349 | $isvalid = intval(eval("return (" . $conditional . ");")); |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | break; |
| 356 | 356 | case "else": |
| 357 | 357 | $conditional = implode(' ', $condition); |
| 358 | - $isvalid = intval(eval("return (" . $conditional . ");")); |
|
| 358 | + $isvalid = intval(eval("return (" . $conditional . ");")); |
|
| 359 | 359 | if (!$isvalid) { |
| 360 | 360 | $output = $modifier_value[$i]; |
| 361 | 361 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | case "select": |
| 364 | 364 | $raw = explode("&", $modifier_value[$i]); |
| 365 | 365 | $map = array(); |
| 366 | - $count = count($raw); |
|
| 366 | + $count = count($raw); |
|
| 367 | 367 | for ($m = 0; $m < $count; $m++) { |
| 368 | 368 | $mi = explode("=", $raw[$m]); |
| 369 | 369 | $map[$mi[0]] = $mi[1]; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | ##### End of Conditional Modifiers |
| 374 | 374 | |
| 375 | 375 | ##### String Modifiers |
| 376 | - case "default": |
|
| 376 | + case "default": |
|
| 377 | 377 | $output = ($output === '') ? $modifier_value[0] : $output; |
| 378 | 378 | break; |
| 379 | 379 | case "lcase": |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | // If we haven't yet found the modifier, let's look elsewhere |
| 484 | 484 | default: |
| 485 | - $snippet = ''; |
|
| 485 | + $snippet = ''; |
|
| 486 | 486 | // modified by Anton Kuzmin (23.06.2010) // |
| 487 | 487 | $snippetName = 'phx:' . $modifier_cmd[$i]; |
| 488 | 488 | if (isset($modx->snippetCache[$snippetName])) { |
@@ -512,16 +512,16 @@ discard block |
||
| 512 | 512 | $cm = $snippet; |
| 513 | 513 | // end // |
| 514 | 514 | |
| 515 | - if(!empty($cm)){ |
|
| 516 | - ob_start(); |
|
| 517 | - $options = $modifier_value[$i]; |
|
| 518 | - $custom = eval($cm); |
|
| 519 | - $msg = ob_get_contents(); |
|
| 520 | - $output = $msg . $custom; |
|
| 521 | - ob_end_clean(); |
|
| 522 | - }else{ |
|
| 523 | - $output = ''; |
|
| 524 | - } |
|
| 515 | + if(!empty($cm)){ |
|
| 516 | + ob_start(); |
|
| 517 | + $options = $modifier_value[$i]; |
|
| 518 | + $custom = eval($cm); |
|
| 519 | + $msg = ob_get_contents(); |
|
| 520 | + $output = $msg . $custom; |
|
| 521 | + ob_end_clean(); |
|
| 522 | + }else{ |
|
| 523 | + $output = ''; |
|
| 524 | + } |
|
| 525 | 525 | break; |
| 526 | 526 | } |
| 527 | 527 | if (count($condition)) $this->Log(" |--- Condition = '" . $condition[count($condition) - 1] . "'"); |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | // Log pass |
| 584 | - public function LogPass() |
|
| 584 | + public function LogPass() |
|
| 585 | 585 | { |
| 586 | 586 | $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Pass " . $this->curPass . "</div>"; |
| 587 | 587 | } |
@@ -13,428 +13,428 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Video |
| 15 | 15 | { |
| 16 | - /** Ссылка на ролик */ |
|
| 17 | - protected $link; |
|
| 16 | + /** Ссылка на ролик */ |
|
| 17 | + protected $link; |
|
| 18 | 18 | |
| 19 | - /** Распарсенные части ссылки */ |
|
| 20 | - protected $link_parts; |
|
| 19 | + /** Распарсенные части ссылки */ |
|
| 20 | + protected $link_parts; |
|
| 21 | 21 | |
| 22 | - /** Видеохостинг */ |
|
| 23 | - protected $hosting; |
|
| 22 | + /** Видеохостинг */ |
|
| 23 | + protected $hosting; |
|
| 24 | 24 | |
| 25 | - /** Идентификатор видео */ |
|
| 26 | - protected $id; |
|
| 25 | + /** Идентификатор видео */ |
|
| 26 | + protected $id; |
|
| 27 | 27 | |
| 28 | - /** Картинка */ |
|
| 29 | - protected $image; |
|
| 28 | + /** Картинка */ |
|
| 29 | + protected $image; |
|
| 30 | 30 | |
| 31 | - /** Название видео */ |
|
| 32 | - protected $title; |
|
| 31 | + /** Название видео */ |
|
| 32 | + protected $title; |
|
| 33 | 33 | |
| 34 | - /** Видео */ |
|
| 35 | - protected $video; |
|
| 34 | + /** Видео */ |
|
| 35 | + protected $video; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @var int |
| 39 | 39 | */ |
| 40 | - protected $width = 420; |
|
| 40 | + protected $width = 420; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @var int |
| 44 | 44 | */ |
| 45 | - protected $height = 315; |
|
| 45 | + protected $height = 315; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @var bool |
| 49 | 49 | */ |
| 50 | - protected $autoplay = false; |
|
| 50 | + protected $autoplay = false; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @var string |
| 54 | 54 | */ |
| 55 | - public $scheme = 'https'; |
|
| 55 | + public $scheme = 'https'; |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * |
| 59 | 59 | */ |
| 60 | - const YOUTUBE = 'youtube'; |
|
| 60 | + const YOUTUBE = 'youtube'; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * |
| 64 | 64 | */ |
| 65 | - const VIMEO = 'vimeo'; |
|
| 65 | + const VIMEO = 'vimeo'; |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * |
| 69 | 69 | */ |
| 70 | - const RUTUBE = 'rutube'; |
|
| 71 | - |
|
| 72 | - /** Регулярки для определения видеохостинга и идентификатора ролика */ |
|
| 73 | - protected $regexp = array( |
|
| 74 | - self::YOUTUBE => array( //Не используются |
|
| 75 | - '/[http|https]+:\/\/(?:www\.|)youtube\.com\/watch\?(?:.*)?v=([a-zA-Z0-9_\-]+)/i', |
|
| 76 | - '/[http|https]+:\/\/(?:www\.|)youtube\.com\/embed\/([a-zA-Z0-9_\-]+)/i', |
|
| 77 | - '/[http|https]+:\/\/(?:www\.|)youtu\.be\/([a-zA-Z0-9_\-]+)/i' |
|
| 78 | - ), |
|
| 79 | - self::VIMEO => array( //Не используются |
|
| 80 | - '/[http|https]+:\/\/(?:www\.|)vimeo\.com\/([a-zA-Z0-9_\-]+)(&.+)?/i', |
|
| 81 | - '/[http|https]+:\/\/player\.vimeo\.com\/video\/([a-zA-Z0-9_\-]+)(&.+)?/i' |
|
| 82 | - ), |
|
| 83 | - self::RUTUBE => array( |
|
| 84 | - '/[http|https]+:\/\/(?:www\.|)rutube\.ru\/video\/embed\/([a-zA-Z0-9_\-]+)/i', |
|
| 85 | - '/[http|https]+:\/\/(?:www\.|)rutube\.ru\/tracks\/([a-zA-Z0-9_\-]+)(&.+)?/i' |
|
| 86 | - ) |
|
| 87 | - ); |
|
| 88 | - |
|
| 89 | - /** Ссылка на RUtube без идентификатора в адресе */ |
|
| 90 | - protected $regexp_rutube_extra = '/[http|https]+:\/\/(?:www\.|)rutube\.ru\/video\/([a-zA-Z0-9_\-]+)\//i'; |
|
| 91 | - |
|
| 92 | - /** Варианты ссылок, которые поддерживаются */ |
|
| 93 | - protected static $test = array( |
|
| 94 | - 'http://youtube.com/watch?v=ShPq2Dmy6X8', |
|
| 95 | - 'http://www.youtube.com/watch?v=6dwqZw0j_jY&feature=youtu.be', |
|
| 96 | - 'http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel', |
|
| 97 | - 'www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub', |
|
| 98 | - 'http://www.youtube.com/embed/ShPq2Dmy6X8?rel=0', |
|
| 99 | - 'http://youtu.be/ShPq2Dmy6X8', |
|
| 100 | - 'youtu.be/6dwqZw0j_jY', |
|
| 101 | - 'http://www.youtu.be/afa-5HQHiAs', |
|
| 102 | - |
|
| 103 | - 'vimeo.com/55028438', |
|
| 104 | - 'http://player.vimeo.com/video/55028438?title=0&byline=0&portrait=0&badge=0&color=e1a931', |
|
| 105 | - |
|
| 106 | - 'http://rutube.ru/video/6fd81c1c212c002673280850a1c56415/#.UMQYln9yTWQ', |
|
| 107 | - 'http://rutube.ru/video/dec0a58c8cb4d226abc7b1030bbb63b9/?ref=top', |
|
| 108 | - 'rutube.ru/tracks/6032725.html', |
|
| 109 | - 'http://www.rutube.ru/video/embed/6032725', |
|
| 110 | - ); |
|
| 70 | + const RUTUBE = 'rutube'; |
|
| 71 | + |
|
| 72 | + /** Регулярки для определения видеохостинга и идентификатора ролика */ |
|
| 73 | + protected $regexp = array( |
|
| 74 | + self::YOUTUBE => array( //Не используются |
|
| 75 | + '/[http|https]+:\/\/(?:www\.|)youtube\.com\/watch\?(?:.*)?v=([a-zA-Z0-9_\-]+)/i', |
|
| 76 | + '/[http|https]+:\/\/(?:www\.|)youtube\.com\/embed\/([a-zA-Z0-9_\-]+)/i', |
|
| 77 | + '/[http|https]+:\/\/(?:www\.|)youtu\.be\/([a-zA-Z0-9_\-]+)/i' |
|
| 78 | + ), |
|
| 79 | + self::VIMEO => array( //Не используются |
|
| 80 | + '/[http|https]+:\/\/(?:www\.|)vimeo\.com\/([a-zA-Z0-9_\-]+)(&.+)?/i', |
|
| 81 | + '/[http|https]+:\/\/player\.vimeo\.com\/video\/([a-zA-Z0-9_\-]+)(&.+)?/i' |
|
| 82 | + ), |
|
| 83 | + self::RUTUBE => array( |
|
| 84 | + '/[http|https]+:\/\/(?:www\.|)rutube\.ru\/video\/embed\/([a-zA-Z0-9_\-]+)/i', |
|
| 85 | + '/[http|https]+:\/\/(?:www\.|)rutube\.ru\/tracks\/([a-zA-Z0-9_\-]+)(&.+)?/i' |
|
| 86 | + ) |
|
| 87 | + ); |
|
| 88 | + |
|
| 89 | + /** Ссылка на RUtube без идентификатора в адресе */ |
|
| 90 | + protected $regexp_rutube_extra = '/[http|https]+:\/\/(?:www\.|)rutube\.ru\/video\/([a-zA-Z0-9_\-]+)\//i'; |
|
| 91 | + |
|
| 92 | + /** Варианты ссылок, которые поддерживаются */ |
|
| 93 | + protected static $test = array( |
|
| 94 | + 'http://youtube.com/watch?v=ShPq2Dmy6X8', |
|
| 95 | + 'http://www.youtube.com/watch?v=6dwqZw0j_jY&feature=youtu.be', |
|
| 96 | + 'http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel', |
|
| 97 | + 'www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub', |
|
| 98 | + 'http://www.youtube.com/embed/ShPq2Dmy6X8?rel=0', |
|
| 99 | + 'http://youtu.be/ShPq2Dmy6X8', |
|
| 100 | + 'youtu.be/6dwqZw0j_jY', |
|
| 101 | + 'http://www.youtu.be/afa-5HQHiAs', |
|
| 102 | + |
|
| 103 | + 'vimeo.com/55028438', |
|
| 104 | + 'http://player.vimeo.com/video/55028438?title=0&byline=0&portrait=0&badge=0&color=e1a931', |
|
| 105 | + |
|
| 106 | + 'http://rutube.ru/video/6fd81c1c212c002673280850a1c56415/#.UMQYln9yTWQ', |
|
| 107 | + 'http://rutube.ru/video/dec0a58c8cb4d226abc7b1030bbb63b9/?ref=top', |
|
| 108 | + 'rutube.ru/tracks/6032725.html', |
|
| 109 | + 'http://www.rutube.ru/video/embed/6032725', |
|
| 110 | + ); |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * @var bool |
| 114 | 114 | */ |
| 115 | - protected $info = false; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @param $link ссылка на видео |
|
| 119 | - * @param $autostart сразу определить превью и клип |
|
| 120 | - */ |
|
| 121 | - public function __construct($link = null, $autostart = true, $info = false) |
|
| 122 | - { |
|
| 123 | - if ($link) { |
|
| 124 | - $this->setLink($link); |
|
| 125 | - $this->setInfo($info); |
|
| 126 | - if ($autostart) { |
|
| 127 | - $this->process(); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 115 | + protected $info = false; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @param $link ссылка на видео |
|
| 119 | + * @param $autostart сразу определить превью и клип |
|
| 120 | + */ |
|
| 121 | + public function __construct($link = null, $autostart = true, $info = false) |
|
| 122 | + { |
|
| 123 | + if ($link) { |
|
| 124 | + $this->setLink($link); |
|
| 125 | + $this->setInfo($info); |
|
| 126 | + if ($autostart) { |
|
| 127 | + $this->process(); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | 135 | public function getScheme(){ |
| 136 | - switch($this->scheme){ |
|
| 137 | - case 'http': |
|
| 138 | - $out = 'http://'; |
|
| 139 | - break; |
|
| 140 | - case 'https': |
|
| 141 | - $out = 'https://'; |
|
| 142 | - break; |
|
| 143 | - default: |
|
| 144 | - $out = '//'; |
|
| 145 | - break; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return $out; |
|
| 149 | - } |
|
| 136 | + switch($this->scheme){ |
|
| 137 | + case 'http': |
|
| 138 | + $out = 'http://'; |
|
| 139 | + break; |
|
| 140 | + case 'https': |
|
| 141 | + $out = 'https://'; |
|
| 142 | + break; |
|
| 143 | + default: |
|
| 144 | + $out = '//'; |
|
| 145 | + break; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return $out; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * @param $info |
| 153 | 153 | */ |
| 154 | 154 | public function setInfo($info){ |
| 155 | - $this->info = (bool)$info; |
|
| 156 | - } |
|
| 155 | + $this->info = (bool)$info; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * @return bool |
| 160 | 160 | */ |
| 161 | 161 | public function getInfo(){ |
| 162 | - return $this->info; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** Видеохостинг */ |
|
| 166 | - public function getHosting() |
|
| 167 | - { |
|
| 168 | - return $this->hosting; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** Идентификатор видео */ |
|
| 172 | - public function getId() |
|
| 173 | - { |
|
| 174 | - return $this->id; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** Ссылка на превью */ |
|
| 178 | - public function getImage() |
|
| 179 | - { |
|
| 180 | - return $this->getScheme().$this->image; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** Ссылка на видео */ |
|
| 184 | - public function getVideo($autoplay = false) |
|
| 185 | - { |
|
| 186 | - $url = $this->video; |
|
| 187 | - if($autoplay){ |
|
| 188 | - $url .= '&autoplay=1'; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return $this->getScheme().$url; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** Название видео */ |
|
| 195 | - public function getTitle() |
|
| 196 | - { |
|
| 197 | - return $this->title; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** Задать ссылку на видео */ |
|
| 201 | - public function setLink($link) |
|
| 202 | - { |
|
| 203 | - $this->link = $link; |
|
| 204 | - |
|
| 205 | - return $this; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** Обработка ссылки. Возвращает идентификатор видеохостинга или false */ |
|
| 209 | - public function process($link = null, $info = null) |
|
| 210 | - { |
|
| 211 | - if(!empty($link)) $this->setLink($link); |
|
| 212 | - if(!empty($info)) $this->setInfo($info); |
|
| 213 | - |
|
| 214 | - if ($this->cleanLink()) { |
|
| 215 | - if ($this->maybeYoutube()) { |
|
| 216 | - return self::YOUTUBE; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - if ($this->maybeVimeo()) { |
|
| 220 | - return self::VIMEO; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - if ($this->maybeRutube()) { |
|
| 224 | - return self::RUTUBE; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return false; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** Скачать превью. Если не указать имя файла для записи - функция вернет содержимое файла */ |
|
| 232 | - public function fetchImage($filename = null) |
|
| 233 | - { |
|
| 234 | - if (!$url = $this->getImage()) { |
|
| 235 | - return false; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - if (!$res = $this->fetchPage($url)) { |
|
| 239 | - return false; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - return $filename |
|
| 243 | - ? file_put_contents($filename, $res) |
|
| 244 | - : $res; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** Проверка и подготовка ссылки и частей */ |
|
| 248 | - protected function cleanLink() |
|
| 249 | - { |
|
| 250 | - if (!preg_match('/^(http|https)\:\/\//i', $this->link)) { |
|
| 251 | - $this->link = 'http://' . $this->link; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - if (!$this->link_parts = parse_url($this->link)) { |
|
| 255 | - return false; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - return true; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** Проверка YOUTUBE */ |
|
| 262 | - protected function maybeYoutube() |
|
| 263 | - { |
|
| 264 | - $h = str_replace('www.', '', $this->link_parts['host']); |
|
| 265 | - $p = isset($this->link_parts['path']) ? $this->link_parts['path'] : false; |
|
| 266 | - |
|
| 267 | - if ('youtube.com' == $h) { |
|
| 268 | - parse_str($this->link_parts['query'], $q); |
|
| 269 | - |
|
| 270 | - if ('/watch' == $p && !empty($q['v'])) { |
|
| 271 | - return $this->foundYoutube($q['v']); |
|
| 272 | - } |
|
| 273 | - if (0 === strpos($p, '/embed/')) { |
|
| 274 | - return $this->foundYoutube(str_replace('/embed/', '', $p)); |
|
| 275 | - } |
|
| 276 | - } elseif ('youtu.be' == $h) { |
|
| 277 | - return $this->foundYoutube(trim($p, '/')); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** Проверка VIMEO */ |
|
| 284 | - protected function maybeVimeo() |
|
| 285 | - { |
|
| 286 | - $h = str_replace('www.', '', $this->link_parts['host']); |
|
| 287 | - $p = isset($this->link_parts['path']) ? $this->link_parts['path'] : false; |
|
| 288 | - |
|
| 289 | - if ('vimeo.com' == $h) { |
|
| 290 | - return $this->foundVimeo(trim($p, '/')); |
|
| 291 | - } elseif ('player.vimeo.com' == $h && 0 === strpos($p, '/video/')) { |
|
| 292 | - return $this->foundVimeo(str_replace('/video/', '', $p)); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - return false; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - /** Проверка RUTUBE */ |
|
| 299 | - protected function maybeRutube($html = null) |
|
| 300 | - { |
|
| 301 | - $link = $html ?: $this->link; |
|
| 302 | - |
|
| 303 | - foreach ($this->regexp[self::RUTUBE] as $regexp) { |
|
| 304 | - if (preg_match($regexp, $link, $matches)) { |
|
| 305 | - return $this->foundRutube($matches[1]); |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // Проверка на особенную ссылку RUtube`a |
|
| 310 | - if (is_null($html) && preg_match($this->regexp_rutube_extra, $this->link, $matches)) { |
|
| 311 | - $html = $this->fetchPage($matches[0]); |
|
| 312 | - if ($r = $this->maybeRutube($html)) { |
|
| 313 | - return $r; |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - return false; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - /** Обработка YOUTUBE */ |
|
| 321 | - protected function foundYoutube($id) |
|
| 322 | - { |
|
| 323 | - if (empty($id) || strlen($id) != 11) { |
|
| 324 | - return false; |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - $this->hosting = self::YOUTUBE; |
|
| 328 | - $this->id = $id; |
|
| 329 | - $this->image = 'img.youtube.com/vi/' . $id . '/0.jpg'; |
|
| 330 | - /** @see https://developers.google.com/youtube/player_parameters */ |
|
| 331 | - $this->video = 'www.youtube.com/embed/' . $id.'?showinfo=0&modestbranding=1&rel=0'; |
|
| 332 | - |
|
| 333 | - if ($this->info) { |
|
| 334 | - $this->getYoutubeInfo($id); |
|
| 335 | - } |
|
| 336 | - return true; |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** Обработка VIMEO */ |
|
| 340 | - protected function foundVimeo($id) |
|
| 341 | - { |
|
| 342 | - if (empty($id) || !is_numeric($id)) { |
|
| 343 | - return false; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - $this->hosting = self::VIMEO; |
|
| 347 | - $this->id = $id; |
|
| 348 | - $this->video = 'player.vimeo.com/video/' . $id.'?'; |
|
| 349 | - |
|
| 350 | - if($this->info) { |
|
| 351 | - $this->getVimeoInfo($id); |
|
| 352 | - } |
|
| 353 | - return true; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** Обработка RUTUBE */ |
|
| 357 | - protected function foundRutube($id) |
|
| 358 | - { |
|
| 359 | - $this->hosting = self::RUTUBE; |
|
| 360 | - $this->id = $id; |
|
| 361 | - $this->video = 'rutube.ru/video/embed/' . $id.'?'; |
|
| 362 | - |
|
| 363 | - if($this->info) { |
|
| 364 | - $this->getRutubeInfo($id); |
|
| 365 | - } |
|
| 366 | - return true; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** Парсинг XML от RUTUBE и определение превьюхи */ |
|
| 370 | - protected function getRutubeInfo($id) |
|
| 371 | - { |
|
| 372 | - if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=" . $id . "&utf=1")) { |
|
| 373 | - $this->title = (string)$xml->title; |
|
| 374 | - $this->image = (string)$xml->thumbnail_url; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - /** Парсинг XML от VIMEO и определение превьюхи */ |
|
| 379 | - protected function getVimeoInfo($id) |
|
| 380 | - { |
|
| 381 | - if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $id . '.xml')) { |
|
| 382 | - $this->title = (string)$xml->video->title; |
|
| 383 | - $this->image = (string)$xml->video->thumbnail_large ? : $xml->video->thumbnail_medium; |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - /** Получение названия ролика */ |
|
| 388 | - protected function getYoutubeInfo($id) |
|
| 389 | - { |
|
| 390 | - if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $id)) { |
|
| 391 | - $this->title = (string)$xml->title; |
|
| 392 | - } |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** Скачивание страницы с помощью CURL */ |
|
| 396 | - protected function fetchPage($url) |
|
| 397 | - { |
|
| 398 | - $ch = curl_init(); |
|
| 399 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 400 | - curl_setopt($ch, CURLOPT_FAILONERROR, true); |
|
| 401 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 402 | - curl_setopt($ch, CURLOPT_TIMEOUT, 3); |
|
| 403 | - |
|
| 404 | - return curl_exec($ch); |
|
| 405 | - } |
|
| 162 | + return $this->info; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** Видеохостинг */ |
|
| 166 | + public function getHosting() |
|
| 167 | + { |
|
| 168 | + return $this->hosting; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** Идентификатор видео */ |
|
| 172 | + public function getId() |
|
| 173 | + { |
|
| 174 | + return $this->id; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** Ссылка на превью */ |
|
| 178 | + public function getImage() |
|
| 179 | + { |
|
| 180 | + return $this->getScheme().$this->image; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** Ссылка на видео */ |
|
| 184 | + public function getVideo($autoplay = false) |
|
| 185 | + { |
|
| 186 | + $url = $this->video; |
|
| 187 | + if($autoplay){ |
|
| 188 | + $url .= '&autoplay=1'; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return $this->getScheme().$url; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** Название видео */ |
|
| 195 | + public function getTitle() |
|
| 196 | + { |
|
| 197 | + return $this->title; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** Задать ссылку на видео */ |
|
| 201 | + public function setLink($link) |
|
| 202 | + { |
|
| 203 | + $this->link = $link; |
|
| 204 | + |
|
| 205 | + return $this; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** Обработка ссылки. Возвращает идентификатор видеохостинга или false */ |
|
| 209 | + public function process($link = null, $info = null) |
|
| 210 | + { |
|
| 211 | + if(!empty($link)) $this->setLink($link); |
|
| 212 | + if(!empty($info)) $this->setInfo($info); |
|
| 213 | + |
|
| 214 | + if ($this->cleanLink()) { |
|
| 215 | + if ($this->maybeYoutube()) { |
|
| 216 | + return self::YOUTUBE; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + if ($this->maybeVimeo()) { |
|
| 220 | + return self::VIMEO; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + if ($this->maybeRutube()) { |
|
| 224 | + return self::RUTUBE; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return false; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** Скачать превью. Если не указать имя файла для записи - функция вернет содержимое файла */ |
|
| 232 | + public function fetchImage($filename = null) |
|
| 233 | + { |
|
| 234 | + if (!$url = $this->getImage()) { |
|
| 235 | + return false; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + if (!$res = $this->fetchPage($url)) { |
|
| 239 | + return false; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + return $filename |
|
| 243 | + ? file_put_contents($filename, $res) |
|
| 244 | + : $res; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** Проверка и подготовка ссылки и частей */ |
|
| 248 | + protected function cleanLink() |
|
| 249 | + { |
|
| 250 | + if (!preg_match('/^(http|https)\:\/\//i', $this->link)) { |
|
| 251 | + $this->link = 'http://' . $this->link; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + if (!$this->link_parts = parse_url($this->link)) { |
|
| 255 | + return false; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + return true; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** Проверка YOUTUBE */ |
|
| 262 | + protected function maybeYoutube() |
|
| 263 | + { |
|
| 264 | + $h = str_replace('www.', '', $this->link_parts['host']); |
|
| 265 | + $p = isset($this->link_parts['path']) ? $this->link_parts['path'] : false; |
|
| 266 | + |
|
| 267 | + if ('youtube.com' == $h) { |
|
| 268 | + parse_str($this->link_parts['query'], $q); |
|
| 269 | + |
|
| 270 | + if ('/watch' == $p && !empty($q['v'])) { |
|
| 271 | + return $this->foundYoutube($q['v']); |
|
| 272 | + } |
|
| 273 | + if (0 === strpos($p, '/embed/')) { |
|
| 274 | + return $this->foundYoutube(str_replace('/embed/', '', $p)); |
|
| 275 | + } |
|
| 276 | + } elseif ('youtu.be' == $h) { |
|
| 277 | + return $this->foundYoutube(trim($p, '/')); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** Проверка VIMEO */ |
|
| 284 | + protected function maybeVimeo() |
|
| 285 | + { |
|
| 286 | + $h = str_replace('www.', '', $this->link_parts['host']); |
|
| 287 | + $p = isset($this->link_parts['path']) ? $this->link_parts['path'] : false; |
|
| 288 | + |
|
| 289 | + if ('vimeo.com' == $h) { |
|
| 290 | + return $this->foundVimeo(trim($p, '/')); |
|
| 291 | + } elseif ('player.vimeo.com' == $h && 0 === strpos($p, '/video/')) { |
|
| 292 | + return $this->foundVimeo(str_replace('/video/', '', $p)); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + return false; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + /** Проверка RUTUBE */ |
|
| 299 | + protected function maybeRutube($html = null) |
|
| 300 | + { |
|
| 301 | + $link = $html ?: $this->link; |
|
| 302 | + |
|
| 303 | + foreach ($this->regexp[self::RUTUBE] as $regexp) { |
|
| 304 | + if (preg_match($regexp, $link, $matches)) { |
|
| 305 | + return $this->foundRutube($matches[1]); |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // Проверка на особенную ссылку RUtube`a |
|
| 310 | + if (is_null($html) && preg_match($this->regexp_rutube_extra, $this->link, $matches)) { |
|
| 311 | + $html = $this->fetchPage($matches[0]); |
|
| 312 | + if ($r = $this->maybeRutube($html)) { |
|
| 313 | + return $r; |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + return false; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + /** Обработка YOUTUBE */ |
|
| 321 | + protected function foundYoutube($id) |
|
| 322 | + { |
|
| 323 | + if (empty($id) || strlen($id) != 11) { |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + $this->hosting = self::YOUTUBE; |
|
| 328 | + $this->id = $id; |
|
| 329 | + $this->image = 'img.youtube.com/vi/' . $id . '/0.jpg'; |
|
| 330 | + /** @see https://developers.google.com/youtube/player_parameters */ |
|
| 331 | + $this->video = 'www.youtube.com/embed/' . $id.'?showinfo=0&modestbranding=1&rel=0'; |
|
| 332 | + |
|
| 333 | + if ($this->info) { |
|
| 334 | + $this->getYoutubeInfo($id); |
|
| 335 | + } |
|
| 336 | + return true; |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** Обработка VIMEO */ |
|
| 340 | + protected function foundVimeo($id) |
|
| 341 | + { |
|
| 342 | + if (empty($id) || !is_numeric($id)) { |
|
| 343 | + return false; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + $this->hosting = self::VIMEO; |
|
| 347 | + $this->id = $id; |
|
| 348 | + $this->video = 'player.vimeo.com/video/' . $id.'?'; |
|
| 349 | + |
|
| 350 | + if($this->info) { |
|
| 351 | + $this->getVimeoInfo($id); |
|
| 352 | + } |
|
| 353 | + return true; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** Обработка RUTUBE */ |
|
| 357 | + protected function foundRutube($id) |
|
| 358 | + { |
|
| 359 | + $this->hosting = self::RUTUBE; |
|
| 360 | + $this->id = $id; |
|
| 361 | + $this->video = 'rutube.ru/video/embed/' . $id.'?'; |
|
| 362 | + |
|
| 363 | + if($this->info) { |
|
| 364 | + $this->getRutubeInfo($id); |
|
| 365 | + } |
|
| 366 | + return true; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** Парсинг XML от RUTUBE и определение превьюхи */ |
|
| 370 | + protected function getRutubeInfo($id) |
|
| 371 | + { |
|
| 372 | + if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=" . $id . "&utf=1")) { |
|
| 373 | + $this->title = (string)$xml->title; |
|
| 374 | + $this->image = (string)$xml->thumbnail_url; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + /** Парсинг XML от VIMEO и определение превьюхи */ |
|
| 379 | + protected function getVimeoInfo($id) |
|
| 380 | + { |
|
| 381 | + if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $id . '.xml')) { |
|
| 382 | + $this->title = (string)$xml->video->title; |
|
| 383 | + $this->image = (string)$xml->video->thumbnail_large ? : $xml->video->thumbnail_medium; |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + /** Получение названия ролика */ |
|
| 388 | + protected function getYoutubeInfo($id) |
|
| 389 | + { |
|
| 390 | + if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $id)) { |
|
| 391 | + $this->title = (string)$xml->title; |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** Скачивание страницы с помощью CURL */ |
|
| 396 | + protected function fetchPage($url) |
|
| 397 | + { |
|
| 398 | + $ch = curl_init(); |
|
| 399 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 400 | + curl_setopt($ch, CURLOPT_FAILONERROR, true); |
|
| 401 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 402 | + curl_setopt($ch, CURLOPT_TIMEOUT, 3); |
|
| 403 | + |
|
| 404 | + return curl_exec($ch); |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | 407 | /** |
| 408 | 408 | * @param $options |
| 409 | 409 | * @return string |
| 410 | 410 | */ |
| 411 | 411 | public function getEmbed($options){ |
| 412 | - $autoplay = isset($options["autoplay"]) ? $options["autoplay"] : $this->autoplay; |
|
| 413 | - $width = isset($options["width"]) ? (int)$options["width"] : $this->width; |
|
| 414 | - $height = isset($options["height"]) ? (int)$options["height"] : $this->height; |
|
| 415 | - $class = isset($options['class']) ? $options['class'] : ''; |
|
| 416 | - |
|
| 417 | - $url = $this->getVideo($autoplay); |
|
| 418 | - if(!empty($class)){ |
|
| 419 | - $class = ' class="'.$class.'"'; |
|
| 420 | - } |
|
| 421 | - return '<iframe src="'.$url.'" width="'.$width.'" height="'.$height.'" frameborder="0" allowfullscreen'.$class.'></iframe>'; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** Прогоняем тест по видам URL */ |
|
| 425 | - public static function RunTest($links = null) |
|
| 426 | - { |
|
| 427 | - if (!is_array($links)) { |
|
| 428 | - $links = static::$test; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - foreach ($links as $link) { |
|
| 432 | - $v = new static($link); |
|
| 433 | - echo "<h1>$link</h1>\n" |
|
| 434 | - . "<h3>" . $v->getHosting() . "</h3>" |
|
| 435 | - . "<b>Видео:</b> " . $v->getVideo() . "<br />\n" |
|
| 436 | - . "<b>Название:</b> " . $v->getTitle() . "<br />\n" |
|
| 437 | - . "<b>Картинка:</b> " . $v->getImage() . "<hr />\n"; |
|
| 438 | - } |
|
| 439 | - } |
|
| 412 | + $autoplay = isset($options["autoplay"]) ? $options["autoplay"] : $this->autoplay; |
|
| 413 | + $width = isset($options["width"]) ? (int)$options["width"] : $this->width; |
|
| 414 | + $height = isset($options["height"]) ? (int)$options["height"] : $this->height; |
|
| 415 | + $class = isset($options['class']) ? $options['class'] : ''; |
|
| 416 | + |
|
| 417 | + $url = $this->getVideo($autoplay); |
|
| 418 | + if(!empty($class)){ |
|
| 419 | + $class = ' class="'.$class.'"'; |
|
| 420 | + } |
|
| 421 | + return '<iframe src="'.$url.'" width="'.$width.'" height="'.$height.'" frameborder="0" allowfullscreen'.$class.'></iframe>'; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** Прогоняем тест по видам URL */ |
|
| 425 | + public static function RunTest($links = null) |
|
| 426 | + { |
|
| 427 | + if (!is_array($links)) { |
|
| 428 | + $links = static::$test; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + foreach ($links as $link) { |
|
| 432 | + $v = new static($link); |
|
| 433 | + echo "<h1>$link</h1>\n" |
|
| 434 | + . "<h3>" . $v->getHosting() . "</h3>" |
|
| 435 | + . "<b>Видео:</b> " . $v->getVideo() . "<br />\n" |
|
| 436 | + . "<b>Название:</b> " . $v->getTitle() . "<br />\n" |
|
| 437 | + . "<b>Картинка:</b> " . $v->getImage() . "<hr />\n"; |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | 440 | } |
| 441 | 441 | \ No newline at end of file |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | * |
| 64 | 64 | */ |
| 65 | - const VIMEO = 'vimeo'; |
|
| 65 | + const VIMEO = 'vimeo'; |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * |
| 69 | 69 | */ |
| 70 | - const RUTUBE = 'rutube'; |
|
| 70 | + const RUTUBE = 'rutube'; |
|
| 71 | 71 | |
| 72 | 72 | /** Регулярки для определения видеохостинга и идентификатора ролика */ |
| 73 | 73 | protected $regexp = array( |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | /** |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function getScheme(){ |
|
| 136 | - switch($this->scheme){ |
|
| 135 | + public function getScheme() { |
|
| 136 | + switch ($this->scheme) { |
|
| 137 | 137 | case 'http': |
| 138 | 138 | $out = 'http://'; |
| 139 | 139 | break; |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | /** |
| 152 | 152 | * @param $info |
| 153 | 153 | */ |
| 154 | - public function setInfo($info){ |
|
| 154 | + public function setInfo($info) { |
|
| 155 | 155 | $this->info = (bool)$info; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * @return bool |
| 160 | 160 | */ |
| 161 | - public function getInfo(){ |
|
| 161 | + public function getInfo() { |
|
| 162 | 162 | return $this->info; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | public function getVideo($autoplay = false) |
| 185 | 185 | { |
| 186 | 186 | $url = $this->video; |
| 187 | - if($autoplay){ |
|
| 187 | + if ($autoplay) { |
|
| 188 | 188 | $url .= '&autoplay=1'; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | /** Обработка ссылки. Возвращает идентификатор видеохостинга или false */ |
| 209 | 209 | public function process($link = null, $info = null) |
| 210 | 210 | { |
| 211 | - if(!empty($link)) $this->setLink($link); |
|
| 212 | - if(!empty($info)) $this->setInfo($info); |
|
| 211 | + if (!empty($link)) $this->setLink($link); |
|
| 212 | + if (!empty($info)) $this->setInfo($info); |
|
| 213 | 213 | |
| 214 | 214 | if ($this->cleanLink()) { |
| 215 | 215 | if ($this->maybeYoutube()) { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | protected function cleanLink() |
| 249 | 249 | { |
| 250 | 250 | if (!preg_match('/^(http|https)\:\/\//i', $this->link)) { |
| 251 | - $this->link = 'http://' . $this->link; |
|
| 251 | + $this->link = 'http://'.$this->link; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | if (!$this->link_parts = parse_url($this->link)) { |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | $this->hosting = self::YOUTUBE; |
| 328 | 328 | $this->id = $id; |
| 329 | - $this->image = 'img.youtube.com/vi/' . $id . '/0.jpg'; |
|
| 329 | + $this->image = 'img.youtube.com/vi/'.$id.'/0.jpg'; |
|
| 330 | 330 | /** @see https://developers.google.com/youtube/player_parameters */ |
| 331 | - $this->video = 'www.youtube.com/embed/' . $id.'?showinfo=0&modestbranding=1&rel=0'; |
|
| 331 | + $this->video = 'www.youtube.com/embed/'.$id.'?showinfo=0&modestbranding=1&rel=0'; |
|
| 332 | 332 | |
| 333 | 333 | if ($this->info) { |
| 334 | 334 | $this->getYoutubeInfo($id); |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | $this->hosting = self::VIMEO; |
| 347 | 347 | $this->id = $id; |
| 348 | - $this->video = 'player.vimeo.com/video/' . $id.'?'; |
|
| 348 | + $this->video = 'player.vimeo.com/video/'.$id.'?'; |
|
| 349 | 349 | |
| 350 | - if($this->info) { |
|
| 350 | + if ($this->info) { |
|
| 351 | 351 | $this->getVimeoInfo($id); |
| 352 | 352 | } |
| 353 | 353 | return true; |
@@ -358,9 +358,9 @@ discard block |
||
| 358 | 358 | { |
| 359 | 359 | $this->hosting = self::RUTUBE; |
| 360 | 360 | $this->id = $id; |
| 361 | - $this->video = 'rutube.ru/video/embed/' . $id.'?'; |
|
| 361 | + $this->video = 'rutube.ru/video/embed/'.$id.'?'; |
|
| 362 | 362 | |
| 363 | - if($this->info) { |
|
| 363 | + if ($this->info) { |
|
| 364 | 364 | $this->getRutubeInfo($id); |
| 365 | 365 | } |
| 366 | 366 | return true; |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | /** Парсинг XML от RUTUBE и определение превьюхи */ |
| 370 | 370 | protected function getRutubeInfo($id) |
| 371 | 371 | { |
| 372 | - if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=" . $id . "&utf=1")) { |
|
| 372 | + if (@$xml = simplexml_load_file("http://rutube.ru/cgi-bin/xmlapi.cgi?rt_mode=movie&rt_movie_id=".$id."&utf=1")) { |
|
| 373 | 373 | $this->title = (string)$xml->title; |
| 374 | 374 | $this->image = (string)$xml->thumbnail_url; |
| 375 | 375 | } |
@@ -378,16 +378,16 @@ discard block |
||
| 378 | 378 | /** Парсинг XML от VIMEO и определение превьюхи */ |
| 379 | 379 | protected function getVimeoInfo($id) |
| 380 | 380 | { |
| 381 | - if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $id . '.xml')) { |
|
| 381 | + if (@$xml = simplexml_load_file('http://vimeo.com/api/v2/video/'.$id.'.xml')) { |
|
| 382 | 382 | $this->title = (string)$xml->video->title; |
| 383 | - $this->image = (string)$xml->video->thumbnail_large ? : $xml->video->thumbnail_medium; |
|
| 383 | + $this->image = (string)$xml->video->thumbnail_large ?: $xml->video->thumbnail_medium; |
|
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** Получение названия ролика */ |
| 388 | 388 | protected function getYoutubeInfo($id) |
| 389 | 389 | { |
| 390 | - if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $id)) { |
|
| 390 | + if (@$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/'.$id)) { |
|
| 391 | 391 | $this->title = (string)$xml->title; |
| 392 | 392 | } |
| 393 | 393 | } |
@@ -408,14 +408,14 @@ discard block |
||
| 408 | 408 | * @param $options |
| 409 | 409 | * @return string |
| 410 | 410 | */ |
| 411 | - public function getEmbed($options){ |
|
| 411 | + public function getEmbed($options) { |
|
| 412 | 412 | $autoplay = isset($options["autoplay"]) ? $options["autoplay"] : $this->autoplay; |
| 413 | 413 | $width = isset($options["width"]) ? (int)$options["width"] : $this->width; |
| 414 | 414 | $height = isset($options["height"]) ? (int)$options["height"] : $this->height; |
| 415 | 415 | $class = isset($options['class']) ? $options['class'] : ''; |
| 416 | 416 | |
| 417 | 417 | $url = $this->getVideo($autoplay); |
| 418 | - if(!empty($class)){ |
|
| 418 | + if (!empty($class)) { |
|
| 419 | 419 | $class = ' class="'.$class.'"'; |
| 420 | 420 | } |
| 421 | 421 | return '<iframe src="'.$url.'" width="'.$width.'" height="'.$height.'" frameborder="0" allowfullscreen'.$class.'></iframe>'; |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | foreach ($links as $link) { |
| 432 | 432 | $v = new static($link); |
| 433 | 433 | echo "<h1>$link</h1>\n" |
| 434 | - . "<h3>" . $v->getHosting() . "</h3>" |
|
| 435 | - . "<b>Видео:</b> " . $v->getVideo() . "<br />\n" |
|
| 436 | - . "<b>Название:</b> " . $v->getTitle() . "<br />\n" |
|
| 437 | - . "<b>Картинка:</b> " . $v->getImage() . "<hr />\n"; |
|
| 434 | + . "<h3>".$v->getHosting()."</h3>" |
|
| 435 | + . "<b>Видео:</b> ".$v->getVideo()."<br />\n" |
|
| 436 | + . "<b>Название:</b> ".$v->getTitle()."<br />\n" |
|
| 437 | + . "<b>Картинка:</b> ".$v->getImage()."<hr />\n"; |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | \ No newline at end of file |
@@ -14,17 +14,17 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @var \DocumentParser|null |
| 16 | 16 | */ |
| 17 | - public $modx = null; |
|
| 17 | + public $modx = null; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - public $pluginName = ''; |
|
| 22 | + public $pluginName = ''; |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - public $params = array(); |
|
| 27 | + public $params = array(); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @var string |
@@ -34,32 +34,32 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @var string |
| 36 | 36 | */ |
| 37 | - public $tpl = ''; |
|
| 37 | + public $tpl = ''; |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @var string |
| 41 | 41 | */ |
| 42 | - public $jsListDefault = ''; |
|
| 42 | + public $jsListDefault = ''; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @var string |
| 46 | 46 | */ |
| 47 | - public $jsListCustom = ''; |
|
| 47 | + public $jsListCustom = ''; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @var string |
| 51 | 51 | */ |
| 52 | - public $cssListDefault = ''; |
|
| 52 | + public $cssListDefault = ''; |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @var string |
| 56 | 56 | */ |
| 57 | - public $cssListCustom = ''; |
|
| 57 | + public $cssListCustom = ''; |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @var array |
| 61 | 61 | */ |
| 62 | - public $pluginEvents = array(); |
|
| 62 | + public $pluginEvents = array(); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @var string |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | /** |
| 70 | 70 | * @var \Helpers\FS|null |
| 71 | 71 | */ |
| 72 | - protected $fs = null; |
|
| 72 | + protected $fs = null; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @var \AssetsHelper|null |
@@ -79,39 +79,39 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * @var null |
| 81 | 81 | */ |
| 82 | - protected $emptyTpl = null; |
|
| 82 | + protected $emptyTpl = null; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * @var string |
| 86 | 86 | */ |
| 87 | - protected $jsListEmpty = ''; |
|
| 87 | + protected $jsListEmpty = ''; |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * @var \DLTemplate|null |
| 91 | 91 | */ |
| 92 | - public $DLTemplate = null; |
|
| 92 | + public $DLTemplate = null; |
|
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * @var string |
| 96 | 96 | */ |
| 97 | - public $lang_attribute = ''; |
|
| 97 | + public $lang_attribute = ''; |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @var bool |
| 101 | 101 | */ |
| 102 | - protected $checkTemplate = true; |
|
| 102 | + protected $checkTemplate = true; |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * @var string |
| 106 | 106 | */ |
| 107 | - protected $renderEvent = 'OnDocFormRender'; |
|
| 107 | + protected $renderEvent = 'OnDocFormRender'; |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * @var bool |
| 111 | 111 | */ |
| 112 | - protected $checkId = true; |
|
| 112 | + protected $checkId = true; |
|
| 113 | 113 | |
| 114 | - /** |
|
| 114 | + /** |
|
| 115 | 115 | * @param $modx |
| 116 | 116 | * @param string $lang_attribute |
| 117 | 117 | */ |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $this->lang_attribute = $lang_attribute; |
| 122 | 122 | $this->params = $modx->event->params; |
| 123 | 123 | if ($this->checkTemplate && !isset($this->params['template']) && $modx->event->name != 'OnEmptyTrash') { |
| 124 | - $doc = $modx->getDocument($this->params['id'],'template','all','all'); |
|
| 124 | + $doc = $modx->getDocument($this->params['id'],'template','all','all'); |
|
| 125 | 125 | $this->params['template'] = is_array($doc) ? end($doc) : null; |
| 126 | 126 | } |
| 127 | 127 | //overload plugin and class properties |
@@ -173,12 +173,12 @@ discard block |
||
| 173 | 173 | $this->modx->logEvent(0, 3, "Cannot create {$this->table} table.", $this->pluginName); |
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | - $this->registerEvents($this->pluginEvents); |
|
| 176 | + $this->registerEvents($this->pluginEvents); |
|
| 177 | 177 | } |
| 178 | 178 | $output = ''; |
| 179 | - $plugins = $this->modx->pluginEvent; |
|
| 180 | - if(($this->renderEvent!=='OnDocFormRender' || (array_search('ManagerManager', $plugins['OnDocFormRender']) === false))) { |
|
| 181 | - $jquery = $this->assets->registerScript('jQuery',array( |
|
| 179 | + $plugins = $this->modx->pluginEvent; |
|
| 180 | + if(($this->renderEvent!=='OnDocFormRender' || (array_search('ManagerManager', $plugins['OnDocFormRender']) === false))) { |
|
| 181 | + $jquery = $this->assets->registerScript('jQuery',array( |
|
| 182 | 182 | 'version' => '1.9.1', |
| 183 | 183 | 'src' => 'assets/js/jquery/jquery-1.9.1.min.js' |
| 184 | 184 | )); |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | $output .= $jquery; |
| 187 | 187 | $output .='<script type="text/javascript">var jQuery = jQuery.noConflict(true);</script>'; |
| 188 | 188 | } |
| 189 | - } |
|
| 190 | - $tpl = MODX_BASE_PATH.$this->tpl; |
|
| 191 | - if($this->fs->checkFile($tpl)) { |
|
| 192 | - $output .= '[+js+][+styles+]'.file_get_contents($tpl); |
|
| 193 | - } else { |
|
| 194 | - $this->modx->logEvent(0, 3, "Cannot load {$this->tpl} .", $this->pluginName); |
|
| 189 | + } |
|
| 190 | + $tpl = MODX_BASE_PATH.$this->tpl; |
|
| 191 | + if($this->fs->checkFile($tpl)) { |
|
| 192 | + $output .= '[+js+][+styles+]'.file_get_contents($tpl); |
|
| 193 | + } else { |
|
| 194 | + $this->modx->logEvent(0, 3, "Cannot load {$this->tpl} .", $this->pluginName); |
|
| 195 | 195 | return false; |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | return $output; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -203,48 +203,48 @@ discard block |
||
| 203 | 203 | * @return string |
| 204 | 204 | */ |
| 205 | 205 | public function renderJS($list,$ph = array()) { |
| 206 | - $js = ''; |
|
| 207 | - $scripts = MODX_BASE_PATH.$list; |
|
| 208 | - if($this->fs->checkFile($scripts)) { |
|
| 209 | - $scripts = @file_get_contents($scripts); |
|
| 210 | - $scripts = $this->DLTemplate->parseChunk('@CODE:'.$scripts,$ph); |
|
| 211 | - $scripts = json_decode($scripts,true); |
|
| 212 | - $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; |
|
| 213 | - foreach ($scripts as $name => $params) { |
|
| 214 | - $script = $this->assets->registerScript($name,$params); |
|
| 206 | + $js = ''; |
|
| 207 | + $scripts = MODX_BASE_PATH.$list; |
|
| 208 | + if($this->fs->checkFile($scripts)) { |
|
| 209 | + $scripts = @file_get_contents($scripts); |
|
| 210 | + $scripts = $this->DLTemplate->parseChunk('@CODE:'.$scripts,$ph); |
|
| 211 | + $scripts = json_decode($scripts,true); |
|
| 212 | + $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles']; |
|
| 213 | + foreach ($scripts as $name => $params) { |
|
| 214 | + $script = $this->assets->registerScript($name,$params); |
|
| 215 | 215 | if ($script !== false) $js .= $script; |
| 216 | - } |
|
| 217 | - } else { |
|
| 218 | - if ($list == $this->jsListDefault) { |
|
| 219 | - $this->modx->logEvent(0, 3, "Cannot load {$this->jsListDefault} .", $this->pluginName); |
|
| 220 | - } elseif ($list == $this->cssListDefault) { |
|
| 221 | - $this->modx->logEvent(0, 3, "Cannot load {$this->cssListDefault} .", $this->pluginName); |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - return $js; |
|
| 216 | + } |
|
| 217 | + } else { |
|
| 218 | + if ($list == $this->jsListDefault) { |
|
| 219 | + $this->modx->logEvent(0, 3, "Cannot load {$this->jsListDefault} .", $this->pluginName); |
|
| 220 | + } elseif ($list == $this->cssListDefault) { |
|
| 221 | + $this->modx->logEvent(0, 3, "Cannot load {$this->cssListDefault} .", $this->pluginName); |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + return $js; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * @return array |
|
| 229 | - */ |
|
| 230 | - public function getTplPlaceholders() { |
|
| 231 | - $ph = array (); |
|
| 232 | - return $ph; |
|
| 233 | - } |
|
| 227 | + /** |
|
| 228 | + * @return array |
|
| 229 | + */ |
|
| 230 | + public function getTplPlaceholders() { |
|
| 231 | + $ph = array (); |
|
| 232 | + return $ph; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | 235 | /** |
| 236 | 236 | * @return string |
| 237 | 237 | */ |
| 238 | 238 | public function render() { |
| 239 | - if (!$this->checkPermissions()) { |
|
| 239 | + if (!$this->checkPermissions()) { |
|
| 240 | 240 | $output = $this->prerender(); |
| 241 | - if ($output !== false) { |
|
| 242 | - $ph = $this->getTplPlaceholders(); |
|
| 243 | - $ph['js'] = $this->renderJS($this->jsListDefault,$ph) . $this->renderJS($this->jsListCustom,$ph); |
|
| 244 | - $ph['styles'] = $this->renderJS($this->cssListDefault,$ph) . $this->renderJS($this->cssListCustom,$ph); |
|
| 245 | - $output = $this->DLTemplate->parseChunk('@CODE:'.$output,$ph); |
|
| 246 | - } |
|
| 247 | - return $output; |
|
| 241 | + if ($output !== false) { |
|
| 242 | + $ph = $this->getTplPlaceholders(); |
|
| 243 | + $ph['js'] = $this->renderJS($this->jsListDefault,$ph) . $this->renderJS($this->jsListCustom,$ph); |
|
| 244 | + $ph['styles'] = $this->renderJS($this->cssListDefault,$ph) . $this->renderJS($this->cssListCustom,$ph); |
|
| 245 | + $output = $this->DLTemplate->parseChunk('@CODE:'.$output,$ph); |
|
| 246 | + } |
|
| 247 | + return $output; |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | * @return mixed |
| 279 | 279 | */ |
| 280 | 280 | public function createTable() { |
| 281 | - $sql = ''; |
|
| 282 | - return $this->modx->db->query($sql); |
|
| 281 | + $sql = ''; |
|
| 282 | + return $this->modx->db->query($sql); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | * @param string $eventsType |
| 288 | 288 | */ |
| 289 | 289 | public function registerEvents($events = array(), $eventsType = '6') { |
| 290 | - $eventsTable = $this->modx->getFullTableName('system_eventnames'); |
|
| 291 | - foreach ($events as $event) { |
|
| 292 | - $result = $this->modx->db->select('`id`',$eventsTable,"`name` = '{$event}'"); |
|
| 293 | - if (!$this->modx->db->getRecordCount($result)) { |
|
| 294 | - $sql = "INSERT INTO {$eventsTable} VALUES (NULL, '{$event}', '{$eventsType}', '{$this->pluginName} Events')"; |
|
| 295 | - if (!$this->modx->db->query($sql)) $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - } |
|
| 290 | + $eventsTable = $this->modx->getFullTableName('system_eventnames'); |
|
| 291 | + foreach ($events as $event) { |
|
| 292 | + $result = $this->modx->db->select('`id`',$eventsTable,"`name` = '{$event}'"); |
|
| 293 | + if (!$this->modx->db->getRecordCount($result)) { |
|
| 294 | + $sql = "INSERT INTO {$eventsTable} VALUES (NULL, '{$event}', '{$eventsType}', '{$this->pluginName} Events')"; |
|
| 295 | + if (!$this->modx->db->query($sql)) $this->modx->logEvent(0, 3, "Cannot register {$event} event.", $this->pluginName); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | 299 | } |
| 300 | 300 | \ No newline at end of file |