Forum

JiFile per Joomla!

JIFile
JiFile è una componente per Joomla! che permette di indicizzare il contenuto dei file(PDF, DOC, ecc.) per poter effettuare delle ricerche al loro interno.

Scopri di più...  Demo

JoomPhoto Mobile

JPhotoMobile
JoomPhoto Mobile è una componente per Joomla! che ti permette di condividere le foto dal tuo dispositivo Android sul tuo portale Joomla!.

Scopri di più...  Demo

iFile Framework

IFile
IFile è un framework open source scritto interamente in PHP, permette l'indicizzazione dei contenuti testuali di un documento (DOC, PDF, EXCEL, etc) e una rapida ricerca all'interno degli stessi.

Scopri di più...  Demo

Easy Language

EasyLanguage
Easy Language è un plugin per la gestione semplice ed immediata di testi multilingua in ogni parte possibile di joomla, articoli, componenti, moduli, metadata, template, altri componenti(esempio K2) ecc.

Scopri di più...

Article Book Effect

Article Book Effect
Visualizza gli articoli di Joomla con l'effetto volta pagina di un libro. Questo plugin consente di visualizzare il contenuto di un articolo Joomla come un vero e proprio libro o una rivista, utilizzando tutti i vantaggi di HTML5

Scopri di più...  Demo

 

Fototessera

Article Book Effect
La più famosa Android App che ti permette di stampare le foto tessere per i tuoi documenti con il tuo smartphone Android, in modo semplice ed intuitivo.

Scopri di più...

 

Ombra pazza 3D

Ombra pazza 3D
Ombra Pazza è il puzzle game 3D frenetico e divertente per Android! Prova a ruotare le forme portandole nella posizione delle proprie ombre senza mai fallire! Risolvi una dopo l'altra tutte le combinazioni dei livelli di gioco.

Scopri di più...

 

Admin Countdown

Admin Countdown
Modulo per Joomla! 2.5 e 3.x visualizza nella parte di amministrazione del sito, un timer con il conto alla rovescia del tempo rimanente della tua sessione.

Scopri di più...  Demo

 
Benvenuto, Ospite
Nome utente: Password: Ricordami

ARGOMENTO: K2 Integration

K2 Integration 11/11/2015 14:46 #2104

  • Simon C
  • Avatar di Simon C
  • OFFLINE
  • Fresh Boarder
  • Messaggi: 3
  • Ringraziamenti ricevuti 1
Hi.

I have a feature request for JiFile.

I want to use the K2 plugin, which allows me to add attachments to an article.

I would like to use JiFile to be able to search for those attachments.

I can do this already simply by setting JiFile to use the K2 uploads folder. But the search results will take me to the file; I want them to take me to the article that has the file attached.

To change this would require that when JiFile outputs its results links, it look in the K2 data to see if that file is linked to an article, and if so, then change the link to point to the article instead.

Would this be possible to do?
L\'Amministratore ha disattivato l\'accesso in scrittura al pubblico.

K2 Integration 11/11/2015 18:08 #2105

  • Simon C
  • Avatar di Simon C
  • OFFLINE
  • Fresh Boarder
  • Messaggi: 3
  • Ringraziamenti ricevuti 1
Hi.

So I've done some research, and I've written some code to do this. I hope this can be incorporated into the main JiFile product?

You need to edit jifile.php in the the search plugin as follows:

1. Add the following function to this class:
    private function k2Integration($title, $href) {
        require_once(JPATH_SITE.'/components/com_k2/helpers/route.php');
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('i.id, i.alias, i.catid, c.alias as catalias')
              ->from($db->quoteName('#__k2_attachments','a'))
              ->where($db->quoteName('filename').' = '.$db->quote($title))
              ->join('INNER', $db->quoteName('#__k2_items', 'i').' ON '.$db->quoteName('i.id').' = '.$db->quoteName('a.itemID'))
              ->join('INNER', $db->quoteName('#__k2_categories', 'c').' ON '.$db->quoteName('c.id').' = '.$db->quoteName('i.catid'))
              ->where('i.published = 1');
        $db->setQuery($query);
        $db->execute();
        $num_rows = $db->getNumRows();
        if ($num_rows) {
            $k2Item = $db->loadObject();
            $href = JRoute::_(K2HelperRoute::getItemRoute($k2Item->id.':'.urlencode($k2Item->alias), $k2Item->catid.':'.urlencode($k2Item->catalias)));
        }
        return $href;
    }

2. At the end of the onContentSearch() function, there is a block that sets $row = array( ... ). This needs to be changed as follows:
            $href = 'index.php?option=com_jifile&task=download&filename='.JFilterOutput::stringURLSafe($title).'&key='.$key;
            if (JComponentHelper::getComponent('com_k2', true)->enabled) {
                $href = $this->k2Integration($title, $href);
            }
 
            $row = array('title' => $title, 
                        'href' => $href, 
                        'created' => $created, 
                        'browsernav' => 0, 
                        'section' => 'JiFile / '.$extension,
                        'text' => $text);
            $rows[] = JArrayHelper::toObject($row);

ie, the 'href' => '....' value is extracted and moved above the $row = array( ... ) block, and an if() block inserted in between to check if K2 is installed, and if so, to get $href from there instead.

This should allow JiFile to continue working as normal if K2 is not installed, but if K2 is installed, it will try to give a link to the article which has the item attached rather than just linking direct to the article.

Known issues:

- This patch assumes that JiFile is configured to search for files in K2's attachments folder. But I haven't checked for that.
- This patch assumes that if you have K2 installed then you want this behaviour (ideally it would be optional, so you could revert to JiFile's normal behaviour)
- Requires you to manually index the files after attaching them in K2. A good additional feature would be to hook into K2's attachment uploader so it could automatically index new attachments.

Despite these points, I hope someone will find this useful, and I hope the JiFile developers will consider implementing it in the mainline plugin.
Ultima modifica: 12/11/2015 10:06 da Simon C.
L\'Amministratore ha disattivato l\'accesso in scrittura al pubblico.
I seguenti utenti ringraziano:: Giampaolo

K2 Integration 11/11/2015 20:03 #2106

  • Giampaolo
  • Avatar di Giampaolo
  • OFFLINE
  • Administrator
  • Messaggi: 465
  • Ringraziamenti ricevuti 43
Thank you very much for your fantastic topic :woohoo:

We hope to integrate this feature in the next version of JiFile (for now we have integrate this in the TODO list).

Thanks again.
If you like, if it was useful, consider a donation, Thanks
Se vuoi, se ti siamo stati utili, considera una donazione, Grazie
Help us by voting our extensions on Joomla.org:
JiFile
JoomPhoto Mobile
Easy Language
L\'Amministratore ha disattivato l\'accesso in scrittura al pubblico.
I seguenti utenti ringraziano:: Simon C

K2 Integration 12/11/2015 10:09 #2107

  • Simon C
  • Avatar di Simon C
  • OFFLINE
  • Fresh Boarder
  • Messaggi: 3
  • Ringraziamenti ricevuti 1
It's a pleasure. Do you know when the next version will be released? (so that I know whether I should implement my patch locally or wait for you to release it)

Also, is your code posted on Github? I looked for it so I could post this as a pull request, but I didn't find it.

Finally, the mechanism I've used here would probably work for other plugins as well (eg Kunena forums allow attachments); with a bit more work it could be made generic so you could integrate with loads of things. Exciting possibilities.
Ultima modifica: 12/11/2015 10:11 da Simon C.
L\'Amministratore ha disattivato l\'accesso in scrittura al pubblico.