Ejemplo n.º 1
0
 public function testSetElementsValues()
 {
     $element2 = new ChatPost();
     $element2->setTitle('chat1');
     $element2->setChats(array(array('name' => 'x1', 'label' => 'lab1'), array('name' => 'x2', 'label' => 'lab2')));
     $element1 = new ChatBlockElement();
     $element1->setContent($element2);
     $subElement = new VariableElement();
     $subElement->setName('title');
     $element1->addChild($subElement);
     $subElement = new LinesBlockElement();
     $subsubElement = new VariableElement();
     $subsubElement->setName('label');
     $subElement->addChild($subsubElement);
     $subsubElement = new VariableElement();
     $subsubElement->setName('line');
     $subElement->addChild($subsubElement);
     $subsubElement = new VariableElement();
     $subsubElement->setName('alt');
     $subElement->addChild($subsubElement);
     $subsubElement = new VariableElement();
     $subsubElement->setName('name');
     $subElement->addChild($subsubElement);
     $subsubElement = new VariableElement();
     $subsubElement->setName('usernumber');
     $subElement->addChild($subsubElement);
     $subsubElement = new LabelBlockElement();
     $subElement->addChild($subsubElement);
     $element1->addChild($subElement);
     $element1->setElementsValues();
     $html = $element1->render();
     $this->assertEquals('chat1lab1oddx11lab2evenx22', $html);
 }
Ejemplo n.º 2
0
 public function testSetChats()
 {
     $post = new ChatPost();
     $this->assertEquals(array(), $post->getChats());
     $post->setChats(array('chat1', 'chat2'));
     $this->assertEquals(array('chat1', 'chat2'), $post->getChats());
 }
Ejemplo n.º 3
0
 private function makePostFromIndex($id, $isPermalinkPage = false)
 {
     $htmlId = $id + 1;
     #fwrite(STDOUT, 'makePostFromIndex: '.$id.', '.$htmlId.PHP_EOL);
     $postObj = null;
     if (isset($this->settings['posts'][$id])) {
         $post = $this->settings['posts'][$id];
         $type = strtolower($post['type']);
         if ($type == 'text') {
             $postObj = new TextPost();
             if (isset($post['title'])) {
                 $postObj->setTitle($post['title']);
             }
             if (isset($post['body'])) {
                 $postObj->setBody($post['body']);
             }
         } elseif ($type == 'link') {
             $postObj = new LinkPost();
             if (isset($post['url'])) {
                 $postObj->setUrl($post['url']);
             }
             if (isset($post['name'])) {
                 $postObj->setName($post['name']);
             }
             if (isset($post['target'])) {
                 $postObj->setTarget($post['target']);
             }
             if (isset($post['description'])) {
                 $postObj->setDescription($post['description']);
             }
         } elseif ($type == 'photo') {
             $postObj = $this->makePhoto($post);
         } elseif ($type == 'photoset') {
             $postObj = new PhotosetPost();
             if (isset($post['caption'])) {
                 $postObj->setCaption($post['caption']);
             }
             if (isset($post['photos'])) {
                 $photos = array();
                 foreach ($post['photos'] as $photo) {
                     $photoObj = $this->makePhoto($photo);
                     if ($photoObj) {
                         $photos[] = $photoObj;
                         #ve($photoObj);
                     }
                 }
                 $postObj->setPhotos($photos);
             }
         } elseif ($type == 'quote') {
             $postObj = new QuotePost();
             if (isset($post['quote'])) {
                 $postObj->setQuote($post['quote']);
             }
             if (isset($post['source'])) {
                 $postObj->setSource($post['source']);
             }
             if (isset($post['length'])) {
                 $postObj->setLength($post['length']);
             }
         } elseif ($type == 'chat') {
             $postObj = new ChatPost();
             if (isset($post['title'])) {
                 $postObj->setTitle($post['title']);
             }
             if (isset($post['chats'])) {
                 $postObj->setChats($post['chats']);
             }
         } elseif ($type == 'answer') {
             $postObj = new AnswerPost();
             if (isset($post['asker'])) {
                 $postObj->setAsker($post['asker']);
             }
             if (isset($post['question'])) {
                 $postObj->setQuestion($post['question']);
             }
             if (isset($post['answer'])) {
                 $postObj->setAnswer($post['answer']);
             }
         }
         if ($postObj) {
             if (isset($post['permalink'])) {
                 $postObj->setPermalink($post['permalink']);
             } else {
                 $postObj->setPermalink('?type=post&id=' . $htmlId);
                 #fwrite(STDOUT, 'makePostFromIndex: '.$postObj->getPermalink().PHP_EOL);
             }
             if (isset($post['date'])) {
                 $postDateTime = new DateTime($post['date']);
                 $postObj->setDateTime($postDateTime);
             }
             if (isset($post['notes'])) {
                 $postObj->setNotes($post['notes']);
             }
             if (isset($post['tags'])) {
                 $postObj->setTags($post['tags']);
             }
             $postObj->setIsPermalinkPage($isPermalinkPage);
             #$postObj->setHasNextPage(isset($this->settings['posts'][$id + 1]));
             $postObj->setPostId($htmlId);
         }
     }
     return $postObj;
 }