Commit f460fa2f authored by Carsten  Rose's avatar Carsten Rose
Browse files

Support.php: corrected phpDoc

Link.php: refactoring for implementing unittests
parent 4e45d751
......@@ -75,7 +75,7 @@ class Support {
*
* @param $type
* @param $value
* @param bool|false $flagOmitEmpty
* @param bool $flagOmitEmpty
* @return string
*/
public static function doAttribute($type, $value, $flagOmitEmpty = true) {
......
......@@ -64,12 +64,30 @@ require_once(__DIR__ . '/../store/Sip.php');
class Link {
private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $additionalUrlParams = "";
private $toolTip = array();
private $modeRender = 0, $picturePosition = "l", $modeHash = false, $encryption = 1;
private $linkClass = "", $defaultLinkClass = "";
private $linkClassSelector = array("i" => "internal", "e" => "external");
private $renderControl, $link = "";
private $mailto = "",
$url = "",
$image = "",
$text = "",
$altText = "",
$imageTitle = "",
$question = "",
$target = "",
$toolTip = ['', ''],
$additionalUrlParams = "",
$link = "";
private $modeRender = 0,
$picturePosition = "l",
$modeHash = false,
$renderControl,
$encryption = 1;
private $linkClass = "", // class name
$defaultLinkClass = "",
$linkClassSelector = array("i" => "internal", "e" => "external"),
$cssLinkClassInternal = '',
$cssLinkClassExternal = '';
//TODO: delete muss noch implementiert werden
private $delete = '';
......@@ -96,8 +114,6 @@ class Link {
*/
private $pageAlias = '';
private $cssLinkClassInternal = '';
private $cssLinkClassExternal = '';
/**
* __construct
......@@ -105,11 +121,10 @@ class Link {
* @param $fr_error
* @param Sip $sip
*/
public function __construct($fr_error, Sip $sip) {
public function __construct($fr_error, Sip $sip, $phpUnit = false) {
$this->fr_error = $fr_error;
$this->sip = $sip;
$this->store = Store::getInstance();
$this->toolTip = ['', ''];
$this->store = Store::getInstance('', $phpUnit);
$this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM);
$this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM);
$this->initRenderControl();
......@@ -196,7 +211,6 @@ class Link {
$this->doCssClass();
// $htmlUrl = $this->doUrl($count, $hash);
$htmlUrl = $this->doUrl();
$htmlImage = $this->doImage();
......@@ -446,7 +460,7 @@ class Link {
break;
}
$this->linkClass = ($class == '') ? '' : ' class="' . $this->linkClass . '"';
// $this->linkClass = ($class == '') ? '' : ' class="' . $this->linkClass . '"';
}
/**
......@@ -459,6 +473,7 @@ class Link {
* @throws SyntaxReportException
*/
private function doUrl() {
$tags = '';
// build URL
$htmlUrl = "";
......@@ -491,13 +506,14 @@ class Link {
}
}
// target
if ($this->target) $this->target = ' target="' . $this->target . '"';
// question
if ($this->question) $this->question = ' onclick="return confirm(\'' . $this->question . '\')"';
$tags .= Support::doAttribute('href', $this->url);
$tags .= Support::doAttribute('class', $this->linkClass);
$tags .= Support::doAttribute('target', $this->target);
if ($this->question) {
$tags .= Support::doAttribute('onclick', 'confirm(\'' . $this->question . '\')');
}
$htmlUrl = '<a href="' . $this->url . '"' . $this->linkClass . $this->target . $this->question . $this->toolTip[0] . '>';
$htmlUrl = '<a ' . $tags . $this->toolTip[0] . '>';
return ($htmlUrl);
}
......
......@@ -71,10 +71,13 @@ class Store {
*/
private static $sanitizeStore = array();
private static $phpUnit = false;
/**
* @param string $bodytext
*/
private function __construct($bodytext = '') {
private function __construct($bodytext = '', $phpUnit = false) {
self::$phpUnit = false;
self::$sanitizeClass = [
// TYPO3_DEBUG_LOAD => SANITIZE_ALLOW_DIGIT,
......@@ -351,7 +354,7 @@ class Store {
// Design Pattern: Singleton
if (self::$instance === null) {
self::$instance = new self($bodytext);
self::$instance = new self($bodytext, self::$phpUnit);
} else {
// Class Store seems to be presistent over multiple QFQ instantiation. Set bodytext again, with every new request (if bodytext is given).
if ($bodytext !== '')
......
......@@ -9,19 +9,38 @@
namespace qfq;
require_once(__DIR__ . '/../../qfq/report/Link.php');
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/store/Sip.php');
class LinkTest extends \PHPUnit_Framework_TestCase {
/**
* @var Sip
*/
private $sip = null;
/**
* @var Store
*/
private $store = null;
public function testLinkSingle() {
$link = new Link(null, null);
$link = new Link(null, $this->sip, true);
$result = $link->renderLink('u:http://math.uzh.ch');
$this->assertEquals($result, '<a href="http://math.uzh.ch" class=""> </a>');
$this->assertEquals($result, '<a href="http://math.uzh.ch" > </a>');
}
public function testLinkClass() {
}
protected function setUp() {
parent::setUp();
$this->store = Store::getInstance('', true);
$this->sip = new Sip('fakesessionname', true);
$this->sip->sipUniqId('badcaffee1234');
}
}
......@@ -5,7 +5,7 @@ namespace qfq;
//use qfq\Sip;
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/QuickFormQuery.php');
//require_once(__DIR__ . '/../../qfq/QuickFormQuery.php');
require_once(__DIR__ . '/../../qfq/store/Sip.php');
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment