Exemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see JSNPowerAdminBarPreviewAdapter::getPreviewLink()
  */
 public function getPreviewLink()
 {
     $matchedMap = null;
     foreach ($this->maps as $map) {
         $params = array();
         parse_str($map['params'], $params);
         $isMatched = true;
         foreach ($params as $key => $value) {
             if (!isset($this->params[$key]) || $this->params[$key] != $value) {
                 $isMatched = false;
                 break;
             }
         }
         if ($isMatched) {
             $matchedMap = $map;
             break;
         }
     }
     if ($matchedMap != null) {
         $link = $matchedMap['link'];
         $_linkParts = array();
         if (preg_match_all('/{@*([^\\}]+)}/i', $link, $_linkParts)) {
             $found = $_linkParts[0];
             $replaced = $_linkParts[1];
             foreach ($found as $k => $value) {
                 $link = str_replace($value, @$this->params[$replaced[$k]], $link);
             }
         }
         if (strpos($link, 'option=') === false) {
             $link = 'option=' . $this->option . '&' . $link;
         }
         return sprintf('index.php?%s', $link);
     }
     return parent::getPreviewLink();
 }
Exemplo n.º 2
0
 /**
  * Load adapter for detect preview link
  * @return JSNPowerAdminBarPreviewAdapter
  */
 private function loadAdapter()
 {
     $builtInFile = dirname(dirname(__FILE__)) . "/supports/{$this->option}.php";
     $builtInXmlFile = dirname(dirname(__FILE__)) . "/supports/{$this->option}.xml";
     $xmlFile = JPATH_ADMINISTRATOR . "/components/{$this->option}/preview.xml";
     if (is_file($builtInFile)) {
         require_once $builtInFile;
         $className = sprintf('JSNPowerAdminBarSupport%s', ucfirst(substr($this->option, strpos($this->option, '_') + 1)));
         $this->adapter = class_exists($className) ? new $className($this->option, $this->params) : null;
     } else {
         require_once dirname(dirname(__FILE__)) . "/supports/base.php";
         $this->adapter = new JSNPowerAdminBarSupportBase($this->option, $this->params);
         if (is_file($builtInXmlFile)) {
             $this->adapter->parseXml($builtInXmlFile);
         } elseif (is_file($xmlFile)) {
             $this->adapter->parseXml($xmlFile);
         }
     }
 }
Exemplo n.º 3
0
 public function getPreviewLink()
 {
     if (!isset($this->params['view']) || !isset($this->params['layout']) || !isset($this->params['id']) || $this->params['view'] != 'item' || $this->params['layout'] != 'edit') {
         return parent::getPreviewLink();
     }
     $dbo = JFactory::getDBO();
     $dbo->setQuery(sprintf('SELECT id, link FROM #__menu WHERE id=%d', $this->params['id']));
     $result = $dbo->loadObject();
     if (empty($result)) {
         return parent::getPreviewLink();
     }
     return sprintf('%s&Itemid=%d', $result->link, $result->id);
 }