С версии: 2.2.0
Автор: Henry Ruhs
Автор: Sven Weingartner
Наследование: implements Redaxscript\Validator\ValidatorInterface
Пример #1
0
 /**
  * testAlias
  *
  * @since 2.2.0
  *
  * @param string $alias
  * @param integer $mode
  * @param integer $expect
  *
  * @dataProvider providerValidatorAlias
  */
 public function testAlias($alias = null, $mode = null, $expect = null)
 {
     /* setup */
     $validator = new Validator\Alias();
     /* result */
     $result = $validator->validate($alias, $mode);
     /* compare */
     $this->assertEquals($expect, $result);
 }
Пример #2
0
 /**
  * parse the readmore tag
  *
  * @since 2.0.0
  *
  * @param string $input content be parsed
  *
  * @return string
  */
 protected function _parseReadmore($input = null)
 {
     $aliasValidator = new Validator\Alias();
     $linkElement = new Element('a');
     /* collect output */
     $output = str_replace($this->_tags['readmore']['search'], '', $input);
     if ($this->_registry->get('lastTable') === 'categories' || !$this->_registry->get('fullRoute') || $aliasValidator->validate($this->_registry->get('firstParameter'), Validator\Alias::MODE_DEFAULT) === Validator\ValidatorInterface::PASSED) {
         $output = substr($output, 0, $this->_tags['readmore']['position']);
         /* add link element */
         if ($this->_route) {
             $output .= $linkElement->attr(array('href' => $this->_registry->get('rewriteRoute') . $this->_route, 'class' => $this->_options['className']['readmore'], 'title' => $this->_language->get('readmore')))->text($this->_language->get('readmore'));
         }
     }
     return $output;
 }
Пример #3
0
 /**
  * build the breadcrumb array
  *
  * @since 2.1.0
  *
  * @param integer $key key of the item
  */
 private function _build($key = 0)
 {
     $aliasValidator = new Validator\Alias();
     /* if title constant */
     if ($this->_registry->get('title')) {
         $this->_breadcrumbArray[$key]['title'] = $this->_registry->get('title');
     } else {
         if (!$this->_registry->get('fullRoute')) {
             $this->_breadcrumbArray[$key]['title'] = $this->_language->get('home');
         } else {
             if ($this->_registry->get('firstParameter') === 'admin') {
                 $this->_buildAdmin($key);
             } else {
                 if ($aliasValidator->validate($this->_registry->get('firstParameter'), Validator\Alias::MODE_DEFAULT) === Validator\Validator::PASSED) {
                     /* join default title */
                     if ($this->_registry->get('firstParameter') && $this->_language->get($this->_registry->get('firstParameter'))) {
                         $this->_breadcrumbArray[$key]['title'] = $this->_language->get($this->_registry->get('firstParameter'));
                     }
                 } else {
                     if (!$this->_registry->get('lastId')) {
                         $this->_breadcrumbArray[$key]['title'] = $this->_language->get('error');
                     } else {
                         if ($this->_registry->get('firstTable')) {
                             $this->_buildContent($key);
                         }
                     }
                 }
             }
         }
     }
 }
Пример #4
0
 /**
  * parse the break tag
  *
  * @since 2.0.0
  *
  * @param string $input content be parsed
  *
  * @return string
  */
 protected function _parseBreak($input = null)
 {
     $aliasValidator = new Validator\Alias();
     /* collect output */
     $output = str_replace('<break>', '', $input);
     if ($this->_registry->get('lastTable') === 'categories' || !$this->_registry->get('fullRoute') || $aliasValidator->validate($this->_registry->get('firstParameter'), Validator\Alias::MODE_DEFAULT) === Validator\Validator::PASSED) {
         $output = substr($output, 0, $this->_tags['break']['position']);
         /* add read more */
         if ($this->_route) {
             $output .= '<a href="' . $this->_registry->get('rewriteRoute') . $this->_route . '" class="' . $this->_options['className']['break'] . '" title="' . $this->_language->get('read_more') . '">' . $this->_language->get('read_more') . '</a>';
         }
     }
     return $output;
 }
Пример #5
0
 /**
  * build the breadcrumb array
  *
  * @since 2.1.0
  *
  * @param integer $key key of the item
  */
 protected function _build($key = 0)
 {
     $aliasValidator = new Validator\Alias();
     $title = $this->_registry->get('title');
     $firstParameter = $this->_registry->get('firstParameter');
     $firstTable = $this->_registry->get('firstTable');
     $fullRoute = $this->_registry->get('fullRoute');
     $lastId = $this->_registry->get('lastId');
     /* if title */
     if ($title) {
         $this->_breadcrumbArray[$key]['title'] = $title;
     } else {
         if (!$fullRoute) {
             $this->_breadcrumbArray[$key]['title'] = $this->_language->get('home');
         } else {
             if ($firstParameter === 'admin') {
                 $this->_buildAdmin($key);
             } else {
                 if ($aliasValidator->validate($firstParameter, Validator\Alias::MODE_DEFAULT) === Validator\ValidatorInterface::PASSED) {
                     /* join default title */
                     if ($firstParameter && $this->_language->get($firstParameter)) {
                         $this->_breadcrumbArray[$key]['title'] = $this->_language->get($firstParameter);
                     }
                 } else {
                     if (!$lastId) {
                         $this->_breadcrumbArray[$key]['title'] = $this->_language->get('error');
                     } else {
                         if ($firstTable) {
                             $this->_buildContent($key);
                         }
                     }
                 }
             }
         }
     }
 }