[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-04 10:56:29', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': 1, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 43, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': 'class DocType:\n  def __init__(self, d, dl):\n    self.doc, self.doclist = d,dl\n\n  # replace $image\n  # ------------------\n  def validate(self):\n    import re\n    p = re.compile(\'\\$page\\( (?P<name> [^)]*) \\)\', re.VERBOSE)\n    i = re.compile(\'\\$image\\( (?P<name> [^)]*) \\)\', re.VERBOSE)\n    if self.doc.editor:\n      self.doc.editor = p.sub(self.replace_by_link, self.doc.editor)\n      self.doc.editor = i.sub(self.replace_by_img, self.doc.editor)\n  \n  def replace_by_link(self, match):\n    name = match.group(\'name\')\n    \n    # create wiki page if not created\n    if not db_exists(\'Wiki Page\', name):\n      w = Document(\'Wiki Page\')\n      w.page_name = name\n      w.save(1)\n    \n    return \'\'\'<a href="javascript:loaddoc(\'Wiki Page\',\'%s\')">%s</a>\'\'\' % (name, name)\n    \n  def replace_by_img(self, match):\n    name = match.group(\'name\')\n    return \'<img src="cgi-bin/getfile.cgi?ac=%s&name=%s">\' % (session[\'data\'][\'control_panel\'][\'account_id\'], name)    \n    \n  def on_update(self):\n    if not sql("select name from `tabWiki History` where reference=%s", self.doc.name):\n      latest_revision = 0\n      self.make_history(latest_revision)\n    else:\n      latest_revision = sql("select max(revision) from `tabWiki History` where reference=%s", self.doc.name)[0][0]\n      if latest_revision:\n        content = sql("select editor from `tabWiki History` where revision = %s and reference = %s", (latest_revision, self.doc.name))[0][0]\n        \n        if content == self.doc.editor:\n          pass\n        else:\n          self.make_history(latest_revision)\n\n  def make_history(self,revision):\n    wh = Document(\'Wiki History\')\n    wh.reference = self.doc.name\n    wh.editor = self.doc.editor\n    wh.revision = cint(revision) + 1\n    wh.save(1)', 'allow_trash': None, 'allow_print': None, 'autoname': 'field:page_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Wiki Page', 'idx': None, 'hide_toolbar': 1, 'colour': 'White:FFF', 'client_script': 'cur_frm.cscript.onload = function(doc,dt,dn) {\n  pscript.cur_doc = doc; pscript.cur_dt = dt; pscript.cur_dn = dn;\n  \n  set_field_options(\'Page HTML\', doc.editor);\n  set_field_options(\'Heading\', \'<h1>\'+doc.name+\'</h1>\');\n  \n\n  unhide_field(\'Page HTML\');\n  unhide_field(\'Edit\');\n\n  hide_field(\'editor\');\n  hide_field(\'Done\');\n  \n  pscript.show_wiki_history(doc,dt,dn);\n}\n\ncur_frm.cscript.refresh = function() {\n  \n}\n\ncur_frm.cscript.Edit = function(doc,dt,dn) {\n  hide_field(\'Page HTML\');\n  hide_field(\'Edit\');\n\n  unhide_field(\'editor\');\n  unhide_field(\'Done\');\n}\n\ncur_frm.cscript.Done = function(doc,dt,dn) {\n\n  unhide_field(\'Page HTML\');\n  unhide_field(\'Edit\');\n\n  hide_field(\'editor\');\n  hide_field(\'Done\');\n\n  cur_frm.save(\'Save\', function() {\n    set_field_options(\'Page HTML\', locals[\'Wiki Page\'][doc.name].editor);\n    pscript.show_wiki_history(doc,dt,dn);\n  });\n  //\n}\n\n// Showing wiki detail\npscript.show_wiki_history = function(doc,dt,dn){\n /* $c(\'runserverobj\',args={\'method\':\'get_wiki_detail\',\'docs\':compress_doclist([doc])},\n  function(r,rt){\n    alert(\'in callback\');\n    alert(r.message);\n    detail = r.message.detail;\n    contributors = r.message.contributors;\n    \n    var txt = \'<br>This is Revision - \' + detail[0][0] + \' of \' + dn +\'.\' + \'<br>Last modified by \' + detail[0][1] + \' on \' + dateutil.str_to_user(detail[0][2])\n                  + \'<br><br>Contributors : \' + contributors.join(\', \');\n    set_field_options(\'History HTML\', txt);\n  })*/\n  \n  var callback = function(r,rt){\n    detail = r.message.detail;\n    contributors = r.message.contributors;\n    \n    var txt = \'<br>This is Revision - \' + detail[0][0] + \' of \' + dn +\'.\' + \'<br>Last modified by \' + detail[0][1] + \' on \' + dateutil.str_to_user(detail[0][2])\n                  + \'<br><br>Contributors : \' + contributors.join(\', \');\n    set_field_options(\'History HTML\', txt);\n  }\n  \n  args = {};\n  args.doc = doc; args.dt = dt; args.dn = dn;\n  $c_obj(\'Wiki Control\',\'get_wiki_detail\', docstring(args),callback);\n}\n\n// showing page history (keep this we will use this later)\n/*\npscript.show_page_history = function(){\n  if(!pscript.history_list){\n    history_list = new Listing(\'\',1);\n    history_list.colwidths = [\'30%\',\'30%\',\'40%\'];\n    history_list.colnames = [\'Revision\', \'Date\', \'Modified By\'];\n    pscript.history_list = history_list;\n  }\n  \n  if(!pscript.history_div){ pscript.history_div = document.createElement(\'div\'); }\n  pscript.history_div.innerHTML = \'\';\n\n  pscript.history_list.get_query = function(){\n    this.query = repl("select version_no, creation, modified_by, name from `tabWiki History` where reference=\'%(ref)s\' order by version_no desc", {\'ref\':pscript.cur_dn});\n    this.query_max = repl("select count(name) from `tabWiki History` where reference=\'%(ref)s\'", {\'ref\':pscript.cur_dn});\n  }\n  \n  pscript.history_list.show_cell = function(cell,ri,ci,d){\n    if(ci==0){\n      alert(d[ri][3]);\n      \n      var revision = $a(cell,\'span\',\'link_type\');\n      revision.innerHTML = \'Revision - \' + d[ri][0];\n      revision.name = d[ri][3];\n      \n      revision.onclick = function(){ alert(1); alert(this.name); }\n    }\n    \n    if(ci==1){ cell.innerHTML = dateutil.str_to_user(d[ri][1]); }\n    \n    if(ci==2){ cell.innerHTML = d[ri][2]; }\n  }\n  \n  pscript.history_list.make(pscript.history_div);\n  \n  pscript.history_list.run();\n  \n  pscript.history_list.onrun = function(){\n    //set_field_options\n    var df = get_field(pscript.cur_dt, \'History HTML\', pscript.cur_dn);\n    if(df)df.options = pscript.history_div;\n    alert(df.options);\n    msgprint(df.options);\n    refresh_field(\'History HTML\');\n  }\n}\n\npscript.show_history_content = function(wh){\n  alert(wh);\n}\n*/', 'modified': '2010-09-20 14:06:57', 'server_code_error': '<pre style="text-align: left;"></pre>', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00526', 'parent': 'Wiki Page', 'read': 1, 'create': 1, 'creation': '2009-12-04 10:56:29', 'modified': '2009-12-09 18:18:55', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'All', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': 'page_name', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Page Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03472', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': 'page_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Heading', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03473', 'idx': 2, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'HTML', 'options': '', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Button', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Done', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03474', 'idx': 3, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Page HTML', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03475', 'idx': 4, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'HTML', 'options': '', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text Editor', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': 'editor', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Editor', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03476', 'idx': 5, 'default': None, 'colour': 'White:FFF', 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': 'editor', 'fieldtype': 'Text Editor', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Button', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Edit', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03477', 'idx': 6, 'default': None, 'colour': 'White:FFF', 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': '', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Footer HTML', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03478', 'idx': 7, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': '', 'fieldtype': 'HTML', 'options': '<div style=\'border-top: 1px solid #AAA; margin-top: 32px; padding-top: 8px\'>To create / link another WIki Page, use <span style="font-family: Courier, fixed">$page(New Page Name)</span></div>\n\n<div>To add image, use <span style="font-family:Courier,fixed">$image(filename)</span></div>\n<!--\n<div><span class="link_type" onclick="pscript.show_page_history()">Show page history</span></div> -->', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-07 16:49:50', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'History HTML', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03482', 'idx': 8, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'HTML', 'options': '', 'report_hide': None, 'parentfield': 'fields'}]