function getGallery($row) { if ($row['tree'] !== 0) { $row['tree'] = $_REQUEST['id']; } if ($row['module']) { $row['name'] = FieldWidget::getFieldReserve($row, 'name'); } if (!$row['name']) { $row['name'] = $row['path']; $row['select'] = FieldWidget::getUndefinedFieldNames($row); } $row['path'] == '' ? $row['path'] = md5(microtime(true)) : ''; $row['files'] = array(); if (is_numeric($row['tree'])) { $sql = ' SELECT id FROM {{data}} WHERE tree=' . $row['tree'] . ' AND path=\'' . $row['path'] . '\' AND type=\'gallery\' '; $dataId = DB::getOne($sql); if ($dataId) { $sql = ' SELECT id2 FROM {{relations}} WHERE modul1=\'data\' AND modul2=\'files\' AND id1=' . $dataId . ' '; $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; } } } } View::widget('fields/gallery', $row); }
<?php } ?> <?php } ?> </table> </li> <?php } ?> <?php foreach ($fields as $item) { ?> <?php FieldWidget::run($item); ?> <?php } ?> </ul> <?php if ($_GET['tree'] != 'new') { ?> <div class="edit_form_section edit_form_section_other create-additional"> <table class="edit_form_table"> <tr> <td><strong>Создать дополнительно</strong></td> <td> <select class="jsSelectStyled" id="FieldList" onchange="addRow()"> <option value=""></option>
function getMultival($row) { $data = array(); $value = OutFieldWidget::getValue($row['path']); $row['id'] = $value['id']; $row['value'] = array(); if ($row['id'] == '') { $row['id'] = 0; } if ($row['module']) { $row['name'] = FieldWidget::getFieldReserve($row, 'name'); $row['params'] = FieldWidget::getFieldReserve($row, 'params'); } $params = explode('-', $row['params']); $module = Module::getModuleByPath($params[0]); if ($module) { if ($module['type'] == 'cat') { $sql = ' SELECT {{tree}}.* FROM {{tree}} INNER JOIN {{' . $module['path'] . '}} ON {{tree}}.id={{' . $module['path'] . '}}.tree WHERE 1 ORDER BY num '; } } else { if (count($params) == 2) { $sql = 'SELECT * FROM {{' . $params[0] . '}} ORDER BY num'; } else { $sql = 'SELECT id FROM {{' . $params[0] . '}} WHERE path=\'' . $params[1] . '\' ORDER BY num'; $parent = DB::getOne($sql); if ($parent == '') { $parent = 0; } $sql = 'SELECT * FROM {{' . $params[0] . '}} WHERE parent=' . $parent . ' ORDER BY num'; } } $items = DB::getAll($sql); $sql = 'SELECT id2 FROM {{relations}} WHERE modul1=\'data\' AND id1=' . $row['id'] . ''; $result = DB::getAll($sql, 'id2'); foreach ($items as $item) { $data[] = array('name' => $item[$params[count($params) - 1]], 'value' => $item['id'], 'selected' => in_array($item['id'], $result) ? 'selected' : ''); if (in_array($item['id'], $result)) { $multival = ''; if (in_array($item['id'], $result)) { $sql = 'SELECT * FROM {{multival}} WHERE relations=' . $item['id'] . ''; $multival = DB::getRow($sql); for ($i = 1; $i < 4; $i++) { $multival[$i] = $multival['value_string' . $i] == '' ? $multival['value_int' . $i] : $multival['value_string' . $i]; } } $row['value'][] = $item[$params[count($params) - 1]]; } } $row['list'] = $data; return View::getWidget('outfields/multival', $row); }
<?php FieldWidget::run(array('type' => $_POST['type']));