Skip to content

Commit

Permalink
do not throw an error when no technique has been chosen yet (fixes #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
selfthinker committed Apr 4, 2015
1 parent aef1317 commit 3bb2c3a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions action.php
Expand Up @@ -41,6 +41,7 @@ function _addFontCode(&$event, $param) {
$fontSysDir = $pluginSysDir.'fonts/';
$fontDir = $pluginDir.'fonts/';

$technique = $this->getConf('technique');
$fontFileName = $this->getConf('fontFile');
$fontName = $this->getConf('fontName');
$headings = $this->getConf('headings');
Expand All @@ -50,8 +51,13 @@ function _addFontCode(&$event, $param) {
$CSSfiles = array();
$CSSembed = '';

// don't apply anything if no technique is chosen
if (empty($technique)) {
return false;
}

// prepare CSS and JS to embed depending on the technique
switch ($this->getConf('technique')) {
switch ($technique) {
case 'fontface':
$fontEOT = $fontFileName.'.eot';
$fontWOFF = $fontFileName.'.woff';
Expand Down Expand Up @@ -173,8 +179,8 @@ function _addFontCode(&$event, $param) {
// if not set (for techniques other than cufon and sifr), set them through CSS as usual
if ( $this->getConf('addStyles') &&
!empty($headings) &&
($this->getConf('technique')!='cufon') &&
($this->getConf('technique')!='sifr') ) {
($technique!='cufon') &&
($technique!='sifr') ) {
$CSSembed .= $headings." { font-family: '".$fontName."', ".$this->getConf('genericFamily')."; }";
}

Expand Down
2 changes: 1 addition & 1 deletion conf/default.php
Expand Up @@ -3,7 +3,7 @@
* default configuration settings
*/

$conf['technique'] = 'fontface';
$conf['technique'] = '';
$conf['fontFile'] = '';
$conf['fontName'] = ''; // not needed for cufon and sifr (name for typeface is in <fontFile>.typeface.js)
$conf['headings'] = 'h1'; // without addStyles still needed for: cufon, sifr
Expand Down
2 changes: 1 addition & 1 deletion conf/metadata.php
Expand Up @@ -3,7 +3,7 @@
* configuration metadata
*/

$meta['technique'] = array('multichoice','_choices' => array('fontface', 'google', 'kernest', 'cufon', 'typeface', 'sifr'));
$meta['technique'] = array('multichoice','_choices' => array('', 'fontface', 'google', 'kernest', 'cufon', 'typeface', 'sifr'));
$meta['fontFile'] = array('string');
$meta['fontName'] = array('string');
$meta['headings'] = array('multicheckbox','_choices' => array('h1', 'h2', 'h3', 'h4', 'h5'));
Expand Down

0 comments on commit 3bb2c3a

Please sign in to comment.