Ejemplo n.º 1
0
 /**
  * Constructor
  *
  * For php4 compatability we must not use the __constructor as a constructor for plugins
  * because func_get_args ( void ) returns a copy of all passed arguments, NOT references.
  * This causes problems with cross-referencing necessary for the observer design pattern.
  *
  * @param	object	$subject The object to observe
  * @param	object 	$params  The object to observe
  */
 function plgContentJabookmark(&$subject, $params = null)
 {
     if (!$subject) {
         return;
     }
     parent::__construct($subject, $params);
     $this->plugin = JPluginHelper::getPlugin('content', 'jabookmark');
     $this->params = new JRegistry();
     $this->params->loadString($this->plugin->params);
 }
Ejemplo n.º 2
0
 /**
  * Display Preview content
  * @return void
  */
 public function showPreview()
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     $language = JFactory::getLanguage();
     // reset document type
     $document =& JFactory::getDocument();
     $document->setType('html');
     // required by module loadposition
     jimport('joomla.application.module.helper');
     // load paramter class
     jimport('joomla.html.parameter');
     wfimport('admin.helpers.extension');
     // Get variables
     $component_id = JRequest::getInt('component_id');
     // get post data
     $data = JRequest::getVar('data', '', 'POST', 'STRING', JREQUEST_ALLOWRAW);
     // cleanup data
     $data = preg_replace(array('#<!DOCTYPE([^>]+)>#i', '#<(head|title|meta)([^>]*)>([\\w\\W]+)<\\/1>#i', '#<\\/?(html|body)([^>]*)>#i'), '', rawurldecode($data));
     $component = WFExtensionHelper::getComponent($component_id);
     // create params registry object
     $params = new JRegistry();
     // create empty params string
     if (!isset($component->params)) {
         $component->params = '';
     }
     // process attribs (com_content etc.)
     if ($component->attribs) {
         $params->loadString($component->attribs);
     } else {
         if (class_exists('JParameter')) {
             $params = new JParameter($component->params);
         } else {
             $params->loadString($component->params);
         }
     }
     $article = JTable::getInstance('content');
     $article->id = 0;
     $article->created_by = $user->get('id');
     $article->parameters = new JRegistry();
     $article->text = $data;
     // allow this to be skipped as some plugins can cause FATAL errors.
     if ((bool) $this->getParam('process_content', 1)) {
         $limitstart = 0;
         JPluginHelper::importPlugin('content');
         require_once JPATH_SITE . '/components/com_content/helpers/route.php';
         // set error reporting to error only
         error_reporting(E_ERROR);
         $dispatcher->trigger('onPrepareContent', array(&$article, &$params, $limitstart));
     }
     $this->processURLS($article);
     return $article->text;
 }