public function getText(PostsProcessor $processor, $postId, $takeTextFromPost) { if (!$takeTextFromPost) { return getRandomString(TestManager::RND_STRING_LEN); } $ident = $processor->getPostType() . '_' . $postId; $matches = array(); if (array_key_exists($ident, $this->postData)) { $matches = $this->postData[$ident]; } else { $content = $processor->getPostContentProvider($postId)->getPostContent()->getContent(); preg_match_all("/<p[^>]*>([^<]*)<\\/p>/si", $content, $matches, PREG_PATTERN_ORDER); $matches = $matches[1]; $this->postData[$ident] = $matches; } $cnt = count($matches); $text = trim($cnt == 0 ? getRandomString(TestManager::RND_STRING_LEN) : $matches[rand(0, $cnt - 1)]); return $text ? UserInputTools::safeLongText($text) : getRandomString(TestManager::RND_STRING_LEN); }
/** @return MagManager */ public static function inst() { return parent::inst(); }
public function onPagePreload(WebPage $page) { switch ($page->getCode()) { case $this->getRubricPage()->getCode(): $this->onRubricShow(); break; default: parent::onPagePreload($page); break; } }
private function setPostData(Post $post, PostsProcessor $pp) { $this->setExtraData('pid', $post->getId()); $this->setExtraData('rid', $post->getRubricId()); $this->setExtraData('ptype', $post->getPostType()); $this->setExtraData('pdate', $post->getDtPublication()); $this->setExtraData('pdate_dmy', $post->getDtEvent(DF_JS_DATEPICKER)); $this->setExtraData('cover', $pp->getCoverDi4Show($post->getIdent())->getRelPath()); $this->setExtraData('cover96x96', $pp->getCoverDi($post->getIdent(), '96x96')->getRelPath()); $this->setExtraData('cover156x156', $pp->getCoverDi($post->getIdent(), '156x156')->getRelPath()); $this->setExtraData('post'); //isPost }