Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Änderungen für SOH-1 EOT #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Presets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/*
* Array containing the preset definition(s)
*
* Every preset has at least to provide informations about
* - font
* - size
* - color
* */

Sleightofhand_presets::$default_presets = array(
'default' => array('font'=>'Korean_Calligraphy.ttf',
/*'fontpath'=>'',*/
'size'=>'24',
'color'=>'#8B0000'/*,
'wordwrap'=>'',
'quality'=>'',
'text-align'=>''*/));
5 changes: 5 additions & 0 deletions bootstrap.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class Sleightofhand
*/
static public function main($dir='')
{
/* Presets */
include_once $dir . 'classes/Presets/Presets.class.php';
include_once $dir . 'Presets.php';


/* classes, functions */
include_once $dir . 'classes/Environment/Abstract.php';
include_once $dir . 'classes/Environment/Redaxo5.php';
Expand Down
11 changes: 9 additions & 2 deletions classes/Environment/Oxid.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ public function getCachePath()
*/
public function getPublicPath()
{
return './out/sleightofhand/';
$conf = oxconfig::getInstance();
$baspath = $conf->getShopUrl();
return $baspath.'/out/sleightofhand/';
}

public function getPublicPathLocal()
{
$baspath = $_SERVER['DOCUMENT_ROOT'].'/'.ltrim(dirname($_SERVER['SCRIPT_NAME']), '/');
return $baspath.'/out/sleightofhand/';
}

/**
Expand All @@ -145,5 +153,4 @@ public function extensionPoint($type, $callback)
Sleightofhand_Output_Filter::register($callback);
}
}

}
31 changes: 26 additions & 5 deletions classes/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class Sleightofhand_Generator
*/
protected $_settings = array();

/**
* Array containing the used preset
*
* @var array Preset values array
*/
protected $_preset = array();

/**
* Main/Init SOH Function
* Checks settings, caching and generally
Expand All @@ -57,6 +64,11 @@ public function __construct($settings = array())
$this->env->getModulePath() . 'fonts/'
);

/* Initiate variable for preset if a preset name is submitted */
if($this->setting('preset') != '' and array_key_exists($this->setting('preset'), Sleightofhand_presets::$default_presets)){
$this->_preset = Sleightofhand_presets::$default_presets[$this->setting('preset')];
}

$font = $this->setting('font');
$fontpath = $this->setting('fontpath');
$size = $this->setting('size');
Expand All @@ -65,6 +77,7 @@ public function __construct($settings = array())
$quality = $this->setting('quality');
$align = $this->setting('text-align');


$quality = intVal($quality);
if ($quality == 0) {
$quality = 4;
Expand Down Expand Up @@ -98,11 +111,10 @@ public function __construct($settings = array())
if (!empty($font) && !empty($size) && !empty($color)
&& file_exists($fontpath . $font)
) {

$this->valid = true;

$cachekey = md5(serialize($this->_settings));
$cachepath = $this->env->getPublicPath();
$cachepath = $this->env->getPublicPathLocal();

if (!file_exists($cachepath)) {
$result = @mkdir($cachepath);
Expand All @@ -118,7 +130,7 @@ public function __construct($settings = array())
/*
* Force compiling for development
*/
//$this->generate();
$this->generate();
}
}

Expand All @@ -133,6 +145,7 @@ function generate()
* This isn't really needed, and should be commented out while testing.
* It is only here for poorly configured servers.
*/

@ini_set('max_execution_time', 300);
@ini_set('memory_limit', '256M');

Expand Down Expand Up @@ -548,9 +561,17 @@ function setting($key = null, $value = null)
{
if ($key != null && $value == null) {
/* getter */
if (isset($this->_settings[$key])) {

/* Use preset if requested and key exists in preset */
if (count($this->_preset) != 0 and array_key_exists($key, $this->_preset)) {
if(isset($this->_settings[$key])){
return $this->_settings[$key];
} else {
return $this->_preset[$key];
}
} elseif(isset($this->_settings[$key])){
return $this->_settings[$key];
} else {
}else {
return '';
}
} else if ($key != null && $value != null) {
Expand Down
28 changes: 28 additions & 0 deletions classes/Presets/Presets.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Sleightofhand_presets
*
* PHP version 5
*
* @category Sleightofhand
* @package Sleightofhand
* @author Heiko Adams <[email protected]>
* @license MIT License http://www.opensource.org/licenses/mit-license.html
* @version GIT: <git_id>
* @link http://bit.ly/sleightofhand-site
*/

/**
* Sleightofhand_presets - Preset-array providing class
*
* @category Sleightofhand
* @package Sleightofhand
* @author Heiko Adams <[email protected]>
* @license MIT License http://www.opensource.org/licenses/mit-license.html
* @version Release: <package_version>
* @link http://bit.ly/sleightofhand-site
*/
class Sleightofhand_presets
{
public static $default_presets = array();
}