コード例 #1
0
ファイル: Labeler.php プロジェクト: pscheit/psc-cms
 public function guessLabel($identifier)
 {
     if (array_key_exists($identifier, $this->commonLabels)) {
         return $this->commonLabels[$identifier];
     }
     // camelCase => camel Case
     $identifier = Preg::replace($identifier, '/([a-z])([A-Z])/', '$1 $2');
     // camel Case => Camel Case
     return S::ucfirst($identifier);
 }
コード例 #2
0
ファイル: ResponseHeader.php プロジェクト: pscheit/psc-cms
 public function parseFrom($string)
 {
     $fields = explode("\r\n", Preg::replace($string, '/\\x0D\\x0A[\\x09\\x20]+/', ' '));
     //Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
     //HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
     if (!Preg::match($statusLine = array_shift($fields), '|HTTP/([0-9]+\\.[0-9]+)\\s+([0-5][0-9]+)\\s+(.*)|', $match)) {
         throw new \Psc\Exception('Kann Header Status-Line nicht parsen: "' . $statusLine . '"');
     }
     list($NULL, $this->version, $this->code, $this->reason) = $match;
     parent::parseFrom($string);
 }
コード例 #3
0
ファイル: Header.php プロジェクト: pscheit/psc-cms
 public function parseFrom($string)
 {
     $fields = explode("\r\n", Preg::replace($string, '/\\x0D\\x0A[\\x09\\x20]+/', ' '));
     $fields = explode("\r\n", $string);
     //Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
     //HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
     if (!Preg::match($statusLine = array_shift($fields), '|HTTP/([0-9]+\\.[0-9]+)\\s+([0-5][0-9]+)\\s+(.*)|', $match)) {
         throw new \Psc\Exception('Kann Header Status-Line nicht parsen: "' . $statusLine . '"');
     }
     list($NULL, $this->version, $this->code, $this->reason) = $match;
     /*
        message-header = field-name ":" [ field-value ]
        field-name     = token
        field-value    = *( field-content | LWS )
        field-content  = <the OCTETs making up the field-value
                         and consisting of either *TEXT or combinations
                         of token, separators, and quoted-string>
     */
     foreach ($fields as $field) {
         try {
             if (Preg::match($field, '/([^:]+): (.+)/m', $match)) {
                 list($NULL, $name, $value) = $match;
                 $name = Preg::replace_callback(mb_strtolower(trim($name)), '/(?<=^|[\\x09\\x20\\x2D])./', function ($m) {
                     return mb_strtoupper($m[0]);
                 });
                 if (isset($this->values[$name])) {
                     if (is_array($this->values[$name])) {
                         $this->values[$name][] = $value;
                     } else {
                         $this->values[$name] = array($this->values[$name], $value);
                     }
                 } else {
                     $this->values[$name] = trim($value);
                 }
             }
         } catch (\Psc\Exception $e) {
             if (mb_strpos($e->getMessage(), 'Bad UTF8') === FALSE) {
                 throw $e;
             }
         }
     }
 }
コード例 #4
0
ファイル: Header.php プロジェクト: pscheit/psc-cms
 public function parseFrom($string)
 {
     $fields = explode("\r\n", Preg::replace($string, '/\\x0D\\x0A[\\x09\\x20]+/', ' '));
     array_shift($fields);
     // status line wegnehmen, denn das wird in den ableitenden geparsed
     /*
        message-header = field-name ":" [ field-value ]
        field-name     = token
        field-value    = *( field-content | LWS )
        field-content  = <the OCTETs making up the field-value
                         and consisting of either *TEXT or combinations
                         of token, separators, and quoted-string>
     */
     foreach ($fields as $field) {
         if (Preg::match($field, '/([^:]+): (.+)/m', $match)) {
             list($NULL, $name, $value) = $match;
             $name = Preg::replace_callback(mb_strtolower(trim($name)), '/(?<=^|[\\x09\\x20\\x2D])./', function ($m) {
                 return mb_strtoupper($m[0]);
             });
             $this->setField($name, $value);
         }
     }
 }
コード例 #5
0
ファイル: TPL.php プロジェクト: pscheit/psc-cms
 public static function replaceBUIMarkup($text)
 {
     /*  **bold**, //italic//, __underlined__ */
     $text = Preg::replace($text, '/\\*\\*(.*?)\\*\\*/s', '<strong>$1</strong>');
     $text = Preg::replace($text, '~//(.*?)//~', '<em>$1</em>');
     $text = Preg::replace($text, '/__(.*?)__/', '<em class="u">$1</em>');
     return $text;
 }