Esempio n. 1
0
 /**
  *
  * @param type $corename
  */
 public static function init($corename = DEFAULT_TEST_CORENAME)
 {
     $CB_PATH = \CB_DOC_ROOT;
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['SERVER_NAME'] = static::getHost();
     $_GET['core'] = $corename;
     $_SESSION['user'] = array('id' => 1, 'groups' => []);
     require_once $CB_PATH . '/config.php';
     require_once $CB_PATH . '/lib/language.php';
     L\initTranslations();
     Config::setEnvVar('user_language_index', 1);
 }
Esempio n. 2
0
 protected function getData($p)
 {
     $rez = array();
     if (empty($p)) {
         return $rez;
     }
     // form columns
     L\initTranslations();
     $defaultColumns = Config::getDefaultGridColumnConfigs();
     $columns = $defaultColumns;
     // retreive data
     $p['start'] = 0;
     $p['rows'] = 500;
     $sr = new \CB\BrowserView();
     $results = $sr->getChildren($p);
     if (!empty($results['DC'])) {
         $columns = array();
         foreach ($results['DC'] as $colName => $col) {
             if (@$col['hidden'] !== true) {
                 $columns[$colName] = $col;
             }
         }
     }
     $colTitles = array();
     foreach ($columns as $name => &$col) {
         $colTitles[] = empty($defaultColumns[$name]) ? @Util\coalesce($col['title'], $name) : $defaultColumns[$name]['title'];
     }
     //insert header
     $rez[] = $colTitles;
     while (!empty($results['data'])) {
         foreach ($results['data'] as $r) {
             $record = array();
             foreach ($columns as $colName => $col) {
                 if (@$col['xtype'] == 'datecolumn') {
                     $value = Util\dateISOToMysql(@$r[$colName]);
                     if (!empty($col['format'])) {
                         $value = Util\formatMysqlTime($value, $col['format']);
                     } else {
                         $value = Util\formatMysqlTime($value);
                         $tmp = explode(' ', $value);
                         if (!empty($tmp[1]) && $tmp[1] == '00:00') {
                             $value = $tmp[0];
                         }
                     }
                     $record[] = $value;
                 } elseif (strpos($colName, 'date') === false) {
                     if (in_array($colName, array('oid', 'cid', 'uid')) && !empty($r[$colName])) {
                         $record[] = User::getDisplayName($r[$colName]);
                     } else {
                         $record[] = @$r[$colName];
                     }
                 }
             }
             $rez[] = $record;
         }
         if ($p['start'] + $p['rows'] < $results['total']) {
             $p['start'] += $p['rows'];
             $results = $sr->getChildren($p);
         } else {
             $results['data'] = array();
         }
     }
     return $rez;
 }