Example #1
0
 /**
  * Injects Insert Tags input box and drop down menu to adminForm
  *
  * @access	public
  * @since	1.5
  */
 function onAfterRenderCategory()
 {
     $db =& JFactory::getDBO();
     $query = 'SELECT *  FROM #__extensions as a WHERE a.folder = "fieldsattachment"  AND a.enabled= 1';
     $db->setQuery($query);
     $results_plugins = $db->loadObjectList();
     $body = JResponse::getBody();
     //echo "sssssssssssssssssssssssssssssssss:: ".count($results_plugins);
     $id = JRequest::getVar('id');
     if (!empty($id)) {
         $fields_tmp0 = fieldsattachHelper::getfieldsForAllCategory($id);
         $fields = fieldsattachHelper::getfieldsCategory($id);
         $fields = array_merge($fields_tmp0, $fields);
     }
     $idgroup = -1;
     if (count($fields) > 0) {
         $exist = false;
         //NEW
         JPluginHelper::importPlugin('fieldsattachment');
         // very important
         foreach ($fields as $field) {
             //select
             foreach ($results_plugins as $obj) {
                 $function = "plgfieldsattachment_" . $obj->element . "::construct();";
                 $base = JPATH_BASE;
                 $base = str_replace("/administrator", "", $base);
                 $base = JPATH_SITE;
                 $file = $base . '/plugins/fieldsattachment/' . $obj->element . '/' . $obj->element . '.php';
                 if (JFile::exists($file)) {
                     //file exist
                     eval($function);
                 }
                 $i = count($this->array_fields);
                 //$str .= "<br> ".$field->type." == ".$obj->element;
                 if ($field->type == $obj->element && $field->visible) {
                     $function = "plgfieldsattachment_" . $obj->element . "::getHTML(" . $id . "," . $field->id . ", true);";
                     //$sustitucion  = "<br> ".$function ;
                     // echo "<br>".$function;
                     eval("\$sustitucion   =" . $function . "");
                     // $str .= $function;
                 }
             }
             //echo "xxxxxxxxxx dd:".$idgroup;
             // $body .=    $field->titlegroup.'sdddddddddddddddddddddddddddddddddddddddddddddddd<br>ss';
             if ($field->visible) {
                 $patron = "{fieldsattach_" . $field->id . "}";
                 // echo $patron;
                 $body = str_replace($patron, $sustitucion, $body);
                 $exist = true;
                 $idgroup = $field->idgroup;
             } else {
                 $patron = "{fieldsattach_" . $field->id . "}";
                 // echo $patron;
                 $body = str_replace($patron, "", $body);
             }
         }
     }
     JResponse::setBody($body);
 }