$entries = array();
$rowclass = 'row1';
foreach ($plugins as $plugin => $parameters) {
    $entry = new stdClass();
    $entry->name = $plugin;
    $entry->path = $parameters['path'];
    //	$entry->field = $this->CreateInputCheckbox($id, $plugin, 1, (isset($params['is_submitted'])) ? $params[$plugin] : $this->GetPreference($plugin, 0));
    if (isset($parameters['active']) && $parameters['active']) {
        $entry->active = $this->CreateLink($id, 'managePlugin', $returnid, $this->getIcon('connect.png', $this->Lang('desactivate')), array('plugin' => $plugin, 'plugin_action' => 'change_state'));
    } else {
        $entry->active = $this->CreateLink($id, 'managePlugin', $returnid, $this->getIcon('disconnect.png', $this->Lang('activate')), array('plugin' => $plugin, 'plugin_action' => 'change_state'));
    }
    $entry->deletelink = $this->CreateLink($id, 'deletePlugin', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/delete.gif', $this->Lang('delete_plugin'), '', '', 'systemicon'), array('plugin' => $plugin), $this->Lang('areyousure'));
    $entry->rowclass = $rowclass;
    $rowclass == "row1" ? $rowclass = "row2" : ($rowclass = "row1");
    $entries[] = $entry;
}
/*$this->smarty->assign('plugins_startform', $this->CreateFormStart($id, 'defaultadmin', $returnid));
$this->smarty->assign('plugins_endform', $this->CreateFormEnd());
$this->smarty->assign('is_submitted',$this->CreateInputHidden($id, 'is_submitted', '1'));
$this->smarty->assign('submit_button',$this->CreateInputSubmit($id, 'submit', 'Update plugins'));*/
$this->smarty->assign('is_active', $this->lang('is active'));
$this->smarty->assign('title_plugin', $this->Lang('title_plugin'));
$this->smarty->assign('title_path', $this->Lang('title_path'));
$this->smarty->assign('plugins', $entries);
// OPTIONS
$form = new jQueryForm('jQuery', $id, 'defaultadmin', $returnid);
$form->setWidget('active_tab', 'hidden', array('value' => 'options'));
$form->setWidget('autoload', 'checkbox', array('preference' => 'autoload'));
$this->smarty->assign('form', $form);
echo $this->ProcessTemplate('adminpanel.tpl');
}
if (isset($params['delete'])) {
    $script->delete();
    return $this->Redirect($id, 'defaultadmin', $returnid, array('active_tab' => 'scripts'));
}
if (isset($params['load_default_state'])) {
    $script->setLoadDefault(!$script->getLoadDefault());
    $script->save();
    return $this->Redirect($id, 'defaultadmin', $returnid, array('active_tab' => 'scripts'));
}
if (isset($params['in_header_state'])) {
    $script->setInHeader(!$script->getInHeader());
    $script->save();
    return $this->Redirect($id, 'defaultadmin', $returnid, array('active_tab' => 'scripts'));
}
$form = new jQueryForm('jQuery', $id, 'manageScript', $returnid);
//$form->setLabel('submit',$this->lang('save'));
//$form->setLabel('apply',$this->lang('save_continue'));
$form->setButtons(array('submit', 'apply', 'cancel'));
$form->setWidget('script_id', 'hidden', array('object' => &$script, 'field_name' => 'id'));
$form->setWidget('name', 'text', array('object' => &$script));
$form->setWidget('code', 'textarea', array('object' => &$script));
$form->setWidget('load_default', 'checkbox', array('object' => &$script));
$form->setWidget('in_header', 'checkbox', array('object' => &$script));
$form->setWidget('required_plugins', 'text', array('object' => &$script));
if (isset($params['submit']) || isset($params['apply'])) {
    $script->save();
    $form->getWidget('script_id')->setValues($script->getId());
    if (isset($params['submit'])) {
        return $this->Redirect($id, 'defaultadmin', $returnid, array('active_tab' => 'scripts'));
    }