$tempformfield['VALUE'] = replaceSpecialURLs($props[$c]['VALUE']); break; case 'TEXTAREA': $tempformfield['FORMFIELD'] = 2; $tempformfield['VALUE'] = replaceSpecialURLs($props[$c]['VALUE']); break; case 'RICHTEXT': $tempformfield['FORMFIELD'] = 3; $tempformfield['VALUE'] = replaceSpecialURLs($props[$c]['VALUE']); break; case 'CHECKBOX': $tempformfield['FORMFIELD'] = 4; break; case 'LINK': $tempformfield['FORMFIELD'] = 5; $special_url = resolveSpecialURL($props[$c]['VALUE']); if ($special_url !== false) { $special_url_info = getSpecialURLInfo($props[$c]['VALUE']); if ($special_url_info['TYPE'] == 'IMG' || $special_url_info['TYPE'] == 'DOWN') { $tempformfield['IS_FILE'] = true; if ($special_url_info['ID']) { $file = sFileMgr()->getFile($special_url_info['ID']); $link_fileinfo = $file->get(); $tempformfield['LINKTITLE'] = $link_fileinfo['NAME']; $link_filetype = $filetypeMgr->get($link_fileinfo['FILETYPE']); $tempformfield['IDENTIFIER'] = $link_filetype['IDENTIFIER']; $tempformfield['TYPECODE'] = $link_filetype['TYPECODE']; $tempformfield['COLOR'] = $link_filetype['COLOR']; $tempformfield['FILE_ID'] = $special_url_info['ID']; } } else {
<?php $prefix = '/'; $special_url = substr($this->request->parameters['special_url'], count($prefix)); $special_url = resolveSpecialURL($special_url); if ($special_url !== false) { $smarty->assign("presetURL", $special_url); } else { $smarty->assign("presetURL", trim(prettifyUrl($this->request->parameters['special_url']))); } $siteMgr = new Sites(); // Check if coming from Contenteditor if (substr($this->request->parameters['opener_reference'], 0, 8) == 'textarea') { $smarty->assign("fromContentEditor", true); } $smarty->assign("action", $this->request->parameters['action']); $smarty->assign("opener_reference", $this->request->parameters['opener_reference']); $smarty->assign("win_no", $this->request->parameters['win_no']); $smarty->assign("sites", $siteMgr->getList()); $smarty->assign("site", $this->request->parameters['site']); $smarty->display('file:' . $this->page_template);
/** * Post processes a property value (resolves urls, permanent names, etc.) * * @param string $type Property type * @param string $value Property value * @return mixed Post processed property value */ function postProcessValue($type, $value) { switch ($type) { case 'LINK': $linkInfo = checkLinkInternalExternal(resolveSpecialURL($value)); if ($linkInfo['TYPE'] == 'internal') { return resolveSpecialURL($linkInfoJSON['href']); } elseif ($linkInfo['TYPE'] == 'file') { $pname = sFileMgr()->getPNameByFileId($linkInfo['INFO']['FILE_ID']); if ($pname) { return sApp()->webroot . 'download/' . $pname; } } else { if ($value != '') { return $value; } else { return NULL; } } case 'PAGE': $pageInfo = json_decode($value, true); $tmpPageMgr = sPageMgr($pageInfo['site']); $tmpPage = $tmpPageMgr->getPage($pageInfo['page']); if ($tmpPage) { $tmpUrl = $tmpPage->getUrl(); $tmpPname = $tmpPageMgr->getPNameByPageId($pageInfo['page']); return array('SITE_ID' => $pageInfo['site'], 'PAGE_ID' => $pageInfo['page'], 'URL' => $tmpUrl, 'PNAME' => $tmpPname, 'VALUE' => $value); } else { return NULL; } case 'FILE': $pname = sFileMgr()->getPNameByFileId($value); if ($pname) { return array('FILE_ID' => $value, 'URL' => sApp()->webroot . 'download/' . $pname, 'IMAGE_URL' => sApp()->webroot . 'image/' . $pname, 'PNAME' => $pname, 'VALUE' => $value); } else { return NULL; } case 'RICHTEXT': return replaceSpecialURLs($value); break; case 'CBLOCK': $pname = sCblockMgr()->getPNameByCblockId($value); if ($pname) { return array('CBLOCK_ID' => $value, 'PNAME' => $pname, 'VALUE' => $value); } else { return NULL; } case 'TAG': $tagInfo = sTags()->get($value); if ($tagInfo) { return array('TAG_ID' => $value, 'NAME' => $tagInfo['NAME'], 'VALUE' => $value); } else { return NULL; } default: return $value; } }
$currPageInfo['RDELETE'] = $currPage->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $history[$i]['NEWVALUE'], "RDELETE"); $iconData = getIconForPage($currPageInfo); $history[$i]['NEWVALUE'] = '<div class="icon' . $iconData['iconclass'] . '"></div>' . "<a onclick=\"\$K.yg_openObjectDetails('" . $history[$i]['NEWVALUE'] . "-" . $history[$i]['TARGETID'] . "', 'page', '" . $currPageInfo['NAME'] . "', '" . $iconData['iconclass'] . "', '" . $iconData['style'] . "');\">" . $currPageInfo['NAME'] . "</a>"; } } } if ($history[$i]['TEXT'] == 'TXT_PAGE_H_PROP_DATE') { $history[$i]['NEWVALUE'] = date($itext['DATE_FORMAT'], TStoLocalTS($history[$i]['NEWVALUE'])); } if ($history[$i]['TEXT'] == 'TXT_PAGE_H_PROP_DATETIME') { $dateString = date($itext['DATE_FORMAT'], TStoLocalTS($history[$i]['NEWVALUE'])); $timeString = date('H', TStoLocalTS($history[$i]['NEWVALUE'])) . ':' . date('i', TStoLocalTS($history[$i]['NEWVALUE'])); $history[$i]['NEWVALUE'] = $dateString . ' ' . $timeString; } if ($history[$i]['TEXT'] == 'TXT_PAGE_H_PROP_LINK') { $special_url = resolveSpecialURL($history[$i]['NEWVALUE']); if ($special_url !== false) { $target_aid = ''; $target_id = ''; $target_type = 0; $special_url_info = getSpecialURLInfo($history[$i]['NEWVALUE']); if ($special_url_info['TYPE'] == 'DOWN') { $target_type = 'FILE'; $target_id = $special_url_info['ID']; if ($target_id) { $file = sFileMgr()->getFile($target_id); if ($file) { $objectInfo = $file->get(); $history[$i]['NEWVALUE'] = '<span onmouseover="$K.yg_hoverFileHint(\'' . $target_id . '\', event);"><span style="display:inline-block;" class="filetype ' . $objectInfo['COLOR'] . '">' . $objectInfo['CODE'] . '</span> ' . "<a onclick=\"\$K.yg_openObjectDetails('" . $target_id . "', 'file', '" . $objectInfo['NAME'] . "', {color:'" . $objectInfo['COLOR'] . "',typecode:'" . $objectInfo['CODE'] . "'});\">" . $objectInfo['NAME'] . "</a></span>"; } }
} if ($object_property['TYPE'] == 'PAGE') { if ($objectdynprops[$objectdynprops_cnt]['VALUE']['site'] && $objectdynprops[$objectdynprops_cnt]['VALUE']['page']) { $pageMgr = new PageMgr($objectdynprops[$objectdynprops_cnt]['VALUE']['site']); $currPage = $pageMgr->getPage($objectdynprops[$objectdynprops_cnt]['VALUE']['page']); $pageInfo = $currPage->get(); $objectdynprops[$objectdynprops_cnt]['PAGETITLE'] = $pageInfo['NAME']; } } if ($object_property['TYPE'] == 'DATETIME' || $object_property['TYPE'] == 'DATE') { if ($objectdynprops[$objectdynprops_cnt]['VALUE']) { $objectdynprops[$objectdynprops_cnt]['VALUE'] = TStoLocalTS($objectdynprops[$objectdynprops_cnt]['VALUE']); } } if ($object_property['TYPE'] == 'LINK') { $special_url = resolveSpecialURL($objectdynprops[$objectdynprops_cnt]['VALUE']); if ($special_url !== false) { $special_url_info = getSpecialURLInfo($objectdynprops[$objectdynprops_cnt]['VALUE']); if ($special_url_info['TYPE'] == 'IMG' || $special_url_info['TYPE'] == 'DOWN') { $objectdynprops[$objectdynprops_cnt]['IS_FILE'] = true; if ($special_url_info['ID']) { $tmpFile = sFileMgr()->getFile($special_url_info['ID']); if ($tmpFile) { $link_fileinfo = $tmpFile->get(); $objectdynprops[$objectdynprops_cnt]['LINKTITLE'] = $link_fileinfo['NAME']; $link_filetype = $filetypeMgr->get($link_fileinfo['FILETYPE']); $objectdynprops[$objectdynprops_cnt]['FILEIDENTIFIER'] = $link_filetype['IDENTIFIER']; $objectdynprops[$objectdynprops_cnt]['FILEABBREVIATION'] = $link_filetype['CODE']; $objectdynprops[$objectdynprops_cnt]['FILECOLOR'] = $link_filetype['COLOR']; $objectdynprops[$objectdynprops_cnt]['FILE_ID'] = $special_url_info['ID']; }
/** * Updates References to Pages (external Links) * * @param int $srcType Source Reference Type * @param int $srcObjectId Source Object Id * @param int $srcVersion Source Object version * @param string $html HTML Code */ private function updateExtHrefFromHtml($srcType, $srcObjectId, $srcVersion, $html) { $srcType = (int) $srcType; $srcObjectId = (int) $srcObjectId; $srcVersion = (int) $srcVersion; $regexp_href = "<a\\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\\/a>"; if (preg_match_all("/{$regexp_href}/siU", stripslashes($html), $matches, PREG_SET_ORDER) > 0) { foreach ($matches as $match) { $targetUrl = $match[2]; $special_url = resolveSpecialURL($targetUrl); if (preg_match_all("/(.*)" . $this->_internPrefix . "([a-z]*)\\/([0-9]*)(\\/*)(.*)/", $targetUrl, $internal) == 0 && $special_url === false) { if (preg_match_all("/(.*)mailto:(.*)/", $targetUrl, $internal) == 0) { $targetid = ""; $trgtType = 0; $trgtType = REFTYPE_EXTERNAL; $trgtObjectId = $targetUrl; if (strlen($trgtObjectId) > 0) { $this->addRef($srcType, $srcObjectId, $srcVersion, $trgtType, $trgtObjectId); } } } } } }
/** * Gets Formfields of this Cblock including content, optionally of one specific Entrymask (internal method) * * @param int $linkId (optional) Cblock Entrymask Link Id * @return array Array of Formfields */ function getFormfieldsInternal($linkId = 0) { $version = (int) $this->getVersion(); $linkId = (int) $linkId; $cbId = (int) $this->_id; if ($this->permissions->checkInternal($this->_uid, $cbId, "RREAD")) { if ($cbId > 0) { $sql_where = "CBID = {$cbId} AND CBVERSION = {$version} "; } if ($linkId > 0) { $linksql = "AND lnk.ID = {$linkId}"; } $sql = "SELECT\n\t\t\t\tlnk.ID AS LINKID,\n\t\t\t\tlnk.ENTRYMASK AS ENTRYMASKID,\n\t\t\t\tctrl.CODE AS CODE,\n\t\t\t\tctrl.NAME AS ENTRYMASKNAME,\n\t\t\t\tCBID,\n\t\t\t\tCBVERSION\n\t\t\tFROM\n\t\t\t\t`yg_contentblocks_lnk_entrymasks` as lnk,\n\t\t\t\tyg_entrymasks_properties as ctrl\n\t\t\tWHERE\n\t\t\t\t({$sql_where} {$linksql}) AND\n\t\t\t\t(lnk.ENTRYMASK = ctrl.OBJECTID)\n\t\t\tORDER BY ORDERPROD;"; $ra = $this->cacheExecuteGetArray($sql); $webroot = (string) Singleton::config()->getVar('CONFIG/DIRECTORIES/WEBROOT'); for ($l = 0; $l < count($ra); $l++) { $sql = "SELECT\n\t\t\t\t\t\t\tl.ID AS LINKID,\n\t\t\t\t\t\t\tl.ENTRYMASK AS ENTRYMASKID,\n\t\t\t\t\t\t\tp.CODE AS CODE,\n\t\t\t\t\t\t\tp.NAME AS ENTRYMASKNAME,\n\t\t\t\t\t\t\tw.IDENTIFIER AS IDENTIFIER,\n\t\t\t\t\t\t\tf.TYPE AS TYPE,\n\t\t\t\t\t\t\tc.ID,\n\t\t\t\t\t\t\tc.FORMFIELD,\n\t\t\t\t\t\t\tc.ENTRYMASKFORMFIELD,\n\t\t\t\t\t\t\tc.LNK,\n\t\t\t\t\t\t\tc.VALUE01,\n\t\t\t\t\t\t\tc.VALUE02,\n\t\t\t\t\t\t\tc.VALUE03,\n\t\t\t\t\t\t\tc.VALUE04,\n\t\t\t\t\t\t\tc.VALUE05,\n\t\t\t\t\t\t\tc.VALUE06,\n\t\t\t\t\t\t\tc.VALUE07,\n\t\t\t\t\t\t\tc.VALUE08,\n\t\t\t\t\t\t\tw.NAME AS NAME,\n\t\t\t\t\t\t\tl.CBID AS CBID,\n\t\t\t\t\t\t\tw.PRESET AS PRESET,\n\t\t\t\t\t\t\tw.WIDTH AS WIDTH,\n\t\t\t\t\t\t\tw.MAXLENGTH AS MAXLENGTH,\n\t\t\t\t\t\t\tw.CONFIG AS CONFIG,\n\t\t\t\t\t\t\tw.CUSTOM AS CUSTOM\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tyg_contentblocks_lnk_entrymasks_c AS c,\n\t\t\t\t\t\t\tyg_contentblocks_lnk_entrymasks AS l,\n\t\t\t\t\t\t\tyg_entrymasks_lnk_formfields as w,\n\t\t\t\t\t\t\tyg_entrymasks_properties AS p,\n\t\t\t\t\t\t\tyg_formfields as f\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t(c.LNK = ?) AND\n\t\t\t\t\t\t\t(c.LNK = l.ID) AND\n\t\t\t\t\t\t\t(c.ENTRYMASKFORMFIELD = w.ID) AND\n\t\t\t\t\t\t\t(w.ENTRYMASK = p.OBJECTID) AND\n\t\t\t\t\t\t\t(l.ENTRYMASK = p.OBJECTID) AND\n\t\t\t\t\t\t\t(c.FORMFIELD = f.ID)\n\t\t\t\t\t\tORDER BY w.ORDER ASC;"; $wc = $this->cacheExecuteGetArray($sql, $ra[$l]["LINKID"]); for ($w = 0; $w < count($wc); $w++) { switch ($wc[$w]['TYPE']) { case 'TEXT': case 'CHECKBOX': case 'PASSWORD': case 'DATE': case 'DATETIME': case 'HEADLINE': $wc[$w]['VALUE'] = $wc[$w]['VALUE01']; break; case 'TEXTAREA': case 'WYSIWYG': $wc[$w]['VALUE'] = replaceSpecialURLs($wc[$w]['VALUE01']); break; case 'LINK': $resolvedUrl = resolveSpecialURL($wc[$w]['VALUE01']); if ($resolvedUrl) { $wc[$w]['URL'] = $resolvedUrl; } else { $wc[$w]['URL'] = $wc[$w]['VALUE01']; } break; case 'PAGE': $wc[$w]['PAGE_ID'] = $wc[$w]['VALUE01']; $wc[$w]['SITE_ID'] = $wc[$w]['VALUE02']; $wc[$w]['URL'] = $webroot . $wc[$w]['VALUE03']; $wc[$w]['PNAME'] = $wc[$w]['VALUE04']; $wc[$w]['SITE_PNAME'] = $wc[$w]['VALUE05']; break; case 'FILE': case 'FILEFOLDER': $wc[$w]['FILE_ID'] = $wc[$w]['VALUE01']; if ($wc[$w]['FILE_ID']) { $wc[$w]['VALUE03'] = sFileMgr()->getPNameByFileId($wc[$w]['FILE_ID']); } $wc[$w]['URL'] = ''; if ($wc[$w]['VALUE03'] != "") { $wc[$w]['URL'] = $webroot . 'download/' . $wc[$w]['VALUE03']; $wc[$w]['IMAGE_URL'] = $webroot . 'image/' . $wc[$w]['VALUE03']; $wc[$w]['PNAME'] = $wc[$w]['VALUE03']; } break; case 'CO': $wc[$w]['CBLOCK_ID'] = $wc[$w]['VALUE01']; break; case 'TAG': $wc[$w]['TAG_ID'] = $wc[$w]['VALUE01']; break; case 'LIST': $wc[$w]['VALUE'] = $wc[$w]['VALUE01']; break; } } } return $wc; } else { return false; } }
function getAdditionalFormfieldData(&$controlFormfields) { $entrymaskMgr = new Entrymasks(); $tagMgr = new Tags(); $filetypeMgr = new Filetypes(); for ($w = 0; $w < count($controlFormfields); $w++) { $controlFormfields[$w]['LVALUES'] = NULL; $controlFormfields[$w]['DISPLAYNAME'] = NULL; // Date & Datetime if ($controlFormfields[$w]['TYPE'] == 'DATE' || $controlFormfields[$w]['TYPE'] == 'DATETIME') { if ($controlFormfields[$w]['VALUE']) { $controlFormfields[$w]['VALUE'] = TStoLocalTS($controlFormfields[$w]['VALUE']); } } // Link if ($controlFormfields[$w]['TYPE'] == 'LINK') { $special_url = resolveSpecialURL($controlFormfields[$w]['URL']); if ($special_url !== false) { $special_url_info = getSpecialURLInfo($controlFormfields[$w]['VALUE01']); if ($special_url_info['TYPE'] == 'IMG' || $special_url_info['TYPE'] == 'DOWN') { $controlFormfields[$w]['IS_FILE'] = true; $file = sFileMgr()->getFile($special_url_info['ID']); $link_fileinfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_fileinfo['NAME']; $link_filetype = $filetypeMgr->get($link_fileinfo['FILETYPE']); $controlFormfields[$w]['IDENTIFIER'] = $link_filetype['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $link_filetype['CODE']; $controlFormfields[$w]['COLOR'] = $link_filetype['COLOR']; $controlFormfields[$w]['FILE_ID'] = $special_url_info['ID']; } else { $pageMgr = new PageMgr($special_url_info['SITE']); $page = $pageMgr->getPage($special_url_info['ID']); $link_pageInfo = $page->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_pageInfo['NAME']; $controlFormfields[$w]['IS_INTERNAL'] = true; } } else { if (preg_match_all(sApp()->URLRegEx1, $controlFormfields[$w]['VALUE01'], $internal) > 0) { if ($internal[2][0] == 'download') { $controlFormfields[$w]['IS_FILE'] = true; $link_file = str_replace('/', '', $internal[3][0]); $file = sFileMgr()->getFile($link_file); $link_fileinfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_fileinfo['NAME']; $link_filetype = $filetypeMgr->get($link_fileinfo['FILETYPE']); $controlFormfields[$w]['IDENTIFIER'] = $link_filetype['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $link_filetype['CODE']; $controlFormfields[$w]['COLOR'] = $link_filetype['COLOR']; $controlFormfields[$w]['FILE_ID'] = $link_file; } else { $link_site = $internal[3][0]; $link_page = str_replace('/', '', $internal[5][0]); $pageMgr = new PageMgr($link_site); $page = $pageMgr->getPage($link_page); $link_pageInfo = $page->get(); $controlFormfields[$w]['DISPLAYNAME'] = $link_pageInfo['NAME']; $controlFormfields[$w]['IS_INTERNAL'] = true; } } elseif (substr($controlFormfields[$w]['URL'], 0, 7) == 'mailto:') { $controlFormfields[$w]['IS_EMAIL'] = true; } else { $linkInfo = checkLinkInternalExternal($controlFormfields[$w]['URL']); switch ($linkInfo['TYPE']) { case 'external': $controlFormfields[$w]['DISPLAYNAME'] = $controlFormfields[$w]['URL']; break; case 'internal': $controlFormfields[$w]['DISPLAYNAME'] = $linkInfo['NAME']; $controlFormfields[$w]['IS_INTERNAL'] = true; break; case 'file': $controlFormfields[$w]['IS_FILE'] = true; $controlFormfields[$w]['DISPLAYNAME'] = $linkInfo['NAME']; $controlFormfields[$w]['IDENTIFIER'] = $linkInfo['INFO']['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $linkInfo['INFO']['CODE']; $controlFormfields[$w]['COLOR'] = $linkInfo['INFO']['COLOR']; $controlFormfields[$w]['FILE_ID'] = $linkInfo['INFO']['FILE_ID']; break; } } } } // File if ($controlFormfields[$w]['TYPE'] == 'FILE') { if (trim($controlFormfields[$w]['FILE_ID'])) { $file = sFileMgr()->getFile($controlFormfields[$w]['FILE_ID']); if ($file) { $fileInfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $fileInfo['NAME']; $controlFormfields[$w]['IDENTIFIER'] = $fileInfo['IDENTIFIER']; $controlFormfields[$w]['TYPECODE'] = $fileInfo['CODE']; $controlFormfields[$w]['COLOR'] = $fileInfo['COLOR']; } } } // File if ($controlFormfields[$w]['TYPE'] == 'FILEFOLDER') { if (trim($controlFormfields[$w]['FILE_ID'])) { $file = sFileMgr()->getFile($controlFormfields[$w]['FILE_ID']); if ($file) { $fileInfo = $file->get(); $controlFormfields[$w]['DISPLAYNAME'] = $fileInfo['NAME']; } } } // Contentblock if ($controlFormfields[$w]['TYPE'] == 'CO') { if (trim($controlFormfields[$w]['CBLOCK_ID'])) { $cb = sCblockMgr()->getCblock($controlFormfields[$w]['CBLOCK_ID']); $info = $cb->get(); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } // Tag if ($controlFormfields[$w]['TYPE'] == 'TAG') { if (trim($controlFormfields[$w]['TAG_ID'])) { $info = $tagMgr->get($controlFormfields[$w]['TAG_ID']); $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } // Page if ($controlFormfields[$w]['TYPE'] == 'PAGE') { if (trim($controlFormfields[$w]['SITE_ID']) && trim($controlFormfields[$w]['PAGE_ID'])) { $tmpPageMgr = new PageMgr($controlFormfields[$w]['SITE_ID']); $tmpPage = $tmpPageMgr->getPage($controlFormfields[$w]['PAGE_ID']); $info = $tmpPage->get(); $info['RWRITE'] = $tmpPage->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $controlFormfields[$w]['PAGE_ID'], "RWRITE"); $info['RDELETE'] = $tmpPage->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $controlFormfields[$w]['PAGE_ID'], "RDELETE"); $iconData = getIconForPage($info); $controlFormfields[$w]['ICON'] = $iconData['iconclass']; $controlFormfields[$w]['STYLE'] = $iconData['style']; $controlFormfields[$w]['DISPLAYNAME'] = $info['NAME']; } } // List if ($controlFormfields[$w]['TYPE'] == 'LIST') { if (trim($controlFormfields[$w]['ENTRYMASKFORMFIELD'])) { $controlFormfields[$w]['LIST_VALUES'] = $entrymaskMgr->getListValuesByLinkID($controlFormfields[$w]['ENTRYMASKFORMFIELD']); } } } }