Exemplo n.º 1
0
            $standardAccount = $us->getProperty("csvImportStandardAccount");
        } catch (BadgerException $ex) {
            $standardAccount = '';
        }
        $accountSelectFile = $widgets->createSelectField("accountSelect", $account, $standardAccount, getBadgerTranslation2("importCsv", "toolTopAccountSelect"), true, "onchange='updateParser();'");
        $selectParserLabel = $widgets->createLabel("parserSelect", getBadgerTranslation2("importCsv", "selectParser") . ":", true);
        /*
            		//sql to get CSV Parsers
        	    	$sql = "SELECT * FROM csv_parser";
        	      	$parser = array();
        	      	$res =& $badgerDb->query($sql);
        	      	while ($res->fetchInto ($row)){ 
        	      		$parser[$row[2]] = $row[1];
        	      	}
        */
        $parser = getParsers();
        $selectParserFile = $widgets->createSelectField("parserSelect", $parser, null, getBadgerTranslation2("importCsv", "toolTipParserSelect"));
        $uploadButton = $widgets->createButton("Upload", getBadgerTranslation2("importCsv", "upload"), "submit", "Widgets/table_save.gif");
        //use tempate engine
        eval("echo \"" . $tpl->getTemplate("CsvImport/csvImportSelectFileForm") . "\";");
    }
}
if (isset($_POST['Upload'])) {
    $uploadTitle = getBadgerTranslation2('importCsv', 'uploadTitle');
    // for every file
    foreach ($_FILES as $file_name => $file_array) {
        //if a file is chosen
        if (isset($_POST["file"])) {
            #eval("echo \"".$tpl->getTemplate("CsvImport/csvImportWarning")."\";");
        }
        if (is_uploaded_file($file_array['tmp_name'])) {
function printFrontend()
{
    global $pageTitle;
    global $tpl;
    global $am;
    global $redirectPageAfterSave;
    $widgets = new WidgetEngine($tpl);
    $widgets->addToolTipJS();
    $widgets->addJSValMessages();
    $tpl->addJavaScript("js/prototype.js");
    $tpl->addOnLoadEvent("Form.focusFirstElement('mainform')");
    $tpl->addJavaScript("js/account.js");
    $widgets->addNavigationHead();
    if (isset($_GET['ID'])) {
        $pageTitle = getBadgerTranslation2('accountAccount', 'pageTitleProp');
    } else {
        $pageTitle = getBadgerTranslation2('accountAccount', 'pageTitlePropNew');
    }
    echo $tpl->getHeader($pageTitle);
    echo $widgets->addToolTipLayer();
    if (isset($_GET['ID'])) {
        //edit: load values for this ID
        $ID = getGPC($_GET, 'ID', 'integer');
        $account = $am->getAccountById($ID);
        $titleValue = $account->getTitle();
        $descriptionValue = $account->getDescription();
        $lowerLimitValue = is_null($tmp = $account->getLowerLimit()) ? '' : $tmp->getFormatted();
        $upperLimitValue = is_null($tmp = $account->getUpperLimit()) ? '' : $tmp->getFormatted();
        $balanceValue = is_null($tmp = $account->getBalance()) ? '' : $tmp->getFormatted();
        $currencyValue = $account->getCurrency()->getId();
        $deleteOldPlannedTransactionsValue = $account->getDeleteOldPlannedTransactions() == false ? 'checked="checked"' : '';
        $csvParserValue = $account->getCsvParser();
    } else {
        //new: empty values
        $ID = "new";
        $account = "";
        $titleValue = "";
        $descriptionValue = "";
        $lowerLimitValue = "";
        $upperLimitValue = "";
        $balanceValue = "";
        $currencyValue = "";
        $deleteOldPlannedTransactionsValue = 'checked="checked"';
        $csvParserValue = '';
    }
    //set vars with values
    $FormAction = $_SERVER['PHP_SELF'];
    $legend = getBadgerTranslation2('accountAccount', 'legend');
    $hiddenID = $widgets->createField("hiddenID", 20, $ID, "", false, "hidden");
    $pageHeading = $pageTitle;
    //Fields & Labels
    $titleLabel = $widgets->createLabel("title", getBadgerTranslation2('accountAccount', 'title'), true);
    $titleField = $widgets->createField("title", 30, $titleValue, "", true, "text", "style='width: 30ex;'");
    $descriptionLabel = $widgets->createLabel("description", getBadgerTranslation2('accountAccount', 'description'), false);
    $descriptionField = $widgets->createTextarea("description", $descriptionValue, "", false, "style='width: 30ex; height: 5em;'");
    $lowerLimitLabel = $widgets->createLabel("lowerLimit", getBadgerTranslation2('accountAccount', 'lowerLimit'), false);
    $lowerLimitField = $widgets->createField("lowerLimit", 30, $lowerLimitValue, "", false, "text", "style='width: 30ex;' regexp='BADGER_NUMBER'");
    $upperLimitLabel = $widgets->createLabel("upperLimit", getBadgerTranslation2('accountAccount', 'upperLimit'), false);
    $upperLimitField = $widgets->createField("upperLimit", 30, $upperLimitValue, "", true, "text", "style='width: 30ex;' regexp='BADGER_NUMBER'");
    $currencyLabel = $widgets->createLabel("currency", getBadgerTranslation2('accountAccount', 'currency'), true);
    $currencies = getCurrencyArray('symbol');
    $currencyField = $widgets->createSelectField("currency", $currencies, $default = $currencyValue, "", false, "style='width: 31ex;'");
    $deleteOldPlannedTransactionsLabel = $widgets->createLabel('deleteOldPlannedTransactions', getBadgerTranslation2('accountAccount', 'deleteOldPlannedTransactions'), false);
    $deleteOldPlannedTransactionsField = $widgets->createField('deleteOldPlannedTransactions', 30, 'on', getBadgerTranslation2('accountAccount', 'deleteOldPlannedTransactionsDescription'), false, 'checkbox', $deleteOldPlannedTransactionsValue);
    $csvParserLabel = $widgets->createLabel('csvParser', getBadgerTranslation2('accountAccount', 'csvParser'), false);
    $csvParsers = getParsers();
    $csvParsers = array_merge(array('NULL' => getBadgerTranslation2('accountAccount', 'csvNoParser')), $csvParsers);
    $csvParserField = $widgets->createSelectField('csvParser', $csvParsers, $csvParserValue, '', false, "style='width: 31ex;'");
    //Buttons
    $submitBtn = $widgets->createButton("submitBtn", getBadgerTranslation2('dataGrid', 'save'), "submit", "Widgets/accept.gif", "accesskey='s'");
    $backBtn = $widgets->createButton("backBtn", getBadgerTranslation2('dataGrid', 'back'), "location.href='{$redirectPageAfterSave}';return false;", "Widgets/back.gif");
    //add vars to template, print site
    eval("echo \"" . $tpl->getTemplate("Account/Account") . "\";");
    eval("echo \"" . $tpl->getTemplate("badgerFooter") . "\";");
}
Exemplo n.º 3
0
        $this->bgColor = $bgColor;
        $this->url = $url;
        $this->className = $className;
    }
    public $name;
    public $bgColor;
    public $fgColor;
    public $className;
    public $url;
}
function getParsers()
{
    $basePath = './parsers';
    $i = 0;
    if ($handle = opendir($basePath)) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != ".." && stripos($entry, '.php') !== false) {
                include_once "{$basePath}/" . $entry;
                $className = str_ireplace('.php', '', $entry);
                $obj = new $className();
                $colors = $obj->getFgAndBgColor();
                $parsers[$i] = new SerializedParser($obj->getSourceName(), $colors['fg'], $colors['bg'], $obj->getSiteUrl(), $className);
                $i++;
            }
        }
        closedir($handle);
        return json_encode($parsers);
    }
}
echo getParsers();