Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
colintucker committed Nov 1, 2017
2 parents ba3a48e + c1f0b66 commit 7eefb2d
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 8 deletions.
4 changes: 3 additions & 1 deletion _config/assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
Name: silverware-assets
---

# Configure Allowed Extensions:
# Configure File Extensions:

SilverStripe\Assets\File:
extensions:
- SilverWare\Extensions\Assets\RenderInlineExtension
allowed_extensions:
- svg
2 changes: 2 additions & 0 deletions _config/styles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ SilverWare\Grid\Frameworks\Bootstrap\Framework:
image:
image: image
fluid: img-fluid
link:
image: link-image
pagination:
small: pagination-sm
large: pagination-lg
Expand Down
64 changes: 64 additions & 0 deletions src/Extensions/Assets/RenderInlineExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* This file is part of SilverWare.
*
* PHP version >=5.6.0
*
* For full copyright and license information, please view the
* LICENSE.md file that was distributed with this source code.
*
* @package SilverWare\Extensions\Assets
* @author Colin Tucker <colin@praxis.net.au>
* @copyright 2017 Praxis Interactive
* @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @link https://github.com/praxisnetau/silverware
*/

namespace SilverWare\Extensions\Assets;

use SilverStripe\Core\Extension;
use SilverStripe\ORM\FieldType\DBField;
use DOMDocument;

/**
* An extension which adds inline rendering for vector images to the file class.
*
* @package SilverWare\Extensions\Assets
* @author Colin Tucker <colin@praxis.net.au>
* @copyright 2017 Praxis Interactive
* @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @link https://github.com/praxisnetau/silverware
*/
class RenderInlineExtension extends Extension
{
/**
* Renders the content of the extended object inline.
*
* @return DBHTMLText
*/
public function getRenderInline()
{
// Check File Exists / File Extension:

if ($this->owner->exists() && $this->owner->getExtension() == 'svg') {

// Create DOM Document:

$dom = new DOMDocument();

// Load SVG Data into DOM:

$dom->load(BASE_PATH . $this->owner->URL);

// Normalise SVG Data:

$dom->normalizeDocument();

// Render SVG as HTML:

return DBField::create_field('HTMLFragment', $dom->saveHTML($dom->documentElement));

}
}
}
15 changes: 14 additions & 1 deletion src/Extensions/Lists/ListSourceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace SilverWare\Extensions\Lists;

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField;
Expand Down Expand Up @@ -257,7 +258,9 @@ public function getListItems()

if ($this->owner->PaginateItems) {

$items = PaginatedList::create($items, $_GET)->setPaginationGetVar($this->owner->getPaginationGetVar());
$items = PaginatedList::create($items, $this->getRequest());

$items->setPaginationGetVar($this->owner->getPaginationGetVar());

if ($this->owner->ItemsPerPage) {
$items->setPageLength($this->owner->ItemsPerPage);
Expand Down Expand Up @@ -355,4 +358,14 @@ public function getPaginationGetVar()

return 'start';
}

/**
* Answers the request object from the current controller.
*
* @return HTTPRequest
*/
protected function getRequest()
{
return Controller::curr()->getRequest();
}
}
2 changes: 1 addition & 1 deletion src/Extensions/Model/DetailFieldsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function getDetailFields()

}

$text = isset($spec['text']) ? $this->owner->processDetailFieldValue($spec['text']) : null;
$text = isset($spec['text']) ? $spec['text'] : null;

if ($text) {

Expand Down
Loading

0 comments on commit 7eefb2d

Please sign in to comment.