Ignore:
Timestamp:
02/24/07 02:18:05 (13 years ago)
Author:
ray
Message:

updated branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ray/plugins/InsertSnippet/snippets.php

    • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
    r439 r761  
    1 var snippets = new Array(); 
    2 var i = 0; 
    31<?php 
     2$snippets_file = 'snippets.html'; 
    43 
    5 function get_all_parts($string) 
     4include_once('../../contrib/php-xinha.php'); 
     5 
     6if($passed_data = xinha_read_passed_data()) 
    67{ 
    7         preg_match_all('#<!--(.*?)-->(.*?)<!--/.*?-->#s',$string,$matches); 
     8        extract($passed_data);       
     9} 
     10$snippets = file_get_contents($snippets_file); 
     11preg_match_all('/<!--(.*?)-->(.*?)<!--\/.*?-->/s',$snippets,$matches); 
    812         
    9         $array=array(); 
    10         for ($i=0;$i<count($matches[1]);$i++) 
    11         { 
    12                 $array[$matches[1][$i]] = $matches[2][$i]; 
    13         } 
    14         return $array; 
     13$array=array(); 
     14for ($i=0;$i<count($matches[1]);$i++) 
     15{ 
     16        $id = $matches[1][$i]; 
     17        $html = $matches[2][$i]; 
     18        $array[] = array('id'=>$id,'HTML'=>$html); 
    1519} 
    16 $snippets = file_get_contents('snippets.html'); 
    17  
    18 $matches = get_all_parts($snippets); 
    19 foreach ($matches as $name =>$html) 
    20 { 
    21         print "snippets[i] = new Object();\n"; 
    22         print "snippets[i]['id'] = '$name';\n"; 
    23         print "snippets[i]['HTML'] = '".str_replace("\n",'\n',addcslashes($html,"'"))."';\n"; 
    24         print "i++;\n"; 
    25 } 
     20print "var snippets = " . xinha_to_js($array); 
    2621 
    2722?> 
Note: See TracChangeset for help on using the changeset viewer.