/**
  * prepare content in detail layout method
  *
  * Method is called by the view
  * @param 	object		The article object.  Note $article->text is also available
  * @param 	object		The article params
  * @param 	int			The 'page' number
  * @return  unknown
  */
 function article(&$article, &$params, $limitstart = 0)
 {
     if (!$this->pluginParams->get('content_mode', 'auto')) {
         $article->text = $this->removeCode($article->text);
         return;
     }
     //check exclude images
     $regex1 = '/{jathumbnail(\\s*)off/';
     if (!preg_match_all($regex1, $article->text, $matches)) {
         $HSmethodDIRECT = false;
     } else {
         $HSmethodDIRECT = true;
     }
     if ($HSmethodDIRECT) {
         require_once 'plugins/content/plg_jathumbnail/parser.php';
         $parser = new ReplaceCallbackParser('jathumbnail');
         $arr_imgs = $parser->parse($article->text, array($this, 'Jathumbnail_replacer_DIRECT'));
         if (!is_array($this->_excludeImgs)) {
             $this->_excludeImgs = array($this->_excludeImgs);
         }
     }
     //end check
     $width = $this->pluginParams->get('content_mode-auto-manual-content_width', 200);
     $height = $this->pluginParams->get('content_mode-auto-manual-content_height', 200);
     $thumbnails = $this->replaceImage($article->text, $width, $height);
     $mode = $this->pluginParams->get('content_mode');
     $position = $this->pluginParams->get('content_mode-auto-content_position', 0);
     if ($thumbnails) {
         $regex = '/\\<img[^\\>]*>/';
         $mark = '{jathumbnail}';
         if ($mode == 'auto') {
             //Auto
             //before ignore images on exclude list
             $this->beforeReplace($article->text);
             //end before
             if ($position == 0) {
                 //Place at top
                 $article->text = preg_replace($regex, '', $article->text);
                 $article->text = $thumbnails . $article->text;
             } else {
                 //Replace first image
                 $article->text = $this->removeCode($article->text);
                 $article->text = preg_replace($regex, $mark, $article->text, 1);
                 //Remove other images
                 $article->text = preg_replace($regex, '', $article->text);
                 $article->text = str_replace($mark, $thumbnails, $article->text);
             }
             //after ignore images on exclude list
             $this->afterReplace($article->text);
             //end after
             $article->text = $this->removeCode($article->text);
         }
         if ($mode == 'manual') {
             //manual
             $test = preg_match($this->_plgMatch, $article->text);
             if (preg_match($this->_plgCode, $article->text) || preg_match($this->_plgMatch, $article->text)) {
                 $regex = '/\\<img[^\\>]*>/';
                 $mark = '{jathumbnail}';
                 //before ignore images on exclude listn
                 $this->beforeReplace($article->text);
                 //end before
                 if (preg_match($this->_plgMatch, $article->text)) {
                     $article->text = preg_replace($regex, '', $article->text);
                     $article->text = preg_replace($this->_plgMatch, $thumbnails, $article->text, 1);
                 } else {
                     $article->text = preg_replace($regex, '', $article->text);
                     $article->text = preg_replace($this->_plgCode, $thumbnails, $article->text, 1);
                 }
                 //after ignore images on exclude list
                 $this->afterReplace($article->text);
                 //end after
                 $this->removeCode($article->text);
             }
         }
     }
 }
 /**
  * prepare content in detail layout method
  *
  * Method is called by the view
  * @param 	object		The article object.  Note $article->text is also available
  * @param 	object		The article params
  * @param 	int			The 'page' number
  * @return  unknown
  */
 function article(&$article, &$params, $limitstart = 0)
 {
     if (!$this->pluginParams->get('content_mode', 'auto')) {
         $article->text = $this->removeCode($article->text);
         return;
     }
     /**
      * Check thumbnail off
      */
     if (preg_match($this->_plgCodeDisable, $article->introtext) || preg_match($this->_plgCodeDisable, $article->text)) {
         $article->introtext = preg_replace($this->_plgCodeDisable, '', $article->introtext);
         $article->text = preg_replace($this->_plgCodeDisable, '', $article->text);
     } else {
         //check exclude images
         $regex1 = '/{jathumbnail(\\s*)off/';
         if (!preg_match_all($regex1, $article->text, $matches)) {
             $HSmethodDIRECT = false;
         } else {
             $HSmethodDIRECT = true;
         }
         //Get images of content
         $images_exts = '';
         $paramscontent = $article->params;
         if ($article->images) {
             $images = json_decode($article->images);
             if ($paramscontent->get('access-view')) {
                 if (isset($images->image_fulltext) and !empty($images->image_fulltext)) {
                     $images_html = '';
                     $imgfloat = empty($images->float_fulltext) ? $paramscontent->get('float_fulltext') : $images->float_fulltext;
                     if ($images->image_fulltext_caption) {
                         $images_html = 'class="caption"' . ' title="' . htmlspecialchars($images->image_fulltext_caption) . '"';
                     }
                     $images_exts = '<div class="img-fulltext-' . htmlspecialchars($imgfloat) . '"><img ' . $images_html . ' src="' . htmlspecialchars($images->image_fulltext) . '" alt="' . htmlspecialchars($images->image_fulltext_alt) . '"/></div>';
                 }
             }
         }
         //End
         $article->text = $images_exts . $article->text;
         if ($HSmethodDIRECT) {
             require_once 'plugins/content/plg_jathumbnail/parser.php';
             $parser = new ReplaceCallbackParser('jathumbnail');
             $arr_imgs = $parser->parse($article->text, array($this, 'Jathumbnail_replacer_DIRECT'));
             if (!is_array($this->_excludeImgs)) {
                 $this->_excludeImgs = array($this->_excludeImgs);
             }
         }
         //end check
         $width = $this->pluginParams->get('content_mode-auto-manual-content_width', 200);
         $height = $this->pluginParams->get('content_mode-auto-manual-content_height', 200);
         $thumbnails = $this->replaceImage($article->text, $width, $height);
         $mode = $this->pluginParams->get('content_mode');
         $position = $this->pluginParams->get('content_mode-auto-content_position', 0);
         if ($thumbnails) {
             $regex = '/\\<img[^\\>]*>/';
             $mark = '{jathumbnail}';
             if ($mode == 'auto') {
                 //Auto
                 //before ignore images on exclude list
                 $this->beforeReplace($article->text);
                 //end before
                 if ($position == 0) {
                     //Place at top
                     $article->text = preg_replace($regex, '', $article->text);
                     $article->text = $thumbnails . $article->text;
                 } else {
                     //Replace first image
                     $article->text = $this->removeCode($article->text);
                     $article->text = preg_replace($regex, $mark, $article->text, 1);
                     //Remove other images
                     $article->text = preg_replace($regex, '', $article->text);
                     $article->text = str_replace($mark, $thumbnails, $article->text);
                 }
                 //after ignore images on exclude list
                 $this->afterReplace($article->text);
                 //end after
                 $article->text = $this->removeCode($article->text);
                 //$article->images = '';
             }
             if ($mode == 'manual') {
                 //manual
                 $test = preg_match($this->_plgMatch, $article->text);
                 if (preg_match($this->_plgCode, $article->text)) {
                     //if (preg_match($this->_plgMatch, $article->text)) {
                     $regex = '/\\<img[^\\>]*>/';
                     $mark = '{jathumbnail}';
                     //before ignore images on exclude listn
                     $this->beforeReplace($article->text);
                     //end before
                     if (preg_match($this->_plgMatch, $article->text)) {
                         $article->text = preg_replace($regex, '', $article->text);
                         $article->text = preg_replace($this->_plgMatch, $thumbnails, $article->text, 1);
                     } else {
                         $article->text = preg_replace($regex, '', $article->text);
                         $article->text = preg_replace($this->_plgCode, $thumbnails, $article->text, 1);
                     }
                     //after ignore images on exclude list
                     $this->afterReplace($article->text);
                     //end after
                     $this->removeCode($article->text);
                     //$article->images = '';
                     //}
                 }
             }
         }
         $article->images = '';
     }
 }