/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/frank
/TileRenderer
/TileRendererFactory.php
/**
* Get the tile rendering class
*
* Will first check if there is a rendering class in app then in frank.
* If none is found, will throw an error
*
* @throws \Exception If no tile renderer class is found
* @param \WP_Post the post
* @return string the class
*/
protected function getTileRendererClass(\WP_Post $post) {
$postType = str_replace('-', '_', $post->post_type);
$partialClassName = "TileRenderer\\TileRenderer_{$postType}";
$className = $this->getClassAcrossNamespaces($partialClassName);
if (is_null($className)) {
throw new \Exception("TileRenderer {$partialClassName} type not found.");
}
return $className;
}
}
?>
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/frank
/TileRenderer
/TileRendererFactory.php
class TileRendererFactory implements TileRendererInterface {
use \Frank\Traits\GetClassAcrossNamespaces;
/**
* The post the tile should be generated from
*
* @var WP_Post|null
*/
protected $post = null;
public function setPost(\WP_Post $post = null) {
$this->post = $post;
}
public function render() {
// Try to get the correct tile renderer
if ($this->post) {
// Automatically assign a template renderer when singular page
$className = $this->getTileRendererClass($this->post);
//Check if the class implements the TemplateRendererInterface
$interfaces = class_implements($className);
if (isset($interfaces['Frank\TileRenderer\TileRendererInterface'])) {
$tileRenderer = new $className();
$tileRenderer->setPost($this->post);
$tileRenderer->render();
}else{
throw new \Exception("TileRenderer {$className} doesn't implement Frank\TileRenderer\TileRendererInterface.");
}
} else {
throw new \Exception("No post available for TileRendererFactory.");
}
}
/**
* Get the tile rendering class
*
* Will first check if there is a rendering class in app then in frank.
* If none is found, will throw an error
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/app
/SectionRenderer
/SectionRenderer_tag_content_default.php
</div>
</section>
<?php
else:
?>
No posts are available.
<?php
endif;
}
/**
* Generate the tiles for the section content
*/
protected function generatePostsTiles() {
if ($this->formatter->hasPosts()) {
foreach ($this->formatter->getPosts() as $post) {
// Dynamically call the tiles renderer
$tileRenderer = new TileRendererFactory();
$tileRenderer->setPost($post);
$tileRenderer->render();
}
}
}
}
?>
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/app
/SectionRenderer
/SectionRenderer_tag_content_default.php
/**
* The section formatter
*
* @var \Frank\SectionContract\SectionContract_tag_content_default
*/
protected $formatter = null;
protected $sectionFormatterContract = 'App\SectionContract\SectionContract_tag_content_default';
public function generateSection() {
if ($this->formatter->hasPosts()):
?>
<section class="archive_content">
<div class="archive_content-container container">
<div class="archive_content-post_count">
<span><?php echo $this->formatter->getCountOfTotalPostsInTag() ; ?> <?php echo ($this->formatter->isPostPlural() ? 'posts' : 'post'); ?> in the <?php echo $this->formatter->getTagName() ; ?> tag</span>
</div>
<div class="archive_content-tiles_wrapper">
<?php $this->generatePostsTiles(); ?>
</div>
<?php if ($this->formatter->hasPagination()): ?>
<div class="archive_content-pagination_wrapper">
<?php echo $this->formatter->getPagination(); ?>
</div>
<?php endif; ?>
</div>
</section>
<?php
else:
?>
No posts are available.
<?php
endif;
}
/**
* Generate the tiles for the section content
*/
protected function generatePostsTiles() {
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/frank
/SectionRenderer
/SectionRenderer.php
if ($this->sectionFormatterContract) {
// Check if the section formatter is implementing the contract for the section
$interfaces = class_implements($dataFormatter);
if (!isset($interfaces[$this->sectionFormatterContract])) {
$className = get_class($dataFormatter);
throw new \Exception("SectionFormatter {$className} must implement {$this->sectionFormatterContract}.");
}
}
$this->formatter = $dataFormatter;
}
public function render() {
$result = null;
if ($this->formatter->shouldDisplaySection()) {
// Buffer the output to return it as a string
ob_start();
$this->displayDebugStripe(get_class($this));
// Output the section
$this->generateSection();
// Get the buffer content
$result = ob_get_clean();
if (empty($result)) {
return null;
}
}
return $result;
}
}
?>
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/frank
/TemplateRenderer
/TemplateRenderer.php
return $result;
}
protected function renderSection($sectionRendererName, $sectionFormatterName) {
if (!is_string($sectionRendererName)) {
throw new Exception("Section renderer name not a string. Received {$sectionRendererName}");
} else if (!is_string($sectionFormatterName)) {
throw new Exception("Section formatter name not a string. Received {$sectionFormatterName}");
}
$sectionRenderer = $this->getSectionRenderer($sectionRendererName);
$sectionFormatter = $this->getSectionFormatter($sectionFormatterName);
// Set the data for the formatter
$sectionFormatter->setPost($this->post);
// Initialise the content for the section
$sectionFormatter->initialiseData();
// Set the formatter for the renderer
$sectionRenderer->setSectionFormatter($sectionFormatter);
return $sectionRenderer->render();
}
/**
* Get the section rendering class
*
* Will first check if there is a rendering class in app then in frank.
* If none is found, will throw an error
*
* @throws Exception If no section renderer class is found
* @param string The name of the renderer
* @return \Frank\SectionRenderer\SectionRendererInterface the section renderer
*/
protected function getSectionRenderer($rendererName) {
if (!is_string($rendererName)) {
throw new Exception("Section renderer name not a string. Received {$rendererName}");
}
if ( 'cta' === $rendererName )
$rendererName = 'cta_strip';
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/frank
/TemplateRenderer
/TemplateRenderer.php
$this->post = $post;
}
public function render() {
$result = '';
// Loop through all the pages sections and render them
if (sizeof($this->templateSections)) {
foreach ($this->templateSections as $section) {
if (
is_array($section) &&
sizeof($section) === 2 &&
is_string($section[0]) &&
is_string($section[1])
) {
$sectionRendererName = $section[0];
$sectionFormatterName = $section[1];
// Render the sections
$sectionResult = $this->renderSection($sectionRendererName, $sectionFormatterName);
// Add the section to the final result
if ($sectionResult) {
$result .= $sectionResult;
}
} else {
if (
!is_array($section) ||
sizeof($section) !== 2
) {
throw new Exception("Section with invalid format. Must be array with size of 2. Received " . gettype($section));
} else if (!is_string($section[0])) {
throw new Exception("Section renderer name not a string. Received {$section[0]}");
} else if (!is_string($section[1])) {
throw new Exception("Section formatter name not a string. Received {$section[1]}");
}
}
}
}
return $result;
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/frank
/PageRenderer
/PageRenderer.php
} else {
throw new \Exception("No post available for PageRenderer.");
}
} else {
// Check if a template renderer is set, otherwise, assign one automatically
if (defined('APP_ARCHIVE_TEMPLATE_RENDERER')) {
$className = APP_ARCHIVE_TEMPLATE_RENDERER;
$interfaces = class_implements($className);
if (isset($interfaces['Frank\TemplateRenderer\TemplateRendererInterface'])) {
$this->templateRenderer = new $className();
}else{
throw new \Exception("TemplateRenderer {$className} doesn't implement Frank\TemplateRenderer\TemplateRendererInterface.");
}
} else if (is_null($this->templateRenderer)) {
$this->templateRenderer = new \Frank\TemplateRenderer\TemplateRenderer_archive_default();
}
}
if ($this->templateRenderer) {
$result = $this->templateRenderer->render();
echo $result;
} else {
throw new \Exception("No TemplateRenderer available for PageRenderer.");
}
}
/**
* Get the template rendering class
*
* Will first check if there is a rendering class in app then in frank.
* If none is found, will throw an error
*
* @throws \Exception If no template renderer class is found
* @param \WP_Post the post
* @return string the class
*/
protected function getTemplateRendererClass(\WP_Post $post) {
$postType = str_replace('-', '_', $post->post_type);
$templateName = $this->formatPageTemplate($post->ID);
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/index.php
<?php
use Frank\PageRenderer\PageRenderer;
// Get the default wordpress header
get_header();
$renderer = new PageRenderer();
$renderer->setSingular((is_single() || is_page()));
if (have_posts()) {
while (have_posts()) {
the_post();
$renderer->addPost($post);
}
}
$renderer->render();
get_footer();
?>
/nas
/content
/live
/comsol
/wp-content
/themes
/community-solutions
/tag.php
<?php
/**
* Define the template renderer to use for the archive
*/
define('APP_ARCHIVE_TEMPLATE_RENDERER', 'App\TemplateRenderer\TemplateRenderer_tag_default');
include __DIR__ . '/index.php';
?>
/nas
/content
/live
/comsol
/wp-includes
/template-loader.php
}
break;
}
}
if ( ! $template ) {
$template = get_index_template();
}
/**
* Filters the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
$template = apply_filters( 'template_include', $template );
if ( $template ) {
include $template;
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
}
/nas
/content
/live
/comsol
/wp-blog-header.php
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}
/nas
/content
/live
/comsol
/index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';