/** * 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 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 3.0.0 * * @param string $directory * @param array $optionArray * * @return string */ public static function render($directory = null, $optionArray = []) { $output = null; $outputItem = null; /* html elements */ $listElement = new Html\Element(); $listElement->init('ul', ['class' => self::$_configArray['className']['list']]); /* has directory */ if (is_dir($directory)) { /* remove as needed */ if ($optionArray['command'] === 'remove') { self::_removeThumb($directory); } /* create as needed */ if ($optionArray['command'] === 'create' || !is_dir($directory . '/' . self::$_configArray['thumbDirectory'])) { self::_createThumb($directory, $optionArray); } $outputItem .= self::_renderItem($directory, $optionArray); /* collect list output */ if ($outputItem) { $output = $listElement->html($outputItem); } } else { self::setNotification('error', Language::get('directory_not_found') . Language::get('colon') . ' ' . $directory . Language::get('point')); } return $output; }
/** * render * * @since 2.2.0 * * @param mixed $src * @param array $options * * @return string */ public static function render($src = null, $options = array()) { $output = null; /* device related images */ if (is_array($src)) { /* process source */ foreach ($src as $key => $value) { if (in_array($key, self::$_config['device']) && Registry::get('my' . ucfirst($key))) { $src = $value; } } } /* collect output */ if (file_exists($src)) { $imageElement = new Html\Element(); $imageElement->init('img', array('alt' => $options['alt'], 'class' => self::$_config['className']['image'] . ' ' . $options['className'], 'src' => self::$_config['placeholder'])); /* collect output */ $output = $imageElement->copy()->attr('data-src', $src); /* placeholder */ if (self::$_config['placeholder']) { /* calculate image ratio */ $imageDimensions = getimagesize($src); $imageRatio = $imageDimensions[1] / $imageDimensions[0] * 100; /* placeholder */ $placeholderElement = new Html\Element(); $placeholderElement->init('div', array('class' => self::$_config['className']['placeholder'], 'style' => 'padding-bottom:' . $imageRatio . '%')); /* collect output */ $output = $placeholderElement->html($output); } /* noscript fallback */ $output .= '<noscript>' . $imageElement . '</noscript>'; } return $output; }
/** * testHtml * * @since 2.6.0 * * @param string $html * @param string $expect * * @dataProvider providerHtml */ public function testHtml($html = null, $expect = null) { /* setup */ $element = new Html\Element(); $element->init('a'); /* actual */ $actual = $element->html($html); /* compare */ $this->assertEquals($expect, $actual); }
/** * 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; }
/** * render * * @since 2.6.0 * * @param string $directory * @param array $options * * @return string */ public static function render($directory = null, $options = null) { $output = null; $outputDirectory = null; $outputFile = null; /* hash option */ if ($options['hash']) { $hashString = '#' . $options['hash']; } /* handle query */ $directoryQuery = Request::getQuery('d'); if ($directoryQuery && $directory !== $directoryQuery) { $pathFilter = new Filter\Path(); $directory = $pathFilter->sanitize($directoryQuery); $parentDirectory = $pathFilter->sanitize(dirname($directory)); } /* has directory */ if (is_dir($directory)) { /* html elements */ $linkElement = new Html\Element(); $linkElement->init('a', array('class' => self::$_config['className']['link'])); $textSizeElement = new Html\Element(); $textSizeElement->init('span', array('class' => self::$_config['className']['textSize'])); $textDateElement = new Html\Element(); $textDateElement->init('span', array('class' => self::$_config['className']['textDate'])); $listElement = new Html\Element(); $listElement->init('ul', array('class' => self::$_config['className']['list'])); /* list directory object */ $listDirectory = new Directory(); $listDirectory->init($directory); $listDirectoryArray = $listDirectory->getArray(); /* date format */ $dateFormat = Db::getSettings('date'); /* parent directory */ if (is_dir($parentDirectory)) { $outputDirectory .= '<li>'; $outputDirectory .= $linkElement->copy()->attr(array('href' => Registry::get('rewriteRoute') . Registry::get('fullRoute') . '&d=' . $parentDirectory . $hashString, 'title' => Language::get('directory_parent', '_directory_lister')))->addClass(self::$_config['className']['types']['directoryParent'])->text(Language::get('directory_parent', '_directory_lister')); $outputDirectory .= '</li>'; } /* process directory */ foreach ($listDirectoryArray as $key => $value) { $path = $directory . '/' . $value; $fileExtension = pathinfo($path, PATHINFO_EXTENSION); $text = $value; /* replace option */ if ($options['replace']) { foreach ($options['replace'] as $replaceKey => $replaceValue) { if ($replaceKey === self::$_config['replaceKey']['extension']) { $replaceKey = $fileExtension; } $text = str_replace($replaceKey, $replaceValue, $text); } } /* handle directory */ if (is_dir($path)) { $outputDirectory .= '<li>'; $outputDirectory .= $linkElement->copy()->attr(array('href' => Registry::get('rewriteRoute') . Registry::get('fullRoute') . '&d=' . $path . $hashString, 'title' => Language::get('directory', '_directory_lister')))->addClass(self::$_config['className']['types']['directory'])->text($text); $outputDirectory .= $textSizeElement->copy(); $outputDirectory .= $textDateElement->copy()->text(date($dateFormat, filectime($path))); $outputDirectory .= '</li>'; } else { if (is_file($path)) { if (array_key_exists($fileExtension, self::$_config['extension'])) { $fileType = self::$_config['extension'][$fileExtension]; $outputFile .= '<li>'; $outputFile .= $linkElement->copy()->attr(array('href' => $path, 'target' => '_blank', 'title' => Language::get('file', '_directory_lister')))->addClass(self::$_config['className']['types'][$fileType])->text($text); $outputFile .= $textSizeElement->copy()->attr('data-unit', self::$_config['size']['unit'])->html(ceil(filesize($path) / self::$_config['size']['divider'])); $outputFile .= $textDateElement->copy()->html(date($dateFormat, filectime($path))); $outputFile .= '</li>'; } } } } /* collect list output */ if ($outputDirectory || $outputFile) { $output = $listElement->html($outputDirectory . $outputFile); } } return $output; }
/** * render * * @since 2.6.0 * * @param string $directory * @param array $optionArray * * @return string */ public static function render($directory = null, $optionArray = []) { $output = null; $outputItem = null; /* html elements */ $listElement = new Html\Element(); $listElement->init('ul', ['class' => self::$_configArray['className']['list']]); /* handle option */ if ($optionArray['hash']) { $optionArray['hash'] = '#' . $optionArray['hash']; } /* handle query */ $directoryQuery = Request::getQuery('directory'); $directoryQueryArray = explode('/', $directoryQuery); /* parent directory */ if ($directoryQueryArray[0] === $directory && $directory !== $directoryQuery) { $pathFilter = new Filter\Path(); $rootDirectory = $directory; $directory = $pathFilter->sanitize($directoryQuery); $parentDirectory = $pathFilter->sanitize(dirname($directory)); $outputItem .= self::_renderParent($rootDirectory, $parentDirectory, $optionArray); } /* has directory */ if (is_dir($directory)) { $outputItem .= self::_renderItem($directory, $optionArray); /* collect list output */ if ($outputItem) { $output = $listElement->html($outputItem); } } else { self::setNotification('error', Language::get('directory_not_found') . Language::get('colon') . ' ' . $directory . Language::get('point')); } return $output; }
/** * render the form * * @since 2.6.0 * * @return string */ public function render() { $output = Hook::trigger('form_start'); $formElement = new Element(); $formElement->init('form', $this->_attributeArray['form']); /* collect output */ $output .= $formElement->html($this->_html); $output .= Hook::trigger('form_end'); 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; }
/** * render * * @since 2.2.0 * * @param string $alias * @param string $path * * @return string */ public static function render($alias = null, $path = null) { $titleElement = new Html\Element(); $titleElement->init('h2', array('class' => 'title_content', 'title' => $alias)); $linkElement = new Html\Element(); $linkElement->init('a', array('href' => Registry::get('secondParameter') === $alias ? null : Registry::get('rewriteRoute') . 'preview/' . $alias, 'title' => $alias)); /* collect output */ $output = $titleElement->html($linkElement->text($alias)); $output .= Template::partial($path); return $output; }
/** * render * * @since 3.0.0 * * @param string $alias * @param string $path * * @return string */ public static function render($alias = null, $path = null) { $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-preview', 'id' => $alias]); $linkElement = new Html\Element(); $linkElement->init('a', ['href' => Registry::get('secondParameter') === $alias ? Registry::get('parameterRoute') . 'preview#' . $alias : Registry::get('parameterRoute') . 'preview/' . $alias])->text(Registry::get('secondParameter') === $alias ? Language::get('back') : $alias); /* collect output */ $output = $titleElement->html($linkElement); $output .= Template\Tag::partial($path); return $output; }
/** * render * * @since 2.2.0 * * @param mixed $file * @param array $optionArray * * @return string */ public static function render($file = null, $optionArray = []) { $output = null; /* device related images */ if (is_array($file)) { /* process source */ foreach ($file as $key => $value) { if (in_array($key, self::$_configArray['device']) && Registry::get('my' . ucfirst($key))) { $file = $value; } } } /* collect output */ if (file_exists($file)) { $imageElement = new Html\Element(); $imageElement->init('img', ['alt' => $optionArray['alt'], 'class' => self::$_configArray['className']['image'], 'src' => self::$_configArray['placeholder']]); /* collect image output */ $output = $imageElement->copy()->addClass($optionArray['className'])->attr('data-src', $file); /* placeholder */ if (self::$_configArray['placeholder']) { /* calculate image ratio */ $imageDimensions = getimagesize($file); $imageRatio = $imageDimensions[1] / $imageDimensions[0] * 100; /* placeholder */ $placeholderElement = new Html\Element(); $placeholderElement->init('div', ['class' => self::$_configArray['className']['placeholder'], 'style' => 'padding-bottom:' . $imageRatio . '%']); /* collect output */ $output = $placeholderElement->html($output); } /* noscript fallback */ $output .= '<noscript>' . $imageElement . '</noscript>'; } else { self::setNotification('error', Language::get('file_not_found') . Language::get('colon') . ' ' . $file . Language::get('point')); } return $output; }