Exemple #1
0
 /**
  * Retrieve the icon HTML for the post
  *
  * @param Fishpig_Wordpress_Model_Post $post
  * @return string
  */
 public function getIcons(Fishpig_Wordpress_Model_Post $post)
 {
     if ($this->isEnabled()) {
         $html = Mage::helper('wordpress')->getWpOption('st_tags');
         if (preg_match_all("/(<span.*><\\/span>)/iU", $html, $matches)) {
             $tags = array();
             foreach ($matches[1] as $match) {
                 $class = $this->_patternMatch("/class='(.*)'/iU", $match);
                 $displayText = $this->_patternMatch("/displayText='(.*)'/iU", $match);
                 $stVia = trim($this->_patternMatch("/st_via='(.*)'/iU", $match));
                 if ($displayText) {
                     $displayText = ' displayText="' . $displayText . '" ';
                 }
                 if ($stVia) {
                     $stVia = ' st_via="' . $stVia . '"';
                 }
                 $tag = sprintf('<span class="%s"%sst_title="%s" st_summary="%s" st_url="%s"%s></span>', $class, $displayText, addslashes($post->getPostTitle()), trim(strip_tags(addslashes($post->getPostExcerpt()))), $post->getPermalink(), $stVia);
                 if ($image = $post->getFeaturedImage()) {
                     $tag = str_replace('></span>', ' st_image="' . $image->getAvailableImage() . '"></span>', $tag);
                 }
                 $tags[] = $tag;
             }
             return implode('', $tags);
         }
     }
 }
Exemple #2
0
 /**
  * Retrieve the post excerpt
  *
  * @param Fishpig_Wordpress_Model_Post $post
  * @return string
  */
 public function getPostExcerpt(Fishpig_Wordpress_Model_Post $post)
 {
     if ($excerpt = trim(strip_tags($post->getPostExcerpt()))) {
         $words = explode(' ', $excerpt);
         if (count($words) > $this->getExcerptLength()) {
             $words = array_slice($words, 0, $this->getExcerptLength());
         }
         return trim(implode(' ', $words), '.,!:-?"\'£$%') . '...';
     }
     return '';
 }
 /**
  * Retrieve the icon HTML for the post
  *
  * @param Fishpig_Wordpress_Model_Post $post
  * @return string
  */
 public function getIcons(Fishpig_Wordpress_Model_Post $post)
 {
     if ($this->isEnabled()) {
         $tags = Mage::helper('wordpress')->getWpOption('st_tags');
         $tags = preg_replace("/(<\\?php[ ]{0,}the_title\\(\\)[;]{0,1}[ ]{0,}[php]{0,3}\\?>)/", addslashes($post->getPostTitle()), $tags);
         $tags = preg_replace("/(<\\?php[ ]{0,}the_permalink\\(\\)[;]{0,1}[ ]{0,}[php]{0,3}\\?>)/", addslashes($post->getPermalink()), $tags);
         $tags = preg_replace("/(<\\?php[ ]{0,}the_excerpt\\(\\)[;]{0,1}[ ]{0,}[php]{0,3}\\?>)/", addslashes(strip_tags($post->getPostExcerpt())), $tags);
         if (strpos($tags, 'the_image(') !== false) {
             if ($image = $post->getFeaturedImage()) {
                 $tags = preg_replace("/(<\\?php[ ]{0,}the_image\\(\\)[;]{0,1}[ ]{0,}[php]{0,3}\\?>)/", $image->getThumbnailImage(), $tags);
             }
         }
         return $tags;
     }
 }