Skip to content

Commit

Permalink
Changed the naming conventions.
Browse files Browse the repository at this point in the history
Changed the naming conventions of the plugin files and classes. All the
class names and file names now begin with '[Ee]embedGoogleMap' to avoid
conflicts with other plugins.
  • Loading branch information
petkivim committed Mar 28, 2015
1 parent ee80f93 commit ae1e361
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 79 deletions.
29 changes: 0 additions & 29 deletions src/builderFactory.php

This file was deleted.

29 changes: 29 additions & 0 deletions src/embedGoogleMapBuilderFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

require_once __DIR__ . '/embedGoogleMapClassicHtmlBuilder.php';
require_once __DIR__ . '/embedGoogleMapNewHtmlBuilder.php';
require_once __DIR__ . '/embedGoogleMapEmbedAPIHtmlBuilder.php';

class EmbedGoogleMapBuilderFactory {
public static function createBuilder($version) {
if(strcmp($version,'classic') == 0) {
return new EmbedGoogleMapClassicHtmlBuilder;
} else if(strcmp($version,'new') == 0) {
return new EmbedGoogleMapNewHtmlBuilder;
} else if(strcmp($version,'embed') == 0) {
return new EmbedGoogleMapEmbedAPIHtmlBuilder;
}
return new EmbedGoogleMapNewHtmlBuilder;
}
}
?>
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.0 2014-05-30 17:30 $
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014 Petteri Kivimäki. All rights reserved.
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

require_once __DIR__ . '/htmlBuilder.php';
require_once __DIR__ . '/embedGoogleMapHtmlBuilder.php';

class ClassicHtmlBuilder extends HtmlBuilder {
class EmbedGoogleMapClassicHtmlBuilder extends EmbedGoogleMapHtmlBuilder {

private $baseUrl = "http://maps.google.com/";

Expand Down Expand Up @@ -61,5 +61,4 @@ public function buildHtml(&$params) {
}
}

?>

?>
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.0 2014-06-05 17:54 $
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014 Petteri Kivimäki. All rights reserved.
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

require_once __DIR__ . '/htmlBuilder.php';
require_once __DIR__ . '/embedGoogleMapHtmlBuilder.php';

class EmbedAPIHtmlBuilder extends HtmlBuilder {
class EmbedGoogleMapEmbedAPIHtmlBuilder extends EmbedGoogleMapHtmlBuilder {

private $baseUrl = "https://www.google.com/maps/embed/v1/search";

Expand Down Expand Up @@ -58,5 +58,4 @@ private function getMapType($mapType) {
}
}

?>

?>
9 changes: 4 additions & 5 deletions src/htmlBuilder.php → src/embedGoogleMapHtmlBuilder.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.0 2014-06-05 17:53 $
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014 Petteri Kivimäki. All rights reserved.
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

abstract class HtmlBuilder {
abstract class EmbedGoogleMapHtmlBuilder {
abstract public function buildHtml(&$params);

protected function getUrl(&$params, $baseUrl) {
Expand Down Expand Up @@ -43,5 +43,4 @@ protected function getLinkHtml($url, $label) {

}

?>

?>
11 changes: 5 additions & 6 deletions src/newHtmlBuilder.php → src/embedGoogleMapNewHtmlBuilder.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.0 2014-06-05 17:53 $
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014 Petteri Kivimäki. All rights reserved.
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

require_once __DIR__ . '/htmlBuilder.php';
require_once __DIR__ . '/embedGoogleMapHtmlBuilder.php';

class NewHtmlBuilder extends HtmlBuilder {
class EmbedGoogleMapNewHtmlBuilder extends EmbedGoogleMapHtmlBuilder {

private $baseUrl = "https://www.google.com/maps";

Expand Down Expand Up @@ -54,5 +54,4 @@ private function getMapType($mapType) {
}
}

?>

?>
8 changes: 4 additions & 4 deletions src/parameters.php → src/embedGoogleMapParameters.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.0 2014-06-01 17:30 $
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014 Petteri Kivimäki. All rights reserved.
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

class Parameters {
class EmbedGoogleMapParameters {
private $version = "new";
private $embedAPIKey = "";
private $address = "";
Expand Down Expand Up @@ -206,4 +206,4 @@ public function toString() {
return $str;
}
}
?>
?>
8 changes: 4 additions & 4 deletions src/parser.php → src/embedGoogleMapParser.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.0 2014-06-01 17:30 $
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014 Petteri Kivimäki. All rights reserved.
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

class Parser {
class EmbedGoogleMapParser {

public function parse($string, &$params) {
$arr = explode('|',$string);
Expand Down Expand Up @@ -148,4 +148,4 @@ public function parse($string, &$params) {
}
}

?>
?>
16 changes: 8 additions & 8 deletions src/embed_google_map.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @version $Id: Embed Google Map v2.0.0 2014-06-05 17:50 $
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014 Petteri Kivimäki. All rights reserved.
* @copyright Copyright (C) 2014-2015 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
Expand All @@ -14,9 +14,9 @@

jimport('joomla.plugin.plugin');

require_once __DIR__ . '/parameters.php';
require_once __DIR__ . '/builderFactory.php';
require_once __DIR__ . '/parser.php';
require_once __DIR__ . '/embedGoogleMapParameters.php';
require_once __DIR__ . '/embedGoogleMapBuilderFactory.php';
require_once __DIR__ . '/embedGoogleMapParser.php';

class plgContentembed_google_map extends JPlugin
{
Expand All @@ -38,7 +38,7 @@ function onContentPrepare($context, &$row, &$params, $limitstart)
foreach ( $matches[0] as $value )
{
// Plugin params
$plgParams = new Parameters;
$plgParams = new EmbedGoogleMapParameters;
// Load plugin params
$plgParams->setVersion($this->params->def('version', 'new'));
$plgParams->setEmbedAPIKey($this->params->def('embed_api_key', ''));
Expand All @@ -65,7 +65,7 @@ function onContentPrepare($context, &$row, &$params, $limitstart)
if( strstr($map, $find) )
{
// New Parser object
$parser = new Parser;
$parser = new EmbedGoogleMapParser;
// Parse parameters
$parser->parse($map, $plgParams);
} else {
Expand All @@ -85,7 +85,7 @@ function onContentPrepare($context, &$row, &$params, $limitstart)
$plgParams->setLinkLabel(JText::_($mtcs[1]));
}
// Create new HTML builder
$builder = BuilderFactory::createBuilder($plgParams->getVersion());
$builder = EmbedGoogleMapBuilderFactory::createBuilder($plgParams->getVersion());
// Generate HTML code
$replacement[$count] = $builder->buildHtml($plgParams);
// Increase counter
Expand Down
22 changes: 11 additions & 11 deletions src/embed_google_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
<extension version="1.6" type="plugin" group="content" method="upgrade">
<name>PLG_EMBED_GOOGLE_MAP</name>
<author>Petteri Kivimäki</author>
<creationDate>5 June 2014</creationDate>
<copyright>(C)2012-2014 Petteri Kivimäki</copyright>
<creationDate>28 March 2015</creationDate>
<copyright>(C)2012-2015 Petteri Kivimäki</copyright>
<license>http://www.gnu.org/copyright/gpl.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<version>2.0.0</version>
<authorEmail>[email protected]</authorEmail>
<version>2.0.1</version>
<description>PLG_EMBED_GOOGLE_MAP_DESC</description>
<files>
<filename plugin="embed_google_map">embed_google_map.php</filename>
<filename>parameters.php</filename>
<filename>embedGoogleMapParameters.php</filename>
<!-- Parser -->
<filename>parser.php</filename>
<filename>embedGoogleMapParser.php</filename>
<!-- Builders -->
<filename>builderFactory.php</filename>
<filename>htmlBuilder.php</filename>
<filename>classicHtmlBuilder.php</filename>
<filename>newHtmlBuilder.php</filename>
<filename>embedAPIHtmlBuilder.php</filename>
<filename>embedGoogleMapBuilderFactory.php</filename>
<filename>embedGoogleMapHtmlBuilder.php</filename>
<filename>embedGoogleMapClassicHtmlBuilder.php</filename>
<filename>embedGoogleMapNewHtmlBuilder.php</filename>
<filename>embedGoogleMapEmbedAPIHtmlBuilder.php</filename>
<!-- Other files-->
<filename>index.html</filename>
<filename>license-gpl.txt</filename>
Expand Down

0 comments on commit ae1e361

Please sign in to comment.