/** * @return void */ public function testReplaceTextLinks() { /** * @todo: white-space handling is still messed up */ //change nothing $this->assertEquals("hello world", replaceTextLinks("hello world")); //simple link $this->assertEquals("hello<a href=\"http://www.kajona.de\"> http://www.kajona.de</a> world", replaceTextLinks("hello http://www.kajona.de world")); $this->assertEquals("hello<a href=\"https://www.kajona.de\"> https://www.kajona.de</a> world", replaceTextLinks("hello https://www.kajona.de world")); $this->assertEquals("hello<a href=\"ftp://www.kajona.de\"> ftp://www.kajona.de</a> world", replaceTextLinks("hello ftp://www.kajona.de world")); $this->assertEquals("hello<a href=\"ftp://www.kajona.de\"> ftp://www.kajona.de</a> world hello<a href=\"ftp://www.kajona.de\"> ftp://www.kajona.de</a> world", replaceTextLinks("hello ftp://www.kajona.de world hello ftp://www.kajona.de world")); //no replacement if protocol is missing $this->assertEquals("hello www.kajona.de world", replaceTextLinks("hello www.kajona.de world")); //keep links already existing $this->assertEquals("hello <a href=\"http://www.kajona.de\">aaaa</a> world", replaceTextLinks("hello <a href=\"http://www.kajona.de\">aaaa</a> world")); $this->assertEquals("hello <a href=\"http://www.kajona.de\">http://www.kajona.de</a> world", replaceTextLinks("hello <a href=\"http://www.kajona.de\">http://www.kajona.de</a> world")); }
/** * Creates a summary of the message * * @return string */ protected function actionView() { /** @var class_module_messaging_message $objMessage */ $objMessage = class_objectfactory::getInstance()->getObject($this->getSystemid()); //different permission handlings if ($objMessage !== null && !$objMessage->rightView()) { return $this->strOutput = $this->getLang("commons_error_permissions"); } else { if ($objMessage == null) { $strText = $this->getLang("message_not_existing"); $strOk = $this->getLang("commons_ok"); $strLink = class_link::getLinkAdminHref($this->getArrModule("modul"), "list"); $strCore = class_resourceloader::getInstance()->getCorePathForModule("module_v4skin"); $strMessage = "<script type='text/javascript'>\n KAJONA.admin.loader.loadFile('_webpath_{$strCore}/module_v4skin/admin/skins/kajona_v4/js/kajona_dialog.js', function() {\n jsDialog_1.setTitle(' ');\n jsDialog_1.setContent('{$strText}', '{$strOk}', '{$strLink}'); jsDialog_1.init();\n \$('#'+jsDialog_1.containerId+'_cancelButton').css('display', 'none');\n });\n </script>"; return $strMessage; } } if ($objMessage->getStrUser() == $this->objSession->getUserID()) { $strReturn = ""; if (!$objMessage->getBitRead()) { $objMessage->setBitRead(true); $objMessage->updateObjectToDb(); } $objSender = new class_module_user_user($objMessage->getStrSenderId()); $strReference = ""; if (validateSystemid($objMessage->getStrMessageRefId())) { $objRefMessage = new class_module_messaging_message($objMessage->getStrMessageRefId()); $strReference = $objRefMessage->getStrDisplayName(); if ($objRefMessage->rightView()) { $strReference = getLinkAdmin($this->getArrModule("modul"), "view", "&systemid=" . $objRefMessage->getSystemid(), $strReference, "", "", false); } } $arrMetaData = array(array($this->getLang("message_subject"), $objMessage->getStrTitle()), array($this->getLang("message_date"), dateToString($objMessage->getObjDate())), array($this->getLang("message_type"), $objMessage->getObjMessageProvider()->getStrName()), array($this->getLang("message_sender"), $objSender->getStrDisplayName()), array($this->getLang("message_reference"), $strReference)); $strReturn .= $this->objToolkit->dataTable(null, $arrMetaData); $strBody = nl2br($objMessage->getStrBody()); $strBody = replaceTextLinks($strBody); $strReturn .= $this->objToolkit->getFieldset($objMessage->getStrTitle(), $this->objToolkit->getTextRow($strBody)); return $strReturn; } else { return $this->getLang("commons_error_permissions"); } }