当前位置: 首页>>代码示例>>PHP>>正文


PHP XsltProcessor::registerPHPFunctions方法代码示例

本文整理汇总了PHP中XsltProcessor::registerPHPFunctions方法的典型用法代码示例。如果您正苦于以下问题:PHP XsltProcessor::registerPHPFunctions方法的具体用法?PHP XsltProcessor::registerPHPFunctions怎么用?PHP XsltProcessor::registerPHPFunctions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XsltProcessor的用法示例。


在下文中一共展示了XsltProcessor::registerPHPFunctions方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  * Implement configurable object pattern 
  * @param Array|Zend_Config $config
  */
 public function __construct($config = null)
 {
     if ($config === null) {
         $config = array();
     }
     parent::__construct((array) $config);
     $this->_processor = new XsltProcessor();
     $this->_processor->registerPHPFunctions('System_View_Xslt_PartialRenderer::process');
     if (isset($config['params'])) {
         $this->setParameters($config['params']);
     }
     if (isset($config['debugMode'])) {
         $this->setDebugMode($config['debugMode']);
     }
 }
开发者ID:kandy,项目名称:system,代码行数:20,代码来源:Xslt.php

示例2: handle

 function handle($match, $state, $pos, Doku_Handler $handler)
 {
     switch ($state) {
         case DOKU_LEXER_SPECIAL:
             $matches = preg_split('/(&&XML&&\\n*|\\n*&&XSLT&&\\n*|\\n*&&END&&)/', $match, 5);
             $data = "XML: " . $matches[1] . "\nXSLT: " . $matches[2] . "(" . $match . ")";
             $xsltproc = new XsltProcessor();
             $xml = new DomDocument();
             $xsl = new DomDocument();
             $xml->loadXML($matches[1]);
             $xsl->loadXML($matches[2]);
             $xsltproc->registerPHPFunctions();
             $xsltproc->importStyleSheet($xsl);
             $data = $xsltproc->transformToXML($xml);
             if (!$data) {
                 $errors = libxml_get_errors();
                 foreach ($errors as $error) {
                     $data = display_xml_error($error, $xml);
                 }
                 libxml_clear_errors();
             }
             unset($xsltproc);
             return array($state, $data);
         case DOKU_LEXER_UNMATCHED:
             return array($state, $match);
         case DOKU_LEXER_EXIT:
             return array($state, '');
     }
     return array();
 }
开发者ID:rpeyron,项目名称:plugin-xslt,代码行数:30,代码来源:syntax.php

示例3: evaluatePath

 /**
  * @param $path
  * @param array $data
  * @return string
  */
 protected function evaluatePath($path, array $data = [])
 {
     $preferences = $this->XSLTSimple->addChild('Preferences');
     $url = $preferences->addChild('url');
     $url->addAttribute('isHttps', Request::secure());
     $url->addAttribute('currentUrl', Request::url());
     $url->addAttribute('baseUrl', URL::to(''));
     $url->addAttribute('previousUrl', URL::previous());
     $server = $preferences->addChild('server');
     $server->addAttribute('curretnYear', date('Y'));
     $server->addAttribute('curretnMonth', date('m'));
     $server->addAttribute('curretnDay', date('d'));
     $server->addAttribute('currentDateTime', date('Y-m-d H:i:s'));
     $language = $preferences->addChild('language');
     $language->addAttribute('current', App::getLocale());
     $default_language = \Config::get('app.default_language');
     if (isset($default_language)) {
         $language->addAttribute('default', $default_language);
     }
     $languages = \Config::get('app.available_languages');
     if (is_array($languages)) {
         foreach ($languages as $lang) {
             $language->addChild('item', $lang);
         }
     }
     // from form generator
     if (isset($data['form'])) {
         $this->XSLTSimple->addChild('Form', form($data['form']));
     }
     // adding form errors to xml
     if (isset($data['errors'])) {
         $this->XSLTSimple->addData($data['errors']->all(), 'FormErrors', false);
     }
     // "barryvdh/laravel-debugbar":
     // adding XML tab
     if (true === class_exists('Debugbar')) {
         $dom = dom_import_simplexml($this->XSLTSimple)->ownerDocument;
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         $prettyXml = $dom->saveXML();
         // add new tab and append xml to it
         if (false === \Debugbar::hasCollector('XML')) {
             \Debugbar::addCollector(new \DebugBar\DataCollector\MessagesCollector('XML'));
         }
         \Debugbar::getCollector('XML')->addMessage($prettyXml, 'info', false);
     }
     $xsl_processor = new \XsltProcessor();
     $xsl_processor->registerPHPFunctions();
     $xsl_processor->importStylesheet(simplexml_load_file($path));
     return $xsl_processor->transformToXML($this->XSLTSimple);
 }
开发者ID:gulios,项目名称:xsl-laravel-template-engine,代码行数:56,代码来源:XSLTEngine.php

示例4: getInterpretedXslt

function getInterpretedXslt($xslPath, $xmlPath, $xsltProcessor = null)
{
    if ($xsltProcessor == null) {
        $xsltProcessor = new XsltProcessor();
        $xsltProcessor->registerPHPFunctions();
    }
    $xsl = new DOMDocument();
    $xsl->load($xslPath);
    $xsltProcessor->importStylesheet($xsl);
    $xml = new DOMDocument();
    $xml->load($xmlPath);
    $output = $xsltProcessor->transformToXML($xml) or die('Transformation error!');
    return $output;
}
开发者ID:CyborgOne,项目名称:cybihomecontrol_ui,代码行数:14,代码来源:xslt_functions.php

示例5: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('view', function ($app) {
         $xsltProcessor = new XsltProcessor();
         $xsltProcessor->registerPHPFunctions();
         $extendedSimpleXMLElement = new ExtendedSimpleXMLElement('<App/>');
         $factory = new XSLTFactory($app['view.engine.resolver'], $app['view.finder'], $app['events'], $extendedSimpleXMLElement);
         $factory->setContainer($app);
         $factory->addExtension('xsl', 'xslt', function () use($xsltProcessor, $extendedSimpleXMLElement, $app) {
             return new XSLTEngine($xsltProcessor, $extendedSimpleXMLElement, $app['events']);
         });
         return $factory;
     });
 }
开发者ID:krowinski,项目名称:laravel-xslt,代码行数:19,代码来源:XSLTServiceProvider.php

示例6: xhtmlAction

 public function xhtmlAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $xml = DOCS_PATH . $this->view->docid . '.xml';
     $xsl = APPLICATION_PATH . 'modules/site/controllers/xml2html.xsl';
     $doc = new DOMDocument();
     $doc->substituteEntities = TRUE;
     $doc->load($xsl);
     $proc = new XsltProcessor();
     $proc->importStylesheet($doc);
     @$doc->load($xml);
     $proc->setParameter('', 'contextPath', '/');
     $proc->setParameter('', 'nodeResPath', '/res/' . $this->view->docid . '/');
     $proc->registerPHPFunctions('TypecontentController::widget');
     echo $proc->transformToXml($doc);
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:16,代码来源:TypecontentController.php

示例7: process

 /**
  * This function will take a given XML file, a stylesheet and apply
  * the transformation. Any errors will call the error function to log
  * them into the `$_errors` array
  *
  * @see toolkit.XSLTProcess#__error()
  * @see toolkit.XSLTProcess#__process()
  * @param string $xml
  *  The XML for the transformation to be applied to
  * @param string $xsl
  *  The XSL for the transformation
  * @param array $parameters
  *  An array of available parameters the XSL will have access to
  * @param array $register_functions
  *  An array of available PHP functions that the XSL can use
  * @return string|boolean
  *  The string of the resulting transform, or false if there was an error
  */
 public function process($xml = null, $xsl = null, array $parameters = array(), array $register_functions = array())
 {
     if ($xml) {
         $this->_xml = $xml;
     }
     if ($xsl) {
         $this->_xsl = $xsl;
     }
     // dont let process continue if no xsl functionality exists
     if (!XsltProcess::isXSLTProcessorAvailable()) {
         return false;
     }
     $XSLProc = new XsltProcessor();
     if (!empty($register_functions)) {
         $XSLProc->registerPHPFunctions($register_functions);
     }
     $result = @$this->__process($XSLProc, $this->_xml, $this->_xsl, $parameters);
     unset($XSLProc);
     return $result;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:38,代码来源:class.xsltprocess.php

示例8: translate

 /**
  * translate xml
  *
  * @param string $xml_dom 
  * @param string $xsl_dom 
  * @param string $params 
  * @param string $php_functions 
  * @return void
  * @author Andy Bennett
  */
 private static function translate($xml_dom, $xsl_dom, $params = array(), $php_functions = array())
 {
     /* create the processor and import the stylesheet */
     $proc = new XsltProcessor();
     $proc->importStyleSheet($xsl_dom);
     foreach ($params as $name => $param) {
         $proc->setParameter('', $name, $param);
     }
     if (is_array($php_functions)) {
         $proc->registerPHPFunctions($php_functions);
     }
     /* transform and output the xml document */
     $newdom = $proc->transformToDoc($xml_dom);
     return $newdom->saveXML();
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:25,代码来源:xsl.php

示例9: navigation

 /**
  * undocumented function
  *
  * @param integer $n 
  * @param integer $level 
  * @return string
  * @author Andy Bennett
  */
 public function navigation($n = 2, $level = 0, $xsl = "navigation")
 {
     $xsl_path = Kohana::find_file('xsl', $xsl, TRUE, 'xsl');
     // load the xml file and stylesheet as domdocuments
     $xsl = new DomDocument();
     $xsl->load($xsl_path);
     $inputdom = new DomDocument();
     $inputdom->loadXML($this->sitemap_string);
     // create the processor and import the stylesheet
     $proc = new XsltProcessor();
     $proc->importStyleSheet($xsl);
     $proc->setParameter("", 'base', substr(url::base(), 0, -1));
     $proc->setParameter("", 'currentpage', '/' . $this->current_page($n));
     $proc->setParameter("", 'pagename', $this->get_page_name());
     $proc->setParameter("", 'level', $level);
     $proc->registerPHPFunctions(array('sitemap_helper::check_acl', 'sitemap_helper::get_url', 'sitemap_helper::check_external'));
     // transform and output the xml document
     $newdom = $proc->transformToDoc($inputdom);
     $r = $newdom->saveXML($newdom->documentElement, LIBXML_NOEMPTYTAG);
     /*
     	$r = str_replace('<?xml version="1.0"?>', '', $r);
     	$r = str_replace('<ul/>', '', $r);
     */
     return $r;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:33,代码来源:Sitemap_Base.php

示例10: getUserBySearchvaluesXml

function getUserBySearchvaluesXml($emailSuche, $nameSuche, $ortSuche)
{
    $xsltProcessor = new XsltProcessor();
    $xsltProcessor->registerPHPFunctions();
    $UserImagePath = "http://" . $_SERVER['HTTP_HOST'] . substr(dirname($_SERVER['SCRIPT_NAME']), 1) . "/includes/pictures/generateBBThumb.inc.php?picname=" . "/pics/user/";
    $searchSql = "SELECT   u.id,\r\n                           u.Vorname,\r\n                           u.Nachname,\r\n                           u.Name,\r\n                           u.Geburtstag,\r\n                           u.Strasse,\r\n                           u.Plz,\r\n                           u.Ort,\r\n                           u.Email,\r\n                           u.User,\r\n                           u.Nation,\r\n                           u.Status,\r\n                           u.Signatur,\r\n                           u.Lastlogin,\r\n                           concat( '" . $UserImagePath . "', u.pic ) as pic,\r\n                           u.aktiv,\r\n                           (SELECT (now() - g.timeonupdate) as diffTme FROM  gpsPositions g WHERE g.user_id = u.id) as diffTime, \r\n                           if (exists (SELECT * FROM freundesliste f WHERE f.friend_id = u.id AND f.user_id = " . $_SESSION['config']->CURRENTUSER->USERID . "), 'J', 'N' ) as onFriendList\r\n                    FROM user u\r\n                    WHERE u.id != " . $_SESSION['config']->CURRENTUSER->USERID . "\r\n                    ";
    if ($emailSuche != null && strlen($emailSuche) > 1) {
        $searchSql .= " AND LOWER(u.email) = '" . strtolower($emailSuche) . "' ";
    }
    if ($nameSuche != null && strlen($nameSuche) > 1) {
        $searchSql .= " AND LOWER(u.name) = '" . strtolower($nameSuche) . "' ";
    }
    if ($ortSuche != null && strlen($ortSuche) > 1) {
        $searchSql .= " AND LOWER(u.ort) = '" . strtolower($ortSuche) . "' ";
    }
    //echo $searchSql;
    return getSqlResultAsXml($_SESSION['config']->DBCONNECT, $searchSql);
}
开发者ID:CyborgOne,项目名称:cybihomecontrol_ui,代码行数:18,代码来源:interface.php

示例11: applyLuceneXSLT

 /**
  * apply an xslt to lucene gsearch search results
  *
  * @param <type> $resultData
  * @param <type> $startPage
  * @param <type> $xslt_file
  * @param <type> $query the query that was executed.  May want to pass this on.
  */
 function applyLuceneXSLT($resultData, $startPage = 1, $xslt_file = '/xsl/results.xsl', $query = null)
 {
     $path = drupal_get_path('module', 'Fedora_Repository');
     $proc = null;
     if (!$resultData) {
         //drupal_set_message(t('No Results!'));
         return ' ';
         //no results
     }
     try {
         $proc = new XsltProcessor();
     } catch (Exception $e) {
         drupal_set_message(t('Error loading results xslt! ') . $e->getMessage());
         return ' ';
     }
     if (isset($query)) {
         $proc->setParameter('', 'fullQuery', $query);
     }
     //inject into xsl stylesheet
     global $user;
     $proc->setParameter('', 'userID', $user->uid);
     $proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search'));
     //token generated by Drupal, keeps tack of what tab etc we are on
     $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository');
     //needed in our xsl
     $proc->setParameter('', 'objectsPage', base_path());
     $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'demo: changeme:'));
     $proc->setParameter('', 'hitPageStart', $startPage);
     $proc->registerPHPFunctions();
     $xsl = new DomDocument();
     $test = $xsl->load($path . $xslt_file);
     if (!isset($test)) {
         drupal_set_message(t('Error loading search results xslt!'));
         return t('Error loading search results xslt! ');
     }
     $input = new DomDocument();
     $didLoadOk = $input->loadXML($resultData);
     if (!isset($didLoadOk)) {
         drupal_set_message(t('Error loading search results!'));
         return t('Error loading search results! ');
     } else {
         $proc->importStylesheet($xsl);
         $newdom = $proc->transformToDoc($input);
         return $newdom->saveXML();
     }
 }
开发者ID:ratzeni,项目名称:islandora,代码行数:54,代码来源:SearchClass.php

示例12: navigation

 /**
  * create navigation from the sitemap
  *
  * @param integer $n 
  * @param integer $level 
  * @return string
  * @author Andy Bennett
  */
 public function navigation($n = 2, $level = 0)
 {
     $xsl_path = Kohana::find_file('xsl', 'navigation', TRUE, 'xsl');
     /* load the xml file and stylesheet as domdocuments */
     $xsl = new DomDocument();
     $xsl->load($xsl_path);
     $inputdom = new DomDocument();
     $inputdom->loadXML($this->sitemap_string);
     /* create the processor and import the stylesheet */
     $proc = new XsltProcessor();
     $proc->importStyleSheet($xsl);
     $proc->setParameter("", 'base', substr(url::base(), 0, -1));
     $proc->setParameter("", 'currentpage', '/' . $this->current_page($n));
     $proc->setParameter("", 'level', $level);
     $proc->registerPHPFunctions(array('sitemap_helper::check_acl'));
     /* transform and output the xml document */
     $newdom = $proc->transformToDoc($inputdom);
     $r = $newdom->saveXML();
     $r = str_replace('<?xml version="1.0"?>', '', $r);
     $r = str_replace('<ul/>', '', $r);
     return $r;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:30,代码来源:Sitemap_Base.php

示例13: process

 public function process($xml = null, $xsl = null, array $parameters = array(), array $register_functions = array())
 {
     global $processErrors;
     $processErrors = array();
     if ($xml) {
         $this->_xml = $xml;
     }
     if ($xsl) {
         $this->_xsl = $xsl;
     }
     $xml = trim($xml);
     $xsl = trim($xsl);
     if (!self::isXSLTProcessorAvailable()) {
         return false;
     }
     //dont let process continue if no xsl functionality exists
     $arguments = array('/_xml' => $this->_xml, '/_xsl' => $this->_xsl);
     $XSLProc = new XsltProcessor();
     if (!empty($register_functions)) {
         $XSLProc->registerPHPFunctions($register_functions);
     }
     $result = @$this->__process($XSLProc, 'arg:/_xml', 'arg:/_xsl', null, $arguments, $parameters);
     while ($error = @array_shift($processErrors)) {
         $this->__error($error['number'], $error['message'], $error['type'], $error['line']);
     }
     unset($XSLProc);
     return $result;
 }
开发者ID:bauhouse,项目名称:sym-calendar,代码行数:28,代码来源:class.xsltprocess.php

示例14: parseContent

 /**
  * internal function
  * uses an xsl to parse the sparql xml returned from the ITQL query
  *
  *
  * @param $content String
  */
 function parseContent($content, $pid, $dsId, $collection, $pageNumber = null)
 {
     $path = drupal_get_path('module', 'Fedora_Repository');
     global $base_url;
     $collection_pid = $pid;
     //we will be changing the pid later maybe
     //module_load_include('php', ''Fedora_Repository'', 'ObjectHelper');
     $objectHelper = $this;
     $parsedContent = NULL;
     $contentModels = $objectHelper->get_content_models_list($pid);
     $isCollection = false;
     //if this is a collection object store the $pid in the session as it will come in handy
     //after a purge or ingest to return to the correct collection.
     if (!empty($contentModels)) {
         foreach ($contentModels as $contentModel) {
             if ($contentModel == 'epistemetec:albumCModel' || $contentModel == 'epistemetec:compilationCModel' || $contentModel == 'epistemetec:videotecaCModel' || $contentModel == 'epistemetec:collectionCModel') {
                 $_SESSION['fedora_collection'] = $pid;
                 $isCollection = true;
             }
         }
     }
     //get a list of datastream for this object
     $datastreams = $this->get_formatted_datastream_list($pid, $contentModels);
     //$label=$content;
     $collectionName = $collection;
     if (!$pageNumber) {
         $pageNumber = 1;
     }
     if (!isset($collectionName)) {
         $collectionName = variable_get('fedora_repository_name', 'Collection');
     }
     $xslContent = $this->getXslContent($pid, $path);
     //get collection list and display using xslt-------------------------------------------
     if (isset($content) && $content != false) {
         $input = new DomDocument();
         $input->loadXML(trim($content));
         $results = $input->getElementsByTagName('result');
         if ($results->length > 0) {
             try {
                 $proc = new XsltProcessor();
                 $proc->setParameter('', 'collectionPid', $collection_pid);
                 $proc->setParameter('', 'collectionTitle', $collectionName);
                 $proc->setParameter('', 'baseUrl', $base_url);
                 $proc->setParameter('', 'path', $base_url . '/' . $path);
                 $proc->setParameter('', 'hitPage', $pageNumber);
                 $proc->registerPHPFunctions();
                 $xsl = new DomDocument();
                 $xsl->loadXML($xslContent);
                 //php xsl does not seem to work with namespaces so removing it below
                 //I may have just been being stupid here
                 //         $content = str_ireplace('xmlns="http://www.w3.org/2001/sw/DataAccess/rf1/result"', '', $content);
                 $xsl = $proc->importStylesheet($xsl);
                 $newdom = $proc->transformToDoc($input);
                 $objectList = $newdom->saveXML();
                 //is the xml transformed to html as defined in the xslt associated with the collection object
                 if (!$objectList) {
                     throw new Exception("Invalid XML.");
                 }
             } catch (Exception $e) {
                 drupal_set_message(t($e->getMessage()), 'error');
                 return '';
             }
         }
     } else {
         drupal_set_message(t("No Objects in this Collection or bad query."));
     }
     //--------------------------------------------------------------------------------
     //show the collections datastreams
     if ($results->length > 0 || $isCollection == true) {
         //	if(strlen($objectList)>22||$contentModel=='Collection'||$contentModel=='Community'){//length of empty dom still equals 22 because of <table/> etc
         $collectionPolicyExists = $objectHelper->getMimeType($pid, 'COLLECTION_POLICY');
         //drupal_set_message($collectionPolicyExists, 'error');
         if (user_access(ObjectHelper::$INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) {
             if (!empty($collectionPolicyExists) && strcasecmp($collectionPolicyExists, 'application/zip')) {
                 $ingestObject = '<a title="' . t('Ingest a New object into ') . $collectionName . ' ' . $collection_pid . '" href="' . base_path() . 'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img hspace = "8" src="' . $base_url . '/' . $path . '/images/ingest.png" alt="' . t('Ingest Object') . '"></a>';
             }
         } else {
             $ingestObject = '&nbsp;';
         }
         $datastreams .= $ingestObject;
         $collection_fieldset = array('#title' => t('Collection Description'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#value' => $datastreams);
         $collectionListOut = theme('fieldset', $collection_fieldset);
         $object_list_fieldset = array('#title' => t('Items in this Collection'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#value' => isset($objectList) ? $objectList : '');
         $objectListOut = theme('fieldset', $object_list_fieldset);
     } else {
         //$collectionName='';
         $collection_fieldset = array('#title' => "", '#collapsible' => TRUE, '#collapsed' => FALSE, '#value' => $datastreams);
         $collectionListOut = theme('fieldset', $collection_fieldset);
         $objectListOut = '';
         //no collection objects to show so don't show field set
     }
     return "<STRONG>" . $collectionName . "</STRONG>" . ' <br />' . $collectionListOut . '<br />' . $objectListOut;
 }
开发者ID:ratzeni,项目名称:islandora,代码行数:100,代码来源:ObjectHelper.php


注:本文中的XsltProcessor::registerPHPFunctions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。