/** * Gibt den Text mit den ersetzten Links zurück * @return string */ public function getText() { $this->text = html_entity_decode($this->text); $matches = []; // Suchen nach allem, dass in [[ ]] eingeschlossen ist preg_match_all('/\\[\\[([\\w\\.\\säöüÄÖÜß]+)\\]\\]/', $this->text, $matches); Logging::debug(print_r($matches, true)); foreach ($matches[1] as $match) { $artikel = CmsArtikel::loadByBezeichnung($match, $this->kategorieId); if ($artikel == null) { Logging::info('Lege Artikel neu an: ' . $match); $artikel = new CmsArtikel(); $artikel->ca_kategorie = $this->kategorieId; $artikel->ca_bezeichnung = $match; $artikel->ca_aktiv = 1; $artikel->ca_autor = Security::getUserId(); $artikel->save(); $titel = Text::get($artikel->getElementId() . '.titel'); $titel->te_text = $match; $titel->save(); } $link = EntityLinks::show($artikel); $tag = "<a href=\"{$link}\">{$match}</a>"; $this->text = str_replace('[[' . $match . ']]', $tag, $this->text); } return $this->text; }
public function posDown() { $this->artikel = new CmsArtikel($this->request->id); $this->artikel->down(); $this->request->kategorie = $this->artikel->ca_kategorie; }
public function getArtikel() { return CmsArtikel::filter(array('kategorie' => $this->id, 'aktiv' => 1)); }
public function setText($schluessel) { $this->artikel = CmsArtikel::loadByBezeichnung($schluessel); return $this; }
/** * @param string $string * @return CmsArtikel|null */ public static function loadByBezeichnung($string, $kategorieId = -1) { if ($kategorieId <= 0) { return CmsArtikel::findFirst(array('bezeichnung' => $string)); } else { return CmsArtikel::findFirst(['bezeichnung' => $string, 'kategorie' => $kategorieId]); } }