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

Define: Adjusted iconf path to extension QFQ

Link: implemented creation of SIP for links. Remove the old 'hash' implementation.
Constants:
parent f0550b6e
......@@ -58,7 +58,7 @@ define("DFLT_UPLOAD_BASE_DIR", "fileadmin");
define("DFLT_UPLOAD_TMP_DIR", "fileadmin/tempfiles");
define("DFLT_UPLOAD_TMP_TTL", "300");
define("PATH_ICONS", "typo3conf/ext/" . FORMREPORT . "/icons/");
define("PATH_ICONS", "typo3conf/ext/qfq/Resources/Public/icons/");
// Definitions to allow successfull include of ext_localconf.
//define( 'TYPO3_MODE', '1' );
//define( 'FORMREPORT', '1' );
......@@ -57,21 +57,18 @@ require_once(__DIR__ . '/../store/Sip.php');
* C:checkbox [name]
* R:right
* h:hash
* f:formname
* i:recordId
* T:tablename
*
*
* A: A:[u:p:m]
* G: G:[N|..]
*/
class Link {
private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $formName = "", $additionalUrlParams = "";
private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = false, $recordId = -1, $encryption = 1;
private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $additionalUrlParams = "";
private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = false, $encryption = 1;
private $linkClass = "", $defaultLinkClass = "";
private $linkClassSelector = array("i" => "internal", "e" => "external");
private $renderControl, $link = "", $tableName = "";
private $renderControl, $link = "";
/**
* @var Sip
......@@ -121,7 +118,7 @@ class Link {
$this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM);
$this->initRenderControl();
} // __construct
}
/**
* Initializes RenderControl Array
......@@ -175,7 +172,7 @@ class Link {
$this->renderControl[5][0][1] = 0;
$this->renderControl[5][1][0] = 0;
$this->renderControl[5][1][1] = 0;
} // initRenderControl()
}
/**
* Build the whole link
......@@ -198,7 +195,7 @@ class Link {
}
// if there is no url or mailto definition: ~global.pageId
if (!$this->url && !$this->mailto) $this->url = "?" . $GLOBALS["TSFE"]->id;
if (!$this->url && !$this->mailto) $this->url = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
$this->doCssClass();
......@@ -282,7 +279,7 @@ class Link {
return $this->link;
} // buildHash()
}
/**
* Parse Item of link string, fill class global variables.
......@@ -293,8 +290,6 @@ class Link {
*/
private function parseItem($key, $value) {
$_EXTKEY = FORMREPORT;
switch ($key) {
// URL
case "u":
......@@ -309,7 +304,7 @@ class Link {
break;
case "p":
if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->pageAlias = $value ? $value : $GLOBALS["TSFE"]->id; // If no pageid|pagealias ist defined, take current page
$this->pageAlias = $value ? $value : $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); // If no pageid|pagealias is defined, take current page
$this->url = "?" . $this->pageAlias;
$this->defaultLinkClass = $this->cssLinkClassInternal;
break;
......@@ -408,29 +403,13 @@ class Link {
if ($this->modeHash) throw new SyntaxReportException ("Multiple modeHash defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->modeHash = TRUE;
break;
case "f":
if ($this->formName) throw new SyntaxReportException ("Multiple formName defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->formName = $value;
break;
case "U": //if($this->additionalUrlParams) throw new syntaxException ( "Multiple additionalUrlParams defined: '$key'","",__FILE__,__LINE__, "Column: " . $fthis->r_error["columnIndex"], $this->fr_error);
//$this->additionalUrlParams = $value;
// Save url params as array!
$param = explode('=', $value);
$this->additionalUrlParams[$param[0]] = $param[1];
break;
case "i":
if ($this->recordId != -1) throw new SyntaxReportException ("Multiple recordId defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->recordId = $value;
$this->additionalUrlParams = $value;
break;
case "R":
if ($this->picturePosition != "l") throw new SyntaxReportException ("Multiple picturePosition defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->picturePosition = "r";
break;
case "T":
if ($this->tableName) throw new SyntaxReportException ("Multiple tableName defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->tableName = $value;
break;
// A,G
case "G":
......@@ -445,7 +424,7 @@ class Link {
}
} // splitAndAddDelimter()
}
/**
* Parse CSS Class Settings
......@@ -467,80 +446,60 @@ class Link {
} else {
$this->linkClass = "";
}
} // encryptMailtoJS()
}
/**
* Build URL
* Builds complete HTML anchor.
* - <a href="mailto:info@example.com:>info@example.com</a>
* - <a href="http://example.com:>http://example.com</a>
* - If $this->modeHash is set, create a
*
* @param int $count Row count of current query. $count=1 means 'generate new hash values', everything else means 'take existing hash values'.
* @param string $hash RC for hash if count=1, else 'hash' to use.
* @return string
* @throws SyntaxReportException
*/
private function doUrl($count, &$hash) {
private function doUrl() {
// build URL
$htmlUrl = "";
// If there is no encryption: handle the mailto as an ordinary URL
if ($this->mailto && $this->encryption == 0) {
$this->url = "mailto:" . $this->mailto;
$this->mailto = "";
}
if ($this->url) {
$param = array();
if ($this->modeHash) {
$param[] = $this->buildHash($count, $hash);
} else {
if ($this->formName) $param[] = URL_FORMNAME . '=' . $this->formName;
if ($this->recordId != -1) $param[] = URL_RECORD_ID . '=' . $this->recordId;
if ($this->additionalUrlParam) $param[] = $this->additionalUrlParams;
}
if ($param) {
// Append '&' or '?' depending if there is already a '?'
$this->url .= (strpos($this->url, '?') >= 0) ? '&' : '?';
// Append all additional params.
$this->url .= implode('&', $param);
}
// target
if ($this->target) $this->target = ' target="' . $this->target . '"';
$this->url = $this->sip->queryStringToSip($this->additionalUrlParams);
// question
if ($this->question) $this->question = ' onclick="return confirm(\'' . $this->question . '\')"';
} else {
$htmlUrl = '<a href="' . $this->url . '"' . $this->linkClass . $this->target . $this->question . $this->toolTip[0] . '>';
if ($this->additionalUrlParams) {
// Append '&' or '?' depending if there is already a '?'
$this->url .= (strpos($this->url, '?') >= 0) ? '&' : '?';
// Append all additional params.
$this->url .= $this->additionalUrlParams;
}
}
}
return ($htmlUrl);
} // doCssClass()
/**
* Build the URL and/or Hash
*
* @param $count
* @param $hash
* @return string The complete Link
*/
private function buildHash($count, &$hash) {
if ($count == 1) {
$hash = $this->utils->randomAlphaNumUnique();
// If there is no encryption: handle the mailto as an ordinary URL
if ($this->mailto) {
$_SESSION[FORMREPORT][$hash]['formName'][0] = $this->formName;
$_SESSION[FORMREPORT][$hash]['referrer'] = $_SERVER['REQUEST_URI'];
// Delete Links: tablename mandatory
if ($this->tableName) {
$_SESSION[FORMREPORT][$hash]['tableName'] = $this->tableName;
$_SESSION[FORMREPORT][$hash]['dbAlias'] = $this->dbAlias;
if ($this->encryption == 0) {
$this->url = "mailto:" . $this->mailto;
$this->mailto = "";
} else {
throw new SyntaxReportException ("Oops, sorry: encrypted mail not implemented ...", "", __FILE__, __LINE__,
"Column: " . $this->fr_error["columnIndex"], $this->fr_error);
}
}
$_SESSION[FORMREPORT][$hash]['idMap'][$count]['recordId'] = $this->recordId;
$_SESSION[FORMREPORT][$hash]['idMap'][$count]['param'] = $this->additionalUrlParams;
// target
if ($this->target) $this->target = ' target="' . $this->target . '"';
return (URL_HASH . '=' . $hash . '&' . URL_RECORD_ID . '=' . $count);
} // doUrl()
// question
if ($this->question) $this->question = ' onclick="return confirm(\'' . $this->question . '\')"';
$htmlUrl = '<a href="' . $this->url . '"' . $this->linkClass . $this->target . $this->question . $this->toolTip[0] . '>';
return ($htmlUrl);
}
/**
* Create Image HTML Tag
......@@ -564,7 +523,7 @@ class Link {
}
return ($htmlImage);
} // doImage()
}
/**
* Encrypt the mailto address via JS.
......@@ -628,7 +587,7 @@ class Link {
if ($href) $tt .= $this->toolTip[1];
return ($tt);
} //renderLink()
}
/**
* Split a string around the $delimiter.
......@@ -652,5 +611,5 @@ class Link {
$arr[$key] = $value;
return ($arr);
} // parseItem
}
}
\ No newline at end of file
Markdown is supported
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