/** * render * * @since 2.2.0 * * @param array $options * * @return string */ public static function render($options = array()) { $output = null; $counter = 0; $log = self::_log(); /* html elements */ $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', array('class' => self::$_config['className']['list'])); /* 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->html($output); } return $output; }
/** * render * * @since 3.0.0 * * @param string $url * @param array $optionArray * * @return string */ public static function render($url = null, $optionArray = []) { $counter = 0; $output = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', ['class' => self::$_configArray['className']['title']]); $linkElement = new Html\Element(); $linkElement->init('a', ['target' => '_blank']); $boxElement = new Html\Element(); $boxElement->init('div', ['class' => self::$_configArray['className']['box']]); /* load result */ $reader = new Reader(); $result = $reader->loadXML($url)->getObject(); $result = $result->entry ? $result->entry : $result->channel->item; /* process result */ if ($result) { foreach ($result as $value) { if ($counter++ < $optionArray['limit']) { $linkElement->attr('href', $value->link->attributes()->href ? $value->link->attributes()->href : $value->link)->text($value->title); /* collect output */ $output .= $titleElement->html($linkElement) . $boxElement->text($value->summary ? $value->summary : $value->description); } } } else { self::setNotification('error', Language::get('url_incorrect') . Language::get('point')); } return $output; }
/** * render * * @since 2.2.0 * * @return string */ public static function render() { $output = null; $outputItem = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', array('class' => self::$_config['className']['title'])); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('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 (!$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 = null; } $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 = null; } $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; }
/** * render * * @since 2.2.0 * * @return string */ public static function render() { $output = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', ['class' => self::$_configArray['className']['title']]); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => self::$_configArray['className']['list']]); /* query articles */ $articles = Db::forTablePrefix('articles')->where('status', 1)->whereLanguageIs(Registry::get('language'))->orderByDesc('date')->findMany(); /* process articles */ if (!$articles) { $error = Language::get('article_no') . Language::get('point'); } else { $accessValidator = new Validator\Access(); $accessDeny = 0; $lastDate = 0; foreach ($articles as $value) { if ($accessValidator->validate($value->access, Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) { $month = date('n', strtotime($value->date)); $year = date('Y', strtotime($value->date)); $currentDate = $month + $year; /* collect output */ if ($lastDate != $currentDate) { $output .= $titleElement->text(Language::get($month - 1, '_month') . ' ' . $year); } $lastDate = $currentDate; /* collect item output */ $outputItem = '<li>'; $outputItem .= $linkElement->attr(['href' => Registry::get('parameterRoute') . build_route('articles', $value->id), 'title' => $value->description ? $value->description : $value->title])->text($value->title); $outputItem .= '</li>'; /* collect list output */ $output .= $listElement->html($outputItem); } 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; }
/** * render * * @since 2.2.0 * * @param string $url * * @return string */ public static function render($url = null) { $output = null; if ($url) { /* html elements */ $linkElement = new Html\Element(); $linkElement->init('a', ['target' => '_blank']); $listElement = new Html\Element(); $listElement->init('ul', ['class' => self::$_configArray['className']['list']]); /* process network */ foreach (self::$_configArray['network'] as $key => $value) { $output .= '<li>'; $output .= $linkElement->attr(['class' => self::$_configArray['className']['link'] . ' ' . $value['className'], 'data-height' => $value['height'], 'data-type' => $key, 'data-width' => $value['width'], 'href' => $value['url'] . $url])->text($key); $output .= '</li>'; } /* collect list output */ if ($output) { $output = $listElement->html($output); } } return $output; }
/** * render the view * * @since 3.0.0 * * @param array $resultArray array for the result * * @return string */ public function render($resultArray = []) { $output = Hook::trigger('resultListStart'); $accessValidator = new Validator\Access(); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-result']); $listElement = new Html\Element(); $listElement->init('ol', ['class' => 'rs-list-result']); $itemElement = new Html\Element(); $itemElement->init('li'); $linkElement = new Html\Element(); $linkElement->init('a', ['class' => 'rs-link-result']); $textElement = new Html\Element(); $textElement->init('span', ['class' => 'rs-text-result-date']); /* process result */ foreach ($resultArray as $table => $result) { $outputItem = null; if ($result) { /* collect item output */ foreach ($result as $value) { if ($accessValidator->validate($result->access, $this->_registry->get('myGroups')) === Validator\ValidatorInterface::PASSED) { $textDate = date(Db::getSetting('date'), strtotime($value->date)); $linkElement->attr('href', $this->_registry->get('parameterRoute') . build_route($table, $value->id))->text($value->title ? $value->title : $value->author); $textElement->text($textDate); $outputItem .= $itemElement->html($linkElement . $textElement); } } /* collect output */ if ($outputItem) { $titleElement->text($this->_language->get($table)); $listElement->html($outputItem); $output .= $titleElement . $listElement; } } } $output .= Hook::trigger('resultListEnd'); return $output; }
/** * render * * @since 2.3.0 * * @param string $url * @param array $options * * @return string */ public static function render($url = null, $options = array()) { $output = null; $counter = 0; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', array('class' => self::$_config['className']['title'])); $linkElement = new Html\Element(); $linkElement->init('a', array('target' => '_blank')); $boxElement = new Html\Element(); $boxElement->init('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; }
/** * renderParent * * @param string $rootDirectory * @param string $parentDirectory * @param array $optionArray * * @return string */ protected static function _renderParent($rootDirectory = null, $parentDirectory = null, $optionArray = []) { $outputItem = null; $queryString = $rootDirectory !== $parentDirectory ? '&directory=' . $parentDirectory : null; /* html elements */ $linkElement = new Html\Element(); $linkElement->init('a', ['class' => self::$_configArray['className']['link']]); /* collect item output */ $outputItem .= '<li>'; $outputItem .= $linkElement->attr(['href' => Registry::get('parameterRoute') . Registry::get('fullRoute') . $queryString . $optionArray['hash'], 'title' => Language::get('directory_parent', '_directory_lister')])->addClass(self::$_configArray['className']['types']['directoryParent'])->text(Language::get('directory_parent', '_directory_lister')); $outputItem .= '</li>'; return $outputItem; }
/** * testAttr * * @since 2.2.0 * * @param array $attribute * @param string $expect * * @dataProvider providerAttr */ public function testAttr($attribute = array(), $expect = null) { /* setup */ $element = new Html\Element(); $element->init('a'); /* actual */ $actual = $element->attr($attribute[0], $attribute[1])->removeAttr($attribute[2])->render(); /* compare */ $this->assertEquals($expect, $actual); }
/** * render * * @since 2.6.0 * * @param string $directory * @param array $options * * @return string */ public static function render($directory = null, $options = null) { $output = null; $outputItem = null; /* html elements */ $imageElement = new Html\Element(); $imageElement->init('img', array('class' => self::$_config['className']['image'])); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', array('class' => self::$_config['className']['list'])); /* gallery directory */ $galleryDirectory = new Directory(); $galleryDirectory->init($directory, self::$_config['thumbDirectory']); $galleryDirectoryArray = $galleryDirectory->getArray(); /* adjust order */ if ($options['order'] === 'desc') { $galleryDirectoryArray = array_reverse($galleryDirectoryArray); } /* gallery data */ $galleryCounter = 0; $galleryTotal = count($galleryDirectoryArray); $galleryId = uniqid('gallery-'); /* remove thumbs */ if ($options['command'] === 'remove' || !$galleryTotal) { $galleryDirectory->remove(self::$_config['thumbDirectory']); } else { /* process directory */ foreach ($galleryDirectoryArray as $key => $value) { $imagePath = $directory . '/' . $value; $thumbPath = $directory . '/' . self::$_config['thumbDirectory'] . '/' . $value; /* create thumbs */ if ($options['command'] === 'create' || !is_file($thumbPath)) { self::_createThumb($value, $directory, $options); } /* image data */ $imageData = self::_getImageData($imagePath); /* collect item output */ $outputItem .= '<li>'; $outputItem .= $linkElement->copy()->attr(array('href' => $imagePath, 'data-counter' => ++$galleryCounter, 'data-total' => $galleryTotal, 'data-id' => $galleryId, 'data-artist' => array_key_exists('artist', $imageData) ? $imageData['artist'] : null, 'data-date' => array_key_exists('date', $imageData) ? $imageData['date'] : null, 'data-description' => array_key_exists('description', $imageData) ? $imageData['description'] : null))->html($imageElement->copy()->attr(array('src' => $thumbPath, 'alt' => array_key_exists('description', $imageData) ? $imageData['description'] : null))); $outputItem .= '</li>'; } $output = $listElement->attr('id', $galleryId)->html($outputItem); } return $output; }
/** * render the breadcrumb trail as an unordered list * * @since 2.1.0 * * @return string */ public function render() { $output = Hook::trigger('breadcrumbStart'); $outputItem = null; /* breadcrumb keys */ $breadcrumbKeys = array_keys($this->_breadcrumbArray); $lastKey = end($breadcrumbKeys); /* html elements */ $linkElement = new Html\Element(); $linkElement->init('a'); $itemElement = new Html\Element(); $itemElement->init('li'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => $this->_optionArray['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>'; /* create a link */ if ($route) { $outputItem .= $linkElement->attr('href', $this->_registry->get('parameterRoute') . $route)->text($title); } else { $outputItem .= $title; } $outputItem .= '</li>'; /* add divider */ if ($key !== $lastKey) { $outputItem .= $itemElement->addClass($this->_optionArray['className']['divider'])->text($this->_optionArray['divider']); } } } /* collect list output */ if ($outputItem) { $output = $listElement->html($outputItem); } $output .= Hook::trigger('breadcrumbEnd'); return $output; }