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


PHP tidy::body方法代码示例

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


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

示例1: createContentElements

 protected function createContentElements(&$objItem)
 {
     if ($objItem->tl_content) {
         // need to wrap <p> around text for contao
         $tidyConfig = array('enclose-text' => true, 'drop-font-tags' => true, 'drop-proprietary-attributes' => true, 'quote-ampersand' => true, 'clean' => false);
         $bodyText = '<!DOCTYPE html><head><title></title></head><body>' . $objItem->tl_content . '</body></html>';
         //			$bodyText = $this->convert_external_link_tags($bodyText);
         //			$bodyText = $this->convert_internal_link_tags($bodyText);
         $bodyText = $this->nl2p($bodyText);
         $tidy = new \tidy();
         $tidy->parseString($bodyText, $tidyConfig, $GLOBALS['TL_CONFIG']['dbCharset']);
         $body = $tidy->body();
         $objContent = new \ContentModel();
         $objContent->text = trim(str_replace(array('<body>', '</body>'), '', $body));
         $objContent->text = preg_replace("/<img[^>]+\\>/i", "", $objContent->text);
         // strip images
         // create links from text
         $objContent->text = preg_replace('!(\\s|^)((https?://|www\\.)+[a-z0-9_./?=&-]+)!i', ' <a href="http://$2" target="_blank">$2</a>', $objContent->text);
         // replace <b> by <strong>
         $objContent->text = preg_replace('!<b(.*?)>(.*?)</b>!i', '<strong>$2</strong>', $objContent->text);
         // replace emails with inserttags
         $objContent->text = preg_replace('/([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
         // strip not allowed tags
         $objContent->text = strip_tags($objContent->text, \Config::get('allowedTags'));
         $objContent->text = $this->stripAttributes($objContent->text, array('style', 'class', 'id'));
         $objContent->ptable = static::$strTable;
         $objContent->pid = $objItem->id;
         $objContent->sorting = 16;
         $objContent->tstamp = time();
         $objContent->type = 'text';
         $objContent->save();
     }
 }
开发者ID:heimrichhannot,项目名称:contao-newsport,代码行数:33,代码来源:NewsImporter.php

示例2: toPlainText

 /**
  * @return string
  */
 public function toPlainText(Io_Charset $outputCharset_ = null)
 {
     if (null === $outputCharset_) {
         $outputCharset_ = $this->m_charset;
     }
     $html = html_entity_decode($this->m_value, ENT_QUOTES, $this->m_charset->name());
     $tidy = new \tidy();
     $tidy->parseString($html, ['char-encoding' => $this->m_charset->name(), 'input-encoding' => $this->m_charset->name(), 'output-encoding' => $outputCharset_->name()]);
     $string = '';
     $this->nodeToPlainText($tidy->body(), $string);
     return $string;
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.text,代码行数:15,代码来源:html.php

示例3: createContentElements

 protected function createContentElements(&$objItem)
 {
     if ($objItem->tl_content) {
         // need to wrap <p> around text for contao
         $tidyConfig = array('enclose-text' => true, 'drop-font-tags' => true, 'drop-proprietary-attributes' => true, 'quote-ampersand' => true, 'clean' => false, 'wrap-attributes' => false, 'wrap' => 500);
         $bodyText = '<!DOCTYPE html><head><title></title></head><body>' . $objItem->tl_content . '</body></html>';
         //			$bodyText = $this->convert_external_link_tags($bodyText);
         //			$bodyText = $this->convert_internal_link_tags($bodyText);
         $bodyText = $this->nl2p($bodyText);
         $tidy = new \tidy();
         $tidy->parseString($bodyText, $tidyConfig, $GLOBALS['TL_CONFIG']['dbCharset']);
         $body = $tidy->body();
         $objContent = new \ContentModel();
         $objContent->text = urldecode($objContent->text);
         // decode, otherwise link and email regex wont work
         $objContent->text = trim(str_replace(array('<body>', '</body>'), '', $body));
         $objContent->text = preg_replace("/<img[^>]+\\>/i", "", $objContent->text);
         // strip images
         // remove inline styles
         $objContent->text = preg_replace('#(<[a-z ]*)(style=("|\')(.*?)("|\'))([a-z ]*>)#', '\\1\\6', $objContent->text);
         // remove white space from empty tags
         $objContent->text = preg_replace('#(<[a-z]*)(\\s+)>#', '$1>', $objContent->text);
         // create links from text
         $objContent->text = preg_replace('!(\\s|^)((https?://|www\\.)+[a-z0-9_./?=&-]+)!i', ' <a href="http://$2" target="_blank">$2</a>', $objContent->text);
         // replace <b> by <strong>
         $objContent->text = preg_replace('!<b(.*?)>(.*?)</b>!i', '<strong>$2</strong>', $objContent->text);
         // replace plain email text with inserttags
         $objContent->text = preg_replace('/([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?(?![^<]*>)(?![^>]*<)/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
         // replace email links with inserttags
         $objContent->text = preg_replace('/<a.*href=[\'|"]mailto:([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?[\'|"].*>(.*)<\\/a>/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
         // strip not allowed tags
         $objContent->text = strip_tags($objContent->text, \Config::get('allowedTags'));
         $objContent->text = $this->stripAttributes($objContent->text, array('style', 'class', 'id'));
         $objContent->ptable = $this->dbTargetTable;
         $objContent->pid = $objItem->id;
         $objContent->sorting = 16;
         $objContent->tstamp = time();
         $objContent->type = 'text';
         $objContent->save();
     }
 }
开发者ID:heimrichhannot,项目名称:contao-entity_import,代码行数:41,代码来源:NewsImporter.php

示例4: array

<?php

header("Content-type: application/xml");
if (isset($_REQUEST['x'])) {
    echo file_get_contents("../../{$_REQUEST['x']}");
    exit;
}
$html = str_replace("></", "><!--c--></", $GLOBALS["HTTP_RAW_POST_DATA"]);
$config = array("indent" => false, "output-xhtml" => true, "wrap" => 200);
$tidy = new tidy();
$tidy->parseString($html, $config, "utf8");
$tidy->cleanRepair();
echo $tidy->body()->child[0]->value;
开发者ID:hynekmusil,项目名称:hr-help,代码行数:13,代码来源:xml.php

示例5: dirname

<?php

//encoding=utf-8
header("Content-type: application/xml");
$html = $GLOBALS["HTTP_RAW_POST_DATA"];
$dataURI = $_REQUEST["dataURI"];
$dir = dirname(__FILE__);
$baseDir = substr($dir, 0, strpos($dir, "component"));
$config = array("indent" => false, "output-xhtml" => true, "wrap" => 200);
$tidy = new tidy();
$tidy->parseString($html, $config, "utf8");
$tidy->cleanRepair();
$content = str_replace("&nbsp;", "&#160;", $tidy->body()->child[0]->value);
$content = "<div xmlns=\"http://www.w3.org/1999/xhtml\"" . substr($content, 4);
$contentDoc = new DOMDocument("1.0", "UTF-8");
$contentDoc->loadXML($content);
$xslDoc = new DOMDocument();
$xslDoc->load("setter-header.xsl");
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xslDoc);
$result = $xslt->transformToXML($contentDoc);
print $result;
$fp = fopen($baseDir . $dataURI, "w");
fwrite($fp, $result);
fclose($fp);
开发者ID:hynekmusil,项目名称:hr-help,代码行数:25,代码来源:setter-header.php

示例6: dirname

<?php

//encoding=utf-8
header("Content-type: application/xml");
$html = $GLOBALS["HTTP_RAW_POST_DATA"];
$dataURI = $_REQUEST["dataURI"];
$dir = dirname(__FILE__);
$baseDir = substr($dir, 0, strpos($dir, "component"));
$config = array("indent" => false, "output-xhtml" => true, "wrap" => 200);
$tidy = new tidy();
$tidy->parseString($html, $config, "utf8");
$tidy->cleanRepair();
$xmlDoc = new DOMDocument("1.0", "utf-8");
$xmlDoc->loadXML(str_replace("&nbsp;", "&#160;", $tidy->body()->child[0]->value));
$xslt = new XSLTProcessor();
$xslDoc = new DOMDocument();
$xslDoc->load('setter-article.xsl');
$xslt->importStylesheet($xslDoc);
$result = $xslt->transformToXML($xmlDoc);
print $result;
$fp = fopen($baseDir . $dataURI, "w");
fwrite($fp, $result);
fclose($fp);
开发者ID:hynekmusil,项目名称:hr-help,代码行数:23,代码来源:setter-article.php


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