function setup() { db::table('pages_content'); db::where('page_id', PAGE_ID); db::where('content_pub', '1'); db::order('content_id'); $res = db::select('content'); $i = 0; if ($res) { while ($row = mysql_fetch_assoc($res)) { $i++; s::set('page_content' . $i, $row['content']); } } db::table('pages_files'); db::where('page_id', PAGE_ID); $r = db::select(); if (db::rows() != 0) { s::section('page_files_show'); } while ($a = mysql_fetch_assoc($r)) { $a['file_icon'] = files::getFileIco($a['file_type']); $a['file_size'] = files::parseSizeSmart($a['file_size']); s::roll('page_files', $a); } }
function show() { $event = web::getEvent(); if ($event === false) { $year = date('Y'); } else { $year = $event; } s::set('info_date_select', htmlspecialchars($year)); $sql = "SELECT `section_year` as date FROM `info_sections` WHERE `section_view`='0' GROUP BY `date` ORDER BY `date` DESC"; $res = db::query($sql); $rows = mysql_num_rows($res); if ($rows > 1) { s::add('info_date_selector', '<ul class="years">'); while ($row = mysql_fetch_assoc($res)) { if ($row['date'] == $year) { $row['date'] = '<li><span>' . $row['date'] . '</span></li>'; } else { $row['date'] = '<li><a href="' . web::get('page_folder') . '' . $row['date'] . '/">' . $row['date'] . '</a></li>'; } s::add('info_date_selector', $row['date']); } s::add('info_date_selector', '</ul>'); } $files = array(); db::table('info_files'); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $files[$a['section_id']][] = $a; } db::table('info_sections'); db::order('section_order', 'DESC'); db::where('section_year', $year); $r = db::select(); if (db::rows() == 0) { web::error404(); } while ($a = mysql_fetch_assoc($r)) { if ($a['section_view'] == '0') { s::roll('sections', $a); } else { s::roll('sections_view', $a); } if (isset($files[$a['section_id']])) { foreach ($files[$a['section_id']] as $v) { $v['file_icon'] = files::getFileIco($v['file_type']); $v['file_size'] = files::parseSizeSmart($v['file_size']); s::roll('items' . $a['section_id'], $v); } } } }
function upload() { $dir = FILES_ROOT . 'all/'; if (!empty($_FILES['file']['name'])) { $file_name = urldecode($_GET['file_name']); $file_type = files::info($_FILES['file']['name'], 'type'); $file_size = files::info($_FILES['file']['tmp_name'], 'size'); db::table('files'); db::insert('', 'NOW()', $file_name, $file_type, $file_size); $file_id = mysql_insert_id(); $file = $dir . $file_id . '.' . $file_type; copy($_FILES['file']['tmp_name'], $file); $file_icon = files::getFileIco($file_type); buffer::set('<p class="load"><img src="/i/fileicons/' . $file_icon . '.png" width="18" height="18" alt="" /> <a href="/download/files/download/?file=' . $file_id . '">' . $file_name . '</a> <span>(' . $file_type . ', ' . round($file_size / 1000) . ' Кб)</span></p>'); } }
function showCard($item_id, $section_id) { $dir_path = IMAGES_PATH . 'items/'; db::table('catalog_items'); db::where('item_id', $item_id); $item = db::assoc(); if (db::rows() == 0) { web::error404(); } db::table('catalog_sections'); db::where('section_id', $section_id); $section = db::assoc(); s::set('page_title', $item['item_name']); s::set('page_header', $item['item_name']); s::set('add_path', '<a href="/catalog/' . $section['section_id'] . '/">' . $section['section_name'] . '</a> <span>→</span>'); s::set($item); db::table('catalog_items_photos'); db::where('item_id', $item_id); $r = db::select(); if (db::rows() > 1) { s::section('item_photos_show'); } $i = 0; while ($a = mysql_fetch_assoc($r)) { $i++; if ($i == 1) { $a['act'] = 'act'; s::set('big_pic', '<img src="' . $dir_path . $a['file_id'] . '.jpg' . '" width="268" alt="" />'); } $a['file_path'] = $dir_path . $a['file_id'] . '_m.jpg'; s::roll('item_photos', $a); } db::table('catalog_items_files'); db::where('item_id', $item_id); $r = db::select(); if (db::rows() != 0) { s::section('item_files_show'); } while ($a = mysql_fetch_assoc($r)) { $a['file_icon'] = files::getFileIco($a['file_type']); $a['file_size'] = files::parseSizeSmart($a['file_size']); s::roll('item_files', $a); } db::table('catalog_items_parts'); db::where('item_id', $item_id); db::order('part_id'); $r = db::select(); if (db::rows() > 1) { s::section('item_parts_show'); } $i = 0; while ($a = mysql_fetch_assoc($r)) { s::roll('parts', $a); } }
function uploadFiles() { $dir = FILES_ROOT . 'items/'; if (!empty($_FILES['item_files']['name'])) { $file_size = $_FILES['item_files']['size']; $file_type = files::info($_FILES['item_files']['name'], 'type'); $file_id = md5(date('YmdHis')); $file_name = str_replace('.' . $file_type, '', $_FILES['item_files']['name']); $file = $dir . $file_id . '.' . $file_type; $array = array('file_id' => $file_id, 'file_date' => 'NOW()', 'file_type' => $file_type, 'file_name' => $file_name, 'file_size' => $file_size, 'item_id' => 0); db::table('catalog_items_files'); db::smartInsert($array); copy($_FILES['item_files']['tmp_name'], $file); buffer::set(' <li id="files_id' . $file_id . '"> <input type="hidden" name="files_id[' . $file_id . ']" value="' . $file_id . '"> <img class="vamiddle" src="/i/fileicons/' . files::getFileIco($file_type) . '.png" /> ' . $file_name . '.' . $file_type . ' <a href="javascript:void(null);" onclick="deleteFilesFile(\'' . $file_id . '\');" title="Удалить файл" class="ico ico16 ico_delete"> </a> </li>'); } }
function edit() { events::observe('save', 'pages', 'savePage'); events::observer(); if (events::detect('save')) { return true; } if (events::detect('restore')) { self::restoreVersion(events::get('restore')); } admin::components('tabs', 'validator', 'upload'); if (settings::get('pages', 'redactor')) { admin::components('redactor'); s::section('redactor'); } $page_id = admin::get('id'); appPages::getPagesSelect(ADMIN_SITE_ID, $page_id); appPages::getParentPages(ADMIN_SITE_ID, true); appTemplates::getTmpls(ADMIN_SITE_ID); db::table('pages'); db::where('page_id', $page_id); $row = db::assoc(); s::set('page_link', '<a href="' . self::getUrl($row['page_folder']) . '">Посмотреть страницу на сайте</a>'); if ($row['page_dynamic'] == '1') { $row['page_folder'] = ''; } else { if ($row['page_folder'] != '/') { $row['page_folder'] = string::clearBoth($row['page_folder']); $arr = explode('/', $row['page_folder']); $row['page_folder'] = arrays::lastValue($arr); } } f::set('page_content', $row['page_content'], 0); f::set($row); s::set('page_id', $page_id); db::table('pages_files'); db::where('page_id', $page_id); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $a['file_type'] = files::getFileIco($a['file_type']); s::roll('page_files', $a); } /* Load versions */ db::table('pages_versions'); db::where('page_id', $page_id); db::order('version_date', 'DESC'); $res = db::select(); $versions = array(); while ($row = mysql_fetch_assoc($res)) { $versions[$row['version_date']][$row['content_id']] = array('version_id' => $row['version_id'], 'content_id' => $row['content_id'], 'version_content' => $row['version_content']); } foreach ($versions as $k => $v) { s::roll('versions', array('date' => dt::date2print('%H:%i:%s %d.%m.%Y', $k), 'version_date' => $k, 'id' => md5($k))); foreach ($v as $d => $f) { $f['version_content'] = htmlspecialchars('{non}' . $f['version_content'] . '{/non}'); s::roll('versions_' . md5($k), $f); } } }