Esempio n. 1
0
 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' : ''));
 }
 /**
  * Get default cloud document service for current user.
  * In this method we don't know about local controller.
  * @return null|DocumentHandler
  * @throws \Bitrix\Main\SystemException
  */
 public function getDefaultServiceForCurrentUser()
 {
     //todo may be we should use userId but now we look on $USER;
     static $currentHandler;
     if ($currentHandler) {
         return $currentHandler;
     }
     $codeForUser = UserConfiguration::getDocumentServiceCode();
     if (empty($codeForUser)) {
         //todo by default we use googleHandler. But possible create option with default service.
         /** @var GoogleHandler $googleDriveClass */
         $googleDriveClass = GoogleHandler::className();
         $codeForUser = $googleDriveClass::getCode();
     }
     $currentHandler = $this->getHandlerByCode($codeForUser);
     return $currentHandler;
 }
Esempio n. 3
0
',
	DISK_FILE_VIEW_COPY_INTERNAL_LINK: '<?php 
echo GetMessageJS("DISK_FILE_VIEW_COPY_INTERNAL_LINK");
?>
',
	DISK_FILE_VIEW_EXT_LINK_ON: '<?php 
echo GetMessageJS("DISK_FILE_VIEW_EXT_LINK_ON");
?>
',
	DISK_FILE_VIEW_EXT_LINK_OFF: '<?php 
echo GetMessageJS("DISK_FILE_VIEW_EXT_LINK_OFF");
?>
',



	disk_revision_api: '<?php 
echo (int) \Bitrix\Disk\Configuration::getRevisionApi();
?>
',
	disk_document_service: '<?php 
echo (string) \Bitrix\Disk\UserConfiguration::getDocumentServiceCode();
?>
',
	wd_desktop_disk_is_installed: '<?php 
echo (bool) \Bitrix\Disk\Desktop::isDesktopDiskInstall();
?>
'
});
</script>
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
 /**
  * Sets option for current user for disk uninstall.
  */
 public static function setDesktopDiskUninstalled()
 {
     global $USER;
     \CUserOptions::setOption(Driver::INTERNAL_MODULE_ID, self::OPT_DESKTOP_DISK_INSTALL, false, false, $USER->getId());
     UserConfiguration::resetDocumentServiceCode();
 }