Пример #1
0
 /**
  * Returns a new LinkQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    LinkQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof LinkQuery) {
         return $criteria;
     }
     $query = new LinkQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Пример #2
0
 public function saveData($aLinkData)
 {
     if ($this->iLinkId === null) {
         $oLink = new Link();
     } else {
         $oLink = LinkQuery::create()->findPk($this->iLinkId);
     }
     $oLink->setUrl(LinkUtil::getUrlWithProtocolIfNotSet($aLinkData['url']));
     $oLink->setName($aLinkData['name']);
     $oLink->setLinkCategoryId($aLinkData['link_category_id'] == null ? null : $aLinkData['link_category_id']);
     $oLink->setDescription($aLinkData['description']);
     if (isset($aLinkData['language_id'])) {
         $oLink->setLanguageId($aLinkData['language_id'] != null ? $aLinkData['language_id'] : null);
     }
     $this->validate($aLinkData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     if ($oLink->getLinkCategoryId() != null) {
         if ($oLink->isNew() || $oLink->isColumnModified(LinkPeer::LINK_CATEGORY_ID)) {
             $oLink->setSort(LinkQuery::create()->filterByLinkCategoryId($oLink->getLinkCategoryId())->count() + 1);
         }
     }
     $oLink->save();
     return $oLink->getId();
 }
Пример #3
0
 public function externalLinks()
 {
     $aResult = array();
     foreach (LinkCategoryQuery::create()->filterByHasLinks()->orderByName()->find() as $oLinkCategory) {
         foreach (LinkQuery::create()->filterByLinkCategoryId($oLinkCategory->getId())->orderByName()->find() as $oLink) {
             $aResult[$oLinkCategory->getName()][$oLink->getId()] = $oLink->getName();
         }
     }
     $sWithoutCategory = TranslationPeer::getString('wns.links.select_without_title');
     foreach (LinkQuery::create()->filterByLinkCategoryId(null, Criteria::ISNULL)->orderByName()->find() as $oLink) {
         $aResult[$sWithoutCategory][$oLink->getId()] = $oLink->getName();
     }
     return $aResult;
 }
Пример #4
0
 public static function listQuery($aOptions)
 {
     $oQuery = LinkQuery::create()->filterByDisplayLanguage();
     // Link categories
     $aCategories = isset($aOptions['link_categories']) ? is_array($aOptions['link_categories']) ? $aOptions['link_categories'] : array($aOptions['link_categories']) : array();
     $iCountCategories = count($aCategories);
     if ($iCountCategories > 0) {
         $oQuery->filterByLinkCategoryId($aCategories);
     }
     // Tags
     $aTags = isset($aOptions['tags']) ? is_array($aOptions['tags']) ? $aOptions['tags'] : array($aOptions['tags']) : array();
     $bHasTags = count($aTags) > 0 && $aTags[0] !== null;
     if ($bHasTags) {
         $oQuery->filterByTagId($aTags);
     }
     // Sort order only in case of one category and no tags
     if ($iCountCategories === 1 && $bHasTags === false && $aOptions['sort_by'] === self::SORT_BY_SORT) {
         $oQuery->orderBySort();
     }
     return $oQuery->orderByName();
 }
Пример #5
0
 public function getCriteria()
 {
     $oQuery = LinkQuery::create();
     if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_link_categories', true)) {
         $oQuery->excludeExternallyManaged();
     }
     if ($this->oTagFilter && $this->oDelegateProxy->getListSettings()->getFilterColumnValue('has_tags') !== CriteriaListWidgetDelegate::SELECT_ALL) {
         $oQuery->filterByTagId($this->oDelegateProxy->getListSettings()->getFilterColumnValue('has_tags'));
     }
     return $oQuery;
 }
Пример #6
0
 /**
  * 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(LinkPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = LinkQuery::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 (!(LinkPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "links")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Пример #7
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Language is new, it will return
  * an empty collection; or if this Language has previously
  * been saved, it will retrieve related Links from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Language.
  *
  * @param Criteria $criteria optional Criteria object to narrow the query
  * @param PropelPDO $con optional connection object
  * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return PropelObjectCollection|Link[] List of Link objects
  */
 public function getLinksJoinUserRelatedByUpdatedBy($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = LinkQuery::create(null, $criteria);
     $query->joinWith('UserRelatedByUpdatedBy', $join_behavior);
     return $this->getLinks($query, $con);
 }
 /**
  * renderBlogrollWidget()
  *
  * description: renders a simple list of link managed in the links admin module
  * define the required link cagegory by overwriting the config param "blogroll_link_category_id" in your site/config/config.yml
  * @return Template object
  */
 private function renderBlogrollWidget()
 {
     $iLinkCategoryId = Settings::getSetting('journal', 'blogroll_link_category_id', null);
     if ($iLinkCategoryId === null) {
         return null;
     }
     $aLinks = LinkQuery::create()->filterByLinkCategoryId($iLinkCategoryId)->orderBySort()->find();
     if (empty($aLinks)) {
         return null;
     }
     $oTemplate = $this->constructTemplate('widget_blogroll');
     $oLinkPrototype = $this->constructTemplate('widget_blogroll_link');
     foreach ($aLinks as $oLink) {
         $oLinkTemplate = clone $oLinkPrototype;
         $oLinkTemplate->replaceIdentifier('name', $oLink->getName());
         $oLinkTemplate->replaceIdentifier('description', $oLink->getDescription());
         $oLinkTemplate->replaceIdentifier('url', $oLink->getUrl());
         $oTemplate->replaceIdentifierMultiple('link', $oLinkTemplate);
     }
     return $oTemplate;
 }
Пример #9
0
 public static function externalLinkCallbackBe($oIdentifier)
 {
     $oLink = LinkQuery::create()->findPk($oIdentifier->getValue());
     if ($oLink) {
         return self::writeTagForIdentifier("a", array('href' => self::getLink(array('external_link_proxy', $oLink->getId()), 'FileManager')), $oIdentifier, null, $oLink);
     } else {
         return self::writeTagForIdentifier("a", array('href' => '#', 'style' => "color: red;!important;"), $oIdentifier, $oIdentifier->getParameter("link_text") . ' [Link missing!]');
     }
 }
Пример #10
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @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(LinkPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             LinkQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }