public function allDocumentsByCategories() { $aResult = array(); // find files in media dirs - large files that cannot be uploaded with http $aCustomFiles = array(); $aMediaDirs = ResourceFinder::create()->addExpression('web', '/^(media|flash)$/')->addRecursion()->noCache()->returnObjects()->find(); foreach ($aMediaDirs as $oFileResource) { if ($oFileResource->isFile()) { $aCustomFiles[$oFileResource->getRelativePath()] = $oFileResource->getInstancePrefix() . $oFileResource->getRelativePath(); } } if (count($aCustomFiles) > 0) { $sCustomFiles = TranslationPeer::getString('wns.documents.custom_files'); $aResult[$sCustomFiles] = array_flip($aCustomFiles); } // find files in database ordered by category foreach (DocumentCategoryQuery::create()->filterByIsExternallyManaged(false)->orderByName()->find() as $oCategory) { $aDocuments = DocumentQuery::create()->useDocumentCategoryQuery()->filterByIsExternallyManaged(false)->endUse()->orderByDocumentCategoryId()->orderByName()->select(array('Id', 'Name'))->find(); foreach ($aDocuments as $aDocument) { $aResult[$oCategory->getName()][$aDocument['Id']] = $aDocument['Name']; } } $sWithoutCategory = TranslationPeer::getString('wns.documents.select_without_title'); foreach (self::getDocumentsWithoutCategoryId() as $iId => $sName) { $aResult[$sWithoutCategory][$iId] = $sName; } return $aResult; }
public function getCriteria() { $oQuery = DocumentCategoryQuery::create(); if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_document_categories', true)) { return $oQuery->filterByIsExternallyManaged('false'); } return $oQuery; }
public function getCriteria() { $oQuery = DocumentCategoryQuery::create(); if ($this->bExcludeExternallyManaged) { $oQuery->filterByIsExternallyManaged(false); } return $oQuery; }
public function allCategories($bGetCategoriesWithDocumentsOnly = false) { $oQuery = DocumentCategoryQuery::create()->distinct()->filterByIsExternallyManaged(false); if ($bGetCategoriesWithDocumentsOnly) { $oQuery->joinDocument(null, Criteria::INNER_JOIN); if (is_string($bGetCategoriesWithDocumentsOnly)) { $oQuery->useDocumentQuery()->filterByDocumentKind($bGetCategoriesWithDocumentsOnly)->endUse(); } } return WidgetJsonFileModule::jsonBaseObjects($oQuery->orderByName()->find(), array('id', 'name')); }
public function onNavigationItemChildrenCacheDetectOutdated($oNavigationItem, $oCache, $aContainer) { $bIsOutdated =& $aContainer[0]; if (!($oNavigationItem instanceof PageNavigationItem && $oNavigationItem->getIdentifier() === 'photos')) { return; } if ($bIsOutdated) { return; } // Make sure the children are re-rendered when the items in the query are updated $bIsOutdated = $oCache->isOlderThan(DocumentQuery::create()->filterByDocumentKind('image')) || $oCache->isOlderThan(DocumentCategoryQuery::create()->filterByDocumentKind('image')); }
public function __construct($sSessionId) { parent::__construct($sSessionId); $iDocumentationPartCategory = 2; if (DocumentCategoryQuery::create()->filterById($iDocumentationPartCategory)->count() === 0) { throw new Exception(__METHOD__ . ': Please setup the exernally managed document category for this module'); } $this->setSetting('documentation_image_category_id', $iDocumentationPartCategory); $oRichtext = WidgetModule::getWidget('rich_text', null, null, 'documentation_part'); $oRichtext->setTemplate(PagePeer::getRootPage()->getTemplate()); $this->setSetting('richtext_session', $oRichtext->getSessionKey()); }
public static function getCategoryOptions() { $oQuery = DocumentCategoryQuery::create()->orderByName(); if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_document_categories', true)) { $oQuery->filterByIsExternallyManaged(false); } $aResult = $oQuery->select(array('Id', 'Name'))->find()->toKeyValue('Id', 'Name'); if (count($aResult) > 0 && !Settings::getSetting('admin', 'list_allows_multiple_categories', true)) { $aResult = array('' => ' ---- ') + $aResult; } return $aResult; }
public function saveData($aDocumentCategoryData) { if ($this->iDocumentCategoryId === null) { $oDocumentCategory = new DocumentCategory(); } else { $oDocumentCategory = DocumentCategoryQuery::create()->findPk($this->iDocumentCategoryId); } $this->validate($aDocumentCategoryData); if (!Flash::noErrors()) { throw new ValidationException(); } $oDocumentCategory->setMaxWidth($aDocumentCategoryData['max_width'] == null ? null : $aDocumentCategoryData['max_width']); $oDocumentCategory->setName($aDocumentCategoryData['name']); $oDocumentCategory->setIsExternallyManaged($aDocumentCategoryData['is_externally_managed']); $oDocumentCategory->save(); $oResult = new stdClass(); if ($this->iDocumentCategoryId === null) { $oResult->inserted = true; } else { $oResult->updated = true; } $oResult->id = $this->iDocumentCategoryId = $oDocumentCategory->getId(); return $oResult; }
public function getDocumentCategoryName() { $oDocumentCategory = DocumentCategoryQuery::create()->findPk($this->oDelegateProxy->getDocumentCategoryId()); if ($oDocumentCategory) { return $oDocumentCategory->getName(); } if ($this->oDelegateProxy->getDocumentCategoryId() === CriteriaListWidgetDelegate::SELECT_WITHOUT) { return TranslationPeer::getString('wns.documents.without_category'); } return $this->oDelegateProxy->getDocumentCategoryId(); }
/** * 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(DocumentCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = DocumentCategoryQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // referenceable behavior if (ReferencePeer::hasReference($this)) { throw new PropelException("Exception in " . __METHOD__ . ": tried removing an instance from the database even though it is still referenced.", new StillReferencedException($this)); } // denyable behavior if (!(DocumentCategoryPeer::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; } }
/** * Returns the number of related DocumentCategory objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related DocumentCategory objects. * @throws PropelException */ public function countDocumentCategorysRelatedByUpdatedBy(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collDocumentCategorysRelatedByUpdatedByPartial && !$this->isNew(); if (null === $this->collDocumentCategorysRelatedByUpdatedBy || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocumentCategorysRelatedByUpdatedBy) { return 0; } if ($partial && !$criteria) { return count($this->getDocumentCategorysRelatedByUpdatedBy()); } $query = DocumentCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUserRelatedByUpdatedBy($this)->count($con); } return count($this->collDocumentCategorysRelatedByUpdatedBy); }
/** * Get the associated DocumentCategory object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return DocumentCategory The associated DocumentCategory object. * @throws PropelException */ public function getDocumentCategory(PropelPDO $con = null, $doQuery = true) { if ($this->aDocumentCategory === null && $this->document_category_id !== null && $doQuery) { $this->aDocumentCategory = DocumentCategoryQuery::create()->findPk($this->document_category_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->aDocumentCategory->addDocuments($this); */ } return $this->aDocumentCategory; }