Beispiel #1
0
 /**
  * Construction of the exception - a message is needed (1st argument)
  *
  * @param string $message The exception message
  * @param numeric $code The exception code
  * @param misc $previous The previous exception if so
  */
 public function __construct($message, $code = 0, $previous = null)
 {
     // We let the default PHP Exception manager construction
     parent::__construct($message, $code, $previous);
     $this->trace = parent::getTrace();
     $this->previous = parent::getPrevious();
     if (isset($php_errormsg)) {
         $this->php_error_message = $php_errormsg;
     }
     $dom_id = Profiler::getNewDomId('exception');
     $this->infos = array('message' => self::_buildExceptionStr(), 'type' => 'exception', 'scope' => 'Exception', 'file' => $this->getFile(), 'line' => $this->getLine(), 'filename' => basename($this->getFile()), 'dirname' => dirname($this->getFile()), 'dom_id' => $dom_id, 'source' => Profiler::getHighlightedSource($this->getFile(), $this->getLine()));
     $this->infos['traces'] = Profiler::getHighlightedTraces($this->getTrace(), $this->infos);
     $this->debugger = Debugger::getInstance();
     $this->debugger->addStack('message', $this->infos);
     $this->debugger->setDebuggerTitle(self::_buildExceptionStr(true), Url::getRequestUrl());
 }
Beispiel #2
0
 public function __construct($route = null, Collection $routes = null, array $arguments_table = array(), $matcher = null)
 {
     if (!is_null($routes)) {
         $this->setRoutes($routes);
     }
     if (!is_null($arguments_table)) {
         $this->setArgumentsTable($arguments_table);
     }
     if (!is_null($matcher)) {
         $this->setMatcher($matcher);
     }
     if (!is_null($route)) {
         $this->setRoute($route);
     } else {
         $this->setRoute(UrlHelper::getRequestUrl());
     }
 }
 /**
  */
 public function display(array $params, $view = null)
 {
     // request params settings
     $params = array_merge(array('merge_css' => isset($_GET['merge_css']) ? (bool) $_GET['merge_css'] : false, 'minify_css' => isset($_GET['minify_css']) ? (bool) $_GET['minify_css'] : false, 'merge_js' => isset($_GET['merge_js']) ? (bool) $_GET['merge_js'] : false, 'minify_js' => isset($_GET['minify_js']) ? (bool) $_GET['minify_js'] : false), $params);
     if (!isset($params['content']) && isset($params['output'])) {
         $params['content'] = $params['output'];
     }
     $title = 'Test of the Template Engine';
     if (isset($params['title'])) {
         $title = $params['title'];
     }
     $this->template_engine->templateFallback('getTemplateObject', array('TitleTag'))->add($title);
     $title_block = array('title' => isset($params['title']) ? $params['title'] : $title, 'subheader' => isset($params['subheader']) ? $params['subheader'] : "A PHP package to build HTML5 views (based on HTML5 Boilerplate layouts).", 'slogan' => isset($params['slogan']) ? $params['slogan'] : "<p>These pages show and demonstrate the use and functionality of the <a href=\"http://github.com/atelierspierrot/templatengine\">atelierspierrot/templatengine</a> PHP package you just downloaded.</p>");
     $params['title'] = $title_block;
     if (empty($params['menu'])) {
         $params['menu'] = array('Home' => UrlHelper::url(array('page' => 'index')), 'Simple test' => UrlHelper::url(array('page' => 'hello')), 'Functions doc' => UrlHelper::url(array('page' => 'fcts')), 'Plugins test' => UrlHelper::url(array('page' => 'test')), 'Typographic tests' => UrlHelper::url(array('page' => 'loremipsum')), 'PHP Assets manager' => UrlHelper::url(array('page' => 'assets')));
     }
     $params['footer'] = array('right' => 'A test of footer');
     //var_export($params); exit('yo');
     // this will display the layout on screen and exit
     $this->template_engine->renderLayout($view, $params, true, true);
 }
 /**
  */
 public function display(array $params, $view = null)
 {
     // request params settings
     $params = array_merge(array('merge_css' => isset($_GET['merge_css']) ? (bool) $_GET['merge_css'] : false, 'minify_css' => isset($_GET['minify_css']) ? (bool) $_GET['minify_css'] : false, 'merge_js' => isset($_GET['merge_js']) ? (bool) $_GET['merge_js'] : false, 'minify_js' => isset($_GET['minify_js']) ? (bool) $_GET['minify_js'] : false), $params);
     if (!isset($params['content']) && isset($params['output'])) {
         $params['content'] = $params['output'];
     }
     $title = 'Test of the Template Engine';
     if (isset($params['title'])) {
         $title = $params['title'];
     }
     $this->template_engine->templateFallback('getTemplateObject', array('TitleTag'))->add($title);
     $title_block = array('title' => isset($params['title']) ? $params['title'] : $title, 'subheader' => isset($params['subheader']) ? $params['subheader'] : "The Bootstrap & Font-Awesome libraries ready to use with the atelierspierrot/assets-manager", 'slogan' => isset($params['slogan']) ? $params['slogan'] : "<p>These pages show and demonstrate the use and functionality of the <a href=\"http://github.com/atelierspierrot/assets-bootstrapper\">atelierspierrot/assets-bootstrapper</a> PHP package you just downloaded.</p>");
     $params['title'] = $title_block;
     if (empty($params['menu'])) {
         $params['menu'] = array('Home' => UrlHelper::url(array('page' => 'index')), 'Theme' => UrlHelper::url(array('page' => 'theme')), 'Typographic tests' => UrlHelper::url(array('page' => 'loremipsum')), 'Off canvas' => UrlHelper::url(array('page' => 'offcanvas')));
     }
     $params['footer'] = array('right' => 'A test of footer');
     //var_export($params); exit('yo');
     // this will display the layout on screen and exit
     $this->template_engine->renderLayout($view, $params, true, true);
 }
 /**
  * Construction of the error - a message is needed (1st argument)
  *
  * @param string $message The error message
  * @param numeric $code The error code
  * @param numeric $severity The error severity code
  * @param string $filename The file name of the error
  * @param numeric $lineno The line number of the error
  * @param misc $previous The previous error if so
  */
 public function __construct($message, $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, $previous = null)
 {
     // This error code is not in the error_reporting()
     if (!(error_reporting() & $code)) {
         return;
     }
     // We let the default PHP Exception manager construction
     parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
     $this->trace = parent::getTrace();
     $this->previous = parent::getPrevious();
     if (isset($php_errormsg)) {
         $this->php_error_message = $php_errormsg;
     }
     switch ($this->getCode()) {
         case E_ERROR:
         case E_USER_ERROR:
             $this->setType('fatal');
             $this->setScope('Fatal Error');
             $this->exit = true;
             break;
         case E_WARNING:
         case E_USER_WARNING:
             $this->setType('warning');
             $this->setScope('Warning');
             break;
         case E_NOTICE:
         case E_USER_NOTICE:
         case @E_STRICT:
             $this->setType('notice');
             $this->setScope('Notice');
             break;
         case @E_RECOVERABLE_ERROR:
             $this->setType('catchable');
             $this->setScope('Catchable Error');
             break;
         case E_PARSE:
             $this->setType('parse');
             $this->setScope('Parsing Error');
             break;
         case @E_DEPRECATED:
         case @E_USER_DEPRECATED:
             $this->setType('deprecated');
             $this->setScope('Deprecated Error');
             break;
         default:
             $this->setType('unknown');
             $this->setScope('Unknown Error');
             $this->exit = true;
             break;
     }
     $dom_id = Profiler::getNewDomId($this->getType());
     $this->infos = array('message' => self::_buildExceptionStr(), 'scope' => $this->getScope(), 'type' => $this->getType(), 'file' => $this->getFile(), 'line' => $this->getLine(), 'severity' => $this->getSeverity(), 'filename' => basename($this->getFile()), 'dirname' => dirname($this->getFile()), 'dom_id' => $dom_id, 'source' => Profiler::getHighlightedSource($this->getFile(), $this->getLine()));
     $this->infos['traces'] = Profiler::getHighlightedTraces($this->getTrace(), $this->infos);
     $this->debugger = Debugger::getInstance();
     $this->debugger->addStack('message', $this->infos);
     $this->debugger->setDebuggerTitle(self::_buildExceptionStr(true), Url::getRequestUrl());
     return false;
 }
Beispiel #6
0
    return str_replace(join($ds, $parts), $ds . '[***]', $path);
}
/**
 * GET arguments settings
 */
$arg_ln = isset($_GET['ln']) ? $_GET['ln'] : 'en';
function getPhpClassManualLink($class_name, $ln = 'en')
{
    return sprintf('http://php.net/manual/%s/class.%s.php', $ln, strtolower($class_name));
}
if (file_exists($a = __DIR__ . '/../vendor/autoload.php')) {
    require_once $a;
} else {
    die('You need to run Composer on your project to use this interface!');
}
$webservice_domain = str_replace('demo', 'www', \Library\Helper\Url::getRequestUrl());
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>Test & documentation of PHP "WebServices" package</title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" href="assets/html5boilerplate/css/normalize.css" />
    <link rel="stylesheet" href="assets/html5boilerplate/css/main.css" />
    <script src="assets/html5boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
Beispiel #7
0
 /**
  * URL parser : load and parse the current URL
  *
  * The class will pass arguments values to any `$this->fromUrlParam($value)` method for the
  * parameter named `param`.
  *
  */
 protected function _parseUrl()
 {
     $url_frgts = UrlHelper::parse($this->getUrl());
     $route = array('all' => array());
     if (!empty($url_frgts['params'])) {
         $frgts = array();
         $url_args = $this->getArgumentsMap();
         foreach ($url_frgts['params'] as $_var => $_val) {
             $_meth = 'fromUrl' . TextHelper::toCamelCase($_var);
             if (method_exists($this, $_meth)) {
                 $_val = call_user_func_array(array($this, $_meth), array($_val));
             }
             if (isset($url_args[$_var])) {
                 $route[$url_args[$_var]] = $_val;
             } else {
                 $route['all'][$_var] = $_val;
             }
         }
     }
     $this->setRouteParsed($route);
 }
Beispiel #8
0
 /**
  * @return string
  */
 public function buildUrl()
 {
     $url = UrlHelper::parse($this->getUrl());
     $get = $this->getArguments();
     if (!empty($get)) {
         foreach ($get as $arg => $val) {
             if ($this->getFlag() & self::REWRITE_SEGMENTS_QUERY) {
                 $url['params'][$arg] = null;
                 $path = '/' . $arg . '/';
                 if (1 === preg_match('#\\/' . $arg . '\\/[^\\/]*#i', $url['path'], $matches)) {
                     $url['path'] = str_replace($matches[0], '/' . $arg . '/' . urlencode($val), $url['path']);
                 } else {
                     $url['path'] .= '/' . $arg . '/' . urlencode($val);
                 }
             } else {
                 $url['params'][$arg] = $val;
             }
         }
     }
     $user = $this->getAuthentication('user');
     if (!empty($user)) {
         $url['user'] = $user;
     }
     $pwd = $this->getAuthentication('pwd');
     if (!empty($pwd)) {
         $url['pass'] = $pwd;
     }
     $built_url = UrlHelper::build($url);
     return $built_url;
 }
 /**
  * @covers ../../../src/Library/Helper/Url::resolveHttp()
  * @covers ../../../src/Library/Helper/Url::resolvePath()
  */
 public function testResolvers()
 {
     $this->checkNoArg('resolveHttp');
     $url = 'domain.com/index.php?param=A&param1=test1&param2=test2';
     $this->assertEquals('http://' . $url, \Library\Helper\Url::resolveHttp($url));
     $this->assertEquals('http://' . $url, \Library\Helper\Url::resolveHttp('http://' . $url));
     $this->checkNoArg('resolvePath');
     $path = 'my/path/../to/./a/file';
     $realpath = 'my/to/a/file';
     $this->assertEquals($realpath, \Library\Helper\Url::resolvePath($path));
 }
Beispiel #10
0
 public static function getProfiler()
 {
     $docbook = FrontController::getInstance();
     return array('date' => new DateTime(), 'timezone' => date_default_timezone_get(), 'php_uname' => php_uname(), 'php_version' => phpversion(), 'php_sapi_name' => php_sapi_name(), 'apache_version' => function_exists('apache_get_version') ? apache_get_version() : '?', 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'git_clone' => DirectoryHelper::isGitClone($docbook->getPath('root_dir')), 'request' => UrlHelper::getRequestUrl());
 }
Beispiel #11
0
    <div id="content" role="main">

<form action="" method="get">
    <label>Repository to test:&nbsp;
    <input type="text" name="repo" value="<?php 
echo $repo;
?>
" size="60" />
    </label>
    <input type="submit" />
</form>

<pre>
<?php 
if (!empty($repo)) {
    if (\Library\Helper\Url::isUrl($repo)) {
        $tmp_dir = __DIR__ . '/tmp';
        if (!file_exists($tmp_dir)) {
            if (!mkdir($tmp_dir)) {
                die(sprintf('Can not create temporary directory "%s"!', $tmp_dir));
            }
        }
        if (!is_writable($tmp_dir)) {
            die(sprintf('Temporary directory "%s" MUST be writable!', $tmp_dir));
        }
        $a = \GitApi\GitApi::create($tmp_dir . '/' . basename($repo), $repo);
    } else {
        $a = \GitApi\GitApi::open($repo);
    }
    echo '<br />new GitApi object : ' . $a->getRepositoryPath();
    echo '<br />';
 protected function _find()
 {
     if ($this->isInited()) {
         return;
     }
     $this->reset();
     foreach ($this->directories as $dir) {
         $this->_findByDirectory(UrlHelper::resolvePath($dir));
     }
     $this->setInited(true);
 }
 /**
  * URL manager
  *
  * @param string/array/null $param A parameter to set, or an array like `param => value` to set in URL
  * @param string/null $value The value of the `$param` argument (if it is a string)
  * @param string/null $url The URL to work on (`self::getRequestUrl()` by default)
  * @param bool $return Return/Echo flag (default is to echo result)
  * @return mixed The result of the `_echo` function (string or bool)
  * @see Library\Helper\Url::url()
  * @see _echo()
  */
 function _url($param = null, $value = null, $url = null, $return = false)
 {
     return _echo(Helper\Url::url($param, $value, $url), $return);
 }
 /**
  * Test if a string is a classic url or an url like `//domain.ext/asset`
  *
  * @param   string $str
  * @return  bool
  */
 public static function isUrl($str)
 {
     return (bool) (UrlHelper::isUrl($str) || UrlHelper::isUrl('http' . $str));
 }
Beispiel #15
0
 public static function checkString($str)
 {
     if (Url::isUrl($str)) {
         return sprintf(self::mask_a_link, $str);
     } elseif (Url::isEmail($str)) {
         return sprintf(self::mask_mailto_link, $str);
     } elseif (@file_exists($str)) {
         return sprintf(self::mask_abbr, realpath($str), $str);
     } elseif (false !== strpos($str, '&')) {
         return str_replace('&', '&amp;', $str);
     }
     return $str;
 }
 /**
  * @return array
  */
 protected function getUsageParams()
 {
     $data = $this->getUserOptions();
     $data['webservice_url'] = UrlHelper::getRequestUrl(false, true, false, true);
     return $data;
 }