diff options
-rw-r--r-- | ext/domxml/domxml.c | 10 | ||||
-rw-r--r-- | ext/hyperwave/hg_comm.c | 71 | ||||
-rw-r--r-- | ext/hyperwave/hw.c | 1 | ||||
-rw-r--r-- | tests/testhyperwave | 18 |
4 files changed, 69 insertions, 31 deletions
diff --git a/ext/domxml/domxml.c b/ext/domxml/domxml.c index 87e9adf9ec..f430f0f1e3 100644 --- a/ext/domxml/domxml.c +++ b/ext/domxml/domxml.c @@ -1201,7 +1201,7 @@ static int node_attributes(zval **attributes, xmlNode *nodep) add_property_stringl(pattr, "content", (char *) attr->val->content, strlen(attr->val->content), 1); else { if(0 == node_children(&children, attr->val)) - zend_hash_update(pattr->value.obj.properties, "content", strlen("content")+1, (void *) &children, sizeof(zval *), NULL); + zend_hash_update(pattr->value.obj.properties, "content", sizeof("content"), (void *) &children, sizeof(zval *), NULL); } zend_hash_next_index_insert((*attributes)->value.ht, &pattr, sizeof(zval *), NULL); attr = attr->next; @@ -1250,15 +1250,15 @@ static int node_children(zval **children, xmlNode *nodep) /* Get the namespace of the current node and add it as a property */ if(!node_namespace(&namespace, last)) - zend_hash_update(child->value.obj.properties, "namespace", strlen("namespace")+1, (void *) &namespace, sizeof(zval *), NULL); + zend_hash_update(child->value.obj.properties, "namespace", sizeof("namespace"), (void *) &namespace, sizeof(zval *), NULL); /* Get the attributes of the current node and add it as a property */ if(!node_attributes(&attributes, last)) - zend_hash_update(child->value.obj.properties, "attributes", strlen("attributes")+1, (void *) &attributes, sizeof(zval *), NULL); + zend_hash_update(child->value.obj.properties, "attributes", sizeof("attributes"), (void *) &attributes, sizeof(zval *), NULL); /* Get recursively the children of the current node and add it as a property */ if(!node_children(&mchildren, last->childs)) - zend_hash_update(child->value.obj.properties, "children", strlen("children")+1, (void *) &mchildren, sizeof(zval *), NULL); + zend_hash_update(child->value.obj.properties, "children", sizeof("children"), (void *) &mchildren, sizeof(zval *), NULL); last = last->next; } @@ -1305,7 +1305,7 @@ PHP_FUNCTION(xmltree) if(0 == node_children(&children, root)) { int i, count; HashTable *lht; - zend_hash_update(return_value->value.obj.properties, "children", strlen("children")+1, (void *) &children, sizeof(zval *), NULL); + zend_hash_update(return_value->value.obj.properties, "children", sizeof("children"), (void *) &children, sizeof(zval *), NULL); /* Find the child of xml type element */ lht = children->value.ht; diff --git a/ext/hyperwave/hg_comm.c b/ext/hyperwave/hg_comm.c index 6cf1098025..45ee5c6ca8 100644 --- a/ext/hyperwave/hg_comm.c +++ b/ext/hyperwave/hg_comm.c @@ -457,15 +457,36 @@ DLIST *fnCreateAnchorList(hw_objectID objID, char **anchors, char **docofanchorr cur_ptr->fragment = estrdup(link); } - cur_ptr->htmlattr = NULL; - if(NULL != (str = strstr(object, "HtmlAttr="))) { + { + char *htmlattr, *str2; + int offset; + str1 = object; + htmlattr = emalloc(strlen(object)); + htmlattr[0] = '\0'; + offset = 0; + while(NULL != (str = strstr(str1, "HtmlAttr="))) { str += 9; str1 = str; while((*str1 != '\n') && (*str1 != '\0')) str1++; - cur_ptr->htmlattr = emalloc(str1 - str + 1); - strncpy(cur_ptr->htmlattr, str, str1 - str); - cur_ptr->htmlattr[str1 - str] = '\0'; + if(NULL != (str2 = strchr(str, '='))) { + str2++; + strncpy(&htmlattr[offset], str, str2 - str); + offset = offset + (str2 - str); + htmlattr[offset++] = '"'; + strncpy(&htmlattr[offset], str2, str1 - str2); + offset = offset + (str1 - str2); + htmlattr[offset++] = '"'; + htmlattr[offset++] = ' '; + htmlattr[offset] = '\0'; + } + } + if(offset){ + /* remove last space */ + htmlattr[offset-1] = '\0'; + cur_ptr->htmlattr = estrdup(htmlattr); + } + efree(htmlattr); } if(NULL != (str = strstr(object, "LinkType="))) { @@ -629,9 +650,14 @@ char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char default: newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>"); if(cur_ptr->fragment) - snprintf(istr, BUFFERLEN, "<A HREF='%s#%s' %s>", cur_ptr->link, cur_ptr->fragment, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr); + snprintf(istr, BUFFERLEN, "<A HREF='%s#%s'", cur_ptr->link, cur_ptr->fragment); else - snprintf(istr, BUFFERLEN, "<A HREF='%s' %s>", cur_ptr->link, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr); + snprintf(istr, BUFFERLEN, "<A HREF='%s'", cur_ptr->link); + if(cur_ptr->htmlattr) { + strncat(istr, " ", BUFFERLEN - 1 - strlen(istr)); + strncat(istr, cur_ptr->htmlattr, BUFFERLEN - 1 - strlen(istr)); + } + strncat(istr, ">", BUFFERLEN - 1 - strlen(istr)); } } else { switch(cur_ptr->linktype) { @@ -643,7 +669,6 @@ char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char break; case HW_INTAG_LINK: if(cur_ptr->fragment) -/* snprintf(istr, BUFFERLEN, " %s='%s/%s#%s'", cur_ptr->tagattr, scriptname == NULL ? "." : scriptname, cur_ptr->destdocname, cur_ptr->fragment);*/ snprintf(istr, BUFFERLEN, " %s='#%s'", cur_ptr->tagattr, cur_ptr->fragment); else snprintf(istr, BUFFERLEN, " %s='%s/%s'", cur_ptr->tagattr, scriptname == NULL ? "." : scriptname, cur_ptr->destdocname); @@ -661,19 +686,19 @@ char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>"); if(cur_ptr->nameanchor) - snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s' %s>", scriptname == NULL ? "schade" : scriptname, cur_ptr->destdocname, cur_ptr->nameanchor, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr); + snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s'", scriptname == NULL ? "schade" : scriptname, cur_ptr->destdocname, cur_ptr->nameanchor); + else if(cur_ptr->fragment) + snprintf(istr, BUFFERLEN, "<A HREF=\"%s/%s#%s\"", scriptname == NULL ? "" : scriptname, cur_ptr->destdocname, cur_ptr->fragment); else - if(cur_ptr->fragment) - snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s' %s>", scriptname == NULL ? "" : scriptname, cur_ptr->destdocname, cur_ptr->fragment, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr); - else - snprintf(istr, BUFFERLEN, "<A HREF='%s/%s' %s>", scriptname == NULL ? "" : scriptname, cur_ptr->destdocname, cur_ptr->htmlattr == NULL ? "" : cur_ptr->htmlattr); + snprintf(istr, BUFFERLEN, "<A HREF='%s/%s'", scriptname == NULL ? "" : scriptname, cur_ptr->destdocname); + + if(cur_ptr->htmlattr) { + strncat(istr, " ", BUFFERLEN - 1 - strlen(istr)); + strncat(istr, cur_ptr->htmlattr, BUFFERLEN - 1 - strlen(istr)); + } + strncat(istr, ">", BUFFERLEN - 1 - strlen(istr)); } } - newtext = fnInsStr(newtext, cur_ptr->start, istr); - /* In case there are several TAGS nested, we accumulate the offset - You wonder what the 4 means? It's the length of </A> */ - offset += strlen(istr) + 4; - laststart = cur_ptr->start; } else { if(laststart >= cur_ptr->end) offset = 0; @@ -686,12 +711,12 @@ char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->keyword); else if(cur_ptr->nameanchor) snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->nameanchor); - newtext = fnInsStr(newtext, cur_ptr->start, istr); - /* In case there are several TAGS nested, we accumulate the offset - You wonder what the 4 means? It's the length of </A> */ - offset += strlen(istr) + 4; - laststart = cur_ptr->start; } + newtext = fnInsStr(newtext, cur_ptr->start, istr); + /* In case there are several TAGS nested, we accumulate the offset + You wonder what the 4 means? It's the length of </A> */ + offset += strlen(istr) + 4; + laststart = cur_ptr->start; #ifdef newlist ptr = (ANCHOR **) zend_llist_get_prev(pAnchorList); if(ptr) diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c index af03df7ab0..1e6013c09a 100644 --- a/ext/hyperwave/hw.c +++ b/ext/hyperwave/hw.c @@ -299,6 +299,7 @@ int make2_return_array_from_objrec(pval **return_value, char *objrec, zval *sarr add_assoc_long(spec_arr, "Description", HW_ATTR_LANG); add_assoc_long(spec_arr, "Keyword", HW_ATTR_LANG); add_assoc_long(spec_arr, "Group", HW_ATTR_NONE); + add_assoc_long(spec_arr, "HtmlAttr", HW_ATTR_NONE); } if (array_init(*return_value) == FAILURE) { diff --git a/tests/testhyperwave b/tests/testhyperwave index f7de5284dd..5391cc6f34 100644 --- a/tests/testhyperwave +++ b/tests/testhyperwave @@ -1,9 +1,9 @@ <? - $id = 187852; // A plain/text document + $id = 188178; // A plain/text document $collid = 169828; // A collection $query = "Name=m*"; // Search query for test_9 $host = "gehtnix"; - $username = "steinm"; + $username = "annonymous"; $password = ""; $connect = hw_connect($host, 418, $username, $password); @@ -22,11 +22,13 @@ $test_7 = "no"; // Insert a new text document $test_8 = "no"; // Remove the just inserted text document $test_9 = "no"; // Searching for objects with Name $query + $test_10= "yes"; // Listing all anchors of a document /* Lists an object array */ function list_attr($attributes) { - global $imagepath; + var_dump($attributes); + return; for($i=0; $i<count($attributes); $i++) { $key = key($attributes); switch($key) { @@ -196,5 +198,15 @@ list_attr($objrecs[$c_objrecs]); } + if($test_10 == "yes") { + $anchors = hw_getanchorsobj($connect, $id); + $countanchors = count($anchors) - 1; + echo "$countanchors Anchors of Object $id\n"; + for($i=0; $i<$countanchors; $i++) { + $arr = hw_objrec2array($anchors[$i]); + list_attr($arr); + } + } + hw_close($connect); ?> |