Exemple #1
0
def widget_type():
    if ((not request.vars.fieldtype) &
        ('reference' in request.vars.value)) | ('reference' in str(
            request.vars.fieldtype)):
        from plugin_cms import CmsModel
        cms = CmsModel()
        table = cms.define_dtable()
        rows = cms.db(table).select(orderby=table.name)
        tables = cms.db.tables
        if 'folder' not in cms.db.tables: tables.append('folder')
        for row in rows:
            if row.name not in cms.db.tables: tables.append(row.name)
        tables.sort()
        op = [
            OPTION(T(table),
                   _value=table,
                   _selected=(request.vars.value.endswith(table)))
            for table in tables
        ]
        widget = SELECT(op, _name='tablename', _id="tablename")
        script = SCRIPT(
            '''$('#tablename').change(function() {document.getElementById("dfield_ftype").value = document.getElementById("fieldtype").value+' '+$(this).val(); });'''
        )
        return SPAN(widget, script)
    else:
        script = SCRIPT(
            '''document.getElementById("dfield_ftype").value = document.getElementById("fieldtype").value;'''
        )
        return script
Exemple #2
0
def widget_field():
    from plugin_cms import CmsModel
    cms = CmsModel()
    table = cms.define_dfield()
    ftype = request.vars.fieldtype or request.vars.ftype
    if len(ftype.split(' ')) == 3:
        ftype = ftype.split(' ')[0] + ' ' + ftype.split(' ')[1]
    rows = cms.db(table.ftype.startswith(ftype)).select(orderby=table.name)
    op = [
        OPTION(row.name,
               _value=row.id,
               _selected=(row.id == int(request.vars.value))) for row in rows
    ]
    widget = SELECT(op, _name='dfield', _id='tablefield_dfield')
    return widget
Exemple #3
0
def index():
    from plugin_cms import CmsModel
    ul = UL()
    for table in ['folder', 'dtable', 'rtable', 'dfield', 'tablefield']:
        ul.append(
            LI(A(T(table), _href=URL(f=table)),
               _class='table_%s' % table,
               _id='table_%s' % table))
    ul.append(
        LI(A(T('dcontent'), _href=URL(f='manage', args=['dcontent'])),
           _class='table_dcontent',
           _id='table_dcontent'))
    ul.append(
        LI(A(T('box'), _href=URL(f='manage', args=['box'])),
           _class='table_box',
           _id='table_box'))
    ul.append(
        LI(A(T('rtable'), _href=URL(f='manage', args=['rtable'])),
           _class='table_box',
           _id='table_box'))
    content = DIV(ul, _class='cmsindex', _id='cmsindex')
    cms = CmsModel()
    table = cms.define_dtable()
    rows = cms.db(table).select(orderby=table.display_order)
    ul1 = UL(_class='table_data')
    ul2 = UL(_class='table_publish')
    for row in rows:
        li = LI(A(T(row.name), _href=URL(f='manage', args=[row.name])),
                _class='table_%s' % row.name,
                _id='table_%s' % row.name)
        if row.publish: ul2.append(li)
        else: ul1.append(li)
    content.append(ul1)
    content.append(ul2)
    response.view = 'plugin_cms/content.html'
    return dict(content=content)