Skip to content

Commit

Permalink
Mandatory check for undefined index in all values.
Browse files Browse the repository at this point in the history
  • Loading branch information
anagh-p committed Sep 8, 2016
1 parent 1097a21 commit 83ce0d1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 27 deletions.
18 changes: 17 additions & 1 deletion src/Quintype/Seo/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,30 @@ private function getSeoMetadata() {

}

protected function getTitle(){
protected function getPageTitle(){
if(isset($this->seoMetadata['page-title'])){
return $this->seoMetadata['page-title'];
} else {
return $this->config['title'];
}
}

protected function getTitle(){
if(isset($this->seoMetadata['title'])){
return $this->seoMetadata['title'];
} else {
return $this->config['title'];
}
}

protected function getDescription(){
if(isset($this->seoMetadata['description'])){
return $this->seoMetadata['description'];
} else {
return '';
}
}

protected function getFacebookData($key){
if(isset($this->config['facebook'])){
if(isset($this->config['facebook'][$key])){
Expand Down
16 changes: 8 additions & 8 deletions src/Quintype/Seo/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ function tags() {
if (sizeof($this->seoMetadata)>0){

return [
'title' => trim($this->getTitle()),
'description' => trim($this->seoMetadata['description']),
'title' => trim($this->getPageTitle()),
'description' => trim($this->getDescription()),
'og' => [
'title' => trim($this->seoMetadata['title']),
'description' => trim($this->seoMetadata['description'])
'title' => trim($this->getTitle()),
'description' => trim($this->getDescription())
],
'twitter' => [
'title' => trim($this->seoMetadata['title']),
'description' => trim($this->seoMetadata['description'])
'title' => trim($this->getTitle()),
'description' => trim($this->getDescription())
],
'msvalidate.01' => $this->getBingId(),
'fb' => [
Expand All @@ -28,11 +28,11 @@ function tags() {
'alternate' => [
'href' => '/feed',
'type' => 'application/atom+xml',
'title' => trim($this->getTitle()) . " ATOM Feed"
'title' => trim($this->getPageTitle()) . " ATOM Feed"
]
];
} else {
return ['title' => trim($this->getTitle())];
return ['title' => trim($this->getPageTitle())];
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/Quintype/Seo/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ function tags() {
if (sizeof($this->seoMetadata)>0){

return [
'title' => trim($this->getTitle()),
'description' => trim($this->seoMetadata['description']),
'title' => trim($this->getPageTitle()),
'description' => trim($this->getDescription()),
'og' => [
'title' => trim($this->seoMetadata['title']),
'description' => trim($this->seoMetadata['description'])
'title' => trim($this->getTitle()),
'description' => trim($this->getDescription())
],
'twitter' => [
'title' => trim($this->seoMetadata['title']),
'description' => trim($this->seoMetadata['description'])
'title' => trim($this->getTitle()),
'description' => trim($this->getDescription())
]
];
} else {
return ['title' => trim($this->getTitle())];
return ['title' => trim($this->getPageTitle())];
}
}

protected function getTitle(){
protected function getPageTitle(){
if(isset($this->seoMetadata['page-title'])){
return $this->seoMetadata['page-title'];
} else {
Expand Down
38 changes: 28 additions & 10 deletions src/Quintype/Seo/Story.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function tags() {
if (sizeof($this->story)>0){

return [
'title' => trim($this->getTitle()),
'description' => trim($this->story['summary']),
'title' => trim($this->getPageTitle()),
'description' => trim($this->getDescription()),
'og' => $this->getOgAttributes(),
'twitter' => $this->getTwitterAttributes(),
'msvalidate.01' => $this->getBingId(),
Expand All @@ -29,22 +29,38 @@ function tags() {
'publisher' => $this->getPublisher()
],
'rel:canonical' => $this->getCanonicalUrl(),
'al:android:package' => $this->getPublisher('al:android:package'),
'al:android:app-name' => $this->getPublisher('al:android:app-name'),
'al:android:package' => $this->getAndroidData('al:android:package'),
'al:android:app-name' => $this->getAndroidData('al:android:app-name'),
'al:android:url' => "quintypefb://" . $this->config['sketches-host'] . "/". $this->story['slug']
];
} else {
return ['title' => $this->getTitle()];
return ['title' => $this->getPageTitle()];
}
}

protected function getDescription(){
if(isset($this->story['summary'])){
return $this->story['summary'];
} else {
return '';
}
}

protected function getTitle(){
if(isset($this->story['headline'])){
return $this->story['headline'];
} else {
return $this->config['title'];
}
}

private function getOgAttributes(){
$attributes = [
'title' => trim($this->story['headline']),
'title' => trim($this->getTitle()),
'type' => 'article',
'url' => $this->getCanonicalUrl(),
'site-name' => trim($this->config['title']),
'description' => trim($this->story['summary']),
'description' => trim($this->getDescription()),
'image' => $this->getHeroImageUrl()
];

Expand All @@ -68,8 +84,8 @@ private function getOgAttributes(){

private function getTwitterAttributes(){
$attributes = [
'title' => trim($this->story['headline']),
'description' => trim($this->story['summary']),
'title' => trim($this->getTitle()),
'description' => trim($this->getDescription()),
'card' => 'summary-large-image',
'site' => $this->getTwitterSite(),
'image' => [
Expand Down Expand Up @@ -100,7 +116,9 @@ private function getPublisher(){

private function getAndroidData($element){
if(isset($this->config['apps-data'])){
return $this->config['apps-data'][$element];
if(isset($this->config['apps-data'][$element])){
return $this->config['apps-data'][$element];
}
}
}

Expand Down

0 comments on commit 83ce0d1

Please sign in to comment.