$listViewExtensionId = 0; } if ($listViewExtensionId == 0) { // Find default extension foreach ($listviewExtensions as $listviewExtension) { if ($listviewExtension['CODE'] == 'defaultCblockListView') { $listViewExtensionId = $listviewExtension['ID']; $isDefaultExtension = true; } } } if ($listViewExtensionId) { // Get entries for special from chosen extension $objectInfo = $extensionMgr->get($listViewExtensionId); if ($objectInfo["CODE"]) { $extension = $extensionMgr->getExtension($objectInfo["CODE"]); if ($extension && $objectInfo["INSTALLED"]) { $extensionProperties = $extension->properties; $listColumns = $extension->getListColumns(); if (strtoupper($this->page) == 'CONTENTBLOCK_LISTITEM') { $filterArray = array(array('CBID' => $coId)); } else { // Get additional information about contentblock $cb = sCblockMgr()->getCblock($coFolderID); $coInfo = $cb->get(); $coListCount = $extension->getCblockListCount($coFolderID, "SUBNODES", $coInfo['LEVEL'] + 1, 0, array()); // for paging $pageDirInfo = calcPageDir($coListCount, '0', 'ASC'); //$pageDirOrderBy = $pageDirInfo['pageDirOrderBy']; //$pageDirOrderDir = $pageDirInfo['pageDirOrderDir']; $pageDirOrderBy = $sortcol;
} // Check if copying a template cblock is requested (or creating a new one) $copyCBlock = false; if ($mode == 'list') { if ($coListExtensionId == 0) { $listviewExtensions = $extensionMgr->getList(EXTENSION_CBLOCKLISTVIEW, true); // Find default extension foreach ($listviewExtensions as $listviewExtension) { if ($listviewExtension['CODE'] == 'defaultCblockListView') { $coListExtensionId = $listviewExtension['ID']; } } } $extensionInfo = $extensionMgr->get($coListExtensionId); if ($extensionInfo['CODE']) { $extension = $extensionMgr->getExtension($extensionInfo['CODE']); if ($extension && $extensionInfo['INSTALLED']) { $defaultCo = $extension->extensionProperties->getValueInternal('DEFAULT_CO'); $defaultcb = sCblockMgr()->getCblock($defaultCo); if ($defaultCo) { $copyCBlock = true; } } } } if ($copyCBlock) { // Copy template cblock $new_id = sCblockMgr()->add($cblockID); $newcb = sCblockMgr()->getCblock($new_id); if ($new_id > 0) { $defaultCoInfo = $defaultcb->get();
/** * Copies Extensions from another Mailing to this Mailing * * @param object $sourceObject Source Mailing object */ function copyExtensionsFrom(&$sourceObject) { $sourceId = $sourceObject->getID(); $sourceVersion = $sourceObject->getVersion(); $targetId = $this->getID(); $targetVersion = $this->getVersion(); $extensions = new ExtensionMgr(sYDB(), $this->_uid); $all_extensions = $extensions->getList(EXTENSION_MAILING, true); foreach ($all_extensions as $all_extension) { $extension = $extensions->getExtension($all_extension['CODE']); if ($extension && $extension->usedByMailing($sourceId, $sourceVersion) === true) { if ($extension->usedByMailing($targetId, $targetVersion) !== true) { $newfid = $extension->addToMailingInternal($targetId, $targetVersion); } $extension = $extensions->getExtension($all_extension['CODE'], $targetId, $targetVersion); $sourceext = $extensions->getExtension($all_extension['CODE'], $sourceId, $sourceVersion); if ($extension && $sourceext) { $newfid = $extension->getPropertyId(); $oldfid = $sourceext->getPropertyId(); $extension->properties->copyTo($oldfid, $newfid); } } } }
} } } elseif (substr($objectType, 0, 3) == 'ext') { // extension mode $extensionMgr = new ExtensionMgr(); $filetypeMgr = new Filetypes(); $loop = 0; foreach ($data as $item) { $coid = $item[0]; $contentarea = $item[1]; $contentarea_id = $item[2]; $colnkid = $item[3]; $extension_id = explode('-', $item[3]); $extension_id = $extension_id[1]; $ex = $extensioninfo = $extensionMgr->get($extension_id); $extension = $extensionMgr->getExtension($ex["CODE"], $pageID, $pageInfo['VERSION'], $siteID); if ($extension) { $props = $extension->properties->getList('LISTORDER'); foreach ($props as $prop_idx => $prop) { $props[$prop_idx]['VALUE'] = $extension->properties->getValueInternal($prop['IDENTIFIER']); if ($props[$prop_idx]['TYPE'] == 'LIST') { $props[$prop_idx]['LIST_VALUES'] = $extension->propertySettings->getListValues($prop['IDENTIFIER']); } if ($props[$prop_idx]['TYPE'] == 'FILE') { if (strlen(trim($props[$prop_idx]['VALUE'])) > 0) { $file = sFileMgr()->getFile($props[$prop_idx]['VALUE']); if ($file) { $fileInfo = $file->get(); $props[$prop_idx]['COLOR'] = $fileInfo['COLOR']; $props[$prop_idx]['TYPECODE'] = $fileInfo['CODE']; $props[$prop_idx]['DISPLAYNAME'] = $fileInfo['NAME'];
/** * Calls a specific Extension hook Callback method * * @param string $method * @param int $fileId File Id * @param int $version File version * @param mixed $args Arbitrary arguments */ function callExtensionHook($method, $fileId, $version, $args) { $extensions = new ExtensionMgr($this->_db, $this->_uid); $all_file_extensions = $extensions->getList(EXTENSION_FILE, true); $extarr = array(); foreach ($all_file_extensions as $all_file_extension) { $extension = $extensions->getExtension($all_file_extension['CODE']); if ($extension && $extension->usedByFile($fileId, $version) === true) { $extension = $extensions->getExtension($all_file_extension['CODE'], $fileId, $version); if ($extension) { array_push($extarr, $extension); } } } foreach ($extarr as $extension) { $extension->callExtensionHook($method, $args); } }
$currentObject = sCblockMgr()->getCblock($lockedObject['OBJECTID']); $currentObject->releaseLock($lockedObject['TOKEN']); } } // Check for lock, and lock if not locked $lockStatus = $cblock->getLock(); if ($lockStatus['LOCKED'] == 0) { $lockedFailed = !$cblock->acquireLock($lockToken); } else { $lockedFailed = true; } $all_cblock_extensions = $extensionMgr->getList(EXTENSION_CBLOCK, true); $used_extensions = array(); $used_extensions_info = array(); foreach ($all_cblock_extensions as $all_cblock_extension) { $extension = $extensionMgr->getExtension($all_cblock_extension["CODE"]); if ($extension && $extension->usedByCblock($objectID, $cblockInfo['VERSION']) === true) { $extension = $extensionMgr->getExtension($all_cblock_extension["CODE"], $objectID, $cblockInfo['VERSION']); if ($extension) { array_push($used_extensions_info, $all_cblock_extension); array_push($used_extensions, $extension); } } } $object_property_ids = array(); foreach ($used_extensions as $used_extension_idx => $used_extension) { // Call callback $used_extension->callExtensionHook('onRenderExtensionTab'); $used_extensions_info[$used_extension_idx]['PROPERTIES'] = $used_extension->properties->getList(); } $pageInfo = $cblockInfo;
$sourcePName = $oldPageInfo['PNAME']; if (!$sourcePName) { $sourcePName = $oldPageInfo['NAME']; } if ($TargetPageMgr->getPageIdByPname($sourcePName)) { $sourcePName = $newPage->calcPName(); } $newPage->setPName($sourcePName); $newPage->setActive(1); $jsQueue->add($newPageID, HISTORYTYPE_PAGE, 'PAGE_ADD', sGuiUS(), NULL); // Check for extensions to copy $all_page_extensions = $extensionMgr->getList(EXTENSION_PAGE, true); $used_extensions = array(); $used_extensions_info = array(); foreach ($all_page_extensions as $all_page_extension) { $extension = $extensionMgr->getExtension($all_page_extension["CODE"]); if ($extension && $extension->usedByPage($source, $oldPageInfo['VERSION'], $sourcesite) === true) { $tmpExtension = $extensionMgr->getExtension($all_page_extension["CODE"], $source, $oldPageInfo['VERSION'], $sourcesite); if ($tmpExtension) { array_push($used_extensions_info, $all_page_extension); array_push($used_extensions, $tmpExtension); } } } foreach ($used_extensions as $used_extension_idx => $used_extension) { $used_extensions_info[$used_extension_idx]['PROPERTIES'] = $used_extension->properties->getList(); } $newPageInfo = $newPage->get(); foreach ($used_extensions_info as $used_extensions_info_item) { $srcExtension = $extensionMgr->getExtension($used_extensions_info_item["CODE"], $source, $oldPageInfo['VERSION'], $sourcesite); $trgtExtension = $extensionMgr->getExtension($used_extensions_info_item["CODE"]);
/** * Calls a specific Extension hook Callback method * * @param string $method * @param int $mailingId Mailing Id * @param int $version Mailing version * @param mixed $args Arbitrary arguments */ function callExtensionHook($method, $mailingId, $version, $args) { $extensions = new ExtensionMgr($this->_db, $this->_uid); $all_mailing_extensions = $extensions->getList(EXTENSION_MAILING, true); $extarr = array(); foreach ($all_mailing_extensions as $all_mailing_extension) { $extension = $extensions->getExtension($all_mailing_extension['CODE']); if ($extension && $extension->usedByMailing($mailingId, $version) === true) { $extension = $extensions->getExtension($all_mailing_extension['CODE'], $mailingId, $version); if ($extension) { array_push($extarr, $extension); } } } $origargs = $args; $ext_result = false; foreach ($extarr as $extension) { $ext_result = $extension->callExtensionHook($method, $args); if ($ext_result && $method == "beforeSend") { $args = $ext_result; } } if ($ext_result === false) { return $origargs; } else { return $ext_result; } }
/** * Calls a specific Extension hook Callback method * * @param string $callbackName * @param mixed ... (any type of parameters) */ function callExtensionHook() { $args = func_get_args(); $extensionMgr = new ExtensionMgr(); $all_extensions = $extensionMgr->getList(EXTENSION_ALL, true); foreach ($all_extensions as $all_extension_item) { $extension = $extensionMgr->getExtension($all_extension_item['CODE']); if ($extension) { return call_user_func_array(array($extension, 'callExtensionHook'), $args); } } }
$methodName = ''; switch ($extensioninfo['TYPE']) { case EXTENSION_PAGE: $methodName = 'usedByPage'; break; case EXTENSION_MAILING: $methodName = 'usedByMailing'; break; case EXTENSION_FILE: $methodName = 'usedByFile'; break; case EXTENSION_CBLOCK: $methodName = 'usedByCblock'; break; } $extension = $extensionMgr->getExtension($extensioninfo['CODE']); if ($extension && $methodName != '' && $extension->{$methodName}($objectID, $objectInfo['VERSION'], $siteID) === true) { $extension = $extensionMgr->getExtension($extensioninfo['CODE'], $objectID, $objectInfo['VERSION'], $siteID); if ($extension && $extensioninfo['TYPE'] == EXTENSION_PAGE) { $props = $extension->properties->getList('LISTORDER'); } foreach ($props as $prop) { if ($prop['ID'] == $history[$i]['TARGETID']) { $formfield_name = $prop['NAME']; } } // Get contentblock <-> page link $page_lnk = $page->getCblockLinkById($formfield_lnk[0]['CBLOCKID']); // Special Case for Files if ($history[$i]['TEXT'] == 'TXT_OBJECT_H_EXTEDIT_FRMFLD_6') { if ($history[$i]['NEWVALUE']) {
$siteID = $this->params['site']; if ($pageID && $siteID && is_numeric($siteID)) { $PageMgr = new PageMgr($siteID); $page = $PageMgr->getPage($pageID); $pageInfo = $page->get(); } $jsQueue = new JSQueue(NULL); $extensionMgr = new ExtensionMgr(); switch ($action) { case 'extensionExportData': $extensionid = $this->params['extensionId']; $uploadwinid = $this->params['uploadWinId']; $openerwinid = $this->params['openerWinId']; $extensioninfo = $extensionMgr->get($extensionid); if ($extensioninfo['CODE']) { $extension = $extensionMgr->getExtension($extensioninfo['CODE']); if ($extension) { $filelist = array(); $extension->export($filelist); $koala->callJSFunction('Koala.windows[\'wid_' . $uploadwinid . '\'].setCaption', $itext['TXT_EXPORT_FILES'], 'extensionexport'); $koala->queueScript('Koala.windows[\'' . $openerwinid . '\'].tabs.select(0, Koala.windows[\'' . $openerwinid . '\'].tabs.params);'); $fileIdx = 1; foreach ($filelist as $file) { $koala->callJSFunction('Koala.yg_addExtensionExportFile', $uploadwinid, $extensionid, $fileIdx, $file['FILENAME'], $file['MIME']); $fileIdx++; } // Clear all properties after export $properties = $extension->exportProperties->getList(); foreach ($properties as $property) { $extension->exportProperties->setValue($property['IDENTIFIER'], ''); }
break; case 'export': $extensiontype = EXTENSION_EXPORT; break; } break; } if ($adminAllowed) { $extensionMgr = new ExtensionMgr(); $extensionMgr->refreshList($this->approot . $this->extensiondir); $extensions = $extensionMgr->getList($extensiontype, $only_installed, true); // Filter out self-controlled extensions if ($selectiondialog || $objecttype == 'data') { $real_extensions = array(); foreach ($extensions as $extensionItem) { $currExtension = $extensionMgr->getExtension($extensionItem['CODE']); if ($currExtension && $currExtension->info['ASSIGNMENT'] != EXTENSION_ASSIGNMENT_EXT_CONTROLLED) { $real_extensions[] = $extensionItem; } } $extensions = $real_extensions; } } $smarty->assign('mode', $mode); $smarty->assign('extensioncount', count($extensions)); $smarty->assign('extensions', $extensions); $smarty->assign('extensiontype', $extensiontype); $smarty->assign('extensiondir', $this->extensiondir); $smarty->assign('objecttype', $objecttype); $smarty->assign('opener_reference', $this->request->parameters['opener_reference']); $smarty->assign('selectiondialog', $selectiondialog);
/** * Calls a specific Extension hook Callback method * * @param string $method * @param int $siteId Site Id * @param int $pageId Page Id * @param int $version Page version * @param mixed $args Arbitrary arguments */ function callExtensionHook($method, $siteId, $pageId, $version, $args) { $extensions = new ExtensionMgr($this->_db, $this->_uid); $all_page_extensions = $extensions->getList(EXTENSION_PAGE, true); $extarr = array(); foreach ($all_page_extensions as $all_page_extension) { $extension = $extensions->getExtension($all_page_extension["CODE"]); if ($extension && $extension->usedByPage($pageId, $version, $siteId) === true) { $extension = $extensions->getExtension($all_page_extension["CODE"], $pageId, $version, $siteId); if ($extension) { array_push($extarr, $extension); } } } foreach ($extarr as $extension) { $extension->callExtensionHook($method, $args); } }
} } } } } } } //$mailing->setStatus('UNSENT'); $jsQueue->add($object, HISTORYTYPE_MAILING, 'HIGHLIGHT_MAILING', sGuiUS(), 'name'); } break; case 'extension': $extensionMgr = new ExtensionMgr(); $value = str_replace("\r", '', str_replace("\n", '\\n', $this->reponsedata[$property]->value)); $extensionInfo = $extensionMgr->get((int) $data[0]); $extension = $extensionMgr->getExtension($extensionInfo["CODE"]); if ($extension) { switch ($data[1]) { default: case 'extensions': $properties = $extension->extensionProperties; break; case 'data': switch ($extensionInfo['TYPE']) { case EXTENSION_IMPORT: // Import $properties = $extension->importProperties; break; case EXTENSION_EXPORT: // Export $properties = $extension->exportProperties;