function cut_words($params) { if (!$params[1]) { $params[1] = ' '; } if (isset($params[3])) { return XSTRING::findncut_symbol_positon($params[0], $params[1], $params[2], $params[3]); } return XSTRING::findncut_symbol_positon($params[0], $params[1], $params[2]); }
function as_select_opt($arr_assoc, $elementname = null, $is_empty = '') { if (is_array($arr_assoc)) { if (XSTRING::is_string_int($elementname)) { $elementname = (int) $elementname; } foreach ($arr_assoc as $key => $val) { //for multiply selectors if (is_array($elementname)) { $fkey = array_key_exists($key, $elementname); if ($fkey) { $selected = "selected"; } else { $selected = ''; } } else { if ($elementname === $key) { $selected = "selected"; } else { $selected = ""; } } $ext = $ext . "<option value='{$key}' {$selected} >{$val}</option>\r"; } if ($is_empty) { $ext = "<option value=' ' selected >{$is_empty}</option>\r" . $ext; } return $ext; } }
function select_objects($params) { if ($params['spack']['endleafs']) { $params['spack']['ancestors'][$params['spack']['endleafs']][] = $params['spack']['ancestor']['ancestor']; unset($params['spack']['ancestor']['ancestor']); } if (is_array($params['spack'])) { foreach ($params['spack'] as $stype => $svalues) { switch ($stype) { case 'to': $svalues = XARRAY::clear_empty_items($svalues); while (list($k, $v) = each($svalues)) { $svalues[$k] = XSTRING::date_recognize($v); } if (!empty($svalues)) { $OM = $this->_tree->Search($svalues, false, false, $OM, '<='); if (empty($OM)) { break 2; } } break; case 'from': $svalues = XARRAY::clear_empty_items($svalues); while (list($k, $v) = each($svalues)) { $svalues[$k] = XSTRING::date_recognize($v); } if (!empty($svalues)) { $OM = $this->_tree->Search($svalues, false, false, $OM, '>='); if (empty($OM)) { break 2; } } break; case 'rlike': case 'rwords': case 'lrlike': $svalues = XARRAY::clear_empty_items($svalues); if ($stype == 'rwords') { $or = 1; } else { $or = 0; } if (!empty($svalues)) { $OMR = $this->_tree->Search($svalues, false, false, null, $stype, null, null, $or); if (!$OM) { $OM = $OMR; } else { $OM = array_intersect($OMR, $OM); } if (empty($OM)) { break 2; } } break; case 'equal': $svalues = XARRAY::clear_empty_items($svalues); if (!empty($svalues)) { $OM = $this->_tree->Search($svalues, false, false, $OM, '='); if (empty($OM)) { break 2; } } break; case 'equalor': $svalues = XARRAY::clear_empty_items($svalues); if (!empty($svalues)) { if (XARRAY::array_depth($svalues) > 1) { foreach ($svalues as $v => $qa) { foreach ($qa as $c) { $ZM = $this->_tree->Search(array($v => $c), false, false, $ZM, '=', null, null, true); } } } else { $ZM = $this->_tree->Search($svalues, false, false, $ZM, '=', null, null, true); } if ($ZM && $OM) { $OM = array_intersect($ZM, $OM); } else { $OM = $ZM; } if (empty($OM)) { break 2; } } break; case 'inchildsall': $svalues = XARRAY::clear_empty_items($svalues); if (!empty($svalues)) { foreach ($svalues['id'] as $sv) { if ($childs = $this->_tree->Search(array('id' => $sv), true, false, null, '=')) { $childs = XARRAY::askeyval($childs, 'ancestor'); if (!$LOM) { !($LOM = $childs); } $LOM = array_intersect($LOM, $childs); } else { break 1; } } if ($OM) { $OM = array_intersect($LOM, $OM); } if (empty($OM)) { break 1; } } break; case 'inchilds': $svalues = XARRAY::clear_empty_items($svalues); $stop_level = array_keys($svalues); if (!empty($svalues)) { if ($childs = $this->_tree->Search($svalues, true, false, null, '=')) { $a = XARRAY::askeyval($childs, 'ancestor'); if ($OM) { $OM = array_intersect($a, $OM); } } else { break 3; } if (empty($OM)) { break 2; } } break; case 'ancestors': $svalues = XARRAY::clear_empty_items($svalues); $stop_level = array_keys($svalues); $ancestors = array(); $this->_tree->EXPcache = null; if (is_array(!$svalues[$stop_level[0]])) { $ancarr[] = trim($svalues[$stop_level[0]]); } else { $ancarr = $svalues[$stop_level[0]]; } if (is_array($ancarr)) { foreach ($ancarr as $anc) { if ($anc) { $a = $this->_tree->recursiveChildCollectFast($anc, array('_CATGROUP'), 'ASC', $stop_level[0]); } if (is_array($a)) { $ancestors = array_merge($ancestors, $a); } } } else { $ancestors = $ancarr; } if (is_array($params['spack']['ancestor'])) { $se = array('ancestor' => $ancestors) + $params['spack']['ancestor']; } else { $se = array('ancestor' => $ancestors); } if ($se['ancestor']) { if ($params['spack']['endleafs']) { $SOM = array(); $childs = $this->_tree->get_anc_multiply_childs2($se['ancestor'], $se['obj_type']); if ($childs) { $OM = array_intersect($OM, array_keys($childs)); } else { $OM = null; } } else { $OM = $this->_tree->Search(array('Disable' => ''), false, $se, $OM, '=', false, ' order by s.rate ASC'); } } if (empty($OM)) { break 2; } break; case 'ancestor': $svalues = XARRAY::clear_empty_items($svalues); if (!empty($svalues)) { $OM = $this->_tree->Search(null, false, $svalues, $OM, '=', false, ' order by s.rate ASC'); if (empty($OM)) { break 1; } } break; case 'sortby': $sortby = XARRAY::clear_empty_items($svalues); break; case 'sort': $sort = XARRAY::clear_empty_items($svalues); break; } } $endpage = $params['startpage'] + $params['Onpage']; if (!empty($OM) && is_array($OM)) { //убираем отключенные из результатаы if ($DOM = $this->_tree->Search(array('Disable' => '1'), false, array('id' => $OM))) { $OM = array_diff($OM, $DOM); } if ($sortby) { $OM = $this->sortby($OM, $sortby); } if ($sort) { $OM = $this->sorter($OM, $sort); } $obj_count = count($OM); if ($OM = array_slice($OM, $params['startpage'], $params['Onpage'])) { return array('objects' => $this->_tree->GetNodesByIdArray($OM, 'ASC', true), 'count' => $obj_count); } } } }
function CreateView() { global $TDB; if (!$this->_options['page_num_where']) { $this->_options['page_num_where'] = $this->_options['where']; } $this->pages_num = Common::get_nav_pages($this->_options['table'], $this->_options['rows_per_page'], $this->_options['page_num_where']); if (!$this->_options['startRow']) { $this->_options['startRow'] = 0; } if ($this->_options['rows_per_page']) { $limit = ' limit ' . $this->_options['startRow'] . ' , ' . $this->_options['rows_per_page']; } else { $limit = ''; } if ($this->_options['where']) { $where = ' where ' . $this->_options['where']; } if (!$this->_options['customSqlQuery']) { $query = 'select ' . implode(',', $this->_options['columns']) . ' from ' . $this->_options['table'] . $where . $limit; } else { $query = $this->_options['customSqlQuery']; } if ($results = $TDB->get_results($query)) { if ($this->_options['filter'] or $this->_options['gridFormat']) { while (list($id, $record) = each($results)) { if ($this->_options['filter']) { foreach ($this->_options['filter'] as $field => $filter) { switch ($filter['name']) { case 'fromtimestamp': $record[$field] = date($filter['format'], $record[$field]); break; case 'cutwords': $record[$field] = XSTRING::findncut_symbol_positon($record[$field], " ", $filter['count']); break; } } } $result[$id] = $record; if ($this->_options['gridFormat']) { foreach ($record as $key => $val) { if ($this->_options['callfunc'][$key]) { $context = $this->_options['callfunc'][$key][0]; $func = $this->_options['callfunc'][$key][1]; $result[$id][$key] = $context->{$func}($val, $id); } } $nsq = null; if (is_array($this->_options['sequence'])) { foreach ($this->_options['sequence'] as $sq) { $nsq[] = $result[$id][$sq]; } $result[$id] = $nsq; } $result['rows'][$result[$id][0]] = array('data' => array_values($result[$id])); unset($result[$id]); } } return $result; } else { return $results; } } }
} //трансформ по функции if ($tempValue['onAttribute']) { $extData[$tempValue['name']] = $tempValue['onAttribute']($tempValue['onAttributeParams'], $extData[$tempValue['name']], $id); } } if ($this->_options['onRecord']) { $extData = $this->_options['onRecord']($extData); } if ($this->_options['gridFormat']) { $r = array('id' => $id, 'data' => $extData, 'obj_type' => $node['obj_type']); if ($childsNodes->HasChild($id)) { $r['xmlkids'] = 1; } $result['data_set']['rows'][$id] = $r; } else { $result['data_set'][$id] = $extData; } } } return $result; } } } //endclass treeJsonSource::$fromTimeStamp = function ($params, $value, $id) { return date($params['format'], $value); }; treeJsonSource::$cutWords = function ($params, $value) { return XSTRING::findncut_symbol_positon($value, " ", $params['count']); };