public function getCriteria() { $oQuery = DocumentTypeQuery::create(); if ($this->oDelegateProxy->getDocumentKind() !== CriteriaListWidgetDelegate::SELECT_ALL) { $oQuery->filterByMimetype($this->oDelegateProxy->getDocumentKind() . '/%', Criteria::LIKE); } return $oQuery; }
public static function getDocumentKindsAssoc($bWithDocumentsOnly = false) { $aResult = array(); $oQuery = DocumentTypeQuery::create(); if ($bWithDocumentsOnly) { $oQuery->joinDocument(); } foreach ($oQuery->find() as $oDocumentType) { $aKind = explode('/', $oDocumentType->getMimeType()); $aResult[$aKind[0]] = self::getDocumentKindName($aKind[0]); } asort($aResult); return $aResult; }
public function saveData($aDocumentTypeData) { if ($this->iTypeId === null) { $oType = new DocumentType(); } else { $oType = DocumentTypeQuery::create()->findPk($this->iTypeId); } $this->validate($aDocumentTypeData, $oType); if (!Flash::noErrors()) { throw new ValidationException(); } $oType->setExtension($aDocumentTypeData['extension']); $oType->setMimetype($aDocumentTypeData['mimetype']); return $oType->save(); }
public function __construct($aRequestPath) { parent::__construct($aRequestPath); if (!isset($this->aPath[0])) { throw new Exception("Error in DocumentTypePreviewFileModule->__construct: no type given"); } $this->oDocumentType = DocumentTypeQuery::create()->findPk($this->aPath[0]); if ($this->oDocumentType === null) { throw new Exception("Error in DocumentTypePreviewFileModule->__construct: type invalid: {$this->aPath[0]}"); } $this->iSize = 512; if (isset($_REQUEST['size'])) { $this->iSize = min($this->iSize, (int) $_REQUEST['size']); } }
public function filterByDocumentKind($sDocumentKind = 'image') { return $this->filterByDocumentTypeId(DocumentTypeQuery::findDocumentTypeIDsByKind($sDocumentKind), Criteria::IN); }
public function acceptsURL($sUrl, $bCreateType = false) { $sFileName = substr($sUrl, strrpos($sUrl, '/') + 1); $aName = explode('.', $sFileName); $sExtension = null; if (count($aName) > 1) { $sExtension = array_pop($aName); } $sFileName = implode('.', $aName); $aHeaders = @get_headers($sUrl, true); $sMimeType = null; $oDocumentType = null; if ($aHeaders && isset($aHeaders['Content-Type'])) { $sMimeType = $aHeaders['Content-Type']; $oDocumentType = DocumentTypeQuery::findDocumentTypeByMimetype($sMimeType); } if ($oDocumentType === null && $sExtension !== null) { $oDocumentType = DocumentTypePeer::getDocumentTypeByExtension($sExtension); } if ($oDocumentType === null && $bCreateType && $sMimeType && $sExtension) { $oDocumentType = new DocumentType(); $oDocumentType->setExtension($sExtension); $oDocumentType->setMimetype($sMimeType); $oDocumentType->save(); } if ($oDocumentType === null) { throw new LocalizedException("wns.file_upload.document_type_not_found", array('extension' => $sExtension, 'mimetype' => $sMimeType)); } return $oDocumentType->getId(); }
/** * Returns a new DocumentTypeQuery object. * * @param string $modelAlias The alias of a model in the query * @param DocumentTypeQuery|Criteria $criteria Optional Criteria to build the query from * * @return DocumentTypeQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof DocumentTypeQuery) { return $criteria; } $query = new DocumentTypeQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Returns the number of related DocumentType objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related DocumentType objects. * @throws PropelException */ public function countDocumentTypesRelatedByUpdatedBy(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collDocumentTypesRelatedByUpdatedByPartial && !$this->isNew(); if (null === $this->collDocumentTypesRelatedByUpdatedBy || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocumentTypesRelatedByUpdatedBy) { return 0; } if ($partial && !$criteria) { return count($this->getDocumentTypesRelatedByUpdatedBy()); } $query = DocumentTypeQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUserRelatedByUpdatedBy($this)->count($con); } return count($this->collDocumentTypesRelatedByUpdatedBy); }
/** * @deprecated use DocumentTypeQuery::findDocumentTypeAndMimetypeByDocumentKind() */ public static function getDocumentTypeAndMimetypeByDocumentKind($sMimeTypeKind = 'image', $bLike = true) { return DocumentTypeQuery::findDocumentTypeAndMimetypeByDocumentKind($sMimeTypeKind, $bLike); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(DocumentTypePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = DocumentTypeQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // denyable behavior if (!(DocumentTypePeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "documents"))); } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Get the associated DocumentType object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return DocumentType The associated DocumentType object. * @throws PropelException */ public function getDocumentType(PropelPDO $con = null, $doQuery = true) { if ($this->aDocumentType === null && $this->document_type_id !== null && $doQuery) { $this->aDocumentType = DocumentTypeQuery::create()->findPk($this->document_type_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aDocumentType->addDocuments($this); */ } return $this->aDocumentType; }