Skip to content

Commit 8ee15b7

Browse files
committed
*lots* of changes. Many cli scripts to help with administration. Improved look and feel. Improved process for viewing and editing related records. g2 is now off by default, and mysqli is now the default db engine.
Added support for auto_update_filters preference. When this is set to 0 or false, the resultlist filters won't auto-update when you change a selection. It will add an update button which applies all of the filters together. Added better way to customize the tables menu. Simply add actions with category=_tables, and these actions will be used for your tables menu. Too many other improvements to list here - but mostly related to look and feel. This update is way overdue. Now the UI looks much more modern.
2 parents af23e4f + f9694fa commit 8ee15b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2681
-483
lines changed

.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
RewriteEngine On
22
RewriteRule (installer\.php|index\.php|install_form.js.php)$ - [L]
3-
RewriteRule !.+\.(png|jpg|gif|GIF|PNG|JPG|jpeg|JPEG|ICO|js|css|html|xml|htm)$ 403.html [L]
3+
RewriteRule !.+\.(png|jpg|gif|GIF|PNG|JPG|jpeg|JPEG|ICO|js|css|html|xml|htm|woff|eot|woff2|ttf)$ 403.html [L]

Dataface/ActionTool.php

+7
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ function &getAction($params, $action=null){
149149

150150
}
151151

152+
function countActions($params=array(), $actions=null) {
153+
if (is_string($params)) {
154+
$params = array('category' => $params);
155+
}
156+
return count($this->getActions($params, $actions));
157+
}
158+
152159
/**
153160
* Returns an array of all actions as specified by $params.
154161
* $params must be an array. It may contain the following options:

Dataface/Application.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ class Dataface_Application {
301301
'show_record_tabs' => 1, // View, Edit, Translate, History, etc...
302302
'show_record_tree' => 1, // Tree to navigate the relationships of this record.
303303
'list_view_scroll_horizontal'=>1, // Whether to scroll list horizontal if it exceeds page width
304-
'list_view_scroll_vertical'=>1 // Whether to scroll list vertical if it exceeds page height.
304+
'list_view_scroll_vertical'=>1, // Whether to scroll list vertical if it exceeds page height.
305+
'disable_master_detail' => 1
305306

306307
);
307308

@@ -609,7 +610,9 @@ function __construct($conf = null) {
609610

610611
}
611612
if ( !isset($dbinfo['driver']) ){
612-
$dbinfo['driver'] = 'mysql';
613+
// It's time to move to mysqli as the default database driver.
614+
// this might break old apps.
615+
$dbinfo['driver'] = 'mysqli';
613616
}
614617
require_once 'xf/db/drivers/'.basename($dbinfo['driver']).'.php';
615618
//if ( @$dbinfo['persistent'] ){
@@ -683,9 +686,13 @@ function __construct($conf = null) {
683686

684687
// Include XataJax module always.
685688
$mods = array('modules_XataJax'=>'modules/XataJax/XataJax.php');
686-
if ( !@$this->_conf['disable_g2'] ){
687-
$mods['modules_g2'] = 'modules/g2/g2.php';
688-
}
689+
690+
// We used to make g2 the default, but
691+
// starting with version 3.0, we will be going back to the default
692+
// look - which is improved.
693+
//if ( !@$this->_conf['disable_g2'] ){
694+
// $mods['modules_g2'] = 'modules/g2/g2.php';
695+
//}
689696
foreach ($this->_conf['_modules'] as $k=>$v){
690697
$mods[$k] = $v;
691698
}
@@ -2781,6 +2788,7 @@ function parseString($expression, $context=null){
27812788
$site_href = DATAFACE_SITE_HREF;
27822789
$dataface_url = DATAFACE_URL;
27832790
$table = $this->_currentTable;
2791+
$authTool = Dataface_AuthenticationTool::getInstance();
27842792
$tableObj = Dataface_Table::loadTable($table);
27852793
if ( PEAR::isError($tableObj) ){
27862794
throw new Exception($tableObj->getMessage(), $tableObj->getCode());

Dataface/FormTool.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,12 @@ function display(&$form, $template=null, $singleField=false, $useTabs=false){
973973
$renderer = new HTML_QuickForm_Renderer_ArrayDataface(true);
974974
$form->accept($renderer);
975975
$form_data = $renderer->toArray();
976+
$mainSectionLabel = df_translate('scripts.Dataface_FormTool.LABEL_EDIT_DETAILS', 'Edit Details');
977+
if (isset($template) and (stripos($template, 'search') !== false or stripos($template, 'find') !== false )) {
978+
$mainSectionLabel = 'Advanced Search';
979+
}
976980
if ( !@$form_data['sections'] ){
977-
$form_data['sections'] = array('__global__'=>array('header'=>df_translate('scripts.Dataface_FormTool.LABEL_EDIT_DETAILS', 'Edit Details'), 'name'=>'Edit','elements'=>&$form_data['elements']));
981+
$form_data['sections'] = array('__global__'=>array('header'=>$mainSectionLabel, 'name'=>'Edit','elements'=>&$form_data['elements']));
978982
unset($form_data['elements']);
979983
}
980984
//throw new Exception("here");

Dataface/GlanceList.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function oneLineDescription(&$record){
3636

3737
if ( is_a($origRecord, 'Dataface_RelatedRecord') ){
3838
$origDel = $origRecord->_record->table()->getDelegate();
39-
$method = 'rel_'.$origRecord->_relationshipName.'__'.oneLineDescription;
39+
$method = 'rel_'.$origRecord->_relationshipName.'__oneLineDescription';
4040
if ( isset($origDel) and method_exists($origDel, $method) ){
4141
return $del->$method($origRecord);
4242
}
@@ -52,7 +52,7 @@ function oneLineDescription(&$record){
5252
}
5353
$out = '<span class="Dataface_GlanceList-oneLineDescription">
5454
<span class="Dataface_GlanceList-oneLineDescription-title"><a href="'.df_escape($record->getURL('-action=view')).'" title="View this record">'.df_escape($origRecord->getTitle()).'</a></span> ';
55-
if ( $creator = $record->getCreator() ){
55+
if ( $creator = $record->getCreator() and !is_numeric($creator) ){
5656
$show = true;
5757
if ( isset($app->prefs['hide_posted_by']) and $app->prefs['hide_posted_by'] ) $show = false;
5858
if ( isset($record->_table->_atts['__prefs__']['hide_posted_by']) and $record->_table->_atts['__prefs__']['hide_posted_by'] ) $show = false;

Dataface/Record.php

+16
Original file line numberDiff line numberDiff line change
@@ -4548,6 +4548,22 @@ function getId(){
45484548
}
45494549

45504550

4551+
function getPrimaryKeyValue() {
4552+
$keys = array_keys($this->_table->keys());
4553+
$params=array();
4554+
$out = '';
4555+
$first = true;
4556+
foreach ($keys as $key){
4557+
if ($first) {
4558+
$first = false;
4559+
} else {
4560+
$out .= ', ';
4561+
}
4562+
$out .= $this->strval($key);
4563+
}
4564+
return $out;
4565+
}
4566+
45514567
// @}
45524568
// END Record Metadata
45534569
//--------------------------------------------------------------------------------------

Dataface/Relationship.php

+36
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function __construct($tablename, $relationshipName, &$values){
122122
}
123123
function Dataface_Relationship($tablename, $relationshipName, &$values) { self::__construct($tablename, $relationshipName, $values); }
124124

125+
125126
function &getFieldDefOverride($field_name, $default=array()){
126127
if ( strpos($field_name,'.') !== false ){
127128
list($rname,$field_name) = explode('.', $field_name);
@@ -1206,6 +1207,10 @@ function getDomainSQL(){
12061207

12071208
}
12081209

1210+
function isDomainTable($table) {
1211+
return $table == $this->getDomainTable();
1212+
}
1213+
12091214
/**
12101215
* Returns the name of the "domain table" for this relationship. The domain table is the main
12111216
* table that comprises the data of a related record. I.e., it is the destination table that is
@@ -1224,6 +1229,37 @@ function getDomainTable(){
12241229
return $this->domainTable;
12251230
}
12261231

1232+
function isForeignKey($table, $field, $excludeConstrained=false) {
1233+
$fkvals = $this->getForeignKeyValues();
1234+
1235+
if (!@$fkvals[$table]) {
1236+
return false;
1237+
}
1238+
if (!@$fkvals[$table][$field]) {
1239+
return false;
1240+
}
1241+
1242+
if ($excludeConstrained and strpos($fkvals[$table][$field], '$') === 0) {
1243+
return false;
1244+
}
1245+
return true;
1246+
}
1247+
1248+
function isConstrainedForeignKey($table, $field) {
1249+
$fkvals = $this->getForeignKeyValues();
1250+
1251+
if (!@$fkvals[$table]) {
1252+
return false;
1253+
}
1254+
if (!@$fkvals[$table][$field]) {
1255+
return false;
1256+
}
1257+
1258+
if (strpos($fkvals[$table][$field], '$') === 0) {
1259+
return true;
1260+
}
1261+
return false;
1262+
}
12271263

12281264
/**
12291265
* Gets the values of the foreign keys of a particular relationship. This returns an associative

Dataface/ResultController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ function listHtml($prefix = '') {
385385

386386
$pages2[df_translate('scripts.GLOBAL.LABEL_NEXT', 'Next')] = $pages[$curr_page + 1];
387387
}
388-
$out = array('<ul class="resultController">');
388+
$out = array('<div class="resultControllerWrapper"><ul class="resultController">');
389389
$out[] = '<li class="rs-description">' . df_translate('scripts.GLOBAL.MESSAGE_FOUND', 'Found ' . $found . ' records', array('found' => $found)) . ' </li>';
390390
foreach ($pages2 as $pageno => $link) {
391391
if ($pageno == $curr_page)
@@ -399,7 +399,7 @@ function listHtml($prefix = '') {
399399
$appurl = preg_replace('/[&\?]' . preg_quote('-' . $prefix . 'skip=') . '[^&]*/', '', $appurl);
400400
$urlprefix = ( $this->_baseUrl ? $this->_baseUrl . '?' . substr($appurl, strpos($appurl, '?') + 1) : $appurl);
401401
$out[] = '<li class="results-per-page"> ' . df_translate('scripts.GLOBAL.LABEL_SHOWING', 'Showing') . ' <input type="text" value="' . $limit . '" onchange="window.location = \'' . $urlprefix . '&-' . $prefix . 'limit=\'+this.value" size="3"/>' . df_translate('scripts.GLOBAL.MESSAGE_RESULTS_PER_PAGE', 'Results per page');
402-
$out[] = '</ul>';
402+
$out[] = '</ul><div style="clear:both;height:0; padding:0; margin:0"></div></div>';
403403

404404
return implode("\n", $out);
405405
}

Dataface/ResultList.php

+33-7
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function toHtml(){
352352

353353
if ( !$label ) $label = $this->_table->getFieldProperty('widget:label',$key);
354354
$searchColumn = $this->_table->getDisplayField($key);
355-
echo "<th data-column=\"$key\" data-search-column=\"$searchColumn\" class=\"$class\"><a href=\"$link\">".df_escape($label)."</a> $legend</th>";
355+
echo "<th data-column=\"$key\" data-search-column=\"$searchColumn\" class=\"$class\"><a class='sort-link' href=\"$link\"><i class='material-icons'>sort</i></a><span class='th-label'>".df_escape($label)."</span> $legend</th>";
356356
}
357357
}
358358
}
@@ -606,11 +606,21 @@ function getResultFilters(){
606606
$query =& $app->getQuery();
607607

608608
echo '<div class="resultlist-filters">
609-
<h3>'.df_translate('scripts.Dataface_ResultList.MESSAGE_FILTER_RESULTS', 'Filter Results').':</h3>
609+
<h3 class="resultlist-filters-heading">'.df_translate('scripts.Dataface_ResultList.MESSAGE_FILTER_RESULTS', 'Filter Results').':</h3>
610610
<script language="javascript"><!--
611611
612-
function resultlist__updateFilters(col,select){
612+
function resultlist__updateAllFilters() {
613613
var currentURL = "'.$app->url('').'";
614+
var selects = document.querySelectorAll(\'.resultlist-filters select\');
615+
selects.forEach(function(select) {
616+
currentURL = resultlist__updateFilters(select.getAttribute(\'data-col\'), select, currentURL);
617+
});
618+
window.location = currentURL;
619+
}
620+
621+
function resultlist__updateFilters(col,select, currentURL){
622+
var autoRedirect = currentURL ? false : true;
623+
currentURL = currentURL || "'.$app->url('').'";
614624
var currentParts = currentURL.split("?");
615625
var currentQuery = "?"+currentParts[1];
616626
var value = select.options[select.selectedIndex].value;
@@ -626,12 +636,20 @@ function resultlist__updateFilters(col,select){
626636
currentQuery += \'&\'+col+\'==\'+encodeURIComponent(value);
627637
}
628638
currentQuery = currentQuery.replace(/([&\?])-skip=[^&]+/, "$1");
629-
window.location=currentParts[0]+currentQuery;
639+
if (autoRedirect) {
640+
window.location=currentParts[0]+currentQuery;
641+
} else {
642+
return currentParts[0]+currentQuery;
643+
}
630644
}
631645
//--></script>
632646
<ul>';
633647

634648
$qb = new Dataface_QueryBuilder($this->_table->tablename, $query);
649+
$autoUpdateFilters = true;
650+
if (isset($app->prefs['auto_update_filters']) and !$app->prefs['auto_update_filters']) {
651+
$autoUpdateFilters = false;
652+
}
635653
foreach ( $this->_filterCols as $col ){
636654
$field =& $this->_table->getField($col);
637655

@@ -643,8 +661,11 @@ function resultlist__updateFilters(col,select){
643661
$vocab=null;
644662

645663
}
646-
647-
echo '<li> '.df_escape($field['widget']['label']).' <select onchange="resultlist__updateFilters(\''.addslashes($col).'\', this);"><option value="">'.df_translate('scripts.GLOBAL.LABEL_ALL', 'All').'</option>';
664+
$onchange = 'onchange="resultlist__updateFilters(\''.addslashes($col).'\', this);"';
665+
if (!$autoUpdateFilters) {
666+
$onchange = '';
667+
}
668+
echo '<li> '.df_escape($field['widget']['label']).' <select data-col="'.htmlspecialchars($col).'" '.$onchange.'><option value="">'.df_translate('scripts.GLOBAL.LABEL_ALL', 'All').'</option>';
648669

649670
$res = df_query("select `$col`, count(*) as `num` ".$qb->_from()." ".$qb->_secure( $qb->_where(array($col=>null)) )." group by `$col` order by `$col`", null, true);
650671
if ( !$res and !is_array($res)) trigger_error(xf_db_error(df_db()), E_USER_ERROR);
@@ -668,7 +689,12 @@ function resultlist__updateFilters(col,select){
668689
//@xf_db_free_result($res);
669690
echo '</select></li>';
670691
}
671-
echo '</ul></div>';
692+
693+
echo '</ul>';
694+
if (!$autoUpdateFilters) {
695+
echo '<div class="resultlist-filters-buttons"><button onclick="resultlist__updateAllFilters();"><i class="material-icons">update</i> Update</button></div>';
696+
}
697+
echo '</div>';
672698
$out = ob_get_contents();
673699
ob_end_clean();
674700
return $out;

Dataface/SkinTool.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,8 @@ function actions_menu($params, &$smarty){
693693
if ( isset($params['maxcount']) and intval($params['maxcount']) < count($context['actions']) ){
694694
$more = array(
695695
'name'=>'more',
696-
'label'=> df_translate('actions_menu.more.label', 'More'),
696+
'label'=> "",
697+
'materialIcon' => 'more_vert',
697698
'subactions' => array(),
698699
'description' => df_translate('actions_menu.more.description','More actions...'),
699700
'url'=>'#'
@@ -1052,7 +1053,7 @@ function bread_crumbs($params, &$smarty){
10521053
$base = '';
10531054
if ( $record ){
10541055
foreach ( $record->getBreadCrumbs() as $label=>$url){
1055-
$base .= ' :: <a href="'.$url.'" id="bread-crumbs-'.str_replace(' ','_', $label).'">'.$label.'</a>';
1056+
$base .= ' :: <a href="'.htmlspecialchars($url).'" id="bread-crumbs-'.htmlspecialchars(str_replace(' ','_', $label)).'">'.htmlspecialchars($label).'</a>';
10561057
}
10571058
}
10581059
$base = substr($base, 4);
@@ -1066,7 +1067,7 @@ function bread_crumbs($params, &$smarty){
10661067
$base = '';
10671068

10681069
foreach ( $bc as $label=>$url){
1069-
$base .= ' :: <a href="'.$url.'" id="bread-crumbs-'.str_replace(' ','_', $label).'">'.$label.'</a>';
1070+
$base .= ' :: <a href="'.htmlspecialchars($url).'" id="bread-crumbs-'.htmlspecialchars(str_replace(' ','_', $label)).'">'.htmlspecialchars($label).'</a>';
10701071
}
10711072
}
10721073
}
@@ -1084,7 +1085,7 @@ function bread_crumbs($params, &$smarty){
10841085
$base .= ' :: '.Dataface_LanguageTool::translate(
10851086
$action['label_i18n'],
10861087
$action['label']);
1087-
return "<b>".df_translate('scripts.Dataface_SkinTool.LABEL_BREADCRUMB', "You are here").":</b> ".$base;
1088+
return "<b><i class='material-icons' style='font-size:100%'>bookmark</i></b> ".$base;
10881089
}
10891090

10901091
function search_form($params, &$smarty){

Dataface/templates/Dataface_ActionsMenu.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232
{foreach from=$action.atts item=actionAttValue key=actionAttName}{$actionAttName|escape}="{$actionAttValue|escape}" {/foreach}
3333
>
3434

35-
<a class="{if $action.subactions}trigger{/if}" id="{$id_prefix}{$action.id|escape}-link" href="{$action.url|escape}"{if $action.onclick} onclick="{$action.onclick|escape}"{/if}{if $action.target} target="{$action.target|escape}"{/if}
35+
<a {if $action.subactions}onclick="return false;" {/if}class="{if $action.subactions}trigger{/if}" id="{$id_prefix}{$action.id|escape}-link" href="{$action.url|escape}"{if $action.onclick} onclick="{$action.onclick|escape}"{/if}{if $action.target} target="{$action.target|escape}"{/if}
3636
accesskey="{$action.accessKey|escape}" title="{$action.description|escape}" data-xf-permission="{$action.permission|escape}"
3737
{if $action.confirm}data-xf-confirm-message="{$action.confirm|escape}"{/if}
3838
>
39-
{if $action.icon}<img id="{$id_prefix}{$action.id}-icon" src="{$action.icon|escape}" alt="{$action.label|escape}"/>{/if}
39+
{if $action.icon}<img id="{$id_prefix}{$action.id}-icon" src="{$action.icon|escape}" alt="{$action.label|escape}"/>{/if}
40+
{if $action.materialIcon}<i class="material-icons {$action.materialIconStyle|escape}">{$action.materialIcon|escape}</i>{/if}
41+
{if !$action.icon and !$action.materialIcon and $action.subactions}<i class="material-icons {$action.materialIconStyle|escape}">arrow_drop_down</i>{/if}
4042
<span class="action-label">{$action.label|escape}</span>
4143

4244
</a>
@@ -50,11 +52,12 @@
5052
{if $subaction.subactions}xf-dropdown{/if}"
5153
{foreach from=$subaction.atts item=subactionAttValue key=subactionAttName}{$subactionAttName|escape}="{$subactionAttValue|escape}" {/foreach}
5254
>
53-
<a class="{if $subaction.subactions}trigger horizontal-trigger{/if}" id="{$id_prefix}{$subaction.id|escape}-link" href="{$subaction.url|escape}"{if $subaction.onclick} onclick="{$subaction.onclick|escape}"{/if}{if $subaction.target} target="{$subaction.target|escape}"{/if}
55+
<a {if $subaction.subactions}onclick="return false;" {/if}class="{if $subaction.subactions}trigger horizontal-trigger{/if}" id="{$id_prefix}{$subaction.id|escape}-link" href="{$subaction.url|escape}"{if $subaction.onclick} onclick="{$subaction.onclick|escape}"{/if}{if $subaction.target} target="{$subaction.target|escape}"{/if}
5456
accesskey="{$subaction.accessKey|escape}" title="{$subaction.description|escape}" data-xf-permission="{$subaction.permission|escape}"
5557
{if $subaction.confirm}data-xf-confirm-message="{$subaction.confirm|escape}"{/if}
5658
>
5759
{if $subaction.icon}<img id="{$id_prefix}{$subaction.id}-icon" src="{$subaction.icon|escape}" alt="{$subaction.label|escape}"/>{/if}
60+
{if $subaction.materialIcon}<i class="material-icons {$subaction.materialIconStyle|escape}">{$subaction.materialIcon|escape}</i>{/if}
5861
<span class="action-label">{$subaction.label|escape}</span>
5962

6063
</a>
@@ -69,8 +72,11 @@
6972
<a id="{$id_prefix}{$subsubaction.id|escape}-link" href="{$subsubaction.url|escape}"{if $subsubaction.onclick} onclick="{$subsubaction.onclick|escape}"{/if}{if $subsubaction.target} target="{$subsubaction.target|escape}"{/if}
7073
accesskey="{$subsubaction.accessKey|escape}" title="{$subsubaction.description|escape}" data-xf-permission="{$subsubaction.permission|escape}"
7174
{if $subsubaction.confirm}data-xf-confirm-message="{$subsubaction.confirm|escape}"{/if}
75+
7276
>
7377
{if $subsubaction.icon}<img id="{$id_prefix}{$subsubaction.id}-icon" src="{$subsubaction.icon|escape}" alt="{$subsubaction.label|escape}"/>{/if}
78+
{if $subsubaction.materialIcon}<i class="material-icons {$subsubaction.materialIconStyle|escape}">{$subsubaction.materialIcon|escape}</i>{/if}
79+
7480
<span class="action-label">{$subsubaction.label|escape}</span>
7581

7682
</a>

Dataface/templates/Dataface_Edit_Record_inc.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
2+
<div class="edit-record-wrapper">
33
{assign var="record" value=$ENV.APPLICATION_OBJECT->getRecord()}
44
{assign var="tableSingularLabel" value=$ENV.table_object->getSingularLabel()|escape}
55
{assign var="recordTitle" value=$record->getTitle()|truncate:50|escape}
6-
<h3>
6+
<h3 class="edit-record-heading">
77
{translate id="Edit Record Form Heading" tablename=$tableSingularLabel recordTitle=$recordTitle}
88
Edit {$tableSingularLabel|escape} &raquo; {$recordTitle|escape}
99
{/translate}
@@ -44,3 +44,4 @@ <h3>
4444
{if $tabs and $tabs|@count>1}
4545
</div><!-- tabs-panel -->
4646
{/if}
47+
</div><!-- edit-record-wrapper -->

Dataface/templates/Dataface_FindForm.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
so that we have that cool animation effect it the user wants to
188188
hide a section.
189189
*}
190-
190+
<div class="xf-form-group-wrapper">
191191
{collapsible_sidebar heading=$section.header}
192192
{block name="before_findform_table"}
193193
<table width="100%" class="Dataface_QuickForm-table-wrapper Dataface_FindForm-table-wrapper">
@@ -272,6 +272,7 @@
272272
</table>
273273
{block name="after_findform_table"}
274274
{/collapsible_sidebar}
275+
</div>
275276
{/foreach}
276277

277278
</form>

0 commit comments

Comments
 (0)