예제 #1
1
 function handle(&$params)
 {
     if (!@$_REQUEST['email']) {
         return PEAR::raiseError("No email address  specified");
     }
     import('HTML/QuickForm.php');
     $form = new HTML_QuickForm('opt_out_form', 'post');
     $form->addElement('hidden', 'email', $_REQUEST['email']);
     $form->addElement('hidden', '-action', 'email_opt_out');
     $form->addElement('submit', 'submit', 'Cancel Subscription');
     if ($form->validate()) {
         $res = mysql_query("replace into dataface__email_blacklist (email) values ('" . addslashes($_REQUEST['email']) . "')", df_db());
         if (!$res) {
             trigger_error(mysql_error(df_db()), E_USER_ERROR);
         }
         header('Location: ' . DATAFACE_SITE_HREF . '?--msg=' . urlencode('You have successfully opted out of our mail list.  You will no longer receive emails from us.'));
         exit;
     }
     ob_start();
     $form->display();
     $html = ob_get_contents();
     ob_end_clean();
     $context = array();
     $context['form'] = $html;
     df_register_skin('email', DATAFACE_PATH . '/modules/Email/templates');
     df_display($context, 'email/opt_out_form.html');
 }
예제 #2
0
 function handle($params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     if (!isset($query['-relationship'])) {
         return PEAR::raiseError("No relationship specified.");
     }
     $table =& Dataface_Table::loadTable($query['-table']);
     $record =& $app->getRecord();
     if (!$record) {
         return Dataface_Error::permissionDenied("No record found");
     }
     $perms = $record->getPermissions(array('relationship' => $query['-relationship']));
     if (!@$perms['view related records']) {
         return Dataface_Error::permissionDenied('You don\'t have permission to view this relationship.');
     }
     $action = $table->getRelationshipsAsActions(array(), $query['-relationship']);
     if (isset($query['-template'])) {
         df_display(array('record' => $record), $query['-template']);
     } else {
         if (isset($action['template'])) {
             df_display(array('record' => $record), $action['template']);
         } else {
             df_display(array('record' => $record), 'Dataface_Related_Records_List.html');
         }
     }
 }
예제 #3
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $record =& $app->getRecord();
     $query =& $app->getQuery();
     if (!isset($query['--subsearch'])) {
         $query['--subsearch'] = '';
     }
     $results = array();
     foreach ($record->_table->relationships() as $rname => $r) {
         $fields = $r->fields(true);
         $qstr = array();
         foreach ($fields as $field) {
             //list($tname, $field) = explode('.', $field);
             $qstr[] = '`' . str_replace('`', '', $field) . "` LIKE '%" . addslashes($query['--subsearch']) . "%'";
         }
         $qstr = implode(' OR ', $qstr);
         $results[$rname] = $record->getRelatedRecordObjects($rname, 0, 10, $qstr);
         unset($r);
         unset($fields);
     }
     if (@$query['--format'] == 'RSS2.0') {
         $this->handleRSS($results);
     } else {
         df_display(array('results' => &$results, 'queryString' => $query['--subsearch']), 'Dataface_single_record_search.html');
     }
 }
예제 #4
0
 public function handle($params)
 {
     $uitk = Dataface_ModuleTool::getInstance()->loadModule('modules_uitk');
     $uitk->registerPaths();
     Dataface_JavascriptTool::getInstance()->import('swete/actions/import_translations.js');
     df_display(array(), 'swete/actions/import_translations.html');
 }
예제 #5
0
파일: history.php 프로젝트: promoso/HVAC
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $record =& $app->getRecord();
     $context = array();
     if (!$record) {
         return PEAR::raiseError("No record is currently selected", DATAFACE_E_ERROR);
     }
     $history_tablename = $record->_table->tablename . '__history';
     if (!Dataface_Table::tableExists($history_tablename)) {
         $context['error'] = PEAR::raiseError("This record has no history yet recorded.", DATAFACE_E_NOTICE);
     } else {
         import('Dataface/HistoryTool.php');
         $history_tool = new Dataface_HistoryTool();
         $history_log = $history_tool->getHistoryLog($record);
         $context['log'] =& $history_log;
         // let's make a query string for the current record
         //current_record_qstr
         $keys = array_keys($record->_table->keys());
         $qstr = array();
         foreach ($keys as $key) {
             $qstr[] = urlencode('--__keys__[' . $key . ']') . '=' . urlencode($record->strval($key));
         }
         $context['current_record_qstr'] = implode('&', $qstr);
     }
     df_display($context, 'Dataface_RecordHistory.html');
 }
예제 #6
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('xataface/view/tests/test_MasterDetailView.js');
     df_display(array(), 'xataface/tests/test_MasterDetailView.html');
 }
 function handle($params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $record =& $app->getRecord();
     if (!$record) {
         return PEAR::raiseError("No record found.", DATAFACE_E_NOTICE);
     }
     if (!isset($query['-relationship'])) {
         return PEAR::raiseError("No relationship specified.");
     }
     $table =& Dataface_Table::loadTable($query['-table']);
     $action = $table->getRelationshipsAsActions(array(), $query['-relationship']);
     if (@$action['permission'] and !$record->checkPermission($action['permission'])) {
         return Dataface_Error::permissionDenied();
     }
     ob_start();
     import('Dataface/RelationshipCheckboxForm.php');
     $form = new Dataface_RelationshipCheckboxForm($record, $query['-relationship']);
     $out = ob_get_contents();
     ob_end_clean();
     if (isset($query['-template'])) {
         df_display(array('form' => $out), $query['-template']);
     } else {
         if (isset($action['template'])) {
             df_display(array('form' => $out), $action['template']);
         } else {
             df_display(array('form' => $out), 'Dataface_related_records_checkboxes.html');
         }
     }
 }
예제 #8
0
파일: find.php 프로젝트: minger11/Pipeline
 function handle($params)
 {
     import('Dataface/SearchForm.php');
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $new = true;
     $form = new Dataface_SearchForm($query['-table'], $app->db(), $query);
     $res = $form->_build();
     if (PEAR::isError($res)) {
         trigger_error($res->toString() . Dataface_Error::printStackTrace(), E_USER_ERROR);
     }
     /*
      *
      * We need to add the current GET parameter flags (the GET vars starting with '-') so
      * that the controller knows to pass control to this method again upon form submission.
      *
      */
     $form->setDefaults(array('-action' => $query['-action']));
     if ($form->validate()) {
         $res = $form->process(array(&$form, 'performFind'));
     }
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('find.js');
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $context = array('form' => &$out);
     df_display($context, 'Dataface_Find_View.html', true);
 }
예제 #9
0
 function handle(&$params)
 {
     try {
         $app = Dataface_Application::getInstance();
         $query =& $app->getQuery();
         $jt = Dataface_JavascriptTool::getInstance();
         $jt->import('swete/ui/filter_translations.js');
         $app->addHeadContent('<link rel="stylesheet" type="text/css" href="css/swete/actions/review_translations.css"/>');
         if (!@$query['-recordid']) {
             throw new Exception("No record id was specified");
         }
         $record = df_get_record_by_id($query['-recordid']);
         $job = new SweteJob($record);
         $tm = XFTranslationMemory::loadTranslationMemoryFor($record, $record->val('source_language'), $record->val('destination_language'));
         $translations = $job->getTranslations();
         $template = 'swete/actions/review_translations.html';
         if (@$query['-isDialog']) {
             $template = 'swete/actions/review_translations_dlg.html';
         }
         df_display(array('job' => $job, 'translations' => $translations), $template);
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
예제 #10
0
파일: GlanceList.php 프로젝트: promoso/HVAC
 function toHtml()
 {
     ob_start();
     df_display(array('records' => &$this->records, 'list' => &$this), 'Dataface_GlanceList.html');
     $out = ob_get_contents();
     ob_end_clean();
     return $out;
 }
예제 #11
0
파일: Portlet.php 프로젝트: Zunair/xataface
 public function toHtml()
 {
     \Dataface_JavascriptTool::getInstance()->import('xataface/components/Portlet.js');
     ob_start();
     df_display(array('portlet' => $this), 'xataface/components/Portlet.html');
     $contents = ob_get_contents();
     ob_end_clean();
     return $contents;
 }
예제 #12
0
 function handle($params)
 {
     $js = Dataface_JavascriptTool::getInstance();
     $js->import('tests/doctest.js');
     $js->setMinify(false);
     $js->setUseCache(false);
     df_register_skin('xatajax', XATAJAX_PATH . DIRECTORY_SEPARATOR . 'templates');
     df_display(array(), 'tests/doctest.html');
 }
예제 #13
0
 function installationForm($params, $env)
 {
     //if ( $this->step != __FUNCTION__ ) return false;
     if (isset($_POST['--process-installationForm'])) {
         $required = array('host', 'name', 'user');
     }
     df_display(array('pipeline_vars' => &$env, 'params' => &$params, 'validation_result' => &$res, 'repository_apps' => array()), 'installationForm.html');
     return;
 }
예제 #14
0
    function handle(&$params)
    {
        $app =& Dataface_Application::getInstance();
        $tt = new Dataface_TranslationTool();
        if (!Dataface_Table::tableExists('dataface__translation_submissions', false)) {
            $tt->createTranslationSubmissionsTable();
            header('Location: ' . $app->url(''));
            exit;
        }
        if (!@$_POST['--submit']) {
            df_display(array('query' => $app->getQuery(), 'success' => @$_REQUEST['--success']), 'Dataface_submit_translation.html');
            exit;
        } else {
            if (@$_POST['subject']) {
                // This is a dummy field - possible hacking attempt
                header('Location: ' . $app->url('-action=list'));
                exit;
            }
            if (@$_POST['--recordid']) {
                $record = df_get_record_by_id($_POST['--recordid']);
                $values = array('record_id' => @$_POST['--recordid'], 'language' => @$_POST['--language'], 'url' => @$_POST['--url'], 'original_text' => @$_POST['--original_text'], 'translated_text' => @$_POST['--translated_text'], 'translated_by' => @$_POST['--translated_by']);
                $trec = new Dataface_Record('dataface__translation_submissions', array());
                $trec->setValues($values);
                $trec->save();
                $email = <<<END
 The following translation was submitted to the web site {$app->url('')}:
 
 Translation for record {$record->getTitle()} which can be viewed at {$record->getURL('-action=view')}.
 This translation was submitted by {$_POST['--translated_by']} after viewing the content at {$_POST['--url']}.
 
 The original text that was being translated is as follows:
 
 {$_POST['--original_text']}
 
 The translation proposed by this person is as follows:
 
 {$_POST['--translated_text']}
 
 For more details about this translation, please visit {$trec->getURL('-action=view')}.
END;
                if (@$app->_conf['admin_email']) {
                    mail($app->_conf['admin_email'], 'New translation submitted', $email);
                }
                if (@$_POST['--redirect'] || @$_POST['--url']) {
                    $url = @$_POST['--redirect'] ? $_POST['--redirect'] : $_POST['--url'];
                    header('Location: ' . $url . '&--msg=' . urlencode('Thank you for your submission.'));
                    exit;
                } else {
                    header('Location: ' . $app->url('') . '&--success=1&--msg=' . urlencode('Thank you for your submission.'));
                    exit;
                }
            } else {
                trigger_error("No record id was provided", E_USER_ERROR);
            }
        }
    }
예제 #15
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $this->table =& Dataface_Table::loadTable($query['-table']);
     $translations =& $this->table->getTranslations();
     foreach (array_keys($translations) as $trans) {
         $this->table->getTranslation($trans);
     }
     //print_r($translations);
     if (!isset($translations) || count($translations) < 2) {
         // there are no translations to be made
         trigger_error('Attempt to translate a record in a table "' . $this->table->tablename . '" that contains no translations.', E_USER_ERROR);
     }
     $this->translatableLanguages = array_keys($translations);
     $translatableLanguages =& $this->translatableLanguages;
     $this->languageCodes = new I18Nv2_Language($app->_conf['lang']);
     $languageCodes =& $this->languageCodes;
     $currentLanguage = $languageCodes->getName($app->_conf['lang']);
     if (count($translatableLanguages) < 2) {
         return PEAR::raiseError(df_translate('Not enough languages to translate', 'There aren\'t enough languages available to translate.'), DATAFACE_E_ERROR);
     }
     //$defaultSource = $translatableLanguages[0];
     //$defaultDest = $translatableLanguages[1];
     $options = array();
     foreach ($translatableLanguages as $lang) {
         $options[$lang] = $languageCodes->getName($lang);
     }
     unset($options[$app->_conf['default_language']]);
     $tt = new Dataface_TranslationTool();
     $form = new HTML_QuickForm('StatusForm', 'POST');
     $form->addElement('select', '--language', 'Translation', $options);
     $form->addElement('select', '--status', 'Status', $tt->translation_status_codes);
     //$form->setDefaults( array('-sourceLanguage'=>$defaultSource, '-destinationLanguage'=>$defaultDest));
     $form->addElement('submit', '--set_status', 'Set Status');
     foreach ($query as $key => $value) {
         $form->addElement('hidden', $key);
         $form->setDefaults(array($key => $value));
     }
     if ($form->validate()) {
         $res = $form->process(array(&$this, 'processForm'));
         if (PEAR::isError($res)) {
             return $res;
         } else {
             header('Location: ' . $app->url('-action=list&-sourceLanguage=&-destinationLanguage=&-translate=') . '&--msg=' . urlencode('Translation status successfully set.'));
             exit;
         }
     }
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $records =& $this->getRecords();
     df_display(array('form' => $out, 'translationTool' => &$tt, 'records' => &$records, 'translations' => &$options, 'context' => &$this), 'Dataface_set_translation_status.html');
 }
예제 #16
0
 function handleGet_settingsNotFound($params)
 {
     $website_id = $params['website_id'];
     $settings = df_get_record('websites', array('website_id' => '=' . $website_id));
     if (!$settings) {
         df_display(array(), 'swete/actions/import_webpages/no_settings_found.html');
         return;
     } else {
         df_display(array('settings' => $settings), 'swete/actions/import_webpages/settings_site_not_found.html');
     }
 }
예제 #17
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('forgot_password.js');
     try {
         if (isset($query['--uuid'])) {
             // A uuid was supplied,
             $res = $this->reset_password_with_uuid($query['--uuid']);
             if ($res) {
                 df_display(array(), 'xataface/forgot_password/password_has_been_reset.html');
                 exit;
             } else {
                 throw new Exception(df_translate('actions.forgot_password.failed_reset_for_uuid', "Failed to reset password for uuid") . ' ' . $query['--uuid']);
             }
         } else {
             if (isset($query['--email'])) {
                 $this->send_reset_email_for_email($query['--email']);
                 if (@$query['--format'] == 'json') {
                     $this->response(array('code' => 200, 'message' => df_translate('actions.forgot_password.email_sent_to_email', 'An email has been sent to the provided email address with instructions for resetting your password.')));
                     exit;
                 } else {
                     df_display(array(), 'xataface/forgot_password/sent_email.html');
                     exit;
                 }
             } else {
                 if (isset($query['--username'])) {
                     $this->send_reset_email_for_username($query['--username']);
                     if (@$query['--format'] == 'json') {
                         $this->response(array('code' => 200, 'message' => df_translate('actions.forgot_password.email_sent_to_email_for_username', 'An email has been sent to the email on file for this user account with instructions for resetting the password.')));
                         exit;
                     } else {
                         df_display(array(), 'xataface/forgot_password/sent_email.html');
                         exit;
                     }
                 } else {
                     df_display(array(), 'xataface/forgot_password/form.html');
                     exit;
                 }
             }
         }
     } catch (Exception $ex) {
         if (@$query['--format'] == 'json') {
             $this->response(array('code' => $ex->getCode(), 'message' => $ex->getMessage()));
             exit;
         } else {
             df_display(array('error' => $ex->getMessage()), 'xataface/forgot_password/form.html');
         }
     }
 }
예제 #18
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     if (!@$_GET['history__id']) {
         return PEAR::raiseError('No history id supplied', DATAFACE_E_ERROR);
     }
     $historyid = $_GET['history__id'];
     $query =& $app->getQuery();
     $table = $query['-table'];
     import('Dataface/HistoryTool.php');
     $ht = new Dataface_HistoryTool();
     if (@$_GET['-show_changes']) {
         $record = $ht->getDiffs($table, $historyid);
     } else {
         $record = $ht->getRecordById($table, $historyid);
     }
     if (!$record) {
         return PEAR::raiseError("No history record for table {$table} with history id {$historyid} could be found", DATAFACE_E_ERROR);
     }
     if (PEAR::isError($record)) {
         return $record;
     }
     $context = array('history_record' => &$record);
     $context['table_record'] = new Dataface_Record($table, $record->vals());
     $t =& Dataface_Table::loadTable($table);
     $numfields = count($t->fields());
     $pts = 0;
     $ppf = array();
     foreach ($t->fields() as $field) {
         if ($t->isText($field['name'])) {
             $pts += 5;
             $ppf[$field['name']] = $pts;
         } else {
             $pts++;
             $ppf[$field['name']] = $pts;
         }
     }
     $firstField = null;
     $threshold = floatval(floatval($pts) / floatval(2));
     foreach ($t->fields() as $field) {
         if ($ppf[$field['name']] >= $threshold) {
             $firstField = $field['name'];
             break;
         }
     }
     $context['first_field_second_col'] = $firstField;
     $context['changes'] = @$_GET['-show_changes'];
     $context['table'] =& $t;
     df_display($context, 'Dataface_HistoryRecordDetails.html');
 }
예제 #19
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $website = df_get_record('websites', array('website_id' => '=' . $query['website_id']));
     if (!$website) {
         throw new Exception("Website could not be found.");
     }
     if (!$website->checkPermission('capture strings')) {
         return Dataface_Error::permissionDenied("You don't have permission to perform this action.");
     }
     Dataface_JavascriptTool::getInstance()->import('swete/actions/swete_tool_bar.js');
     import('inc/SweteSite.class.php');
     df_display(array('website' => $website, 'websiteWrapper' => new SweteSite($website)), 'swete/actions/toolbar_wrapper.html');
 }
예제 #20
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $record_id = $query['--record_id'];
     if (!$record_id) {
         trigger_error("No record id provided", E_USER_ERROR);
     }
     $record =& df_get_record_by_id($record_id);
     $fields =& $record->_table->fields(false, true);
     header('Content-type: text/json; charset=' . $app->_conf['oe']);
     //$out = '';
     //$out .= '<table class="record-view-table"><tbody>';
     $dl = array();
     foreach ($fields as $field) {
         //if ( !$record->val($field['name']) ) continue;
         if (!$record->checkPermission('view', array('field' => $field['name']))) {
             continue;
         }
         if ($field['visibility']['browse'] == 'hidden') {
             continue;
         }
         $val = $record->htmlValue($field['name']);
         if (@$app->_conf['_prefs']['calendar.edit.inline'] and $record->checkPermission('edit', array('field' => $field['name'])) and in_array($field['name'], array_keys($record->_table->fields()))) {
             $class = 'df__editable_wrapper';
         } else {
             $class = '';
         }
         $dl[] = array('fielddef' => &$field, 'tdid' => 'td-' . rand(), 'value' => $val, 'tdclass' => $class);
         //$out .= '<tr><th>'.htmlspecialchars($field['widget']['label']).'</th><td id="td-'.rand().'" class="'.$class.'">'.$val.'</td></tr>';
         unset($field);
     }
     //$out .= '</tbody></table>';
     //import('Dataface/Ontology.php');
     //Dataface_Ontology::registerType('Event', 'Dataface/Ontology/Event.php', 'Dataface_Ontology_Event');
     //$ontology =& Dataface_Ontology::newOntology('Event', $query['-table']);
     //$event =& $ontology->newIndividual($record);
     ob_start();
     df_display(array('fields' => &$dl, 'event' => &$record), 'Dataface_AjaxEventDetails.html');
     $out = ob_get_contents();
     ob_end_clean();
     $response = array('record_id' => $record_id, 'details' => $out);
     import('Services/JSON.php');
     $json = new Services_JSON();
     echo $json->encode($response);
     exit;
 }
예제 #21
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $record =& $app->getRecord();
     if (!$record) {
         return PEAR::raiseError("No record could be found that matches the query.", DATAFACE_E_ERROR);
     }
     if (PEAR::isError($record)) {
         return $record;
     }
     $context = array('record' => &$record);
     $t =& $record->_table;
     $fields = array();
     foreach ($t->fields(false, true) as $field) {
         if ($record->checkPermission('view', array('field' => $field['name']))) {
             $fields[$field['name']] = $field;
         }
     }
     $numfields = count($fields);
     $pts = 0;
     $ppf = array();
     foreach (array_keys($fields) as $field) {
         if ($t->isText($field)) {
             $pts += 5;
             $ppf[$field] = $pts;
         } else {
             $pts++;
             $ppf[$field] = $pts;
         }
     }
     $firstField = null;
     $threshold = floatval(floatval($pts) / floatval(2));
     foreach (array_keys($fields) as $field) {
         if ($ppf[$field] >= $threshold) {
             $firstField = $field;
             break;
         }
     }
     $context['first_field_second_col'] = $firstField;
     $context['table'] =& $t;
     $context['fields'] =& $fields;
     header('Content-type: text/html; charset=' . $app->_conf['oe']);
     df_display($context, 'Dataface_AjaxRecordDetails.html');
 }
 function handle($params)
 {
     $js = Dataface_JavascriptTool::getInstance();
     $js->import('xatacard/layout/tests/RecordSetTest.js');
     $js->setMinify(false);
     $js->setUseCache(false);
     df_register_skin('xatajax', XATAJAX_PATH . DIRECTORY_SEPARATOR . 'templates');
     try {
         df_display(array(), 'tests/xatacard/layout/RecordSet/RecordSetTest.html');
     } catch (Exception $ex) {
         //echo "here";exit;
         while ($ex) {
             echo '<h3>' . $ex->getMessage() . '</h3>';
             echo nl2br(df_escape($ex->getTraceAsString()));
             $ex = $ex->getPrevious();
         }
     }
 }
예제 #23
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $mt =& Dataface_ModuleTool::getInstance();
     $mod =& $mt->loadModule('modules_DataGrid');
     if (PEAR::isError($mod)) {
         return $mod;
     }
     $res = mysql_query("select gridID,gridName from dataface__DataGrids where tableName='" . addslashes($query['-table']) . "'", df_db());
     $grids = array();
     while ($row = mysql_fetch_assoc($res)) {
         $grids[$row['gridID']] = array('name' => $row['gridName'], 'url' => $app->url('-gridid=' . $row['gridID'] . '&-action=DataGrid_view'));
     }
     //print_r($grids);
     df_register_skin('DataGrid', DATAFACE_PATH . '/modules/DataGrid/templates');
     df_display(array('grids' => $grids), 'DataGrid/list.html');
 }
예제 #24
0
 function handle(&$params)
 {
     session_write_close();
     set_time_limit(0);
     import('Dataface/Index.php');
     $index = new Dataface_Index();
     if (@$_POST['--build-index']) {
         if (is_array($_POST['--tables'])) {
             $tables = $_POST['--tables'];
         } else {
             if (!empty($_POST['--tables'])) {
                 $tables = array($_POST['--tables']);
             } else {
                 $tables = null;
             }
         }
         if (@$_POST['--clear']) {
             $clear = true;
         } else {
             $clear = false;
         }
         $index->buildIndex($tables, '*', $clear);
         $app =& Dataface_Application::getInstance();
         header('Location: ' . $app->url('') . '&--msg=' . urlencode('Successfully indexed database'));
         exit;
     }
     $tables = array_keys(Dataface_Table::getTableModificationTimes());
     $count = 0;
     $indexable = array();
     foreach ($tables as $key => $table) {
         if (preg_match('/^dataface__/', $table)) {
             continue;
         }
         if (preg_match('/^_/', $table)) {
             continue;
         }
         if ($index->isTableIndexable($table)) {
             $indexable[] = $table;
             //unset($tables[$key]);
         }
     }
     $tables = $indexable;
     df_display(array('tables' => $tables), 'manage_build_index.html');
 }
예제 #25
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $nav = array('prev' => array('label' => null, 'url' => null), 'next' => array('label' => null, 'url' => null), 'current' => array('label' => null));
     import('Dataface/Ontology.php');
     Dataface_Ontology::registerType('Event', 'Dataface/Ontology/Event.php', 'Dataface_Ontology_Event');
     $ontology =& Dataface_Ontology::newOntology('Event', $query['-table']);
     $dateAtt = $ontology->getFieldname('date');
     if (PEAR::isError($dateAtt)) {
         die($dateAtt->getMessage());
     }
     if (!isset($query[$dateAtt]) or !preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}\\.\\.[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $query[$dateAtt])) {
         $query[$dateAtt] = date('Y-m-01') . '..' . date('Y-m-t');
     }
     list($startDate) = explode('..', $query[$dateAtt]);
     $startTime = strtotime($startDate);
     $prevMonth = intval(date('m', $startTime)) - 1;
     $nextMonth = intval(date('m', $startTime)) + 1;
     $prevTime = mktime(0, 0, 0, $prevMonth, 1, date('Y', $startTime));
     $nextTime = mktime(0, 0, 0, $nextMonth, 1, date('Y', $startTime));
     $nav['prev']['label'] = date('F Y', $prevTime);
     $nav['prev']['url'] = $app->url('-action=calendar&' . $dateAtt . '=' . urlencode(date('Y-m-01', $prevTime) . '..' . date('Y-m-t', $prevTime)), true, true);
     $nav['next']['label'] = date('F Y', $nextTime);
     $nav['next']['url'] = $app->url('-action=calendar&' . $dateAtt . '=' . urlencode(date('Y-m-01', $nextTime) . '..' . date('Y-m-t', $nextTime)), true, true);
     $nav['current']['label'] = date('F Y', $startTime);
     $query['-limit'] = 500;
     $records =& df_get_records_array($query['-table'], $query);
     $events = array();
     foreach ($records as $record) {
         $event = $ontology->newIndividual($record);
         $datems = strtotime(date('Y-m-d', strtotime($event->strval('date')))) * 1000;
         $timems = (strtotime(date('H:i:s', strtotime($event->strval('start')))) - strtotime(date('Y-m-d'))) * 1000;
         $events[] = array('title' => $record->getTitle(), 'description' => $record->getDescription(), 'date' => $datems + $timems, 'startTime' => strtotime($event->strval('date')) * 1000, 'record_id' => $record->getId());
         unset($event);
         unset($record);
     }
     import('Services/JSON.php');
     $json = new Services_JSON();
     $event_data = 'var events = ' . $json->encode($events);
     import('Dataface/ResultList.php');
     $rs = new Dataface_ResultList($query['-table']);
     df_display(array('event_data' => $event_data, 'nav' => &$nav, 'currentTime' => $startTime, 'filters' => $rs->getResultFilters()), 'Dataface_Calendar.html');
 }
예제 #26
0
 function handle(&$params)
 {
     import('Dataface/Index.php');
     $app =& Dataface_Application::getInstance();
     $q = $app->getQuery();
     if (@$q['table']) {
         $q['-table'] = $q['table'];
     } else {
         unset($q['-table']);
     }
     $index = new Dataface_Index();
     $res = $index->find($q, true);
     $results =& $res['results'];
     foreach ($results as $id => $result) {
         $width = intval(floatval($result['relevance']) / 10.0 * 30.0);
         $results[$id]['relevance_bar'] = '<div style="border:1px solid #ccc; padding:1px margin:1px; background-color: #eaeaea; width:32px; height: 5px;"><div style="border: none; background-color: green; width: ' . $width . 'px; height:5px;"></div></div>';
     }
     df_display(array('results' => &$results, 'metadata' => &$res['metadata'], 'search_term' => $q['-search']), 'Dataface_Search_Results.html');
 }
예제 #27
0
파일: custom.php 프로젝트: promoso/HVAC
 function handle($params)
 {
     if (!isset($params['action']['page'])) {
         trigger_error(df_translate('Page not specified', 'No page specified at ' . Dataface_Error::printStackTrace(), array('stack_trace' => Dataface_Error::printStackTrace())), E_USER_ERROR);
     } else {
         $page = $params['action']['page'];
     }
     $app =& Dataface_Application::getInstance();
     $pages = $app->getCustomPages();
     if (!isset($pages[$page])) {
         trigger_error(df_translate('Custom page not found', "Request for custom page '{$page}' failed because page does not exist in pages directory." . Dataface_Error::printStackTrace(), array('page' => $page, 'stack_trace' => Dataface_Error::printStackTrace())), E_USER_ERROR);
     }
     ob_start();
     include $pages[$page];
     $out = ob_get_contents();
     ob_end_clean();
     df_display(array('content' => $out), 'Dataface_Custom_Template.html');
     return true;
 }
예제 #28
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $related_record = df_get_record_by_id($query['-related-record-id']);
     if (!$related_record || PEAR::isError($related_record)) {
         $this->out_404();
     }
     $app->_conf['orig_permissions'] = $related_record->_record->getPermissions();
     Dataface_PermissionsTool::addContextMask($related_record);
     $perms = $related_record->getPermissions();
     //print_r($perms);exit;
     if (!@$perms['view']) {
         return Dataface_Error::permissionDenied('You don\'t have permission to view this record.');
     }
     $query['-relationship'] = $related_record->_relationship->getName();
     Dataface_JavascriptTool::getInstance()->import('xataface/actions/view_related_record.js');
     df_display(array('related_record' => $related_record), 'xataface/actions/view_related_record.html');
 }
예제 #29
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     // We need to load the current data grid from the database.
     // Its id is provided in the -gridid request parameter.
     $mt =& Dataface_ModuleTool::getInstance();
     $mod =& $mt->loadModule('modules_DataGrid');
     if (PEAR::isError($mod)) {
         return $mod;
     }
     if (!@$query['-gridid']) {
         // No grid was specified.. so we will just take the first grid
         $grids = $mod->getDataGrids();
         if (!$grids) {
             // No grids were found.  We need to create one
             $table =& Dataface_Table::loadTable($query['-table']);
             $grid = $mod->createDataGrid($query['-table'] . ' default grid', $query['-table'], array_keys($table->fields()));
             $res = $mod->saveDataGrid($grid);
             if (PEAR::isError($res)) {
                 return $res;
             }
             $dataGrid =& $grid;
         } else {
             $dataGrid = $grids[0];
         }
     }
     if (PEAR::isError($dataGrid)) {
         return $dataGrid;
     }
     if (!@$dataGrid) {
         $dataGrid =& $mod->getDataGrid($query['-gridid']);
     }
     if (!$dataGrid) {
         return PEAR::raiseError("Error, the specified data grid could not be found");
     }
     $json = new Services_JSON();
     $jsonFieldDefs = $json->encode($dataGrid->getFieldDefs(true));
     df_register_skin('DataGrid', DATAFACE_PATH . '/modules/DataGrid/templates');
     df_display(array('grid' => &$dataGrid, 'fieldDefs' => $jsonFieldDefs, 'json' => &$json), 'DataGrid/view.html');
 }
예제 #30
0
파일: default.php 프로젝트: promoso/HVAC
 function handle(&$params)
 {
     import('dataface-public-api.php');
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $action =& $params['action'];
     if (isset($action['mode'])) {
         $query['-mode'] = $action['mode'];
     }
     $context = array();
     if (@$query['-template']) {
         $template = $query['-template'];
     } else {
         if (@$action['template']) {
             $template = $action['template'];
         } else {
             trigger_error("No template found for action '" . @$action['name'] . "'." . Dataface_Error::printStackTrace(), E_USER_ERROR);
         }
     }
     $context = array();
     df_display($context, $template);
 }