Exemplo n.º 1
0
 /**
  * render
  *
  * @since 2.3.0
  *
  * @param string $url
  * @param array $options
  *
  * @return string
  */
 public static function render($url = null, $options = array())
 {
     $output = '';
     $counter = 0;
     /* html elements */
     $titleElement = new Element('h3', array('class' => self::$_config['className']['title']));
     $linkElement = new Element('a', array('target' => '_blank'));
     $boxElement = new Element('div', array('class' => self::$_config['className']['box']));
     /* get contents */
     $contents = file_get_contents($url);
     if ($contents) {
         $feed = new SimpleXMLElement($contents);
         $result = $feed->entry ? $feed->entry : $feed->channel->item;
         /* process result */
         foreach ($result as $value) {
             /* break if limit reached */
             if (++$counter > $options['limit']) {
                 break;
             }
             /* handle feed type */
             $url = $value->link['href'] ? (string) $value->link['href'] : (string) $value->link;
             $text = $value->summary ? $value->summary : $value->description;
             /* url */
             if ($url) {
                 $linkElement->attr('href', $url)->text($value->title);
             } else {
                 $linkElement = $value->title;
             }
             /* collect output */
             $output .= $titleElement->html($linkElement) . $boxElement->text($text);
         }
     }
     return $output;
 }
Exemplo n.º 2
0
 /**
  * render
  *
  * @since 2.2.0
  *
  * @param integer $lat
  * @param integer $lng
  * @param integer $zoom
  *
  * @return string
  */
 public static function render($lat = 0, $lng = 0, $zoom = 0)
 {
     $mapElement = new Element('div', array('class' => self::$_config['className']));
     /* collect attributes */
     if (is_numeric($lat)) {
         $mapElement->attr('data-lat', $lat);
     }
     if (is_numeric($lng)) {
         $mapElement->attr('data-lng', $lng);
     }
     if (is_numeric($zoom)) {
         $mapElement->attr('data-zoom', $zoom);
     }
     $output = $mapElement;
     return $output;
 }
Exemplo n.º 3
0
 /**
  * render
  *
  * @since 2.2.0
  *
  * @return string
  */
 public static function render()
 {
     $output = '';
     $outputItem = '';
     /* html elements */
     $titleElement = new Element('h3', array('class' => self::$_config['className']['title']));
     $linkElement = new Element('a');
     $listElement = new Element('ul', array('class' => self::$_config['className']['list']));
     /* fetch articles */
     $articles = Db::forTablePrefix('articles')->where('status', 1)->whereIn('language', array(Registry::get('language'), ''))->orderByDesc('category')->findArray();
     /* process articles */
     if (empty($articles)) {
         $error = Language::get('article_no') . Language::get('point');
     } else {
         $accessValidator = new Validator\Access();
         $accessDeny = 0;
         $lastCategory = 0;
         foreach ($articles as $value) {
             if ($accessValidator->validate($value['access'], Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) {
                 $currentCategory = $value['category'];
                 /* collect output */
                 if ($lastCategory != $currentCategory) {
                     if ($lastCategory > 0) {
                         $output .= $listElement->html($outputItem);
                         $outputItem = '';
                     }
                     $output .= $titleElement->text($currentCategory < 1 ? Language::get('uncategorized') : Db::forTablePrefix('categories')->whereIdIs($currentCategory)->findOne()->title);
                 }
                 /* collect item output */
                 $outputItem .= '<li>';
                 $outputItem .= $linkElement->attr(array('href' => $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']), 'title' => $value['description'] ? $value['description'] : $value['title']))->text($value['title']);
                 $outputItem .= '</li>';
                 /* collect list output */
                 if (end($articles) === $value) {
                     $output .= $listElement->html($outputItem);
                     $outputItem = '';
                 }
                 $lastCategory = $currentCategory;
             } else {
                 $accessDeny++;
             }
         }
         /* handle access */
         if (count($articles) === $accessDeny) {
             $error = Language::get('access_no') . Language::get('point');
         }
     }
     /* handle error */
     if ($error) {
         $output = $listElement->html('<li>' . $error . '</li>');
     }
     return $output;
 }
Exemplo n.º 4
0
 /**
  * render
  *
  * @since 2.2.0
  *
  * @param string $url
  *
  * @return string
  */
 public static function render($url = null)
 {
     $output = '';
     if ($url) {
         /* html elements */
         $linkElement = new Element('a', array('target' => '_blank'));
         $listElement = new Element('ul', array('class' => self::$_config['className']['list']));
         /* process network */
         foreach (self::$_config['network'] as $key => $value) {
             $output .= '<li>';
             $output .= $linkElement->attr(array('href' => $value['url'] . $url, 'class' => self::$_config['className']['link'] . ' ' . $value['className'], 'data-type' => $key, 'data-height' => $value['height'], 'data-width' => $value['width']))->text($key);
             $output .= '</li>';
         }
         /* collect list output */
         if ($output) {
             $output = $listElement->html($output);
         }
     }
     return $output;
 }
Exemplo n.º 5
0
 /**
  * render
  *
  * @since 2.2.0
  *
  * @param array $options
  *
  * @return string
  */
 public static function render($options = array())
 {
     $output = '';
     $counter = 0;
     $log = self::_log();
     /* html elements */
     $linkElement = new Element('a');
     $listElement = new Element('ul');
     /* process log */
     foreach ($log as $value) {
         /* break if limit reached */
         if (++$counter > $options['limit']) {
             break;
         }
         $output .= '<li>';
         $output .= $linkElement->attr(array('href' => Registry::get('rewriteRoute') . $value, 'title' => $value))->text($value);
         $output .= '</li>';
     }
     /* collect list output */
     if ($output) {
         $output = $listElement->attr('class', self::$_config['className']['list'])->html($output);
     }
     return $output;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 /**
  * testAttr
  *
  * @since 2.2.0
  *
  * @param array $attribute
  * @param string $expect
  *
  * @dataProvider providerAttr
  */
 public function testAttr($attribute = array(), $expect = null)
 {
     /* setup */
     $element = new Element('a');
     /* actual */
     $actual = $element->attr($attribute[0], $attribute[1])->removeAttr($attribute[2])->render();
     /* compare */
     $this->assertEquals($expect, $actual);
 }
Exemplo n.º 8
0
 /**
  * render the breadcrumb trail as an unordered list
  *
  * @since 2.1.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('breadcrumb_start');
     $outputItem = '';
     /* breadcrumb keys */
     $breadcrumbKeys = array_keys($this->_breadcrumbArray);
     $lastKey = end($breadcrumbKeys);
     /* html elements */
     $linkElement = new Element('a');
     $itemElement = new Element('li');
     $listElement = new Element('ul', array('class' => $this->_options['className']['list']));
     /* collect item output */
     foreach ($this->_breadcrumbArray as $key => $value) {
         $title = array_key_exists('title', $value) ? $value['title'] : null;
         $route = array_key_exists('route', $value) ? $value['route'] : null;
         if ($title) {
             $outputItem .= '<li>';
             /* build link if route */
             if ($route) {
                 $outputItem .= $linkElement->attr(array('href' => $this->_registry->get('rewriteRoute') . $route, 'title' => $title))->text($title);
             } else {
                 $outputItem .= $title;
             }
             $outputItem .= '</li>';
             /* add divider */
             if ($key !== $lastKey) {
                 $outputItem .= $itemElement->addClass($this->_options['className']['divider'])->text(Db::getSettings('divider'));
             }
         }
     }
     /* collect list output */
     if ($outputItem) {
         $output = $listElement->html($outputItem);
     }
     $output .= Hook::trigger('breadcrumb_end');
     return $output;
 }