<td>1. <small><a href="%s/admin/bibindex/bibindexadmin.py/index?ln=%s&mtype=perform_showindexoverview#1">Overview of indexes</a></small></td>
<td>2. <small><a href="%s/admin/bibindex/bibindexadmin.py/index?ln=%s&mtype=perform_showvirtualindexoverview#2">Overview of virtual indexes</a></small></td>
<td>1. <small><a href="%s/admin/bibindex/bibindexadmin.py/field?ln=%s&mtype=perform_showfieldoverview#1">Overview of logical fields</a></small></td>
<td>1. <small><a href="%s/admin/bibindex/bibindexadmin.py/editfield?fldID=%s&ln=%s&mtype=perform_modifyfield">Modify field code</a></small></td>
<td>5. <small><a href="%s/admin/bibindex/bibindexadmin.py/editfield?fldID=%s&ln=%s&mtype=perform_showdetailsfield">Show field usage</a></small></td>
<td>1. <small><a href="%s/admin/bibindex/bibindexadmin.py/editindex?idxID=%s&ln=%s&mtype=perform_modifyindex">Modify index name / descriptor</a></small></td>
<td>3. <small><a href="%s/admin/bibindex/bibindexadmin.py/editindex?idxID=%s&ln=%s&mtype=perform_modifyindexfields">Modify index fields</a></small></td>
<td>4. <small><a href="%s/admin/bibindex/bibindexadmin.py/editindex?idxID=%s&ln=%s&mtype=perform_modifyindexstemming">Modify index stemming language</a></small></td>
<td>7. <small><a href="%s/admin/bibindex/bibindexadmin.py/editindex?idxID=%s&ln=%s&mtype=perform_modifyremovehtml">Modify remove HTML markup</a></small></td>
<td>2. <small><a href="%s/admin/bibindex/bibindexadmin.py/index?ln=%s&mtype=perform_showvirtualindexoverview#2">Overview of virtual indexes</a></small></td>
return"""<b><span class="info">Field does not exist</span></b>"""
subtitle="""<a name="4"></a>4. Delete the logical field '%s' <small>[<a title="See guide" href="%s/help/admin/bibindex-admin-guide">?</a>]</small>"""%(
fld_dict[int(fldID)],CFG_SITE_URL)
output=""
iffldID:
fldID=int(fldID)
ifconfirmin["0",0]:
check=run_sql(
"SELECT id_field from idxINDEX_field where id_field=%s",(fldID,))
text=""
ifcheck:
text+="""<b><span class="info">This field is used in an index, deletion may cause problems.</span></b><br />"""
text+="""Do you want to delete the logical field '%s' and all its relations and definitions."""%(
subtitle="""<a name="5"></a>11. Delete the index. <small>[<a title="See guide" href="%s/help/admin/bibindex-admin-guide">?</a>]</small>"""%CFG_SITE_URL
output=""
ifconfirmin["0",0]:
idx=get_idx(idxID)
ifidx:
text=""
text+="""<b><span class="info">By deleting an index, you may also loose any indexed data in the forward and reverse table for this index.</span></b><br />"""
text+="""Do you want to delete the index '%s' and all its relations and definitions."""%(
idx[0][1])
output+=createhiddenform(action="deleteindex#5",
text=text,
button="Confirm",
idxID=idxID,
confirm=1)
else:
return"""<br /><b><span class="info">Index specified does not exist.</span></b>"""
output+="""<span class="info">Stemming language has not been changed</span>"""
elifconfirmin[0,"0"]:
text="""
<span class="important">You are about to either disable or change the stemming language setting for this index. Please note that it is not recommended to enable stemming for structured-data indexes like "report number", "year", "author" or "collection". On the contrary, it is advisable to enable stemming for indexes like "fulltext", "abstract", "title", etc. since this would overall improve the retrieval quality. <br /> Beware, however, that after disabling or changing the stemming language setting of an index you will have to reindex it. It is a good idea to change the stemming language and to reindex during low usage hours of your service, since searching results will be potentially affected by the discrepancy between search terms now being (not) stemmed and indexes still using the previous settings until the reindexing is completed</span>.<br /> <strong>Are you sure you want to disable/change the stemming language setting of this index?</strong>"""
subtitle="""<a name="2"></a>1. Modify field code for logical field '%s' <small>[<a title="See guide" href="%s/help/admin/bibindex-admin-guide">?</a>]</small>"""%(
subtitle="""<a name="4"></a>3. Modify tags for the logical field '%s' <small>[<a title="See guide" href="%s/help/admin/bibindex-admin-guide">?</a>]</small>"""%(
fld_dict[int(fldID)],CFG_SITE_URL)
output="""<dl>
<dt>Menu</dt>
<dd><a href="%s/admin/bibindex/bibindexadmin.py/addtag?fldID=%s&ln=%s#4.1">Add a new tag</a></dd>
"""Returns either all portalboxes associated with a collection, or based on either colID or language or both.
colID - collection id
ln - language id"""
sql="SELECT id_collection,id_field,id_fieldvalue,type,score,score_fieldvalue FROM collection_field_fieldvalue, field WHERE id_field=field.id"
params=[]
try:
ifid_field:
sql+=" AND id_field=%s"
params.append(id_field)
sql+=" ORDER BY type, score desc, score_fieldvalue desc"
res=run_sql(sql,tuple(params))
returnres
exceptStandardError:
return""
defget_idx(idxID=''):
sql="SELECT id,name,description,last_updated,stemming_language, synonym_kbrs,remove_stopwords,remove_html_markup,remove_latex_markup,tokenizer FROM idxINDEX"
params=[]
try:
ifidxID:
sql+=" WHERE id=%s"
params.append(idxID)
sql+=" ORDER BY id asc"
res=run_sql(sql,tuple(params))
returnres
exceptStandardError:
return""
defget_idx_synonym_kb(idxID):
"""Returns a synonym knowledge base field value"""
try:
returnrun_sql("SELECT synonym_kbrs FROM idxINDEX WHERE ID=%s",(idxID,))[0][0]
exceptStandardErrorase:
returne.__str__()
defget_idx_remove_stopwords(idxID):
"""Returns a stopwords field value"""
try:
returnrun_sql("SELECT remove_stopwords FROM idxINDEX WHERE ID=%s",(idxID,))[0][0]
exceptStandardErrorase:
return(0,e)
defget_idx_remove_html_markup(idxID):
"""Returns a remove html field value"""
try:
returnrun_sql("SELECT remove_html_markup FROM idxINDEX WHERE ID=%s",(idxID,))[0][0]
exceptStandardErrorase:
return(0,e)
defget_idx_remove_latex_markup(idxID):
"""Returns a remove latex field value"""
try:
returnrun_sql("SELECT remove_latex_markup FROM idxINDEX WHERE ID=%s",(idxID,))[0][0]
exceptStandardErrorase:
return(0,e)
defget_idx_tokenizer(idxID):
"""Returns a tokenizer field value"""
try:
returnrun_sql("SELECT tokenizer FROM idxINDEX WHERE ID=%s",(idxID,))[0][0]
exceptStandardErrorase:
return(0,e)
defget_fld_tags(fldID='',tagID=''):
"""Returns tags associated with a field.
fldID - field id
tagID - tag id"""
sql="SELECT id_field, id_tag, tag.name, tag.value, score FROM field_tag,tag WHERE tag.id=field_tag.id_tag"
params=[]
try:
iffldID:
sql+=" AND id_field=%s"
params.append(fldID)
iftagID:
sql+=" AND id_tag=%s"
params.append(tagID)
sql+=" ORDER BY score desc, tag.value, tag.name"
res=run_sql(sql,tuple(params))
returnres
exceptStandardError:
return""
defget_tags(tagID=''):
"""Returns all or a given tag.
tagID - tag id
ln - language id"""
sql="SELECT id, name, value, recjson_value FROM tag"
params=[]
try:
iftagID:
sql+=" WHERE id=%s"
params.append(tagID)
sql+=" ORDER BY name, value"
res=run_sql(sql,tuple(params))
returnres
exceptStandardError:
return""
defget_fld(fldID=''):
"""Returns all fields or only the given field"""
try:
ifnotfldID:
res=run_sql(
"SELECT id, name, code FROM field ORDER by name, code")
else:
res=run_sql(
"SELECT id, name, code FROM field WHERE id=%s ORDER by name, code",(fldID,))
returnres
exceptStandardError:
return""
defget_fld_id(fld_name=''):
"""Returns field id for a field name"""
try:
res=run_sql('SELECT id FROM field WHERE name=%s',(fld_name,))
returnres[0][0]
exceptStandardError:
return''
defget_fld_value(fldvID=''):
"""Returns fieldvalue"""
try:
sql="SELECT id, name, value FROM fieldvalue"
params=[]
iffldvID:
sql+=" WHERE id=%s"
params.append(fldvID)
res=run_sql(sql,tuple(params))
returnres
exceptStandardError:
return""
defget_idx_fld(idxID=''):
"""Return a list of fields associated with one or all indexes."""
try:
sql="SELECT id_idxINDEX, idxINDEX.name, id_field, field.name, regexp_punctuation, regexp_alphanumeric_separators FROM idxINDEX, field, idxINDEX_field WHERE idxINDEX.id = idxINDEX_field.id_idxINDEX AND field.id = idxINDEX_field.id_field"
params=[]
ifidxID:
sql+=" AND id_idxINDEX=%s"
params.append(idxID)
sql+=" ORDER BY id_idxINDEX asc"
res=run_sql(sql,tuple(params))
returnres
exceptStandardError:
return""
defget_col_nametypes():
"""Return a list of the various translationnames for the fields."""
type=[]
type.append(('ln','Long name'))
returntype
defget_fld_nametypes():
"""Return a list of the various translationnames for the fields."""
type=[]
type.append(('ln','Long name'))
returntype
defget_idx_nametypes():
"""Return a list of the various translationnames for the index"""
type=[]
type.append(('ln','Long name'))
returntype
defget_sort_nametypes():
"""Return a list of the various translationnames for the fields"""
type={}
type['soo']='Sort options'
type['seo']='Search options'
type['sew']='Search within'
returntype
defremove_fld(colID,fldID,fldvID=''):
"""Removes a field from the collection given.
colID - the collection the format is connected to
fldID - the field which should be removed from the collection."""
try:
sql="DELETE FROM collection_field_fieldvalue WHERE id_collection=%s AND id_field=%s"
params=[colID,fldID]
iffldvID:
sql+=" AND id_fieldvalue=%s"
params.append(fldvID)
run_sql(sql,tuple(params))
return(1,"")
exceptStandardErrorase:
return(0,e)
defremove_idxfld(idxID,fldID):
"""Remove a field from a index in table idxINDEX_field
idxID - index id from idxINDEX
fldID - field id from field table"""
try:
sql="DELETE FROM idxINDEX_field WHERE id_field=%s and id_idxINDEX=%s"
run_sql(sql,(fldID,idxID))
return(1,"")
exceptStandardErrorase:
return(0,e)
defremove_fldtag(fldID,tagID):
"""Removes a tag from the field given.
fldID - the field the tag is connected to
tagID - the tag which should be removed from the field."""
try:
sql="DELETE FROM field_tag WHERE id_field=%s AND id_tag=%s"
run_sql(sql,(fldID,tagID))
return(1,"")
exceptStandardErrorase:
return(0,e)
defdelete_tag(tagID):
"""Deletes all data for the given field
fldID - delete all data in the tables associated with field and this id """
try:
run_sql("DELETE FROM tag where id=%s",(tagID,))
return(1,"")
exceptStandardErrorase:
return(0,e)
defdelete_idx(idxID):
"""
Delete all data for the given index.
Delete all data for the given index together with the
idxWORDXXR and idxWORDXXF tables.
"""
try:
idxID=int(idxID)
run_sql("DELETE FROM idxINDEX WHERE id=%s",(idxID,))
run_sql("DELETE FROM idxINDEXNAME WHERE id_idxINDEX=%s",(idxID,))
run_sql("DELETE FROM idxINDEX_field WHERE id_idxINDEX=%s",(idxID,))