]*>\s*)?(\{|\[)".$this->plugincode."\s*(.*?)(\}|\])(\s*<\/p>)?/si"; $this->countmatch = 3; } elseif ($this->brackets=="[") { $this->regex="/(
]*>\s*)?\[".$this->plugincode."\s*(.*?)\](\s*<\/p>)?/si"; $this->countmatch = 2; } else { $this->regex="/(
]*>\s*)?{".$this->plugincode."\s*(.*?)}(\s*<\/p>)?/si"; $this->countmatch = 2; } // The helper class $this->helper = null; // Clean up variables unset($plugin, $option, $view, $task, $layout); } /** * Do something onAfterInitialise */ public function onAfterInitialise() { $this->event = 'onAfterInitialise'; } /** * onPrepareContent is rename in Joomla 1.6 to onContentPrepare */ public function onContentPrepare($context, &$article, &$params, $limitstart=0) { $this->event = 'onContentPrepare'; $app = JFactory::getApplication(); if($app->isAdmin()) { return; } // get document types $this->_getdoc(); $text = &$article->text; $introtext = &$article->introtext; // check whether plugin has been unpublished if ( !$this->params->get( 'publ', 1 ) ) { $text = preg_replace( $this->regex, '', $text ); return true; } // PDF can't show maps so remove it if ($this->doctype=='pdf') { $text = preg_replace( $this->regex, '', $text ); return true; } // check if article is in edit mode then don't replace {mosmap{ so it can be edited if ($this->editmode) return true; // perform the replacement in a normal way, but this has the disadvantage that other plugins // can't add information to the mosmap, other later added content is not checked and modules can't be checked // $this->_replace( $text ); // $this->_replace( $introtext ); // Clean up variables unset($app, $text, $introtext); } /** * onPrepareContent is for Joomla 1.5 */ public function onPrepareContent(&$article) { $this->event = 'onPrepareContent'; $app = JFactory::getApplication(); if($app->isAdmin()) { return; } // get document types $this->_getdoc(); $text = &$article->text; $introtext = &$article->introtext; // check whether plugin has been unpublished if ( !$this->params->get( 'publ', 1 ) ) { $text = preg_replace( $this->regex, '', $text ); return true; } // PDF or feed can't show maps so remove it if ($this->doctype=='pdf'||$this->doctype=='feed') { $text = preg_replace( $this->regex, '', $text ); return true; } // check if article is in edit mode then don't replace {mosmap{ so it can be edited if ($this->editmode) return true; // perform the replacement in a normal way, but this has the disadvantage that other plugins // can't add information to the mosmap, other later added content is not checked and modules can't be checked //$this->_replace( $text ); //$this->_replace( $introtext ); // Clean up variables unset($app, $text, $introtext); } /** * Do something onAfterRoute */ public function onAfterRoute() { $this->event = 'onAfterRoute'; } /** * Do something onAfterDispatch */ public function onAfterDispatch() { $this->event = 'onAfterDispatch'; $app = JFactory::getApplication(); if($app->isAdmin()) { return; } // get document types $this->_getdoc(); // FEED if ($this->doctype=='feed'&&isset($this->document->items)) { foreach($this->document->items as $item) { $text = &$item->description; $text = preg_replace( $this->regex, '', $text ); } return true; } // PDF can't show maps so remove it if ($this->doctype=='pdf') { $text = $this->document->getBuffer("component"); $text = preg_replace( $this->regex, '', $text ); $this->document->setBuffer($text, "component"); return true; } // check if article is in edit mode then don't replace {mosmap{ so it can be edited if ($this->editmode) { return true; } // In other components or leftovers $text = $this->document->getBuffer("component"); if (strlen($text)>0) { // check whether plugin has been unpublished if ( !$this->params->get( 'publ', 1 ) ) $text = preg_replace( $this->regex, '', $text ); else $this->_replace($text); $this->document->setBuffer($text, "component"); } // Clean up variables unset($app, $item, $text, $introtext); } /** * Do something onAfterRender */ public function onAfterRender() { $this->event = 'onAfterRender'; $app = JFactory::getApplication(); if($app->isAdmin()) { return; } // get document types $this->_getdoc(); // Get the rendered body text $text = JResponse::getBody(); // check whether plugin has been unpublished if ( !$this->params->get( 'publ', 1 ) ) { $text = preg_replace( $this->regex, '', $text ); return true; } // PDF or feed can't show maps so remove it if ($this->doctype=='pdf'||$this->doctype=='feed') { $text = preg_replace( $this->regex, '', $text ); return true; } // check if article is in edit mode then don't replace {mosmap{ so it can be edited if ($this->editmode) return true; // perform the replacement $this->_replace( $text ); // Set the body text with the replaced result JResponse::setBody($text); // Clean up variables unset($app, $text, $introtext); } function _getdoc() { if ($this->document==NULL) { $this->document = JFactory::getDocument(); $this->doctype = $this->document->getType(); } // Edit mode? if ($this->editmode==NULL) { // Edit mode? $option = JRequest::getVar('option', ''); $view = JRequest::getVar('view', ''); if (substr($this->jversion,0,3)=="1.5") { // Edit mode Joomla 1.5 $task = JRequest::getVar('task', ''); $this->editmode = ($option=='com_content'&&$view=='article'&&$task=="edit"); } else { // Edit mode Joomla 1.6 $layout = JRequest::getVar('layout', ''); $this->editmode = ($option=='com_content'&&$view=='form'&&$layout=="edit"); } // if (class_exists("JEditor")) // $this->editmode= true; } } function _replace(&$text) { $matches = array(); $cnt = preg_match_all($this->regex,$text,$matches,PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER); // print_r($matches); if ($cnt>0) { if ($this->helper==null) { if (substr($this->jversion,0,3)=="1.5") $filename = JPATH_SITE.DS."/plugins/system/plugin_googlemap2_helper.php"; else $filename = JPATH_SITE.DS."/plugins/system/plugin_googlemap2/plugin_googlemap2_helper.php"; include_once($filename); $this->helper = new plgSystemPlugin_googlemap2_helper($this->jversion, $this->params, $this->regex, $this->document, $this->brackets); } // Process the found {mosmap} codes for($counter = 0; $counter < $cnt; $counter ++) { // Very strange the first match is the plugin code?? $this->helper->process($matches[0][$counter][0], $matches[$this->countmatch][$counter][0], $text, $counter, $this->event); } } // Clean up variables unset($matches, $cnt, $counter, $content, $filename); } function _upgrade_plugin() { $app = JFactory::getApplication(); if($app->isSite()) { return; } if ($this->params->get( 'publ', '' )=='') { if (substr($this->jversion,0,3)=="1.5") { $database =& JFactory::getDBO(); $query = "SELECT params FROM #__plugins AS b WHERE b.element='plugin_googlemap2' AND b.folder='content'"; $database->setQuery($query); if (!$database->query()) JError::raiseWarning(1, 'plgSystemPlugin_googlemap2::install_params: '.JText::_('SQL Error')." ".$database->stderr(true)); $params = $database->loadResult(); $savparams = $database->getEscaped($params); if ($params!="") { $query = "UPDATE #__plugins AS a SET a.params = '{$savparams}' WHERE a.element='plugin_googlemap2' AND a.folder='system'"; $database->setQuery($query); if (!$database->query()) JError::raiseWarning(1, 'plgSystemPlugin_googlemap2::install_params: '.JText::_('SQL Error')." ".$database->stderr(true)); $this->params = new JParameter( $params ); } // Clean up variables unset($database, $query, $params, $savparams, $plugin); } } } function _restore_permanent_defaults() { $app = JFactory::getApplication(); if($app->isSite()) { return; } if ($this->params->get( 'publ', '' )!='') { jimport('joomla.filesystem.file'); if (substr($this->jversion,0,3)=="1.5") $dir = JPATH_SITE.DS."/plugins/system/"; else $dir = JPATH_SITE.DS."/plugins/system/plugin_googlemap2/"; if (file_exists($dir.'plugin_googlemap2.perm')) { if (JFile::move ($dir.'plugin_googlemap2.xml', $dir.'plugin_googlemap2.init')) { if (JFile::move ($dir.'plugin_googlemap2.perm', $dir.'plugin_googlemap2.xml')) JFile::delete($dir.'plugin_googlemap2.init'); else JFile::move ($dir.'plugin_googlemap2.init', $dir.'plugin_googlemap2.xml'); } } } } } ?>