/**
  * Evaluate Extension by getting the name and the params
  * ###mailform(param=value, param=value)###
  *
  * @param String $string The content to parse
  */
 function evaluateExtension($string)
 {
     $regex = "/###Ext:(.*)###/";
     $regex2 = "/^(.*)\\((.*)\\)\$/";
     preg_match($regex, $string, $matches);
     if (!empty($matches[1])) {
         preg_match($regex2, $matches[1], $params);
         if (!empty($params[1])) {
             $extName = $params[1];
             $tmpParams = $params[2];
             //Explode Params
             $tmpParams = explode(",", $tmpParams);
             foreach ($tmpParams as $val) {
                 $para = explode("=", $val);
                 $extParams[trim($para[0])] = trim($para[1]);
             }
             //now we got the name and the params so lets include and pass
             require_once $this->config->miplexDir . "ExtensionManager.class.php";
             $extManager = new ExtensionManager($this->config);
             $ext = $extManager->loadExtension($extName);
             if ($ext != false) {
                 $ret = $ext->main($extParams);
                 $this->ext = 1;
             } else {
                 $ret = "Plugin not Found";
             }
             $string = preg_replace($regex, $ret, $string);
         }
     }
     return $string;
 }
function smarty_function_loadExtension($params, &$smarty)
{
    //fetch plugin name
    $extName = $params['name'];
    $config =& $params['config'];
    if (empty($extName)) {
        return "No Extension selected";
    }
    $extParams = array();
    if (isset($params['params'])) {
        //Explode Params
        $tmpParams = explode(",", $params['params']);
        foreach ($tmpParams as $val) {
            $para = explode("=", $val);
            $extParams[trim($para[0])] = trim($para[1]);
        }
    }
    // now we got the name and the params so lets include and pass
    require_once $config->miplexDir . "ExtensionManager.class.php";
    $extManager = new ExtensionManager($config);
    $ext = $extManager->loadExtension($extName);
    if ($ext != false) {
        return $ext->main($extParams);
    } else {
        return "Plugin not Found";
    }
}
function smarty_function_loadExtension($params, &$smarty)
{
    //fetch plugin name
    $extName = $params['name'];
    $config =& $params['config'];
    if (empty($extName)) {
        return "No Extension selected";
    }
    // now we got the name and the params so lets include and pass
    require_once $config->miplexDir . "ExtensionManager.class.php";
    $extManager = new ExtensionManager($config);
    $ext = $extManager->loadExtension($extName);
    if ($ext != false) {
        return $ext->main($extParams);
    } else {
        return "Plugin not Found";
    }
}
<?php

//Include Extension Manager
require_once $session->config->miplexDir . "ExtensionManager.class.php";
$extManager = new ExtensionManager($session->config);
//get all Extension
$exts = $extManager->getAllAvailableExtensions();
$menu = "<ul class='extension'>";
foreach ($exts as $ext) {
    $menu .= "<li><a href='?module=ext&id=" . $ext['basename'] . "' title='" . $ext['basename'] . "' class='extLink'>" . $ext['extName'] . "</a></li>";
}
$menu .= "</ul>";
//Handling Backendmenu of extension
if (!empty($_GET['id'])) {
    $obj =& $extManager->loadExtension($_GET['id']);
    $obj->baseSmarty =& $session->smarty;
    $session->smarty->assign("content", $obj->getBackend());
} else {
    $session->smarty->assign("content", "Please Select");
}
//
$session->smarty->assign("menu", $menu);
$session->smarty->assign("i18n", $session->i18n);
$session->smarty->assign("content_tpl", "admin/extensions/main.tpl");
Esempio n. 5
0
 /**
  * ejecuta un reporte que se haya cargado como una extension
  * 
  * @param string $extensionName nombre de la extension que va a generar el reporte
  * @param string $type tipo de reporte a generar (pdf, odt, html)
  * @return string 
  * 	nombre de la exension o false si no se genera el reporte
  * */
 public function RunToFile($extensionName, $type)
 {
     $extension = null;
     if (!$this->extensionFolder) {
         $this->extensionFolder = realpath('.') . '/';
     }
     if (!$this->reportOutDir) {
         $this->reportOutDir = $this->extensionFolder;
     }
     if (!$this->inExtension($extensionName)) {
         $extension = ExtensionManager::loadExtension($extensionName, $this->extensionFolder, $this->typeExtension);
         if ($extension) {
             $this->addExtension($extension);
         } else {
             return false;
         }
     }
     //instancia el reporte
     $report = new PJRU();
     $conn = $extension->getConexion();
     if (!$conn) {
         $conn = PJRUConexion::get();
     }
     $reportName = uniqid() . '.' . $type;
     $sqlSentence = $extension->getSqlSentence();
     $outfilename = $this->reportOutDir . $reportName;
     if ($extension->beforeRun() === false) {
         return false;
     }
     $parameters = $extension->getParam();
     if ($sqlSentence) {
         $methodName = 'run' . ucfirst($type) . 'FromSql';
         $reportFileName = $extension->reportFileName . '.jrxml';
     } else {
         $methodName = 'runReportTo' . ucfirst($type) . 'File';
         $reportFileName = $extension->reportFileName . '.jasper';
     }
     if (get_class($conn) == 'JdbcConnection') {
         $conn = $conn->getConnection();
     }
     $result = $report->{$methodName}(realpath($this->extensionFolder) . '/' . $reportFileName, $outfilename, $parameters, $sqlSentence, $conn);
     $extension->afterRun($outfilename);
     if ($result) {
         return $outfilename;
     } else {
         return false;
     }
 }