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"); ...@@ -58,7 +58,7 @@ define("DFLT_UPLOAD_BASE_DIR", "fileadmin");
define("DFLT_UPLOAD_TMP_DIR", "fileadmin/tempfiles"); define("DFLT_UPLOAD_TMP_DIR", "fileadmin/tempfiles");
define("DFLT_UPLOAD_TMP_TTL", "300"); 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. // Definitions to allow successfull include of ext_localconf.
//define( 'TYPO3_MODE', '1' ); //define( 'TYPO3_MODE', '1' );
//define( 'FORMREPORT', '1' ); //define( 'FORMREPORT', '1' );
...@@ -57,9 +57,6 @@ require_once(__DIR__ . '/../store/Sip.php'); ...@@ -57,9 +57,6 @@ require_once(__DIR__ . '/../store/Sip.php');
* C:checkbox [name] * C:checkbox [name]
* R:right * R:right
* h:hash * h:hash
* f:formname
* i:recordId
* T:tablename
* *
* A: A:[u:p:m] * A: A:[u:p:m]
* G: G:[N|..] * G: G:[N|..]
...@@ -67,11 +64,11 @@ require_once(__DIR__ . '/../store/Sip.php'); ...@@ -67,11 +64,11 @@ require_once(__DIR__ . '/../store/Sip.php');
class Link { class Link {
private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $formName = "", $additionalUrlParams = ""; private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $additionalUrlParams = "";
private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = false, $recordId = -1, $encryption = 1; private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = false, $encryption = 1;
private $linkClass = "", $defaultLinkClass = ""; private $linkClass = "", $defaultLinkClass = "";
private $linkClassSelector = array("i" => "internal", "e" => "external"); private $linkClassSelector = array("i" => "internal", "e" => "external");
private $renderControl, $link = "", $tableName = ""; private $renderControl, $link = "";
/** /**
* @var Sip * @var Sip
...@@ -121,7 +118,7 @@ class Link { ...@@ -121,7 +118,7 @@ class Link {
$this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM); $this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM);
$this->initRenderControl(); $this->initRenderControl();
} // __construct }
/** /**
* Initializes RenderControl Array * Initializes RenderControl Array
...@@ -175,7 +172,7 @@ class Link { ...@@ -175,7 +172,7 @@ class Link {
$this->renderControl[5][0][1] = 0; $this->renderControl[5][0][1] = 0;
$this->renderControl[5][1][0] = 0; $this->renderControl[5][1][0] = 0;
$this->renderControl[5][1][1] = 0; $this->renderControl[5][1][1] = 0;
} // initRenderControl() }
/** /**
* Build the whole link * Build the whole link
...@@ -198,7 +195,7 @@ class Link { ...@@ -198,7 +195,7 @@ class Link {
} }
// if there is no url or mailto definition: ~global.pageId // 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(); $this->doCssClass();
...@@ -282,7 +279,7 @@ class Link { ...@@ -282,7 +279,7 @@ class Link {
return $this->link; return $this->link;
} // buildHash() }
/** /**
* Parse Item of link string, fill class global variables. * Parse Item of link string, fill class global variables.
...@@ -293,8 +290,6 @@ class Link { ...@@ -293,8 +290,6 @@ class Link {
*/ */
private function parseItem($key, $value) { private function parseItem($key, $value) {
$_EXTKEY = FORMREPORT;
switch ($key) { switch ($key) {
// URL // URL
case "u": case "u":
...@@ -309,7 +304,7 @@ class Link { ...@@ -309,7 +304,7 @@ class Link {
break; break;
case "p": 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); 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->url = "?" . $this->pageAlias;
$this->defaultLinkClass = $this->cssLinkClassInternal; $this->defaultLinkClass = $this->cssLinkClassInternal;
break; break;
...@@ -408,29 +403,13 @@ class Link { ...@@ -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); if ($this->modeHash) throw new SyntaxReportException ("Multiple modeHash defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->modeHash = TRUE; $this->modeHash = TRUE;
break; 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); 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; $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;
break; break;
case "R": case "R":
if ($this->picturePosition != "l") throw new SyntaxReportException ("Multiple picturePosition defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); if ($this->picturePosition != "l") throw new SyntaxReportException ("Multiple picturePosition defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->picturePosition = "r"; $this->picturePosition = "r";
break; 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 // A,G
case "G": case "G":
...@@ -445,7 +424,7 @@ class Link { ...@@ -445,7 +424,7 @@ class Link {
} }
} // splitAndAddDelimter() }
/** /**
* Parse CSS Class Settings * Parse CSS Class Settings
...@@ -467,41 +446,48 @@ class Link { ...@@ -467,41 +446,48 @@ class Link {
} else { } else {
$this->linkClass = ""; $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 * @return string
* @throws SyntaxReportException
*/ */
private function doUrl($count, &$hash) { private function doUrl() {
// build URL // build URL
$htmlUrl = ""; $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) { if ($this->url) {
$param = array();
if ($this->modeHash) { if ($this->modeHash) {
$param[] = $this->buildHash($count, $hash);
$this->url = $this->sip->queryStringToSip($this->additionalUrlParams);
} else { } 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) { if ($this->additionalUrlParams) {
// Append '&' or '?' depending if there is already a '?' // Append '&' or '?' depending if there is already a '?'
$this->url .= (strpos($this->url, '?') >= 0) ? '&' : '?'; $this->url .= (strpos($this->url, '?') >= 0) ? '&' : '?';
// Append all additional params. // Append all additional params.
$this->url .= implode('&', $param); $this->url .= $this->additionalUrlParams;
}
}
}
// If there is no encryption: handle the mailto as an ordinary URL
if ($this->mailto) {
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);
}
} }
// target // target
...@@ -511,37 +497,10 @@ class Link { ...@@ -511,37 +497,10 @@ class Link {
if ($this->question) $this->question = ' onclick="return confirm(\'' . $this->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] . '>'; $htmlUrl = '<a href="' . $this->url . '"' . $this->linkClass . $this->target . $this->question . $this->toolTip[0] . '>';
}
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) { return ($htmlUrl);
$hash = $this->utils->randomAlphaNumUnique();
$_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;
}
} }
$_SESSION[FORMREPORT][$hash]['idMap'][$count]['recordId'] = $this->recordId;
$_SESSION[FORMREPORT][$hash]['idMap'][$count]['param'] = $this->additionalUrlParams;
return (URL_HASH . '=' . $hash . '&' . URL_RECORD_ID . '=' . $count);
} // doUrl()
/** /**
* Create Image HTML Tag * Create Image HTML Tag
* @return string $htmlImage * @return string $htmlImage
...@@ -564,7 +523,7 @@ class Link { ...@@ -564,7 +523,7 @@ class Link {
} }
return ($htmlImage); return ($htmlImage);
} // doImage() }
/** /**
* Encrypt the mailto address via JS. * Encrypt the mailto address via JS.
...@@ -628,7 +587,7 @@ class Link { ...@@ -628,7 +587,7 @@ class Link {
if ($href) $tt .= $this->toolTip[1]; if ($href) $tt .= $this->toolTip[1];
return ($tt); return ($tt);
} //renderLink() }
/** /**
* Split a string around the $delimiter. * Split a string around the $delimiter.
...@@ -652,5 +611,5 @@ class Link { ...@@ -652,5 +611,5 @@ class Link {
$arr[$key] = $value; $arr[$key] = $value;
return ($arr); return ($arr);
} // parseItem }
} }
\ No newline at end of file
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