* add support of the table border.

This commit is contained in:
wangchunsheng
2012-12-02 03:15:12 +00:00
parent 787e16d810
commit f86e04590d
3 changed files with 39 additions and 0 deletions
+1
View File
@@ -396,6 +396,7 @@ class doc extends control
$this->view->actions = $this->loadModel('action')->getList('doc', $docID);
$this->view->users = $this->user->getPairs('noclosed,nodeleted,noletter');
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('doc', $docID);
$this->view->keTableCSS = $this->doc->extractKETableCSS($doc->content);
$this->display();
}
+37
View File
@@ -279,4 +279,41 @@ class docModel extends model
{
return $this->dao->findByType('projectdoc')->from(TABLE_MODULE)->andWhere('type')->eq('projectdoc')->fetchPairs('id', 'name');
}
/**
* Extract css styles for tables created in kindeditor.
*
* Like this: <table class="ke-table1" style="width:100%;" cellpadding="2" cellspacing="0" border="1" bordercolor="#000000">
*
* @param string $content
* @access public
* @return void
*/
public function extractKETableCSS($content)
{
$css = '';
$rule = '/<table class="ke(.*)" .*/';
if(preg_match_all($rule, $content, $results))
{
foreach($results[0] as $tableLine)
{
$attributes = explode(' ', str_replace('"', '', $tableLine));
foreach($attributes as $attribute)
{
if(strpos($attribute, '=') === false) continue;
list($attributeName, $attributeValue) = explode('=', $attribute);
$$attributeName = $attributeValue;
}
if(!isset($class)) continue;
$className = $class;
$borderSize = isset($border) ? $border . 'px' : '1px';
$borderColor = isset($bordercolor) ? $bordercolor : 'gray';
$borderStyle = "{border:$borderSize $borderColor solid}\n";
$css .= ".$className$borderStyle";
$css .= ".$className td$borderStyle";
}
}
return $css;
}
}
+1
View File
@@ -11,6 +11,7 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php echo css::internal($keTableCSS);?>
<div id='titlebar'>
<div id='main' <?php if($doc->deleted) echo "class='deleted'";?>>DOC #<?php echo $doc->id . ' ' . $doc->title;?></div>
<div>