Ejemplo n.º 1
0
 /**
  * Create a syntax highlighted diagram of class functions, and optionally the current output of each method.
  * Only use the autofire if you are sure ALL METHODS perform a non-permanent functions.
  *
  * --== WARNING, USING AUTOFIRE IS DANGEROUS AND CAN DESTROY DATA PERMANENTLY ==--
  *
  * For instance,  autofiring a function called delete_all_users() ...will do exactly that!
  *
  * You have been warned!
  *
  * @param   object   $obj       The object to explore.
  * @param   boolean  $autofire  Fire each method, to acertain its current return value.
  * @return  [type]              [description]
  */
 public static function methods($obj, $autofire = false)
 {
     echo self::$is_themed ? '' : self::$theme;
     $methods = get_class_methods($obj);
     asort($methods);
     echo "<pre class='obj_explorer'>" . PHP_EOL;
     self::classes($obj);
     $cnt = 0;
     foreach ($methods as $m) {
         echo "<div class='method'>";
         $fnc = new \ReflectionMethod($obj, $m);
         $num = $fnc->getNumberOfParameters();
         $req = $fnc->getNumberOfRequiredParameters();
         $arg = $fnc->getParameters();
         $mod = implode(' ', \Reflection::getModifierNames($fnc->getModifiers())) . ' ';
         $lin = self::get_func_url($fnc->getStartLine(), $fnc->getEndLine(), $fnc->getFileName());
         $exp = $fnc->getEndLine();
         $dbk = $fnc->getDocComment();
         $nam = "function <b id='{$m}' class='nam'>{$m}</b>";
         # Parse method arguments
         if ($num > 0) {
             $arg = implode($arg, ', ');
             preg_match_all('/\\[(.*?)\\]/', $arg, $arg);
             $arg = implode($arg[1], ',');
             # Remove optional required tags
             $arg = preg_replace('/<required>|<optional>|<head>/', "", $arg);
             # Strip double spaces
             $arg = preg_replace('/\\s+/', "", $arg);
             # Add nice spacing
             $arg = preg_replace('/,/', ', ', $arg);
             # Add Function brackets
             $arg = "({$arg})";
         } else {
             # No arguments with this function, empty brackets
             $arg = '()';
         }
         # Completed function string
         $function = $mod . $nam . $arg;
         # Docblock
         $dbk = self::clean_docblok($dbk);
         # Convert tabs to space
         $dbk = preg_replace('/\\t+/', '    ', $dbk);
         # Realign offset offset docbloks
         $dbk = preg_replace('/\\s\\s+\\*/', "\n *", $dbk);
         # Completed docblok string
         $dokblock = $dbk;
         # Return Defaults
         $result = 'autofire disabled ';
         $type = 'safemode';
         # Parse return value
         if ($autofire) {
             if ($req) {
                 $result = "<b class='com'>...Untested {$req} required argument(s) needed</b>";
             } else {
                 $result = $obj->{$m}();
                 $type = gettype($result);
                 if ($type === "boolean") {
                     $type = AlpStrings::boolstr($result);
                     $result = '';
                 }
                 if ($type === "integer") {
                 }
                 if ($type === "double") {
                 }
                 if ($type === "string") {
                     $result = "'{$result}'";
                 }
                 if ($type === "array") {
                     $result = PHP_EOL . PHP_EOL . '{ARR}' . print_r($result, true) . '{/ARR}';
                 }
                 if ($type === "object") {
                     $result = 'object';
                     #recurse!
                 }
                 if ($type === "resource") {
                     $result = $type;
                 }
                 if ($type === "NULL") {
                     $result = "<b class='com'>...Check page src for possible function echo</b>";
                 }
                 if ($type === "unknown type") {
                     $result = $type;
                 }
             }
         }
         #divider and Line Info
         # Completed return string
         $result = "<b class='ops'>" . trim("Returned </b>(<b class='dec'>{$type}</b>)") . " {$result}";
         $method_info = $dokblock . PHP_EOL . PHP_EOL . $function . PHP_EOL . PHP_EOL . $result;
         $method_info = Syntax::php($method_info, 'all');
         echo $lin;
         echo $method_info;
         echo "</div>";
     }
     echo '</pre>';
     return;
     /*
     	#echo implode(' ', Reflection::getModifierNames($fnc->getModifiers())).PHP_EOL;
     
     	#echo 'getParameters()                 : '.print_r(         $fnc->getParameters()).PHP_EOL;
     	#echo 'getStaticVariables()            : '.print_r(         $fnc->getStaticVariables()).PHP_EOL;
     	#echo 'isAbstract()                    : '.AT::boolstr( $fnc->isAbstract()).PHP_EOL;
     	#echo 'isConstructor()                 : '.AT::boolstr( $fnc->isConstructor()).PHP_EOL;
     	#echo 'isDestructor()                  : '.AT::boolstr( $fnc->isDestructor()).PHP_EOL;
     	#echo 'isFinal()                       : '.AT::boolstr( $fnc->isFinal()).PHP_EOL;
     	#echo 'isPrivate()                     : '.AT::boolstr( $fnc->isPrivate()).PHP_EOL;
     	#echo 'isProtected()                   : '.AT::boolstr( $fnc->isProtected()).PHP_EOL;
     	#echo 'isPublic()                      : '.AT::boolstr( $fnc->isPublic()).PHP_EOL;
     	#echo 'isStatic()                      : '.AT::boolstr( $fnc->isStatic()).PHP_EOL;
     	#echo 'inNamespace()                   : '.AT::boolstr( $fnc->inNamespace()).PHP_EOL;
     	#echo 'isClosure()                     : '.AT::boolstr( $fnc->isClosure()).PHP_EOL;
     	#echo 'isDeprecated()                  : '.AT::boolstr( $fnc->isDeprecated()).PHP_EOL;
     	#echo 'isGenerator()                   : '.AT::boolstr( $fnc->isGenerator()).PHP_EOL;
     	#echo 'isInternal()                    : '.AT::boolstr( $fnc->isInternal()).PHP_EOL;
     	#echo 'isUserDefined()                 : '.AT::boolstr( $fnc->isUserDefined()).PHP_EOL;
     	#echo 'returnsReference()              : '.AT::boolstr( $fnc->returnsReference()).PHP_EOL;
     	#echo 'Name                            : '.                 $fnc->name.PHP_EOL;
     	#echo 'Class                           : '.                 $fnc->class.PHP_EOL;
     	#echo 'getModifiers()                  : '.                 implode(' ', Reflection::getModifierNames($fnc->getModifiers())).PHP_EOL;
     	#echo 'getEndLine()                    : '.                 $fnc->getEndLine().PHP_EOL;
     	#echo 'getNumberOfParameters()         : '.                 $fnc->getNumberOfParameters().PHP_EOL;
     	#echo 'getNumberOfRequiredParameters() : '.                 $fnc->getNumberOfRequiredParameters().PHP_EOL;
     	#echo 'getStartLine()                  : '.                 $fnc->getStartLine().PHP_EOL;
     	#echo 'getDocComment()                 : '.                 $fnc->getDocComment().PHP_EOL;
     	#echo 'getExtensionName()              : '.                 $fnc->getExtensionName().PHP_EOL;
     	#echo 'getFileName()                   : '.                 $fnc->getFileName().PHP_EOL;
     	#echo 'getName()                       : '.                 $fnc->getName().PHP_EOL;
     	#echo 'getNamespaceName()              : '.                 $fnc->getNamespaceName().PHP_EOL;
     	#echo 'getShortName()                  : '.                 $fnc->getShortName().PHP_EOL;
     */
 }
Ejemplo n.º 2
0
 /**
  * Returns an array of Syntax objects that this LDAP server uses mapped to
  * their descriptions. The key of each entry is the OID of the Syntax.
  */
 public function SchemaSyntaxes($method = null, $dn = '')
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 25, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     # Set default return
     $return = null;
     if ($return = get_cached_item($this->index, 'schema', 'syntaxes')) {
         if (DEBUG_ENABLED) {
             debug_log('Returning CACHED [%s] (%s).', 25, 0, __FILE__, __LINE__, __METHOD__, $this->index, 'syntaxes');
         }
         return $return;
     }
     $raw = $this->getRawSchema($method, 'ldapSyntaxes', $dn);
     if ($raw) {
         # build the array of attributes
         $return = array();
         foreach ($raw as $line) {
             if (is_null($line) || !strlen($line)) {
                 continue;
             }
             $syntax = new Syntax($line);
             $key = strtolower(trim($syntax->getOID()));
             if (!$key) {
                 continue;
             }
             $return[$key] = $syntax;
         }
         ksort($return);
         # cache the schema to prevent multiple schema fetches from LDAP server
         set_cached_item($this->index, 'schema', 'syntaxes', $return);
     }
     if (DEBUG_ENABLED) {
         debug_log('Returning (%s)', 25, 0, __FILE__, __LINE__, __METHOD__, $return);
     }
     return $return;
 }
Ejemplo n.º 3
0
 /**
  * Returns an array of Syntax objects that this LDAP server uses mapped to
  * their descriptions. The key of each entry is the OID of the Syntax.
  */
 function SchemaSyntaxes($dn = null)
 {
     # Set default return
     $return = null;
     if ($return = get_cached_item($this->server_id, 'schema', 'syntaxes')) {
         debug_log('%s::SchemaSyntaxes(): Returning CACHED [%s] (%s).', 25, get_class($this), $this->server_id, 'syntaxes');
         return $return;
     }
     $raw_syntaxes = $this->getRawSchema('ldapSyntaxes', $dn);
     if ($raw_syntaxes) {
         # build the array of attributes
         $return = array();
         foreach ($raw_syntaxes as $syntax_string) {
             $syntax = new Syntax($syntax_string);
             $key = strtolower(trim($syntax->getOID()));
             if (!$key) {
                 continue;
             }
             $return[$key] = $syntax;
         }
         ksort($return);
         # cache the schema to prevent multiple schema fetches from LDAP server
         set_cached_item($this->server_id, 'schema', 'syntaxes', $return);
     }
     debug_log('%s::SchemaSyntaxes(): Entered with (%s), Returning (%s).', 25, get_class($this), $dn, $return);
     return $return;
 }
Ejemplo n.º 4
0
 public static function useXpSyntax()
 {
     self::$syntax = Syntax::forName('xp');
 }
Ejemplo n.º 5
0
 function checkForMethod($method)
 {
     // wenn die Methode nicht existiert, wird die Fehlervariable gefüllt
     if (class_exists("Syntax") and !method_exists($this, $method)) {
         $syntax = new Syntax();
         $language = new Language();
         $this->error = $syntax->createDeadlink("{" . get_class($this) . "}", $language->getLanguageValue("plugin_error_missing_method_2", get_class($this), $method));
     }
 }
Ejemplo n.º 6
0
function wfSyntaxHighlightVimRender( $in, array $argv ) {
	$in = ltrim( $in, "\n" );
	$syntax = new Syntax( $in );

	return $syntax->getOut();
}
Ejemplo n.º 7
0
 public function testMethodIsAllowedToBeNull()
 {
     $syntax = new Syntax('? equals ?');
     $this->assert($syntax->getMethod())->isNull;
 }
Ejemplo n.º 8
0
 function findInPage($cat, $page)
 {
     global $CatPage;
     // Dateiinhalt auslesen, wenn vorhanden...
     if (false !== ($pagecontent = $CatPage->get_PageContent($cat, $page))) {
         if (strlen($pagecontent) < 1) {
             return false;
         }
         # den eigenen Placholder raus nehmen sonst endlosschleife
         $pagecontent = preg_replace("/\\{" . $this->placeholder . "\\|(.*)\\}/m", "", $pagecontent);
         $pagecontent = str_replace("{" . $this->placeholder . "}", "", $pagecontent);
         $tmp_syntax = new Syntax();
         $pagecontent = $tmp_syntax->convertContent($pagecontent, true);
         # alle Komentare raus
         $pagecontent = preg_replace("/\\<!--(.*)-->/Umsi", " ", $pagecontent);
         # alle script, select, object, embed sachen raus
         $pagecontent = preg_replace("/\\<script(.*)\\<\\/script>/Umsi", "", $pagecontent);
         $pagecontent = preg_replace("/\\<select(.*)\\<\\/select>/Umsi", "", $pagecontent);
         $pagecontent = preg_replace("/\\<object(.*)\\<\\/object>/Umsi", "", $pagecontent);
         $pagecontent = preg_replace("/\\<embed(.*)\\<\\/embed>/Umsi", "", $pagecontent);
         # alle tags raus
         $pagecontent = strip_tags($pagecontent);
         $pagecontent = $this->lowercase($pagecontent);
         # nach alle Suchbegrieffe suchen
         foreach ($this->phrasearray as $phrase) {
             if ($phrase == "") {
                 continue;
             }
             // Wenn...
             if (substr_count($this->lowercase($CatPage->get_HrefText($cat, $page)), $phrase) > 0 or substr_count($pagecontent, $phrase) > 0) {
                 // gefunden
                 return true;
             }
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 9
0
 function get_PageContent($cat, $page, $for_syntax = false, $convert_content = false)
 {
     $cat = $this->get_AsKeyName($cat);
     $page = $this->get_AsKeyName($page);
     if ($this->CatPageArray[$cat]['_protect-']) {
         return false;
     }
     if ($this->CatPageArray[$cat]['_pages-'][$page]['_protect-']) {
         return false;
     }
     # wenn das nee Vituelle page ist
     if (isset($this->CatPageArray[$cat]['_pages-'][$page]["_content-"]) and $this->CatPageArray[$cat]['_pages-'][$page]["_content-"]) {
         $page_content = $this->CatPageArray[$cat]['_pages-'][$page]["_content-"];
         if ($for_syntax and !$convert_content) {
             global $syntax;
             $page_content = $syntax->preparePageContent($page_content);
         }
         if ($convert_content) {
             $mysyntax = new Syntax();
             $page_content = $mysyntax->convertContent($page_content, $for_syntax);
         }
         return $page_content;
     }
     $cat = $this->get_FileSystemName($cat, false);
     $page = $this->get_FileSystemName($cat, $page);
     if ($this->get_Type($cat, $page) != EXT_LINK) {
         if (file_exists(CONTENT_DIR_REL . $cat . '/' . $page)) {
             $page_content = file_get_contents(CONTENT_DIR_REL . $cat . '/' . $page);
             global $page_protect_search;
             $page_content = str_replace($page_protect_search, "", $page_content);
             if ($for_syntax and !$convert_content) {
                 global $syntax;
                 $page_content = $syntax->preparePageContent($page_content);
             }
             if ($convert_content) {
                 $mysyntax = new Syntax();
                 $page_content = $mysyntax->convertContent($page_content, $for_syntax);
             }
             return $page_content;
         }
     }
     return false;
 }
Ejemplo n.º 10
0
 public function testDepth()
 {
     $syntax = new Syntax();
     $this->assertEquals(1, $syntax->depth());
     $rule = new Rule($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $rule->depth());
     $syntax->addChild($rule);
     $this->assertEquals(2, $syntax->depth());
     $seq = new Sequence($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $seq->depth());
     $rule->addChild($seq);
     $this->assertEquals(2, $rule->depth());
     $this->assertEquals(3, $syntax->depth());
     $ident = new Identifier($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $ident->depth());
     $seq->addChild($ident);
     $this->assertEquals(2, $seq->depth());
     $this->assertEquals(3, $rule->depth());
     $this->assertEquals(4, $syntax->depth());
     $loop = new Loop($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $loop->depth());
     $seq->addChild($loop);
     $this->assertEquals(2, $seq->depth());
     $this->assertEquals(3, $rule->depth());
     $this->assertEquals(4, $syntax->depth());
     $term = new Terminal($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $term->depth());
     $loop->addChild($term);
     $this->assertEquals(2, $loop->depth());
     $this->assertEquals(3, $seq->depth());
     $this->assertEquals(4, $rule->depth());
     $this->assertEquals(5, $syntax->depth());
 }