protected function processActionDefault() { $this->arResult = array('FILES' => $this->loadFilesData(), 'UID' => $this->getComponentId()); $driver = \Bitrix\Disk\Driver::getInstance(); $this->arResult['CLOUD_DOCUMENT'] = array(); static $documentHandlerName = null; static $documentHandlerCode = null; static $isLocal = null; if ($documentHandlerName === null) { if (Configuration::canCreateFileByCloud()) { $documentServiceCode = \Bitrix\Disk\UserConfiguration::getDocumentServiceCode(); if (!$documentServiceCode) { $documentServiceCode = 'l'; } if (LocalDocumentController::isLocalService($documentServiceCode)) { $documentHandlerName = LocalDocumentController::getName(); $documentHandlerCode = LocalDocumentController::getCode(); $isLocal = true; } else { $defaultDocumentHandler = \Bitrix\Disk\Driver::getInstance()->getDocumentHandlersManager()->getDefaultServiceForCurrentUser(); if ($defaultDocumentHandler) { $documentHandlerName = $defaultDocumentHandler->getName(); $documentHandlerCode = $defaultDocumentHandler->getCode(); $isLocal = false; } } } } if ($documentHandlerCode) { $this->arResult['CLOUD_DOCUMENT'] = array('DEFAULT_SERVICE' => $documentHandlerCode, 'DEFAULT_SERVICE_LABEL' => $documentHandlerName, 'IS_LOCAL' => $isLocal); $this->arResult['DEFAULT_DOCUMENT_SERVICE_EDIT_NAME'] = $documentHandlerName; $this->arResult['DEFAULT_DOCUMENT_SERVICE_EDIT_CODE'] = $documentHandlerCode; } else { $documentHandlerCode = 'l'; } if ($this->editMode) { $this->arResult['controlName'] = $this->arParams['PARAMS']['arUserField']['FIELD_NAME']; $this->arResult['SHARE_EDIT_ON_OBJECT_UF'] = Configuration::isEnabledDefaultEditInUf(); $urlManager = $driver->getUrlManager(); $this->arResult['CREATE_BLANK_URL'] = $urlManager->getUrlToStartCreateUfFileByService('docx', $documentHandlerCode); $this->arResult['RENAME_FILE_URL'] = $urlManager->getUrlDocumentController('rename', array('document_action' => 'rename')); $this->arResult['UPLOAD_FILE_URL'] = $urlManager->getUrlToUploadUfFile(); //now we show checkbox only if it's create post, etc. $this->arResult['DISK_ATTACHED_OBJECT_ALLOW_EDIT'] = empty($this->arResult['FILES']); $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager(); $this->arResult['INPUT_NAME_OBJECT_ALLOW_EDIT'] = $userFieldManager->getInputNameForAllowEditByEntityType($this->arParams['PARAMS']['arUserField']['ENTITY_ID']); } foreach (GetModuleEvents("main", $this->arParams['PARAMS']['arUserField']["USER_TYPE_ID"], true) as $arEvent) { if (!ExecuteModuleEventEx($arEvent, array($this->arResult, $this->arParams))) { return; } } if (is_array($this->arParams['PARAMS'])) { $this->arParams = array_merge($this->arParams, $this->arParams['PARAMS']); } $this->includeComponentTemplate($this->editMode ? 'edit' : 'show' . ($this->arParams['INLINE'] == 'Y' ? '_inline' : '')); }
protected function processActionDefault() { $driver = \Bitrix\Disk\Driver::getInstance(); $this->arResult['BUTTONS'] = array(); $securityContext = $this->storage->getCurrentUserSecurityContext(); /** @var Folder $folder */ $folder = $this->getFolder(); if (!$folder) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FOLDER_TOOLBAR_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT))); $this->includeComponentTemplate(); } $this->arResult['CLOUD_DOCUMENT'] = array(); if ($this->isFolderList() && $folder->canAdd($securityContext)) { $this->arResult['BUTTONS'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_UPLOAD_FILE_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_UPLOAD_FILE_TITLE'), 'LINK' => "javascript:void(0);", 'ICON' => 'element-upload'); if (\Bitrix\Disk\Configuration::canCreateFileByCloud()) { $documentHandlerName = $documentHandlerCode = null; $documentServiceCode = \Bitrix\Disk\UserConfiguration::getDocumentServiceCode(); if (!$documentServiceCode) { $documentServiceCode = 'l'; } if (LocalDocumentController::isLocalService($documentServiceCode)) { $documentHandlerName = LocalDocumentController::getName(); $documentHandlerCode = LocalDocumentController::getCode(); } else { $defaultDocumentHandler = \Bitrix\Disk\Driver::getInstance()->getDocumentHandlersManager()->getDefaultServiceForCurrentUser(); if ($defaultDocumentHandler) { $documentHandlerName = $defaultDocumentHandler->getName(); $documentHandlerCode = $defaultDocumentHandler->getCode(); } } if ($documentHandlerCode) { $urlManager = $driver->getUrlManager(); $this->arResult['CLOUD_DOCUMENT'] = array('DEFAULT_SERVICE' => $documentHandlerCode, 'DEFAULT_SERVICE_LABEL' => $documentHandlerName, 'CREATE_BLANK_FILE_URL' => $urlManager->getUrlToStartCreateUfFileByService('docx', $documentHandlerCode), 'RENAME_BLANK_FILE_URL' => $urlManager->getUrlDocumentController('rename', array('document_action' => 'rename'))); $this->arResult['BUTTONS'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_CREATE_DOC_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_CREATE_DOC_TITLE'), 'LINK' => "javascript:BX.Disk['FolderToolbarClass_{$this->getComponentId()}'].createFile();", 'ICON' => 'docs-add'); } } $this->arResult['BUTTONS'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_CREATE_FOLDER_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_CREATE_FOLDER_TITLE'), 'LINK' => $this->extendedAddFolder ? "javascript:BX.Disk['FolderToolbarClass_{$this->getComponentId()}'].createExtendedFolder();" : "javascript:BX.Disk['FolderToolbarClass_{$this->getComponentId()}'].createFolder();", 'ICON' => 'folder-add'); } if ($this->isTrashCan() && $folder->canRestore($securityContext)) { if (!empty($this->arParams['URL_TO_EMPTY_TRASHCAN'])) { $this->arResult['BUTTONS'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EMPTY_TRASHCAN_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EMPTY_TRASHCAN_TITLE'), 'LINK' => "javascript:BX.Disk['FolderToolbarClass_{$this->getComponentId()}'].emptyTrashCan();", 'ICON' => 'empty-trashcan'); } } $this->arResult['DROPDOWN_FILTER'] = array(); if (!empty($this->arParams['URL_TO_FOLDER_LIST'])) { $this->arResult['DROPDOWN_FILTER'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_FOLDER_LIST_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_FOLDER_LIST_TITLE'), 'HREF' => $this->arParams['URL_TO_FOLDER_LIST']); if ($this->isFolderList()) { $this->arResult['DROPDOWN_FILTER_CURRENT_LABEL'] = Loc::getMessage('DISK_FOLDER_TOOLBAR_FOLDER_LIST_TEXT'); if ($this->arParams['RELATIVE_PATH'] && $folder->getId() != $this->storage->getRootObjectId()) { $relativePath = explode('/', trim($this->arParams['RELATIVE_PATH'], '/')); array_pop($relativePath); if ($relativePath) { $prevPageListing = rtrim(CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FOLDER_LIST'], array('PATH' => implode('/', $relativePath))), '/'); } else { $prevPageListing = $this->arParams['URL_TO_FOLDER_LIST']; } array_unshift($this->arResult['BUTTONS'], array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_GO_BACK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_GO_BACK_TITLE'), 'LINK' => $prevPageListing, 'ICON' => 'back')); } } } if (!empty($this->arParams['PATH_TO_EXTERNAL_LINK_LIST'])) { $this->arResult['DROPDOWN_FILTER'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_TEXT_2'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_TITLE'), 'HREF' => $this->arParams['PATH_TO_EXTERNAL_LINK_LIST']); if ($this->isExternalLinkList()) { $this->arResult['DROPDOWN_FILTER_CURRENT_LABEL'] = Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_TEXT_2'); $this->arResult['BUTTONS'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_GO_BACK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_GO_BACK_TITLE'), 'LINK' => $this->arParams['URL_TO_FOLDER_LIST'], 'ICON' => 'back'); } } if (!empty($this->arParams['URL_TO_TRASHCAN_LIST'])) { $this->arResult['DROPDOWN_FILTER'][] = array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_TRASHCAN_TEXT_2'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_TRASHCAN_TITLE'), 'HREF' => $this->arParams['URL_TO_TRASHCAN_LIST']); if ($this->isTrashCan()) { $this->arResult['DROPDOWN_FILTER_CURRENT_LABEL'] = Loc::getMessage('DISK_FOLDER_TOOLBAR_TRASHCAN_TEXT'); array_unshift($this->arResult['BUTTONS'], array('TEXT' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_GO_BACK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FOLDER_TOOLBAR_EXTERNAL_LINK_LIST_GO_BACK_TITLE'), 'LINK' => $this->arParams['URL_TO_FOLDER_LIST'], 'ICON' => 'back')); } } $this->includeComponentTemplate(); }