Example #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' : ''));
 }