本文整理汇总了PHP中Dataface_Application类的典型用法代码示例。如果您正苦于以下问题:PHP Dataface_Application类的具体用法?PHP Dataface_Application怎么用?PHP Dataface_Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dataface_Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
if (!isset($_POST['--confirm_invalidate'])) {
return PEAR::raiseError("Cannot invalidate translations with a GET request. Please provide the POST parameter '--confirm_invalidate'");
}
$record =& $app->getRecord();
if (!$record) {
return PEAR::raiseError("Attempt to invalidate translations on null record. No record could be found to match the query parameters.");
}
import('Dataface/TranslationTool.php');
$tt = new Dataface_TranslationTool();
$res = $tt->markNewCanonicalVersion($record, $app->_conf['default_language']);
if (PEAR::isError($res)) {
return $res;
}
$query =& $app->getQuery();
if (isset($query['--redirect'])) {
header('Location: ' . $query['--redirect'] . '&--msg=' . urlencode("Translations successfully invalidated."));
exit;
} else {
header('Location: ' . $record->getURL('-action=edit') . '&--msg=' . urlencode('Translations successfully invalidated.'));
exit;
}
}
示例2: toHtml
function toHtml()
{
$id = rand(10, 100000);
$app =& Dataface_Application::getInstance();
$p = $this->prefix;
if (@$app->prefs['default_collapse_sort_control']) {
$out = '<a href="#" onclick="document.getElementById(\'Dataface_SortControl-' . $id . '\').style.display=\'\'; this.style.display=\'none\'; return false">Sort Results</a>';
$style = 'display:none';
} else {
$style = '';
}
$out .= '<div style="' . $style . '" id="Dataface_SortControl-' . $id . '" class="Dataface_SortControl"><fieldset><legend>Sorted on:</legend><ul class="Dataface_SortControl_current_sort-list">
';
foreach ($this->current_sort as $fieldname => $dir) {
$fieldDef = $this->table->getField($fieldname);
$out .= '<li>
<a class="Dataface_SortControl-reverse-' . $dir . '" href="' . $app->url('-' . $p . 'sort=' . urlencode($this->reverseSortOn($fieldname))) . '" title="Sort the results in reverse order on this column"><img src="' . DATAFACE_URL . '/images/' . ($dir == 'asc' ? 'arrowUp.gif' : 'arrowDown.gif') . '"/>' . $fieldDef['widget']['label'] . '</a>
<a href="' . $app->url('-' . $p . 'sort=' . urlencode($this->removeParameter($fieldname))) . '" title="Remove this field from the sort parameters"><img src="' . DATAFACE_URL . '/images/delete.gif"/></a>
</li>';
}
$out .= '</ul>';
$out .= '<select onchange="window.location=this.options[this.selectedIndex].value">
<option value="">Add Columns</th>';
foreach ($this->fields as $fieldname) {
$fieldDef = $this->table->getField($fieldname);
$out .= '<option value="' . $app->url('-' . $p . 'sort=' . urlencode($this->addParameter($fieldname))) . '">' . $fieldDef['widget']['label'] . '</option>';
}
$out .= '</select><div style="clear:both"></div></fieldset></div>';
return $out;
}
示例3: __construct
/**
* @brief Initializes the datepicker module and registers all of the event listener.
*
*/
function __construct()
{
$app = Dataface_Application::getInstance();
// Now work on our dependencies
$mt = Dataface_ModuleTool::getInstance();
// We require the XataJax module
// The XataJax module activates and embeds the Javascript and CSS tools
$mt->loadModule('modules_XataJax', 'modules/XataJax/XataJax.php');
// Register the geopicker widget with the form tool so that it responds
// to widget:type=geopicker
import('Dataface/FormTool.php');
$ft = Dataface_FormTool::getInstance();
$ft->registerWidgetHandler('geopicker', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widget.php', 'Dataface_FormTool_geopicker');
if (!@$app->_conf['modules_geopicker'] or !@$app->_conf['modules_geopicker']['key']) {
$msg = <<<END
<p>Google Maps Module is installed but no API key is specified.</p>
<p>For information about obtaining your API key see <a href="https://developers.google.com/maps/documentation/javascript/tutorial#api_key">this page</a>.</p>
<p>After obtaining your key, add the following section to your application's conf.ini file:</p>
<p><code><pre>
[modules_geopicker]
key=YOUR_API_KEY_HERE
</pre></code></p>
END;
die($msg);
}
$app->addHeadContent('<script>XF_GEOPICKER_API_KEY="' . htmlspecialchars($app->_conf['modules_geopicker']['key']) . '";</script>');
foreach (Dataface_Table::loadTable('', df_db(), true) as $t) {
$evt = new StdClass();
$evt->table = $t;
$this->afterTableInit($evt);
}
$app->registerEventListener("afterTableInit", array($this, 'afterTableInit'));
$app->registerEventListener("Dataface_Record__htmlValue", array($this, 'Dataface_Record__htmlValue'));
}
示例4: handle
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;
}
}
}
示例5: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
if (!@$_POST['-valuelist']) {
echo JSON::error("No valuelist specified.");
exit;
}
$valuelist = $_POST['-valuelist'];
$query =& $app->getQuery();
$table =& Dataface_Table::loadTable($query['-table']);
if (!@$_POST['-value']) {
echo JSON::error("No value was provided to be appended to the valuelist.");
exit;
}
$value = $_POST['-value'];
if (@$_POST['-key']) {
$key = $_POST['-key'];
} else {
$key = null;
}
$vt =& Dataface_ValuelistTool::getInstance();
$res = $vt->addValueToValuelist($table, $valuelist, $value, $key, true);
if (PEAR::isError($res)) {
echo JSON::error($res->getMessage());
exit;
}
echo JSON::json(array('success' => 1, 'value' => array('key' => $res['key'], 'value' => $res['value'])));
exit;
}
示例6: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$app->_handleGetBlob($query);
exit;
}
示例7: handle
function handle(&$params)
{
try {
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
if (isset($query['-record-id'])) {
//todo fix the php notice here. Undefined index: -record-id
$selectedRecord = df_get_record_by_id($query['-record-id']);
echo $selectedRecord->val('website_id');
} else {
$selectedRecords = df_get_selected_records($query);
if (empty($selectedRecords)) {
throw new Exception("No records specified");
}
$record = $selectedRecords[0];
$websiteId = $record->val('website_id');
//ensure that all selectedRecords are for the same website
foreach ($selectedRecords as $record) {
if ($record->val('website_id') != $websiteId) {
throw new Exception("All records must be from the same site.", E_USER_ERROR);
}
}
//return the website id
echo $websiteId;
}
} catch (Exception $e) {
if ($e->getCode() == E_USER_ERROR) {
echo $e->getMessage();
} else {
throw $e;
}
}
}
示例8: beforeHandleRequest
public function beforeHandleRequest()
{
$query =& Dataface_Application::getInstance()->getQuery();
if ($query['-action'] !== 'friends_api') {
$query['-action'] = 'install_app';
}
}
示例9: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
$record =& $app->getRecord();
if (!$record) {
echo '{}';
}
$relationships = $record->_table->getRelationshipsAsActions();
if (isset($_GET['-relationship'])) {
$relationships = array($relationships[$_GET['-relationship']]);
}
$outerOut = array();
foreach ($relationships as $relationship) {
$innerOut = array();
$relatedRecords = $record->getRelatedRecordObjects($relationship['name'], 0, 60);
foreach ($relatedRecords as $relatedRecord) {
$domainRecord = $relatedRecord->toRecord();
$innerOut[] = "'" . $domainRecord->getId() . "': " . $domainRecord->toJS(array());
}
if (count($relationships) > 1) {
$outerOut[] = "'" . $relationship['name'] . "': {'__title__': '" . $relationship['label'] . "', '__url__': '" . $record->getURL('-action=related_records_list&-relationship=' . urlencode($relationship['name'])) . "','records': {" . implode(',', $innerOut) . "}}";
} else {
$outerOut[] = implode(',', $innerOut);
}
}
echo '{' . implode(',', $outerOut) . '}';
exit;
}
示例10: handle
function handle(&$params)
{
session_write_close();
header('Connection: close');
$app = Dataface_Application::getInstance();
try {
$query =& $app->getQuery();
if (!@$query['-record-id']) {
throw new Exception("No record id was specified");
}
$record = df_get_record_by_id($query['-record-id']);
$username = $query['-username'];
if (!$username) {
throw new Exception("No username was specified");
}
if ($record->val('compiled') == 0) {
throw new Exception("The job has must be compiled before it can be approved");
}
if ($record->val('job_status') == SweteJob::JOB_STATUS_CLOSED) {
throw new Exception("The job has already been approved");
}
$job = new SweteJob($record);
$job->approve($username);
$out = array('code' => 200, 'message' => 'Successfully approved your job ');
} catch (Exception $ex) {
$out = array('code' => $ex->getCode(), 'message' => $ex->getMessage());
}
header('Content-type: text/json; charset="' . $app->_conf['oe'] . '"');
echo json_encode($out);
return;
}
示例11: handle
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');
}
}
}
示例12: handle
function handle(&$params)
{
try {
// add a new message to the current job record
//-content is the new message content
$app = Dataface_Application::getInstance();
$query = $app->getQuery();
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
$content = trim(htmlspecialchars($query['-content']));
if (!$content) {
throw new Exception("No message contents entered.", E_USER_ERROR);
}
$job_id = $query['-job_id'];
$job_rec =& df_get_record("jobs", array('job_id' => $job_id));
if (!$job_rec->checkPermission('add new related record')) {
throw new Exception("You do not have permission to add a note to this job.", E_USER_ERROR);
}
require_once 'inc/SweteDb.class.php';
require_once 'inc/SweteJob.class.php';
require_once 'inc/SweteJobInbox.class.php';
$job = new SweteJob($job_rec);
$inbox = $job->getInbox($user->val('username'));
$noteRec = $inbox->addMessage($content);
} catch (Exception $e) {
if ($e->getCode() == E_USER_ERROR) {
echo $e->getMessage();
} else {
throw $e;
}
}
}
示例13: handle
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');
}
}
}
示例14: DB_Test
function DB_Test($name = 'DB_Test')
{
$this->BaseTest($name);
Dataface_Application::getInstance();
$this->DB =& Dataface_DB::getInstance();
//parent::BaseTest();
}
示例15: handle
function handle(&$params)
{
try {
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if (!isset($query['-site-id'])) {
throw new Exception("No site id specified");
}
if (isset($query['-compiled'])) {
if ($query['-compiled'] == 'true' || $query['-compiled'] == 1) {
$compiled = 1;
} else {
$compiled = 0;
}
$jobs = df_get_records_array('jobs', array('website_id' => $query['-site-id'], 'posted_by' => $user->val('username'), 'compiled' => $compiled));
} else {
$jobs = df_get_records_array('jobs', array('website_id' => $query['-site-id'], 'posted_by' => $user->val('username')));
}
//array of job ids and job titles to present to user
$results = array();
foreach ($jobs as $job) {
$results[] = array('job_id' => $job->val('job_id'), 'title' => $job->getTitle());
}
echo json_encode($results);
} catch (Exception $e) {
if ($e->getCode() == E_USER_ERROR) {
echo $e->getMessage();
} else {
throw $e;
}
}
}