/** * Check whether $Content object is valid. * * @param Content $content * @throws \Exception * @return void */ public function validate(Content $content) { // Security check. if ($content->getUid() <= 0) { throw new MissingIdentifierException('Missing identifier for Content Object', 1351605542); } }
/** * Process File with action "move". * * @param Content $content * @param string $target * @throws \Exception * @return bool */ public function processMove(Content $content, $target) { $file = ResourceFactory::getInstance()->getFileObject($content->getUid()); if ($this->getMediaModule()->hasFolderTree()) { $targetFolder = $this->getMediaModule()->getCurrentFolder(); if ($targetFolder->getIdentifier() !== $file->getParentFolder()->getIdentifier()) { // Move file $file->moveTo($targetFolder, $file->getName(), 'renameNewFile'); } } else { // Only process if the storage is different. if ((int) $file->getStorage()->getUid() !== (int) $target) { $targetStorage = ResourceFactory::getInstance()->getStorageObject((int) $target); // Retrieve target directory in the new storage. The folder will only be returned if the User has the correct permission. $targetFolder = $this->getMediaModule()->getDefaultFolderInStorage($targetStorage, $file); try { // Move file $file->moveTo($targetFolder, $file->getName(), 'renameNewFile'); } catch (\Exception $e) { $this->errorMessages = $e->getMessage(); } } } return TRUE; }
/** * Fetch the files given an object assuming * * @param $propertyName * @param Content $object * @return File[] */ protected function findByFileReference($propertyName, Content $object) { $fileField = 'uid_local'; $tableName = 'sys_file_reference'; $clause = sprintf('tablenames = "%s" %s AND fieldname = "%s" AND uid_foreign = %s', $object->getDataType(), $this->getWhereClauseForEnabledFields($tableName), GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName), $object->getUid()); $rows = $this->getDatabaseConnection()->exec_SELECTgetRows($fileField, $tableName, $clause); // Build array of Files $files = array(); foreach ($rows as $row) { $files[] = ResourceFactory::getInstance()->getFileObject($row[$fileField]); } return $files; }
/** * Tells whether a Content is related to another content. * The $fieldName corresponds to the relational field name * between the first content object and the second. * * @param \Fab\Vidi\Domain\Model\Content $relatedContent * @return boolean */ public function render($relatedContent) { $isChecked = FALSE; // Only computes whether the object is checked if one row is beeing edited. $numberOfObjects = $this->templateVariableContainer->get('numberOfObjects'); if ($numberOfObjects === 1) { /** @var \Fab\Vidi\Domain\Model\Content $content */ $content = $this->templateVariableContainer->get('content'); $fieldName = $this->templateVariableContainer->get('fieldName'); // Build an array of user group uids $relatedContentsIdentifiers = array(); /** @var \Fab\Vidi\Domain\Model\Content $contentObject */ foreach ($content[$fieldName] as $contentObject) { $relatedContentsIdentifiers[] = $contentObject->getUid(); } $isChecked = in_array($relatedContent->getUid(), $relatedContentsIdentifiers); } return $isChecked; }
/** * @param Content $object * @return string */ protected function getEditUri(Content $object) { $hiddenField = Tca::table()->getHiddenField(); $additionalParameters = array($this->getModuleLoader()->getParameterPrefix() => ['controller' => 'Content', 'action' => 'update', 'format' => 'json', 'fieldNameAndPath' => Tca::table()->getHiddenField(), 'matches' => ['uid' => $object->getUid()], 'content' => [$hiddenField => (int) (!$this->object[$hiddenField])]]); return $this->getModuleLoader()->getModuleUrl($additionalParameters); }
/** * @param Content $object * @return string */ protected function getImageEditorUri(Content $object) { $urlParameters = array(MediaModule::getParameterPrefix() => array('controller' => 'ImageEditor', 'action' => 'show', 'file' => $object->getUid())); return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); }
/** * @param Content $object * @return string */ protected function getEditParameterName(Content $object) { return sprintf('edit[%s][%s]', $object->getDataType(), $object->getUid()); }
/** * Process Content with action "localize". * * @param Content $content * @param int $language * @return bool */ public function processLocalize(Content $content, $language) { $command[$content->getDataType()][$content->getUid()]['localize'] = $language; $dataHandler = $this->getDataHandler(); $dataHandler->start(array(), $command); $dataHandler->process_datamap(); $dataHandler->process_cmdmap(); $this->errorMessages = $dataHandler->errorLog; // Returns TRUE is log does not contain errors. return empty($dataHandler->errorLog); }
/** * @param Content $object * @return string */ protected function getDeleteUri(Content $object) { $additionalParameters = array($this->getModuleLoader()->getParameterPrefix() => array('controller' => 'Content', 'action' => 'delete', 'format' => 'json', 'matches' => array('uid' => $object->getUid()))); return $this->getModuleLoader()->getModuleUrl($additionalParameters); }
/** * @param Content $object * @return string */ protected function getFilePickerUri(Content $object) { $urlParameters = array(MediaModule::getParameterPrefix() => array('controller' => 'Asset', 'action' => 'download', 'file' => $object->getUid())); return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); }