Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AN-55 Fix for widescreen text width #263

Merged
merged 6 commits into from
Dec 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
113 changes: 68 additions & 45 deletions includes/apple-exporter/builders/class-builder.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
<?php
/**
* Publish to Apple News Includes: Apple_Exporter\Builders\Builder abstract class
*
* Contains an abstract class to form the foundation of component builders.
*
* @package Apple_News
* @subpackage Apple_Exporter
* @since 0.4.0
*/

namespace Apple_Exporter\Builders;

use Apple_Exporter\Exporter_Content;
use Apple_Exporter\Exporter_Content_Settings;

/**
* A base abstract builder. All builders must implement a build method, in
* which they return an array to represent a part of the final article.
* A base abstract builder from which all other builders inherit.
*
* All builders must implement a build method, in which they return an array to
* represent a part of the final article.
*
* @since 0.4.0
*/
Expand All @@ -29,17 +44,22 @@ abstract class Builder {

/**
* Constructor.
*
* @param Exporter_Content $content The content object to load.
* @param Exporter_Content_Settings $settings The settings object to load.
*
* @access public
*/
function __construct( $content, $settings ) {
$this->content = $content;
public function __construct( $content, $settings ) {
$this->content = $content;
$this->settings = $settings;
}

/**
* Returns an array of the content.
*
* @access public
* @return array
* @return array The content in array format.
*/
public function to_array() {
return $this->build();
Expand All @@ -48,112 +68,115 @@ public function to_array() {
/**
* Builds the content.
*
* @abstract
* @access protected
*/
protected abstract function build();

// Isolate dependencies
// ------------------------------------------------------------------------

/**
* Gets the content ID.
* Gets the content byline.
*
* @access protected
* @return mixed
* @return string The byline from the content object.
*/
protected function content_id() {
return $this->content->id();
protected function content_byline() {
return $this->content->byline();
}

/**
* Gets the content title.
* Gets the content cover.
*
* @access protected
* @return string
* @return string The URL for the cover image from the content object.
*/
protected function content_title() {
return $this->content->title() ?: __( 'Untitled Article', 'apple-news' );
protected function content_cover() {
return $this->content->cover();
}

/**
* Gets the content body.
* Gets the content ID.
*
* @access protected
* @return string
* @return int The ID from the content object.
*/
protected function content_text() {
return $this->content->content();
protected function content_id() {
return $this->content->id();
}

/**
* Gets the content intro.
*
* @access protected
* @return Intro
* @return string The intro from the content object.
*/
protected function content_intro() {
return $this->content->intro();
}

/**
* Gets the content cover.
* Gets the content nodes.
*
* @access protected
* @return Cover
* @return array The nodes from the content object.
*/
protected function content_cover() {
return $this->content->cover();
protected function content_nodes() {
return $this->content->nodes();
}

/**
* Gets a content setting.
*
* @param string $name The setting name to retrieve.
*
* @access protected
* @param string $name
* @return string
* @return mixed The value for the setting.
*/
protected function content_setting( $name ) {
return $this->content->get_setting( $name );
}

/**
* Gets the content byline.
* Gets the content body.
*
* @access protected
* @return Byline
* @return string The body text from the content object.
*/
protected function content_byline() {
return $this->content->byline();
protected function content_text() {
return $this->content->content();
}

/**
* Gets the content nodes.
* Gets the content title.
*
* @access protected
* @return array
* @return string The title from the content object, or a fallback title.
*/
protected function content_nodes() {
return $this->content->nodes();
protected function content_title() {
return $this->content->title()
? $this->content->title()
: __( 'Untitled Article', 'apple-news' );
}

/**
* Updates a content property.
* Gets a content setting by key.
*
* @param string $name The setting name to retrieve.
*
* @access protected
* @return mixed The value of the setting.
*/
protected function set_content_property( $name, $value ) {
return $this->content->set_property( $name, $value );
protected function get_setting( $name ) {
return $this->settings->$name;
}

/**
* Gets a content setting by key.
* Updates a content property.
*
* @param string $name The setting key to modify.
* @param mixed $value The new value for the setting.
*
* @access protected
* @param string $name
* @return mixed
*/
protected function get_setting( $name ) {
return $this->settings->get( $name );
protected function set_content_property( $name, $value ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing @param for these guys

$this->content->set_property( $name, $value );
}

}
6 changes: 4 additions & 2 deletions includes/apple-exporter/builders/class-component-layouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public function set_anchor_layout_for( $component ) {
$col_start = 0;
if ( 'right' == $position ) {
if ( $component->is_anchor_target() ) {
$col_start = $layout_columns - $body_column_span + $alignment_offset;
$col_start = $alignment_offset;
} elseif ( 'center' === $this->get_setting( 'body_orientation' ) ) {
$col_start = $layout_columns - $alignment_offset;
} else {
$col_start = $body_column_span - $alignment_offset;
}
Expand All @@ -126,7 +128,7 @@ public function set_anchor_layout_for( $component ) {
if ( $component->is_anchor_target() ) {
$col_span = $body_column_span - $alignment_offset;
} else {
$col_span = $layout_columns - $body_column_span + $alignment_offset;
$col_span = $alignment_offset;
}

// Finally, register the layout
Expand Down