Skip to content

Commit

Permalink
Added font-awesome support
Browse files Browse the repository at this point in the history
  • Loading branch information
kschroeder committed May 8, 2017
1 parent 3666656 commit 5aef44a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions assets/configuration.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<xs:attribute name="identifier" type="xs:string" use="required"/>
<xs:attribute type="xs:string" name="label" use="optional"/>
<xs:attribute type="xs:string" name="glyphicon" use="optional"/>
<xs:attribute type="xs:string" name="font-awesome" use="optional"/>
<xs:attribute name="hidden" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
Expand Down
2 changes: 1 addition & 1 deletion examples/example-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<element identifier="theme" label="Theme"/>
</group>
</section>
<section identifier="security" label="Security">
<section identifier="security" label="Security" font-awesome="lock">
<group identifier="authentication" label="Authentication">
<element identifier="require" label="Require Authentication" type="select" source="Magium\Configuration\Source\YesNo"/>
</group>
Expand Down
3 changes: 2 additions & 1 deletion lib/View/Controllers/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Magium\Configuration\View\Controllers;

use Magium\Configuration\Config\MergedStructure;
use Magium\Configuration\Config\Repository\ConfigInterface;
use Magium\Configuration\File\Context\AbstractContextConfigurationFile;
use Magium\Configuration\MagiumConfigurationFactoryInterface;
use Magium\Configuration\View\Controllers\Helpers\ContextRepository;
Expand Down Expand Up @@ -86,6 +85,8 @@ protected function provideSections()
];
if (isset($section['glyphicon'])) {
$returnSections[$sectionId]['glyphicon'] = (string)$section['glyphicon'];
} else if (isset($section['font-awesome'])) {
$returnSections[$sectionId]['font-awesome'] = (string)$section['font-awesome'];
}
}
return $returnSections;
Expand Down
2 changes: 2 additions & 0 deletions lib/View/views/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
id="section-<?php echo htmlspecialchars($sectionId); ?>">
<?php if (isset($sectionData['glyphicon'])): ?>
<i class="glyphicon glyphicon-<?php echo htmlspecialchars($sectionData['glyphicon']); ?>"></i>
<?php elseif (isset($sectionData['font-awesome'])): ?>
<i class="fa fa-<?php echo htmlspecialchars($sectionData['font-awesome']); ?>"></i>
<?php else: ?>
<i class="glyphicon glyphicon-plus"></i>
<?php endif; ?>
Expand Down
19 changes: 17 additions & 2 deletions tests/View/SectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
use Magium\Configuration\Config\MergedStructure;
use Magium\Configuration\File\Context\AbstractContextConfigurationFile;
use Magium\Configuration\MagiumConfigurationFactoryInterface;
use Magium\Configuration\View\ViewConfiguration;
use Magium\Configuration\View\FrontController;
use SebastianBergmann\PHPLOC\Log\XML;
use Magium\Configuration\View\ViewConfiguration;

class SectionTest extends AbstractViewTestCase
{
Expand Down Expand Up @@ -113,6 +112,22 @@ public function testGylphiconRendered()
$simpleXml = $this->getContent($response);
self::assertXpathExists($simpleXml, '//nav/descendant::ul[@id="magium-sections"]/descendant::li/i[contains(concat(" ",normalize-space(@class)," "), " glyphicon-test ")]');
}
public function testFontAwesomeRendered()
{

$viewConfiguration = $this->getViewConfiguration();
$viewManager = $this->getFrontController($viewConfiguration, <<<XML
<magiumConfiguration xmlns="http://www.magiumlib.com/Configuration">
<section identifier="section1" label="Section Eins" font-awesome="test"/>
</magiumConfiguration>
XML
);

/* @var $viewManager FrontController */
$response = $viewManager->render();
$simpleXml = $this->getContent($response);
self::assertXpathExists($simpleXml, '//nav/descendant::ul[@id="magium-sections"]/descendant::li/i[contains(concat(" ",normalize-space(@class)," "), " fa-test ")]');
}

public function testJqueryRendered()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/View/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Interop\Container\ContainerInterface;
use Magium\Configuration\Config\BuilderInterface;
use Magium\Configuration\Config\Repository\ConfigurationRepository;
use Magium\Configuration\Config\MergedStructure;
use Magium\Configuration\Config\Repository\ConfigurationRepository;
use Magium\Configuration\Config\Storage\StorageInterface;
use Magium\Configuration\MagiumConfigurationFactoryInterface;
use Magium\Configuration\View\FrontController;
Expand Down Expand Up @@ -62,7 +62,7 @@ public function testGroupDisplayed()
$dom->loadHTML(sprintf('<html><body>%s</body></html>', $content));
$simpleXml = simplexml_import_dom($dom);
self::assertXpathNotExists($simpleXml, '//title'); // Make sure the layout isn't called
self::assertXpathExists($simpleXml, '//h2/a[.="Test"]');
self::assertXpathExists($simpleXml, '//h2/span[.="Test"]');
self::assertXpathExists($simpleXml, '//label[.="Element"]');
self::assertXpathExists($simpleXml, '//input[@type="text" and @name="section1_test_element"]'); // we do this separately to test if the element exists apart from whether it has a value.
self::assertXpathExists($simpleXml, '//input[@type="text" and @name="section1_test_element" and @value="Element Value"]');
Expand Down
2 changes: 1 addition & 1 deletion tests/View/standalone/settings/active-directory.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<magiumConfiguration xmlns="http://www.magiumlib.com/Configuration">
<section identifier="magium" label="Magium">
<section identifier="magium" label="Magium" font-awesome="sign-in">
<group identifier="ad" label="Active Directory">
<element identifier="enabled" label="Enabled" type="select" source="Magium\Configuration\Source\Switches\YesNo">
<description>Is the Magium Active Directory integration enabled?</description>
Expand Down

0 comments on commit 5aef44a

Please sign in to comment.