def packs_main(pif): def fmt_link(sec): return pif.render.format_link('?sec=' + sec.id, models.add_icons(pif, 'p_' + sec.id, '', '') + '<center>' + sec.name + '</center>') pif.render.set_page_extra(pif.render.image_selector_js) pif.render.print_html() pif.render.hierarchy_append('/', 'Home') pif.render.hierarchy_append('/database.php', 'Database') pif.render.hierarchy_append('packs.cgi', 'Multi-Model Packs') if pif.form.has('id'): pif.render.hide_title = True pif.form.set_val('id', pif.form.get_list('id')[0]) # with no id this blows pid = useful.clean_id(pif.form.get_str('id')) return do_single_pack(pif, 'packs', pid) elif pif.form.has('page'): return make_pack_list(pif, 'packs', verbose=pif.is_allowed('m') and pif.form.get_int('verbose'), **pif.form.get_dict(['sec', 'year', 'region', 'lid', 'material'])) elif pif.form.has('sec'): pif.render.hide_title = True #useful.write_comment(pif.form) sections = pif.dbh.fetch_sections_by_page_type('packs', pif.form.get_str('sec')) if not sections: return models.make_page_list(pif, 'packs', fmt_link) pif.page_id = sections[0].page_info.id return make_pack_list(pif, 'packs', verbose=pif.is_allowed('m') and pif.form.get_int('verbose'), **pif.form.get_dict(['sec', 'year', 'region', 'lid', 'material'])) return models.make_page_list(pif, 'packs', fmt_link)
def play_main(pif): pif.render.set_page_extra(pif.render.image_selector_js) #useful.write_comment(pif.form) pif.page_id = 'playset.ps' pif.set_page_info(pif.page_id) pif.render.print_html() pif.render.hierarchy_append('/', 'Home') pif.render.hierarchy_append('/database.php', 'Database') pif.render.hierarchy_append('play.cgi', 'Playsets') if pif.form.has('id'): pif.form.set_val('id', pif.form.get_list('id')[0]) # with no id this blows pid = useful.clean_id(pif.form.get_str('id')) return do_single_pack(pif, 'playset', pid) return make_pack_list(pif, 'playset', verbose=pif.is_allowed('m') and pif.form.get_int('verbose'), **pif.form.get_dict(['sec', 'year', 'region']))
def packs_main(pif): def fmt_link(sec): return pif.render.format_link( '?sec=' + sec.id, models.add_icons(pif, 'p_' + sec.id, '', '') + '<center>' + sec.name + '</center>') pif.render.set_page_extra(pif.render.image_selector_js) pif.render.hierarchy_append('/', 'Home') pif.render.hierarchy_append('/database.php', 'Database') pif.render.hierarchy_append('packs.cgi', 'Multi-Model Packs') if pif.form.has('id'): pif.render.hide_title = True pif.form.set_val('id', pif.form.get_list('id')[0]) # with no id this blows pid = useful.clean_id(pif.form.get_str('id')) return do_single_pack(pif, 'packs', pid) elif pif.form.has('page'): pif.render.print_html() return make_pack_list( pif, 'packs', verbose=pif.is_allowed('m') and pif.form.get_int('verbose'), **pif.form.get_dict(['sec', 'year', 'region', 'lid', 'material'])) elif pif.form.has('sec'): pif.render.hide_title = True # useful.write_comment(pif.form) sections = pif.dbh.fetch_sections_by_page_type('packs', pif.form.get_str('sec')) if not sections: pif.render.print_html() return models.make_page_list(pif, 'packs', fmt_link) pif.page_id = sections[0].page_info.id pif.render.print_html() return make_pack_list( pif, 'packs', verbose=pif.is_allowed('m') and pif.form.get_int('verbose'), **pif.form.get_dict(['sec', 'year', 'region', 'lid', 'material'])) pif.render.print_html() return models.make_page_list(pif, 'packs', fmt_link)
def link_page(pif): section_id = useful.clean_id(pif.form.get_str('section')) if section_id: sections = pif.dbh.fetch_sections({'page_id': pif.page_id, 'id': section_id}) else: sections = pif.dbh.fetch_sections({'page_id': pif.page_id}) linklines = pif.dbh.fetch_link_lines(pif.page_id, not_flags=config.FLAG_ITEM_HIDDEN) linklines = pif.dbh.depref('link_line', linklines) linklines.sort(key=lambda x: int(x['display_order'])) sect_links = dict() for link in linklines: sect_links.setdefault(link['section_id'], list()) sect_links[link['section_id']].append(link) llineup = {'id': pif.page_id, 'name': '', 'section': []} for lsec in sections: lsec['anchor'] = lsec['id'] lsec['columns'] = 1 lran = {'id': 'range', 'name': '', 'entry': list(generate_links(pif, sect_links.get(lsec['id'], [])))} lsec['range'] = [lran] llineup['section'].append(lsec) return pif.render.format_template('tlinks.html', llineup=llineup, sections=sections, flags=pif.render.format_shown_flags())
def get_page_id(self, page_id, form_key, defval): return useful.clean_id(self.calc_page_id(page_id, form_key, defval)[:20])
def get_id(self, key, limit=99, defval=''): try: return useful.clean_id(str(self.form[key][:limit])) except: return useful.clean_id(str(defval[:limit]))
def get_id(self, key, limit=99, defval=''): try: return useful.clean_id(self.form[key], limit) except Exception: return useful.clean_id(defval, limit)