Annotation of Amaya/amaya/templates.c, revision 1.47
1.1 cvs 1: /*
2: *
1.27 vatton 3: * COPYRIGHT INRIA and W3C, 1996-2005
1.1 cvs 4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
1.14 cvs 7:
1.1 cvs 8: /*
9: * Amaya browser functions called form Thot and declared in HTML.A.
10: * These functions concern links and other HTML general features.
11: *
1.15 cvs 12: * Authors: I. Vatton, L. Bonameau, S. Bonhomme (INRIA)
1.1 cvs 13: *
14: */
15:
16: /* Included headerfiles */
1.29 tollenae 17:
18:
1.1 cvs 19: #define THOT_EXPORT extern
20: #include "amaya.h"
21: #include "css.h"
22: #include "document.h"
23: #include "view.h"
1.46 vatton 24: #ifdef TEMPLATES
25: #include "Template.h"
26: #endif /* TEMPLATES */
27:
28: #include "AHTURLTools_f.h"
1.28 tollenae 29: #include "appdialogue_wx.h"
1.46 vatton 30: #include "css_f.h"
1.29 tollenae 31: #include "init_f.h"
1.32 tollenae 32: #include "parser.h"
1.46 vatton 33: #include "HTMLhistory_f.h"
1.29 tollenae 34: #include "HTMLimage_f.h"
1.32 tollenae 35: #include "HTMLsave_f.h"
1.46 vatton 36: #include "tree.h"
37: #include "wxdialogapi_f.h"
1.1 cvs 38:
39: /* content of the attr name of the meta tag defining the doc's destination URL */
1.18 cvs 40: #define META_TEMPLATE_NAME "AMAYA_TEMPLATE"
1.1 cvs 41: /* URL of the script providing templates (for reload) */
1.18 cvs 42: static char *script_URL;
1.3 cvs 43:
44:
1.1 cvs 45: /*----------------------------------------------------------------------
1.47 ! vatton 46: NewTemplate: Create the "new document from template's" dialog
1.1 cvs 47: ----------------------------------------------------------------------*/
1.18 cvs 48: void NewTemplate (Document doc, View view)
1.1 cvs 49: {
1.31 tollenae 50: #ifdef TEMPLATES
1.47 ! vatton 51: char *templateDir, *lang;
! 52: char s[MAX_LENGTH];
! 53: ThotBool useAmayaDir = FALSE;
! 54:
! 55: templateDir = TtaGetEnvString ("TEMPLATES_DIRECTORY");
! 56: if (templateDir == NULL || IsW3Path (templateDir))
! 57: {
! 58: useAmayaDir = TRUE;
! 59: templateDir = (char *) TtaGetMemory (MAX_LENGTH);
! 60: lang = TtaGetVarLANG ();
! 61: // Amaya's templates directory
! 62: sprintf (templateDir, "%s%ctemplates%c%s%c",
! 63: TtaGetEnvString ("THOTDIR"), DIR_SEP, DIR_SEP, lang, DIR_SEP);
! 64: if (!TtaDirExists (templateDir))
! 65: // By default use the English templates directory
! 66: sprintf (templateDir, "%s%ctemplates%cen%c",
! 67: TtaGetEnvString ("THOTDIR"), DIR_SEP, DIR_SEP, DIR_SEP);
! 68: }
1.28 tollenae 69: TtaExtractName (DocumentURLs[doc], s, DocumentName);
70: strcpy (DirectoryName, s);
71:
72: int window_id = TtaGetDocumentWindowId( doc, view );
73: ThotWindow p_window = (ThotWindow) TtaGetWindowFromId(window_id);
1.47 ! vatton 74: ThotBool created = CreateNewTemplateDocDlgWX(BaseDialog + OpenTemplate,
! 75: p_window,
! 76: doc,
! 77: TtaGetMessage (AMAYA, AM_NEW_TEMPLATE),
! 78: templateDir,
! 79: s);
! 80: if (useAmayaDir)
! 81: TtaFreeMemory (templateDir);
1.28 tollenae 82:
83: if (created)
1.25 vatton 84: {
1.28 tollenae 85: TtaSetDialoguePosition ();
86: TtaShowDialogue (BaseDialog + OpenTemplate, TRUE);
1.25 vatton 87: }
1.31 tollenae 88: #endif // TEMPLATES
1.1 cvs 89: }
1.25 vatton 90:
1.28 tollenae 91:
1.1 cvs 92: /*----------------------------------------------------------------------
1.47 ! vatton 93: OpenTemplateDocument: Process the meta of a template document,
! 94: changes the URL, try to save it and warn the user if it cannot be
! 95: saved.
1.1 cvs 96: ----------------------------------------------------------------------*/
1.18 cvs 97: void OpenTemplateDocument (Document doc)
1.1 cvs 98: {
1.43 tollenae 99: #ifdef TEMPLATES
1.1 cvs 100: ElementType metaElType;
101: Element metaEl;
102: Attribute metaAttr;
103: AttributeType metaAttrType;
104: ThotBool found = FALSE;
105: int length;
1.24 vatton 106: char *utf8path, *path;
107: char *URLdir, *URLname;
1.1 cvs 108:
109: metaElType.ElSSchema = TtaGetDocumentSSchema (doc);
110: metaElType.ElTypeNum = HTML_EL_META;
111: metaAttrType.AttrSSchema = TtaGetDocumentSSchema (doc);
112: metaAttrType.AttrTypeNum = HTML_ATTR_meta_name;
113: /* search the meta element */
114: metaEl = TtaGetMainRoot (doc);
1.24 vatton 115: path = NULL;
1.1 cvs 116: do
117: {
118: metaEl = TtaSearchTypedElement (metaElType, SearchForward, metaEl);
119: if (metaEl != NULL)
120: {
121: metaAttr = TtaGetAttribute (metaEl, metaAttrType);
122: if (metaAttr != NULL)
123: {
1.47 ! vatton 124: length = TtaGetTextAttributeLength (metaAttr) + 1;
! 125: utf8path = (char *) TtaGetMemory (length);
! 126: TtaGiveTextAttributeValue (metaAttr, utf8path, &length);
! 127: path = (char *)TtaConvertMbsToByte ((unsigned char *)utf8path,
! 128: TtaGetDefaultCharset ());
! 129: TtaFreeMemory (utf8path);
1.24 vatton 130: found = !strcmp (path, META_TEMPLATE_NAME);
1.47 ! vatton 131: /* free previous path if necessary */
! 132: TtaFreeMemory (path);
! 133: path = NULL;
1.1 cvs 134: }
135: }
136: }
1.24 vatton 137: while (metaEl && !found);
138:
1.1 cvs 139: if (found)
140: {
141: /* get the url of the document */
142: metaAttrType.AttrTypeNum = HTML_ATTR_meta_content;
143: metaAttr = TtaGetAttribute (metaEl, metaAttrType);
144: if (metaAttr != NULL)
1.47 ! vatton 145: {
! 146: length = TtaGetTextAttributeLength (metaAttr) + 1;
! 147: utf8path = (char *) TtaGetMemory (length);
! 148: TtaGiveTextAttributeValue (metaAttr, utf8path, &length);
! 149: path = (char *)TtaConvertMbsToByte ((unsigned char *)utf8path,
! 150: TtaGetDefaultCharset ());
! 151: TtaFreeMemory (utf8path);
! 152: }
1.24 vatton 153:
1.1 cvs 154: /* Delete the meta element */
155: TtaDeleteTree (metaEl, doc);
1.24 vatton 156: if (script_URL == NULL)
1.47 ! vatton 157: script_URL = TtaStrdup (DocumentURLs[doc]);
1.24 vatton 158: TtaFreeMemory (DocumentURLs[doc]);
159: DocumentURLs[doc] = TtaStrdup (path);
160: DocumentMeta[doc]->method = CE_TEMPLATE;
161: AddURLInCombobox (DocumentURLs[doc], NULL, TRUE);
162: TtaSetTextZone (doc, 1, URL_list);
163: TtaSetDocumentUnmodified (doc);
164:
1.1 cvs 165: /* set the document name and dir */
1.24 vatton 166: URLname = strrchr (path, URL_SEP);
1.5 cvs 167: if (URLname)
1.47 ! vatton 168: {
! 169: URLname[0] = EOS;
! 170: URLname++;
! 171: URLdir = path;
! 172: TtaSetDocumentDirectory (doc, URLdir);
! 173: TtaSetDocumentName (doc, URLname);
! 174: /* SetBrowserEditor(doc); */
! 175: }
1.5 cvs 176: else
1.47 ! vatton 177: {
! 178: TtaSetDocumentDirectory (doc, "");
! 179: TtaSetDocumentName (doc, path);
! 180: }
1.9 cvs 181: SetWindowTitle (doc, doc, 0);
1.1 cvs 182: }
1.24 vatton 183: TtaFreeMemory (path);
1.43 tollenae 184: #endif /* TEMPLATES */
1.1 cvs 185: }
186:
187: /*----------------------------------------------------------------------
188: ReloadTemplateParams : restores the script URL and method into meta
189: to reload a template
190: ----------------------------------------------------------------------*/
1.18 cvs 191: void ReloadTemplateParams (char **docURL, ClickEvent *method)
1.1 cvs 192: {
1.47 ! vatton 193: *method = CE_FORM_GET;
! 194: TtaFreeMemory (*docURL);
! 195: *docURL = TtaStrdup (script_URL);
1.1 cvs 196: }
1.28 tollenae 197:
198:
199: /*------------------------------------------------------------------------
200: InitTemplateList : fills template list with HTML files in
201: the templates directory
202: ----------------------------------------------------------------------*/
203: void InitTemplateList ()
204: {
1.43 tollenae 205: #ifdef TEMPLATES
1.28 tollenae 206: int i, nb,len;
207: unsigned char *urlstring,c;
208: char *app_home;
209: FILE *file;
210: CHARSET encoding;
211:
212: TtaFreeMemory(Template_list);
213:
214: urlstring = (unsigned char *) TtaGetMemory (MAX_LENGTH);
215:
216: /* open the file list_url.dat into APP_HOME directory */
217: app_home = TtaGetEnvString ("APP_HOME");
218:
219: sprintf ((char *)urlstring, "%s%clist_url_utf8.dat", app_home, DIR_SEP);
220: encoding = UTF_8;
221:
222: file = TtaReadOpen ((char *)urlstring);
223:
224: *urlstring = EOS;
225: if (file)
226: {
227: /* get the size of the file */
228: fseek (file, 0L, 2);
229: /* end of the file */
1.30 gully 230: Template_list_len = (ftell (file) * 4) + GetMaxURLList() + 4;
1.28 tollenae 231: Template_list = (char *)TtaGetMemory (Template_list_len);
232: Template_list[0] = EOS;
233: fseek (file, 0L, 0); /* beginning of the file */
234: /* initialize the list by reading the file */
235: i = 0;
236: nb = 0;
237: while (TtaReadByte (file, &c))
1.43 tollenae 238: {
239: if (c == '"')
240: {
241: len = 0;
242: urlstring[len] = EOS;
243: while (len < MAX_LENGTH && TtaReadByte (file, &c) && c != EOL)
244: {
245: if (c == '"')
246: urlstring[len] = EOS;
247: else if (c == 13) /* Carriage return */
248: urlstring[len] = EOS;
249: else
250: urlstring[len++] = (char)c;
251: }
252: urlstring[len] = EOS;
253: if (i > 0 && len)
254: /* add an EOS between two urls */
255: URL_list[i++] = EOS;
256: if (len)
257: {
258: nb++;
259: strcpy ((char *)&Template_list[i], (char *)urlstring);
260: i += len;
261: }
262: }
263: }
1.28 tollenae 264: Template_list[i + 1] = EOS;
265: TtaReadClose (file);
266: }
267: TtaFreeMemory (urlstring);
1.43 tollenae 268: #endif /* TEMPLATES */
1.28 tollenae 269: }
1.37 tollenae 270:
1.46 vatton 271: /*----------------------------------------------------------------------
1.47 ! vatton 272: Insert the meta element identifying the template's instance
1.46 vatton 273: ----------------------------------------------------------------------*/
1.42 tollenae 274: void InsertInstanceMeta (Document newdoc)
1.36 tollenae 275: {
1.43 tollenae 276: #ifdef TEMPLATES
1.42 tollenae 277: Element head = TtaGetMainRoot (newdoc);
1.36 tollenae 278: Element meta;
279: ElementType elType;
280: AttributeType attrType;
281: Attribute attr;
1.42 tollenae 282: char *temp_id, *name;
283: int length;
284: ThotBool found = false;
1.36 tollenae 285:
286: elType.ElSSchema = TtaGetSSchema ("HTML", newdoc);
287: elType.ElTypeNum = HTML_EL_HEAD;
1.42 tollenae 288: head = TtaSearchTypedElement(elType, SearchInTree, head);
1.36 tollenae 289: if (head)
290: {
291: attrType.AttrTypeNum = HTML_ATTR_meta_name;
292: attrType.AttrSSchema = elType.ElSSchema;
1.42 tollenae 293:
294: elType.ElTypeNum = HTML_EL_META;
295: /* Search the template_id meta in the template document */
296: meta = TtaSearchTypedElement(elType, SearchInTree, head);
297: while (meta && !found)
298: {
299: attr = TtaGetAttribute (meta, attrType);
300: if (attr != NULL)
301: {
302: length = TtaGetTextAttributeLength (attr) + 1;
303: name = (char *) TtaGetMemory (length);
304: TtaGiveTextAttributeValue (attr, name, &length);
305: if (!strcmp (name, "template_id"))
306: {
307: /* The element is the template ID meta */
308: attrType.AttrTypeNum = HTML_ATTR_meta_content;
309: attr = TtaGetAttribute (meta, attrType);
310:
311: if (attr)
312: {
313: length = TtaGetTextAttributeLength (attr) + 1;
314: temp_id = (char *) TtaGetMemory (length);
315: TtaGiveTextAttributeValue (attr, temp_id, &length);
316: found = True;
317: }
318: TtaFreeMemory(name);
319: }
320: }
321: meta = TtaSearchTypedElement(elType, SearchForward, meta);
322: }
323: /* now "temp_id" should contain the content of template_id meta */
1.36 tollenae 324:
1.42 tollenae 325: if (found)
326: {
327: meta = TtaNewElement (newdoc, elType);
328:
329: /* Create the "name" attribute */
330:
331: attrType.AttrTypeNum = HTML_ATTR_meta_name;
332: attr = TtaNewAttribute (attrType);
333: TtaAttachAttribute (meta, attr, newdoc);
334: TtaSetAttributeText (attr, "template", meta, newdoc);
335:
336: /* Create the "content" attribute */
337: attrType.AttrTypeNum = HTML_ATTR_meta_content;
338: attr = TtaNewAttribute (attrType);
339: TtaAttachAttribute (meta, attr, newdoc);
340: TtaSetAttributeText (attr, temp_id, meta, newdoc);
341:
342: TtaInsertFirstChild (&meta, head, newdoc);
343: }
344: }
1.43 tollenae 345: #endif /*TEMPLATES*/
1.36 tollenae 346: }
1.29 tollenae 347:
348:
1.46 vatton 349: /*----------------------------------------------------------------------
350: ----------------------------------------------------------------------*/
351: static void UnlockContentElements (Document doc, Element el)
1.39 tollenae 352: {
1.43 tollenae 353: #ifdef TEMPLATES
1.39 tollenae 354: ElementType elType;
355:
1.46 vatton 356: if (el)
1.39 tollenae 357: {
358: elType = TtaGetElementType (el);
359: if (TtaIsLeaf (elType))
1.46 vatton 360: /* It's a content element */
361: TtaSetAccessRight (el, ReadWrite, doc);
1.39 tollenae 362: else
363: {
1.46 vatton 364: el = TtaGetFirstChild(el);
365: while (el)
366: {
367: UnlockContentElements (doc,el);
368: TtaNextSibling (&el);
369: }
1.39 tollenae 370: }
371: }
1.43 tollenae 372: #endif /*TEMPLATES*/
1.39 tollenae 373: }
374:
1.46 vatton 375: /*----------------------------------------------------------------------
376: CheckFreeAreas
377: Parse the subtree from el, set read-write access to the child elements
378: of free_struct elements.
379: ----------------------------------------------------------------------*/
380: static void CheckFreeAreas (Document doc, Element el)
1.32 tollenae 381: {
382: #ifdef TEMPLATES
1.46 vatton 383: ElementType elType;
384: char *s;
1.32 tollenae 385:
1.46 vatton 386: el = TtaGetFirstChild(el);
387: while (el)
1.32 tollenae 388: {
1.46 vatton 389: elType = TtaGetElementType (el);
390: s = TtaGetSSchemaName (elType.ElSSchema);
1.32 tollenae 391: /* The element is not a leaf */
1.46 vatton 392: if (!strcmp (s,"Template") &&
393: elType.ElTypeNum == Template_EL_FREE_STRUCT)
394: /* The element has a free structure */
395: TtaSetAccessRight (el, ReadWrite, doc);
396: else if (!strcmp (s,"Template") &&
397: elType.ElTypeNum == Template_EL_FREE_CONTENT)
398: /* The element has free content */
399: UnlockContentElements (doc, el);
400: else
401: /* The element has a fixed structure */
402: /* So we look for a free structure in
403: the subtree */
404: CheckFreeAreas(doc, el);
405: TtaNextSibling (&el);
1.32 tollenae 406: }
407: #endif /* TEMPLATES */
408: }
1.29 tollenae 409:
1.46 vatton 410: /*----------------------------------------------------------------------
1.32 tollenae 411: Load a template and create the instance file - update images and
1.29 tollenae 412: stylesheets related to the template.
1.46 vatton 413: ----------------------------------------------------------------------*/
1.29 tollenae 414: int CreateInstanceOfTemplate (Document doc, char *templatename, char *docname,
1.46 vatton 415: DocumentType docType)
1.29 tollenae 416: {
1.43 tollenae 417: #ifdef TEMPLATES
1.41 cvs 418: Element el;
1.46 vatton 419: char *s;
1.29 tollenae 420: int newdoc, len;
421: ThotBool stopped_flag;
422:
1.46 vatton 423: if (!IsW3Path (docname) && TtaFileExist (docname))
424: {
425: s = (char *)TtaGetMemory (strlen (docname) +
426: strlen (TtaGetMessage (AMAYA, AM_OVERWRITE_CHECK)) + 2);
427: sprintf (s, TtaGetMessage (AMAYA, AM_OVERWRITE_CHECK), docname);
428: InitConfirm (0, 0, s);
429: TtaFreeMemory (s);
430: if (!UserAnswer)
431: return 0;
432: }
433:
434: if (InNewWindow || DontReplaceOldDoc)
435: {
436: newdoc = InitDocAndView (doc,
437: !DontReplaceOldDoc /* replaceOldDoc */,
438: InNewWindow, /* inNewWindow */
439: DocumentName, (DocumentType)docType, 0, FALSE,
440: L_Other, (ClickEvent)CE_ABSOLUTE);
441: DontReplaceOldDoc = FALSE;
442: }
443: else
444: {
445: /* record the current position in the history */
446: AddDocHistory (doc, DocumentURLs[doc],
447: DocumentMeta[doc]->initial_url,
448: DocumentMeta[doc]->form_data,
449: DocumentMeta[doc]->method);
450: newdoc = InitDocAndView (doc,
451: !DontReplaceOldDoc /* replaceOldDoc */,
452: InNewWindow, /* inNewWindow */
453: DocumentName, (DocumentType)docType, 0, FALSE,
454: L_Other, (ClickEvent)CE_ABSOLUTE);
455: }
456:
1.33 tollenae 457: if (newdoc != 0)
1.29 tollenae 458: {
1.46 vatton 459: TtaExtractName (templatename, DirectoryName, DocumentName);
1.47 ! vatton 460: /* Register the last used template directory */
! 461: TtaSetEnvString ("TEMPLATES_DIRECTORY", DirectoryName, TRUE);
1.29 tollenae 462: LoadDocument (newdoc, templatename, NULL, NULL, CE_ABSOLUTE,
1.33 tollenae 463: "", DocumentName, NULL, FALSE, &DontReplaceOldDoc);
1.46 vatton 464: InsertInstanceMeta (newdoc);
1.33 tollenae 465:
1.32 tollenae 466: /* Update URLs of linked documents */
467: SetRelativeURLs (newdoc, docname);
1.33 tollenae 468:
1.29 tollenae 469: /* change its URL */
470: TtaFreeMemory (DocumentURLs[newdoc]);
471: len = strlen (docname) + 1;
472: DocumentURLs[newdoc] = TtaStrdup (docname);
473: DocumentSource[newdoc] = 0;
474: /* add the URI in the combobox string */
475: AddURLInCombobox (docname, NULL, FALSE);
476: TtaSetTextZone (newdoc, 1, URL_list);
477: /* change its directory name */
478: TtaSetDocumentDirectory (newdoc, DirectoryName);
479:
480: TtaSetDocumentModified (newdoc);
481: W3Loading = 0; /* loading is complete now */
482: DocNetworkStatus[newdoc] = AMAYA_NET_ACTIVE;
483: stopped_flag = FetchAndDisplayImages (newdoc, AMAYA_LOAD_IMAGE, NULL);
484: if (!stopped_flag)
1.32 tollenae 485: {
486: DocNetworkStatus[newdoc] = AMAYA_NET_INACTIVE;
487: /* almost one file is restored */
488: TtaSetStatus (newdoc, 1, TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED),
1.47 ! vatton 489: NULL);
1.32 tollenae 490: }
1.29 tollenae 491: /* check parsing errors */
492: CheckParsingErrors (newdoc);
1.46 vatton 493: /* Set elements access rights according to free_* elements */
1.41 cvs 494: el = TtaGetMainRoot (newdoc);
1.46 vatton 495: if (el)
496: {
497: TtaSetAccessRight (el, ReadOnly, newdoc);
498: CheckFreeAreas (newdoc, el);
499: }
1.29 tollenae 500: }
1.47 ! vatton 501: BackupDocument = 0;
! 502: return (newdoc);
1.43 tollenae 503: #endif /* TEMPLATES */
1.29 tollenae 504: }
505:
1.46 vatton 506: /*----------------------------------------------------------------------
1.42 tollenae 507: Here we put all the actions to performs when we know a document
508: is an instance
1.46 vatton 509: ----------------------------------------------------------------------*/
1.37 tollenae 510: void LoadInstanceOfTemplate (Document doc)
511: {
1.43 tollenae 512: #ifdef TEMPLATES
513: ThotBool show;
514: Element el = TtaGetMainRoot (doc);
515: char *css_url;
516: PInfoPtr pInfo;
517: CSSInfoPtr css;
518:
1.46 vatton 519: el = TtaGetMainRoot (doc);
520: TtaSetAccessRight (el, ReadOnly, doc);
521: CheckFreeAreas (doc, el);
1.43 tollenae 522: TtaGetEnvBoolean ("SHOW_TEMPLATES", &show);
523: css_url = (char *) TtaGetMemory (MAX_LENGTH);
524: sprintf (css_url, "%s%camaya%chide_template.css", TtaGetEnvString ("THOTDIR"),DIR_SEP,DIR_SEP);
525: if (!show)
526: {
527: /* We don't want to show the frames around template's elements,
528: so we load a stylesheet with border: none for all template's
529: elements */
530:
531: LoadStyleSheet (css_url, doc, NULL, NULL, NULL, CSS_ALL, FALSE);
532: }
533: else
534: {
535: css = SearchCSS (doc, css_url, NULL, &pInfo);
536: if (css)
537: RemoveStyle (css_url, doc, TRUE, TRUE, NULL, CSS_EXTERNAL_STYLE);
538: }
539: TtaFreeMemory(css_url);
540: #endif /* TEMPLATES */
1.37 tollenae 541: }
1.42 tollenae 542:
543:
1.46 vatton 544: /*----------------------------------------------------------------------
1.42 tollenae 545: ThotBool isTemplateInstance (Document doc)
546: Return true if the document is an instance
1.46 vatton 547: ----------------------------------------------------------------------*/
1.42 tollenae 548: ThotBool IsTemplateInstance (Document doc)
549: {
1.43 tollenae 550: #ifdef TEMPLATES
1.42 tollenae 551: Element el = TtaGetMainRoot (doc);
552: Element meta;
553: ElementType metaType;
554: AttributeType attrType;
555: Attribute attr;
556: ThotBool found = false;
557: char* name,* version;
558: int length;
559:
560: /* metaType is first used to find a meta element */
561: metaType.ElSSchema = TtaGetSSchema ("HTML", doc);
562: metaType.ElTypeNum = HTML_EL_META;
563: meta = TtaSearchTypedElement(metaType, SearchInTree, el);
564:
565: /* attrType will be used to find the name attribute of a meta */
566: attrType.AttrSSchema = metaType.ElSSchema;
567: attrType.AttrTypeNum = HTML_ATTR_meta_name;
568: while (meta && !found)
569: {
570: attr = TtaGetAttribute (meta, attrType);
571: if (attr != NULL)
572: /* The element contains a name attribute */
573: {
574: length = TtaGetTextAttributeLength (attr) + 1;
575: name = (char *) TtaGetMemory (length);
576: TtaGiveTextAttributeValue (attr, name, &length);
577:
578: if (!strcmp(name, "template"))
579: {
580: /* The element is the template meta, the document is a template instance */
581: attrType.AttrTypeNum = HTML_ATTR_meta_content;
582: attr = TtaGetAttribute (meta, attrType);
583:
584: if (attr)
585: {
586: length = TtaGetTextAttributeLength (attr) + 1;
587: version = (char *) TtaGetMemory (length);
588: TtaGiveTextAttributeValue (attr, version, &length);
589:
590: DocumentMeta[doc]->template_version = version;
591: TtaFreeMemory (version);
592: found = True;
593: }
594: }
595: TtaFreeMemory(name);
596: }
597: meta = TtaSearchTypedElement(metaType, SearchForward, meta);
598: }
599:
600: return found;
1.43 tollenae 601: #else /* TEMPLATES */
1.44 cvs 602: return FALSE;
1.43 tollenae 603: #endif /* TEMPLATES */
1.42 tollenae 604: }
Webmaster