Example #1
0
 static function getHTML($articleid, $fieldsid, $category = false, $write = false)
 {
     global $globalreturn;
     if (method_exists('fieldattach', 'getFieldValues')) {
         $jsonValues = fieldattach::getFieldValues($articleid, $fieldsid, $category);
         $jsonValuesArray = json_decode($jsonValues);
         if (count($jsonValuesArray) > 0) {
             $valor = html_entity_decode($jsonValuesArray->value);
             $title = $jsonValuesArray->title;
             $published = $jsonValuesArray->published;
             $showTitle = $jsonValuesArray->showtitle;
         }
     } else {
         $valor = fieldattach::getValue($articleid, $fieldsid, $category);
         $title = fieldattach::getName($articleid, $fieldsid, $category);
         $published = plgfieldsattachment_textarea::getPublished($fieldsid);
         $showTitle = fieldattach::getShowTitle($fieldsid);
     }
     $html = "";
     if (!empty($valor) && $published) {
         $html = plgfieldsattachment_textarea::getTemplate($fieldsid, "textarea");
         /*
                         Templating INPUT *****************************
             [TITLE] - Title of field
                         [FIELD_ID] - Field id 
                         [VALUE] - Value of input
         */
         if ($showTitle) {
             $html = str_replace("[TITLE]", $title, $html);
         } else {
             $html = str_replace("[TITLE]", "", $html);
         }
         $html = str_replace("[VALUE]", $valor, $html);
         $html = str_replace("[FIELD_ID]", $fieldsid, $html);
         $html = str_replace("[ARTICLE_ID]", $articleid, $html);
     }
     //WRITE THE RESULT
     if ($write) {
         echo $html;
     } else {
         $globalreturn = $html;
         return $html;
     }
 }
Example #2
0
 function getHTML($articleid, $fieldsid, $category = true, $write = false)
 {
     global $globalreturn;
     $db =& JFactory::getDBO();
     $query = 'SELECT positionarticle FROM #__fieldsattach WHERE id = ' . $fieldsid;
     $db->setQuery($query);
     $category = $db->loadResult();
     $valor = fieldattach::getValue($articleid, $fieldsid, $category);
     $title = fieldattach::getName($articleid, $fieldsid, $category);
     $html = "";
     $published = plgfieldsattachment_textarea::getPublished($fieldsid);
     if (!empty($valor) && $published) {
         $html = plgfieldsattachment_textarea::getTemplate($fieldsid);
         /*
                             Templating INPUT *****************************
             [TITLE] - Title of field
                             [FIELD_ID] - Field id 
                             [VALUE] - Value of input
         */
         if (fieldattach::getShowTitle($fieldsid)) {
             $html = str_replace("[TITLE]", $title, $html);
         } else {
             $html = str_replace("[TITLE]", "", $html);
         }
         $html = str_replace("[VALUE]", $valor, $html);
         $html = str_replace("[FIELD_ID]", $fieldsid, $html);
         $html = str_replace("[ARTICLE_ID]", $articleid, $html);
     }
     //WRITE THE RESULT
     if ($write) {
         echo $html;
     } else {
         $globalreturn = $html;
         return $html;
     }
 }