Exemplo n.º 1
0
 /**
  * Generates a new version of this Page by copying the currently instanced version
  * and updates the currently instanced Object to the new version
  *
  * @return int|false New version of this Page or FALSE in case of an error
  */
 public function newVersion()
 {
     $pageID = $this->_id;
     if ($this->permissions->checkInternal($this->_uid, $pageID, "RWRITE")) {
         $colist = $this->getCblockList();
         $sourceVersion = $this->getVersion();
         $sourceObject = sPageMgr($this->_site)->getPage($this->_id, $sourceVersion);
         if ($sourceVersion == $this->getLatestVersion()) {
             $historyIdentifier = 'TXT_PAGE_H_NEWVERSION';
             $historySourceVersion = NULL;
         } else {
             $historyIdentifier = 'TXT_PAGE_H_NEWVERSION_FROM';
             $historySourceVersion = $sourceVersion;
         }
         $newVersion = parent::newVersion();
         $this->properties = new Properties($this->_table_properties, $this->getPropertyId(), $this);
         $this->tags->copyTo($pageID, $sourceVersion, $pageID, $newVersion);
         $this->copyCblockLinks($sourceVersion, $newVersion);
         $this->copyExtensionsFrom($sourceObject);
         // Check if there are blind entrymasks in this page (and add a version)
         foreach ($colist as $colist_item) {
             if ($colist_item['EMBEDDED'] == 1) {
                 $tmpCb = sCblockMgr()->getCblock($colist_item['OBJECTID'], $colist_item['VERSION']);
                 $version = $tmpCb->newVersion();
                 $CoLnkInfo = $this->getCblockLinkById($colist_item['LINKID']);
                 $this->addCblockVersion($colist_item['OBJECTID'], $CoLnkInfo[0]['TEMPLATECONTENTAREA'], $version);
             }
         }
         $pageMgr = new PageMgr($this->getSite());
         $pageMgr->callExtensionHook('onVersionNew', $this->getSite(), (int) $this->_id, $this->getVersion());
         // Add to history
         $this->history->add(HISTORYTYPE_PAGE, $historySourceVersion, $newVersion, $historyIdentifier);
         return $newVersion;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * 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;
     }
 }
Exemplo n.º 3
0
<?php

$siteMgr = new Sites();
$sites = $siteMgr->getList();
$user = new User(sUserMgr()->getCurrentUserID());
// Last changes from pages per site into an array
$lastchanges['PAGES'] = array();
$startx = 0;
for ($i = 0; $i < count($sites); $i++) {
    $msites[] = $sites[$i];
    $PageMgr = sPageMgr($sites[$i]["ID"]);
    $changeslist = $PageMgr->history->getLastChange(HISTORYTYPE_PAGE, $sites[$i]["ID"]);
    for ($x = $startx; $x < count($changeslist) + $startx; $x++) {
        $lastchanges['PAGES'][$x] = $changeslist[$x - $startx];
        $lastchanges['PAGES'][$x]['SITE'] = $sites[$i]['ID'];
    }
    $startx = $x;
}
// Last changes from content, files, mailings and comments
$lastchanges['CONTENT'] = sCblockMgr()->history->getLastChange(HISTORYTYPE_CO);
$fileMgr = sFileMgr();
$lastchanges['FILES'] = $fileMgr->history->getLastChange(HISTORYTYPE_FILE);
$mailingMgr = new MailingMgr();
$lastchanges['MAILING'] = $mailingMgr->history->getLastChange(HISTORYTYPE_MAILING);
/*
$commentMgr = new Comments();
$lastchanges['COMMENT'] = $commentMgr->getAllComments( $filterArray, $pageDirLimit );
*/
// Enrich information for pages, content, files, mailing
foreach (array('PAGES', 'CONTENT', 'FILES', 'MAILING') as $item) {
    foreach ($lastchanges[$item] as $lastchanges_idx => $lastchanges_item) {
Exemplo n.º 4
0
function gen_tree($current, $site = 1, $icons, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $maxlevels, $dnd, $cms, $subnodes, $itext, $action)
{
    if ($tree_level > $maxlevels) {
        $tree_level--;
        return;
    }
    $svrload = 'false';
    if ($tree_level == (int) $maxlevels) {
        $svrload = 'true';
    }
    $oldlevel = 0;
    $urlprefix = "";
    while (list($key, $value) = each($current)) {
        if ($current[$key]["RREAD"] > 0) {
            $iconData = getIconForPage($current[$key]);
            $img = $icons[$iconData['img']];
            $cststyle = $iconData['style'];
            if ($oldlevel != $current[$key]["LEVEL"]) {
                $pnames = sPageMgr($site)->getParents($current[$key]["ID"]);
                $oldlevel = $current[$key]["LEVEL"];
                $urlprefix = "";
                $pi = count($pnames);
                while ($pi > 0) {
                    if ($pnames[$pi - 1][0]["PNAME"] != "") {
                        $urlprefix .= $pnames[$pi - 1][0]["PNAME"] . "/";
                    }
                    $pi--;
                }
            }
            $url = sApp()->webroot . $urlprefix . $current[$key]["PNAME"] . "/";
            // Add path
            if ($img == '' || img != undefined) {
                $img = $imgpath . 'icons/' . $img;
            }
            $node_svrload = 'false';
            if ($svrload == 'true' && $current[$key]['CHILDREN'] != NULL) {
                $node_svrload = $svrload;
            }
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'page_' . $current[$key]["ID"], 'CAPTION' => htmlspecialchars($current[$key]["NAME"]), 'URL' => $url, 'IC' => $img, 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'DND' => $dnd, 'SVRLOAD' => $node_svrload, 'YG_ID' => $current[$key]["ID"] . '-' . $site, 'YG_TYPE' => 'page', 'YG_PROPERTY' => 'name', 'PNAME' => $current[$key]["PNAME"]);
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            if (is_array($current[$key]["CHILDREN"])) {
                $tree_level++;
                gen_tree($current[$key]["CHILDREN"], $site, $icons, $imgpath, $xml_tree, $tree_id, $tree_level, $maxlevels, $dnd, $cms, $subnodes, $itext, $action);
            }
        }
    }
    if (!$action && !$subnodes && $tree_level == 1) {
        $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'page_trash', 'CAPTION' => htmlspecialchars($itext['TXT_TRASHCAN']), 'URL' => $url, 'IC' => $imgpath . 'icons/ico_trashcan_s.png', 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => 'nodrag nodrop nosub', 'TARGET' => '', 'TITLE' => '', 'DND' => 'false', 'SVRLOAD' => 'false', 'YG_ID' => 'trash-' . $site, 'YG_TYPE' => 'page', 'YG_PROPERTY' => 'name');
        array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
    }
    $tree_level--;
}
Exemplo n.º 5
0
 if ($object_property['TYPE'] == 'TAG') {
     $tagInfo = $tagMgr->get($objectdynprops[$objectdynprops_cnt]['VALUE']);
     $objectdynprops[$objectdynprops_cnt]['TAGTITLE'] = $tagInfo['NAME'];
 }
 if ($object_property['TYPE'] == 'CBLOCK') {
     if ($objectdynprops[$objectdynprops_cnt]['VALUE']) {
         $tmpCb = sCblockMgr()->getCblock($objectdynprops[$objectdynprops_cnt]['VALUE']);
         if ($tmpCb) {
             $cblockInfo = $tmpCb->get();
             $objectdynprops[$objectdynprops_cnt]['CBLOCKTITLE'] = $cblockInfo['NAME'];
         }
     }
 }
 if ($object_property['TYPE'] == 'PAGE') {
     if ($objectdynprops[$objectdynprops_cnt]['VALUE']['site'] && $objectdynprops[$objectdynprops_cnt]['VALUE']['page']) {
         $pageMgr = sPageMgr($objectdynprops[$objectdynprops_cnt]['VALUE']['site']);
         $currPage = $pageMgr->getPage($objectdynprops[$objectdynprops_cnt]['VALUE']['page']);
         if ($currPage) {
             $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) {
Exemplo n.º 6
0
 /**
  * Saves content to a Formfield
  *
  * @param int $linkId Entrymask Formfield Link Id
  * @param string $value01 Content for Formfield parameter 1
  * @param string $value02 Content for Formfield parameter 2
  * @param string $value02 Content for Formfield parameter 3
  * @param string $value04 Content for Formfield parameter 4
  * @param string $value05 Content for Formfield parameter 5
  * @param string $value06 Content for Formfield parameter 6
  * @param string $value07 Content for Formfield parameter 7
  * @param string $value08 Content for Formfield parameter 8
  * @return bool TRUE on success or FALSE in case of an error
  * @throws Exception
  */
 function setFormfield($linkId, $value01, $value02, $value03, $value04, $value05, $value06, $value07, $value08)
 {
     $cbId = $this->_id;
     $linkId = (int) $linkId;
     if ($this->permissions->checkInternal($this->_uid, $cbId, "RWRITE")) {
         $value01 = sYDB()->escape_string($value01);
         $value02 = sYDB()->escape_string($value02);
         $value03 = sYDB()->escape_string($value03);
         $value04 = sYDB()->escape_string($value04);
         $value05 = sYDB()->escape_string($value05);
         $value06 = sYDB()->escape_string($value06);
         $value07 = sYDB()->escape_string($value07);
         $value08 = sYDB()->escape_string($value08);
         // Check if an URL needs to be generated
         $sql = "SELECT\n\t\t\t\t\t\tt.TYPE\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`yg_contentblocks_lnk_entrymasks_c` AS c,\n\t\t\t\t\t\t`yg_formfields` AS t\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(c.FORMFIELD = t.ID) AND\n\t\t\t\t\t\t(c.ID = ?);";
         $ra = $this->cacheExecuteGetArray($sql, $linkId);
         $webRoot = (string) sConfig()->getVar("CONFIG/DIRECTORIES/WEBROOT");
         switch ($ra[0]['TYPE']) {
             case 'PAGE':
                 if (strlen(trim($value02)) && strlen(trim($value01))) {
                     $siteMgr = new Sites();
                     $sitePName = $siteMgr->getPName($value02);
                     $pageMgr = sPageMgr($value02);
                     $tmpPage = $pageMgr->getPage($value01);
                     $tmpPageInfo = $tmpPage->get();
                     $value03 = $webRoot . $sitePName . '/' . $tmpPageInfo['PNAME'] . '/';
                     $value04 = $tmpPageInfo['PNAME'];
                     $value05 = $sitePName;
                 } else {
                     $value01 = $value02 = $value03 = $value04 = '';
                 }
                 break;
             case 'FILE':
                 if (strlen(trim($value01))) {
                     $tmpFile = sFileMgr()->getFile($value01);
                     if ($tmpFile) {
                         $tmpFileInfo = $tmpFile->get();
                         $value02 = $webRoot . 'download/' . $tmpFileInfo['PNAME'] . '/';
                         $value03 = $tmpFileInfo['PNAME'];
                         $value04 = $webRoot . 'image/' . $tmpFileInfo['PNAME'] . '/';
                     }
                 } else {
                     $value01 = $value02 = $value03 = '';
                 }
                 break;
         }
         $sql = "UPDATE `yg_contentblocks_lnk_entrymasks_c` SET\n\t\t\t\t\t\tVALUE01 = ?,\n\t\t\t\t\t\tVALUE02 = ?,\n\t\t\t\t\t\tVALUE03 = ?,\n\t\t\t\t\t\tVALUE04 = ?,\n\t\t\t\t\t\tVALUE05 = ?,\n\t\t\t\t\t\tVALUE06 = ?,\n\t\t\t\t\t\tVALUE07 = ?,\n\t\t\t\t\t\tVALUE08 = ?\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(ID = ?);";
         $result = sYDB()->Execute($sql, $value01, $value02, $value03, $value04, $value05, $value06, $value07, $value08, $linkId);
         if ($result === false) {
             throw new Exception(sYDB()->ErrorMsg());
         }
         // Check to which object this entrymask belongs to
         $CblockInfo = $this->get();
         // Check if it is an embedded entrymask
         if ($CblockInfo['EMBEDDED']) {
             $sql = "SELECT PID, PVERSION FROM yg_mailing_lnk_cb WHERE CBID = " . $CblockInfo['OBJECTID'] . " AND CBVERSION = " . $CblockInfo['VERSION'] . ";";
             $linkedMailings = $this->cacheExecuteGetArray($sql);
             if (count($linkedMailings) > 0) {
                 // Yes, it links to a Mailing
                 $mailingMgr = new MailingMgr();
                 foreach ($linkedMailings as $linkedMailing) {
                     $mailing = $mailingMgr->getMailing($linkedMailing['PID'], $linkedMailing['PVERSION']);
                     if ($mailing) {
                         $mailing->markAsChanged();
                     }
                 }
             } else {
                 // Check if it is related to a Page
                 $sites = sSites()->getList(true, false);
                 for ($i = 0; $i < count($sites); $i++) {
                     $sql = "SELECT PID, PVERSION FROM yg_site_" . (int) $sites[$i]['ID'] . "_lnk_cb WHERE CBID = " . (int) $CblockInfo['OBJECTID'] . " AND CBVERSION = " . (int) $CblockInfo['VERSION'] . ";";
                     $linkedPages = $this->cacheExecuteGetArray($sql);
                     if (count($linkedPages) > 0) {
                         // Yes, it links to a Pages
                         $pageMgr = sPageMgr($sites[$i]['ID']);
                         foreach ($linkedPages as $linkedPage) {
                             $page = $pageMgr->getPage($linkedPage['PID'], $linkedPage['PVERSION']);
                             if ($page) {
                                 $page->markAsChanged();
                             }
                         }
                     }
                 }
             }
         } else {
             // Entrymask is NOT embedded, so mark this Cblock as changed
             $this->markAsChanged();
         }
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 7
0
function resolveSpecialURL($specialURL)
{
    $siteMgr = new Sites();
    $specialURL = urldecode($specialURL);
    $webRoot = rtrim(ltrim((string) sConfig()->getVar("CONFIG/DIRECTORIES/WEBROOT"), '/'), '/');
    if (strpos($specialURL, $webRoot) === 0) {
        $specialURL = substr($specialURL, strlen($webRoot . '/'));
    }
    if (strpos($specialURL, '/' . $webRoot) === 0) {
        $specialURL = substr($specialURL, strlen('/' . $webRoot . '/'));
    }
    $specialURL = mb_substr($specialURL, 2, mb_strlen($specialURL, 'UTF-8') - 2, 'UTF-8');
    $specialArray = explode(':', $specialURL);
    if (strlen($webRoot) > 0) {
        $webRoot = '/' . $webRoot;
    }
    // For Links
    if ($specialArray[0] == 'LINKTO') {
        switch ($specialArray[1]) {
            case 'PAGE':
                // Try to find nice pagename
                $niceURL = '';
                if ($siteMgr->siteExists((int) $specialArray[2])) {
                    $pageMgr = sPageMgr((int) $specialArray[2]);
                    $parentNodes = $pageMgr->getParents((int) $specialArray[3]);
                    foreach ($parentNodes as $parentNode) {
                        $niceURL = '/' . $parentNode[0]['PNAME'] . $niceURL;
                    }
                    $pagepname = $pageMgr->getPnameByPageId((int) $specialArray[3]);
                    if ($pagepname) {
                        $niceURL .= '/' . $pagepname . '/';
                        return $webRoot . $niceURL;
                    } else {
                        return '';
                    }
                } else {
                    return false;
                }
                break;
            case 'IMG':
            case 'DOWN':
                // Try to find nice image-/downloadname
                $fileData = explode('§§', $specialArray[2]);
                $niceURL = '';
                $filepname = sFileMgr()->getPnameByFileId((int) $fileData[0]);
                if ($specialArray[1] == 'IMG') {
                    $niceURL .= '/image/' . $filepname;
                } else {
                    $niceURL .= '/download/' . $filepname;
                }
                if ($fileData[1]) {
                    $niceURL .= '/' . $fileData[1];
                }
                return $webRoot . $niceURL;
                break;
        }
    }
    return false;
}