Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-19348 | php8.2 #27

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ee04330
make pngs non executable
Nov 25, 2014
4207e96
make php non executable
Nov 25, 2014
399b6b5
make all other files non executable
Nov 25, 2014
57df9d9
added ordering-possibility
Dec 1, 2014
aa2e03d
added sorting to default-index
Dec 1, 2014
c3bb1bf
added searchable fields
Dec 1, 2014
0b4d4b6
added searchable-fields on default
Dec 2, 2014
1110036
added pagination
Dec 9, 2014
803175c
fixed pagination on radiums internal models
Dec 9, 2014
0b2c411
fix camel case issue in radium scaffold handling
Feb 10, 2015
e7d98a5
Merge branch 'master' of https://github.com/whowgames/radium
Feb 10, 2015
0076648
No default sort in BaseModel anymore
Mar 4, 2015
b848d00
added functionality for own titles
Mar 4, 2015
f21e1ab
added disabling-function for search and actions in header
Mar 5, 2015
b88698b
added pagination through conditioned results with a nasty hack
Mar 16, 2015
f0fe41d
added ordering with active query-conditions
Mar 16, 2015
9438a17
added possibility for searching in different log-collections provided…
Mar 16, 2015
62bfb92
added collection as param to pagination
Mar 16, 2015
25185e3
added new helper in handlebars named ifcolor
Mar 17, 2015
fd786f6
fixing broken query on $in
Apr 13, 2015
8626aa3
disable versioning in radium per default
Apr 30, 2015
3ce4f69
added basic mysql-conditionhandling
May 11, 2015
131d4cb
pimp search function from radium to be abble to exclude default field…
May 18, 2015
fa00358
update radium search conditions
May 21, 2015
89a6dba
keep query-data on page-reload
May 26, 2015
8ee076b
added or-conditions to mysql-handling
May 26, 2015
64848e5
made it possible to search for MongoObjectIds
May 28, 2015
d72cfe1
Disabled widget Configurations MongoDB query
Jun 11, 2015
87e3f43
fix navigation active issue in radium
Sep 21, 2015
65c0a66
Merge branch 'master' of https://github.com/whowgames/radium
Sep 21, 2015
a165d3a
return default values instead of configurations
Nov 16, 2015
23ae79c
return instead of wrong values
Nov 16, 2015
0865c44
findByMd5 dos not exist
Nov 26, 2015
2ab17bf
Merge branch 'master' of https://github.com/whowgames/radium
Nov 26, 2015
2ddd645
radium change - findByMd5 dos not exist
Nov 26, 2015
2ad1f31
radium change - findByMd5 dos not exist
Nov 26, 2015
34c8a1f
Who cares about the unfiltered count if this executes a second query …
Nov 27, 2015
2d24312
added some equals
motammi Jun 23, 2016
066bb9a
replace all occurrences of String class with StringDeprecated, remove…
Jul 30, 2016
4a196a8
__METHOD__ behavior has changed
Jul 30, 2016
b29fb68
replace all occurrences of String class with StringDeprecated
Jul 30, 2016
1fec936
fix..
Jul 30, 2016
ee6b0dc
remove empty objects
AnnaHenschel Sep 13, 2016
7e6e225
Merge branch 'master' of git://github.com/whowgames/radium
AnnaHenschel Sep 13, 2016
43759e0
remove emptyObjects
AnnaHenschel Sep 14, 2016
833ca79
add removeEmptySelect and mulselect
AnnaHenschel Sep 14, 2016
d1827a4
add removeEmptySelect and mulselect
AnnaHenschel Sep 14, 2016
5f1a581
Fixes: #1442 Repayment
skocic Oct 10, 2016
e806ece
Merge branch 'master' into php7
Dec 15, 2016
a385a63
PHP7 fixes..
Jan 2, 2017
ba1e599
fix..
Jan 3, 2017
79383c1
- refactor Tracking, enable params
skocic Jan 30, 2017
29ca359
Merge remote-tracking branch 'origin/master'
skocic Jan 30, 2017
54da74e
fix camel case named controllers
Jun 20, 2017
0d6cd72
php 7.2 fixes
Feb 22, 2018
aa04e1b
Revert is_object check, instead suppress PHP warning
Jul 17, 2018
cc7e832
Fixed namespace error in Neon library when using DataTime.
Feb 13, 2019
f46e076
allow float as numeric type to edit with more granular numbers possib…
Jun 24, 2020
62bc9ee
fix notice
Oct 18, 2020
8359903
remove short open tags
Jan 5, 2021
6ecd5f5
stop enforcing name
May 27, 2021
3c10153
fix
Jun 20, 2022
78be8ee
force float
Jul 4, 2022
5b58730
change deprecated order of glue and pieces for implode function
whow-rkro Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.DS_Store
.idea/
6 changes: 3 additions & 3 deletions config/bootstrap/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use lithium\action\Response;
use lithium\net\http\Media;
use lithium\util\Set;
use lithium\util\String;
use lithium\util\StringDeprecated;
use Handlebars\Autoloader;

Media::type('default', null, array(
Expand Down Expand Up @@ -58,15 +58,15 @@
if ($scaffold && isset($data['object'])) {
$object = $data['object'] ? : array();
$replace = Set::flatten(array_merge(compact('scaffold'), $object));
$name = String::insert('{:scaffold.human} - {:_id}: {:name}.csv', $replace);
$name = StringDeprecated::insert('{:scaffold.human} - {:_id}: {:name}.csv', $replace);
foreach($fields as $field) {
fputcsv($out, array($field, isset($object[$field]) ? $object[$field] : ''));
}
}

if ($scaffold && isset($data['objects'])) {
$objects = $data['objects'] ? : array();
$name = String::insert('{:slug}.csv', $scaffold);
$name = StringDeprecated::insert('{:slug}.csv', $scaffold);
fputcsv($out, array_values($fields));
foreach($data['objects'] as $row) {
fputcsv($out, Set::flatten($row));
Expand Down
224 changes: 210 additions & 14 deletions controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,85 @@ protected function _message($message, array $options = array(), $key = 'flash_me
* @return array merged array with all $defaults, $options and named params
*/
protected function _search($conditions) {
$result = array('$or' => array());
foreach($conditions as $field => $value) {
if (empty($value) || $field == 'query') {
continue;
}
$result[$field] = array_filter((array) $value);
}
$result = array_filter($result);
if (!empty($conditions['query'])) {
$like = array('like' => sprintf('/%s/i', $conditions['query']));
$result['$or'][] = array('name' => $like);
$result['$or'][] = array('slug' => $like);
$result['$or'][] = array('notes' => $like);
$model = $this->scaffold['model'];

$dbType = $model::meta('connection');

switch($dbType) {

case 'mysql':
$result = array();
if(isset($conditions['query']) && strlen($conditions['query']) > 0){
if(isset($model::$_searchable)){
foreach($model::$_searchable AS $field){
$query[$field] = $conditions['query'];
}

if(count($model::$_searchable) > 1){
$result['OR'][] = $query;
}else{
$result = array_merge($result, $query);
}
}
}
unset($conditions['query']);

$conditions['resource'][] = '';

foreach($conditions AS $key => $condition){
$positions = array_keys($condition, '');;
foreach($positions AS $pos){
unset($conditions[$key][$pos]);
}
if(empty($conditions[$key])){
unset($conditions[$key]);
}
}

$result = array_merge($result, $conditions);

break;

default:
$result = array('$or' => array());
foreach ($conditions as $field => $value) {
if (empty($value) || $field == 'query') {
continue;
}
$result[$field] = array_filter((array)$value);
}
$result = array_filter($result);
if (!empty($conditions['query'])) {
if (isset($model::$_noLikeSearch) && $model::$_noLikeSearch) {
$like = sprintf('%s', $conditions['query']);
} else {
$like = array('like' => sprintf('/%s/i', $conditions['query']));
}



$skipDefaultSearch = true;
if (!isset($model::$_skipDefaultSearch) || $model::$_skipDefaultSearch == false) {
$result['$or'][] = array('name' => $like);
$result['$or'][] = array('slug' => $like);
$result['$or'][] = array('notes' => $like);
$skipDefaultSearch = false;
}

if(isset($model::$_searchable)){
foreach($model::$_searchable AS $field){
if($field == '_id' && preg_match('/\/([0-9a-z]{24})\//', $like['like'], $matches)){
if(isset($matches[1])){
$result['$or'][] = array(
'_id' => $matches[1]);
}
}else {
$result['$or'][] = array($field => $like);
}
}
}
}
break;
}
return $result;
}
Expand Down Expand Up @@ -125,6 +191,136 @@ protected function _options($defaults = array()) {
return $options;
}

/**
* Generates order out of named params
*
* @param string $defaults all default options you want to have set
* @return array merged array with all $defaults, $options and named params
*/
protected function _order($defaults = array()) {
$order = array();
if (!empty($this->request->query)) {
$query = $this->request->query;
if(isset($query['order'])){
if (!stristr($query['order'], ',')) {
$sorts[] = $query['order'];
}else{
$sorts = explode(',', $query['order']);
}
foreach($sorts AS $row){
if (stristr($row, ':')) {
list($key, $val) = explode(':', $row, 2);
$order[$key] = $val;
}
}
unset($this->request->query['order']);
}
}

$order = array_merge($defaults, $order);
return $order;
}


/**
* Generates offset out of params
*
* @param string $defaults all default options you want to have set
* @return array merged array with all $defaults, $options and named params
*/
protected function _offset($defaults = array()) {
$itemsPerPage = $defaults['itemsPerPage'];
$currentPage = $defaults['currentPage'];
$allItems = $defaults['allItems'];

$pages = ceil($allItems/$itemsPerPage);

if($currentPage > $pages){
$currentPage = $pages;
}

if($currentPage <= 0){
$currentPage = 1;
}

$offset = ($currentPage-1)*$itemsPerPage;
if($offset > $allItems){
$offset = $allItems-$itemsPerPage;
}

$limit = $offset+$itemsPerPage;
if($limit > $allItems){
$limit = $allItems;
}


return array(
'limit' => $limit,
'offset' => $offset,
'pages' => $pages,
'page' => $currentPage,
'itemsPerPage' => $itemsPerPage

);
}

/**
* Get current page
*
* @param string $defaults all default options you want to have set
* @return integer of current page/default=0
*/
protected function _currentPage($defaults = array()) {
$currentPage = 1;

if(isset($this->request->query['p'])){
$currentPage = (int) $this->request->query['p'];
}

if($currentPage < 1){
$currentPage = 1;
}
unset($this->request->query['p']);

return $currentPage;
}

/**
* Get queried conditions from get-params
*
* @param array $defaults all default options you want to have set
* @return array of current queried conditions via get-param
*/
protected function _queriedConditions($defaults = array()) {
$conditions = array();

if(isset($this->request->query['q'])){
$query = base64_decode($this->request->query['q']);

if(strlen($query) > 0){
$data = json_decode($query, true);
}

if(is_array($data) && !empty($data)){
if(isset($data['query'])) unset($data['query']);

foreach($data AS $k => $v){
if(isset($v[0]) && $v[0] === ''){
unset($data[$k][0]);
if(empty($data[$k])){
unset($data[$k]);
}
}
}
$conditions = $data;
}
}

unset($this->request->query['q']);

return $conditions;
}

/**
* allows ajaxified upload of files
*
Expand Down Expand Up @@ -177,4 +373,4 @@ protected function _upload(array $options = array()) {
}
}

?>
?>
Loading