|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_integration/pathumthani_drug/plugins/content/ |
Upload File : |
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onPrepareContent', 'plgContentGoogle' );
function plgContentGoogle ( &$row, &$params )
{
JPlugin::loadLanguage( 'plg_content_google', JPATH_ADMINISTRATOR );
if (preg_match('/\{googleSimple\s*(.*?)\}/is', $row->text, $matches)){
$google = contentGoogleMap_getGoogleById($matches[1], 'simple');
$google_params = contentGoogleMap_process($matches);
$html = contentGoogleMap_createHTML($google, 'simple', $google_params);
$row->text = str_replace("{googleSimple $matches[1]}", $html, $row->text);
}elseif(preg_match('/\{googleStandard\s*(.*?)\}/is', $row->text, $matches)){
$google = contentGoogleMap_getGoogleById($matches[1], 'standard');
$google_params = contentGoogleMap_process($matches);
$html = contentGoogleMap_createHTML($google, 'standard', $google_params);
$row->text = str_replace("{googleStandard $matches[1]}", $html, $row->text);
}
return true;
}
function contentGoogleMap_getGoogleById ($id, $type)
{
$db =& JFactory::getDBO();
if($type=='simple') {
$query = "SELECT *"
. " FROM #__google_destinations"
. " WHERE published=1 AND id = ". (int) $id;
$db->setQuery($query);
$google = $db->loadObject();
if(!$google->published)
{
JError::raiseError( 404, "Invalid ID provided" );
}
}elseif ($type=='standard'){
$query = "SELECT a.*"
. " FROM #__google_destinations AS a, #__google AS b "
. " WHERE a.published=1 AND b.published=1 AND a.catid=b.id AND b.id = ".(int) $id;
$db->setQuery($query);
$google = $db->loadObjectList();
}
return $google;
}
function contentGoogleMap_process($matches)
{
if (preg_match("/setcenter=\"(\S*)\"/", $matches[1], $matches2)) $setcenter = $matches2[1];
if (preg_match("/width=\"(\d+[\S]*)\"/", $matches[1], $matches2)) $width = $matches2[1];
if (preg_match("/height=\"(\d+[\S]*)\"/", $matches[1], $matches2)) $height = $matches2[1];
if (preg_match("/zoomlevel=\"(\d+[\S]*)\"/", $matches[1], $matches2)) $zoomlevel = $matches2[1];
if (preg_match("/routing=\"(\d+[\S]*)\"/", $matches[1], $matches2)) $routing = $matches2[1];
if (preg_match("/maptype=\"(\S*)\"/", $matches[1], $matches2)) $maptype = $matches2[1];
$param_google = new stdClass;
$param_google->setcenter = $setcenter;
$param_google->width = $width;
$param_google->height = $height;
$param_google->zoomlevel = $zoomlevel;
$param_google->routing = $routing;
$param_google->maptype = $maptype;
return $param_google;
}
function contentGoogleMap_createHTML($google, $type, $google_params)
{
if($type=='simple') {
require_once(dirname(__FILE__).'/google/simple.php');
}elseif ($type=='standard'){
require_once(dirname(__FILE__).'/google/standard.php');
}
return $html;
}
?>