$sqllist = $db->query("SELECT p.*, u.* {$join_columns} \n\tFROM {$db_projects} AS p {$join_condition}\n\tLEFT JOIN {$db_users} AS u ON u.user_id=p.item_userid\n\t" . $where . "\n\t" . $order . "\n\tLIMIT {$d}, " . $maxrowsperpage); $pagenav = cot_pagenav('projects', $list_url_path, $d, $totalitems, $maxrowsperpage); $catpatharray[] = array(cot_url('projects'), $L['projects']); if (!empty($c)) { $catpatharray = array_merge($catpatharray, cot_structure_buildpath('projects', $c)); } $catpath = cot_breadcrumbs($catpatharray, $cfg['homebreadcrumb'], true); if (is_array($projects_types)) { foreach ($projects_types as $i => $pr_type) { $t->assign(array("PTYPE_ROW_ID" => $i, "PTYPE_ROW_TITLE" => $pr_type, "PTYPE_ROW_URL" => cot_url('projects', 'c=' . $c . '&type=' . $i), "PTYPE_ROW_ACT" => $type == $i ? 'act' : '')); $t->parse("MAIN.PTYPES.PTYPES_ROWS"); } } $t->assign(array("PTYPE_ALL_URL" => cot_url('projects', 'c=' . $c), "PTYPE_ALL_ACT" => empty($type) && empty($realized) ? true : false, "REALIZED_URL" => cot_url('projects', 'c=' . $c . '&realized=1'), "FORPRO_URL" => cot_url('projects', 'c=' . $c . '&type=' . $type . '&forpro=1'), "REALIZED_ACT" => !empty($realized) ? true : false, "SUBMITNEWPROJECT_URL" => cot_url('projects', 'm=add&c=' . $c . '&type=' . $type))); $t->parse("MAIN.PTYPES"); $t->assign(array("SEARCH_ACTION_URL" => cot_url('projects', "&type=" . $type, '', true), "SEARCH_SQ" => cot_inputbox('text', 'sq', htmlspecialchars($sq), 'class="schstring"'), "SEARCH_CAT" => cot_projects_selectcat($c, 'c'), "SEARCH_SORTER" => cot_selectbox($sort, "sort", array('', 'costasc', 'costdesc'), array($L['projects_mostrelevant'], $L['projects_costasc'], $L['projects_costdesc']), false), "PAGENAV_PAGES" => $pagenav['main'], "PAGENAV_PREV" => $pagenav['prev'], "PAGENAV_NEXT" => $pagenav['next'], "PAGENAV_COUNT" => $totalitems, "CATALOG" => cot_build_structure_projects_tree('', array($c)), "BREADCRUMBS" => $catpath, "CATTITLE" => !empty($c) ? $structure['projects'][$c]['title'] : '', "CATDESC" => !empty($c) ? $structure['projects'][$c]['desc'] : '', "SUBMITNEWPROJECT_URL" => cot_url('projects', 'm=add&c=' . $c . '&type=' . $type))); foreach ($cot_extrafields[$db_projects] as $exfld) { $uname = strtoupper($exfld['field_name']); $exfld_val = cot_build_extrafields($exfld['field_name'], $exfld, $shfld[$exfld['field_name']]); $exfld_title = isset($L['projects_' . $exfld['field_name'] . '_title']) ? $L['projects_' . $exfld['field_name'] . '_title'] : $exfld['field_description']; $t->assign(array('SEARCH_' . $uname => $exfld_val, 'SEARCH_' . $uname . '_TITLE' => $exfld_title)); } /* === Hook === */ foreach (cot_getextplugins('projects.list.search.tags') as $pl) { include $pl; } /* ===== */ $sqllist_rowset = $sqllist->fetchAll(); $sqllist_idset = array(); foreach ($sqllist_rowset as $item) { $sqllist_idset[$item['item_id']] = $item['item_alias'];
function cot_build_structure_projects_tree($parent = '', $selected = '', $level = 0, $template = '') { global $structure, $cfg, $db, $sys, $type, $cot_extrafields, $db_structure; global $i18n_notmain, $i18n_locale, $i18n_write, $i18n_admin, $i18n_read, $db_i18n_pages; $urlparams = array('type' => $type); /* === Hook === */ foreach (cot_getextplugins('projects.tree.first') as $pl) { include $pl; } /* ===== */ if (empty($parent)) { $i18n_enabled = $i18n_read; $children = array(); foreach ($structure['projects'] as $i => $x) { if (mb_substr_count($structure['projects'][$i]['path'], ".") == 0) { $children[] = $i; } } } else { $i18n_enabled = $i18n_read && cot_i18n_enabled($parent); $children = $structure['projects'][$parent]['subcats']; } $t1 = new XTemplate(cot_tplfile(array('projects', 'tree', $template), 'module')); /* === Hook === */ foreach (cot_getextplugins('projects.tree.main') as $pl) { include $pl; } /* ===== */ if (count($children) == 0) { return false; } $t1->assign(array("TITLE" => htmlspecialchars($structure['projects'][$parent]['title']), "DESC" => $structure['projects'][$parent]['desc'], "COUNT" => $structure['projects'][$parent]['count'], "ICON" => $structure['projects'][$parent]['icon'], "HREF" => cot_url("projects", $urlparams + array('c' => $parent)), "LEVEL" => $level)); $jj = 0; /* === Hook - Part1 : Set === */ $extp = cot_getextplugins('projects.tree.loop'); /* ===== */ foreach ($children as $row) { $jj++; $urlparams['c'] = $row; $subcats = $structure['projects'][$row]['subcats']; $t1->assign(array("ROW_CAT" => $row, "ROW_TITLE" => htmlspecialchars($structure['projects'][$row]['title']), "ROW_DESC" => $structure['projects'][$row]['desc'], "ROW_COUNT" => $structure['projects'][$row]['count'], "ROW_ICON" => $structure['projects'][$row]['icon'], "ROW_HREF" => cot_url("projects", $urlparams), "ROW_SELECTED" => is_array($selected) && in_array($row, $selected) || !is_array($selected) && $row == $selected ? 1 : 0, "ROW_SUBCAT" => count($subcats) > 0 ? cot_build_structure_projects_tree($row, $selected, $level + 1) : '', "ROW_LEVEL" => $level, "ROW_ODDEVEN" => cot_build_oddeven($jj), "ROW_JJ" => $jj)); // Extra fields for structure foreach ($cot_extrafields[$db_structure] as $exfld) { $uname = strtoupper($exfld['field_name']); $t1->assign(array('ROW_' . $uname . '_TITLE' => isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'ROW_' . $uname => cot_build_extrafields_data('structure', $exfld, $structure['projects'][$row][$exfld['field_name']]), 'ROW_' . $uname . '_VALUE' => $structure['projects'][$row][$exfld['field_name']])); } if ($i18n_enabled && $i18n_notmain) { $x_i18n = cot_i18n_get_cat($row, $i18n_locale); if ($x_i18n) { if (!$cfg['plugin']['i18n']['omitmain'] || $i18n_locale != $cfg['defaultlang']) { $urlparams['l'] = $i18n_locale; } $t1->assign(array('ROW_URL' => cot_url('projects', $urlparams), 'ROW_TITLE' => $x_i18n['title'], 'ROW_DESC' => $x_i18n['desc'])); } } /* === Hook - Part2 : Include === */ foreach ($extp as $pl) { include $pl; } /* ===== */ $t1->parse("MAIN.CATS"); } if ($jj == 0) { return false; } $t1->parse("MAIN"); return $t1->text("MAIN"); }
} /* ===== */ $where = $where ? 'WHERE ' . implode(' AND ', $where) : ''; $order = $order ? 'ORDER BY ' . implode(', ', $order) : ''; $totalitems = $db->query("SELECT COUNT(*) FROM {$db_projects} \n\t" . $where . "")->fetchColumn(); $sqllist = $db->query("SELECT * FROM {$db_projects} AS p LEFT JOIN {$db_users} AS u ON u.user_id=p.item_userid\n\t" . $where . " \n\t" . $order . " \n\tLIMIT {$d}, " . $cfg['maxrowsperpage']); $pagenav = cot_pagenav('admin', $list_url_path, $d, $totalitems, $cfg['maxrowsperpage']); if (is_array($projects_types)) { foreach ($projects_types as $i => $pr_type) { $t->assign(array("TYPE_ROW_TITLE" => $pr_type, "TYPE_ROW_URL" => cot_url('admin', 'm=projects&c=' . $c . '&type=' . $i), "TYPE_ROW_ACT" => $type == $i ? 'act' : '')); $t->parse("MAIN.TYPES.TYPES_ROWS"); } } $t->assign(array('TYPE_ALL_URL' => cot_url('admin', 'm=projects&c=' . $c), 'TYPE_ALL_ACT' => empty($type) ? 'act' : '')); $t->parse('MAIN.TYPES'); $t->assign(array("SEARCH_ACTION_URL" => cot_url('admin', "m=projects&c=" . $c . "&type=" . $type, '', true), "SEARCH_SQ" => cot_inputbox('text', 'sq', $sq, 'class="schstring"'), "SEARCH_STATE" => cot_radiobox($state, 'state', array(0, 1, 2), array('опубликованные', 'скрытые', 'на проверке')), "SEARCH_CAT" => cot_projects_selectcat($c, 'c'), "SEARCH_SORTER" => cot_selectbox($sort, "sort", array('', 'costasc', 'costdesc'), array($L['projects_mostrelevant'], $L['projects_costasc'], $L['projects_costdesc']), false), 'TYPES_EDIT' => cot_url('admin', 'm=projects&p=types'), 'PAGENAV_PAGES' => $pagenav['main'], 'PAGENAV_PREV' => $pagenav['prev'], 'PAGENAV_NEXT' => $pagenav['next'], 'CATALOG' => cot_build_structure_projects_tree('', array($c)), 'CATTITLE' => !empty($c) ? ' / ' . !empty($c) ? ' / ' . htmlspecialchars($structure['projects'][$c]['title']) : '' : '')); $sqllist_rowset = $sqllist->fetchAll(); $sqllist_idset = array(); foreach ($sqllist_rowset as $item) { $sqllist_idset[$item['item_id']] = $item['item_alias']; } /* === Hook === */ $extp = cot_getextplugins('projects.admin.list.loop'); /* ===== */ foreach ($sqllist_rowset as $item) { $jj++; $t->assign(cot_generate_usertags($item, 'PRJ_ROW_OWNER_')); $t->assign(cot_generate_projecttags($item, 'PRJ_ROW_', $cfg['projects']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb'])); $t->assign(array('PRJ_ROW_ODDEVEN' => cot_build_oddeven($jj), 'PRJ_ROW_EDIT_URL' => cot_url('projects', 'm=edit&id=' . $item['item_id']), 'PRJ_ROW_VALIDATE_URL' => cot_url('admin', 'm=projects&p=default&a=validate&id=' . $item['item_id']), 'PRJ_ROW_DELETE_URL' => cot_url('admin', 'm=projects&p=default&a=delete&id=' . $item['item_id']))); /* === Hook - Part2 : Include === */ foreach ($extp as $pl) {
$pagenav = cot_pagenav('index', '', $p, $totalitems, $cfg['projects']['indexlimit'], 'p'); $t_pr->assign(array("PAGENAV_PAGES" => $pagenav['main'], "PAGENAV_PREV" => $pagenav['prev'], "PAGENAV_NEXT" => $pagenav['next'])); $sqllist_rowset = $sqllist->fetchAll(); $sqllist_idset = array(); foreach ($sqllist_rowset as $item) { $sqllist_idset[$item['item_id']] = $item['item_alias']; } /* === Hook === */ $extp = cot_getextplugins('projects.index.loop'); /* ===== */ foreach ($sqllist_rowset as $item) { $jj++; $t_pr->assign(cot_generate_usertags($item, 'PRJ_ROW_OWNER_')); $t_pr->assign(cot_generate_projecttags($item, 'PRJ_ROW_', $cfg['projects']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb'])); $t_pr->assign(array("PRJ_ROW_ODDEVEN" => cot_build_oddeven($jj))); /* === Hook - Part2 : Include === */ foreach ($extp as $pl) { include $pl; } /* ===== */ $t_pr->parse("PROJECTS.PRJ_ROWS"); } $t_pr->assign(array("COUNTOFREALIZEDPROJECTS" => $countofrealizedprojects)); $t_pr->parse("PROJECTS"); $t->assign('PROJECTS', $t_pr->text('PROJECTS')); $t->assign(array("PROJECTS_CATALOG" => cot_build_structure_projects_tree('', array()))); /* === Hook === */ foreach (cot_getextplugins('projects.index.tags') as $pl) { include $pl; } /* ===== */
function cot_build_structure_projects_tree($parent = '', $selected = array(), $level = 0, $template = '') { global $structure, $cfg, $db, $sys, $type; global $i18n_notmain, $i18n_locale, $i18n_write, $i18n_admin, $i18n_read, $db_i18n_pages; if (empty($parent)) { $i18n_enabled = $i18n_read; $children = array(); foreach ($structure['projects'] as $i => $x) { if (mb_substr_count($structure['projects'][$i]['path'], ".") == 0) { $children[] = $i; } } } else { $i18n_enabled = $i18n_read && cot_i18n_enabled($parent); $children = cot_structure_children('projects', $parent, false, false); } $t1 = new XTemplate(cot_tplfile(array('projects', 'tree', $template), 'module')); if (count($children) == 0) { return false; } $jj = 0; foreach ($children as $row) { $jj++; $t1->assign(array("ROW_CAT" => $row, "ROW_TITLE" => htmlspecialchars($structure['projects'][$row]['title']), "ROW_DESC" => $structure['projects'][$row]['desc'], "ROW_COUNT" => $structure['projects'][$row]['count'], "ROW_ICON" => $structure['projects'][$row]['icon'], "ROW_HREF" => cot_url("projects", "c=" . $row . "&type=" . $type), "ROW_SELECTED" => in_array($row, $selected) ? 1 : 0, "ROW_SUBCAT" => cot_build_structure_projects_tree($row, $selected, $level + 1), "ROW_LEVEL" => $level, "ROW_ODDEVEN" => cot_build_oddeven($jj), "ROW_JJ" => $jj)); if ($i18n_enabled && $i18n_notmain) { $x_i18n = cot_i18n_get_cat($row, $i18n_locale); if ($x_i18n) { $urlparams = !$cfg['plugin']['i18n']['omitmain'] || $i18n_locale != $cfg['defaultlang'] ? "c={$row}&l={$i18n_locale}" : "c={$row}"; $t1->assign(array('ROW_URL' => cot_url('page', $urlparams), 'ROW_TITLE' => $x_i18n['title'], 'ROW_DESC' => $x_i18n['desc'])); } } $t1->parse("MAIN.CATS"); $t1->assign(array("TITLE" => htmlspecialchars($structure['projects'][$parent]['title']), "DESC" => $structure['projects'][$parent]['desc'], "COUNT" => $structure['projects'][$parent]['count'], "ICON" => $structure['projects'][$parent]['icon'], "HREF" => cot_url("projects", "c=" . $parent), "LEVEL" => $level)); } if ($jj == 0) { return false; } $t1->parse("MAIN"); return $t1->text("MAIN"); }