Пример #1
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Page is new, it will return
  * an empty collection; or if this Page has previously
  * been saved, it will retrieve related PageStrings 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 Page.
  *
  * @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|PageString[] List of PageString objects
  */
 public function getPageStringsJoinUserRelatedByUpdatedBy($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = PageStringQuery::create(null, $criteria);
     $query->joinWith('UserRelatedByUpdatedBy', $join_behavior);
     return $this->getPageStrings($query, $con);
 }
Пример #2
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(PageStringPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = PageStringQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // denyable behavior
         if (!(PageStringPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.admin_user", array("role_key" => "page_strings")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Пример #3
0
 public function getPageStringByLanguage($sLanguageId)
 {
     if (!isset($this->aStrings[$sLanguageId])) {
         $this->aStrings[$sLanguageId] = PageStringQuery::create()->filterByPage($this)->filterByLanguageId($sLanguageId)->findOne();
     }
     return $this->aStrings[$sLanguageId];
 }
Пример #4
0
 /**
  * Returns a new PageStringQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   PageStringQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return PageStringQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof PageStringQuery) {
         return $criteria;
     }
     $query = new PageStringQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Пример #5
0
 /**
  * @param main template
  * description:
  * - @see config.yml section language_chooser
  * - use parameter replaced in method
  * @return Template The rendered language chooser
  */
 public static function getLanguageChooser($oMainTemplate)
 {
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('languages'), null, true);
     $oLanguageTemplate = new Template(Settings::getSetting("language_chooser", 'template', 'language'), array(DIRNAME_TEMPLATES, DIRNAME_NAVIGATION));
     $sLinkSeparator = Settings::getSetting("language_chooser", 'link_separator', ' | ');
     $oLanguageActiveTemplate = null;
     $bShowActiveLanguage = Settings::getSetting("language_chooser", 'show_active_language', false);
     $bIsPreview = Manager::getCurrentManager() instanceof PreviewManager;
     if ($bShowActiveLanguage) {
         if (Settings::getSetting("language_chooser", 'template_active', false) !== false) {
             $oLanguageActiveTemplate = new Template(Settings::getSetting("language_chooser", 'template_active', 'language_active'), array(DIRNAME_TEMPLATES, DIRNAME_NAVIGATION));
         } else {
             $oLanguageActiveTemplate = clone $oLanguageTemplate;
         }
     }
     // Find request variables
     $aParameters = array_diff_assoc($_REQUEST, $_COOKIE);
     unset($aParameters['path']);
     unset($aParameters['content_language']);
     // Check whether manager needs language to be included
     $bCurrentPathIncludesLanguage = call_user_func(array(Manager::getManagerClassNormalized(null), 'shouldIncludeLanguageInLink'));
     $aRequestPath = explode("/", Manager::getRequestedPath());
     $aLanguages = LanguageQuery::create()->filterByIsActive(true)->exclude($bShowActiveLanguage ? false : ($bIsPreview ? 'edit' : 'current'))->orderBySort()->find();
     foreach ($aLanguages as $i => $oLanguage) {
         $oLangTemplate = null;
         $oPageString = null;
         if ($oLanguage->getId() === Session::language()) {
             $oLangTemplate = $oLanguageActiveTemplate;
             $oLangTemplate->replaceIdentifier('class', 'active');
         } else {
             $oPageString = PageStringQuery::create()->filterByPage(FrontendManager::$CURRENT_PAGE)->filterByLanguageId($oLanguage->getId())->filterByIsInactive(false)->findOne();
             if ($oPageString === null) {
                 continue;
             }
             $oLangTemplate = clone $oLanguageTemplate;
         }
         // If language is included, replace it by language id and set include_language param to false
         if ($bCurrentPathIncludesLanguage) {
             $aRequestPath[0] = $oLanguage->getPathPrefix();
             $sLink = LinkUtil::link($aRequestPath, null, $aParameters, false);
         } else {
             $sLink = LinkUtil::link($aRequestPath, null, array_merge($aParameters, array('content_language' => $oLanguage->getId())));
         }
         $oLangTemplate->replaceIdentifier('link', $sLink);
         // Add alternate language links
         if ($oPageString) {
             ResourceIncluder::metaIncluder()->addCustomResource(array('template' => 'link', 'rel' => 'alternate', 'lang' => $oLanguage->getId(), 'location' => $sLink, 'title' => $oPageString->getPageTitle()));
         }
         $oLangTemplate->replaceIdentifier('id', $oLanguage->getId());
         $oLangTemplate->replaceIdentifier('name', $oLanguage->getLanguageName($oLanguage->getId()));
         $oLangTemplate->replaceIdentifier('name_in_current_lang', $oLanguage->getLanguageName());
         $oTemplate->replaceIdentifierMultiple('languages', $oLangTemplate, null, Template::NO_NEWLINE);
         if ($i + 1 < count($aLanguages)) {
             $oTemplate->replaceIdentifierMultiple('languages', $sLinkSeparator, null, Template::NO_HTML_ESCAPE | Template::NO_NEWLINE);
         }
     }
     return $oTemplate;
 }