Advertisement
Wistaro

Wistaro - Sample Code (4)

Jun 11th, 2019
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.48 KB | None | 0 0
  1. <?php
  2. /****************************
  3. *TEMPLATE GENERATOR v1.0 ***
  4. ****************************
  5. *
  6. *(c) Almaju & Wistaro
  7. *    2011 - 2017
  8. *   [ wistaro.fr / sw ]
  9. *
  10. * This class generate the html's files of the website
  11. *
  12. * Usage: doc/templateGenerator/howToUse.html
  13. *
  14. */
  15. class templates
  16. {
  17. function templates($adresse)
  18. {
  19.     $this->source = get_file($adresse);
  20.    
  21. }
  22. function variable($input, $output)
  23. {  
  24.     $this->source = str_replace('<*'.$input.'>', $output, $this->source);
  25. }
  26. function boucle($boucle)
  27. {
  28.     $this->source = preg_replace('#\<\-'.$boucle.'\>(.+)\<\\\-'.$boucle.'\>#isU', '<-'.$boucle.'~->$1<\\-'.$boucle.'~><-'.$boucle.'>$1<\\-'.$boucle.'>', $this->source);
  29. }
  30. function variableboucle($boucle, $input, $output)
  31. {
  32.     if(empty($output))$output = ' ';
  33.     if(!$output)$output = '';
  34.     while(preg_match('#\<\-'.$boucle.'~-\>(.+)\<\*'.$input.'\>(.+)\<\\\-'.$boucle.'~\>#isU', $this->source))
  35.     {
  36.     $output = str_replace('\\', '|| \ ', $output);
  37.     $this->source = preg_replace('#\<\-'.$boucle.'~-\>(.+)\<\*'.$input.'\>(.+)\<\\\-'.$boucle.'~\>#isU', '<-'.$boucle.'~->$1<*'.$input.'>'.$output.'$2<\\-'.$boucle.'~>', $this->source);
  38.     $this->source = str_replace('<*'.$input.'>'.$output, $output, $this->source);
  39.     $this->source = str_replace('|| \ ', '\\', $this->source);
  40.     }
  41. }
  42. function afficherboucle($boucle)
  43. {
  44.     $this->source = str_replace('<-'.$boucle.'~->', '', $this->source);
  45.     $this->source = str_replace('<\-'.$boucle.'~>', '', $this->source);
  46. }
  47. function videboucle($boucle)
  48. {
  49.     $this->source = preg_replace('#\<\-'.$boucle.'\>(.+)\<\\\-'.$boucle.'\>#isU', '', $this->source);
  50. }
  51. function afficher()
  52. {
  53.     $this->source = preg_replace('#\<\-(.+)\>(.+)\<\\\-(.+)\>#isU', '', $this->source);
  54.     $this->source = preg_replace('#\<\*(.+)\>#isU', '', $this->source);
  55.    
  56.     echo $this->source;
  57. }
  58.  
  59. function retour()
  60. {
  61.     $this->source = preg_replace('#\<\-(.+)\>(.+)\<\\\-(.+)\>#isU', '', $this->source);
  62.     $this->source = preg_replace('#\<\*(.+)\>#isU', '', $this->source);
  63.    
  64.     return $this->source;
  65. }
  66.  
  67.  
  68. function conditionboucle($boucle, $condition, $value)
  69. {
  70.     if($value)
  71.     $this->source = preg_replace('#\<\-'.$boucle.'~-\>(.+)\<\*\*'.$condition.'=(.+)\>(.+)\<\\\-'.$boucle.'~\>#isU', '<-'.$boucle.'~->$1$2$3<\\-'.$boucle.'~>', $this->source);
  72. }
  73.  
  74. function afficherlight()
  75. {
  76.     $this->source = preg_replace('#\<\-(.+)\>(.+)\<\\\-(.+)\>#isU', '', $this->source);
  77.     $this->source = preg_replace('#\<\*(.+)\>#isU', '', $this->source);
  78. }
  79. function Xcode_template()
  80. {
  81.     Xcode_light($this->source);
  82. }
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement