示例#1
0
 protected function setArticleUrl($text, $menuId, $articleId, $nameId)
 {
     for ($number = 1; $number < 7; $number++) {
         $start = strpos($text, '<h' . $number . '>');
         $end = strpos($text, '</h' . $number . '>');
         if ($start !== false && $end !== false) {
             $caption = \Nette\Utils\Strings::webalize(html_entity_decode(substr($text, $start + 4, $end - ($start + 4))));
             if (!$this->checkCaption($menuId, $caption, $articleId)) {
                 $caption .= '-' . $articleId;
             }
             $this->nameModel->setUrl($nameId, $caption);
             return $this;
         }
     }
     throw new CmsException('Článek nemá žádný nadpis. Doplňte prosím chybějící nadpis a uložte článek znovu.');
 }