Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

made the Replace Plugin cope with the PluginManager

  • Loading branch information...
commit 3878ca93f8797dfcc813c9bee1196eaba6bf40bd 1 parent a770415
Hauke Schade authored January 31, 2013

Showing 1 changed file with 43 additions and 12 deletions. Show diff stats Hide diff stats

  1. 55  Replace/Replace.controller.php
55  Replace/Replace.controller.php
@@ -24,32 +24,63 @@
24 24
   const IDENTIFIER = 'Replace';
25 25
 
26 26
   /**
27  
-   * Replace the words.
  27
+   * @var array
  28
+   * @access protected
  29
+   *
  30
+   */
  31
+  protected $_aRequest;
  32
+
  33
+  /**
  34
+   * @var array
  35
+   * @access protected
  36
+   *
  37
+   */
  38
+  protected $_aSession;
  39
+
  40
+  /**
  41
+   * Initialize the software by adding input params.
28 42
    *
29  
-   * @final
30 43
    * @access public
31  
-   * @param array $aRequest
32  
-   * @param array $aSession
33  
-   * @param string $sHtml
34  
-   * @return string HTML
35  
-   * @todo exception instead of die();
  44
+   * @param array $aRequest alias for the combination of $_GET and $_POST
  45
+   * @param array $aSession alias for $_SESSION
  46
+   * @param object $oPlugins the PluginManager
36 47
    *
37 48
    */
38  
-  public final function replace(&$aRequest, &$aSession, $sHtml) {
  49
+  public function __construct(&$aRequest, &$aSession, &$oPlugins) {
  50
+    $this->_aRequest  = & $aRequest;
  51
+    $this->_aSession  = & $aSession;
  52
+
39 53
     # Check for config file
40  
-    if (!isset($aSession['replace'])) {
  54
+    if (!isset($this->_aSession['replace'])) {
41 55
       $sReplaceDataFile = PATH_STANDARD . '/app/config/Replace.yml';
42 56
 
43 57
       if (file_exists($sReplaceDataFile))
44  
-        $aSession['replace'] = \Symfony\Component\Yaml\Yaml::parse(file_get_contents($sReplaceDataFile));
  58
+        $this->_aSession['replace'] = \Symfony\Component\Yaml\Yaml::parse(file_get_contents($sReplaceDataFile));
45 59
 
46 60
       else
47 61
         die('No replace config file.');
48 62
     }
49 63
 
50  
-    foreach ($aSession['replace'] as $sKey => $sValue)
  64
+    # now register some events with the pluginmanager
  65
+    #$oPlugins->registerSimplePlugin($this);
  66
+    # @todo do we want this plugin to replace globally or only in content fields?
  67
+    #$oPlugins->registerContentDisplayPlugin($this);
  68
+    $oPlugins->registerGlobalDisplayPlugin($this);
  69
+  }
  70
+
  71
+  /**
  72
+   * Replace the words.
  73
+   *
  74
+   * @final
  75
+   * @access public
  76
+   * @param string $sHtml
  77
+   * @return string HTML
  78
+   *
  79
+   */
  80
+  public final function prepareContent(&$sHtml) {
  81
+    foreach ($this->_aSession['replace'] as $sKey => $sValue)
51 82
       $sHtml = str_replace($sKey, $sValue, $sHtml);
52 83
 
53 84
     return $sHtml;
54 85
   }
55  
-}
  86
+}

0 notes on commit 3878ca9

Please sign in to comment.
Something went wrong with that request. Please try again.