• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP libxml_use_internal_errors函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中libxml_use_internal_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP libxml_use_internal_errors函数的具体用法?PHP libxml_use_internal_errors怎么用?PHP libxml_use_internal_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: request

 /**
  * @param string $url
  * @param string $method
  * @param string $body
  *
  * @return FhirResponse
  */
 public function request($url, $method = 'GET', $body = null)
 {
     $server_name = null;
     foreach ($this->servers as $name => $server) {
         if (substr($url, 0, strlen($server['base_url']))) {
             $server_name = $name;
             break;
         }
     }
     $this->applyServerConfig($server_name ? $this->servers[$server_name] : array());
     $this->http_client->setUri($url);
     $this->http_client->setMethod($method);
     if ($body) {
         $this->http_client->setRawData($body, 'application/xml+fhir; charset=utf-8');
     }
     $response = $this->http_client->request();
     $this->http_client->resetParameters();
     if ($body = $response->getBody()) {
         $use_errors = libxml_use_internal_errors(true);
         $value = Yii::app()->fhirMarshal->parseXml($body);
         $errors = libxml_get_errors();
         libxml_use_internal_errors($use_errors);
         if ($errors) {
             throw new Exception("Error parsing XML response from {$method} to {$url}: " . print_r($errors, true));
         }
     } else {
         $value = null;
     }
     return new FhirResponse($response->getStatus(), $value);
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:37,代码来源:FhirClient.php


示例2: setLaundryState

 public function setLaundryState(&$laundryPlace)
 {
     $user = 'youruser';
     $pass = 'yourpassword';
     try {
         $client = new Client($laundryPlace['url']);
         $request = $client->get('/LaundryState', [], ['auth' => [$user, $pass, 'Digest'], 'timeout' => 1.5, 'connect_timeout' => 1.5]);
         $response = $request->send();
         $body = $response->getBody();
         libxml_use_internal_errors(true);
         $crawler = new Crawler();
         $crawler->addContent($body);
         foreach ($crawler->filter('img') as $img) {
             $resource = $img->getAttribute('src');
             $img->setAttribute('src', 'http://129.241.126.11/' . trim($resource, '/'));
         }
         $crawler->addHtmlContent('<h1>foobar</h1>');
         //'<link href="http://129.241.126.11/pic/public_n.css" type="text/css">');
         $laundryPlace['html'] = $crawler->html();
         libxml_use_internal_errors(false);
         preg_match_all('/bgColor=Green/', $body, $greenMatches);
         preg_match_all('/bgColor=Red/', $body, $redMatches);
         $laundryPlace['busy'] = count($redMatches[0]);
         $laundryPlace['available'] = count($greenMatches[0]);
     } catch (\Exception $e) {
         $laundryPlace['available'] = self::NETWORK_ERROR;
         $laundryPlace['busy'] = self::NETWORK_ERROR;
         $laundryPlace['html'] = self::NETWORK_ERROR;
     }
 }
开发者ID:kcisek,项目名称:sit-washing,代码行数:30,代码来源:MieleService.php


示例3: load

 /**
  * Returns array of simple xml objects, where key is a handle name
  *
  * @return SimpleXmlElement[]
  * @throws RuntimeException in case of load error (malformed xml, etc)
  */
 public function load()
 {
     $this->validate();
     $original = libxml_use_internal_errors(true);
     $simpleXmlElement = simplexml_load_file($this->filePath);
     $errors = libxml_get_errors();
     libxml_clear_errors();
     libxml_use_internal_errors($original);
     if ($simpleXmlElement === false) {
         $messages = array();
         foreach ($errors as $error) {
             $messages[] = sprintf('%s, line %s, column %s', trim($error->message), $error->line, $error->column);
         }
         throw new RuntimeException(sprintf('File "%s" has a malformed xml structure: %s', $this->filePath, PHP_EOL . implode(PHP_EOL, $messages)));
     }
     $stringXml = array();
     // First convert all elements to string,
     // as in xml file can be multiple string with the same handle names
     foreach ($simpleXmlElement->children() as $key => $element) {
         if (!isset($stringXml[$key])) {
             $stringXml[$key] = '';
         }
         foreach ($element->children() as $child) {
             $stringXml[$key] .= $child->asXml();
         }
     }
     $result = array();
     foreach ($stringXml as $key => $xml) {
         $result[$key] = simplexml_load_string(sprintf('<%1$s>%2$s</%1$s>', $key, $xml));
     }
     return $result;
 }
开发者ID:albertobraschi,项目名称:EcomDev_LayoutCompiler,代码行数:38,代码来源:File.php


示例4: validateXml

 /**
  * Validate XML to be valid for import
  * @param string $xml
  * @param WP_Error[optional] $errors
  * @return bool Validation status
  */
 public static function validateXml(&$xml, $errors = NULL)
 {
     if (FALSE === $xml or '' == $xml) {
         $errors and $errors->add('form-validation', __('WP All Import can\'t read your file.<br/><br/>Probably, you are trying to import an invalid XML feed. Try opening the XML feed in a web browser (Google Chrome is recommended for opening XML files) to see if there is an error message.<br/>Alternatively, run the feed through a validator: http://validator.w3.org/<br/>99% of the time, the reason for this error is because your XML feed isn\'t valid.<br/>If you are 100% sure you are importing a valid XML feed, please contact WP All Import support.', 'wp_all_import_plugin'));
     } else {
         PMXI_Import_Record::preprocessXml($xml);
         if (function_exists('simplexml_load_string')) {
             libxml_use_internal_errors(true);
             libxml_clear_errors();
             $_x = @simplexml_load_string($xml);
             $xml_errors = libxml_get_errors();
             libxml_clear_errors();
             if ($xml_errors) {
                 $error_msg = '<strong>' . __('Invalid XML', 'wp_all_import_plugin') . '</strong><ul>';
                 foreach ($xml_errors as $error) {
                     $error_msg .= '<li>';
                     $error_msg .= __('Line', 'wp_all_import_plugin') . ' ' . $error->line . ', ';
                     $error_msg .= __('Column', 'wp_all_import_plugin') . ' ' . $error->column . ', ';
                     $error_msg .= __('Code', 'wp_all_import_plugin') . ' ' . $error->code . ': ';
                     $error_msg .= '<em>' . trim(esc_html($error->message)) . '</em>';
                     $error_msg .= '</li>';
                 }
                 $error_msg .= '</ul>';
                 $errors and $errors->add('form-validation', $error_msg);
             } else {
                 return true;
             }
         } else {
             $errors and $errors->add('form-validation', __('Required PHP components are missing.', 'wp_all_import_plugin'));
             $errors and $errors->add('form-validation', __('WP All Import requires the SimpleXML PHP module to be installed. This is a standard feature of PHP, and is necessary for WP All Import to read the files you are trying to import.<br/>Please contact your web hosting provider and ask them to install and activate the SimpleXML PHP module.', 'wp_all_import_plugin'));
         }
     }
     return false;
 }
开发者ID:k-hasan-19,项目名称:wp-all-import,代码行数:40,代码来源:record.php


示例5: validate

		public function validate($xml,$schema) {
			// Enable user error handling
			libxml_use_internal_errors(true);

			try {
				if(empty($xml)) {
					throw new Exception("You provided an empty XML string");
				}
				
				$doc = DOMDocument::loadXML($xml);
				if(!($doc instanceof DOMDocument)){
					$this->_errors = libxml_get_errors();
				}
	
				if(!@$doc->schemaValidate($schema)){
			        $this->_errors = libxml_get_errors();
				}
			} catch (Exception $e) {
				$this->_errors = array(0 => array('message'=>$e->getMessage()));
			}

			// Disable user error handling & Error Cleanup
			libxml_use_internal_errors(false);
			libxml_clear_errors();

			// If there are no errors, assume that it is all OK!
			return empty($this->_errors);
    	}
开发者ID:remie,项目名称:schemadevkit,代码行数:28,代码来源:SchemaValidator.php


示例6: layerslider_init

function layerslider_init($atts)
{
    // ID check
    if (empty($atts['id'])) {
        return '[LayerSliderWP] ' . __('Invalid shortcode', 'LayerSlider') . '';
    }
    // Get slider
    $slider = LS_Sliders::find($atts['id']);
    // Get slider if any
    if (!$slider || $slider['flag_deleted'] == '1') {
        return '[LayerSliderWP] ' . __('Slider not found', 'LayerSlider') . '';
    }
    // Slider and markup data
    $slides = $slider['data'];
    $id = $slider['id'];
    $data = '';
    // Include slider file
    if (is_array($slides)) {
        // Get phpQuery
        if (!class_exists('phpQuery')) {
            libxml_use_internal_errors(true);
            include LS_ROOT_PATH . '/helpers/phpQuery.php';
        }
        include LS_ROOT_PATH . '/config/defaults.php';
        include LS_ROOT_PATH . '/includes/slider_markup_init.php';
        include LS_ROOT_PATH . '/includes/slider_markup_html.php';
        $data = implode('', $data);
    }
    // Return data
    if (get_option('ls_concatenate_output', true)) {
        $data = trim(preg_replace('/\\s+/u', ' ', $data));
    }
    return $data;
}
开发者ID:ftopolovec,项目名称:proart,代码行数:34,代码来源:shortcodes.php


示例7: runTest

 public function runTest()
 {
     libxml_use_internal_errors(true);
     $xml = XMLReader::open(join(DIRECTORY_SEPARATOR, array($this->directory, $this->fileName)));
     $xml->setSchema(join(DIRECTORY_SEPARATOR, array($this->directory, $this->xsdFilename)));
     $this->logger->trace(__METHOD__);
     $this->logger->info('  XML file to test validity is ' . $this->fileName . 'using XSD file ' . $this->xsdFilename);
     // You have to parse the XML-file if you want it to be validated
     $currentReadCount = 1;
     $validationFailed = false;
     while ($xml->read() && $validationFailed == false) {
         // I want to break as soon as file is shown not to be valid
         // We could allow it to collect a few messages, but I think it's best
         // to do a manual check once we have discovered the file is not
         // correct. Speed is really what we want here!
         if ($currentReadCount++ % Constants::XML_PROCESSESING_CHECK_ERROR_COUNT == 0) {
             if (count(libxml_get_errors()) > 0) {
                 $validationFailed = true;
             }
         }
     }
     if (count(libxml_get_errors()) == 0) {
         $this->testProperty->addTestResult(true);
         $this->logger->info(' RESULT Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] succeeded');
         $this->testProperty->addTestResultDescription('Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] succeeded');
         $this->testProperty->addTestResultReportDescription('Filen ' . $this->fileName . ' validerer mot filen' . $this->xsdFilename);
     } else {
         $this->testProperty->addTestResult(false);
         $this->logger->error(' RESULT Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] failed');
         $this->testProperty->addTestResultDescription('Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] failed');
         $this->testProperty->addTestResultReportDescription('Filen ' . $this->fileName . ' validerer ikke mot filen' . $this->xsdFilename);
     }
     libxml_clear_errors();
 }
开发者ID:HaakonME,项目名称:noark5-validator,代码行数:34,代码来源:XMLTestValidation.php


示例8: validateXML

 /**
  * This function attempts to validate an XML string against the specified schema.
  *
  * It will parse the string into a DOM document and validate this document against the schema.
  *
  * @param string  $xml    The XML string or document which should be validated.
  * @param string  $schema The schema filename which should be used.
  * @param boolean $debug  To disable/enable the debug mode
  *
  * @return string | DOMDocument $dom  string that explains the problem or the DOMDocument
  */
 public static function validateXML($xml, $schema, $debug = false)
 {
     assert('is_string($xml) || $xml instanceof DOMDocument');
     assert('is_string($schema)');
     libxml_clear_errors();
     libxml_use_internal_errors(true);
     if ($xml instanceof DOMDocument) {
         $dom = $xml;
     } else {
         $dom = new DOMDocument();
         $dom = self::loadXML($dom, $xml);
         if (!$dom) {
             return 'unloaded_xml';
         }
     }
     $schemaFile = dirname(__FILE__) . '/schemas/' . $schema;
     $oldEntityLoader = libxml_disable_entity_loader(false);
     $res = $dom->schemaValidate($schemaFile);
     libxml_disable_entity_loader($oldEntityLoader);
     if (!$res) {
         $xmlErrors = libxml_get_errors();
         syslog(LOG_INFO, 'Error validating the metadata: ' . var_export($xmlErrors, true));
         if ($debug) {
             foreach ($xmlErrors as $error) {
                 echo $error->message . "\n";
             }
         }
         return 'invalid_xml';
     }
     return $dom;
 }
开发者ID:faxe-kommune,项目名称:OS2loop,代码行数:42,代码来源:Utils.php


示例9: __construct

 public function __construct()
 {
     $this->rssStream = null;
     $this->rss = null;
     //disable XML error
     libxml_use_internal_errors(true);
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:7,代码来源:rssnotifierservice.class.php


示例10: parse

 /**
  * private function that generalizes parsing
  * @param $string
  * @param null $names
  * @return array
  */
 private static function parse($string, $names = NULL)
 {
     $dom = new DOMDocument();
     libxml_use_internal_errors(true);
     $dom->loadHTML($string);
     $metas = $dom->getElementsByTagName('meta');
     $metaArray = array();
     if ($names == NULL) {
         foreach ($metas as $meta) {
             $nameKey = $meta->getAttribute('name');
             $contentValue = $meta->getAttribute('content');
             $metaArray["{$nameKey}"] = $contentValue;
         }
     } else {
         foreach ($names as $name) {
             foreach ($metas as $meta) {
                 if ($name === $meta->getAttribute('name')) {
                     $nameKey = $meta->getAttribute('name');
                     $contentValue = $meta->getAttribute('content');
                     $metaArray["{$nameKey}"] = $contentValue;
                 }
             }
         }
     }
     return $metaArray;
 }
开发者ID:isko-algorithm,项目名称:php-es-indexer,代码行数:32,代码来源:MetaParser.php


示例11: parse

 /**
  * Parse the given file for apprentices and mentors.
  *
  * @param string $file Path to the File to parse.
  *
  * @return array
  */
 public function parse($file)
 {
     $return = array('mentors' => array(), 'apprentices' => array());
     $content = file_Get_contents($file);
     $content = str_Replace('<local-time', '<span tag="local-time"', $content);
     $content = str_Replace('</local-time', '</span', $content);
     $content = str_Replace('<time', '<span tag="time"', $content);
     $content = str_Replace('</time', '</span', $content);
     $this->dom = new \DomDocument('1.0', 'UTF-8');
     $this->dom->strictErrorChecking = false;
     libxml_use_internal_errors(true);
     $this->dom->loadHTML('<?xml encoding="UTF-8" ?>' . $content);
     libxml_use_internal_errors(false);
     $xpathMentors = new \DOMXPath($this->dom);
     $mentors = $xpathMentors->query('//a[@id="user-content-mentors-currently-accepting-an-apprentice"]/../following-sibling::ul[1]/li');
     foreach ($mentors as $mentor) {
         $user = $this->parseUser($mentor);
         if (!$user) {
             continue;
         }
         $user['type'] = 'mentor';
         $return['mentors'][] = $user;
     }
     $xpathApprentices = new \DOMXPath($this->dom);
     $apprentices = $xpathApprentices->query('//a[@id="user-content-apprentices-currently-accepting-mentors"]/../following-sibling::ul[1]/li');
     foreach ($apprentices as $apprentice) {
         $user = $this->parseUser($apprentice);
         if (!$user) {
             continue;
         }
         $user['type'] = 'apprentice';
         $return['apprentices'][] = $user;
     }
     return $return;
 }
开发者ID:tsilvers,项目名称:php.ug,代码行数:42,代码来源:Mentoring.php


示例12: parseHtml

 function parseHtml()
 {
     //$this->_html = str_replace("<!DOCTYPE html>", "", $this->_html);
     /*
     $p = xml_parser_create();
     xml_parse_into_struct($p, $this->_html, $vals, $index);
     xml_parser_free($p);
     echo "Index array\n";
     pr($index);
     echo "\nVals array\n";
     pr($vals);
     die;
     */
     /*
     $this->_html = str_replace("<!DOCTYPE html>", "", $this->_html);
     $__data = new SimpleXMLElement($this->_html);
     pr($__data); die;
     */
     $dom = new DOMDocument();
     //echo htmlentities($this->_html); die;
     libxml_use_internal_errors(true);
     //$this->_html = str_replace("<!DOCTYPE html>", "", $this->_html);
     //$this->_html = str_replace("</h1>", "", $this->_html);
     //echo htmlentities($this->_html); die;
     //echo htmlentities($this->_html); die;
     $dom->loadHTML($this->_html);
     foreach ($dom->getElementsByTagName('img') as $node) {
         $array[] = $dom->saveHTML($node);
     }
     //pr($array);
     //die;
 }
开发者ID:str33thack3r,项目名称:wp01,代码行数:32,代码来源:find-html-issues.php


示例13: getXMLData

 public function getXMLData()
 {
     $prevVal = libxml_use_internal_errors(true);
     $data = new \SimpleXMLElement($this->request->getRawData());
     libxml_use_internal_errors($prevVal);
     return $data;
 }
开发者ID:tomaka17,项目名称:niysu,代码行数:7,代码来源:XMLInput.php


示例14: initialize

 /**
  * Reads the configuration file and creates the class attributes
  *
  */
 protected function initialize()
 {
     $reader = new XMLReader();
     $reader->open(parent::getConfigFilePath());
     $reader->setRelaxNGSchemaSource(self::WURFL_CONF_SCHEMA);
     libxml_use_internal_errors(TRUE);
     while ($reader->read()) {
         if (!$reader->isValid()) {
             throw new Exception(libxml_get_last_error()->message);
         }
         $name = $reader->name;
         switch ($reader->nodeType) {
             case XMLReader::ELEMENT:
                 $this->_handleStartElement($name);
                 break;
             case XMLReader::TEXT:
                 $this->_handleTextElement($reader->value);
                 break;
             case XMLReader::END_ELEMENT:
                 $this->_handleEndElement($name);
                 break;
         }
     }
     $reader->close();
     if (isset($this->cache["dir"])) {
         $this->logDir = $this->cache["dir"];
     }
 }
开发者ID:eusholli,项目名称:drupal,代码行数:32,代码来源:XmlConfig.php


示例15: __construct

 /**
  * Class constructor initialises the SimpleXML object and sets a few properties.
  * @param string $filepath Optional filespec for the XML file to use. Will use default otherwise.
  * @throws \Exception If the XML is invalid.
  */
 public function __construct($filepath = null)
 {
     if (empty($filepath)) {
         if (defined('nZEDb_VERSIONS')) {
             $filepath = nZEDb_VERSIONS;
         }
     }
     if (!file_exists($filepath)) {
         throw new \RuntimeException("Versions file '{$filepath}' does not exist!'");
     }
     $this->_filespec = $filepath;
     $this->out = new \ColorCLI();
     $this->git = new Git();
     $temp = libxml_use_internal_errors(true);
     $this->_xml = simplexml_load_file($filepath);
     libxml_use_internal_errors($temp);
     if ($this->_xml === false) {
         if (Utility::isCLI()) {
             $this->out->error("Your versions XML file ({nZEDb_VERSIONS}) is broken, try updating from git.");
         }
         throw new \Exception("Failed to open versions XML file '{$filepath}'");
     }
     if ($this->_xml->count() > 0) {
         $vers = $this->_xml->xpath('/nzedb/versions');
         if ($vers[0]->count() == 0) {
             $this->out->error("Your versions XML file ({nZEDb_VERSIONS}) does not contain version info, try updating from git.");
             throw new \Exception("Failed to find versions node in XML file '{$filepath}'");
         } else {
             $this->out->primary("Your versions XML file ({nZEDb_VERSIONS}) looks okay, continuing.");
             $this->_vers =& $this->_xml->versions;
         }
     } else {
         throw new \RuntimeException("No elements in file!\n");
     }
 }
开发者ID:Jay204,项目名称:nZEDb,代码行数:40,代码来源:Versions.php


示例16: testGravatar

 /**
  * @covers Robo47_View_Helper_Gravatar::Gravatar
  * @dataProvider gravatarProvider
  */
 public function testGravatar($email, $size, $rating, $default, $ssl, $separator, $params)
 {
     $view = new Zend_View();
     $view->setEncoding('utf-8');
     $view->Doctype(Zend_View_Helper_Doctype::XHTML1_STRICT);
     $service = new Robo47_Service_Gravatar();
     $helper = new Robo47_View_Helper_Gravatar($service);
     $helper->setView($view);
     $gravatarImageTag = $helper->Gravatar($email, $size, $rating, $default, $ssl, $separator, $params);
     $src = $service->getUri($email, $size, $rating, $default, $ssl, $separator);
     $alt = 'Gravatar ' . $service->getGravatarHash($email);
     libxml_use_internal_errors(true);
     $dom = new DOMDocument();
     $dom->loadHTML('<html><head><title></title></head><body>' . $gravatarImageTag . '</body></html>');
     libxml_use_internal_errors(false);
     $nodes = $dom->getElementsByTagName('img');
     $this->assertEquals(1, $nodes->length);
     $image = $nodes->item(0);
     $this->assertTrue($image->hasAttribute('src'), 'Image has no attribute "href"');
     $this->assertTrue($image->hasAttribute('alt'), 'Image has no alt');
     foreach ($params as $param => $value) {
         $this->assertTrue($image->hasAttribute($param), 'Image has no attribute "' . $param . '"');
         $this->assertEquals($value, $image->getAttribute($param), 'Image attribute "' . $param . '" has wrong value');
     }
     $srcAttribute = $image->getAttribute('src');
     $this->assertEquals($src, $srcAttribute, 'Image attribute "src" has wrong value');
     if (isset($params['alt'])) {
         $altAttribute = $image->getAttribute('alt');
         $this->assertEquals($params['alt'], $altAttribute, 'Image attribute "alt" has wrong value');
     } else {
         $altAttribute = $image->getAttribute('alt');
         $this->assertEquals($alt, $altAttribute, 'Image attribute "alt" has wrong value');
     }
 }
开发者ID:robo47,项目名称:robo47-components,代码行数:38,代码来源:GravatarTest.php


示例17: doLoad

 /**
  * @inheritdoc
  */
 protected function doLoad($file)
 {
     libxml_use_internal_errors(true);
     $xml = new \DOMDocument();
     $xml->load($file);
     if (!$xml->schemaValidate(__DIR__ . DIRECTORY_SEPARATOR . "XML" . DIRECTORY_SEPARATOR . "configuration.xsd")) {
         libxml_clear_errors();
         throw MigrationException::configurationNotValid('XML configuration did not pass the validation test.');
     }
     $xml = simplexml_load_file($file, "SimpleXMLElement", LIBXML_NOCDATA);
     $config = [];
     if (isset($xml->name)) {
         $config['name'] = (string) $xml->name;
     }
     if (isset($xml->table['name'])) {
         $config['table_name'] = (string) $xml->table['name'];
     }
     if (isset($xml->table['column'])) {
         $config['column_name'] = (string) $xml->table['column'];
     }
     if (isset($xml->{'migrations-namespace'})) {
         $config['migrations_namespace'] = (string) $xml->{'migrations-namespace'};
     }
     if (isset($xml->{'organize-migrations'})) {
         $config['organize_migrations'] = $xml->{'organize-migrations'};
     }
     if (isset($xml->{'migrations-directory'})) {
         $config['migrations_directory'] = $this->getDirectoryRelativeToFile($file, (string) $xml->{'migrations-directory'});
     }
     if (isset($xml->migrations->migration)) {
         $config['migrations'] = $xml->migrations->migration;
     }
     $this->setConfiguration($config);
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:37,代码来源:XmlConfiguration.php


示例18: transformAssetPaths

 /**
  * Transform asset paths based on the report
  *
  * @param $content
  * @return string
  * @throws ExtensionNotLoadedException
  */
 public function transformAssetPaths($content)
 {
     if (null === $content) {
         throw new ContentNotFoundException('No content was found to be rendered');
     }
     libxml_use_internal_errors(true);
     $doc = new \DOMDocument();
     $doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES'));
     $reportRouting = $this->extensionManager->findExtension('report_routing');
     if (null === $reportRouting) {
         throw new ExtensionNotLoadedException('report_routing');
     }
     /* Transform images */
     $images = $doc->getElementsByTagName('img');
     foreach ($images as $image) {
         $this->prepareAsset($image, 'src', $reportRouting);
     }
     /* Transform styles */
     $styles = $doc->getElementsByTagName('link');
     foreach ($styles as $style) {
         $this->prepareAsset($style, 'href', $reportRouting);
     }
     /* Transform scripts */
     $scripts = $doc->getElementsByTagName('script');
     foreach ($scripts as $script) {
         $this->prepareAsset($script, 'src', $reportRouting);
     }
     return $doc->saveHTML();
 }
开发者ID:angelog4,项目名称:sdk-php,代码行数:36,代码来源:RenderEngine.php


示例19: search

 function search($search, $language = 'en', $rpp = '10')
 {
     $return = array();
     $item = array();
     $feedUrl = "http://search.twitter.com/search.atom?q=" . urlencode($search) . "&lang={$language}&rpp={$rpp}";
     libxml_use_internal_errors(true);
     $sxml = simplexml_load_file($feedUrl);
     if ($sxml && !empty($sxml->entry)) {
         foreach ($sxml->entry as $node) {
             $attrs_0 = $node->link[0]->attributes();
             $attrs_1 = $node->link[1]->attributes();
             $datePublished = strtotime($node->published);
             $author = explode(' ', $node->author[0]->name);
             $content = htmlentities($node->content);
             $item["id"] = $attrs_0['href'];
             $item["published"] = date("Y-m-d H:i:s", $datePublished);
             $item["content"] = $node->title;
             $item["thumbnail"] = $attrs_1['href'];
             $item["title"] = $node->title;
             $item["author"] = $node->author[0]->name;
             $item["rating"] = calculateDatarowRating(formatTag($search), $node->title, $author[0]);
             $return[] = $item;
         }
     } else {
         $this->log('Unable to parse twitter XML.');
     }
     return $return;
 }
开发者ID:bskahan,项目名称:newd,代码行数:28,代码来源:twitter_source.php


示例20: strip

 /**
  * Strips blacklisted tags and attributes from content.
  *
  * See following for blacklist:
  *     https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#html-tags
  */
 public static function strip($content)
 {
     if (empty($content)) {
         return $content;
     }
     $blacklisted_tags = self::get_blacklisted_tags();
     $blacklisted_attributes = self::get_blacklisted_attributes();
     $blacklisted_protocols = self::get_blacklisted_protocols();
     $libxml_previous_state = libxml_use_internal_errors(true);
     $dom = new DOMDocument();
     // Wrap in dummy tags, since XML needs one parent node.
     // It also makes it easier to loop through nodes.
     // We can later use this to extract our nodes.
     $result = $dom->loadHTML('<html><body>' . $content . '</body></html>');
     libxml_clear_errors();
     libxml_use_internal_errors($libxml_previous_state);
     if (!$result) {
         return $content;
     }
     $body = $dom->getElementsByTagName('body')->item(0);
     self::strip_tags($body, $blacklisted_tags);
     self::strip_attributes_recursive($body, $blacklisted_attributes, $blacklisted_protocols);
     // Only want children of the body tag, since we have a subset of HTML.
     $out = '';
     foreach ($body->childNodes as $node) {
         $out .= $dom->saveXML($node);
     }
     return $out;
 }
开发者ID:Zaanmedia,项目名称:amp-wp,代码行数:35,代码来源:class-amp-sanitizer.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP license_form_el_advanced函数代码示例发布时间:2022-05-15
下一篇:
PHP libxml_set_streams_context函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap