예제 #1
0
 public function view($itemID)
 {
     parent::view($itemID);
     $blogPosts = $this->view->getData('Tag')->BlogPosts;
     if (!$this->app->getCurrentUser()->hasRole('ADMIN')) {
         for ($i = 0; $i < count($blogPosts); $i++) {
             if (is_null($blogPosts[$i]->Published)) {
                 unset($blogPosts[$i]);
             }
         }
     }
     $this->view->setData('BlogPostList', $blogPosts);
     $this->view->setData('PreviewSize', 1);
 }
예제 #2
0
 public function view($itemID)
 {
     parent::view($itemID);
     $matchResult = preg_match('/<img\\s[^>]*src=[\'"]([^\'"]+)[\'"]/', $this->view->getData('BlogPost')->Body, $matches);
     if ($matchResult === false || $matchResult === 0) {
         $this->view->setData(array('ImageURL' => '', 'ImageWidth' => '', 'ImageHeight' => ''));
     } else {
         if (strpos($matches[1], 'http') === 0) {
             // Do not check dimensions of remote images. -- cwells
             $this->view->setData(array('ImageURL' => $matches[1], 'ImageWidth' => '', 'ImageHeight' => ''));
         } else {
             // Check the image dimensions. -- cwells
             $dimensions = getimagesize(preg_replace('/^(\\.\\.\\/\\.\\.)?/', '../public', $matches[1]));
             $this->view->setData(array('ImageURL' => preg_replace('/^(\\.\\.\\/\\.\\.)?/', PROTOCOL_HOST_PORT, $matches[1]), 'ImageWidth' => $dimensions[0], 'ImageHeight' => $dimensions[1]));
         }
     }
 }