static function listitems($option, $pkg)
 {
     $database = JFactory::getDBO();
     $database->setQuery("select distinct  package as name " . "from #__facileforms_scripts " . "where package is not null and package!='' " . "order by name");
     $pkgs = $database->loadObjectList();
     if ($database->getErrorNum()) {
         echo $database->stderr();
         return false;
     }
     $pkgok = $pkg == '';
     if (!$pkgok && count($pkgs)) {
         foreach ($pkgs as $p) {
             if ($p->name == $pkg) {
                 $pkgok = true;
                 break;
             }
         }
     }
     if (!$pkgok) {
         $pkg = '';
     }
     $pkglist = array();
     $pkglist[] = array($pkg == '', '');
     if (count($pkgs)) {
         foreach ($pkgs as $p) {
             $pkglist[] = array($p->name == $pkg, $p->name);
         }
     }
     $database->setQuery("select * from #__facileforms_scripts " . "where package =  " . $database->Quote($pkg) . " " . "order by type, name, id desc");
     $rows = $database->loadObjectList();
     if ($database->getErrorNum()) {
         echo $database->stderr();
         return false;
     }
     HTML_facileFormsScript::listitems($option, $rows, $pkglist);
 }
    static function listitems($option, &$rows, &$pkglist)
    {
        global $ff_config, $ff_version;
        ?>
		<script type="text/javascript">
			<!--
			function submitbutton(pressbutton)
			{
				var form = document.adminForm;
				switch (pressbutton) {
					case 'copy':
					case 'publish':
					case 'unpublish':
					case 'remove':
						if (form.boxchecked.value==0) {
							alert("<?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_SELSCRIPTSFIRST');
        ?>
");
							return;
						} // if
						break;
					default:
						break;
				} // switch
				if (pressbutton == 'remove')
					if (!confirm("<?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_ASKDELETE');
        ?>
")) return;
				if (pressbutton == '' && form.pkgsel.value == '')
					form.pkg.value = '- blank -';
				else
					form.pkg.value = form.pkgsel.value;
				submitform(pressbutton);
			} // submitbutton

			function listItemTask( id, task )
			{
				var f = document.adminForm;
				cb = eval( 'f.' + id );
				if (cb) {
					for (i = 0; true; i++) {
						cbx = eval('f.cb'+i);
						if (!cbx) break;
						cbx.checked = false;
					} // for
					cb.checked = true;
					f.boxchecked.value = 1;
					submitbutton(task);
				}
				return false;
			} // listItemTask
			//-->
		</script>
		<form action="index.php" method="post" name="adminForm" id="adminForm">
		<table cellpadding="4" cellspacing="1" border="0">
			<tr>
				<td width="50%" nowrap>
					<table class="adminheading">
						<tr><th nowrap class="sections">BreezingForms <?php 
        echo $ff_version;
        ?>
<br/><span class="componentheading"><?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_MANAGESCRIPTS');
        ?>
</span></th></tr>
					</table>
				</td>
				<td nowrap>
					<?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_PACKAGE');
        ?>
:
					<select id="pkgsel" name="pkgsel" class="inputbox" size="1" onchange="submitbutton('');">
<?php 
        if (count($pkglist)) {
            foreach ($pkglist as $pkg) {
                $selected = '';
                if ($pkg[0]) {
                    $selected = ' selected';
                }
                echo '<option value="' . $pkg[1] . '"' . $selected . '>' . $pkg[1] . '&nbsp;</option>';
            }
        }
        // foreach
        ?>
					</select>
				</td>
				<td align="right" width="50%" nowrap>
<?php 
        JToolBarHelper::custom('new', 'new.png', 'new_f2.png', BFText::_('COM_BREEZINGFORMS_TOOLBAR_NEW'), false);
        JToolBarHelper::custom('copy', 'copy.png', 'copy_f2.png', BFText::_('COM_BREEZINGFORMS_TOOLBAR_COPY'), false);
        JToolBarHelper::custom('publish', 'publish.png', 'publish_f2.png', BFText::_('COM_BREEZINGFORMS_TOOLBAR_PUBLISH'), false);
        JToolBarHelper::custom('unpublish', 'unpublish.png', 'unpublish_f2.png', BFText::_('COM_BREEZINGFORMS_TOOLBAR_UNPUBLISH'), false);
        JToolBarHelper::custom('remove', 'delete.png', 'delete_f2.png', BFText::_('COM_BREEZINGFORMS_TOOLBAR_DELETE'), false);
        ?>
				</td>
			</tr>
		</table>
		<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist table table-striped">
			<tr>
				<th nowrap align="center"><input type="checkbox" name="toggle" value="" onclick="<?php 
        $version = new JVersion();
        echo version_compare($version->getShortVersion(), '3.0', '>=') ? 'Joomla.checkAll(this);' : 'checkAll(' . count($rows) . ');';
        ?>
" /></th>
				<th nowrap align="left"><?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_TITLE');
        ?>
</th>
				<th nowrap align="left"><?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_NAME');
        ?>
</th>
				<th nowrap align="left"><?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_TYPE');
        ?>
</th>
				<th nowrap align="right">ID</th>
				<th nowrap align="center"><?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_PUBLISHED');
        ?>
</th>
				<th align="left" width="100%"><?php 
        echo BFText::_('COM_BREEZINGFORMS_SCRIPTS_DESCRIPTION');
        ?>
</th>
			</tr>
<?php 
        $k = 0;
        for ($i = 0; $i < count($rows); $i++) {
            $row = $rows[$i];
            $desc = $row->description;
            if (strlen($desc) > $ff_config->limitdesc) {
                $desc = substr($desc, 0, $ff_config->limitdesc) . '...';
            }
            ?>
				<tr class="row<?php 
            echo $k;
            ?>
">
					<td nowrap valign="top" align="center"><input type="checkbox" id="cb<?php 
            echo $i;
            ?>
" name="ids[]" value="<?php 
            echo $row->id;
            ?>
" onclick="<?php 
            jimport('joomla.version');
            $version = new JVersion();
            echo version_compare($version->getShortVersion(), '3.0', '>=') ? 'Joomla.isChecked(this.checked);' : 'isChecked(this.checked);';
            ?>
" /></td>
					<td nowrap valign="top" align="left"><a href="#edit" onclick="return listItemTask('cb<?php 
            echo $i;
            ?>
','edit')"><?php 
            echo $row->title;
            ?>
</a></td>
					<td nowrap valign="top" align="left"><?php 
            echo $row->name;
            ?>
</td>
					<td nowrap valign="top" align="left"><?php 
            echo HTML_facileFormsScript::typeName($row->type);
            ?>
</td>
					<td nowrap valign="top" align="right"><?php 
            echo $row->id;
            ?>
</td>
					<td nowrap valign="top" align="center"><?php 
            if ($row->published == "1") {
                ?>
<a href="#" onClick="return listItemTask('cb<?php 
                echo $i;
                ?>
','unpublish')"><img src="components/com_breezingforms/images/icons/publish_g.png" alt="+" border="0" /></a><?php 
            } else {
                ?>
<a href="#" onClick="return listItemTask('cb<?php 
                echo $i;
                ?>
','publish')"><img src="components/com_breezingforms/images/icons/publish_x.png" alt="-" border="0" /></a><?php 
            }
            // if
            ?>
</td>
					<td valign="top" align="left"><?php 
            echo htmlspecialchars($desc, ENT_QUOTES);
            ?>
</td>
				</tr>
<?php 
            $k = 1 - $k;
        }
        // for
        ?>
		</table>
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
		<input type="hidden" name="act" value="managescripts" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="pkg" value="" />
		</form>
<?php 
    }