Skip to content

Commit 4cfa3bc

Browse files
committed
Added new sort and filter functionality to related lists.
Implemented related list for mobile theme.
1 parent e1215ca commit 4cfa3bc

26 files changed

+1827
-348
lines changed

Dataface/ActionTool.php

+13
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ function getActions($params=array(), $actions=null){
197197
}
198198
}
199199

200+
if (@$params['category'] == '__relationships__') {
201+
// Special case. The __relationships__ category will get the table's relationship as actions.
202+
if (!$tablename) {
203+
$query = $app->getQuery();
204+
$tablename = $query['-table'];
205+
}
206+
$table = Dataface_Table::loadTable($tablename);
207+
if (PEAR::isError($table)) {
208+
throw new Exception("Cannot find table: ".$tablename);
209+
}
210+
return $table->getRelationshipsAsActions([]);
211+
}
212+
200213
if ( $tablename !== null ){
201214
// Some actions are loaded from the table's actions.ini file and must be loaded before we return the actions.
202215
$table =& Dataface_Table::loadTable($tablename);

Dataface/Application.php

+1
Original file line numberDiff line numberDiff line change
@@ -3172,6 +3172,7 @@ function testCondition($condition, $context=null){
31723172
$resultSet = $app->getResultSet();
31733173
if ( isset($context['record']) ) $record = $context['record'];
31743174
else $record = $app->getRecord();
3175+
$related_record = @$context['related_record'];
31753176

31763177
if ( isset($context['relationship']) ){
31773178
//$tableObj =& Dataface_Table::loadTable($table);

Dataface/QueryBuilder.php

+23-22
Original file line numberDiff line numberDiff line change
@@ -757,30 +757,31 @@ function _fieldWhereClause(&$field, $value, &$use_where, $tableAlias=null){
757757
}
758758

759759
/**
760-
* @brief A wrapper around the _where() method that optionally takes
761-
* a Dataface_Record object as a parameter. This produces just the
762-
* where clause of an SQL query.
763-
*
764-
* @param mixed $query Either an array of parameters or a Dataface_Record object
765-
* which will be used for its keys.
766-
* @param Boolean $merge Whether to merge the criteria with the object's
767-
* current query.
768-
* @return string The where clause e.g. "WHERE name='Steve' and age=29"
769-
* @since 2.0.3
770-
*/
771-
public function where($query = null, $merge=true){
772-
if ( $query instanceof Dataface_Record ){
773-
$record = $query;
774-
$keys = array_keys($record->table()->keys());
775-
$query = array();
776-
foreach ($keys as $key){
777-
$query[$key] = "=".$this->_serializer->serialize($key, $record->val($key));
778-
}
779-
} else if ( !isset($query) ){
780-
$query = array();
760+
* @brief A wrapper around the _where() method that optionally takes
761+
* a Dataface_Record object as a parameter. This produces just the
762+
* where clause of an SQL query.
763+
*
764+
* @param mixed $query Either an array of parameters or a Dataface_Record object
765+
* which will be used for its keys.
766+
* @param Boolean $merge Whether to merge the criteria with the object's
767+
* current query.
768+
* @return string The where clause e.g. "WHERE name='Steve' and age=29"
769+
* @since 2.0.3
770+
*/
771+
public function where($query = null, $merge=true){
772+
if ( $query instanceof Dataface_Record ){
773+
$record = $query;
774+
$keys = array_keys($record->table()->keys());
775+
$query = array();
776+
foreach ($keys as $key){
777+
$query[$key] = "=".$this->_serializer->serialize($key, $record->val($key));
781778
}
782-
return $this->_where($query, $merge);
779+
} else if ( !isset($query) ){
780+
$query = array();
783781
}
782+
return $this->_where($query, $merge);
783+
}
784+
784785

785786
/**
786787
* Returns the where clause for the sql query.

0 commit comments

Comments
 (0)