本文整理汇总了PHP中Dataface_Table类的典型用法代码示例。如果您正苦于以下问题:PHP Dataface_Table类的具体用法?PHP Dataface_Table怎么用?PHP Dataface_Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dataface_Table类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: init
function init(Dataface_Table $table)
{
if (!@Dataface_Application::getInstance()->_conf['enable_static']) {
$efl =& $table->getField('enable_live_translation');
$efl['Default'] = 1;
$efl['widget']['type'] = 'hidden';
}
}
开发者ID:gtoffoli,项目名称:swete,代码行数:8,代码来源:websites.php
示例2: foreach
function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
{
/*
*
* This field uses a table widget.
*
*/
$table =& $record->_table;
$formTool =& Dataface_FormTool::getInstance();
$factory =& Dataface_FormTool::factory();
$widget =& $field['widget'];
$el =& $factory->addElement('table', $formFieldName, $widget['label']);
if (isset($widget['fields'])) {
$widget_fields =& $widget['fields'];
foreach ($widget_fields as $widget_field) {
$widget_field =& Dataface_Table::getTableField($widget_field, $this->db);
if (PEAR::isError($widget_field)) {
return $widget_field;
}
$widget_widget = $formTool->buildWidget($record, $widget_field, $factory, $widget_field['name']);
$el->addField($widget_widget);
}
} else {
if (isset($field['fields'])) {
foreach (array_keys($field['fields']) as $field_key) {
$widget_widget = $formTool->buildWidget($record, $field['fields'][$field_key], $factory, $field['fields'][$field_key]['name']);
$el->addField($widget_widget);
unset($widget_widget);
}
}
}
return $el;
}
开发者ID:promoso,项目名称:HVAC,代码行数:33,代码来源:table.php
示例3: handle
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');
}
开发者ID:promoso,项目名称:HVAC,代码行数:27,代码来源:history.php
示例4: handle2
function handle2($params)
{
$app = Dataface_Application::getInstance();
$query = $app->getQuery();
$table = $query['-table'];
if (!@$query['-field']) {
throw new Exception("No field specified", 500);
}
if (!@$query['-key']) {
throw new Exception("No key specified", 500);
}
$tableObj = Dataface_Table::loadTable($table);
if (PEAR::isError($tableObj)) {
throw new Exception($tableObj->getMessage(), $tableObj->getCode());
}
$field =& $tableObj->getField($query['-field']);
if (PEAR::isError($field)) {
throw new Exception("Field not found " . $field->getMessage(), $field->getCode());
}
if (!@$field['vocabulary']) {
throw new Exception("Field has no vocabulary assigned", 500);
}
$perms = $tableObj->getPermissions(array('field' => $field['name']));
if (!@$perms['edit'] && !@$perms['new']) {
throw new Exception("You don't have permission to access this vocabulary.", 400);
}
$valuelist = $tableObj->getValuelist($field['vocabulary']);
if (PEAR::isError($valuelist)) {
throw new Exception("Valuelist not found.", 404);
}
$value = @$valuelist[$query['-key']];
df_write_json(array('code' => 200, 'message' => 'Found', 'value' => $value));
}
开发者ID:minger11,项目名称:Pipeline,代码行数:33,代码来源:field_vocab_value.php
示例5: handle
function handle($params)
{
session_write_close();
header('Connection:close');
$app = Dataface_Application::getInstance();
$query = $app->getQuery();
if (@$query['--id']) {
$table = Dataface_Table::loadTable($query['-table']);
$keys = array_keys($table->keys());
if (count($keys) > 1) {
throw new Exception("Table has compound key so its permissions cannot be retrieved with the --id parameter.");
}
$query[$keys[0]] = '=' . $query['--id'];
$record = df_get_record($query['-table'], $query);
} else {
$record = $app->getRecord();
}
$perms = array();
if ($record) {
$perms = $record->getPermissions();
}
header('Content-type: application/json; charset="' . $app->_conf['oe'] . '"');
$out = json_encode($perms);
header('Content-Length: ' . strlen($out));
echo $out;
flush();
}
开发者ID:minger11,项目名称:Pipeline,代码行数:27,代码来源:ajax_get_permissions.php
示例6: 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;
}
开发者ID:minger11,项目名称:Pipeline,代码行数:29,代码来源:ajax_valuelist_append.php
示例7: 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');
}
}
}
开发者ID:minger11,项目名称:Pipeline,代码行数:27,代码来源:related_records_list.php
示例8: 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');
}
}
}
开发者ID:minger11,项目名称:Pipeline,代码行数:31,代码来源:related_records_checkboxes.php
示例9: ReferenceBrowser
function ReferenceBrowser($tablename, $relationshipName)
{
$this->_table =& Dataface_Table::loadTable($tablename);
$this->_relationshipName = $relationshipName;
$this->_relationship =& $this->_table->getRelationship($relationshipName);
$this->HTML_QuickForm('Reference Browser');
}
开发者ID:promoso,项目名称:HVAC,代码行数:7,代码来源:ReferenceBrowser.php
示例10: test_html
function test_html()
{
$s =& Dataface_Table::loadTable('Profiles');
$records = df_get_records_array('Profiles');
$grid = new Dataface_dhtmlxGrid_grid($s->fields(), $records);
echo $grid->toXML();
}
开发者ID:Zunair,项目名称:xataface,代码行数:7,代码来源:dhtmlxGridTest.php
示例11: __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'));
}
开发者ID:arkypita,项目名称:xataface-modules-geopicker,代码行数:38,代码来源:geopicker.php
示例12: Dataface_ValuelistEditorForm
function Dataface_ValuelistEditorForm($tablename, $valuelistName, $widgetID = null)
{
$this->table =& Dataface_Table::loadTable($tablename);
$this->valuelistName = $valuelistName;
$this->values = $this->table->getValuelist($this->valuelistName);
$this->widgetID = $widgetID;
}
开发者ID:minger11,项目名称:Pipeline,代码行数:7,代码来源:ValuelistEditorForm.php
示例13: test_add_value
function test_add_value()
{
$vt = Dataface_ValuelistTool::getInstance();
$people = Dataface_Table::loadTable('People');
$vt->addValueToValuelist($people, 'Publications', 'My Test Publication');
$res = xf_db_query("select * from Publications where `BiblioString` = 'My Test Publication'");
$this->assertTrue(xf_db_num_rows($res) === 1);
}
开发者ID:Zunair,项目名称:xataface,代码行数:8,代码来源:ValuelistToolTest.php
示例14: handle
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);
}
}
}
开发者ID:promoso,项目名称:HVAC,代码行数:56,代码来源:submit_translation.php
示例15: handle
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');
}
开发者ID:promoso,项目名称:HVAC,代码行数:55,代码来源:set_translation_status.php
示例16: array
/**
* Defines how a depselect widget should be built.
*
* @param Dataface_Record $record The Dataface_Record that is being edited.
* @param array &$field The field configuration data structure that the widget is being generated for.
* @param HTML_QuickForm The form to which the field is to be added.
* @param string $formFieldName The name of the field in the form.
* @param boolean $new Whether this widget is being built for a new record form.
* @return HTML_QuickForm_element The element that can be added to a form.
*
*/
function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
{
$factory = Dataface_FormTool::factory();
$mt = Dataface_ModuleTool::getInstance();
$mod = $mt->loadModule('modules_depselect');
//$atts = $el->getAttributes();
$widget =& $field['widget'];
$atts = array();
if (!@$atts['class']) {
$atts['class'] = '';
}
$atts['class'] .= ' xf-depselect';
if (!@$atts['data-xf-table']) {
$atts['data-xf-table'] = $field['tablename'];
}
$targetTable = Dataface_Table::loadTable($field['widget']['table']);
if (PEAR::isError($targetTable)) {
error_log("Your field {$formFieldName} is missing the widget:table directive or the table does not exist.");
throw new Exception("Your field {$formFieldName} is missing the widget:table directive or the table does not exist.");
}
$targetPerms = $targetTable->getPermissions();
$atts['data-xf-depselect-options-table'] = $field['widget']['table'];
if (@$targetPerms['new']) {
$atts['data-xf-depselect-perms-new'] = 1;
}
$atts['df:cloneable'] = 1;
$jt = Dataface_JavascriptTool::getInstance();
$jt->addPath(dirname(__FILE__) . '/js', $mod->getBaseURL() . '/js');
$ct = Dataface_CSSTool::getInstance();
$ct->addPath(dirname(__FILE__) . '/css', $mod->getBaseURL() . '/css');
// Add our javascript
$jt->import('xataface/widgets/depselect.js');
$filters = array();
if (@$field['widget']['filters'] and is_array($field['widget']['filters'])) {
foreach ($field['widget']['filters'] as $key => $val) {
$filters[] = urlencode($key) . '=' . urlencode($val);
}
}
$atts['data-xf-depselect-filters'] = implode('&', $filters);
if (@$field['widget']['nomatch']) {
$atts['data-xf-depselect-nomatch'] = $field['widget']['nomatch'];
}
if (@$field['widget']['dialogSize']) {
$atts['data-xf-depselect-dialogSize'] = $field['widget']['dialogSize'];
}
if (@$field['widget']['dialogMargin']) {
$atts['data-xf-depselect-dialogMargin'] = $field['widget']['dialogMargin'];
}
//$el->setAttributes($atts);
$el = $factory->addElement('depselect', $formFieldName, $widget['label'], $atts);
if (PEAR::isError($el)) {
throw new Exception($el->getMessage(), $el->getCode());
}
return $el;
}
开发者ID:shannah,项目名称:xataface-module-depselect,代码行数:66,代码来源:widget.php
示例17: test_table_permissions
function test_table_permissions()
{
$pt =& Dataface_PermissionsTool::getInstance();
$perms = $pt->getPermissions(Dataface_Table::loadTable('Profiles'));
$this->assertEquals(array(1, 1, 1), array($perms['view'], $perms['edit'], $perms['delete']));
$perms = $pt->getPermissions(Dataface_Table::loadTable('Profiles'), array('field' => 'fname'));
$this->assertEquals(array(1, 1, 1), array($perms['view'], $perms['edit'], $perms['delete']));
// varcharfield_checkboxes has view disabled in the fields.ini file
$this->assertTrue(!$pt->view(Dataface_Table::loadTable('Test'), array('field' => 'varcharfield_checkboxes')));
$this->assertTrue($pt->edit(Dataface_Table::loadTable('Test'), array('field' => 'varcharfield_checkboxes')));
}
开发者ID:Zunair,项目名称:xataface,代码行数:11,代码来源:PermissionsToolTest.php
示例18: Dataface_ConfigTool_createConfigTable
/**
* A method to create the configuration table in the database. The configuration
* table is where configuration (e.g. fields.ini etc..) may be stored. This is
* a new feature in 0.6.14.
*
* @author Steve Hannah <[email protected]>
* @created Feb. 26, 2007
*/
function Dataface_ConfigTool_createConfigTable()
{
$self =& Dataface_ConfigTool::getInstance();
if (!Dataface_Table::tableExists($self->configTableName, false)) {
$sql = "CREATE TABLE `" . $self->configTableName . "` (\n\t\t\t\t\tconfig_id int(11) NOT NULL auto_increment primary key,\n\t\t\t\t\t`file` varchar(255) NOT NULL,\n\t\t\t\t\t`section` varchar(128),\n\t\t\t\t\t`key` varchar(128) NOT NULL,\n\t\t\t\t\t`value` text NOT NULL,\n\t\t\t\t\t`lang` varchar(2),\n\t\t\t\t\t`username` varchar(32),\n\t\t\t\t\t`priority` int(5) default 5\n\t\t\t\t\t)";
$res = xf_db_query($sql, df_db());
if (!$res) {
throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
}
}
}
开发者ID:minger11,项目名称:Pipeline,代码行数:19,代码来源:createConfigTable.function.php
示例19: Dataface_SortControl
function Dataface_SortControl($fields, $prefix = '')
{
if (is_string($fields)) {
$t =& Dataface_Table::loadTable($fields);
$fields = array_keys($t->fields(false, true));
} else {
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$t =& Dataface_Table::loadTable($query['-table']);
}
$this->table =& $t;
$this->fields = array();
if (isset($t->_atts['__global__'])) {
$globalProps = $t->_atts['__global__'];
} else {
$globalProps = array();
}
foreach ($fields as $field) {
$fieldDef =& $t->getField($field);
if (isset($globalProps['sortable']) and !$globalProps['sortable'] and !@$fieldDef['sortable']) {
continue;
} else {
if (isset($fieldDef['sortable']) and !@$fieldDef['sortable']) {
continue;
}
}
$this->fields[] = $field;
}
$this->prefix = $prefix;
//$this->fields = $fields;
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
if (!isset($query['-' . $prefix . 'sort'])) {
$sort = '';
} else {
$sort = $query['-' . $prefix . 'sort'];
}
$sort = array_map('trim', explode(',', $sort));
$sort2 = array();
foreach ($sort as $col) {
if (!trim($col)) {
continue;
}
$col = explode(' ', $col);
if (count($col) <= 1) {
$col[1] = 'asc';
}
$sort2[$col[0]] = $col[1];
}
// Now sort2 looks like array('col1'=>'asc', 'col2'=>'desc', etc...)
$this->current_sort =& $sort2;
$this->fields = array_diff($this->fields, array_keys($this->current_sort));
}
开发者ID:minger11,项目名称:Pipeline,代码行数:53,代码来源:SortControl.php
示例20: Dataface_DeleteForm
function Dataface_DeleteForm($tablename, $db, $query)
{
$this->_tablename = $tablename;
$this->_table =& Dataface_Table::loadTable($tablename);
$this->_db = $db;
$this->_query = $query;
$this->_isBuilt = false;
if (!isset($this->_query['-cursor'])) {
$this->_query['-cursor'] = 0;
}
parent::HTML_QuickForm('deleteForm');
}
开发者ID:minger11,项目名称:Pipeline,代码行数:12,代码来源:DeleteForm.php
注:本文中的Dataface_Table类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论