Skip to content

Commit 721dc07

Browse files
authored
Merge pull request #1 from shannah/master
update from master branch
2 parents d362a84 + a728d5f commit 721dc07

File tree

4,138 files changed

+161251
-495811
lines changed

Some content is hidden

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

4,138 files changed

+161251
-495811
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.DS_Store
1+
.DS_Store
2+
/nbproject/private/

.htaccess

+3-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
# Apache 2.2
2-
<IfModule !mod_authz_core.c>
3-
Deny from all
4-
</IfModule>
5-
6-
# Apache 2.4
7-
<IfModule mod_authz_core.c>
8-
Require all denied
9-
</IfModule>
10-
ErrorDocument 403 "403 Access Restricted. <a href='installer.php'>Go to installer</a>"
11-
<FilesMatch "\.(png|jpg|gif|GIF|PNG|JPG|jpeg|JPEG|ICO|js|css|html|xml)$">
12-
# Apache 2.2
13-
<IfModule !mod_authz_core.c>
14-
Allow from all
15-
</IfModule>
16-
17-
# Apache 2.4
18-
<IfModule mod_authz_core.c>
19-
Require all granted
20-
</IfModule>
21-
</FilesMatch>
22-
<FilesMatch "(installer\.php|index\.php|install_form.js.php)$">
23-
# Apache 2.2
24-
<IfModule !mod_authz_core.c>
25-
Allow from all
26-
</IfModule>
27-
28-
# Apache 2.4
29-
<IfModule mod_authz_core.c>
30-
Require all granted
31-
</IfModule>
32-
</FilesMatch>
1+
RewriteEngine On
2+
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|woff|eot|woff2|ttf)$ 403.html [L]

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: php
2+
php: 7.0
3+
before-install:
4+
- sudo apt-get install mariadb-server mariadb-client
5+
script:
6+
- which mysqld
7+
- which mysql
8+
- mysql -V
9+
- export XATAFACE=`pwd`
10+
- cd ..
11+
- mkdir tests
12+
- cd tests
13+
- bash $XATAFACE/.travis/test_create.sh
14+
- rm -rf testapp
15+
- bash $XATAFACE/tests/runtests.sh

.travis/test_create.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -e
4+
ERROR=
5+
function print_errors() {
6+
exit_status=$?
7+
if [ -z $exit_status ]
8+
then
9+
echo "Exit status $exit_status"
10+
echo "mysql-errors.log:\n"
11+
cat testapp/log/mysql-errors.log
12+
else
13+
echo "OK. Exit status $exit_status\n"
14+
fi
15+
}
16+
trap print_errors EXIT
17+
php $XATAFACE/tools/create.php testapp
18+
cd testapp/bin
19+
bash install-module.sh calendar 1.0
20+
bash setup-auth.sh

403.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!doctype html>
2+
<html>
3+
<head>Access Restricted</head>
4+
<body>403 Access Restricted. <a href='installer.php'>Go to installer</a></body>
5+
</html>

DB/Sync.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ class DB_Sync {
1515
var $renamed = array();
1616
var $listeners = array();
1717

18-
function DB_Sync($db1, $db2, $table1=null, $table2=null, $renamed=null){
18+
function __construct($db1, $db2, $table1=null, $table2=null, $renamed=null){
1919
$this->db1 = $db1;
2020
$this->db2 = $db2;
2121

2222
$this->init($table1, $table2, $renamed);
2323
}
24+
function DB_Sync($db1, $db2, $table1=null, $table2=null, $renamed=null) { self::__construct($db1, $db2, $table1, $table2, $renamed); }
2425

2526

2627
/**

Dataface/ActionTool.php

+104-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*-------------------------------------------------------------------------------
2020
*/
21-
import('Dataface/LanguageTool.php');
21+
import(XFROOT.'Dataface/LanguageTool.php');
2222

2323
/**
2424
* A tool to manage actions within the application.
@@ -29,7 +29,7 @@ class Dataface_ActionTool {
2929
var $actions=array();
3030
var $tableActions=array();
3131

32-
function Dataface_ActionTool($conf=null){
32+
function __construct($conf=null){
3333
if ( $conf === null ){
3434
$this->_loadActionsINIFile(/*DATAFACE_PATH."/actions.ini"*/);
3535
//$this->_loadActionsINIFile(DATAFACE_SITE_PATH."/actions.ini");
@@ -38,12 +38,13 @@ function Dataface_ActionTool($conf=null){
3838
}
3939

4040
}
41+
function Dataface_ActionTool($conf=null) { self::__construct($conf); }
4142

4243

4344

4445
function _loadActionsINIFile(/*$path*/){
4546

46-
import('Dataface/ConfigTool.php');
47+
import(XFROOT.'Dataface/ConfigTool.php');
4748
$configTool =& Dataface_ConfigTool::getInstance();
4849
$actions =& $configTool->loadConfig('actions', null);
4950
foreach ( array_keys($actions) as $key){
@@ -72,7 +73,7 @@ function _loadActionsINIFile(/*$path*/){
7273
}
7374

7475
function _loadTableActions($tablename){
75-
import('Dataface/Table.php');
76+
import(XFROOT.'Dataface/Table.php');
7677
// Some actions are loaded from the table's actions.ini file and must be loaded before we return the actions.
7778

7879
$table =& Dataface_Table::loadTable($tablename);
@@ -148,6 +149,13 @@ function &getAction($params, $action=null){
148149

149150
}
150151

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+
151159
/**
152160
* Returns an array of all actions as specified by $params.
153161
* $params must be an array. It may contain the following options:
@@ -161,6 +169,25 @@ function getActions($params=array(), $actions=null){
161169
if ( !is_array($params) ){
162170
trigger_error("In Dataface_ActionTool::getActions(), expected parameter to be an array but received a scalar: ".$params.".".Dataface_Error::printStackTrace(), E_USER_ERROR);
163171
}
172+
if (@$params['category']) {
173+
$cats = $params['category'];
174+
if (is_string($cats)) {
175+
$pos = strpos($cats, '|');
176+
if ($pos !== false) {
177+
$cats = array_map('trim', explode('|', $cats));
178+
}
179+
180+
}
181+
if (is_array($cats)) {
182+
$out = [];
183+
foreach ($cats as $cat) {
184+
$params['category'] = $cat;
185+
$out = array_merge($out, $this->getActions($params, $actions));
186+
}
187+
return $out;
188+
}
189+
}
190+
164191
$app =& Dataface_Application::getInstance();
165192

166193
$out = array();
@@ -189,6 +216,19 @@ function getActions($params=array(), $actions=null){
189216
}
190217
}
191218

219+
if (@$params['category'] == '__relationships__') {
220+
// Special case. The __relationships__ category will get the table's relationship as actions.
221+
if (!$tablename) {
222+
$query = $app->getQuery();
223+
$tablename = $query['-table'];
224+
}
225+
$table = Dataface_Table::loadTable($tablename);
226+
if (PEAR::isError($table)) {
227+
throw new Exception("Cannot find table: ".$tablename);
228+
}
229+
return $table->getRelationshipsAsActions([]);
230+
}
231+
192232
if ( $tablename !== null ){
193233
// Some actions are loaded from the table's actions.ini file and must be loaded before we return the actions.
194234
$table =& Dataface_Table::loadTable($tablename);
@@ -209,14 +249,44 @@ function getActions($params=array(), $actions=null){
209249
}
210250
else $actions = $this->actions;
211251
}
252+
$excludes = null;
253+
if (@$params['exclude']) {
254+
$excludes = $params['exclude'];
255+
if (is_string($excludes)) {
256+
$excludes = explode(' ', $excludes);
257+
}
258+
}
212259
foreach ( array_keys($actions) as $key ){
213260
if ( isset($action) ) unset($action);
214261
$action = $actions[$key];
215262
$action['atts'] = array();
216-
263+
if ($excludes and in_array($action['name'], $excludes)) {
264+
continue;
265+
}
217266
if ( @$params['name'] and @$params['name'] !== @$action['name']) continue;
218267
if ( @$params['id'] and @$params['id'] !== @$action['id']) continue;
219-
268+
if ( @$params['withtags']) {
269+
if (!@$action['tags'] or strpos($action['tags'], $params['withtags']) === false) {
270+
continue;
271+
}
272+
}
273+
if (@$params['with']) {
274+
$missingKey = false;
275+
foreach (explode(' ', $params['with']) as $withKey) {
276+
if (!@$action[$withKey]) {
277+
$missingKey = true;
278+
break;
279+
}
280+
}
281+
if ($missingKey) {
282+
continue;
283+
}
284+
}
285+
if (@$params['sanstags']) {
286+
if (@$action['tags'] and strpos($action['tags'], $params['sanstags']) !== false) {
287+
continue;
288+
}
289+
}
220290
if ( isset($params['category']) and $params['category'] !== @$action['category']) continue;
221291
// make sure that the category matches
222292

@@ -271,11 +341,38 @@ function getActions($params=array(), $actions=null){
271341
}
272342
}
273343
}
344+
$i18nTable = @$params['table'];
345+
if (!$i18nTable) {
346+
if (!@$query) {
347+
$query = $app->getQuery();
348+
}
349+
$i18nTable = $query['-table'];
350+
}
351+
352+
$keyBase = 'tables.'.$i18nTable.'.actions.'.$action['name'].'.';
353+
$action['label'] = df_translate($keyBase.'label', @$action['label']);
354+
$action['description'] = df_translate($keyBase.'description', @$action['description']);
355+
$action['materialIcon'] = df_translate($keyBase.'materialIcon', @$action['materialIcon']);
356+
if (@$action['ajax'] and !@$action['ajax_action']) {
357+
$action['ajax_action'] = $action['name'];
358+
}
359+
if (@$action['ajax_action']) {
360+
xf_script('xataface/actions/ajax_action_client.js');
361+
$removeClass = 'undefined';
362+
if (@$action['ajax.on']) $removeClass = '\''.$action['ajax.on'].'\'';
363+
$addClass = 'undefined';
364+
if (@$action['ajax.off']) $addClass = '\''.$action['ajax.off'].'\'';
365+
$action['onclick'] = 'xataface.post(\''.$action['ajax_action'].'\',this, '.$removeClass.', '.$addClass.')';
366+
$action['url'] = 'javascript:void(0)';
367+
368+
369+
}
370+
274371
$out[$key] =& $action;
275372

276373
unset($action);
277374
}
278-
375+
279376
uasort($out, array(&$this, '_compareActions'));
280377
return $out;
281378
}

0 commit comments

Comments
 (0)