function getTree($module = '') { $items = array(); $sql = 'SELECT * FROM {{tree}} WHERE id=' . Funcs::$uri[2] . ''; $data = DB::getRow($sql); $sql = 'SELECT modul2 FROM {{relations}} WHERE modul1=\'tree\' AND id1=' . Funcs::$uri[2] . ' AND id2=0'; $path = DB::getOne($sql); if ($path) { $sql = 'SELECT * FROM {{modules}} WHERE path=\'' . $path . '\''; $moduleraz = DB::getRow($sql); } $sql = 'SELECT modul2 FROM {{relations}} WHERE modul1=\'tree\' AND id1=' . Funcs::$uri[2] . ' AND id2=1'; $path = DB::getOne($sql); $sql = 'SELECT * FROM {{modules}} WHERE path=\'' . $path . '\''; $module = DB::getRow($sql); if (!$moduleraz) { $moduleraz = $module; } $data['module'] = $module; $data['moduleraz'] = $moduleraz; $data['list'] = array(); $order = 'num'; if (trim($_GET['sort']) != '') { $order = $_GET['sort'] . ' ' . (isset($_GET['desc']) ? 'DESC' : ''); } if (strpos($data['moduleraz']['path'], 'struct_') !== false && is_numeric($_GET['ve'])) { $sql = ' SELECT {{tree}}.* FROM {{tree}} LEFT JOIN {{catalog}} ON {{tree}}.id={{catalog}}.tree WHERE {{tree}}.parent=' . Funcs::$uri[2] . ' AND {{catalog}}.vendor=' . $_GET['ve'] . ' ORDER BY {{tree}}' . $order . ' '; } else { $sql = 'SELECT * FROM {{tree}} WHERE parent=' . Funcs::$uri[2] . ' ORDER BY ' . $order . ''; } $items = DB::getPagi($sql); $fields = Fields::getOutFieldsByTree(1); foreach ($items as $item) { $sql = 'SELECT modul2 FROM {{relations}} WHERE modul1=\'tree\' AND id1=' . $item['id'] . ' AND id2=1'; $path = DB::getOne($sql); $sql = 'SELECT * FROM {{modules}} WHERE path=\'' . $path . '\''; $module = DB::getRow($sql); $item['udate'] = date('d.m.Y H:i:s', strtotime($item['udate'])); $item['module'] = array('id' => $module['id'], 'name' => $module['name'], 'path' => $module['path'], 'type' => $module['type']); foreach ($fields as $field) { $text = OutFieldWidget::run($item['id'], $field, $data['module']); if ($field['type'] == 'editor') { if (strlen(strip_tags($text)) > 50) { $text = substr(strip_tags($text), 0, strpos(strip_tags($text), ' ', 50)) . '...'; } else { $text = strip_tags($text); } } $item['fields'][$field['path']] = $text; } $data['list'][] = $item; } return $data; }
function getGallery($row) { $row['files'] = array(); $value = OutFieldWidget::getValue($row['path']); $row['id'] = $value['id']; if ($row['id']) { $sql = ' SELECT id2 FROM {{relations}} WHERE modul1=\'data\' AND modul2=\'files\' AND id1=' . $row['id'] . ' '; $fileId = DB::getAll($sql, 'id2'); if (count($fileId) > 0) { $sql = ' SELECT * FROM {{files}} WHERE id IN (' . implode(',', $fileId) . ') ORDER BY num '; $temp = DB::getAll($sql); foreach ($temp as $item) { $item['file'] = Funcs::getFileInfo($item['path']); $row['files'][] = $item; } } } if (count($row['files']) > 0) { return View::getWidget('outfields/gallery', $row); } else { return ''; } }