* This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/
// no direct access
defined('_JEXEC') or die('Restricted Access');
JHTML::_('behavior.modal');
$params =& JComponentHelper::getParams('com_joomailermailchimpintegration');
$paramsPrefix = version_compare(JVERSION, '1.6.0', 'ge') ? 'params.' : '';
$MCapi = $params->get($paramsPrefix . 'MCapi');
$MCauth = new MCauth();
$jversion = version_compare(JVERSION, '1.6.0', 'ge') ? '16' : '15';
$template_folders = Jfolder::listFolderTree('../administrator/components/com_joomailermailchimpintegration/templates/', '', 1);
if (!$MCapi) {
    echo '<table>';
    echo $MCauth->apiKeyMissing();
} else {
    if (!$MCauth->MCauth()) {
        echo '<table>';
        echo $MCauth->apiKeyMissing(1);
    } else {
        if (!$template_folders[0]) {
            echo '<form action="index.php?option=com_joomailermailchimpintegration&view=templates" method="post" name="adminForm">';
            echo JText::_('JM_NO_TEMPLATES');
        } else {
            ?>
<form action="index.php?option=com_joomailermailchimpintegration&view=templates" method="post" name="adminForm">
<div class="col100">
 function getImagesDropdown()
 {
     $dropdown = '<select name="fbImage" id="fbImage">';
     jimport('joomla.filesystem.file');
     $dropdown .= '<optgroup label="images">';
     $images = Jfolder::files('../images', '.', false, false, array('index.html'));
     foreach ($images as $image) {
         $dropdown .= '<option value="images/' . $image . '">' . $image . '</option>';
     }
     $dropdown .= '</optgroup>';
     $imageFolders = Jfolder::listFolderTree('../images/', '', 1);
     foreach ($imageFolders as $folder) {
         $images = Jfolder::files($folder["fullname"], '.', true, false, array('index.html'));
         if ($images) {
             $dropdown .= '<optgroup label="' . str_replace('../', '', $folder["fullname"]) . '">';
             foreach ($images as $image) {
                 $dropdown .= '<option value="' . str_replace('../', '', $folder["fullname"]) . $image . '">' . $image . '</option>';
             }
             $dropdown .= '</optgroup>';
         }
     }
     $dropdown .= '</select>';
     return $dropdown;
 }