CODE STYLE class.toolBar.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 13:25:46 -04:00
parent 46a75b7867
commit eb8a057ac1

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.toolBar.php * class.toolBar.php
*
* @package workflow.engine.ProcessMaker * @package workflow.engine.ProcessMaker
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -26,6 +28,7 @@
/** /**
* ToolBar - ToolBar class * ToolBar - ToolBar class
*
* @package workflow.engine.ProcessMaker * @package workflow.engine.ProcessMaker
*/ */
class ToolBar extends form class ToolBar extends form
@@ -34,8 +37,9 @@ class ToolBar extends form
var $align = 'left'; var $align = 'left';
} }
/** /**
* XmlForm_Field_ToolBar - XmlForm_Field_ToolBar class * XmlForm_Field_ToolBar - XmlForm_Field_ToolBar class
*
* @package workflow.engine.ProcessMaker * @package workflow.engine.ProcessMaker
*/ */
class XmlForm_Field_ToolBar extends XmlForm_Field class XmlForm_Field_ToolBar extends XmlForm_Field
@@ -43,34 +47,36 @@ class XmlForm_Field_ToolBar extends XmlForm_Field
var $xmlfile = ''; var $xmlfile = '';
var $type = 'toolbar'; var $type = 'toolbar';
var $toolBar; var $toolBar;
var $home=''; var $home = '';
var $withoutLabel = true; var $withoutLabel = true;
/** /**
* Constructor of the class XmlForm_Field_ToolBar * Constructor of the class XmlForm_Field_ToolBar
*
* @param string $xmlNode * @param string $xmlNode
* @param string $lang * @param string $lang
* @param string $home * @param string $home
* @param string $owner * @param string $owner
* @return void * @return void
*/ */
function XmlForm_Field_ToolBar($xmlNode, $lang='en', $home='', $owner) function XmlForm_Field_ToolBar ($xmlNode, $lang = 'en', $home = '', $owner)
{ {
parent::XmlForm_Field($xmlNode, $lang, $home, $owner); parent::XmlForm_Field( $xmlNode, $lang, $home, $owner );
$this->home = $home; $this->home = $home;
} }
/** /**
* Prints the ToolBar * Prints the ToolBar
*
* @param string $value * @param string $value
* @return string * @return string
*/ */
function render( $value ) function render ($value)
{ {
$this->toolBar = new toolBar( $this->xmlfile , $this->home ); $this->toolBar = new toolBar( $this->xmlfile, $this->home );
$template = PATH_CORE . 'templates/' . $this->type . '.html'; $template = PATH_CORE . 'templates/' . $this->type . '.html';
$out = $this->toolBar->render( $template , $scriptCode ) ; $out = $this->toolBar->render( $template, $scriptCode );
$oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->addScriptFile( $this->toolBar->scriptURL ); $oHeadPublisher->addScriptFile( $this->toolBar->scriptURL );
$oHeadPublisher->addScriptCode( $scriptCode ); $oHeadPublisher->addScriptCode( $scriptCode );
return $out; return $out;
@@ -79,6 +85,7 @@ class XmlForm_Field_ToolBar extends XmlForm_Field
/** /**
* XmlForm_Field_toolButton - XmlForm_Field_toolButton class * XmlForm_Field_toolButton - XmlForm_Field_toolButton class
*
* @package workflow.engine.ProcessMaker * @package workflow.engine.ProcessMaker
*/ */
class XmlForm_Field_toolButton extends XmlForm_Field class XmlForm_Field_toolButton extends XmlForm_Field
@@ -98,77 +105,64 @@ class XmlForm_Field_toolButton extends XmlForm_Field
var $withoutLabel = false; var $withoutLabel = false;
var $buttonStyle = ''; var $buttonStyle = '';
/*$hoverMethod : back | switch*/ /*$hoverMethod : back | switch*/
var $hoverMethod='back'; var $hoverMethod = 'back';
var $class; var $class;
/** /**
* Prints the components of the toolBar * Prints the components of the toolBar
*
* @param string $value * @param string $value
* @return string * @return string
*/ */
function render( $value ) function render ($value)
{ {
$url = $this->file; $url = $this->file;
if ($this->home === "methods") if ($this->home === "methods")
$url = G::encryptlink( SYS_URI . $url ); $url = G::encryptlink( SYS_URI . $url );
if ($this->home === "public_html") if ($this->home === "public_html")
$url ='/' . $url ; $url = '/' . $url;
$urlAlt = $this->fileAlt; $urlAlt = $this->fileAlt;
if ($this->fileAlt!=='') { if ($this->fileAlt !== '') {
if ($this->home === "methods") if ($this->home === "methods")
$urlAlt = G::encryptlink( SYS_URI . $urlAlt ); $urlAlt = G::encryptlink( SYS_URI . $urlAlt );
if ($this->home === "public_html") if ($this->home === "public_html")
$urlAlt ='/' . $urlAlt ; $urlAlt = '/' . $urlAlt;
} }
$this->url=$url; $this->url = $url;
$this->urlAlt=$urlAlt; $this->urlAlt = $urlAlt;
switch($this->buttonType){ switch ($this->buttonType) {
case 'image': case 'image':
$html=''; $html = '';
if ($this->hoverMethod==='back') { if ($this->hoverMethod === 'back') {
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'. $html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . ' onmouseover=\'backImage(this,"url(' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . ') no-repeat")\' onmouseout=\'backImage(this,"")\' title=\'' . addslashes( $this->label ) . '\' />';
(($this->style)?' style="'.$this->style.'"':'').' onmouseover=\'backImage(this,"url('.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').') no-repeat")\' onmouseout=\'backImage(this,"")\' title=\'' . addslashes($this->label) . '\' />'; } elseif ($this->hoverMethod === 'switch') {
} $html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . ' onmouseover=\'switchImage(this,"' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '","' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . '")\' onmouseout=\'switchImage(this,"' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '","' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . '")\'/>';
elseif($this->hoverMethod==='switch'){ } else {
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'. $html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . '/>';
(($this->style)?' style="'.$this->style.'"':'').' onmouseover=\'switchImage(this,"'.htmlentities( $url, ENT_QUOTES, 'utf-8').'","'.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').'")\' onmouseout=\'switchImage(this,"'.htmlentities( $url, ENT_QUOTES, 'utf-8').'","'.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').'")\'/>';
}
else {
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'.
(($this->style)?' style="'.$this->style.'"':'').'/>';
} }
break; break;
case 'text': case 'text':
$html=$this->htmlentities($this->label, ENT_QUOTES,'utf-8'); $html = $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' );
break; break;
case 'html': case 'html':
$html='<div '. $html = '<div ' . ' onmouseover=\'backImage(this,"url(' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . ') no-repeat")\' onmouseout=\'backImage(this,"")\' style="width:25px;height:25px;margin-bottom:3px">' . $this->label . '</div>';
' onmouseover=\'backImage(this,"url('.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').') no-repeat")\' onmouseout=\'backImage(this,"")\' style="width:25px;height:25px;margin-bottom:3px">'.
$this->label.'</div>';
//$html=$this->label; //$html=$this->label;
break; break;
case 'image/text': case 'image/text':
$html='<img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'. $html = '<img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . '/><br/>' . $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' );
(($this->style)?' style="'.$this->style.'"':'').'/><br/>'.
$this->htmlentities($this->label, ENT_QUOTES,'utf-8');
break; break;
case 'text/image': case 'text/image':
$html=$this->htmlentities($this->label, ENT_QUOTES,'utf-8'). $html = $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' ) . '<br/><img src="' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '"' . (($this->style) ? ' style="' . $this->style . '"' : '') . '/>';
'<br/><img src="'.htmlentities( $url, ENT_QUOTES, 'utf-8').'"'.
(($this->style)?' style="'.$this->style.'"':'').'/>';
break; break;
case 'class': case 'class':
$html='<a href="#" onclick="'. $this->onclick.'" onmouseover="backImage(this, \'url(/images/dynamicForm/hover.gif) no-repeat\')" onmouseout="backImage(this, \'\')" style="width:25px;height:25px;margin-bottom:3px"> $html = '<a href="#" onclick="' . $this->onclick . '" onmouseover="backImage(this, \'url(/images/dynamicForm/hover.gif) no-repeat\')" onmouseout="backImage(this, \'\')" style="width:25px;height:25px;margin-bottom:3px">
<div class="'.$this->class.'" title="'.strip_tags($this->label).'" style="width:25px;height:25px;margin-bottom:3px"></div> <div class="' . $this->class . '" title="' . strip_tags( $this->label ) . '" style="width:25px;height:25px;margin-bottom:3px"></div>
</a>'; </a>';
return $html; return $html;
} }
return '<a class="toolButton" '. return '<a class="toolButton" ' . (($this->buttonStyle) ? ' style="' . $this->buttonStyle . '"' : '') . (($this->onclick) ? ' onclick="' . htmlentities( $this->onclick, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>' . $html . '</a>';
(($this->buttonStyle)?' style="'.$this->buttonStyle.'"':'').
(($this->onclick)?' onclick="'. htmlentities($this->onclick, ENT_QUOTES,'utf-8').'"':'').
'>'.$html.'</a>';
} }
} }
?> ?>