Beispiel #1
0
 /**
  * Filter the query by a related DocumentType object
  *
  * @param   DocumentType|PropelObjectCollection $documentType The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 DocumentQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByDocumentType($documentType, $comparison = null)
 {
     if ($documentType instanceof DocumentType) {
         return $this->addUsingAlias(DocumentPeer::DOCUMENT_TYPE_ID, $documentType->getId(), $comparison);
     } elseif ($documentType instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(DocumentPeer::DOCUMENT_TYPE_ID, $documentType->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByDocumentType() only accepts arguments of type DocumentType or PropelCollection');
     }
 }
 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();
 }
 /**
  * Exclude object from result
  *
  * @param   DocumentType $documentType Object to remove from the list of results
  *
  * @return DocumentTypeQuery The current query, for fluid interface
  */
 public function prune($documentType = null)
 {
     if ($documentType) {
         $this->addUsingAlias(DocumentTypePeer::ID, $documentType->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
if (isset($_REQUEST['save'])) {
    // handle ajax save request (do not show the interface)
    $ID = @$_REQUEST['ID'];
    // we posted . characters, but something converts them to _ (HTTP 1.1 standard)
    $r = array();
    foreach ($_REQUEST as $i => $v) {
        $r[join('.', explode('_', $i))] = $v;
        //convert _ back to .
    }
    $typeDocument = array();
    for ($i0 = 0; isset($r['0.' . $i0]); $i0++) {
        $typeDocument[$i0] = array('id' => @$r['0.' . $i0 . '.0'], 'nr' => @$r['0.' . $i0 . '.0']);
    }
    $DocumentType = new DocumentType($ID, $typeDocument);
    if ($DocumentType->save() !== false) {
        die('ok:' . $_SERVER['PHP_SELF'] . '?DocumentType=' . urlencode($DocumentType->getId()));
    } else {
        die('');
    }
    exit;
    // do not show the interface
}
$buttons = "";
if (isset($_REQUEST['new'])) {
    $new = true;
} else {
    $new = false;
}
if (isset($_REQUEST['edit']) || $new) {
    $edit = true;
} else {
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param DocumentType $obj A DocumentType object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         DocumentTypePeer::$instances[$key] = $obj;
     }
 }
Beispiel #6
0
 /**
  * Declares an association between this object and a DocumentType object.
  *
  * @param                  DocumentType $v
  * @return Document The current object (for fluent API support)
  * @throws PropelException
  */
 public function setDocumentType(DocumentType $v = null)
 {
     if ($v === null) {
         $this->setDocumentTypeId(NULL);
     } else {
         $this->setDocumentTypeId($v->getId());
     }
     $this->aDocumentType = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the DocumentType object, it will not be re-added.
     if ($v !== null) {
         $v->addDocument($this);
     }
     return $this;
 }