/** * Render * * @return void * @access public */ function render() { // TODO tradurre le label $output = ''; $output .= '<table id="' . $this->getId() . '" class="js-modulesManager ' . $this->getAttribute('cssClass') . '">'; if ($this->getAttribute('label') != '') { $output .= '<caption>' . $this->getAttribute('label') . '</caption>'; } // disegna le colonne $output .= '<thead>'; $output .= '<tr>'; $output .= '<th class="name">Plugin</th>'; $output .= '<th>Descrizione</th>'; $output .= '<th class="actions"></th>'; $output .= '</tr>'; $output .= '<tfoot><tr><td colspan="3"></td></tr></tfoot>'; $output .= '<tbody>'; $origCssClass = explode(',', $this->getAttribute('cssClass')); $tempCssClass = array(); $modulesState = org_glizy_Modules::getModulesState(); $modules = org_glizy_Modules::getModules(); $this->sort($modules); foreach ($modules as $m) { // $moduleDescription = org_glizy_ObjectFactory::createObject( 'org.glizy.ModuleDescription', $m ); // if ( !empty( $m->pageType ) ) continue; $isEnabled = !isset($modulesState[$m->id]) || $modulesState[$m->id]; if (!count($tempCssClass)) { $tempCssClass = $origCssClass; } $cssClass = array_shift($tempCssClass); $cssClass .= ' ' . ($isEnabled ? 'enabled' : 'disabled'); $output .= '<tr class="' . $cssClass . '">' . '<td class="name">' . __T($m->name) . '</td>' . '<td>' . '<p class="description">' . $m->description . '</p>' . '<p class="info">Versione ' . $m->version . ' | ' . __Link::makeLink2(null, array('label' => $m->author, 'title' => 'Visita il sito dell\'autore', 'url' => $m->authorUrl, 'rel' => 'external')) . ' | ' . __Link::makeLink2(null, array('label' => 'Visita il sito del plugin', 'url' => $m->pluginUrl, 'rel' => 'external')) . '</p>' . '</td>' . '<td class="actions">' . (!$isEnabled ? '<a href="" data-action="enable" data-id="' . $m->id . '" class="js-modulesManagerAction action">abilita</a>' : '') . ($isEnabled ? '<a href="" data-action="disable" data-id="' . $m->id . '" class="js-modulesManagerAction action">disabilita</a>' : '') . ' ' . ($m->canDuplicated ? '<a href="' . __Routing::makeUrl('glizycmsModuleManagerDuplicate', array('pageId' => $this->pageId, 'id' => $m->id)) . '" class="action">duplica</a>' : '') . '</td>' . '</tr>'; } $output .= '</tbody>'; $output .= '</table>'; $output .= <<<EOD <script type="text/javascript"> jQuery(document).ready(function() { \t\$("table.js-modulesManager a.js-modulesManagerAction ").click( function( e ){ \t\te.stopPropagation(); \t\tif ( jQuery( this ).data( "action" ) == "uninstall" ) \t\t{ \t\t\tif ( !confirm( "Sei sicuro di voler rimuovere il plugin?") ) \t\t\t{ \t\t\t\treturn false; \t\t\t} \t\t} \t\t// jQuery.modal('<div></div>', { \t\t// \tclose: false, \t\t// \toverlayCss:{ \t\t// \t\tbackgroundColor:"#000" \t\t// \t}, \t\t// \toverlayClose: false \t\t// }); \t\tjQuery.ajax( { url: Glizy.ajaxUrl+jQuery( this ).data( "action" ), \t\t\t\t\ttype: 'POST', \t\t\t\t\tdata: { id: jQuery( this ).data( "id" ) }, \t\t\t\t\tsuccess: function( response, r, a ) { \t\t\t\t\t\tlocation.reload(); \t\t\t\t\t}}); \t\treturn false; \t}); }); </script> EOD; $this->addOutputCode($output); }