plugin não responde no editor de artigos como paramentro - Joomla! Forum - community, help and support


boa noite,

criei um plugin que deveria inserir uma nova aba com parametros adicionais no modo edição de artigo, porém ele adiciona aba dentro das opções gerais artigo!!!
não sei como resolver isso, alguém já passou por este problema?
deve ser algo muito bobo de se resolver, pois o plugin funciona perfeitamente, e no modo debugue não retornou erro.

php plugin:

code: select all

<?php


defined('jpath_base') or die;


class plgcontentandregaleria extends jplugin
{

    public function __construct(& $subject, $config)
   {
      parent::__construct($subject, $config);
      $this->loadlanguage();
   }

   public function oncontentpreparedata($context, $data)
   {
      if (is_object($data))
      {


         $idartigo = isset($data->id) ? $data->id : 0;

         if ($idartigo >0)
         {

            // load profile data database.
            $db = jfactory::getdbo();
            $db->setquery(
               'select profile_key, profile_value #__user_profiles' .
                  ' user_id = ' . $db->quote($idartigo) . " , profile_key 'andregaleria.%'" .
                  ' order ordering'
            );

            try
            {
               $results = $db->loadrowlist();
            }
            catch (runtimeexception $e)
            {
               $this->_subject->seterror($e->getmessage());
               return false;
            }

            // merge profile data.
            $data->andregaleria = array();

            foreach ($results $v)
            {
               $k = str_replace('andregaleria.', '', $v[0]);
               $data->andregaleria[$k] = json_decode($v[1], true);
               if ($data->andregaleria[$k] === null)
               {
                  $data->andregaleria[$k] = $v[1];
               }
            }
         }else{
            //le o formulário e insere o padrão
            jform::addformpath(__dir__ . '/andregaleria');
            $form = new jform('com_content.article');
            $form->loadfile('andregaleria', true);

             $data->andregaleria = array();
               foreach ($form->getfieldset('andregaleria') $field) {
                     $data->andregaleria[] = array($field->fieldname, $field->value);
               }


         }

      }

      return true;
   }

   //prepara o formulário
   public function oncontentprepareform($form, $data)
   {




      if (!($form instanceof jform))
      {

         $this->_subject->seterror('jerror_not_a_form');
         return false;
      }

      // adiciona os campos extras
      jform::addformpath(__dir__ . '/andregaleria');
      $form->loadfile('andregaleria', false);

      return true;
      
   } //fim da preparação formulario



   public function oncontentaftersave($context, $article, $isnew)
   {
      $idartigo = $article->id;

      if ($idartigo && isset($article->andregaleria) && (count($article->andregaleria)))
      {
         try
         {

            $db = jfactory::getdbo();
            $query = $db->getquery(true)
               ->delete($db->quotename('#__user_profiles'))
               ->where($db->quotename('user_id') . ' = ' . (int) $idartigo)
               ->where($db->quotename('profile_key') . ' ' . $db->quote('andregaleria.%'));
            $db->setquery($query);
            $db->execute();

            $tuples = array();
            $order = 1;

            foreach ($article->andregaleria $k => $v)
            {
               $tuples[] = '(' . $idartigo . ', ' . $db->quote('andregaleria.' . $k) . ', ' . $db->quote(json_encode($v)) . ', ' . $order++ . ')';
            }

            $db->setquery('insert #__user_profiles values ' . implode(', ', $tuples));
            $db->execute();
         }
         catch (runtimeexception $e)
         {
            $this->_subject->seterror($e->getmessage());
            return false;
         }
      }

      return true;
   }

   public function oncontentafterdelete($context, $article)
   {
      $idartigo = $article->id;

      if ($idartigo)
      {
         try
         {
            $db = jfactory::getdbo();
            $db->setquery(
               'delete #__user_profiles user_id = ' . $db->quote($idartigo) .
                  " , profile_key 'andregaleria.%'"
            );

            $db->execute();
         }
         catch (exception $e)
         {
            $this->_subject->seterror($e->getmessage());
            return false;
         }
      }

      return true;
   }





} //fim da class


xml plugin:


code: select all

<form>
      <fields name="andregaleria">
         <fieldset name="andregaleria" label="galeria">
            <field
               name="imagem1"
               type="media"
               directory="gianni"
               id="imagem1"
               description="inserir imagem para o banner"
               label="imagem 1"
            />
           
         </fieldset>
      </fields>
   </form>






Comments

Popular posts from this blog

Joomla 3.3 Installation Error message - Joomla! Forum - community, help and support

Multilanguage infinite redirect loop error. - Joomla! Forum - community, help and support

trim media limit reached