From 2678285c33cbdbc1351fd6e1fec647d63112504f Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 2 Feb 2018 12:07:44 +0500 Subject: [PATCH 1/5] * Minor changes: Code style. --- ddYMap.php | 89 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/ddYMap.php b/ddYMap.php index 33b77d4..193c8a8 100644 --- a/ddYMap.php +++ b/ddYMap.php @@ -5,23 +5,23 @@ * * @desc A snippet that allows Yandex.Maps to be rendered on a page in a simple way. * - * @uses The library modx.ddTools 0.12. + * @uses MODXEvo.libraries.ddTools >= 0.12 {@link http://code.divandesign.biz/modx/ddtools }. * * @note Attention! The jQuery library should be included on the page. * @note From the pair of “$geoPos” / “$docField” parameters one is required. * - * @param $geoPos {comma separated string} - Comma separated longitude and latitude. @required - * @param $docField {string} - A field name with position that is required to be got. - * @param $docId {integer} - Document ID with a field value needed to be received. Default: current document. - * @param $mapElement {string} - Container selector which the map is required to be embed in. Default: '#map'. - * @param $defaultType {'map'; 'satellite'; 'hybrid'; 'publicMap'; 'publicMapHybrid'} - Default map type: 'map' — schematic map, 'satellite' — satellite map, 'hybrid' — hybrid map, 'publicMap' — public map, 'publicMapHybrid' - hybrid public map. Default: 'map'. - * @param $defaultZoom {integer} - Default map zoom. Default: 15. - * @param $icon {string} - An icon to use (relative address). Default: without (default icon). - * @param $iconOffset {comma separated string} - An offset of the icon in pixels (x, y).Basic position: the icon is horizontally centered with respect to x and its bottom position is y. Default: '0,0'. - * @param $scrollZoom {0; 1} - Allow zoom while scrolling. Default: 0. - * @param $mapCenterOffset {comma separated string} - Center offset of the map with respect to the center of the map container in pixels. Default: '0,0'. - * @param $lang {'ru_RU'; 'en_US'; 'ru_UA'; 'uk_UA'; 'tr_TR'} - Map language — locale ID. See http://api.yandex.com/maps/doc/jsapi/2.x/dg/concepts/load.xml for more information. Default: 'ru_RU'. - * @param $scriptsLocation {'head'; 'body';} - The tag where jQuery scripts are included. Default: 'head'. + * @param $geoPos {string_commaSeparated} — Comma separated longitude and latitude. @required + * @param $docField {string} — A field name with position that is required to be got. + * @param $docId {integer} — Document ID with a field value needed to be received. Default: current document. + * @param $mapElement {string} — Container selector which the map is required to be embed in. Default: '#map'. + * @param $defaultType {'map'|'satellite'|'hybrid'|'publicMap'|'publicMapHybrid'} — Default map type: 'map' — schematic map, 'satellite' — satellite map, 'hybrid' — hybrid map, 'publicMap' — public map, 'publicMapHybrid' - hybrid public map. Default: 'map'. + * @param $defaultZoom {integer} — Default map zoom. Default: 15. + * @param $icon {string} — An icon to use (relative address). Default: without (default icon). + * @param $iconOffset {string_commaSeparated} — An offset of the icon in pixels (x, y).Basic position: the icon is horizontally centered with respect to x and its bottom position is y. Default: '0,0'. + * @param $scrollZoom {0|1} — Allow zoom while scrolling. Default: 0. + * @param $mapCenterOffset {string_commaSeparated} — Center offset of the map with respect to the center of the map container in pixels. Default: '0,0'. + * @param $lang {'ru_RU'|'en_US'|'ru_UA'|'uk_UA'|'tr_TR'} — Map language — locale ID. See http://api.yandex.com/maps/doc/jsapi/2.x/dg/concepts/load.xml for more information. Default: 'ru_RU'. + * @param $scriptsLocation {'head'|'body'} — The tag where jQuery scripts are included. Default: 'head'. * * @link http://code.divandesign.biz/modx/ddymap/1.6 * @@ -31,7 +31,7 @@ //Подключаем modx.ddTools require_once $modx->getConfig('base_path').'assets/snippets/ddTools/modx.ddtools.class.php'; -//Для обратной совместимости +//Backward compatibility extract(ddTools::verifyRenamedParams($params, array( 'docField' => 'getField', 'docId' => 'getId' @@ -39,7 +39,10 @@ //Если задано имя поля, которое необходимо получить if (isset($docField)){ - $geoPos = ddTools::getTemplateVarOutput(array($docField), $docId); + $geoPos = ddTools::getTemplateVarOutput( + array($docField), + $docId + ); $geoPos = $geoPos[$docField]; } @@ -67,7 +70,10 @@ $iconSize = getimagesize($icon); //если смещение не задано сделаем над опорной точкой ценруя по ширине - $resultIconOffset = array($iconSize[0] / -2, $iconSize[1] * -1); + $resultIconOffset = array( + $iconSize[0] / -2, + $iconSize[1] * -1 + ); if (!empty($iconOffset)){ $iconOffset = explode(',', $iconOffset); //если задано сделает относительно положения по умолчанию @@ -87,7 +93,12 @@ } //Если нужен скролл колесом мыши, упомянем об этом - if (isset($scrollZoom) && $scrollZoom == 1){$inlineScript .= ', scrollZoom: true';} + if ( + isset($scrollZoom) && + $scrollZoom == 1 + ){ + $inlineScript .= ', scrollZoom: true'; + } //Тип карты по умолчанию if (!empty($defaultType)){$inlineScript .= ', defaultType: "'.$defaultType.'"';} //Масштаб карты по умолчанию @@ -99,18 +110,48 @@ if ($scriptsLocation == 'head') { //Подключаем библиотеку карт - $modx->regClientStartupScript('//api-maps.yandex.ru/2.1/?lang=' . $lang, array('name' => 'api-maps.yandex.ru', 'version' => '2.1')); + $modx->regClientStartupScript( + '//api-maps.yandex.ru/2.1/?lang='.$lang, + array( + 'name' => 'api-maps.yandex.ru', + 'version' => '2.1' + ) + ); //Подключаем $.ddYMap - $modx->regClientStartupScript($modx->getConfig('site_url') . 'assets/js/jquery.ddYMap-1.4.min.js', array('name' => '$.ddYMap', 'version' => '1.4')); + $modx->regClientStartupScript( + $modx->getConfig('site_url').'assets/js/jquery.ddYMap-1.4.min.js', + array( + 'name' => '$.ddYMap', + 'version' => '1.4' + ) + ); //Подключаем инлайн-скрипт с инициализацией - $modx->regClientStartupScript('', array('plaintext' => true)); + $modx->regClientStartupScript( + '', + array('plaintext' => true) + ); }else{ //Подключаем библиотеку карт - $modx->regClientScript("", array('name' => 'api-maps.yandex.ru', 'version' => '2.1')); + $modx->regClientScript( + '', + array( + 'name' => 'api-maps.yandex.ru', + 'version' => '2.1' + ) + ); //Подключаем $.ddYMap - $modx->regClientScript("", array('name' => '$.ddYMap', 'version' => '1.4')); + $modx->regClientScript( + '', + array( + 'name' => '$.ddYMap', + 'version' => '1.4' + ) + ); //Подключаем инлайн-скрипт с инициализацией - $modx->regClientScript("", array('plaintext' => true)); + $modx->regClientScript( + '', + array('plaintext' => true) + ); } } -?> +?> \ No newline at end of file From 5e53c2377abd3f74ccaa7a8e1eb6ac547c55450b Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 2 Feb 2018 12:13:24 +0500 Subject: [PATCH 2/5] * The short array syntax is used. It is more convenient and simple for visual identification. * Attention! PHP >= 5.4 is required. --- ddYMap.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/ddYMap.php b/ddYMap.php index 193c8a8..a3d24b5 100644 --- a/ddYMap.php +++ b/ddYMap.php @@ -5,6 +5,7 @@ * * @desc A snippet that allows Yandex.Maps to be rendered on a page in a simple way. * + * @uses PHP >= 5.4. * @uses MODXEvo.libraries.ddTools >= 0.12 {@link http://code.divandesign.biz/modx/ddtools }. * * @note Attention! The jQuery library should be included on the page. @@ -32,15 +33,15 @@ require_once $modx->getConfig('base_path').'assets/snippets/ddTools/modx.ddtools.class.php'; //Backward compatibility -extract(ddTools::verifyRenamedParams($params, array( +extract(ddTools::verifyRenamedParams($params, [ 'docField' => 'getField', 'docId' => 'getId' -))); +])); //Если задано имя поля, которое необходимо получить if (isset($docField)){ $geoPos = ddTools::getTemplateVarOutput( - array($docField), + [$docField], $docId ); $geoPos = $geoPos[$docField]; @@ -70,10 +71,10 @@ $iconSize = getimagesize($icon); //если смещение не задано сделаем над опорной точкой ценруя по ширине - $resultIconOffset = array( + $resultIconOffset = [ $iconSize[0] / -2, $iconSize[1] * -1 - ); + ]; if (!empty($iconOffset)){ $iconOffset = explode(',', $iconOffset); //если задано сделает относительно положения по умолчанию @@ -112,45 +113,45 @@ //Подключаем библиотеку карт $modx->regClientStartupScript( '//api-maps.yandex.ru/2.1/?lang='.$lang, - array( + [ 'name' => 'api-maps.yandex.ru', 'version' => '2.1' - ) + ] ); //Подключаем $.ddYMap $modx->regClientStartupScript( $modx->getConfig('site_url').'assets/js/jquery.ddYMap-1.4.min.js', - array( + [ 'name' => '$.ddYMap', 'version' => '1.4' - ) + ] ); //Подключаем инлайн-скрипт с инициализацией $modx->regClientStartupScript( '', - array('plaintext' => true) + ['plaintext' => true] ); }else{ //Подключаем библиотеку карт $modx->regClientScript( '', - array( + [ 'name' => 'api-maps.yandex.ru', 'version' => '2.1' - ) + ] ); //Подключаем $.ddYMap $modx->regClientScript( '', - array( + [ 'name' => '$.ddYMap', 'version' => '1.4' - ) + ] ); //Подключаем инлайн-скрипт с инициализацией $modx->regClientScript( '', - array('plaintext' => true) + ['plaintext' => true] ); } } From c3d348d9aa830ee7ef1b9f07fd329cd0d9e79bdc Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 2 Feb 2018 12:24:41 +0500 Subject: [PATCH 3/5] * Attention! MODXEvo.libraries.ddTools >= 0.21 is required. --- ddYMap.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddYMap.php b/ddYMap.php index a3d24b5..8e0dc72 100644 --- a/ddYMap.php +++ b/ddYMap.php @@ -6,7 +6,7 @@ * @desc A snippet that allows Yandex.Maps to be rendered on a page in a simple way. * * @uses PHP >= 5.4. - * @uses MODXEvo.libraries.ddTools >= 0.12 {@link http://code.divandesign.biz/modx/ddtools }. + * @uses MODXEvo.libraries.ddTools >= 0.21 {@link http://code.divandesign.biz/modx/ddtools }. * * @note Attention! The jQuery library should be included on the page. * @note From the pair of “$geoPos” / “$docField” parameters one is required. @@ -29,8 +29,8 @@ * @copyright 2015–2017 DivanDesign {@link http://www.DivanDesign.biz } */ -//Подключаем modx.ddTools -require_once $modx->getConfig('base_path').'assets/snippets/ddTools/modx.ddtools.class.php'; +//Include MODXEvo.libraries.ddTools +require_once $modx->getConfig('base_path').'assets/libs/ddTools/modx.ddtools.class.php'; //Backward compatibility extract(ddTools::verifyRenamedParams($params, [ From 2ad6e9fbc27dc102fd1a76b1b4d35c11ae6616f6 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 2 Feb 2018 13:19:20 +0500 Subject: [PATCH 4/5] =?UTF-8?q?*=20The=20following=20parameters=20have=20b?= =?UTF-8?q?een=20renamed=20(the=20snippet=20works=20with=20the=20old=20nam?= =?UTF-8?q?es=20but=20they=20are=20deprecated):=20=09*=20=E2=80=9CdocField?= =?UTF-8?q?=E2=80=9D=20=E2=86=92=20=E2=80=9CgeoPos=5FdocField=E2=80=9D.=20?= =?UTF-8?q?=09*=20=E2=80=9CdocId=E2=80=9D=20=E2=86=92=20=E2=80=9CgeoPos=5F?= =?UTF-8?q?docId=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ddYMap.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ddYMap.php b/ddYMap.php index 8e0dc72..10dda8f 100644 --- a/ddYMap.php +++ b/ddYMap.php @@ -9,11 +9,11 @@ * @uses MODXEvo.libraries.ddTools >= 0.21 {@link http://code.divandesign.biz/modx/ddtools }. * * @note Attention! The jQuery library should be included on the page. - * @note From the pair of “$geoPos” / “$docField” parameters one is required. + * @note From the pair of “$geoPos” / “$geoPos_docField” parameters one is required. * * @param $geoPos {string_commaSeparated} — Comma separated longitude and latitude. @required - * @param $docField {string} — A field name with position that is required to be got. - * @param $docId {integer} — Document ID with a field value needed to be received. Default: current document. + * @param $geoPos_docField {string} — A field name with position that is required to be got. + * @param $geoPos_docId {integer} — Document ID with a field value needed to be received. Default: current document. * @param $mapElement {string} — Container selector which the map is required to be embed in. Default: '#map'. * @param $defaultType {'map'|'satellite'|'hybrid'|'publicMap'|'publicMapHybrid'} — Default map type: 'map' — schematic map, 'satellite' — satellite map, 'hybrid' — hybrid map, 'publicMap' — public map, 'publicMapHybrid' - hybrid public map. Default: 'map'. * @param $defaultZoom {integer} — Default map zoom. Default: 15. @@ -34,17 +34,17 @@ //Backward compatibility extract(ddTools::verifyRenamedParams($params, [ - 'docField' => 'getField', - 'docId' => 'getId' + 'geoPos_docField' => ['docField', 'getField'], + 'geoPos_docId' => ['docId', 'getId'] ])); //Если задано имя поля, которое необходимо получить -if (isset($docField)){ +if (isset($geoPos_docField)){ $geoPos = ddTools::getTemplateVarOutput( - [$docField], - $docId + [$geoPos_docField], + $geoPos_docId ); - $geoPos = $geoPos[$docField]; + $geoPos = $geoPos[$geoPos_docField]; } //Где должны быть подключены скрипты From 79ac7db3ad3c3383175cfceeb1ce71725bff7336 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 2 Feb 2018 20:30:23 +0500 Subject: [PATCH 5/5] Prerelease 1.6.1 --- ddYMap.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddYMap.php b/ddYMap.php index 10dda8f..7d75090 100644 --- a/ddYMap.php +++ b/ddYMap.php @@ -1,7 +1,7 @@