/**
  * @return list($threadLink, $threadId);
  */
 public function findThread($boardId, Season $season)
 {
     $this->logger->writeln('Suche Thread für ' . $season . ' in board: ' . $boardId);
     $this->req = new URLRequest('http://www.subcentral.de/index.php?page=Board&boardID=' . $boardId, $this->cookieJar);
     $html = $this->req->init()->process();
     /* wir holen uns den richtigen Thread aus den "wichtigen Themen" */
     $dom = xml::doc($html);
     $res = xml::query($dom, '#stickiesStatus table td.columnTopic div.topic p');
     $stickies = array();
     // das sind nicht alle wegen break!
     foreach ($res as $topicP) {
         $topicP = xml::doc($topicP);
         $topicA = A::first(xml::query($topicP, 'a'));
         $title = (string) $topicA->nodeValue;
         $stickies[] = $title;
         $prefix = xml::query($topicP, 'span.prefix strong');
         if (count($prefix) == 1 && $prefix[0]->nodeValue == '[Subs]' && Preg::match($title, '/(Staffel\\s*' . $season->getNum() . '|S0*' . $season->getNum() . ')/i') > 0) {
             $link = $topicA->getAttribute('href');
             $threadId = (int) Preg::qmatch($link, '/threadId=([0-9]+)/');
             break;
         }
     }
     if (!isset($link)) {
         $pe = new SubcentralException('Pfad nicht gefunden: "#stickiesStatus table td.columnTopic div.topic p a" in ' . $this->req->getURL() . ' ' . Code::varInfo($stickies));
         $e = new SubcentralException('Thread für Staffel: ' . $season->getNum() . ' für Serie: ' . $season->getTvShow()->getTitle() . ' nicht gefunden', 0, $pe);
         $this->logger->writeln($e->getMessage());
         $this->logger->writeln($pe->getMessage());
         throw $e;
     }
     $link = 'http://www.subcentral.de/' . $link;
     return array($link, $threadId);
 }
 protected function injectToSetter(GClass $gClass)
 {
     $setter = 'set' . $this->relation->getSourceMethodName();
     if (!$gClass->hasOwnMethod($setter)) {
         throw new \RuntimeException('in der Klasse kann ' . $setter . ' nicht gefunden werden. Womöglich muss der Setter vererbt werden');
     } else {
         $setter = $gClass->getMethod($setter);
     }
     if ($this->relation->isTargetNullable()) {
         $firstParam = current($setter->getParameters());
         $firstParam->setOptional(TRUE)->setDefault(NULL);
     }
     if ($this->relation->shouldUpdateOtherSide()) {
         // wenn die Relation bidrektional ist muss der normale setter auf der Inverse side addXXX auf der aufrufen
         // das ist aber gar nicht so trivial, weil wie wird removed?
         // before('return $this').insert(...)
         $body = $setter->getBodyCode();
         $lastLine = array_pop($body);
         if (\Psc\Preg::match($lastLine, '/^\\s*return \\$this;$/') <= 0) {
             throw new \Psc\Exception('EntityRelationInterfaceBuilder möchte den Setter: ' . $setter->getName() . ' für ' . $gClass . ' ergänzen, aber der Body code scheint kein autoGenererierter zu sein.');
         }
         $body[] = \Psc\TPL\TPL::miniTemplate(($this->relation->isTargetNullable() ? 'if (isset($%paramName%)) ' : NULL) . '$%paramName%->add%otherMethodName%($this);' . "\n", array('paramName' => $this->relation->getTarget()->getParamName(), 'otherMethodName' => $this->relation->getSource()->getMethodName('singular')));
         $body[] = $lastLine;
         $setter->setBodyCode($body);
     }
 }
示例#3
0
 /**
  * @return array $match
  */
 public function matchRX($rx)
 {
     $match = array();
     if (Preg::match($this->part(), $rx, $match) > 0) {
         return $this->success($match);
     }
     $this->fail("part '%s' matched nicht: " . $rx);
 }
示例#4
0
 protected function sync()
 {
     $unison = $this->unisonBinary . ' -batch -terse ';
     $unison .= \Psc\TPL\TPL::miniTemplate('%profile% ', array('profile' => $this->profile));
     //print 'running: '.$unison."\n";
     $envs = array();
     $inherits = array('UNISON', 'HOME', 'PATH', 'SystemRoot', 'LOCALAPPDATA', 'SystemDrive', 'SSH_AUTH_SOCK', 'CommonProgramFiles', 'APPDATA', 'COMPUTERNAME', 'TEMP', 'TMP', 'USERNAME');
     foreach ($inherits as $inherit) {
         $envs[$inherit] = getenv($inherit);
     }
     $process = new Process($unison, NULL, $envs);
     $process->setTimeout(0);
     $log = NULL;
     $result = new \stdClass();
     $resultFound = FALSE;
     $ret = $process->run(function ($type, $buffer) use(&$log, &$result, &$resultFound) {
         // suche nach dem endergebnis:
         $m = array();
         if (\Psc\Preg::match($buffer, '/^Synchronization\\s*complete\\s*at\\s*[0-9:]*\\s*\\(([0-9]+)\\s*items?\\s*transferred, ([0-9]+) skipped,\\s*([0-9]+)\\s*failed\\)/i', $m)) {
             $resultFound = TRUE;
             $result = (object) array('transferred' => (int) $m[1], 'skipped' => (int) $m[2], 'failed' => (int) $m[3]);
         }
         $log .= $buffer;
         //if ('err' === $type) {
         //    echo '[unison-ERR]: '.$buffer;
         //} else {
         //    echo '[unison-OUT]: '.$buffer;
         //}
     });
     print "\n";
     if ($resultFound) {
         print sprintf("Unison: (%d transferred, %d skipped, %d failed)\n", $result->transferred, $result->skipped, $result->failed);
     }
     // http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#exit
     switch ($ret) {
         case 0:
             print 'Unison: successful synchronization';
             break;
         case 1:
             print 'Unison: some files were skipped, but all file transfers were successful.';
             break;
         case 2:
             print 'Unison: non-fatal failures occurred during file transfer.';
             break;
         case 3:
             print 'Unison: a fatal error occurred, or the execution was interrupted.';
             break;
         default:
             print 'Unison: unknown exit code: ' . $ret;
             break;
     }
     print "\n";
     if ($ret !== 0) {
         throw new RuntimeException('Unison failed: ' . $log);
     }
 }
示例#5
0
 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);
 }
示例#6
0
 public function validate($data)
 {
     if ($data === NULL) {
         throw new EmptyDataException();
     }
     $data = trim($data);
     // 60345+ und [A-Z]-340545345345, etc
     if (Preg::match($data, '/[0-9+]/') > 0 || Preg::match($data, '/[A-Z]+-[0-9+]/')) {
         return $data;
     }
     throw new \Psc\Exception('ist keine valide Postleitzahl');
 }
示例#7
0
 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;
             }
         }
     }
 }
示例#8
0
 public static function convertPDOException(\PDOException $e)
 {
     $exceptions = array('\\Psc\\Doctrine\\ForeignKeyConstraintException', '\\Psc\\Doctrine\\UniqueConstraintException', '\\Psc\\Doctrine\\TooManyConnectionsException', '\\Psc\\Doctrine\\UnknownColumnException');
     /* grml. fix pdo */
     if ($e->errorInfo === NULL && mb_strlen($msg = $e->getMessage()) > 0) {
         //SQLSTATE[08004] [1040] Too many connections
         if (\Psc\Preg::match($msg, '/SQLSTATE\\[([0-9]+)\\]\\s*\\[([0-9]+)\\]\\s*(.*)?/s', $m)) {
             $e->errorInfo[0] = $m[1];
             $e->errorInfo[1] = $m[2];
             $e->errorInfo[2] = $m[3];
         }
     }
     foreach ($exceptions as $cname) {
         if ($cname::check($e)) {
             return new $cname($e);
         }
     }
     //throw new \Psc\Exception('unconverted PDO Exception: '.Code::varInfo($e->errorInfo),0,$e);
     print 'unconverted PDOException: ' . Code::varInfo($e->errorInfo);
     return $e;
 }
示例#9
0
 public function compile()
 {
     $gClass = new \Psc\Code\Generate\GClass(\Psc\Code\Code::getClass($this));
     $gClass->elevateClass();
     $this->log('compiling ProjectEntities:');
     foreach ($gClass->getMethods() as $method) {
         if (\Psc\Preg::match($method->getName(), '/^compile[a-z0-9A-Z_]+$/') && $method->isPublic()) {
             $this->modelCompiler = NULL;
             // neuen erzeugen damit flags resetted werden, etc
             $m = $method->getName();
             $this->log('  ' . $m . ':');
             try {
                 $out = $this->{$m}($this->getModelCompiler());
             } catch (\Doctrine\DBAL\DBALException $e) {
                 if (mb_strpos($e->getMessage(), 'Unknown column type') !== FALSE) {
                     $types = A::implode(\Doctrine\DBAL\Types\Type::getTypesMap(), "\n", function ($fqn, $type) {
                         return $type . "\t\t" . ': ' . $fqn;
                     });
                     throw new \Psc\Exception('Database Error: Unknown Column Type: types are: ' . "\n" . $types, $e->getCode(), $e);
                 }
                 throw $e;
             } catch (\Exception $e) {
                 $this->log('    Fehler beim Aufruf von ' . $m);
                 throw $e;
             }
             if ($out instanceof \Webforge\Common\System\File) {
                 $this->log('    ' . $out . ' geschrieben');
             } elseif (is_array($out)) {
                 foreach ($out as $file) {
                     $this->log('    ' . $file . ' geschrieben');
                 }
             } elseif ($out instanceof \Psc\Doctrine\EntityBuilder) {
                 $this->log('    ' . $out->getWrittenFile() . ' geschrieben');
             }
         }
     }
     $this->log('finished.');
     return $this;
 }
示例#10
0
 /**
  * @return list($phpCode, $methodNames)
  */
 public function compile(GClass $gClass)
 {
     $this->methods = array();
     $gClass->elevateClass();
     $closures = array();
     $methodNames = array();
     foreach ($gClass->getAllMethods() as $method) {
         $closureName = $method->getName();
         if ($method->hasDocBlock()) {
             $docBlock = $method->getDocBlock();
             if (($ccAlias = \Psc\Preg::qmatch($docBlock->toString(), '/@cc-alias\\s+(.*?)([\\s]|$)/im', 1)) !== NULL) {
                 $closureName = $ccAlias;
             }
             if (\Psc\Preg::match($docBlock->toString(), '/@cc-ignore/i')) {
                 continue;
             }
         }
         $closures[$closureName] = $this->compileClosure($method, $closureName);
         $this->methods[$closureName] = $method;
         $methodNames[] = $closureName;
     }
     return array(\Webforge\Common\ArrayUtil::join($closures, "%s;\n\n"), $methodNames);
 }
示例#11
0
文件: Text.php 项目: pscheit/psc-cms
 public static function reformat($html, $withPFirst = TRUE)
 {
     /* compile regex */
     $blockElements = array('h1', 'h2', 'h3', 'div', 'h3', 'table', 'tr', 'td', 'ol', 'li', 'ul', 'pre', 'p');
     $blemRx = '(?:' . implode('|', $blockElements) . ')';
     $blemStartRx = '<' . $blemRx . '[^>]*(?<!\\/)>';
     // ignores self-closing
     $blemEndRx = '<\\/' . $blemRx . '[^>]*>';
     $blemBothRx = '<\\/?' . $blemRx . '[^>]*>';
     $debug = FALSE;
     $log = NULL;
     $log .= 'Starte mit Text: "' . $html . '"<br />' . "\n";
     $level = 0;
     $pOpen = FALSE;
     $matching = NULL;
     $ret = NULL;
     $firstP = $withPFirst;
     $x = 0;
     while ($html != '' && $x <= 100000000) {
         $x++;
         $log .= "level: " . $level . ":  ";
         /* $html abschneiden (schritt) */
         if (isset($matching)) {
             $html = mb_substr($html, mb_strlen($matching));
             $ret .= $matching;
             $matching = NULL;
         }
         /* normaler text */
         $match = array();
         if (Preg::match($html, '/^([^\\n<>]+)/', $match) > 0) {
             /* p öffnen, wenn es nicht offen ist */
             if ($level == 0 && !$pOpen) {
                 $pOpen = TRUE;
                 $log .= "open p<br />\n";
                 if ($firstP && mb_strlen(trim($ret)) == 0) {
                     $ret .= '<p class="first">';
                     $firstP = FALSE;
                 } else {
                     $ret .= '<p>';
                 }
             }
             $matching = $match[1];
             $log .= "text(" . mb_strlen($matching) . "): " . str_replace(array("\n", "\r"), array("-n-\n", "-r-\r"), $matching) . "<br />\n";
             continue;
         }
         /* absatz */
         $match = array();
         if (S::startsWith($html, "\n\n")) {
             $matching = "\n\n";
             if ($level == 0 && $pOpen) {
                 $log .= "Absatz (close p)<br />\n";
                 $pOpen = FALSE;
                 $ret .= '</p>';
                 //$ret .= "\n"; // da matching hinzugefügt wird
             }
             continue;
         }
         /* zeilenumbruch  */
         if (S::startsWith($html, "\n")) {
             $matching = "\n";
             $log .= "\\n gefunden<br />\n";
             /* wir machen ein <br /> aus dem \n, wenn wir im p modus sind */
             if ($pOpen) {
                 $ret .= '<br />';
                 $log .= "in br umwandeln<br />\n";
             }
             continue;
         }
         /* prüfen auf html tags (block start, block end, inline tag */
         $match = array();
         if (Preg::match($html, '/^<(\\/)?([^\\s>]+)((?>[^>])*)>/', $match) > 0) {
             list($full, $op, $tagName, $rest) = $match;
             if (in_array($tagName, $blockElements)) {
                 $matching = $full;
                 if ($op != '/') {
                     /* block element start */
                     if ($pOpen) {
                         $ret .= '</p>';
                         $log .= "close p<br />\n";
                         $pOpen = FALSE;
                     }
                     $log .= "block level(" . $level . ") start : '" . $matching . "'<br />\n";
                     $level++;
                 } else {
                     /* block element end */
                     $log .= "block level(" . $level . ") end: '" . $matching . "'<br />\n";
                     $level--;
                 }
             } else {
                 /* html tag (kein block element) */
                 $matching = $full;
                 /* p öffnen, wenn es nicht offen ist */
                 if ($level == 0 && !$pOpen) {
                     $pOpen = TRUE;
                     $log .= "open p<br />\n";
                     if ($firstP && mb_strlen(trim($ret)) == 0) {
                         $ret .= '<p class="first">';
                         $firstP = FALSE;
                     } else {
                         $ret .= '<p>';
                     }
                 }
                 $log .= "inline-tag: '" . $matching . "'<br />\n";
             }
             continue;
         }
         /* kein fall hat gegriffen, wir verkürzen um 1 Zeichen */
         $matching = HTML::esc(mb_substr($html, 0, 1));
         $log .= "zeichen: " . $matching . "<br />\n";
     }
     /* letztes <p> schließen */
     if ($pOpen) {
         $ret .= '</p>' . "\n";
     }
     if ($debug) {
         print $log;
     }
     return $ret;
 }
示例#12
0
 public function parseSummary()
 {
     if (!isset($this->summary) && mb_strlen($this->body) > 0) {
         $m = array();
         if (Preg::match($this->body, '/^\\s*(.+?)[\\n]{2}(.+)$/is', $m)) {
             $this->summary = $m[1];
             $this->body = $m[2];
         }
     }
     return $this;
 }
示例#13
0
文件: TPL.php 项目: pscheit/psc-cms
 public static function replaceLinksMarkup($text)
 {
     $link = function ($url, $label) {
         // label is already escaped
         if (Preg::match($url, '~^([a-zA-Z0-9]+://|www\\.)~')) {
             return HTML::tag('a', $label, array('href' => $url, 'class' => 'external', 'target' => '_blank'));
         } else {
             return HTML::tag('a', $label, array('href' => $url, 'class' => 'internal'));
         }
     };
     $openLink = preg_quote('[[');
     $closeLink = preg_quote(']]');
     $sepLink = preg_quote('|');
     // [[http://www.google.com|This Link points to google]]
     $text = \Psc\Preg::replace_callback($text, '/' . $openLink . '(.*?)' . $sepLink . '(.*?)' . $closeLink . '/', function ($match) use($link) {
         return $link($match[1], $match[2]);
     });
     // [[http://www.google.com]]
     $text = \Psc\Preg::replace_callback($text, '/' . $openLink . '(.*?)' . $closeLink . '/', function ($match) use($link) {
         return $link($match[1], $match[1]);
     });
     return $text;
 }
示例#14
0
 protected function buildQueryAutoCompleteTerm(array $fields, $term)
 {
     $qb = new QueryBuilder($this->_em);
     $qb->select('e')->from($this->_entityName, 'e');
     if (count($fields) > 0 && $term != "") {
         // term in quotes bedeutet wörtliche suche
         if (\Psc\Preg::match($term, '/^\\s*("|\')(.*)("|\')\\s*$/', $m)) {
             $term = $m[2];
             foreach ($fields as $field) {
                 $qb->orWhere('e.' . $field . ' = ?1 ');
             }
             $qb->setParameter(1, $term);
         } else {
             /* normale suche */
             foreach ($fields as $field) {
                 $qb->orWhere('e.' . $field . ' = ?1 ');
                 for ($i = 2; $i <= 4; $i++) {
                     $qb->orWhere('e.' . $field . ' LIKE ?' . $i);
                 }
             }
             $qb->setParameter(1, $term);
             $qb->setParameter(2, '%' . $term);
             $qb->setParameter(3, '%' . $term . '%');
             $qb->setParameter(4, $term . '%');
         }
     }
     return $qb;
 }
示例#15
0
 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);
         }
     }
 }
示例#16
0
文件: Lexer.php 项目: pscheit/psc-cms
 /**
  * 
  * @param string $source der PHP Code als String
  */
 protected function scan($source)
 {
     $source = str_replace(array("\r\n", "\r"), "\n", $source);
     if ($this->eol != "\n") {
         $source = str_replace("\n", $this->eol, $source);
     }
     /* token get all ist php intern */
     $currentLine = 1;
     foreach (token_get_all($source) as $token) {
         if (is_string($token)) {
             switch ($token) {
                 default:
                     $type = self::LITERAL;
                     break;
                 case ',':
                     $type = self::T_COMMA;
                     break;
                 case '.':
                     $type = self::T_DOT;
                     break;
                 case '{':
                     $type = self::T_CBRACE_OPEN;
                     break;
                 case '}':
                     $type = self::T_CBRACE_CLOSE;
                     break;
                 case '(':
                     $type = self::T_BRACE_OPEN;
                     break;
                 case ')':
                     $type = self::T_BRACE_CLOSE;
                     break;
                 case '=':
                     $type = self::T_EQUAL;
                     break;
                 case '&':
                     $type = self::T_AMPERSAND;
                     break;
                 case ';':
                     $type = self::T_SEMICOLON;
                     break;
                 case '+':
                     $type = self::T_PLUS;
                     break;
                 case '-':
                     $type = self::T_MINUS;
                     break;
             }
             $t = array('value' => $token, 'type' => $type, 'line' => $currentLine);
         } else {
             $t = array('value' => $token[1], 'type' => token_name($token[0]), 'line' => $token[2]);
             /* fix */
             if ($t['type'] == 'T_DOUBLE_COLON') {
                 $t['type'] = 'T_PAAMAYIM_NEKUDOTAYIM';
             }
             $currentLine = $t['line'];
         }
         /* whitespace analyisieren */
         if ($t['type'] == 'T_WHITESPACE' && $this->parseWhitespace) {
             Preg::match($t['value'], '/([^\\n]+|\\n)/g', $matches);
             foreach ($matches as $m) {
                 // das geht kaputt mit $this->eol anders als "\n"
                 list($NULL, $white) = $m;
                 if ($white === "\n") {
                     $currentLine++;
                     $type = self::T_EOL;
                 } else {
                     $type = self::T_PLAIN_WHITESPACE;
                 }
                 $this->tokens[] = array('value' => $white, 'type' => $type, 'line' => $currentLine);
             }
         } elseif ($t['type'] == 'T_COMMENT' && $this->parseWhitespace) {
             // EOL abschneiden und als einzelnes T_EOL dahinter machen
             if (S::endsWith($t['value'], $this->eol)) {
                 $t['value'] = mb_substr($t['value'], 0, -1);
                 $this->tokens[] = $t;
                 // comment hinzufügen
                 $currentLine++;
                 $this->tokens[] = array('value' => "\n", 'type' => self::T_EOL, 'line' => $currentLine);
             } else {
                 $this->tokens[] = $t;
                 // comment hinzufügen, auch wenn er kein EOL hata
             }
         } else {
             if (trim($t['value']) == '' && mb_strpos($t['value'], $this->eol) !== FALSE) {
                 // leer und mit umbruch
                 $currentLine += mb_substr_count($t['value'], $this->eol);
             }
             $this->tokens[] = $t;
         }
     }
     return $this;
 }
示例#17
0
 public function routeController(ServiceRequest $request)
 {
     $r = $this->initRequestMatcher($request);
     $controller = $r->qmatchiRx('/^(tpl|excel|images|uploads|persona)$/i');
     if ($controller === 'tpl') {
         $x = 0;
         $tpl = array();
         while (!$r->isEmpty() && $x <= 10) {
             $tpl[] = $r->qmatchRx('/^([-a-zA-Z0-9_.]+)$/');
             $x++;
         }
         $controller = new TPLController($this->project);
         return array($controller, 'get', array($tpl));
     } elseif ($controller === 'excel') {
         $controller = new ExcelController($this->project);
         if ($request->getType() === Service::POST) {
             $body = $request->getBody();
             if ($r->part() === 'convert') {
                 // importieren
                 // im body können dann options stehen oder sowas
                 // der controller holt sich die excelFile selbst
                 return array($controller, 'convert', array(is_object($body) ? $body : new \stdClass()));
             } else {
                 // exportieren
                 return array($controller, 'create', array($body, $r->part()));
                 // nächste ist filename ohne endung
             }
         }
     } elseif ($controller === 'images') {
         $controller = new ImageController(ImageManager::createForProject($this->project, $this->getDoctrinePackage()->getEntityManager(), $this->getDoctrinePackage()->getModule()->getEntityName('Image')));
         if ($r->isEmpty() && $request->getType() === Service::POST && $request->hasFiles()) {
             // nimmt nur eine file, weil moep
             return array($controller, 'insertImageFile', array(current($request->getFiles()), $request->getBody()));
         } else {
             $method = 'getImage';
             $cacheAdapters = array('thumbnail');
             $params = array($r->qmatchiRX('/([a-z0-9]+)/'));
             // id or hash
             // filename immer am ende und optional
             $filename = NULL;
             if (\Psc\Preg::match($r->getLastPart(), '/[a-z0-9]+\\.[a-z0-9]+/i')) {
                 $filename = $r->pop();
             }
             /* gucken ob es eine Version des Images werden soll */
             if (in_array($r->part(), $cacheAdapters)) {
                 $method = 'getImageVersion';
                 $params[] = $r->matchNES();
                 // type
                 $params[] = $r->getLeftParts();
                 // parameter für den cache adapter
             }
             if ($filename) {
                 $params[] = $filename;
             }
             return array($controller, $method, $params);
         }
     } elseif ($controller === 'uploads') {
         $controller = new FileUploadController(UploadManager::createForProject($this->project, $this->dc));
         $this->log('upload-request method: ' . $request->getType());
         $this->log('  has files: ' . ($request->hasFiles() ? 'true' : 'false'), 1);
         if ($r->isEmpty() && $request->getType() === Service::POST && $request->hasFiles()) {
             // nimmt nur eine file, weil moep
             return array($controller, 'insertFile', array(current($request->getFiles()), $request->getBody()));
         } elseif ($r->isEmpty() && $request->getType() === Service::GET) {
             $params = array();
             // criterias
             $params[] = array();
             $params[] = $r->matchOrderBy($r->qVar('orderby'), array('name' => 'originalName'));
             return array($controller, 'getFiles', $params);
         } else {
             $method = 'getFile';
             $params = array($r->qmatchiRX('/([a-z0-9]+)/'));
             // id or hash
             // filename immer am ende und optional
             $filename = NULL;
             try {
                 if (\Psc\Preg::match($r->getLastPart(), '/^(.+)\\.(.+)$/')) {
                     $filename = $r->pop();
                 }
             } catch (\Webforge\Common\Exception $e) {
                 if (mb_strpos('.', $r->getLastPart()) !== FALSE) {
                     $filename = \Webforge\Common\System\File::safeName($r->pop());
                     $filename = Preg::replace($filename, '/_+/', '_');
                 }
             }
             if ($filename) {
                 $params[] = $filename;
             }
             return array($controller, $method, $params);
         }
     } elseif ($controller === 'persona') {
         $controller = new \Webforge\Persona\Controller();
         return array($controller, 'verify', array($r->bvar('assertion')));
     }
     throw HTTPException::NotFound('Die Resource für cms ' . $request . ' existiert nicht.');
 }