JavaScript client * Attributes on the editable element: * - w2mled is "text", "html" or "wysiwyg". * - w2mledid is an edited element ID (opaque for the client). * - w2mledrun is "" (default) or "auto". * JavaScript client --> W2ML interpreter * 1 HTTP parameter per edition. * The HTTP parameter name is the opaque ID; it is the concatenation of 4 strings: * - "w2mle2" is the literal string prefix for standard edition. * - A 10 chars long ID (1) identifies the edited element. * - A 10 chars long ID (2) identifies the edition version; it allows conflicts detection. * - The name of the used editor. * The HTTP parameter value is the edited element content. * * Deletion * -------- * W2ML interpreter --> JavaScript client * Attributes on the deletable element: * - w2mldel is an opaque ID. * Attributes on the del button: * - w2mled is "del" * - w2mlto is a w2mldel opaque ID * JavaScript client --> W2ML interpreter * 1 HTTP parameter per deletion. * The HTTP parameter name is the concatenation of 2 strings: * - "w2mld2" is the literal string prefix for deletion. * - An opaque ID identifies the deleted element. * The HTTP parameter value is not used. * * New template instantiation * -------------------------- * W2ML interpreter --> JavaScript client * Attributes on the template element: * - w2mltemplate is the template ID. * Attributes on the anchor element for the new instance: * - w2mlfrom is the template ID. * - w2mlto is "here", "previousSibling", "nextSibling", "lastSibling", "firstChild", or * "lastChild" * - w2mlnew is the anchor ID. * Attributes on the edition element: * - w2mled is "new". * - w2mlto is a w2mlnew ID or "here", "previousSibling"... * - w2mlnew is present as anchor ID if w2mlto is not a w2mlnew ID. * JavaScript client --> W2ML interpreter * 1 HTTP parameter per new instance. * The HTTP parameter name is the concatenation of 4 strings: * - "w2mln2" is the literal string prefix for new instance. * - the anchor ID * - "-" character * - the new instance number for this anchor ID, starting at 1. * * Editions inside a new instance * ------------------------------ * W2ML interpreter --> JavaScript client * Nothing special. * JavaScript client --> W2ML interpreter * Note that an editable element is an element that can be edited with a standard editor, * or an anchor element for new instances (new attribute), or an element that can be deleted * (del attribute). * The edit number starts at 1 and is incremented for every standard editor, new attribute, * and del attribute. If an element has a new and a del attribute, then the new attribute * is considered first. * Standard edition: * - "w2mli2" is the literal string prefix for edition in a new instance. * - the parent instance ID (parent anchor ID, "-", parent instance number) * - "-" character * - the edit number * - "-" character * - editor name * New instance: * - "w2mln2" is the literal string prefix for new instance in a new instance. * - the parent instance ID (parent anchor ID, "-", parent instance number) * - "-" character * - the edit number * Deletion: * - "w2mld2" is the literal string prefix for deletion in a new instance. * - the parent instance ID (parent anchor ID, "-", parent instance number) * - "-" character * - the edit number */ require_once 'str.php'; # Valid identifier characters for ed_ attribute value. define('ED_ID_CHARS', ALPHA_NUM_STR . '_'); # Number of characters of the element identifier in ed_ attribute value. define('STD_ED_ID_1_LEN', 10); # Number of characters of the conflict identifier in ed_ attribute value. define('STD_ED_ID_2_LEN', 10); # Prefix of request parameter name for standard edition. define('STD_ED_PREFIX', 'w2mle2'); define('INIT_ED_PREFIX', 'w2mli2'); # Prefix of request parameter name for new instance. define('NEW_TPL_PREFIX', 'w2mln2'); # Prefix of request parameter name for deletion. define('DEL_TPL_PREFIX', 'w2mld2'); function make_edition_request_str($econf, $attr_id = '') { if ($econf->new_instance_id !== NULL) { $n = $econf->new_instance_editable_counter->inc(); return $econf->new_instance_id . '-' . $n; } else { return $attr_id; } } function add_ed_browser_support($req, $document) { if (count($req->requested_editors()) === 0) { return; } $head = $req->head_html_element(); $body = $req->body_html_element(); if ($head === NULL || $body === NULL) { log_error('Edition support need HTML head and body elements', DEFAULT_LOG_LIMIT); return; } $qname_script = qname($head, $head->namespaceURI, 'script'); $script = $document->createElementNS($head->namespaceURI, $qname_script, 'w2mlURI="'.W2ML_CLIENT_URI.'"'); $script->setAttributeNS(NULL, 'type', 'text/javascript'); $head->appendChild($script); $script = $document->createElementNS($head->namespaceURI, $qname_script); $script->setAttributeNS(NULL, 'type', 'text/javascript'); $script->setAttributeNS(NULL, 'src', W2ML_CLIENT_URI.'main.js'); $head->appendChild($script); $script = $document->createElementNS($head->namespaceURI, $qname_script); $script->setAttributeNS(NULL, 'type', 'text/javascript'); $script->setAttributeNS(NULL, 'src', W2ML_CLIENT_URI.'window/main.js'); $head->appendChild($script); $script = $document->createElementNS($head->namespaceURI, $qname_script); $script->setAttributeNS(NULL, 'type', 'text/javascript'); $script->setAttributeNS(NULL, 'src', W2ML_CLIENT_URI.'edit/main.js'); $head->appendChild($script); foreach ($req->requested_editors() as $editor_name) { # Example: # $qname_script = qname($body, $body->namespaceURI, 'script'); $script = $document->createElementNS($body->namespaceURI, $qname_script, 'w2mlMain()'); $script->setAttributeNS(NULL, 'type', 'text/javascript'); $body->appendChild($script); } ?>