Esempio n. 1
0
 /**
  * Loads the HTML wms:include tags
  *
  * @version 1
  * @author Rick de Man <*****@*****.**>
  */
 protected function Component__Process()
 {
     // Get all current content
     $Result = ob_get_contents();
     // Empty current content
     ob_clean();
     // While counter
     $While = 0;
     // While counter Max
     $WhileMax = 3;
     while (preg_match_all('/([\\t ]{1,})(\\<wms:component [ \\S="]{1,}\\/>)/mi', $Result, $Matches, PREG_SET_ORDER) && $While < $WhileMax) {
         $While++;
         foreach ($Matches as $K => $V) {
             $Attributes = array();
             $found = false;
             $replace = $V[1] . "<!-- Component Error: " . htmlentities($V[2]) . "-->" . EOL;
             preg_match_all('/(\\S+)=["\']?((?:.(?!["\']?\\s+(?:\\S+)=|[>"\']))+.)["\']?/', $V[2], $TagRegex);
             foreach ($TagRegex[1] as $IndexKey => $Index) {
                 $Attributes[strtolower($Index)] = $TagRegex[2][$IndexKey];
             }
             if (isset($Attributes['component'])) {
                 $Class = "Component_" . $Attributes['component'];
                 $Action = "";
                 if (class_exists($Class)) {
                     if (isset($Attributes['action'])) {
                         $Action = ":" . $Attributes['action'];
                     }
                     if (!isset($this->Components[$Attributes['component']])) {
                         $this->HTML_JsComponentsLoad($Attributes['component']);
                         $this->Components[$Attributes['component']] = new $Class($this->SQL, $this->Template, $this->User);
                     }
                     $ComponentAction = $this->Components[$Attributes['component']]->Action($Attributes);
                     $replace = '';
                     if ($ComponentAction !== '') {
                         $replace .= $V[1] . "<!--  {$Class} -->" . EOL;
                         $replace .= PlaceOffset($V[1], $ComponentAction);
                         $replace .= "<!-- /{$Class} -->" . EOL;
                     }
                 } else {
                     $replace = $V[1] . "<!-- Component not installed: " . $Attributes['component'] . " -->" . EOL;
                 }
             }
             // If repalce is empty add extra new line to be removed
             if ($replace == '') {
                 $V[0] .= EOL;
             }
             $Result = str_replace($V[0], $replace, $Result);
         }
     }
     echo $Result;
 }
Esempio n. 2
0
File: html.php Progetto: RickdeM/wms
 /**
  * Loads the HTML wms:include tags
  *
  * @version 1
  * @author Rick de Man <*****@*****.**>
  */
 protected function HTML__Process()
 {
     $PregWmsInclude = '/^([\\t ]{1,})(\\<wms:include ([ \\S=\'"]+?)\\/>)/mi';
     // Regex tag Attribute & values
     $PregHtmlTags = '/([\\S]{1,})=["\'](.{0,}?)["\'][\\s]{0,1}/';
     // Accessibles functions
     $Elements = array("Bootstrap_Header", "HTML_Css", "HTML_CssFonts", "HTML_CssPlugins", "Html_Favicon", "Html_HiddenHead", "HTML_JS", "HTML_JsPlugins", "HTML_JsTemplate", "HTML_Menu", "HTML_MetaTags", "HTML_Title", "HTML_WmsData");
     // Make sure all values are LowerString
     $Elements = array_map('strtolower', $Elements);
     // Get all current content
     $Result = ob_get_contents();
     // Empty current content
     ob_clean();
     // While counter
     $While = 0;
     // While counter Page
     $WhilePage = 3;
     // While counter Max
     $WhileMax = 6;
     // Log process ?
     $Log = isset($_GET['loghtmlprocess']);
     // Create dir if not exists
     if ($Log == true) {
         CreateDir(WMS_LIB . 'html_process/');
     }
     // Loop while conditions are met
     while (preg_match_all($PregWmsInclude, $Result, $Matches, PREG_SET_ORDER) && $While <= $WhileMax) {
         $While++;
         // Loop through all matches
         foreach ($Matches as $K => $V) {
             // Log process steps
             if ($Log == true) {
                 // Replace Step Backtrace
                 file_put_contents(WMS_ROOT . '/lib/html_process/' . session_id() . '_' . sprintf('%02d', $While) . '_' . sprintf('%02d', $K) . '.html', $Result);
             }
             // Variable for all Tag attributes & values
             $Attributes = array();
             // Variable for wms:include method
             $Method = '';
             // Check for Tag attributes
             preg_match_all($PregHtmlTags, $V[2], $TagRegex);
             // Store each tag Name & Value
             foreach ($TagRegex[1] as $IndexKey => $Index) {
                 $Attributes[strtolower($Index)] = $TagRegex[2][$IndexKey];
             }
             // Check for attributes
             if (isset($Attributes['type']) && isset($Attributes['name'])) {
                 // Create Method name
                 $Method = strtolower($Attributes['type'] . "_" . $Attributes['name']);
             }
             // Check if method is allowed and exists
             if (in_array($Method, $Elements) || $While === $WhilePage && $Method == 'html_page' || $While == $WhileMax && $Method == 'html_builderrors') {
                 // Check if method exists
                 if (method_exists($this, $Method)) {
                     // Call method for output
                     $Replace = $this->{$Method}($V[1], $V[2], $Attributes);
                     if (is_array($Replace)) {
                         $Paramaters = $Replace['Paramaters'];
                         $Replace = $Replace['Result'];
                     }
                     // Remove end Whiteline
                     $Replace = preg_replace('/(' . EOL . ')*$/', '', $Replace);
                     if (isset($Paramaters)) {
                         if ($Paramaters['ClearPage'] === true) {
                             preg_match('/<body>[\\W\\w]+?<div[\\W\\w]+?<\\/div>([\\W\\w]+?[\\W\\w]+?(<div)[\\W\\w]+)<\\/body>/im', $Result, $Match);
                             $Replace = PlaceOffset('	', $Replace);
                             $Result = str_replace($Match[1], EOL . $Replace . EOL, $Result);
                             $Replace = '';
                         }
                     }
                     $Replace = PlaceOffset($V[1], $Replace);
                     // strip last EndOfLine
                     if (endswith(EOL, $Replace)) {
                         $Replace = substr($Replace, 0, -strlen(EOL));
                     }
                     // Replace the tag by the new content in the HTML
                     $Result = str_replace($V[0], $Replace, $Result);
                 } else {
                     // Error - Method not exist
                     $this->BuildErrors[] = $this->Bootstrap_HtmlAlert('wms:include method does not exist: ' . $Method, 'danger');
                     $Result = str_replace($V[0], '', $Result);
                 }
             } else {
                 if (!in_array($Method, array('html_page', 'html_builderrors'))) {
                     // Error - Method not allowed
                     $this->BuildErrors[] = $this->Bootstrap_HtmlAlert('wms:include not allowed: ' . htmlentities($V[2]), 'danger');
                     $Result = str_replace($V[0], '', $Result);
                 }
             }
         }
     }
     if (preg_match('/([\\t ]{1,})(<wms:PageDebug>)/', $Result, $PageDebug)) {
         $Result2 = ob_get_contents();
         ob_clean();
         $Result = str_replace($PageDebug[0], placeoffset($PageDebug[1], $Result2), $Result);
     }
     echo $Result;
     // process wms:components tags
     $this->Component__Process();
 }