source: trunk/plugins/InsertSnippet2/snippets.php @ 1235

Last change on this file since 1235 was 1050, checked in by ray, 11 years ago
File size: 955 bytes
Line 
1<?php
2/**
3 * This is a reference implementation of how to get your snippets dynamically from a PHP data structure into InsertSnippet2's XML format.
4 * <?php
5 *   $categories = array('cat1','etc...'); //categories are optional
6 *   $snippets = array(
7 *     array('name'= 'snippet1','text'=>'some text'),
8 *     array('name'= 'snippet2','text'=>'<p>some HTML</p>', 'varname'=>'{$var}','category'=>'cat1') //varname and category are optional
9 *   )
10 *
11 * ?>
12 */
13header("Content-type: text/xml");
14print '<?xml version="1.0" encoding="UTF-8"?>
15<!DOCTYPE snXML PUBLIC "Xinha InsertSnippet Data File" "http://x-webservice.net/res/snXML.dtd">';
16?>
17<snXML>
18<categories>
19<?php
20foreach ((array)$categories as $c) {
21        print '<c n="'.$c.'" />'."\n";
22}
23
24?>
25</categories>
26<snippets>
27<?php
28foreach ((array)$snippets as $s) {
29        print '<s n="'.$s['name'].'" v="'.$s['varname'].'" c="'.$s['category'].'">
30<![CDATA[
31        '.$s['text'].'
32]]>
33</s>'."\n";
34}
35?>
36</snippets>
37</snXML>
Note: See TracBrowser for help on using the repository browser.