本文整理汇总了PHP中Style::getStyleObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Style::getStyleObject方法的具体用法?PHP Style::getStyleObject怎么用?PHP Style::getStyleObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Style
的用法示例。
在下文中一共展示了Style::getStyleObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @name render
* @desc Turns the html array into a string ready to output
*/
public function render()
{
$html = '';
foreach ($this->nodes as $node) {
$storedHtml = '';
# Render Stored elements (if any)
$styleData = Style::getStyleObject($node->wordStyle, $this);
if (is_object($styleData)) {
if (isset($this->_passUnderStorage[$styleData->htmlClass])) {
if (isset($this->_passUnderStorage[$styleData->htmlClass][$this->_currentPassUnderKey])) {
$res = $this->_passUnderStorage[$styleData->htmlClass][$this->_currentPassUnderKey];
foreach ($res as $subhtml) {
$storedHtml .= $subhtml;
}
unset($this->_passUnderStorage[$styleData->htmlClass][$this->_currentPassUnderKey]);
}
}
}
# Case to remove empty <li>'s
$node->htmlProcess = str_replace(array("<li></li>", "<p></p>"), "", $node->htmlProcess);
$html .= $node->htmlProcess;
$html .= $storedHtml;
}
$this->html = $html;
}
示例2: parseNode
/**
* @name parseNode
* @desc Processes the node into php data or html
* @param boolean $isDirect (Defaults to FALSE)
*/
public function parseNode($isDirect = false)
{
$wordStyle = $this->findStyle($this->dom);
$styleInfo = Style::getStyleObject($wordStyle, $this->docx);
$this->wordStyle = $wordStyle;
# Only proceed for nodes that are children of the w:body tag OR this method was called within a container
if ($this->dom->parentNode->nodeName != 'w:body' && !$isDirect) {
return;
}
if (!$isDirect) {
$this->_tableId = null;
}
switch ($this->dom->nodeName) {
case 'w:p':
$isListItem = false;
$listLevel = 0;
$indent = null;
# Get the list level using the openXml format
$listQuery = $this->xPath->query("w:pPr/w:numPr/w:ilvl", $this->dom);
if ($listQuery->length > 0) {
$listLevel = (int) $listQuery->item(0)->getAttribute('w:val') + 1;
}
# If the style list info is NOT 0, then override the openXml iteration
if (is_object($styleInfo)) {
if ($styleInfo->listLevel > 0) {
$listLevel = $styleInfo->listLevel;
}
}
# Load hyperlink data (if any)
$hyperQuery = $this->xPath->query("w:hyperlink", $this->dom);
if ($hyperQuery->length > 0) {
$hyperlink = '';
$hyperNode = $hyperQuery->item(0);
foreach ($hyperNode->childNodes as $cn) {
if ($cn->nodeName == 'w:r') {
$hyperlink = $cn->nodeValue;
}
}
# If we have the raw hyperlink, parse it
if ($hyperlink != '') {
if (substr($hyperlink, 0, 4) != 'http') {
if (strpos($hyperlink, '@') !== false) {
$modHyperlink = 'mailto:' . $hyperlink;
} else {
$modHyperlink = 'http://' . $hyperlink;
}
} else {
$modHyperlink = $hyperlink;
}
$this->run[] = array('text' => '<a href="' . $modHyperlink . '">' . $hyperlink . '</a>', 'underline' => false, 'tab' => false, 'italic' => false, 'bold' => false);
}
}
# Join the different runs together
$textRun = $this->xPath->query("w:r", $this->dom);
$text = '';
foreach ($textRun as $run) {
$wrArray = $this->_parseWrNode($run);
$this->run[] = $wrArray;
}
# Get the indentation
$indentQuery = $this->xPath->query("w:pPr/w:ind", $this->dom);
if ($indentQuery->length > 0) {
$firstLineInd = $indentQuery->item(0)->getAttribute('w:firstLine');
$indent = (int) Docx::twipToPt($firstLineInd);
}
$this->indent = $indent;
$this->listLevel = $listLevel;
break;
case 'w:drawing':
$this->img = $this->loadDrawing($this->dom);
break;
case 'w:txbxContent':
break;
case 'w:tbl':
$this->_tableId = $this->id;
$this->createTableGrid($this->dom);
break;
}
}
示例3: parseNode
/**
* @name parseNode
* @desc Processes the node into php data or html
* @param boolean $isDirect (Defaults to FALSE)
*/
public function parseNode($isDirect = false)
{
$wordStyle = str_replace(' ', '', $this->findStyle($this->dom));
$styleInfo = Style::getStyleObject($wordStyle, $this->docx);
$this->wordStyle = $wordStyle;
# Only proceed for nodes that are children of the w:body tag OR this method was called within a container
if (!($this->dom->parentNode->nodeName == 'w:r' && $this->dom->nodeName == 'w:drawing')) {
if ($this->dom->parentNode->nodeName != 'w:body' && !$isDirect) {
return;
}
}
if (!$isDirect) {
$this->_tableId = null;
}
switch ($this->dom->nodeName) {
case 'w:p':
$isListItem = false;
$listLevel = 0;
$indent = null;
# Get the list level using the openXml format
$listQuery = $this->xPath->query("w:pPr/w:numPr/w:ilvl", $this->dom);
if ($listQuery->length > 0) {
$listLevel = (int) $listQuery->item(0)->getAttribute('w:val') + 1;
}
# If the style list info is NOT 0, then override the openXml iteration
if (is_object($styleInfo)) {
if ($styleInfo->listLevel > 0) {
$listLevel = $styleInfo->listLevel;
}
}
# Join the different runs together
$textRun = $this->xPath->query("w:r|w:hyperlink|w:br", $this->dom);
$text = '';
foreach ($textRun as $run) {
$wrArray = $this->_parseWrNode($run);
$this->run[] = $wrArray;
}
# Get the indentation
$indentQuery = $this->xPath->query("w:pPr/w:ind", $this->dom);
if ($indentQuery->length > 0) {
$firstLineInd = $indentQuery->item(0)->getAttribute('w:firstLine');
$indent = (int) Docx::twipToPt($firstLineInd);
}
$this->indent = $indent;
$this->listLevel = $listLevel;
break;
case 'w:drawing':
$this->img = $this->loadDrawing($this->dom);
break;
case 'w:txbxContent':
break;
case 'w:tbl':
$this->_tableId = $this->id;
$this->createTableGrid($this->dom);
break;
case 'w:footnote':
$id = intval($this->dom->getAttribute("w:id"));
if ($id < 1) {
return;
}
$idDone = false;
$textQuery = $this->xPath->query("w:p", $this->dom);
$realnode = null;
foreach ($textQuery as $textRes) {
$this->run[] = array('bold' => false, 'italic' => false, 'tab' => false, 'underline' => false, 'text' => !$idDone ? '[' . $id . ']' . $textRes->nodeValue . '<br/>' : $textRes->nodeValue);
$idDone = true;
}
break;
}
}