Skip to content

Commit

Permalink
466T_updateOctPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian committed Mar 7, 2016
1 parent e91c0c4 commit 85a510a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
25 changes: 20 additions & 5 deletions styla/magazine/components/Magazine.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,20 @@ public function defineProperties()
'type' => 'string',
'showExternalParam' => false
],
'caching' => [
'description' => 'Enables caching of SEO and version information.',
'title' => 'Enable Caching',
'default' => true,
'type' => 'checkbox',
'showExternalParam' => false
],
'debug' => [
'description' => 'Displays DEBUG information above the magazine.',
'title' => 'Debug',
'default' => false,
'type' => 'checkbox',
'showExternalParam' => false
],
]
];
}

Expand All @@ -87,6 +94,8 @@ public function onRun()
$feedlimit = $this->property('feedlimit');
$tag = $this->property('tag');

$this->page['caching'] = $this->property('caching');

// --- Set file_get_contents Timeout to 10s -------
ini_set('default_socket_timeout', 10);

Expand Down Expand Up @@ -123,6 +132,7 @@ public function onRun()
$this->page['seoserver'] = $this->property('seoserver'); # URL to SEO server
$this->page['cdnserver'] = $this->property('cdnserver'); # URL to CDN server
$this->page['versionserver'] = $this->property('versionserver'); # URL to Version server
$this->page['caching'] = $this->property('caching'); # Cache disabled
}
}

Expand All @@ -139,7 +149,7 @@ public function fetchAndRememberSEO( $key ){
}

// Check if SEO data is already in cache, if yes, return the cached data
if(Cache::has('styla_SEO_'.$key)){
if(Cache::has('styla_SEO_'.$key) && $this->property('caching')){
if($this->property('debug')){
$this->page['readFromServer'] = 'false';
}
Expand Down Expand Up @@ -194,9 +204,14 @@ public function fetchAndRememberSEO( $key ){
// Fetch and remember SEO information
public function fetchAndRememberCdnVersion(){

$version = Cache::remember('CDN_version', 60, function(){
return @file_get_contents($this->property('versionserver').$this->property('domain'));
});
if($this->property('caching')){
$version = Cache::remember('CDN_version', 60, function(){
return @file_get_contents($this->property('versionserver').$this->property('domain'));
});
}
else{
$version = @file_get_contents($this->property('versionserver').$this->property('domain'));
}

if($this->property('debug')){
$this->page['version'] = $version;
Expand Down
1 change: 1 addition & 0 deletions styla/magazine/components/magazine/default.htm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ <h4>Plugin</h4>
<pre>SEO Server: {{ seoserver }}</pre>
<pre>Feedlimit: {{ feedlimit }}</pre>
<pre>Tag: {{ tag }}</pre>
<pre>Cache enabled: {% if caching %}true{% else %}false{% endif %}</pre>
<hr>
<h4>CDN version</h4>
<pre>Version: {{ version }}</pre>
Expand Down
2 changes: 2 additions & 0 deletions styla/magazine/updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
- Now using the default caching system set in config/cache.php
- Cache expiration now set via SEO API
- Only two pages required now - one for the magazine /rootPath and one wildcard rootPath/*
1.5.1:
- Added a switch to enable or disable Caching

0 comments on commit 85a510a

Please sign in to comment.