Example #1
0
 function getHTML($articleid, $fieldsid, $category = false, $write = false)
 {
     //$str =   fieldattach::getImageGallery($articleid, $fieldsid,$category);
     global $globalreturn;
     $html = "";
     //$html =  '<ul class="gallery">';
     $db =& JFactory::getDBO();
     $query = 'SELECT  a.* FROM #__fieldsattach_images as a  WHERE a.fieldsattachid = ' . $fieldsid . ' AND a.articleid= ' . $articleid . ' ORDER BY a.ordering';
     if ($category) {
         $query = 'SELECT  a.* FROM #__fieldsattach_images as a  WHERE a.fieldsattachid = ' . $fieldsid . ' AND a.catid= ' . $articleid . ' ORDER BY a.ordering';
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $firs_link = '';
     $cont = 0;
     $sitepath = fieldsattachHelper::getabsoluteURL();
     $title = fieldattach::getName($articleid, $fieldsid, $category);
     $published = plgfieldsattachment_imagegallery::getPublished($fieldsid);
     if (!empty($result) && $published) {
         $html = plgfieldsattachment_imagegallery::getTemplate($fieldsid, "imagegallery");
         $line = plgfieldsattachment_imagegallery::getLineTemplate($fieldsid);
         $lines = "";
         /*
                         Templating IMAGEGLLERY *****************************
         [URL1] - Image1
                         [URL2] - Image2
                         [URL3] - Image3
                         [URL1] - Image1
                         [FIELD_ID] - Field id 
                         [ARTICLE_ID] - Article id
                         [TITLE] - Article id
                         [DESCRIPTION] - Article id
         */
         foreach ($result as $obj) {
             $img1 = $sitepath . '' . $obj->image1;
             $img2 = $sitepath . '' . $obj->image2;
             $img3 = $sitepath . '' . $obj->image3;
             $title = $obj->title;
             $description = $obj->description;
             $tmp = $line;
             $tmp = str_replace("[URL1]", $img1, $tmp);
             $tmp = str_replace("[URL2]", $img2, $tmp);
             $tmp = str_replace("[URL3]", $img3, $tmp);
             $tmp = str_replace("[ARTICLE_ID]", $articleid, $tmp);
             $tmp = str_replace("[FIELD_ID]", $fieldsid, $tmp);
             $tmp = str_replace("[TITLE]", $title, $tmp);
             $tmp = str_replace("[DESCRIPTION]", $description, $tmp);
             /*
             if (!JFile::exists( JPATH_SITE .DS. $obj->image2)  )
             {
                 $tmp = str_replace('</a>', '', $tmp);
                 $tmp = preg_replace('/<a[^>]+href[^>]+>/', '', $tmp);
             }
             */
             $lines .= $tmp;
         }
         if (fieldattach::getShowTitle($fieldsid)) {
             $html = str_replace("[TITLE]", $title, $html);
         } else {
             $html = str_replace("[TITLE]", "", $html);
         }
         $html = str_replace("[ARTICLE_ID]", $articleid, $html);
         $html = str_replace("[FIELD_ID]", $fieldsid, $html);
         $html = str_replace("[LINES]", $lines, $html);
     }
     //WRITE THE RESULT
     if ($write) {
         echo $html;
     } else {
         $globalreturn = $html;
         return $html;
     }
 }