????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.55 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.astacus.se/wp-content/plugins/cornerstone/includes/classes/data/ |
Upload File : |
<?php
class Cornerstone_Reducer {
public $data_sets = array();
public $walker_class = 'Cornerstone_Walker';
public $set_ids = array();
public function __construct( $items, $walker_class = null ) {
if ( $walker_class && class_exists( $walker_class ) ) {
$this->walker_class = $walker_class;
}
$walker = new $this->walker_class( $items );
$walker->walk( array( $this, 'reduce_elements' ) );
$this->sort();
}
public function get_type_field( $walker ) {
$item = $walker->data();
return $item['_type'];
}
public function get_id_field( $walker ) {
return '_id';
}
public function get_data( $walker ) {
return $walker->data();
}
public function sort() {
ksort($this->data_sets);
}
public function reduce_elements( $walker ) {
$type = $this->get_type_field( $walker );
if ( !isset( $this->data_sets[$type] ) ) {
$this->data_sets[$type] = array();
}
$data = $this->get_data( $walker );
$id_field = $this->get_id_field( $walker );
if ( !isset( $data[$id_field] ) ) {
return;
}
$id = $data[$id_field];
unset( $data[$id_field] );
unset( $data[$walker->child_key]);
$key = md5(serialize($data));
if ( !isset( $this->set_ids[$key] ) ) {
$this->set_ids[$key] = array();
}
$this->set_ids[$key][] = $id;
$this->data_sets[$type][$key] = $data;
}
public function iterate( $callable ) {
foreach ( $this->data_sets as $type => $set ) {
foreach ( $set as $id_key => $reduced_set ) {
call_user_func_array( $callable, array( $type, $this->set_ids[$id_key], $reduced_set ) );
}
}
}
}