示例#1
0
文件: forme.php 项目: RangerWalt/ecci
function showForm($option, $fid)
{
    global $mainframe, $limitstart, $acl, $formeConfig;
    $my =& JFactory::getUser();
    $processform = JRequest::getVar('form', array(), 'POST');
    $database =& JFactory::getDBO();
    if (!$fid) {
        //get first cid
        $database->setQuery("SELECT id FROM #__forme_forms WHERE published = 1 LIMIT 1");
        $fid = (int) $database->loadResult();
    }
    //check language
    //first check global joomfish
    $check = false;
    if (isset($_COOKIE['mbfcookie']['lang'])) {
        $check = $_COOKIE['mbfcookie']['lang'];
    }
    if (isset($_COOKIE['jfcookie']['lang'])) {
        $check = $_COOKIE['jfcookie']['lang'];
    }
    if (isset($_REQUEST['lang'])) {
        $check = JRequest::getVar('lang', false);
    }
    if ($check) {
        $oldform = new forme_forms($database);
        $oldform->load($fid);
        //check if we find something similar
        $database->setQuery("SELECT id FROM #__forme_forms WHERE lang='{$check}' AND name='{$oldform->name}' ");
        $newfid = $database->loadResult();
        if ($newfid) {
            $fid = $newfid;
        }
    }
    processForm($fid, $processform);
    $query = "SELECT * FROM #__forme_forms WHERE id = '{$fid}' AND published = '1'";
    $database->setQuery($query);
    $form = $database->loadObjectList();
    //load fields
    $query = "SELECT * FROM #__forme_fields WHERE form_id = '{$fid}' AND published = '1' ORDER BY ordering";
    $database->setQuery($query);
    $fields = $database->loadObjectList();
    $form = $form[0];
    if (!$form->published) {
        $mainframe->redirect(JURI::base(), _NOT_EXIST);
    }
    //Output
    forme_HTML::showForm($option, $form, $fields);
}
示例#2
0
function listdata($option, $cid)
{
    global $limit, $limitstart;
    $database =& JFactory::getDBO();
    $cid = intval($cid);
    if (!$cid) {
        //get first cid
        $database->setQuery("SELECT id FROM #__forme_forms LIMIT 1");
        $cid = (int) $database->loadResult();
    }
    //build forms selectlist
    $database->setQuery("SELECT id as value, title as text FROM #__forme_forms");
    $forms = array();
    $forms[] = JHTML::_('select.option', '0', _FORME_BACKEND_LISTDATA_FORMS . ' ');
    $forms = array_merge($forms, $database->loadObjectList());
    $database->SetQuery("SELECT count(*)" . "\nFROM #__forme_data AS d" . "\nWHERE d.form_id = {$cid}");
    $total = $database->loadResult();
    echo $database->getErrorMsg();
    $pageNav = new mosPageNav($total, $limitstart, $limit);
    $query = "SELECT d.*" . "\nFROM #__forme_data AS d" . "\nWHERE d.form_id = {$cid}" . "\nORDER BY d.date_added DESC";
    $database->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $database->loadObjectList();
    //load form
    $form = new forme_forms($database);
    $form->load($cid);
    //select fields
    $query = "SELECT * FROM #__forme_fields WHERE form_id = '{$cid}' AND published=1 AND inputtype!='free text' ORDER BY ordering";
    $database->setQuery($query);
    $fields = $database->loadObjectList();
    $distinct_fields = array();
    foreach ($fields as $field) {
        $distinct_fields[$field->name] = $field;
    }
    $form->fields = $distinct_fields;
    forme_HTML::listdata($option, $rows, $form, $forms, $pageNav);
}