Example #1
0
 public static function Rendering($model, $columnsInfo, $filter, $perPage)
 {
     if ($filter != null) {
         $whereCondition = '$model::';
         $temp = [];
         foreach ($columnsInfo as $key => $value) {
             $temp = array_add($temp, $key, collect($value));
         }
         $columnsInfo = $temp;
         $filter = Filter::Interpret($filter, $columnsInfo);
         $operations = $filter['operations'];
         $operands = $filter['operands'];
         function find_key($alias, $columnsInfo)
         {
             foreach ($columnsInfo as $key => $col) {
                 if ($col->contains($alias)) {
                     return $key;
                 }
             }
         }
         function add_condition(&$isFirst, &$whereCondition, $key, $value, $colInfo, $operations, &$i)
         {
             if ($isFirst) {
                 $whereCondition .= "where('" . $key . "','" . $value[0] . "')->";
                 $isFirst = FALSE;
             } elseif ($operations != []) {
                 if ($operations[$i] == '&') {
                     $whereCondition .= "where('" . $key . "','" . $value[0] . "')->";
                     $i++;
                 } elseif ($operations[$i] == '|') {
                     $whereCondition .= "orWhere('" . $key . "','" . $value[0] . "')->";
                     $i++;
                 }
             }
         }
         function add_condition_wherethrough(&$isFirst, &$whereCondition, $key, $value, $colInfo, $operations, &$i)
         {
             $wherethrough = $colInfo['wherethrough'];
             $class = $colInfo['class'];
             $el = $class::where($wherethrough['key'], $value)->get();
             $id = $el->first()->{$wherethrough}['value'];
             if ($isFirst) {
                 $whereCondition .= "where('" . $key . "','" . $id . "')->";
                 $isFirst = FALSE;
             } elseif ($operations != []) {
                 if ($operations[$i] == '&') {
                     $whereCondition .= "where('" . $key . "','" . $id . "')->";
                     $i++;
                 } elseif ($operations[$i] == '|') {
                     $whereCondition .= "orWhere('" . $key . "','" . $id . "')->";
                     $i++;
                 }
             }
         }
         $i = 0;
         $isFirst = TRUE;
         foreach ($operands as $item) {
             $key = find_key(key($item), $columnsInfo);
             if (!$columnsInfo[$key]->has('wherethrough')) {
                 add_condition($isFirst, $whereCondition, $key, array_values($item), $columnsInfo[$key], $operations, $i);
             } else {
                 add_condition_wherethrough($isFirst, $whereCondition, $key, array_values($item), $columnsInfo[$key], $operations, $i);
             }
         }
         //            echo '<div style="direction: ltr">';
         //            \Symfony\Component\VarDumper\VarDumper::dump($operations);
         //            \Symfony\Component\VarDumper\VarDumper::dump($operands);
         //            \Symfony\Component\VarDumper\VarDumper::dump($columnsInfo);
         //            \Symfony\Component\VarDumper\VarDumper::dump($whereCondition);
         //            echo '</div>';
         return eval('return ' . $whereCondition . "paginate({$perPage});");
     } else {
         return $model::paginate($perPage);
     }
 }
Example #2
0
        TOOLBAR_formmaker::_DEFAULT();
        break;
}
switch ($task) {
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    case 'show_conditions':
        show_conditions();
        break;
    case 'change_choices':
        change_choices();
        break;
    case 'add_condition_fields':
        add_condition_fields();
        break;
    case 'add_condition':
        add_condition();
        break;
    case 'select_data_from_db':
        select_data_from_db();
        break;
    case 'show_ip_info':
        show_ip_info();
        break;
    case 'view_submissions':
        view_submissions();
        break;
    case 'featured_plugins':
        featured_plugins();
        break;
    case 'extensions':
        extensions();