diff --git a/admin-dev/themes/default/template/controllers/stats/engines.tpl b/admin-dev/themes/default/template/controllers/stats/engines.tpl index f073ab22c..0078a01b8 100644 --- a/admin-dev/themes/default/template/controllers/stats/engines.tpl +++ b/admin-dev/themes/default/template/controllers/stats/engines.tpl @@ -23,7 +23,7 @@ * International Registered Trademark & Property of PrestaShop SA *} -
+{*

{l s='Settings'}

@@ -66,5 +66,4 @@

-
- \ No newline at end of file +*} \ No newline at end of file diff --git a/admin-dev/themes/default/template/controllers/stats/menu.tpl b/admin-dev/themes/default/template/controllers/stats/menu.tpl index c21a6304e..d94a14790 100644 --- a/admin-dev/themes/default/template/controllers/stats/menu.tpl +++ b/admin-dev/themes/default/template/controllers/stats/menu.tpl @@ -34,4 +34,5 @@ {else} {l s='No module has been installed.'} {/if} - \ No newline at end of file + + \ No newline at end of file diff --git a/controllers/admin/AdminStatsTabController.php b/controllers/admin/AdminStatsTabController.php index 8c2c0e157..386139bf5 100644 --- a/controllers/admin/AdminStatsTabController.php +++ b/controllers/admin/AdminStatsTabController.php @@ -51,7 +51,6 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor } $this->content .= $this->displayMenu(); - $this->content .= $this->displayEngines(); $this->content .= $this->displayCalendar(); $this->content .= $this->displayStats(); @@ -110,6 +109,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor return $tpl->fetch(); } + /* Not used anymore, but still work */ protected function displayEngines() { $tpl = $this->createTemplate('engines.tpl'); @@ -143,8 +143,13 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor $module_instance = array(); foreach ($modules as $m => $module) { - $module_instance[$module['name']] = Module::getInstanceByName($module['name']); - $modules[$m]['displayName'] = $module_instance[$module['name']]->displayName; + if ($module_instance[$module['name']] = Module::getInstanceByName($module['name'])) + $modules[$m]['displayName'] = $module_instance[$module['name']]->displayName; + else + { + unset($module_instance[$module['name']]); + unset($modules[$m]); + } } uasort($modules, array($this, 'checkModulesNames')); diff --git a/install-dev/upgrade/sql/1.6.0.1.sql b/install-dev/upgrade/sql/1.6.0.1.sql index 00db9a99f..fa32d2424 100644 --- a/install-dev/upgrade/sql/1.6.0.1.sql +++ b/install-dev/upgrade/sql/1.6.0.1.sql @@ -1,6 +1,7 @@ SET NAMES 'utf8'; INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES('PS_DASHBOARD_USE_PUSH', '0', NOW(), NOW()); +UPDATE `PREFIX_configuration` SET `value` = 'graphnvd3' WHERE `name` = 'PS_STATS_RENDER'; ALTER TABLE `PREFIX_employee` CHANGE `bo_show_screencast` `bo_menu` TINYINT(1) NOT NULL DEFAULT '0'; UPDATE `PREFIX_employee` SET bo_menu = 0; diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php index 023771df5..e68bce7ff 100644 --- a/modules/blocknewsletter/blocknewsletter.php +++ b/modules/blocknewsletter/blocknewsletter.php @@ -551,7 +551,7 @@ class Blocknewsletter extends Module 'type' => 'text', 'label' => $this->l('Welcome voucher code'), 'name' => 'NW_VOUCHER_CODE', - 'class' => '.fixed-width-md', + 'class' => 'fixed-width-md', 'desc' => $this->l('Leave blank to disable by default.') ), ), diff --git a/modules/blockrss/blockrss.php b/modules/blockrss/blockrss.php index 102b1fbb8..266f816f4 100644 --- a/modules/blockrss/blockrss.php +++ b/modules/blockrss/blockrss.php @@ -63,14 +63,14 @@ class Blockrss extends Module public function getContent() { - $output = '

'.$this->displayName.'

'; + $output = ''; if (Tools::isSubmit('submitBlockRss')) { $errors = array(); - $urlfeed = Tools::getValue('urlfeed'); - $title = Tools::getValue('title'); - $nbr = (int)Tools::getValue('nbr'); + $urlfeed = Tools::getValue('RSS_FEED_URL'); + $title = Tools::getValue('RSS_FEED_TITLE'); + $nbr = (int)Tools::getValue('RSS_FEED_NBR'); if ($urlfeed AND !Validate::isAbsoluteUrl($urlfeed)) $errors[] = $this->l('Invalid feed URL'); @@ -113,36 +113,7 @@ class Blockrss extends Module $output .= $this->displayError(implode('
', $errors)); } - return $output.$this->displayForm(); - } - - public function displayForm() - { - $output = ' -
-
'.$this->l('Settings').' - -
- -

'.$this->l('Create a title for the block (default: \'RSS feed\')').'

- -
- -
- -

'.$this->l('Add the URL of the feed you want to use (sample: http://news.google.com/?output=rss)').'

- -
- -
- -

'.$this->l('Number of threads displayed by the block (default value: 5)').'

- -
-
-
-
'; - return $output; + return $output.$this->renderForm(); } function hookLeftColumn($params) @@ -193,4 +164,67 @@ class Blockrss extends Module { $this->context->controller->addCSS(($this->_path).'blockrss.css', 'all'); } + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Settings'), + 'icon' => 'icon-cogs' + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('Block title'), + 'name' => 'RSS_FEED_TITLE', + 'desc' => $this->l('Create a title for the block (default: \'RSS feed\')'), + ), + array( + 'type' => 'text', + 'label' => $this->l('Add a feed URL'), + 'name' => 'RSS_FEED_URL', + 'desc' => $this->l('Add the URL of the feed you want to use (sample: http://news.google.com/?output=rss)'), + ), + array( + 'type' => 'text', + 'label' => $this->l('Number of threads displayed'), + 'name' => 'RSS_FEED_NBR', + 'class' => 'fixed-width-sm', + 'desc' => $this->l('Number of threads displayed by the block (default value: 5)'), + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + 'class' => 'btn btn-primary') + ), + ); + + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $helper->identifier = $this->identifier; + $helper->submit_action = 'submitBlockRss'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->tpl_vars = array( + 'fields_value' => $this->getConfigFieldsValues(), + 'languages' => $this->context->controller->getLanguages(), + 'id_language' => $this->context->language->id + ); + + return $helper->generateForm(array($fields_form)); + } + + public function getConfigFieldsValues() + { + return array( + 'RSS_FEED_TITLE' => Tools::getValue('RSS_FEED_TITLE', Configuration::get('RSS_FEED_TITLE')), + 'RSS_FEED_URL' => Tools::getValue('RSS_FEED_URL', Configuration::get('RSS_FEED_URL')), + 'RSS_FEED_NBR' => Tools::getValue('RSS_FEED_NBR', Configuration::get('RSS_FEED_NBR')), + ); + } } diff --git a/modules/blocksocial/blocksocial.php b/modules/blocksocial/blocksocial.php index 389e68d7f..b26aa43a3 100644 --- a/modules/blocksocial/blocksocial.php +++ b/modules/blocksocial/blocksocial.php @@ -56,32 +56,16 @@ class blocksocial extends Module { // If we try to update the settings $output = ''; - if (isset($_POST['submitModule'])) + if (Tools::isSubmit('submitModule')) { - Configuration::updateValue('blocksocial_facebook', (($_POST['facebook_url'] != '') ? $_POST['facebook_url']: '')); - Configuration::updateValue('blocksocial_twitter', (($_POST['twitter_url'] != '') ? $_POST['twitter_url']: '')); - Configuration::updateValue('blocksocial_rss', (($_POST['rss_url'] != '') ? $_POST['rss_url']: '')); + Configuration::updateValue('blocksocial_facebook', (($_POST['blocksocial_facebook'] != '') ? $_POST['blocksocial_facebook']: '')); + Configuration::updateValue('blocksocial_twitter', (($_POST['blocksocial_twitter'] != '') ? $_POST['blocksocial_twitter']: '')); + Configuration::updateValue('blocksocial_rss', (($_POST['blocksocial_rss'] != '') ? $_POST['blocksocial_rss']: '')); $this->_clearCache('blocksocial.tpl'); - $output = '
'.$this->l('Configuration updated').'
'; + $output .= $this->displayConfirmation($this->l('Configuration updated')); } - return ' -

'.$this->displayName.'

- '.$output.' -
-
- - -
 
- - -
 
- - -
 
-
-
-
'; + return $output.$this->renderForm(); } public function hookDisplayHeader() @@ -100,5 +84,67 @@ class blocksocial extends Module return $this->display(__FILE__, 'blocksocial.tpl', $this->getCacheId()); } -} -?> + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Settings'), + 'icon' => 'icon-cogs' + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('Facebook URL:'), + 'name' => 'blocksocial_facebook', + 'desc' => $this->l('Create a title for the block (default: \'RSS feed\')'), + ), + array( + 'type' => 'text', + 'label' => $this->l('Twitter URL:'), + 'name' => 'blocksocial_twitter', + 'desc' => $this->l('Add the URL of the feed you want to use (sample: http://news.google.com/?output=rss)'), + ), + array( + 'type' => 'text', + 'label' => $this->l('RSS URL:'), + 'name' => 'blocksocial_rss', + 'desc' => $this->l('Number of threads displayed by the block (default value: 5)'), + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + 'class' => 'btn btn-primary') + ), + ); + + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $helper->identifier = $this->identifier; + $helper->submit_action = 'submitModule'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->tpl_vars = array( + 'fields_value' => $this->getConfigFieldsValues(), + 'languages' => $this->context->controller->getLanguages(), + 'id_language' => $this->context->language->id + ); + + return $helper->generateForm(array($fields_form)); + } + + public function getConfigFieldsValues() + { + return array( + 'blocksocial_facebook' => Tools::getValue('blocksocial_facebook', Configuration::get('blocksocial_facebook')), + 'blocksocial_twitter' => Tools::getValue('blocksocial_twitter', Configuration::get('blocksocial_twitter')), + 'blocksocial_rss' => Tools::getValue('blocksocial_rss', Configuration::get('blocksocial_rss')), + ); + } + +} \ No newline at end of file diff --git a/modules/blockspecials/blockspecials.php b/modules/blockspecials/blockspecials.php index 3be99ed9d..855434267 100644 --- a/modules/blockspecials/blockspecials.php +++ b/modules/blockspecials/blockspecials.php @@ -69,38 +69,14 @@ class BlockSpecials extends Module public function getContent() { - $output = '

'.$this->displayName.'

'; + $output = ''; if (Tools::isSubmit('submitSpecials')) { - Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)Tools::getValue('always_display')); + Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY')); Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', (int)Tools::getValue('BLOCKSPECIALS_NB_CACHES')); - $output .= '
'.$this->l('Settings updated').'
'; + $output .= $this->displayConfirmation($this->l('Settings updated')); } - return $output.$this->displayForm(); - } - - public function displayForm() - { - return ' -
-
- '.$this->l('Settings').' - -
- - - - -

'.$this->l('Show the block even if no product is available.').'

-
- -
- -

'.$this->l('Specials are displayed randomly on the front end, but since it takes a lot of ressources, it is better to cache the results. Cache is reset everyday. 0 will disable the cache.').'

-
-
-
-
'; + return $output.$this->renderForm(); } public function hookRightColumn($params) @@ -152,4 +128,71 @@ class BlockSpecials extends Module { $this->_clearCache('blockspecials.tpl'); } + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Settings'), + 'icon' => 'icon-cogs' + ), + 'input' => array( + array( + 'type' => 'switch', + 'label' => $this->l('Always display this block.'), + 'name' => 'PS_BLOCK_SPECIALS_DISPLAY', + 'desc' => $this->l('Show the block even if no products are available.'), + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('Disabled') + ) + ), + ), + array( + 'type' => 'text', + 'label' => $this->l('Number of cache files.'), + 'name' => 'BLOCKSPECIALS_NB_CACHES', + 'desc' => $this->l('Specials are displayed randomly on the front end, but since it takes a lot of ressources, it is better to cache the results. Cache is reset everyday. 0 will disable the cache.'), + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + 'class' => 'btn btn-primary') + ), + ); + + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $helper->identifier = $this->identifier; + $helper->submit_action = 'submitSpecials'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->tpl_vars = array( + 'fields_value' => $this->getConfigFieldsValues(), + 'languages' => $this->context->controller->getLanguages(), + 'id_language' => $this->context->language->id + ); + + return $helper->generateForm(array($fields_form)); + } + + public function getConfigFieldsValues() + { + return array( + 'PS_BLOCK_SPECIALS_DISPLAY' => Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')), + 'BLOCKSPECIALS_NB_CACHES' => Tools::getValue('BLOCKSPECIALS_NB_CACHES', Configuration::get('BLOCKSPECIALS_NB_CACHES')), + ); + } } \ No newline at end of file diff --git a/modules/graphartichow/artichow/AntiSpam.class.php b/modules/graphartichow/artichow/AntiSpam.class.php deleted file mode 100644 index fea3cb23e..000000000 --- a/modules/graphartichow/artichow/AntiSpam.class.php +++ /dev/null @@ -1,224 +0,0 @@ -string = (string)$string; - - } - - /** - * Create a random string - * - * @param int $length String length - * @return string String created - */ - public function setRand($length) { - - $length = (int)$length; - - $this->string = ''; - - $letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679'; - $number = strlen($letters); - - for($i = 0; $i < $length; $i++) { - $this->string .= $letters{mt_rand(0, $number - 1)}; - } - - return $this->string; - - } - - /** - * Set noise on image - * - * @param int $nois Noise intensity (from 0 to 10) - */ - public function setNoise($noise) { - if($noise < 0) { - $noise = 0; - } - if($noise > 10) { - $noise = 10; - } - $this->noise = (int)$noise; - } - - /** - * Save string value in session - * You can use check() to verify the value later - * - * @param string $qName A name that identify the anti-spam image - */ - public function save($qName) { - $this->session(); - $session = 'artichow_'.(string)$qName; - $_SESSION[$session] = $this->string; - } - - /** - * Verify user entry - * - * @param string $qName A name that identify the anti-spam image - * @param string $value User-defined value - * @param bool $case TRUE for case insensitive check, FALSE for case sensitive check ? (default to TRUE) - * @return bool TRUE if the value is correct, FALSE otherwise - */ - public function check($qName, $value, $case = TRUE) { - - $this->session(); - - $session = 'artichow_'.(string)$qName; - - return ( - array_key_exists($session, $_SESSION) === TRUE and - $case ? - (strtolower($_SESSION[$session]) === strtolower((string)$value)) : - ($_SESSION[$session] === (string)$value) - ); - - } - - /** - * Draw image - */ - public function draw() { - - $fonts = array( - 'Tuffy', - 'TuffyBold', - 'TuffyItalic', - 'TuffyBoldItalic' - ); - - $sizes = array(12, 12.5, 13, 13.5, 14, 15, 16, 17, 18, 19); - - $widths = array(); - $heights = array(); - $texts = array(); - - // Set up a temporary driver to allow font size calculations... - $this->setSize(10, 10); - $driver = $this->getDriver(); - - for($i = 0; $i < strlen($this->string); $i++) { - - $fontKey = array_rand($fonts); - $sizeKey = array_rand($sizes); - - $font = new awTTFFont( - $fonts[$fontKey], $sizes[$sizeKey] - ); - - $text = new awText( - $this->string{$i}, - $font, - NULL, - mt_rand(-15, 15) - ); - - $widths[] = $driver->getTextWidth($text); - $heights[] = $driver->getTextHeight($text); - $texts[] = $text; - - } - - // ... and get rid of it. - $this->driver = NULL; - - $width = array_sum($widths); - $height = array_max($heights); - - $totalWidth = $width + 10 + count($texts) * 10; - $totalHeight = $height + 20; - - $this->setSize($totalWidth, $totalHeight); - - $this->create(); - - for($i = 0; $i < strlen($this->string); $i++) { - - $this->driver->string( - $texts[$i], - new awPoint( - 5 + array_sum(array_slice($widths, 0, $i)) + $widths[$i] / 2 + $i * 10, - 10 + ($height - $heights[$i]) / 2 - ) - ); - - } - - $this->drawNoise($totalWidth, $totalHeight); - - $this->send(); - - } - - protected function drawNoise($width, $height) { - - $points = $this->noise * 30; - $color = new awColor(0, 0, 0); - - for($i = 0; $i < $points; $i++) { - $this->driver->point( - $color, - new awPoint( - mt_rand(0, $width), - mt_rand(0, $height) - ) - ); - } - - } - - protected function session() { - - // Start session if needed - if(!session_id()) { - session_start(); - } - - } - -} - -registerClass('AntiSpam'); - diff --git a/modules/graphartichow/artichow/Artichow.cfg.php b/modules/graphartichow/artichow/Artichow.cfg.php deleted file mode 100644 index 3b9f71555..000000000 --- a/modules/graphartichow/artichow/Artichow.cfg.php +++ /dev/null @@ -1,84 +0,0 @@ -label = new awLabel; - - $this->barPadding = new awSide(0.08, 0.08, 0, 0); - $this->barShadow = new awShadow(awShadow::RIGHT_TOP); - $this->barBorder = new awBorder; - - $this->setValues($values); - - $this->identifier = (int)$identifier; - $this->number = (int)$number; - $this->depth = (int)$depth; - - $this->move = new awSide; - - // Hide vertical grid - $this->grid->hideVertical(TRUE); - - } - - /** - * Change bars padding - * This method is not compatible with awBarPlot::setBarPadding() - * - * @param float $left Left padding (between 0 and 1) - * @param float $right Right padding (between 0 and 1) - */ - public function setBarPadding($left = NULL, $right = NULL) { - $this->barPadding->set($left, $right); - } - - /** - * Change bars size - * This method is not compatible with awBarPlot::setBarPadding() - * - * @param int $width Bars size (between 0 and 1) - */ - public function setBarSize($size) { - $padding = (1 - $size) / 2; - $this->barPadding->set($padding, $padding); - } - - /** - * Move bars - * - * @param int $x - * @param int $y - */ - public function move($x, $y) { - $this->move->set($x, NULL, $y, NULL); - } - - /** - * Change bars space - * - * @param int $space Space in pixels - */ - public function setBarSpace($space) { - $this->barSpace = (int)$space; - } - - /** - * Change line background color - * - * @param awColor $color - */ - public function setBarColor(awColor $color) { - $this->barBackground = $color; - } - - /** - * Change line background gradient - * - * @param awGradient $gradient - */ - public function setBarGradient(awGradient $gradient) { - $this->barBackground = $gradient; - } - - /** - * Get the line thickness - * - * @return int - */ - public function getLegendLineThickness() { - } - - /** - * Get the line type - * - * @return int - */ - public function getLegendLineStyle() { - } - - /** - * Get the color of line - * - * @return Color - */ - public function getLegendLineColor() { - } - - /** - * Get the background color or gradient of an element of the component - * - * @return Color, Gradient - */ - public function getLegendBackground() { - return $this->barBackground; - } - - /** - * Get a mark object - * - * @return Mark - */ - public function getLegendMark() { - } - - public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { - - $count = count($this->datay); - $max = $this->getRealYMax(NULL); - $min = $this->getRealYMin(NULL); - - // Find zero for bars - if($this->xAxisZero and $min <= 0 and $max >= 0) { - $zero = 0; - } else if($max < 0) { - $zero = $max; - } else { - $zero = $min; - } - - // Get base position - $zero = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint(0, $zero)); - - // Distance between two values on the graph - $distance = $this->xAxis->getDistance(0, 1); - - // Compute paddings - $leftPadding = $this->barPadding->left * $distance; - $rightPadding = $this->barPadding->right * $distance; - - $padding = $leftPadding + $rightPadding; - $space = $this->barSpace * ($this->number - 1); - - $barSize = ($distance - $padding - $space) / $this->number; - $barPosition = $leftPadding + $barSize * ($this->identifier - 1); - - for($key = 0; $key < $count; $key++) { - - $value = $this->datay[$key]; - - if($value !== NULL) { - - $position = awAxis::toPosition( - $this->xAxis, - $this->yAxis, - new awPoint($key, $value) - ); - - $barStart = $barPosition + ($this->identifier - 1) * $this->barSpace + $position->x; - $barStop = $barStart + $barSize; - - $t1 = min($zero->y, $position->y); - $t2 = max($zero->y, $position->y); - - if(round($t2 - $t1) == 0) { - continue; - } - - $p1 = new awPoint( - round($barStart) + $this->depth + $this->move->left, - round($t1) - $this->depth + $this->move->top - ); - - $p2 = new awPoint( - round($barStop) + $this->depth + $this->move->left, - round($t2) - $this->depth + $this->move->top - ); - - $this->drawBar($driver, $p1, $p2); - - } - - } - - // Draw labels - foreach($this->datay as $key => $value) { - - if($value !== NULL) { - - $position = awAxis::toPosition( - $this->xAxis, - $this->yAxis, - new awPoint($key, $value) - ); - - $point = new awPoint( - $barPosition + ($this->identifier - 1) * $this->barSpace + $position->x + $barSize / 2 + 1 + $this->depth, - $position->y - $this->depth - ); - - $this->label->draw($driver, $point, $key); - - } - - } - - } - - public function getXAxisNumber() { - return count($this->datay) + 1; - } - // ça bidouille à fond ici ! - public function getXMax() { - return array_max($this->datax) + 1; - } - - public function getXCenter() { - return TRUE; - } - - protected function drawBar(awDriver $driver, awPoint $p1, awPoint $p2) { - - // Draw shadow - $this->barShadow->draw( - $driver, - $p1, - $p2, - awShadow::OUT - ); - - if(abs($p2->y - $p1->y) > 1) { - - $this->barBorder->rectangle( - $driver, - $p1, - $p2 - ); - - if($this->barBackground !== NULL) { - - $size = $this->barBorder->visible() ? 1 : 0; - - $b1 = $p1->move($size, $size); - $b2 = $p2->move(-1 * $size, -1 * $size); - - // Draw background - $driver->filledRectangle( - $this->barBackground, - new awLine($b1, $b2) - ); - - } - - } - } - -} - -registerClass('BarPlot'); - diff --git a/modules/graphartichow/artichow/Component.class.php b/modules/graphartichow/artichow/Component.class.php deleted file mode 100644 index 2a683d67c..000000000 --- a/modules/graphartichow/artichow/Component.class.php +++ /dev/null @@ -1,415 +0,0 @@ -components = array(); - } - - /** - * Add a component to the group - * - * @param awComponent $component A component - */ - public function add(awComponent $component) { - $this->components[] = $component; - } - -} - -registerClass('ComponentGroup', TRUE); - -abstract class awComponent { - - /** - * Component driver - * - * @var Driver - */ - protected $driver; - - /** - * Component width - * - * @var float - */ - public $width = 1.0; - - /** - * Component height - * - * @var float - */ - public $height = 1.0; - - /** - * Position X of the center the graph (from 0 to 1) - * - * @var float - */ - public $x = 0.5; - - /** - * Position Y of the center the graph (from 0 to 1) - * - * @var float - */ - public $y = 0.5; - - /** - * Component absolute width (in pixels) - * - * - * @var int - */ - public $w; - - /** - * Component absolute height (in pixels) - * - * - * @var int - */ - public $h; - - /** - * Left-top corner Y position - * - * @var float - */ - public $top; - - /** - * Left-top corner X position - * - * @var float - */ - public $left; - - /** - * Component background color - * - * @var Color - */ - protected $background; - - /** - * Component padding - * - * @var Side - */ - protected $padding; - - /** - * Component space - * - * @var Side - */ - protected $space; - - /** - * Component title - * - * @var Label - */ - public $title; - - /** - * Adjust automatically the component ? - * - * @var bool - */ - protected $auto = TRUE; - - /** - * Legend - * - * @var Legend - */ - public $legend; - - /** - * Build the component - */ - public function __construct() { - - // Component legend - $this->legend = new awLegend(); - - $this->padding = new awSide(25, 25, 25, 25); - $this->space = new awSide(0, 0, 0, 0); - - // Component title - $this->title = new awLabel( - NULL, - new awTuffy(10), - NULL, - 0 - ); - $this->title->setAlign(awLabel::CENTER, awLabel::TOP); - - } - - /** - * Adjust automatically the component ? - * - * @param bool $auto - */ - public function auto($auto) { - $this->auto = (bool)$auto; - } - - /** - * Change the size of the component - * - * @param int $width Component width (from 0 to 1) - * @param int $height Component height (from 0 to 1) - */ - public function setSize($width, $height) { - - $this->width = (float)$width; - $this->height = (float)$height; - - } - - /** - * Change the absolute size of the component - * - * @param int $w Component width (in pixels) - * @param int $h Component height (in pixels) - */ - public function setAbsSize($w, $h) { - - $this->w = (int)$w; - $this->h = (int)$h; - - } - - /** - * Change component background color - * - * @param awColor $color (can be null) - */ - public function setBackgroundColor($color) { - if($color === NULL or $color instanceof awColor) { - $this->background = $color; - } - } - - /** - * Change component background gradient - * - * @param awGradient $gradient (can be null) - */ - public function setBackgroundGradient($gradient) { - if($gradient === NULL or $gradient instanceof awGradient) { - $this->background = $gradient; - } - } - - /** - * Change component background image - * - * @param awImage $image (can be null) - */ - public function setBackgroundImage($image) { - if($image === NULL or $image instanceof awImage) { - $this->background = $image; - } - } - - /** - * Return the component background - * - * @return Color, Gradient - */ - public function getBackground() { - return $this->background; - } - - /** - * Change component padding - * - * @param int $left Padding in pixels (NULL to keep old value) - * @param int $right Padding in pixels (NULL to keep old value) - * @param int $top Padding in pixels (NULL to keep old value) - * @param int $bottom Padding in pixels (NULL to keep old value) - */ - public function setPadding($left = NULL, $right = NULL, $top = NULL, $bottom = NULL) { - $this->padding->set($left, $right, $top, $bottom); - } - - /** - * Change component space - * - * @param float $left Space in % (NULL to keep old value) - * @param float $right Space in % (NULL to keep old value) - * @param float $bottom Space in % (NULL to keep old value) - * @param float $top Space in % (NULL to keep old value) - */ - public function setSpace($left = NULL, $right = NULL, $bottom = NULL, $top = NULL) { - $this->space->set($left, $right, $bottom, $top); - } - - /** - * Change the absolute position of the component on the graph - * - * @var int $x Left-top corner X position - * @var int $y Left-top corner Y position - */ - public function setAbsPosition($left, $top) { - - $this->left = (int)$left; - $this->top = (int)$top; - - } - - /** - * Set the center of the component - * - * @param int $x Position X of the center of the component - * @param int $y Position Y of the center of the component - */ - public function setCenter($x, $y) { - - $this->x = (float)$x; - $this->y = (float)$y; - - } - - /** - * Get component coords with its padding - * - * @return array Coords of the component - */ - public function getPosition() { - - // Get component coords - $x1 = $this->padding->left; - $y1 = $this->padding->top; - $x2 = $this->w - $this->padding->right; - $y2 = $this->h - $this->padding->bottom; - - return array($x1, $y1, $x2, $y2); - - } - - /** - * Init the drawing of the component - */ - public function init(awDriver $driver) { - - // Set component background - $background = $this->getBackground(); - - if($background !== NULL) { - - $p1 = new awPoint(0, 0); - $p2 = new awPoint($this->w - 1, $this->h - 1); - - if($background instanceof awImage) { - - $driver->copyImage( - $background, - $p1, - $p2 - ); - - } else { - - $driver->filledRectangle( - $background, - new awLine($p1, $p2) - ); - - } - - } - } - - /** - * Finalize the drawing of the component - */ - public function finalize(awDriver $driver) { - - // Draw component title - $point = new awPoint( - $this->w / 2, - $this->padding->top - 8 - ); - $this->title->draw($driver, $point); - - // Draw legend - $this->legend->draw($driver); - - } - - /** - * Draw the grid around your component - * - * @param Driver A driver - * @return array Coords for the component - */ - abstract public function drawEnvelope(awDriver $driver); - - /** - * Draw the component on the graph - * Component should be drawed into specified coords - * - * @param Driver A driver - * @param int $x1 - * @param int $y1 - * @param int $x2 - * @param int $y2 - * @param bool $aliasing Use anti-aliasing to draw the component ? - */ - abstract public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing); - - /** - * Get space width in pixels - * - * @param int $width Component width - * @param int $height Component height - * @return array - */ - protected function getSpace($width, $height) { - - $left = (int)($width * $this->space->left / 100); - $right = (int)($width * $this->space->right / 100); - $top = (int)($height * $this->space->top / 100); - $bottom = (int)($height * $this->space->bottom / 100); - - return array($left, $right, $top, $bottom); - - } - -} - -registerClass('Component', TRUE); - diff --git a/modules/graphartichow/artichow/Graph.class.php b/modules/graphartichow/artichow/Graph.class.php deleted file mode 100644 index bf018a518..000000000 --- a/modules/graphartichow/artichow/Graph.class.php +++ /dev/null @@ -1,412 +0,0 @@ -setSize($width, $height); - - if(ARTICHOW_CACHE) { - - $this->name = $name; - $this->timeout = $timeout; - - // Clean sometimes all the cache - if(mt_rand(0, 5000) === 0) { - awGraph::cleanCache(); - } - - // Take the graph from the cache if possible - if($this->name !== NULL) { - - $this->fileCache = ARTICHOW_CACHE_DIRECTORY."/".$this->name; - $this->fileCacheTime = $this->fileCache."-time"; - - if(is_file($this->fileCache)) { - - $type = awGraph::cleanGraphCache($this->fileCacheTime); - - if($type === NULL) { - awGraph::deleteFromCache($this->name); - } else { - header("Content-Type: image/".$type); - echo file_get_contents($this->fileCache); - exit; - } - - } - - } - - } - - $this->title = new awLabel( - NULL, - new awTuffy(16), - NULL, - 0 - ); - $this->title->setAlign(awLabel::CENTER, awLabel::BOTTOM); - - } - - /** - * Delete a graph from the cache - * - * @param string $name Graph name - * @return bool TRUE on success, FALSE on failure - */ - public static function deleteFromCache($name) { - - if(ARTICHOW_CACHE) { - - if(is_file(ARTICHOW_CACHE_DIRECTORY."/".$name."-time")) { - unlink(ARTICHOW_CACHE_DIRECTORY."/".$name.""); - unlink(ARTICHOW_CACHE_DIRECTORY."/".$name."-time"); - } - - } - - } - - /** - * Delete all graphs from the cache - */ - public static function deleteAllCache() { - - if(ARTICHOW_CACHE) { - - $dp = opendir(ARTICHOW_CACHE_DIRECTORY); - - while($file = readdir($dp)) { - if($file !== '.' and $file != '..') { - unlink(ARTICHOW_CACHE_DIRECTORY."/".$file); - } - } - - } - - } - - /** - * Clean cache - */ - public static function cleanCache() { - - if(ARTICHOW_CACHE) { - - $glob = glob(ARTICHOW_CACHE_DIRECTORY."/*-time"); - - foreach($glob as $file) { - - $type = awGraph::cleanGraphCache($file); - - if($type === NULL) { - $name = preg_replace('!.*/(.*)\-time!', "\\1", $file); - awGraph::deleteFromCache($name); - } - - } - - } - - } - - /** - * Enable/Disable Graph timing - * - * @param bool $timing - */ - public function setTiming($timing) { - $this->timing = (bool)$timing; - } - - /** - * Add a component to the graph - * - * @param awComponent $component - */ - public function add(awComponent $component) { - - $this->components[] = $component; - - } - - /** - * Add a label to the component - * - * @param awLabel $label - * @param int $x Position on X axis of the center of the text - * @param int $y Position on Y axis of the center of the text - */ - public function addLabel(awLabel $label, $x, $y) { - - $this->labels[] = array( - $label, $x, $y - ); - - } - - /** - * Add a label to the component with absolute position - * - * @param awLabel $label - * @param awPoint $point Text position - */ - public function addAbsLabel(awLabel $label, awPoint $point) { - - $this->labels[] = array( - $label, $point - ); - - } - - /** - * Build the graph and draw component on it - * - * @param string $mode Display mode (can be a file name) - */ - public function draw($mode = Graph::DRAW_DISPLAY) { - - if($this->timing) { - $time = microtimeFloat(); - } - - $this->create(); - - foreach($this->components as $component) { - - $this->drawComponent($component); - - } - - $this->drawTitle(); - $this->drawShadow(); - $this->drawLabels(); - - if($this->timing) { - $this->drawTiming(microtimeFloat() - $time); - } - - // Create graph - $data = $this->get(); - - // Put the graph in the cache if needed - $this->cache($data); - - switch($mode) { - - case Graph::DRAW_DISPLAY : - $this->sendHeaders(); - echo $data; - break; - - case Graph::DRAW_RETURN : - return $data; - - default : - if(is_string($mode)) { - file_put_contents($mode, $data); - } else { - awImage::drawError("Class Graph: Unable to draw the graph."); - } - - } - - } - - private function drawLabels() { - - $driver = $this->getDriver(); - - foreach($this->labels as $array) { - - if(count($array) === 3) { - - // Text in relative position - list($label, $x, $y) = $array; - - $point = new awPoint( - $x * $this->width, - $y * $this->height - ); - - } else { - - // Text in absolute position - list($label, $point) = $array; - - } - - $label->draw($driver, $point); - - } - - } - - private function drawTitle() { - - $driver = $this->getDriver(); - - $point = new awPoint( - $this->width / 2, - 10 - ); - - $this->title->draw($driver, $point); - - } - - private function drawTiming($time) { - - $driver = $this->getDriver(); - - $label = new awLabel; - $label->set("(".sprintf("%.3f", $time)." s)"); - $label->setAlign(awLabel::LEFT, awLabel::TOP); - $label->border->show(); - $label->setPadding(1, 0, 0, 0); - $label->setBackgroundColor(new awColor(230, 230, 230, 25)); - - $label->draw($driver, new awPoint(5, $driver->imageHeight - 5)); - - } - - private function cache($data) { - if(ARTICHOW_CACHE and $this->name !== NULL) { - - if(is_writable(ARTICHOW_CACHE_DIRECTORY) === FALSE) { - awImage::drawError("Class Graph: Cache directory is not writable."); - } - - file_put_contents($this->fileCache, $data); - file_put_contents($this->fileCacheTime, $this->timeout."\n".$this->getFormatString()); - - } - } - - private static function cleanGraphCache($file) { - - list( - $time, - $type - ) = explode("\n", file_get_contents($file)); - - $time = (int)$time; - - if($time !== 0 and $time < time()) { - return NULL; - } else { - return $type; - } - - - } - -} - -registerClass('Graph'); - -/* - * To preserve PHP 4 compatibility - */ -function microtimeFloat() { - list($usec, $sec) = explode(" ", microtime()); - return (float)$usec + (float)$sec; -} - diff --git a/modules/graphartichow/artichow/Image.class.php b/modules/graphartichow/artichow/Image.class.php deleted file mode 100644 index 129508e3f..000000000 --- a/modules/graphartichow/artichow/Image.class.php +++ /dev/null @@ -1,606 +0,0 @@ -background = new awColor(255, 255, 255); - $this->shadow = new awShadow(awShadow::RIGHT_BOTTOM); - $this->border = new awBorder; - - } - - /** - * Get driver of the image - * - * @param int $w Driver width (from 0 to 1) (default to 1) - * @param int $h Driver height (from 0 to 1) (default to 1) - * @param float $x Position on X axis of the center of the driver (default to 0.5) - * @param float $y Position on Y axis of the center of the driver (default to 0.5) - * @return Driver - */ - public function getDriver($w = 1, $h = 1, $x = 0.5, $y = 0.5) { - $this->create(); - $this->driver->setSize($w, $h); - $this->driver->setPosition($x, $y); - return $this->driver; - } - - /** - * Sets the driver that will be used to draw the graph - * - * @param string $driverString - */ - public function setDriver($driverString) { - $this->driver = $this->selectDriver($driverString); - - $this->driver->init($this); - } - - /** - * Change the image size - * - * @var int $width Image width - * @var int $height Image height - */ - public function setSize($width, $height) { - - if($width !== NULL) { - $this->width = (int)$width; - } - if($height !== NULL) { - $this->height = (int)$height; - } - - } - - /** - * Change image background - * - * @param mixed $background - */ - public function setBackground($background) { - if($background instanceof awColor) { - $this->setBackgroundColor($background); - } elseif($background instanceof awGradient) { - $this->setBackgroundGradient($background); - } - } - - /** - * Change image background color - * - * @param awColor $color - */ - public function setBackgroundColor(awColor $color) { - $this->background = $color; - } - - /** - * Change image background gradient - * - * @param awGradient $gradient - */ - public function setBackgroundGradient(awGradient $gradient) { - $this->background = $gradient; - } - - /** - * Return image background, whether a Color or a Gradient - * - * @return mixed - */ - public function getBackground() { - return $this->background; - } - - /** - * Turn antialiasing on or off - * - * @var bool $bool - */ - public function setAntiAliasing($bool) { - $this->antiAliasing = (bool)$bool; - } - - /** - * Return the antialiasing setting - * - * @return bool - */ - public function getAntiAliasing() { - return $this->antiAliasing; - } - - /** - * Change image format - * - * @var int $format New image format - */ - public function setFormat($format) { - if($format === awImage::JPEG or $format === awImage::PNG or $format === awImage::GIF) { - $this->format = $format; - } - } - - /** - * Returns the image format as an integer - * - * @return unknown - */ - public function getFormat() { - return $this->format; - } - - /** - * Returns the image format as a string - * - * @return string - */ - public function getFormatString() { - - switch($this->format) { - case awImage::JPEG : - return 'jpeg'; - case awImage::PNG : - return 'png'; - case awImage::GIF : - return 'gif'; - } - - } - - /** - * Create a new awimage - */ - public function create() { - - if($this->driver === NULL) { - $driver = $this->selectDriver($this->driverString); - - $driver->init($this); - - $this->driver = $driver; - } - - } - - /** - * Select the correct driver - * - * @param string $driver The desired driver - * @return mixed - */ - protected function selectDriver($driver) { - $drivers = array('gd'); - $driver = strtolower((string)$driver); - - if(in_array($driver, $drivers, TRUE)) { - $string = $driver; - } else { - $string = ARTICHOW_DRIVER; - } - - switch ($string) { - case 'gd': - require_once ARTICHOW.'/inc/drivers/gd.class.php'; - $this->driverString = $string; - return new awGDDriver(); - - default: - // We should never get here, unless the wrong string is used AND the ARTICHOW_DRIVER - // global has been messed with. - awImage::drawError('Class Image: Unknown driver type (\''.$string.'\')'); - break; - } - } - - /** - * Draw a component on the image - * - * @var awComponent $component A component - */ - public function drawComponent(awComponent $component) { - - $shadow = $this->shadow->getSpace(); // Image shadow - $border = $this->border->visible() ? 1 : 0; // Image border size - - $driver = clone $this->driver; - $driver->setImageSize( - $this->width - $shadow->left - $shadow->right - $border * 2, - $this->height - $shadow->top - $shadow->bottom - $border * 2 - ); - - // No absolute size specified - if($component->w === NULL and $component->h === NULL) { - - list($width, $height) = $driver->setSize($component->width, $component->height); - - // Set component size in pixels - $component->setAbsSize($width, $height); - - } else { - - $driver->setAbsSize($component->w, $component->h); - - } - - if($component->top !== NULL and $component->left !== NULL) { - $driver->setAbsPosition( - $border + $shadow->left + $component->left, - $border + $shadow->top + $component->top - ); - } else { - $driver->setPosition($component->x, $component->y); - } - - $driver->movePosition($border + $shadow->left, $border + $shadow->top); - - list($x1, $y1, $x2, $y2) = $component->getPosition(); - - $component->init($driver); - - $component->drawComponent($driver, $x1, $y1, $x2, $y2, $this->antiAliasing); - $component->drawEnvelope($driver, $x1, $y1, $x2, $y2); - - $component->finalize($driver); - - } - - protected function drawShadow() { - - $driver = $this->getDriver(); - - $this->shadow->draw( - $driver, - new awPoint(0, 0), - new awPoint($this->width, $this->height), - awShadow::IN - ); - - } - - /** - * Send the image into a file or to the user browser - * - */ - public function send() { - $this->driver->send($this); - } - - /** - * Return the image content as binary data - * - */ - public function get() { - return $this->driver->get($this); - } - - /** - * Send the correct HTTP header according to the image type - * - */ - public function sendHeaders() { - - if(headers_sent() === FALSE) { - - switch ($this->driverString) { - case 'gd' : - header('Content-type: image/'.$this->getFormatString()); - break; - - } - - } - - } - - - private static $errorWriting = FALSE; - - - /* - * Display an error image and exit - * - * @param string $message Error message - */ - public static function drawError($message) { - - - if(self::$errorWriting) { - return; - } - - self::$errorWriting = TRUE; - - $message = wordwrap($message, 40, "\n", TRUE); - - $width = 400; - $height = max(100, 40 + 22.5 * (substr_count($message, "\n") + 1)); - - $image = new awImage(); - $image->setSize($width, $height); - $image->setDriver('gd'); - - $driver = $image->getDriver(); - $driver->init($image); - - // Display title - $driver->filledRectangle( - new awWhite, - new awLine( - new awPoint(0, 0), - new awPoint($width, $height) - ) - ); - - $driver->filledRectangle( - new awRed, - new awLine( - new awPoint(0, 0), - new awPoint(110, 25) - ) - ); - - $text = new awText( - "Artichow error", - new awFont3, - new awWhite, - 0 - ); - - $driver->string($text, new awPoint(5, 6)); - - // Display red box - $driver->rectangle( - new awRed, - new awLine( - new awPoint(0, 25), - new awPoint($width - 90, $height - 1) - ) - ); - - // Display error image - $file = ARTICHOW_IMAGE.DIRECTORY_SEPARATOR.'error.png'; - - $imageError = new awFileImage($file); - $driver->copyImage( - $imageError, - new awPoint($width - 81, $height - 81), - new awPoint($width - 1, $height - 1) - ); - - // Draw message - $text = new awText( - strip_tags($message), - new awFont2, - new awBlack, - 0 - ); - - $driver->string($text, new awPoint(10, 40)); - - $image->send(); - - exit; - - } - - /* - * Display an error image located in a file and exit - * - * @param string $error Error name - */ - public static function drawErrorFile($error) { - - $file = ARTICHOW_IMAGE.DIRECTORY_SEPARATOR.'errors'.DIRECTORY_SEPARATOR.$error.'.png'; - - header("Content-Type: image/png"); - readfile($file); - exit; - - } - -} - -registerClass('Image'); - - -/** - * Load an image from a file - * - * @package Artichow - */ -class awFileImage extends awImage { - - /** - * Build a new awimage - * - * @param string $file Image file name - */ - public function __construct($file) { - - $driver = $this->selectDriver($this->driverString); - - $driver->initFromFile($this, $file); - - $this->driver = $driver; - - } - -} - -registerClass('FileImage'); - - diff --git a/modules/graphartichow/artichow/LinePlot.class.php b/modules/graphartichow/artichow/LinePlot.class.php deleted file mode 100644 index e2a494c39..000000000 --- a/modules/graphartichow/artichow/LinePlot.class.php +++ /dev/null @@ -1,585 +0,0 @@ -mark = new awMark; - $this->label = new awLabel; - - $this->lineMode = (int)$mode; - - $this->setValues($values); - - } - - /** - * Hide line - * - * @param bool $hide - */ - public function hideLine($hide) { - $this->lineHide = (bool)$hide; - } - - /** - * Add a filled area - * - * @param int $start Begining of the area - * @param int $end End of the area - * @param mixed $background Background color or gradient of the area - */ - public function setFilledArea($start, $stop, $background) { - - if($stop <= $start) { - awImage::drawError("Class LinePlot: End position can not be greater than begin position in setFilledArea()."); - } - - $this->areas[] = array((int)$start, (int)$stop, $background); - - } - - /** - * Change line color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->lineColor = $color; - } - - /** - * Change line style - * - * @param int $style - */ - public function setStyle($style) { - $this->lineStyle = (int)$style; - } - - /** - * Change line tickness - * - * @param int $tickness - */ - public function setThickness($tickness) { - $this->lineThickness = (int)$tickness; - } - - /** - * Change line background color - * - * @param awColor $color - */ - public function setFillColor(awColor $color) { - $this->lineBackground = $color; - } - - /** - * Change line background gradient - * - * @param awGradient $gradient - */ - public function setFillGradient(awGradient $gradient) { - $this->lineBackground = $gradient; - } - - /** - * Get the line thickness - * - * @return int - */ - public function getLegendLineThickness() { - return $this->lineThickness; - } - - /** - * Get the line type - * - * @return int - */ - public function getLegendLineStyle() { - return $this->lineStyle; - } - - /** - * Get the color of line - * - * @return Color - */ - public function getLegendLineColor() { - return $this->lineColor; - } - - /** - * Get the background color or gradient of an element of the component - * - * @return Color, Gradient - */ - public function getLegendBackground() { - return $this->lineBackground; - } - - /** - * Get a mark object - * - * @return Mark - */ - public function getLegendMark() { - return $this->mark; - } - - public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { - - $max = $this->getRealYMax(); - $min = $this->getRealYMin(); - - // Get start and stop values - list($start, $stop) = $this->getLimit(); - - if($this->lineMode === awLinePlot::MIDDLE) { - $inc = $this->xAxis->getDistance(0, 1) / 2; - } else { - $inc = 0; - } - - // Build the polygon - $polygon = new awPolygon; - - for($key = $start; $key <= $stop; $key++) { - - $value = $this->datay[$key]; - - if($value !== NULL) { - - $p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $value)); - $p = $p->move($inc, 0); - $polygon->set($key, $p); - - } - - } - - // Draw backgrounds - if($this->lineBackground instanceof awColor or $this->lineBackground instanceof awGradient) { - - $backgroundPolygon = new awPolygon; - - $p = $this->xAxisPoint($start); - $p = $p->move($inc, 0); - $backgroundPolygon->append($p); - - // Add others points - foreach($polygon->all() as $point) { - $backgroundPolygon->append(clone $point); - } - - $p = $this->xAxisPoint($stop); - $p = $p->move($inc, 0); - $backgroundPolygon->append($p); - - // Draw polygon background - $driver->filledPolygon($this->lineBackground, $backgroundPolygon); - - } - - $this->drawArea($driver, $polygon); - - // Draw line - $prev = NULL; - - // Line color - if($this->lineHide === FALSE) { - - if($this->lineColor === NULL) { - $this->lineColor = new awColor(0, 0, 0); - } - - foreach($polygon->all() as $point) { - - if($prev !== NULL) { - $driver->line( - $this->lineColor, - new awLine( - $prev, - $point, - $this->lineStyle, - $this->lineThickness - ) - ); - } - $prev = $point; - - } - - } - - // Draw marks and labels - foreach($polygon->all() as $key => $point) { - - $this->mark->draw($driver, $point); - $this->label->draw($driver, $point, $key); - - } - - } - - protected function drawArea(awDriver $driver, awPolygon $polygon) { - - $starts = array(); - foreach($this->areas as $area) { - list($start) = $area; - $starts[$start] = TRUE; - } - - // Draw filled areas - foreach($this->areas as $area) { - - list($start, $stop, $background) = $area; - - $polygonArea = new awPolygon; - - $p = $this->xAxisPoint($start); - $polygonArea->append($p); - - for($i = $start; $i <= $stop; $i++) { - $p = clone $polygon->get($i); - if($i === $stop and array_key_exists($stop, $starts)) { - $p = $p->move(-1, 0); - } - $polygonArea->append($p); - } - - $p = $this->xAxisPoint($stop); - if(array_key_exists($stop, $starts)) { - $p = $p->move(-1, 0); - } - $polygonArea->append($p); - - // Draw area - $driver->filledPolygon($background, $polygonArea); - - } - - } - - public function getXAxisNumber() { - if($this->lineMode === awLinePlot::MIDDLE) { - return count($this->datay) + 1; - } else { - return count($this->datay); - } - } - - protected function xAxisPoint($position) { - $y = $this->xAxisZero ? 0 : $this->getRealYMin(); - return awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($position, $y)); - } - - public function getXCenter() { - return ($this->lineMode === awLinePlot::MIDDLE); - } - -} - -registerClass('LinePlot'); - - -/** - * Simple LinePlot - * Useful to draw simple horizontal lines - * - * @package Artichow - */ -class awSimpleLinePlot extends awPlot implements awLegendable { - - /** - * Line color - * - * @var Color - */ - protected $lineColor; - - /** - * Line start - * - * @var int - */ - protected $lineStart; - - /** - * Line stop - * - * @var int - */ - protected $lineStop; - - /** - * Line value - * - * @var flaot - */ - protected $lineValue; - - /** - * Line mode - * - * @var int - */ - protected $lineMode = awLinePlot::LINE; - - /** - * Line type - * - * @var int - */ - protected $lineStyle = awLine::SOLID; - - /** - * Line thickness - * - * @var int - */ - protected $lineThickness = 1; - - /** - * Line mode - * - * @var int - */ - const LINE = 0; - - /** - * Line in the middle - * - * @var int - */ - const MIDDLE = 1; - - /** - * Construct a new awLinePlot - * - * @param float $value A Y value - * @param int $start Line start index - * @param int $stop Line stop index - * @param int $mode Line mode - */ - public function __construct($value, $start, $stop, $mode = awLinePlot::LINE) { - - parent::__construct(); - - $this->lineMode = (int)$mode; - - $this->lineStart = (int)$start; - $this->lineStop = (int)$stop; - $this->lineValue = (float)$value; - - $this->lineColor = new awColor(0, 0, 0); - - } - - /** - * Change line color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->lineColor = $color; - } - - /** - * Change line style - * - * @param int $style - */ - public function setStyle($style) { - $this->lineStyle = (int)$style; - } - - /** - * Change line tickness - * - * @param int $tickness - */ - public function setThickness($tickness) { - $this->lineThickness = (int)$tickness; - } - - /** - * Get the line thickness - * - * @return int - */ - public function getLegendLineThickness() { - return $this->lineThickness; - } - - /** - * Get the line type - * - * @return int - */ - public function getLegendLineStyle() { - return $this->lineStyle; - } - - /** - * Get the color of line - * - * @return Color - */ - public function getLegendLineColor() { - return $this->lineColor; - } - - public function getLegendBackground() { - return NULL; - } - - public function getLegendMark() { - return NULL; - } - - public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { - - if($this->lineMode === awLinePlot::MIDDLE) { - $inc = $this->xAxis->getDistance(0, 1) / 2; - } else { - $inc = 0; - } - - $p1 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($this->lineStart, $this->lineValue)); - $p2 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($this->lineStop, $this->lineValue)); - - $driver->line( - $this->lineColor, - new awLine( - $p1->move($inc, 0), - $p2->move($inc, 0), - $this->lineStyle, - $this->lineThickness - ) - ); -} - - public function getXAxisNumber() { - if($this->lineMode === awLinePlot::MIDDLE) { - return count($this->datay) + 1; - } else { - return count($this->datay); - } - } - - protected function xAxisPoint($position) { - $y = $this->xAxisZero ? 0 : $this->getRealYMin(); - return awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($position, $y)); - } - - public function getXCenter() { - return ($this->lineMode === awLinePlot::MIDDLE); - } - -} - -registerClass('SimpleLinePlot'); - diff --git a/modules/graphartichow/artichow/MathPlot.class.php b/modules/graphartichow/artichow/MathPlot.class.php deleted file mode 100644 index 7d318207d..000000000 --- a/modules/graphartichow/artichow/MathPlot.class.php +++ /dev/null @@ -1,438 +0,0 @@ -f = (string)$f; - $this->fromX = is_null($fromX) ? NULL : (float)$fromX; - $this->toX = is_null($toX) ? NULL : (float)$toX; - - $this->line = new awLine; - $this->mark = new awMark; - $this->color = new awBlack; - - } - - /** - * Change line color - * - * @param awColor $color A new awcolor - */ - public function setColor(awColor $color) { - $this->color = $color; - } - - /** - * Get line color - * - * @return Color - */ - public function getColor() { - return $this->color; - } - - /** - * Get the background color or gradient of an element of the component - * - * @return Color, Gradient - */ - public function getLegendBackground() { - } - - /** - * Get the line thickness - * - * @return NULL - */ - public function getLegendLineThickness() { - return $this->line->getThickness(); - } - - /** - * Get the line type - * - * @return NULL - */ - public function getLegendLineStyle() { - return $this->line->getStyle(); - } - - /** - * Get the color of line - * - * @return NULL - */ - public function getLegendLineColor() { - return $this->color; - } - - /** - * Get a mark object - * - * @return NULL - */ - public function getLegendMark() { - return $this->mark; - } - -} - -registerClass('MathFunction'); - -/** - * For mathematics functions - * - * @package Artichow - */ -class awMathPlot extends awComponent { - - /** - * Functions - * - * @var array - */ - protected $functions = array(); - - /** - * Grid properties - * - * @var Grid - */ - public $grid; - - /** - * X axis - * - * @var Axis - */ - public $xAxis; - - /** - * Y axis - * - * @var Axis - */ - public $yAxis; - - /** - * Extremum - * - * @var Side - */ - private $extremum = NULL; - - /** - * Interval - * - * @var float - */ - private $interval = 1; - - /** - * Build the plot - * - * @param int $xMin Minimum X value - * @param int $xMax Maximum X value - * @param int $yMax Maximum Y value - * @param int $yMin Minimum Y value - */ - public function __construct($xMin, $xMax, $yMax, $yMin) { - - parent::__construct(); - - $this->setPadding(8, 8, 8, 8); - - $this->grid = new awGrid; - - // Hide grid by default - $this->grid->hide(TRUE); - - // Set extremum - $this->extremum = new awSide($xMin, $xMax, $yMax, $yMin); - - // Create axis - $this->xAxis = new awAxis; - $this->xAxis->setTickStyle(awTick::IN); - $this->xAxis->label->hideValue(0); - $this->initAxis($this->xAxis); - - $this->yAxis = new awAxis; - $this->yAxis->setTickStyle(awTick::IN); - $this->yAxis->label->hideValue(0); - $this->initAxis($this->yAxis); - - } - - protected function initAxis(awAxis $axis) { - - $axis->setLabelPrecision(1); - $axis->addTick('major', new awTick(0, 5)); - $axis->addTick('minor', new awTick(0, 3)); - $axis->addTick('micro', new awTick(0, 1)); - $axis->setNumberByTick('minor', 'major', 1); - $axis->setNumberByTick('micro', 'minor', 4); - $axis->label->setFont(new awTuffy(7)); - - } - - /** - * Interval to calculate values - * - * @param float $interval - */ - public function setInterval($interval) { - $this->interval = (float)$interval; - } - - /** - * Add a formula f(x) - * - * @param awMathFunction $function - * @param string $name Name for the legend (can be NULL if you don't want to set a legend) - * @param int $type Type for the legend - */ - public function add(awMathFunction $function, $name = NULL, $type = awLegend::LINE) { - - $this->functions[] = $function; - - if($name !== NULL) { - $this->legend->add($function, $name, $type); - } - - } - - public function init(awDriver $driver) { - - list($x1, $y1, $x2, $y2) = $this->getPosition(); - - $this->xAxis->line->setX($x1, $x2); - $this->xAxis->label->setAlign(NULL, awLabel::BOTTOM); - $this->xAxis->label->move(0, 3); - $this->xAxis->setRange($this->extremum->left, $this->extremum->right); - - $this->yAxis->line->setY($y2, $y1); - $this->yAxis->label->setAlign(awLabel::RIGHT); - $this->yAxis->label->move(-6, 0); - $this->yAxis->reverseTickStyle(); - $this->yAxis->setRange($this->extremum->bottom, $this->extremum->top); - - - $this->xAxis->setYCenter($this->yAxis, 0); - $this->yAxis->setXCenter($this->xAxis, 0); - - if($this->yAxis->getLabelNumber() === NULL) { - $number = $this->extremum->top - $this->extremum->bottom + 1; - $this->yAxis->setLabelNumber($number); - } - - if($this->xAxis->getLabelNumber() === NULL) { - $number = $this->extremum->right - $this->extremum->left + 1; - $this->xAxis->setLabelNumber($number); - } - - // Set ticks - - $this->xAxis->tick('major')->setNumber($this->xAxis->getLabelNumber()); - $this->yAxis->tick('major')->setNumber($this->yAxis->getLabelNumber()); - - - // Set axis labels - $labels = array(); - for($i = 0, $count = $this->xAxis->getLabelNumber(); $i < $count; $i++) { - $labels[] = $i; - } - $this->xAxis->label->set($labels); - - $labels = array(); - for($i = 0, $count = $this->yAxis->getLabelNumber(); $i < $count; $i++) { - $labels[] = $i; - } - $this->yAxis->label->set($labels); - - parent::init($driver); - - // Create the grid - $this->createGrid(); - - // Draw the grid - $this->grid->draw($driver, $x1, $y1, $x2, $y2); - - } - - public function drawEnvelope(awDriver $driver) { - - // Draw axis - $this->xAxis->draw($driver); - $this->yAxis->draw($driver); - - } - - public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { - - foreach($this->functions as $function) { - - $f = $function->f; - $fromX = is_null($function->fromX) ? $this->extremum->left : $function->fromX; - $toX = is_null($function->toX) ? $this->extremum->right : $function->toX; - - $old = NULL; - - for($i = $fromX; $i <= $toX; $i += $this->interval) { - - $p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($i, $f($i))); - - if($p->y >= $y1 and $p->y <= $y2) { - $function->mark->draw($driver, $p); - } - - if($old !== NULL) { - - $line = $function->line; - $line->setLocation($old, $p); - - if( - ($line->p1->y >= $y1 and $line->p1->y <= $y2) or - ($line->p2->y >= $y1 and $line->p2->y <= $y2) - ) { - $driver->line( - $function->getColor(), - $line - ); - } - - } - - $old = $p; - - } - - // Draw last point if needed - if($old !== NULL and $i - $this->interval != $toX) { - - $p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($toX, $f($toX))); - - if($p->y >= $y1 and $p->y <= $y2) { - $function->mark->draw($driver, $p); - } - - - $line = $function->line; - $line->setLocation($old, $p); - - if( - ($line->p1->y >= $y1 and $line->p1->y <= $y2) or - ($line->p2->y >= $y1 and $line->p2->y <= $y2) - ) { - $driver->line( - $function->getColor(), - $line - ); - } - - } - - } - - } - - protected function createGrid() { - - // Horizontal lines of the grid - - $major = $this->yAxis->tick('major'); - $interval = $major->getInterval(); - $number = $this->yAxis->getLabelNumber() - 1; - - $h = array(); - if($number > 0) { - for($i = 0; $i <= $number; $i++) { - $h[] = $i / $number; - } - } - - // Vertical lines - - $major = $this->xAxis->tick('major'); - $interval = $major->getInterval(); - $number = $this->xAxis->getLabelNumber() - 1; - - $w = array(); - if($number > 0) { - for($i = 0; $i <= $number; $i++) { - if($i%$interval === 0) { - $w[] = $i / $number; - } - } - } - - $this->grid->setGrid($w, $h); - - } - -} - -registerClass('MathPlot'); diff --git a/modules/graphartichow/artichow/Pattern.class.php b/modules/graphartichow/artichow/Pattern.class.php deleted file mode 100644 index 0eee7e1ee..000000000 --- a/modules/graphartichow/artichow/Pattern.class.php +++ /dev/null @@ -1,96 +0,0 @@ -args[$name] = $value; - } - } - - /** - * Get an argument - * - * @param string $name - * @param mixed $default Default value if the argument does not exist (default to NULL) - * @return mixed Argument value - */ - protected function getArg($name, $default = NULL) { - if(array_key_exists($name, $this->args)) { - return $this->args[$name]; - } else { - return $default; - } - } - - /** - * Change several arguments - * - * @param array $args New arguments - */ - public function setArgs($args) { - if(is_array($args)) { - foreach($args as $name => $value) { - $this->setArg($name, $value); - } - } - } - -} - -registerClass('Pattern', TRUE); diff --git a/modules/graphartichow/artichow/Pie.class.php b/modules/graphartichow/artichow/Pie.class.php deleted file mode 100644 index 8dec47825..000000000 --- a/modules/graphartichow/artichow/Pie.class.php +++ /dev/null @@ -1,694 +0,0 @@ -setValues($values); - - if(is_array($colors)) { - $this->colors = $colors; - } else { - - switch($colors) { - - case awPie::AQUA : - $this->colors = array( - new awColor(131, 220, 215), - new awColor(131, 190, 215), - new awColor(131, 160, 215), - new awColor(160, 140, 215), - new awColor(190, 131, 215), - new awColor(220, 131, 215) - ); - break; - - case awPie::EARTH : - $this->colors = array( - new awColor(97, 179, 110), - new awColor(130, 179, 97), - new awColor(168, 179, 97), - new awColor(179, 147, 97), - new awColor(179, 108, 97), - new awColor(99, 107, 189), - new awColor(99, 165, 189) - ); - break; - - case awPie::DARK : - $this->colors = array( - new awColor(140, 100, 170), - new awColor(130, 170, 100), - new awColor(160, 160, 120), - new awColor(150, 110, 140), - new awColor(130, 150, 160), - new awColor(90, 170, 140) - ); - break; - - default : - $this->colors = array( - new awColor(187, 213, 151), - new awColor(223, 177, 151), - new awColor(111, 186, 132), - new awColor(197, 160, 230), - new awColor(165, 169, 63), - new awColor(218, 177, 89), - new awColor(116, 205, 121), - new awColor(200, 201, 78), - new awColor(127, 205, 177), - new awColor(205, 160, 160), - new awColor(190, 190, 190) - ); - break; - - } - - } - - parent::__construct(); - - $this->label = new awLabel; - $this->label->setCallbackFunction('callbackPerCent'); - - } - - /** - * Change legend values - * - * @param array $legend An array of values for each part of the pie - */ - public function setLegend($legend) { - - $this->legendValues = (array)$legend; - - } - - /** - * Set a border all around the pie - * - * @param awColor $color A color for the border - */ - public function setBorderColor(awColor $color) { - $this->border = $color; - } - - /** - * Set a border all around the pie - * - * @param awColor $color A color for the border - */ - public function setBorder(awColor $color) { - if(ARTICHOW_DEPRECATED === TRUE) { - awImage::drawError('Class Pie: Method setBorder() has been deprecated since Artichow 1.0.9. Please use setBorderColor() instead.'); - } else { - $this->setBorderColor($color); - } - } - - /** - * Change 3D effect intensity - * - * @param int $size Effect size - */ - public function set3D($size) { - $this->size = (int)$size; - } - - /** - * Change initial angle - * - * @param int $angle New angle in degrees - */ - public function setStartAngle($angle) { - $this->angle = (int)$angle; - } - - /** - * Change label precision - * - * @param int $precision New precision - */ - public function setLabelPrecision($precision) { - $this->precision = (int)$precision; - } - - /** - * Change label position - * - * @param int $position New position in pixels - */ - public function setLabelPosition($position) { - $this->position = (int)$position; - } - - /** - * Change label number - * - * @param int $number New number - */ - public function setLabelNumber($number) { - $this->number = is_null($number) ? $number : (int)$number; - } - - /** - * Change label minimum - * - * @param int $minimum New minimum - */ - public function setLabelMinimum($minimum) { - $this->minimum = is_null($minimum) ? $minimum : (int)$minimum; - } - - /** - * Change Pie explode - * - * @param array $explode - */ - public function explode($explode) { - $this->explode = (array)$explode; - } - - public function drawEnvelope(awDriver $driver) { - - } - - public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { - - $count = count($this->values); - $sum = array_sum($this->values); - - $width = $x2 - $x1; - $height = $y2 - $y1; - - if($aliasing) { - $x = $width / 2; - $y = $height / 2; - } else { - $x = $width / 2 + $x1; - $y = $height / 2 + $y1; - } - - $position = $this->angle; - $values = array(); - $parts = array(); - $angles = 0; - - if($aliasing) { - $side = new awSide(0, 0, 0, 0); - } - - foreach($this->values as $key => $value) { - - $angle = ($value / $sum * 360); - - if($key === $count - 1) { - $angle = 360 - $angles; - } - - $angles += $angle; - - if(array_key_exists($key, $this->explode)) { - $middle = 360 - ($position + $angle / 2); - $posX = $this->explode[$key] * cos($middle * M_PI / 180); - $posY = $this->explode[$key] * sin($middle * M_PI / 180) * -1; - - if($aliasing) { - $explode = new awPoint( - $posX * 2, - $posY * 2 - ); - $side->set( - max($side->left, $posX * -2), - max($side->right, $posX * 2), - max($side->top, $posY * -2), - max($side->bottom, $posY * 2) - ); - } else { - $explode = new awPoint( - $posX, - $posY - ); - } - - } else { - $explode = new awPoint(0, 0); - } - - $values[$key] = array( - $position, ($position + $angle), $explode - ); - - $color = $this->colors[$key % count($this->colors)]; - $parts[$key] = new awPiePart($color); - - // Add part to the legend - $legend = array_key_exists($key, $this->legendValues) ? $this->legendValues[$key] : $key; - $this->legend->add($parts[$key], $legend, awLegend::BACKGROUND); - - $position += $angle; - - } - - if($aliasing) { - - $mainDriver = $driver; - - $x *= 2; - $y *= 2; - $width *= 2; - $height *= 2; - $this->size *= 2; - - $image = new awImage; - $image->border->hide(); - - // Adds support for antialiased pies on non-white background - $background = $this->getBackground(); - - if($background instanceof awColor) { - $image->setBackgroundColor($background); - } -// elseif($background instanceof awGradient) { -// $image->setBackgroundColor(new White(100)); -// } - - $image->setSize( - $width + $side->left + $side->right, - $height + $side->top + $side->bottom + $this->size + 1 /* bugs.php.net ! */ - ); - - $driver = $image->getDriver( - $width / $image->width, - $height / $image->height, - ($width / 2 + $side->left) / $image->width, - ($height / 2 + $side->top) / $image->height - ); - - } - - // Draw 3D effect - for($i = $this->size; $i > 0; $i--) { - - foreach($values as $key => $value) { - - $color = clone $this->colors[$key % count($this->colors)]; - $color->brightness(-50); - - list($from, $to, $explode) = $value; - - $driver->filledArc($color, $explode->move($x, $y + $i), $width, $height, $from, $to); - - unset($color); - - if($this->border instanceof awColor) { - - $point = $explode->move($x, $y); - - if($i === $this->size) { - - $driver->arc($this->border, $point->move(0, $this->size), $width, $height, $from, $to); - - } - - } - - } - - } - - foreach($values as $key => $value) { - - $color = $this->colors[$key % count($this->colors)]; - - list($from, $to, $explode) = $value; - - $driver->filledArc($color, $explode->move($x, $y), $width, $height, $from, $to); - - if($this->border instanceof awColor) { - - $point = $explode->move($x, $y); - $driver->arc($this->border, $point, $width, $height, $from, $to); - } - - } - - if($aliasing) { - - $x = $x / 2 + $x1; - $y = $y / 2 + $y1; - $width /= 2; - $height /= 2; - $this->size /= 2; - - foreach($values as $key => $value) { - $old = $values[$key][2]; - $values[$key][2] = new awPoint( - $old->x / 2, $old->y / 2 - ); - } - - $mainDriver->copyResizeImage( - $image, - new awPoint($x1 - $side->left / 2, $y1 - $side->top / 2), - new awPoint($x1 - $side->left / 2 + $image->width / 2, $y1 - $side->top / 2 + $image->height/ 2), - new awPoint(0, 0), - new awPoint($image->width, $image->height), - TRUE - ); - - $driver = $mainDriver; - - } - - // Get labels values - $pc = array(); - foreach($this->values as $key => $value) { - $pc[$key] = round($value / $sum * 100, $this->precision); - } - if($this->label->count() === 0) { // Check that there is no user defined values - $this->label->set($pc); - } - - $position = 0; - - foreach($pc as $key => $value) { - - // Limit number of labels to display - if($position === $this->number) { - break; - } - - if(is_null($this->minimum) === FALSE and $value < $this->minimum) { - continue; - } - - $position++; - - list($from, $to, $explode) = $values[$key]; - - $angle = $from + ($to - $from) / 2; - $angleRad = (360 - $angle) * M_PI / 180; - - $point = new awPoint( - $x + $explode->x + cos($angleRad) * ($width / 2 + $this->position), - $y + $explode->y - sin($angleRad) * ($height / 2 + $this->position) - ); - - $angle %= 360; - - // We don't display labels on the 3D effect - if($angle > 0 and $angle < 180) { - $point = $point->move(0, -1 * sin($angleRad) * $this->size); - } - - if($angle >= 45 and $angle < 135) { - $this->label->setAlign(awLabel::CENTER, awLabel::BOTTOM); - } else if($angle >= 135 and $angle < 225) { - $this->label->setAlign(awLabel::RIGHT, awLabel::MIDDLE); - } else if($angle >= 225 and $angle < 315) { - $this->label->setAlign(awLabel::CENTER, awLabel::TOP); - } else { - $this->label->setAlign(awLabel::LEFT, awLabel::MIDDLE); - } - - $this->label->draw( - $driver, - $point, - $key - ); - - } - - } - - /** - * Return margins around the component - * - * @return array Left, right, top and bottom margins - */ - public function getMargin() { - - // Get axis informations - - $leftAxis = $this->padding->left; - $rightAxis = $this->padding->right; - $topAxis = $this->padding->top; - $bottomAxis = $this->padding->bottom; - - return array($leftAxis, $rightAxis, $topAxis, $bottomAxis); - - } - - - /** - * Change values of Y axis - * This method ignores not numeric values - * - * @param array $values - */ - public function setValues($values) { - - $this->checkArray($values); - $this->values = $values; - - } - - - /** - * Return values of Y axis - * - * @return array - */ - public function getValues() { - return $this->values; - } - - private function checkArray(&$array) { - - if(is_array($array) === FALSE) { - awImage::drawError("Class Pie: You tried to set values that are not an array."); - } - - foreach($array as $key => $value) { - if(is_numeric($value) === FALSE) { - unset($array[$key]); - } - } - - if(count($array) < 1) { - awImage::drawError("Class Pie: Your graph must have at least 1 value."); - } - - } - -} - -registerClass('Pie'); - -/** - * Pie - * - * @package Artichow - */ -class awPiePart implements awLegendable { - - /** - * Pie part color - * - * @var Color - */ - protected $color; - - /** - * Build a new awPiePart - * - * @param awColor $color Pie part color - */ - public function __construct(awColor $color) { - - $this->color = $color; - - } - - /** - * Get the background color or gradient of an element of the component - * - * @return Color, Gradient - */ - public function getLegendBackground() { - return $this->color; - } - - /** - * Get the line thickness - * - * @return NULL - */ - public function getLegendLineThickness() { - } - - /** - * Get the line type - * - * @return NULL - */ - public function getLegendLineStyle() { - } - - /** - * Get the color of line - * - * @return NULL - */ - public function getLegendLineColor() { - } - - /** - * Get a mark object - * - * @return NULL - */ - public function getLegendMark() { - } - -} - -registerClass('PiePart'); - -function callbackPerCent($value) { - return $value.'%'; -} diff --git a/modules/graphartichow/artichow/Plot.class.php b/modules/graphartichow/artichow/Plot.class.php deleted file mode 100644 index 614b68efb..000000000 --- a/modules/graphartichow/artichow/Plot.class.php +++ /dev/null @@ -1,1463 +0,0 @@ -grid = new awGrid; - $this->grid->setBackgroundColor(new awWhite); - - $this->padding->add(20, 0, 0, 20); - - $this->xAxis = new awAxis; - $this->xAxis->addTick('major', new awTick(0, 5)); - $this->xAxis->addTick('minor', new awTick(0, 3)); - $this->xAxis->setTickStyle(awTick::OUT); - $this->xAxis->label->setFont(new awTuffy(7)); - - $this->yAxis = new awAxis; - $this->yAxis->auto(TRUE); - $this->yAxis->addTick('major', new awTick(0, 5)); - $this->yAxis->addTick('minor', new awTick(0, 3)); - $this->yAxis->setTickStyle(awTick::OUT); - $this->yAxis->setNumberByTick('minor', 'major', 3); - $this->yAxis->label->setFont(new awTuffy(7)); - $this->yAxis->title->setAngle(90); - - } - - /** - * Get plot values - * - * @return array - */ - public function getValues() { - return $this->datay; - } - - /** - * Reduce number of values in the plot - * - * @param int $number Reduce number of values to $number - */ - public function reduce($number) { - - $count = count($this->datay); - $ratio = ceil($count / $number); - - if($ratio > 1) { - - $tmpy = $this->datay; - $datay = array(); - - $datax = array(); - $cbLabel = $this->xAxis->label->getCallbackFunction(); - - for($i = 0; $i < $count; $i += $ratio) { - - $slice = array_slice($tmpy, $i, $ratio); - $datay[] = array_sum($slice) / count($slice); - - // Reduce data on X axis if needed - if($cbLabel !== NULL) { - $datax[] = $cbLabel($i + round($ratio / 2)); - } - - } - - $this->setValues($datay); - - if($cbLabel !== NULL) { - $this->xAxis->setLabelText($datax); - } - - - } - - } - - /** - * Count values in the plot - * - * @return int - */ - public function getXAxisNumber() { - list($min, $max) = $this->xAxis->getRange(); - return ($max - $min + 1); - } - - /** - * Change X axis - * - * @param int $axis - */ - public function setXAxis($axis) { - $this->xAxisPosition = $axis; - } - - /** - * Get X axis - * - * @return int - */ - public function getXAxis() { - return $this->xAxisPosition; - } - - /** - * Set X axis on zero - * - * @param bool $zero - */ - public function setXAxisZero($zero) { - $this->xAxisZero = (bool)$zero; - } - - /** - * Set Y axis on zero - * - * @param bool $zero - */ - public function setYAxisZero($zero) { - $this->yAxisZero = (bool)$zero; - } - - /** - * Change Y axis - * - * @param int $axis - */ - public function setYAxis($axis) { - $this->yAxisPosition = $axis; - } - - /** - * Get Y axis - * - * @return int - */ - public function getYAxis() { - return $this->yAxisPosition; - } - - /** - * Change min value for Y axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setYMin($value) { - $this->yMin = $value; - $this->yAxis->auto(FALSE); - $this->updateAxis(); - } - - /** - * Change max value for Y axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setYMax($value) { - $this->yMax = $value; - $this->yAxis->auto(FALSE); - $this->updateAxis(); - } - - /** - * Change min value for X axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setXMin($value) { - $this->xMin = $value; - $this->updateAxis(); - } - - /** - * Change max value for X axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setXMax($value) { - $this->xMax = $value; - $this->updateAxis(); - } - - /** - * Get min value for Y axis - * - * @return float $value - */ - public function getYMin() { - if($this->auto) { - if(is_null($this->yMin)) { - $min = array_min($this->datay); - if($min > 0) { - return 0; - } - } - } - return is_null($this->yMin) ? array_min($this->datay) : (float)$this->yMin; - } - - /** - * Get max value for Y axis - * - * @return float $value - */ - public function getYMax() { - if($this->auto) { - if(is_null($this->yMax)) { - $max = array_max($this->datay); - if($max < 0) { - return 0; - } - } - } - return is_null($this->yMax) ? array_max($this->datay) : (float)$this->yMax; - } - - /** - * Get min value for X axis - * - * @return float $value - */ - public function getXMin() { - return floor(is_null($this->xMin) ? array_min($this->datax) : $this->xMin); - } - - /** - * Get max value for X axis - * - * @return float $value - */ - public function getXMax() { - return (ceil(is_null($this->xMax) ? array_max($this->datax) : (float)$this->xMax)) + ($this->getXCenter() ? 1 : 0); - } - - /** - * Get min value with spaces for Y axis - * - * @return float $value - */ - public function getRealYMin() { - $min = $this->getYMin(); - if($this->space->bottom !== NULL) { - $interval = ($this->getYMax() - $min) * $this->space->bottom / 100; - return $min - $interval; - } else { - return is_null($this->yMin) ? $min : (float)$this->yMin; - } - } - - /** - * Get max value with spaces for Y axis - * - * @return float $value - */ - public function getRealYMax() { - $max = $this->getYMax(); - if($this->space->top !== NULL) { - $interval = ($max - $this->getYMin()) * $this->space->top / 100; - return $max + $interval; - } else { - return is_null($this->yMax) ? $max : (float)$this->yMax; - } - } - - public function init(awDriver $driver) { - - list($x1, $y1, $x2, $y2) = $this->getPosition(); - - // Get space informations - list($leftSpace, $rightSpace, $topSpace, $bottomSpace) = $this->getSpace($x2 - $x1, $y2 - $y1); - - $this->xAxis->setPadding($leftSpace, $rightSpace); - - if($this->space->bottom > 0 or $this->space->top > 0) { - - list($min, $max) = $this->yAxis->getRange(); - $interval = $max - $min; - - $this->yAxis->setRange( - $min - $interval * $this->space->bottom / 100, - $max + $interval * $this->space->top / 100 - ); - - } - - // Auto-scaling mode - $this->yAxis->autoScale(); - - // Number of labels is not specified - if($this->yAxis->getLabelNumber() === NULL) { - $number = round(($y2 - $y1) / 75) + 2; - $this->yAxis->setLabelNumber($number); - } - - $this->xAxis->line->setX($x1, $x2); - $this->yAxis->line->setY($y2, $y1); - - // Set ticks - - $this->xAxis->tick('major')->setNumber($this->getXAxisNumber()); - $this->yAxis->tick('major')->setNumber($this->yAxis->getLabelNumber()); - - - // Center X axis on zero - if($this->xAxisZero) { - $this->xAxis->setYCenter($this->yAxis, 0); - } - - // Center Y axis on zero - if($this->yAxisZero) { - $this->yAxis->setXCenter($this->xAxis, 0); - } - - // Set axis labels - $labels = array(); - - list($xMin, $xMax) = $this->xAxis->getRange(); - for($i = $xMin; $i <= $xMax; $i++) { - $labels[] = $i; - } - $this->xAxis->label->set($labels); - - parent::init($driver); - - list($x1, $y1, $x2, $y2) = $this->getPosition(); - - list($leftSpace, $rightSpace) = $this->getSpace($x2 - $x1, $y2 - $y1); - - // Create the grid - $this->createGrid(); - - // Draw the grid - $this->grid->setSpace($leftSpace, $rightSpace, 0, 0); - $this->grid->draw($driver, $x1, $y1, $x2, $y2); - - } - - public function drawEnvelope(awDriver $driver) { - - list($x1, $y1, $x2, $y2) = $this->getPosition(); - - if($this->getXCenter()) { - $size = $this->xAxis->getDistance(0, 1); - $this->xAxis->label->move($size / 2, 0); - $this->xAxis->label->hideLast(TRUE); - } - - // Draw top axis - if($this->xAxisPosition === awPlot::TOP or $this->xAxisPosition === awPlot::BOTH) { - $top = clone $this->xAxis; - if($this->xAxisZero === FALSE) { - $top->line->setY($y1, $y1); - } - $top->label->setAlign(NULL, awLabel::TOP); - $top->label->move(0, -3); - $top->title->move(0, -25); - $top->draw($driver); - } - - // Draw bottom axis - if($this->xAxisPosition === awPlot::BOTTOM or $this->xAxisPosition === awPlot::BOTH) { - $bottom = clone $this->xAxis; - if($this->xAxisZero === FALSE) { - $bottom->line->setY($y2, $y2); - } - $bottom->label->setAlign(NULL, awLabel::BOTTOM); - $bottom->label->move(0, 3); - $bottom->reverseTickStyle(); - $bottom->title->move(0, 25); - $bottom->draw($driver); - } - - // Draw left axis - if($this->yAxisPosition === awPlot::LEFT or $this->yAxisPosition === awPlot::BOTH) { - $left = clone $this->yAxis; - if($this->yAxisZero === FALSE) { - $left->line->setX($x1, $x1); - } - $left->label->setAlign(awLabel::RIGHT); - $left->label->move(-6, 0); - $left->title->move(-25, 0); - $left->draw($driver); - } - - // Draw right axis - if($this->yAxisPosition === awPlot::RIGHT or $this->yAxisPosition === awPlot::BOTH) { - $right = clone $this->yAxis; - if($this->yAxisZero === FALSE) { - $right->line->setX($x2, $x2); - } - $right->label->setAlign(awLabel::LEFT); - $right->label->move(6, 0); - $right->reverseTickStyle(); - $right->title->move(25, 0); - $right->draw($driver); - } - - } - - protected function createGrid() { - - $max = $this->getRealYMax(); - $min = $this->getRealYMin(); - - $number = $this->yAxis->getLabelNumber() - 1; - - if($number < 1) { - return; - } - - // Horizontal lines of the grid - - $h = array(); - for($i = 0; $i <= $number; $i++) { - $h[] = $i / $number; - } - - // Vertical lines - - $major = $this->yAxis->tick('major'); - $interval = $major->getInterval(); - $number = $this->getXAxisNumber() - 1; - - $w = array(); - - if($number > 0) { - - for($i = 0; $i <= $number; $i++) { - if($i%$interval === 0) { - $w[] = $i / $number; - } - } - - } - - $this->grid->setGrid($w, $h); - - } - - /** - * Change values of Y axis - * This method ignores not numeric values - * - * @param array $datay - * @param array $datax - */ - public function setValues($datay, $datax = NULL) { - - $this->checkArray($datay); - - foreach($datay as $key => $value) { - unset($datay[$key]); - $datay[(int)$key] = $value; - } - - if($datax === NULL) { - $datax = array(); - for($i = 0; $i < count($datay); $i++) { - $datax[] = $i; - } - } else { - foreach($datax as $key => $value) { - unset($datax[$key]); - $datax[(int)$key] = $value; - } - } - - $this->checkArray($datax); - - if(count($datay) === count($datax)) { - - // Set values - $this->datay = $datay; - $this->datax = $datax; - // Update axis with the new awvalues - $this->updateAxis(); - } else { - awImage::drawError("Class Plot: Plots must have the same number of X and Y points."); - } - - } - - /** - * Return begin and end values - * - * @return array - */ - protected function getLimit() { - - $i = 0; - while(array_key_exists($i, $this->datay) and $this->datay[$i] === NULL) { - $i++; - } - $start = $i; - $i = count($this->datay) - 1; - while(array_key_exists($i, $this->datay) and $this->datay[$i] === NULL) { - $i--; - } - $stop = $i; - - return array($start, $stop); - - } - - /** - * Return TRUE if labels must be centered on X axis, FALSE otherwise - * - * @return bool - */ - abstract public function getXCenter(); - - private function updateAxis() { - - $this->xAxis->setRange( - $this->getXMin(), - $this->getXMax() - ); - $this->yAxis->setRange( - $this->getRealYMin(), - $this->getRealYMax() - ); - - } - - private function checkArray(&$array) { - - if(is_array($array) === FALSE) { - awImage::drawError("Class Plot: You tried to set a value that is not an array."); - } - - foreach($array as $key => $value) { - if(is_numeric($value) === FALSE and is_null($value) === FALSE) { - awImage::drawError("Class Plot: Expected numeric values for the plot."); - } - } - - if(count($array) < 1) { - awImage::drawError("Class Plot: Your plot must have at least 1 value."); - } - - } - -} - -registerClass('Plot', TRUE); - -class awPlotAxis { - - /** - * Left axis - * - * @var Axis - */ - public $left; - - /** - * Right axis - * - * @var Axis - */ - public $right; - - /** - * Top axis - * - * @var Axis - */ - public $top; - - /** - * Bottom axis - * - * @var Axis - */ - public $bottom; - - /** - * Build the group of axis - */ - public function __construct() { - - $this->left = new awAxis; - $this->left->auto(TRUE); - $this->left->label->setAlign(awLabel::RIGHT); - $this->left->label->move(-6, 0); - $this->yAxis($this->left); - $this->left->setTickStyle(awTick::OUT); - $this->left->title->move(-25, 0); - - $this->right = new awAxis; - $this->right->auto(TRUE); - $this->right->label->setAlign(awLabel::LEFT); - $this->right->label->move(6, 0); - $this->yAxis($this->right); - $this->right->setTickStyle(awTick::IN); - $this->right->title->move(25, 0); - - $this->top = new awAxis; - $this->top->label->setAlign(NULL, awLabel::TOP); - $this->top->label->move(0, -3); - $this->xAxis($this->top); - $this->top->setTickStyle(awTick::OUT); - $this->top->title->move(0, -25); - - $this->bottom = new awAxis; - $this->bottom->label->setAlign(NULL, awLabel::BOTTOM); - $this->bottom->label->move(0, 3); - $this->xAxis($this->bottom); - $this->bottom->setTickStyle(awTick::IN); - $this->bottom->title->move(0, 25); - - } - - protected function xAxis(awAxis $axis) { - - $axis->addTick('major', new awTick(0, 5)); - $axis->addTick('minor', new awTick(0, 3)); - $axis->label->setFont(new awTuffy(7)); - - } - - protected function yAxis(awAxis $axis) { - - $axis->addTick('major', new awTick(0, 5)); - $axis->addTick('minor', new awTick(0, 3)); - $axis->setNumberByTick('minor', 'major', 3); - $axis->label->setFont(new awTuffy(7)); - $axis->title->setAngle(90); - - } - -} - -registerClass('PlotAxis'); - -/** - * A graph with axis can contain some groups of components - * - * @package Artichow - */ -class awPlotGroup extends awComponentGroup { - - /** - * Grid properties - * - * @var Grid - */ - public $grid; - - /** - * Left, right, top and bottom axis - * - * @var PlotAxis - */ - public $axis; - - /** - * Set the X axis on zero - * - * @var bool - */ - protected $xAxisZero = TRUE; - - /** - * Set the Y axis on zero - * - * @var bool - */ - protected $yAxisZero = FALSE; - - /** - * Real axis used for Y axis - * - * @var string - */ - private $yRealAxis = awPlot::LEFT; - - /** - * Real axis used for X axis - * - * @var string - */ - private $xRealAxis = awPlot::BOTTOM; - - /** - * Change min value for Y axis - * - * @var mixed - */ - private $yMin = NULL; - - /** - * Change max value for Y axis - * - * @var mixed - */ - private $yMax = NULL; - - /** - * Change min value for X axis - * - * @var mixed - */ - private $xMin = NULL; - - /** - * Change max value for X axis - * - * @var mixed - */ - private $xMax = NULL; - - /** - * Build the PlotGroup - * - */ - public function __construct() { - - parent::__construct(); - - $this->grid = new awGrid; - $this->grid->setBackgroundColor(new awWhite); - - $this->axis = new awPlotAxis; - - } - - /** - * Set the X axis on zero or not - * - * @param bool $zero - */ - public function setXAxisZero($zero) { - $this->xAxisZero = (bool)$zero; - } - - /** - * Set the Y axis on zero or not - * - * @param bool $zero - */ - public function setYAxisZero($zero) { - $this->yAxisZero = (bool)$zero; - } - - /** - * Change min value for Y axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setYMin($value) { - $this->axis->left->auto(FALSE); - $this->axis->right->auto(FALSE); - $this->yMin = $value; - } - - /** - * Change max value for Y axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setYMax($value) { - $this->axis->left->auto(FALSE); - $this->axis->right->auto(FALSE); - $this->yMax = $value; - } - - /** - * Change min value for X axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setXMin($value) { - $this->xMin = $value; - } - - /** - * Change max value for X axis - * Set NULL for auto selection. - * - * @param float $value - */ - public function setXMax($value) { - $this->xMax = $value; - } - - /** - * Get min value for X axis - * - * @return float $value - */ - public function getXMin() { - - return $this->getX('min'); - - } - - /** - * Get max value for X axis - * - * @return float $value - */ - public function getXMax() { - - return $this->getX('max'); - - } - - private function getX($type) { - - switch($type) { - case 'max' : - if($this->xMax !== NULL) { - return $this->xMax; - } - break; - case 'min' : - if($this->xMin !== NULL) { - return $this->xMin; - } - break; - } - - $value = NULL; - $get = 'getX'.ucfirst($type); - - for($i = 0; $i < count($this->components); $i++) { - - $component = $this->components[$i]; - - if($value === NULL) { - $value = $component->$get(); - } else { - $value = $type($value, $component->$get()); - } - - } - - return $value; - - } - - /** - * Get min value with spaces for Y axis - * - * @param string $axis Axis name - * @return float $value - */ - public function getRealYMin($axis = NULL) { - - if($axis === NULL) { - return NULL; - } - - $min = $this->getRealY('min', $axis); - $max = $this->getRealY('max', $axis); - - if($this->space->bottom !== NULL) { - $interval = ($min - $max) * $this->space->bottom / 100; - return $min + $interval; - } else { - return $min; - } - - } - - /** - * Get max value with spaces for Y axis - * - * @param string $axis Axis name - * @return float $value - */ - public function getRealYMax($axis = NULL) { - - if($axis === NULL) { - return NULL; - } - - $min = $this->getRealY('min', $axis); - $max = $this->getRealY('max', $axis); - - if($this->space->top !== NULL) { - $interval = ($max - $min) * $this->space->top / 100; - return $max + $interval; - } else { - return $max; - } - - } - - private function getRealY($type, $axis) { - - switch($type) { - case 'max' : - if($this->yMax !== NULL) { - return $this->yMax; - } - break; - case 'min' : - if($this->yMin !== NULL) { - return $this->yMin; - } - break; - } - - $value = NULL; - $get = 'getY'.ucfirst($type); - - for($i = 0; $i < count($this->components); $i++) { - - $component = $this->components[$i]; - - switch($axis) { - - case awPlot::LEFT : - case awPlot::RIGHT : - $test = ($component->getYAxis() === $axis); - break; - default : - $test = FALSE; - - } - - if($test) { - - $auto = $component->yAxis->isAuto(); - $this->axis->{$axis}->auto($auto); - - if($value === NULL) { - $value = $component->$get(); - } else { - $value = $type($value, $component->$get()); - } - - } - - } - - return $value; - - } - - public function init(awDriver $driver) { - - list($x1, $y1, $x2, $y2) = $this->getPosition(); - - // Get PlotGroup space - list($leftSpace, $rightSpace, $topSpace, $bottomSpace) = $this->getSpace($x2 - $x1, $y2 - $y1); - - // Count values in the group - $values = $this->getXAxisNumber(); - - // Init the PlotGroup - $this->axis->top->line->setX($x1, $x2); - $this->axis->bottom->line->setX($x1, $x2); - $this->axis->left->line->setY($y2, $y1); - $this->axis->right->line->setY($y2, $y1); - - $this->axis->top->setPadding($leftSpace, $rightSpace); - $this->axis->bottom->setPadding($leftSpace, $rightSpace); - - $xMin = $this->getXMin(); - $xMax = $this->getXMax(); - - $this->axis->top->setRange($xMin, $xMax); - $this->axis->bottom->setRange($xMin, $xMax); - - for($i = 0; $i < count($this->components); $i++) { - - - $component = $this->components[$i]; - - $component->auto($this->auto); - - // Copy space to the component - - $component->setSpace($this->space->left, $this->space->right, $this->space->top, $this->space->bottom); - - $component->xAxis->setPadding($leftSpace, $rightSpace); - $component->xAxis->line->setX($x1, $x2); - - $component->yAxis->line->setY($y2, $y1); - - } - - // Set Y axis range - foreach(array('left', 'right') as $axis) { - - if($this->isAxisUsed($axis)) { - - $min = $this->getRealYMin($axis); - $max = $this->getRealYMax($axis); - - $interval = $max - $min; - - $this->axis->{$axis}->setRange( - $min - $interval * $this->space->bottom / 100, - $max + $interval * $this->space->top / 100 - ); - - // Auto-scaling mode - if($this->axis->{$axis}->isAuto()) { - $this->axis->{$axis}->autoScale(); - } - - } - - } - - if($this->axis->left->getLabelNumber() === NULL) { - $number = round(($y2 - $y1) / 75) + 2; - $this->axis->left->setLabelNumber($number); - } - - if($this->axis->right->getLabelNumber() === NULL) { - $number = round(($y2 - $y1) / 75) + 2; - $this->axis->right->setLabelNumber($number); - } - - // Center labels on X axis if needed - $test = array(awPlot::TOP => FALSE, awPlot::BOTTOM => FALSE); - - for($i = 0; $i < count($this->components); $i++) { - - - $component = $this->components[$i]; - - - if($component->getValues() !== NULL) { - - $axis = $component->getXAxis(); - - if($test[$axis] === FALSE) { - - // Center labels for bar plots - if($component->getXCenter()) { - $size = $this->axis->{$axis}->getDistance(0, 1); - $this->axis->{$axis}->label->move($size / 2, 0); - $this->axis->{$axis}->label->hideLast(TRUE); - $test[$axis] = TRUE; - } - - } - - } - - - } - - // Set axis labels - $labels = array(); - for($i = $xMin; $i <= $xMax; $i++) { - $labels[] = $i; - } - if($this->axis->top->label->count() === 0) { - $this->axis->top->label->set($labels); - } - if($this->axis->bottom->label->count() === 0) { - $this->axis->bottom->label->set($labels); - } - - // Set ticks - - $this->axis->top->tick('major')->setNumber($values); - $this->axis->bottom->tick('major')->setNumber($values); - $this->axis->left->tick('major')->setNumber($this->axis->left->getLabelNumber()); - $this->axis->right->tick('major')->setNumber($this->axis->right->getLabelNumber()); - - - // Set X axis on zero - if($this->xAxisZero) { - $axis = $this->selectYAxis(); - $this->axis->bottom->setYCenter($axis, 0); - $this->axis->top->setYCenter($axis, 0); - } - - // Set Y axis on zero - if($this->yAxisZero) { - $axis = $this->selectXAxis(); - $this->axis->left->setXCenter($axis, 1); - $this->axis->right->setXCenter($axis, 1); - } - - parent::init($driver); - - list($leftSpace, $rightSpace, $topSpace, $bottomSpace) = $this->getSpace($x2 - $x1, $y2 - $y1); - - // Create the grid - $this->createGrid(); - - // Draw the grid - $this->grid->setSpace($leftSpace, $rightSpace, 0, 0); - $this->grid->draw($driver, $x1, $y1, $x2, $y2); - - } - - public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { - - $xMin = $this->getXMin(); - $xMax = $this->getXMax(); - - $maxLeft = $this->getRealYMax(awPlot::LEFT); - $maxRight = $this->getRealYMax(awPlot::RIGHT); - - $minLeft = $this->getRealYMin(awPlot::LEFT); - $minRight = $this->getRealYMin(awPlot::RIGHT); - - foreach($this->components as $component) { - - $min = $component->getYMin(); - $max = $component->getYMax(); - - // Set component minimum and maximum - if($component->getYAxis() === awPlot::LEFT) { - - list($min, $max) = $this->axis->left->getRange(); - - $component->setYMin($min); - $component->setYMax($max); - - } else { - - list($min, $max) = $this->axis->right->getRange(); - - $component->setYMin($min); - $component->setYMax($max); - - } - - $component->setXAxisZero($this->xAxisZero); - $component->setYAxisZero($this->yAxisZero); - - $component->xAxis->setRange($xMin, $xMax); - - $component->drawComponent( - $driver, - $x1, $y1, - $x2, $y2, - $aliasing - ); - - $component->setYMin($min); - $component->setYMax($max); - - } - - } - - public function drawEnvelope(awDriver $driver) { - - list($x1, $y1, $x2, $y2) = $this->getPosition(); - - // Hide unused axis - foreach(array(awPlot::LEFT, awPlot::RIGHT, awPlot::TOP, awPlot::BOTTOM) as $axis) { - if($this->isAxisUsed($axis) === FALSE) { - $this->axis->{$axis}->hide(TRUE); - } - } - - // Draw top axis - $top = $this->axis->top; - if($this->xAxisZero === FALSE) { - $top->line->setY($y1, $y1); - } - $top->draw($driver); - - // Draw bottom axis - $bottom = $this->axis->bottom; - if($this->xAxisZero === FALSE) { - $bottom->line->setY($y2, $y2); - } - $bottom->draw($driver); - - // Draw left axis - $left = $this->axis->left; - if($this->yAxisZero === FALSE) { - $left->line->setX($x1, $x1); - } - $left->draw($driver); - - // Draw right axis - $right = $this->axis->right; - if($this->yAxisZero === FALSE) { - $right->line->setX($x2, $x2); - } - $right->draw($driver); - - } - - /** - * Is the specified axis used ? - * - * @param string $axis Axis name - * @return bool - */ - protected function isAxisUsed($axis) { - - for($i = 0; $i < count($this->components); $i++) { - - $component = $this->components[$i]; - - switch($axis) { - - case awPlot::LEFT : - case awPlot::RIGHT : - if($component->getYAxis() === $axis) { - return TRUE; - } - break; - - case awPlot::TOP : - case awPlot::BOTTOM : - if($component->getXAxis() === $axis) { - return TRUE; - } - break; - - } - - } - - return FALSE; - - } - - protected function createGrid() { - - $max = $this->getRealYMax(awPlot::LEFT); - $min = $this->getRealYMin(awPlot::RIGHT); - - // Select axis (left if possible, right otherwise) - $axis = $this->selectYAxis(); - - $number = $axis->getLabelNumber() - 1; - - if($number < 1) { - return; - } - - // Horizontal lines of grid - - $h = array(); - for($i = 0; $i <= $number; $i++) { - $h[] = $i / $number; - } - - // Vertical lines - - $major = $axis->tick('major'); - $interval = $major->getInterval(); - $number = $this->getXAxisNumber() - 1; - - $w = array(); - - if($number > 0) { - - for($i = 0; $i <= $number; $i++) { - if($i%$interval === 0) { - $w[] = $i / $number; - } - } - - } - - $this->grid->setGrid($w, $h); - - } - - protected function selectYAxis(){ - - // Select axis (left if possible, right otherwise) - if($this->isAxisUsed(awPlot::LEFT)) { - $axis = $this->axis->left; - } else { - $axis = $this->axis->right; - } - - return $axis; - - } - - protected function selectXAxis(){ - - // Select axis (bottom if possible, top otherwise) - if($this->isAxisUsed(awPlot::BOTTOM)) { - $axis = $this->axis->bottom; - } else { - $axis = $this->axis->top; - } - - return $axis; - - } - - protected function getXAxisNumber() { - $offset = $this->components[0]; - $max = $offset->getXAxisNumber(); - for($i = 1; $i < count($this->components); $i++) { - $offset = $this->components[$i]; - $max = max($max, $offset->getXAxisNumber()); - } - return $max; - } - -} - -registerClass('PlotGroup'); diff --git a/modules/graphartichow/artichow/ScatterPlot.class.php b/modules/graphartichow/artichow/ScatterPlot.class.php deleted file mode 100644 index 7e01c1425..000000000 --- a/modules/graphartichow/artichow/ScatterPlot.class.php +++ /dev/null @@ -1,300 +0,0 @@ -mark = new awMark; - $this->mark->setType(awMark::CIRCLE); - $this->mark->setSize(7); - $this->mark->border->show(); - - $this->label = new awLabel; - - $this->setValues($datay, $datax); - $this->setColor(new awBlack); - - } - - /** - * Display plot as impulses - * - * @param awColor $impulse Impulses color (or NULL to disable impulses) - */ - public function setImpulse($color) { - $this->impulse = $color; - } - - /** - * Link scatter plot points - * - * @param bool $link - * @param awColor $color Line color (default to black) - */ - public function link($link, $color = NULL) { - $this->link = (bool)$link; - if($color instanceof awColor) { - $this->setColor($color); - } - } - - /** - * Ignore null values for Y data and continue linking - * - * @param bool $link - */ - public function linkNull($link) { - $this->linkNull = (bool)$link; - } - - /** - * Change line color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->lineColor = $color; - } - - /** - * Change line style - * - * @param int $style - */ - public function setStyle($style) { - $this->lineStyle = (int)$style; - } - - /** - * Change line tickness - * - * @param int $tickness - */ - public function setThickness($tickness) { - $this->lineThickness = (int)$tickness; - } - - /** - * Get the line thickness - * - * @return int - */ - public function getLegendLineThickness() { - return $this->lineThickness; - } - - /** - * Get the line type - * - * @return int - */ - public function getLegendLineStyle() { - return $this->lineStyle; - } - - /** - * Get the color of line - * - * @return Color - */ - public function getLegendLineColor() { - return $this->lineColor; - } - - /** - * Get the background color or gradient of an element of the component - * - * @return Color, Gradient - */ - public function getLegendBackground() { - return NULL; - } - - /** - * Get a mark object - * - * @return Mark - */ - public function getLegendMark() { - return $this->mark; - } - - public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) { - - $count = count($this->datay); - - // Get start and stop values - list($start, $stop) = $this->getLimit(); - - // Build the polygon - $polygon = new awPolygon; - - for($key = 0; $key < $count; $key++) { - - $x = $this->datax[$key]; - $y = $this->datay[$key]; - - if($y !== NULL) { - $p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($x, $y)); - $polygon->set($key, $p); - } else if($this->linkNull === FALSE) { - $polygon->set($key, NULL); - } - - } - - // Link points if needed - if($this->link) { - - $prev = NULL; - - foreach($polygon->all() as $point) { - - if($prev !== NULL and $point !== NULL) { - $driver->line( - $this->lineColor, - new awLine( - $prev, - $point, - $this->lineStyle, - $this->lineThickness - ) - ); - } - $prev = $point; - - } - } - - // Draw impulses - if($this->impulse instanceof awColor) { - - foreach($polygon->all() as $key => $point) { - - if($point !== NULL) { - - $zero = awAxis::toPosition( - $this->xAxis, - $this->yAxis, - new awPoint($key, 0) - ); - - $driver->line( - $this->impulse, - new awLine( - $zero, - $point, - awLine::SOLID, - 1 - ) - ); - - } - - } - - } - - // Draw marks and labels - foreach($polygon->all() as $key => $point) { - - $this->mark->draw($driver, $point); - $this->label->draw($driver, $point, $key); - - } - - } - - protected function xAxisPoint($position) { - $y = $this->xAxisZero ? 0 : $this->getRealYMin(); - return awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($position, $y)); - } - - public function getXCenter() { - return FALSE; - } - -} - -registerClass('ScatterPlot'); - diff --git a/modules/graphartichow/artichow/cache/Abel b/modules/graphartichow/artichow/cache/Abel deleted file mode 100644 index 82538a612..000000000 Binary files a/modules/graphartichow/artichow/cache/Abel and /dev/null differ diff --git a/modules/graphartichow/artichow/cache/Abel-time b/modules/graphartichow/artichow/cache/Abel-time deleted file mode 100644 index a730f38b1..000000000 --- a/modules/graphartichow/artichow/cache/Abel-time +++ /dev/null @@ -1,2 +0,0 @@ -1166203484 -png \ No newline at end of file diff --git a/modules/graphartichow/artichow/cache/Albert b/modules/graphartichow/artichow/cache/Albert deleted file mode 100644 index a40f42441..000000000 Binary files a/modules/graphartichow/artichow/cache/Albert and /dev/null differ diff --git a/modules/graphartichow/artichow/cache/Albert-time b/modules/graphartichow/artichow/cache/Albert-time deleted file mode 100644 index 7e2eb85de..000000000 --- a/modules/graphartichow/artichow/cache/Albert-time +++ /dev/null @@ -1,2 +0,0 @@ -1166203480 -png \ No newline at end of file diff --git a/modules/graphartichow/artichow/cache/Example-006 b/modules/graphartichow/artichow/cache/Example-006 deleted file mode 100644 index a16839b7d..000000000 Binary files a/modules/graphartichow/artichow/cache/Example-006 and /dev/null differ diff --git a/modules/graphartichow/artichow/cache/Example-006-time b/modules/graphartichow/artichow/cache/Example-006-time deleted file mode 100644 index 615edc04f..000000000 --- a/modules/graphartichow/artichow/cache/Example-006-time +++ /dev/null @@ -1,2 +0,0 @@ -1204776421 -png \ No newline at end of file diff --git a/modules/graphartichow/artichow/cache/index.php b/modules/graphartichow/artichow/cache/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/cache/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/artichow/common.php b/modules/graphartichow/artichow/common.php deleted file mode 100644 index f4e6e042f..000000000 --- a/modules/graphartichow/artichow/common.php +++ /dev/null @@ -1,96 +0,0 @@ - 0) { - - do { - $min = array_pop($array); - if(is_numeric($min) === FALSE) { - $min = NULL; - } - } while(count($array) > 0 and $min === NULL); - - if($min !== NULL) { - $min = (float)$min; - } - - foreach($array as $value) { - if(is_numeric($value) and (float)$value < $min) { - $min = (float)$value; - } - } - - return $min; - - } - - return NULL; - -} - -/* - * Get the maximum of an array and ignore non numeric values - */ -function array_max($array) { - - if(is_array($array) and count($array) > 0) { - - do { - $max = array_pop($array); - if(is_numeric($max) === FALSE) { - $max = NULL; - } - } while(count($array) > 0 and $max === NULL); - - if($max !== NULL) { - $max = (float)$max; - } - - foreach($array as $value) { - if(is_numeric($value) and (float)$value > $max) { - $max = (float)$value; - } - } - - return $max; - - } - - return NULL; - -} -/* - * Define file_put_contents() if needed - */ -if(function_exists('file_put_contents') === FALSE) { - - function file_put_contents($file, $content) { - $fp = fopen($file, 'w'); - if($fp) { - fwrite($fp, $content); - fclose($fp); - } - } - -} - -/* - * Change error handler - */ -set_error_handler('errorHandlerArtichow'); - -function errorHandlerArtichow($level, $message, $file, $line) { - awImage::drawError($message.' in '.$file.' on line '.$line.'.'); -} - diff --git a/modules/graphartichow/artichow/font/Tuffy.ttf b/modules/graphartichow/artichow/font/Tuffy.ttf deleted file mode 100644 index 8151817be..000000000 Binary files a/modules/graphartichow/artichow/font/Tuffy.ttf and /dev/null differ diff --git a/modules/graphartichow/artichow/font/TuffyBold.ttf b/modules/graphartichow/artichow/font/TuffyBold.ttf deleted file mode 100644 index 2f45b4f17..000000000 Binary files a/modules/graphartichow/artichow/font/TuffyBold.ttf and /dev/null differ diff --git a/modules/graphartichow/artichow/font/TuffyBoldItalic.ttf b/modules/graphartichow/artichow/font/TuffyBoldItalic.ttf deleted file mode 100644 index 554faf202..000000000 Binary files a/modules/graphartichow/artichow/font/TuffyBoldItalic.ttf and /dev/null differ diff --git a/modules/graphartichow/artichow/font/TuffyItalic.ttf b/modules/graphartichow/artichow/font/TuffyItalic.ttf deleted file mode 100644 index 5f972ec08..000000000 Binary files a/modules/graphartichow/artichow/font/TuffyItalic.ttf and /dev/null differ diff --git a/modules/graphartichow/artichow/font/index.php b/modules/graphartichow/artichow/font/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/font/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/artichow/images/book.png b/modules/graphartichow/artichow/images/book.png deleted file mode 100644 index da1885100..000000000 Binary files a/modules/graphartichow/artichow/images/book.png and /dev/null differ diff --git a/modules/graphartichow/artichow/images/error.png b/modules/graphartichow/artichow/images/error.png deleted file mode 100644 index e5addb110..000000000 Binary files a/modules/graphartichow/artichow/images/error.png and /dev/null differ diff --git a/modules/graphartichow/artichow/images/errors/index.php b/modules/graphartichow/artichow/images/errors/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/images/errors/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/artichow/images/errors/missing-anti-aliasing.png b/modules/graphartichow/artichow/images/errors/missing-anti-aliasing.png deleted file mode 100644 index f020d263f..000000000 Binary files a/modules/graphartichow/artichow/images/errors/missing-anti-aliasing.png and /dev/null differ diff --git a/modules/graphartichow/artichow/images/errors/missing-gd2.png b/modules/graphartichow/artichow/images/errors/missing-gd2.png deleted file mode 100644 index cac144cb8..000000000 Binary files a/modules/graphartichow/artichow/images/errors/missing-gd2.png and /dev/null differ diff --git a/modules/graphartichow/artichow/images/index.php b/modules/graphartichow/artichow/images/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/images/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/artichow/images/paperclip.png b/modules/graphartichow/artichow/images/paperclip.png deleted file mode 100644 index 12188f90c..000000000 Binary files a/modules/graphartichow/artichow/images/paperclip.png and /dev/null differ diff --git a/modules/graphartichow/artichow/images/star.png b/modules/graphartichow/artichow/images/star.png deleted file mode 100644 index 4acf00330..000000000 Binary files a/modules/graphartichow/artichow/images/star.png and /dev/null differ diff --git a/modules/graphartichow/artichow/inc/Axis.class.php b/modules/graphartichow/artichow/inc/Axis.class.php deleted file mode 100644 index 4eb4ce7d4..000000000 --- a/modules/graphartichow/artichow/inc/Axis.class.php +++ /dev/null @@ -1,768 +0,0 @@ - 'toProportionalValue', - 'toPosition' => 'toProportionalPosition' - ); - - /** - * Build the axis - * - * @param float $min Begin of the range of the axis - * @param float $max End of the range of the axis - */ - public function __construct($min = NULL, $max = NULL) { - - $this->line = new awVector( - new awPoint(0, 0), - new awPoint(0, 0) - ); - - $this->label = new awLabel; - $this->padding = new awSide; - - $this->title = new awLabel( - NULL, - NULL, - NULL, - 0 - ); - - $this->setColor(new awBlack); - - if($min !== NULL and $max !== NULL) { - $this->setRange($min, $max); - } - - } - - /** - * Enable/disable auto-scaling mode - * - * @param bool $auto - */ - public function auto($auto) { - $this->auto = (bool)$auto; - } - - /** - * Get auto-scaling mode status - * - * @return bool - */ - public function isAuto() { - return $this->auto; - } - - /** - * Hide axis - * - * @param bool $hide - */ - public function hide($hide = TRUE) { - $this->hide = (bool)$hide; - } - - /** - * Show axis - * - * @param bool $show - */ - public function show($show = TRUE) { - $this->hide = !(bool)$show; - } - - /** - * Return a tick object from its name - * - * @param string $name Tick object name - * @return Tick - */ - public function tick($name) { - - return array_key_exists($name, $this->ticks) ? $this->ticks[$name] : NULL; - - } - - /** - * Add a tick object - * - * @param string $name Tick object name - * @param awTick $tick Tick object - */ - public function addTick($name, awTick $tick) { - - $this->ticks[$name] = $tick; - - } - - /** - * Delete a tick object - * - * @param string $name Tick object name - */ - public function deleteTick($name) { - if(array_key_exists($name, $this->ticks)) { - unset($this->ticks[$name]); - } - } - - /** - * Hide all ticks - * - * @param bool $hide Hide or not ? - */ - public function hideTicks($hide = TRUE) { - - foreach($this->ticks as $tick) { - $tick->hide($hide); - } - - } - - /** - * Change ticks style - * - * @param int $style Ticks style - */ - public function setTickStyle($style) { - - foreach($this->ticks as $tick) { - $tick->setStyle($style); - } - - } - - /** - * Change ticks interval - * - * @param int $interval Ticks interval - */ - public function setTickInterval($interval) { - - foreach($this->ticks as $tick) { - $tick->setInterval($interval); - } - - } - - /** - * Change number of ticks relative to others ticks - * - * @param awTick $to Change number of theses ticks - * @param awTick $from Ticks reference - * @param float $number Number of ticks by the reference - */ - public function setNumberByTick($to, $from, $number) { - $this->ticks[$to]->setNumberByTick($this->ticks[$from], $number); - } - - /** - * Reverse ticks style - */ - public function reverseTickStyle() { - - foreach($this->ticks as $tick) { - if($tick->getStyle() === awTick::IN) { - $tick->setStyle(awTick::OUT); - } else if($tick->getStyle() === awTick::OUT) { - $tick->setStyle(awTick::IN); - } - } - - } - - /** - * Change interval of labels - * - * @param int $interval Interval - */ - public function setLabelInterval($interval) { - $this->auto(FALSE); - $this->setTickInterval($interval); - $this->label->setInterval($interval); - } - - /** - * Change number of labels - * - * @param int $number Number of labels to display (can be NULL) - */ - public function setLabelNumber($number) { - $this->auto(FALSE); - $this->labelNumber = is_null($number) ? NULL : (int)$number; - } - - /** - * Get number of labels - * - * @return int - */ - public function getLabelNumber() { - return $this->labelNumber; - } - - /** - * Change precision of labels - * - * @param int $precision Precision - */ - public function setLabelPrecision($precision) { - $this->auto(FALSE); - $function = 'axis'.time().'_'.(microtime() * 1000000); - eval('function '.$function.'($value) { - return sprintf("%.'.(int)$precision.'f", $value); - }'); - $this->label->setCallbackFunction($function); - } - - /** - * Change text of labels - * - * @param array $texts Some texts - */ - public function setLabelText($texts) { - if(is_array($texts)) { - $this->auto(FALSE); - $function = 'axis'.time().'_'.(microtime() * 1000000); - eval('function '.$function.'($value) { - $texts = '.var_export($texts, TRUE).'; - return isset($texts[$value]) ? $texts[$value] : \'?\'; - }'); - $this->label->setCallbackFunction($function); - } - } - - /** - * Get the position of a point - * - * @param awAxis $xAxis X axis - * @param awAxis $yAxis Y axis - * @param awPoint $p Position of the point - * @return Point Position on the axis - */ - public static function toPosition(awAxis $xAxis, awAxis $yAxis, awPoint $p) { - - $p1 = $xAxis->getPointFromValue($p->x); - $p2 = $yAxis->getPointFromValue($p->y); - - return new awPoint( - round($p1->x), - round($p2->y) - ); - - } - - /** - * Change title alignment - * - * @param int $alignment New Alignment - */ - public function setTitleAlignment($alignment) { - - switch($alignment) { - - case awLabel::TOP : - $this->setTitlePosition(1); - $this->title->setAlign(NULL, awLabel::BOTTOM); - break; - - case awLabel::BOTTOM : - $this->setTitlePosition(0); - $this->title->setAlign(NULL, awLabel::TOP); - break; - - case awLabel::LEFT : - $this->setTitlePosition(0); - $this->title->setAlign(awLabel::LEFT); - break; - - case awLabel::RIGHT : - $this->setTitlePosition(1); - $this->title->setAlign(awLabel::RIGHT); - break; - - } - - } - - /** - * Change title position on the axis - * - * @param float $position A new awposition between 0 and 1 - */ - public function setTitlePosition($position) { - $this->titlePosition = (float)$position; - } - - /** - * Change axis and axis title color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->color = $color; - $this->title->setColor($color); - } - - /** - * Change axis padding - * - * @param int $left Left padding in pixels - * @param int $right Right padding in pixels - */ - public function setPadding($left, $right) { - $this->padding->set($left, $right); - } - - /** - * Get axis padding - * - * @return Side - */ - public function getPadding() { - return $this->padding; - } - - /** - * Change axis range - * - * @param float $min - * @param float $max - */ - public function setRange($min, $max) { - if($min !== NULL) { - $this->range[0] = (float)$min; - } - if($max !== NULL) { - $this->range[1] = (float)$max; - } - } - - /** - * Get axis range - * - * @return array - */ - public function getRange() { - return $this->range; - } - - /** - * Change axis range callback function - * - * @param string $toValue Transform a position between 0 and 1 to a value - * @param string $toPosition Transform a value to a position between 0 and 1 on the axis - */ - public function setRangeCallback($toValue, $toPosition) { - $this->rangeCallback = array( - 'toValue' => (string)$toValue, - 'toPosition' => (string)$toPosition - ); - } - - /** - * Center X values of the axis - * - * @param awAxis $axis An axis - * @param float $value The reference value on the axis - */ - public function setXCenter(awAxis $axis, $value) { - - // Check vector angle - if($this->line->isVertical() === FALSE) { - awImage::drawError("Class Axis: setXCenter() can only be used on vertical axes."); - } - - $p = $axis->getPointFromValue($value); - - $this->line->setX( - $p->x, - $p->x - ); - - } - - /** - * Center Y values of the axis - * - * @param awAxis $axis An axis - * @param float $value The reference value on the axis - */ - public function setYCenter(awAxis $axis, $value) { - - // Check vector angle - if($this->line->isHorizontal() === FALSE) { - awImage::drawError("Class Axis: setYCenter() can only be used on horizontal axes."); - } - - $p = $axis->getPointFromValue($value); - - $this->line->setY( - $p->y, - $p->y - ); - - } - - /** - * Get the distance between to values on the axis - * - * @param float $from The first value - * @param float $to The last value - * @return Point - */ - public function getDistance($from, $to) { - - $p1 = $this->getPointFromValue($from); - $p2 = $this->getPointFromValue($to); - - return $p1->getDistance($p2); - - } - - /** - * Get a point on the axis from a value - * - * @param float $value - * @return Point - */ - protected function getPointFromValue($value) { - - $callback = $this->rangeCallback['toPosition']; - - list($min, $max) = $this->range; - $position = $callback($value, $min, $max); - - return $this->getPointFromPosition($position); - - } - - /** - * Get a point on the axis from a position - * - * @param float $position A position between 0 and 1 - * @return Point - */ - protected function getPointFromPosition($position) { - - $vector = $this->getVector(); - - $angle = $vector->getAngle(); - $size = $vector->getSize(); - - return $vector->p1->move( - cos($angle) * $size * $position, - -1 * sin($angle) * $size * $position - ); - - } - - /** - * Draw axis - * - * @param awDriver $driver A driver - */ - public function draw(awDriver $driver) { - - if($this->hide) { - return; - } - - $vector = $this->getVector(); - - // Draw axis ticks - $this->drawTicks($driver, $vector); - - // Draw axis line - $this->line($driver); - - // Draw labels - $this->drawLabels($driver); - - // Draw axis title - $p = $this->getPointFromPosition($this->titlePosition); - $this->title->draw($driver, $p); - - } - - public function autoScale() { - - if($this->isAuto() === FALSE) { - return; - } - - list($min, $max) = $this->getRange(); - $interval = $max - $min; - - if($interval > 0) { - $partMax = $max / $interval; - $partMin = $min / $interval; - } else { - $partMax = 0; - $partMin = 0; - } - - $difference = log($interval) / log(10); - $difference = floor($difference); - - $pow = pow(10, $difference); - - if($pow > 0) { - $intervalNormalize = $interval / $pow; - } else { - $intervalNormalize = 0; - } - - if($difference <= 0) { - - $precision = $difference * -1 + 1; - - if($intervalNormalize > 2) { - $precision--; - } - - } else { - $precision = 0; - } - - if($min != 0 and $max != 0) { - $precision++; - } - - if($this->label->getCallbackFunction() === NULL) { - $this->setLabelPrecision($precision); - } - - if($intervalNormalize <= 1.5) { - $intervalReal = 1.5; - $labelNumber = 4; - } else if($intervalNormalize <= 2) { - $intervalReal = 2; - $labelNumber = 5; - } else if($intervalNormalize <= 3) { - $intervalReal = 3; - $labelNumber = 4; - } else if($intervalNormalize <= 4) { - $intervalReal = 4; - $labelNumber = 5; - } else if($intervalNormalize <= 5) { - $intervalReal = 5; - $labelNumber = 6; - } else if($intervalNormalize <= 8) { - $intervalReal = 8; - $labelNumber = 5; - } else if($intervalNormalize <= 10) { - $intervalReal = 10; - $labelNumber = 6; - } - - if($min == 0) { - - $this->setRange( - $min, - $intervalReal * $pow - ); - - } else if($max == 0) { - - $this->setRange( - $intervalReal * $pow * -1, - 0 - ); - - } - - $this->setLabelNumber($labelNumber); - - } - - protected function line(awDriver $driver) { - - $driver->line( - $this->color, - $this->line - ); - - } - - protected function drawTicks(awDriver $driver, awVector $vector) { - - foreach($this->ticks as $tick) { - $tick->setColor($this->color); - $tick->draw($driver, $vector); - } - - } - - protected function drawLabels($driver) { - - if($this->labelNumber !== NULL) { - list($min, $max) = $this->range; - $number = $this->labelNumber - 1; - if($number < 1) { - return; - } - $function = $this->rangeCallback['toValue']; - $labels = array(); - for($i = 0; $i <= $number; $i++) { - $labels[] = $function($i / $number, $min, $max); - } - $this->label->set($labels); - } - - $labels = $this->label->count(); - - for($i = 0; $i < $labels; $i++) { - - $p = $this->getPointFromValue($this->label->get($i)); - $this->label->draw($driver, $p, $i); - - } - - } - - protected function getVector() { - - $angle = $this->line->getAngle(); - - // Compute paddings - $vector = new awVector( - $this->line->p1->move( - cos($angle) * $this->padding->left, - -1 * sin($angle) * $this->padding->left - ), - $this->line->p2->move( - -1 * cos($angle) * $this->padding->right, - -1 * -1 * sin($angle) * $this->padding->right - ) - ); - - return $vector; - - } - - public function __clone() { - - $this->label = clone $this->label; - $this->line = clone $this->line; - $this->title = clone $this->title; - - foreach($this->ticks as $name => $tick) { - $this->ticks[$name] = clone $tick; - } - - } - -} - -registerClass('Axis'); - -function toProportionalValue($position, $min, $max) { - return $min + ($max - $min) * $position; -} - -function toProportionalPosition($value, $min, $max) { - if($max - $min == 0) { - return 0; - } - return ($value - $min) / ($max - $min); -} diff --git a/modules/graphartichow/artichow/inc/Border.class.php b/modules/graphartichow/artichow/inc/Border.class.php deleted file mode 100644 index 6e8fc41fc..000000000 --- a/modules/graphartichow/artichow/inc/Border.class.php +++ /dev/null @@ -1,197 +0,0 @@ -setStyle($style); - - if($color instanceof awColor) { - $this->setColor($color); - } else { - $this->setColor(new awBlack); - } - - } - - /** - * Change border color - * This method automatically shows the border if it is hidden - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->color = $color; - $this->show(); - } - - /** - * Change border style - * - * @param int $style - */ - public function setStyle($style) { - $this->style = (int)$style; - } - - /** - * Hide border ? - * - * @param bool $hide - */ - public function hide($hide = TRUE) { - $this->hide = (bool)$hide; - } - - /** - * Show border ? - * - * @param bool $show - */ - public function show($show = TRUE) { - $this->hide = (bool)!$show; - } - - /** - * Is the border visible ? - * - * @return bool - */ - public function visible() { - return !$this->hide; - } - - /** - * Draw border as a rectangle - * - * @param awDriver $driver - * @param awPoint $p1 Top-left corner - * @param awPoint $p2 Bottom-right corner - */ - public function rectangle(awDriver $driver, awPoint $p1, awPoint $p2) { - - // Border is hidden - if($this->hide) { - return; - } - - $line = new awLine; - $line->setStyle($this->style); - $line->setLocation($p1, $p2); - - $driver->rectangle($this->color, $line); - - } - - /** - * Draw border as an ellipse - * - * @param awDriver $driver - * @param awPoint $center Ellipse center - * @param int $width Ellipse width - * @param int $height Ellipse height - */ - public function ellipse(awDriver $driver, awPoint $center, $width, $height) { - - // Border is hidden - if($this->hide) { - return; - } - - switch($this->style) { - - case awLine::SOLID : - $driver->ellipse($this->color, $center, $width, $height); - break; - - default : - awImage::drawError("Class Border: Dashed and dotted borders and not yet implemented on ellipses."); - break; - - } - - - } - - /** - * Draw border as a polygon - * - * @param awDriver $driver A Driver object - * @param awPolygon $polygon A Polygon object - */ - public function polygon(awDriver $driver, awPolygon $polygon) { - - // Border is hidden - if($this->hide) { - return; - } - - $polygon->setStyle($this->style); - $driver->polygon($this->color, $polygon); - - // In case of Line::SOLID, Driver::polygon() uses imagepolygon() - // which automatically closes the shape. In any other case, - // we have to do it manually here. - if($this->style !== Line::SOLID) { - $this->closePolygon($driver, $polygon); - } - } - - /** - * Draws the last line of a Polygon, between the first and last point - * - * @param awDriver $driver A Driver object - * @param awPolygon $polygon The polygon object to close - */ - private function closePolygon(awDriver $driver, awPolygon $polygon) { - $first = $polygon->get(0); - $last = $polygon->get($polygon->count() - 1); - - $line = new awLine($first, $last, $this->style, $polygon->getThickness()); - $driver->line($this->color, $line); - } - -} - -registerClass('Border'); diff --git a/modules/graphartichow/artichow/inc/Color.class.php b/modules/graphartichow/artichow/inc/Color.class.php deleted file mode 100644 index 40a7a93fb..000000000 --- a/modules/graphartichow/artichow/inc/Color.class.php +++ /dev/null @@ -1,165 +0,0 @@ -red = (int)$red; - $this->green = (int)$green; - $this->blue = (int)$blue; - $this->alpha = (int)round($alpha * 127 / 100); - - } - - /** - * Get RGB and alpha values of your color - * - * @return array - */ - public function getColor() { - return $this->rgba(); - } - - /** - * Change color brightness - * - * @param int $brightness Add this intensity to the color (betweeen -255 and +255) - */ - public function brightness($brightness) { - - $brightness = (int)$brightness; - - $this->red = min(255, max(0, $this->red + $brightness)); - $this->green = min(255, max(0, $this->green + $brightness)); - $this->blue = min(255, max(0, $this->blue + $brightness)); - - } - - /** - * Get RGB and alpha values of your color - * - * @return array - */ - public function rgba() { - - return array($this->red, $this->green, $this->blue, $this->alpha); - - } - -} - -registerClass('Color'); - -$colors = array( - 'Black' => array(0, 0, 0), - 'AlmostBlack' => array(48, 48, 48), - 'VeryDarkGray' => array(88, 88, 88), - 'DarkGray' => array(128, 128, 128), - 'MidGray' => array(160, 160, 160), - 'LightGray' => array(195, 195, 195), - 'VeryLightGray' => array(220, 220, 220), - 'White' => array(255, 255, 255), - 'VeryDarkRed' => array(64, 0, 0), - 'DarkRed' => array(128, 0, 0), - 'MidRed' => array(192, 0, 0), - 'Red' => array(255, 0, 0), - 'LightRed' => array(255, 192, 192), - 'VeryDarkGreen' => array(0, 64, 0), - 'DarkGreen' => array(0, 128, 0), - 'MidGreen' => array(0, 192, 0), - 'Green' => array(0, 255, 0), - 'LightGreen' => array(192, 255, 192), - 'VeryDarkBlue' => array(0, 0, 64), - 'DarkBlue' => array(0, 0, 128), - 'MidBlue' => array(0, 0, 192), - 'Blue' => array(0, 0, 255), - 'LightBlue' => array(192, 192, 255), - 'VeryDarkYellow' => array(64, 64, 0), - 'DarkYellow' => array(128, 128, 0), - 'MidYellow' => array(192, 192, 0), - 'Yellow' => array(255, 255, 2), - 'LightYellow' => array(255, 255, 192), - 'VeryDarkCyan' => array(0, 64, 64), - 'DarkCyan' => array(0, 128, 128), - 'MidCyan' => array(0, 192, 192), - 'Cyan' => array(0, 255, 255), - 'LightCyan' => array(192, 255, 255), - 'VeryDarkMagenta' => array(64, 0, 64), - 'DarkMagenta' => array(128, 0, 128), - 'MidMagenta' => array(192, 0, 192), - 'Magenta' => array(255, 0, 255), - 'LightMagenta' => array(255, 192, 255), - 'DarkOrange' => array(192, 88, 0), - 'Orange' => array(255, 128, 0), - 'LightOrange' => array(255, 168, 88), - 'VeryLightOrange' => array(255, 220, 168), - 'DarkPink' => array(192, 0, 88), - 'Pink' => array(255, 0, 128), - 'LightPink' => array(255, 88, 168), - 'VeryLightPink' => array(255, 168, 220), - 'DarkPurple' => array(88, 0, 192), - 'Purple' => array(128, 0, 255), - 'LightPurple' => array(168, 88, 255), - 'VeryLightPurple' => array(220, 168, 255), -); - - - -$php = ''; - -foreach($colors as $name => $color) { - - list($red, $green, $blue) = $color; - - $php .= ' - class aw'.$name.' extends awColor { - - public function __construct($alpha = 0) { - parent::__construct('.$red.', '.$green.', '.$blue.', $alpha); - } - - } - '; - - if(ARTICHOW_PREFIX !== 'aw') { - $php .= ' - class '.ARTICHOW_PREFIX.$name.' extends aw'.$name.' { - - } - '; - } - -} - -eval($php); - - - - diff --git a/modules/graphartichow/artichow/inc/Driver.class.php b/modules/graphartichow/artichow/inc/Driver.class.php deleted file mode 100644 index 345b01698..000000000 --- a/modules/graphartichow/artichow/inc/Driver.class.php +++ /dev/null @@ -1,724 +0,0 @@ -phpFontDriver = new awPHPFontDriver(); - $this->fileFontDriver = new awFileFontDriver(); - } - - /** - * Initialize the driver for a particular awImage object - * - * @param awImage $image - */ - abstract public function init(awImage $image); - - /** - * Initialize the Driver for a particular FileImage object - * - * @param awFileImage $fileImage The FileImage object to work on - * @param string $file Image filename - */ - abstract public function initFromFile(awFileImage $fileImage, $file); - - /** - * Change the image size - * - * @param int $width Image width - * @param int $height Image height - */ - abstract public function setImageSize($width, $height); - - /** - * Inform the driver of the position of your image - * - * @param float $x Position on X axis of the center of the component - * @param float $y Position on Y axis of the center of the component - */ - abstract public function setPosition($x, $y); - - /** - * Inform the driver of the position of your image - * This method need absolutes values - * - * @param int $x Left-top corner X position - * @param int $y Left-top corner Y position - */ - abstract public function setAbsPosition($x, $y); - - /** - * Move the position of the image - * - * @param int $x Add this value to X axis - * @param int $y Add this value to Y axis - */ - abstract public function movePosition($x, $y); - - /** - * Inform the driver of the size of your image - * Height and width must be between 0 and 1. - * - * @param int $w Image width - * @param int $h Image height - * @return array Absolute width and height of the image - */ - abstract public function setSize($w, $h); - - /** - * Inform the driver of the size of your image - * You can set absolute size with this method. - * - * @param int $w Image width - * @param int $h Image height - */ - abstract public function setAbsSize($w, $h); - - /** - * Get the size of the component handled by the driver - * - * @return array Absolute width and height of the component - */ - abstract public function getSize(); - - /** - * Turn antialiasing on or off - * - * @var bool $bool - */ - abstract public function setAntiAliasing($bool); - - /** - * When passed a Color object, returns the corresponding - * color identifier (driver dependant). - * - * @param awColor $color A Color object - * @return int $rgb A color identifier representing the color composed of the given RGB components - */ - abstract public function getColor(awColor $color); - - /** - * Draw an image here - * - * @param awImage $image Image - * @param int $p1 Image top-left point - * @param int $p2 Image bottom-right point - */ - abstract public function copyImage(awImage $image, awPoint $p1, awPoint $p2); - - /** - * Draw an image here - * - * @param awImage $image Image - * @param int $d1 Destination top-left position - * @param int $d2 Destination bottom-right position - * @param int $s1 Source top-left position - * @param int $s2 Source bottom-right position - * @param bool $resample Resample image ? (default to TRUE) - */ - abstract public function copyResizeImage(awImage $image, awPoint $d1, awPoint $d2, awPoint $s1, awPoint $s2, $resample = TRUE); - - /** - * Draw a string - * - * @var awText $text Text to print - * @param awPoint $point Draw the text at this point - * @param int $width Text max width - */ - abstract public function string(awText $text, awPoint $point, $width = NULL); - - /** - * Draw a pixel - * - * @param awColor $color Pixel color - * @param awPoint $p - */ - abstract public function point(awColor $color, awPoint $p); - - /** - * Draw a colored line - * - * @param awColor $color Line color - * @param awLine $line - * @param int $thickness Line tickness - */ - abstract public function line(awColor $color, awLine $line); - - /** - * Draw a color arc - - * @param awColor $color Arc color - * @param awPoint $center Point center - * @param int $width Ellipse width - * @param int $height Ellipse height - * @param int $from Start angle - * @param int $to End angle - */ - abstract public function arc(awColor $color, awPoint $center, $width, $height, $from, $to); - - /** - * Draw an arc with a background color - * - * @param awColor $color Arc background color - * @param awPoint $center Point center - * @param int $width Ellipse width - * @param int $height Ellipse height - * @param int $from Start angle - * @param int $to End angle - */ - abstract public function filledArc(awColor $color, awPoint $center, $width, $height, $from, $to); - - /** - * Draw a colored ellipse - * - * @param awColor $color Ellipse color - * @param awPoint $center Ellipse center - * @param int $width Ellipse width - * @param int $height Ellipse height - */ - abstract public function ellipse(awColor $color, awPoint $center, $width, $height); - - /** - * Draw an ellipse with a background - * - * @param mixed $background Background (can be a color or a gradient) - * @param awPoint $center Ellipse center - * @param int $width Ellipse width - * @param int $height Ellipse height - */ - abstract public function filledEllipse($background, awPoint $center, $width, $height); - - /** - * Draw a colored rectangle - * - * @param awColor $color Rectangle color - * @param awLine $line Rectangle diagonale - * @param awPoint $p2 - */ - abstract public function rectangle(awColor $color, awLine $line); - - /** - * Draw a rectangle with a background - * - * @param mixed $background Background (can be a color or a gradient) - * @param awLine $line Rectangle diagonale - */ - abstract public function filledRectangle($background, awLine $line); - - /** - * Draw a polygon - * - * @param awColor $color Polygon color - * @param Polygon A polygon - */ - abstract public function polygon(awColor $color, awPolygon $polygon); - - /** - * Draw a polygon with a background - * - * @param mixed $background Background (can be a color or a gradient) - * @param Polygon A polygon - */ - abstract public function filledPolygon($background, awPolygon $polygon); - - /** - * Sends the image, as well as the correct HTTP headers, to the browser - * - * @param awImage $image The Image object to send - */ - abstract public function send(awImage $image); - - /** - * Get the image as binary data - * - * @param awImage $image - */ - abstract public function get(awImage $image); - - /** - * Return the width of some text - * - * @param awText $text - */ - abstract public function getTextWidth(awText $text); - - /** - * Return the height of some text - * - * @param awText $text - */ - abstract public function getTextHeight(awText $text); - - /** - * Return the string representing the type of driver - * - * @return string - */ - public function getDriverString() { - return $this->driverString; - } - - /** - * Returns whether or not the driver is compatible with the given font type - * - * @param awFont $font - * @return bool - */ - abstract protected function isCompatibleWithFont(awFont $font); - -// abstract private function drawImage(awImage $image, $return = FALSE, $header = TRUE); - -} - -registerClass('Driver', TRUE); - -/** - * Abstract class for font drivers. - * Those are used to do all the grunt work on fonts. - * - * @package Artichow - */ - -abstract class awFontDriver { - - public function __construct() { - - } - - /** - * Draw the actual text. - * - * @param awDriver $driver The Driver object to draw upon - * @param awText $text The Text object - * @param awPoint $point Where to draw the text - * @param float $width The width of the area containing the text - */ - abstract public function string(awDriver $driver, awText $text, awPoint $point, $width = NULL); - - /** - * Calculate the width of a given Text. - * - * @param awText $text The Text object - * @param awDriver $driver The awDriver object used to draw the graph - */ - abstract public function getTextWidth(awText $text, awDriver $driver); - - /** - * Calculate the height of a given Text. - * - * @param awText $text The Text object - * @param awDriver $driver The awDriver object used to draw the graph - */ - abstract public function getTextHeight(awText $text, awDriver $driver); - -} - -registerClass('FontDriver', TRUE); - -/** - * Class to handle calculations on PHPFont objects - * - * @package Artichow - */ -class awPHPFontDriver extends awFontDriver { - - public function __construct() { - parent::__construct(); - } - - public function string(awDriver $driver, awText $text, awPoint $point, $width = NULL) { - - switch ($driver->getDriverString()) { - case 'gd': - $this->gdString($driver, $text, $point, $width); - break; - - default: - awImage::drawError('Class PHPFontDriver: Incompatibility between driver and font - You should never see this error message: have you called awDriver::isCompatibleWithFont() properly?'); - break; - - } - } - - /** - * Draw a string onto a GDDriver object - * - * @param awGDDriver $driver The GDDriver to draw the text upon - * @param awText $text The awText object containing the string to draw - * @param awPoint $point Where to draw the text - * @param float $width The width of the text - */ - private function gdString(awGDDriver $driver, awText $text, awPoint $point, $width = NULL) { - - $angle = $text->getAngle(); - if($angle !== 90 and $angle !== 0) { - awImage::drawError("Class PHPFontDriver: You can only use 0° and 90° angles."); - } - - if($angle === 90) { - $function = 'imagestringup'; - $addAngle = $this->getGDTextHeight($text); - } else { - $function = 'imagestring'; - $addAngle = 0; - } - - $color = $text->getColor(); - $rgb = $driver->getColor($color); - - $textString = $text->getText(); - $textString = str_replace("\r", "", $textString); - - $textHeight = $this->getGDTextHeight($text); - - // Split text if needed - if($width !== NULL) { - - $characters = floor($width / ($this->getGDTextWidth($text) / strlen($textString))); - - if($characters > 0) { - $textString = wordwrap($textString, $characters, "\n", TRUE); - } - - } - - $font = $text->getFont(); - $lines = explode("\n", $textString); - - foreach($lines as $i => $line) { - - // Line position handling - if($angle === 90) { - $addX = $i * $textHeight; - $addY = 0; - } else { - $addX = 0; - $addY = $i * $textHeight; - } - - $function( - $driver->resource, - $font->font, - $driver->x + $point->x + $addX, - $driver->y + $point->y + $addY + $addAngle, - $line, - $rgb - ); - - } - } - - public function getTextWidth(awText $text, awDriver $driver) { - - switch ($driver->getDriverString()) { - case 'gd': - return $this->getGDTextWidth($text); - - default: - awImage::drawError('Class PHPFontDriver: Cannot get text width - incompatibility between driver and font'); - break; - } - - } - - public function getTextHeight(awText $text, awDriver $driver) { - - switch ($driver->getDriverString()) { - case 'gd': - return $this->getGDTextHeight($text); - - default: - awImage::drawError('Class PHPFontDriver: Cannot get text height - incompatibility between driver and font'); - break; - } - - } - - /** - * Return the width of a text for a GDDriver - * - * @param awText $text - * @return int $fontWidth - */ - private function getGDTextWidth(awText $text) { - $font = $text->getFont(); - - if($text->getAngle() === 90) { - $text->setAngle(45); - return $this->getGDTextHeight($text); - } else if($text->getAngle() === 45) { - $text->setAngle(90); - } - - $fontWidth = imagefontwidth($font->font); - - if($fontWidth === FALSE) { - awImage::drawError("Class PHPFontDriver: Unable to get font size."); - } - - return (int)$fontWidth * strlen($text->getText()); - } - - /** - * Return the height of a text for a GDDriver - * - * @param awText $text - * @return int $fontHeight - */ - private function getGDTextHeight(awText $text) { - $font = $text->getFont(); - - if($text->getAngle() === 90) { - $text->setAngle(45); - return $this->getGDTextWidth($text); - } else if($text->getAngle() === 45) { - $text->setAngle(90); - } - - $fontHeight = imagefontheight($font->font); - - if($fontHeight === FALSE) { - awImage::drawError("Class PHPFontDriver: Unable to get font size."); - } - - return (int)$fontHeight; - } -} - -registerClass('PHPFontDriver'); - -/** - * Class to handle calculations on FileFont objects - * - * @package Artichow - */ -class awFileFontDriver extends awFontDriver { - - public function __construct() { - parent::__construct(); - } - - public function string(awDriver $driver, awText $text, awPoint $point, $width = NULL) { - - switch ($driver->getDriverString()) { - case 'gd': - $this->gdString($driver, $text, $point, $width); - break; - - default: - awImage::drawError('Class fileFontDriver: Incompatibility between driver and font - You should never see this error message: have you called awDriver::isCompatibleWithFont() properly?'); - break; - } - } - - /** - * Draw an awFileFont object on a GD ressource - * - * @param awGDDriver $driver The awGDDriver object containing the ressource to draw upon - * @param awText $text The awText object containing the string to draw - * @param awPoint $point Where to draw the string from - * @param float $width The width of the area containing the text - */ - private function gdString(awGDDriver $driver, awText $text, awPoint $point, $width = NULL) { - // Make easier font positionment - $text->setText($text->getText()." "); - - $font = $text->getFont(); - if($font instanceof awTTFFont === FALSE and $font->getExtension() === NULL) { - $font->setExtension('ttf'); - } - - $filePath = $font->getName().'.'.$font->getExtension(); - - $box = imagettfbbox($font->getSize(), $text->getAngle(), $filePath, $text->getText()); - $textHeight = - $box[5]; - - $box = imagettfbbox($font->getSize(), 90, $filePath, $text->getText()); - $textWidth = abs($box[6] - $box[2]); - - // Restore old text - $text->setText(substr($text->getText(), 0, strlen($text->getText()) - 1)); - - $textString = $text->getText(); - - // Split text if needed - if($width !== NULL) { - - $characters = floor($width / $this->getGDAverageWidth($font)); - $textString = wordwrap($textString, $characters, "\n", TRUE); - - } - - $color = $text->getColor(); - $rgb = $driver->getColor($color); - - imagettftext( - $driver->resource, - $font->getSize(), - $text->getAngle(), - $driver->x + $point->x + $textWidth * sin($text->getAngle() / 180 * M_PI), - $driver->y + $point->y + $textHeight, - $rgb, - $filePath, - $textString - ); - } - - public function getTextWidth(awText $text, awDriver $driver) { - switch ($driver->getDriverString()) { - case 'gd': - return $this->getGDTextWidth($text); - - default: - awImage::drawError('Class FileFontDriver: Cannot get text width - incompatibility between driver and font'); - break; - } - } - - public function getTextHeight(awText $text, awDriver $driver) { - switch ($driver->getDriverString()) { - case 'gd': - return $this->getGDTextHeight($text); - - default: - awImage::drawError('Class FileFontDriver: Cannot get text height - incompatibility between driver and font'); - break; - } - } - - private function getGDTextWidth(awText $text) { - $font = $text->getFont(); - if($font->getExtension() === NULL) { - $font->setExtension('ttf'); - } - - $filePath = $font->getName().'.'.$font->getExtension(); - - $box = imagettfbbox($font->getSize(), $text->getAngle(), $filePath, $text->getText()); - - if($box === FALSE) { - awImage::drawError("Class FileFontDriver: Unable to get font width (GD)."); - } - - list(, , $x2, , , , $x1, ) = $box; - - return abs($x2 - $x1); - } - - private function getGDTextHeight(awText $text) { - $font = $text->getFont(); - if($font->getExtension() === NULL) { - $font->setExtension('ttf'); - } - - $filePath = $font->getName().'.'.$font->getExtension(); - - $box = imagettfbbox($font->getSize(), $text->getAngle(), $filePath, $text->getText()); - - if($box === FALSE) { - awImage::drawError("Class FileFontDriver: Unable to get font height (GD)."); - } - - list(, , , $y2, , , , $y1) = $box; - - return abs($y2 - $y1); - } - - private function getGDAverageWidth(awFileFont $font) { - - $text = "azertyuiopqsdfghjklmmmmmmmwxcvbbbn,;:!?."; - - $box = imagettfbbox($font->getSize(), 0, $font->getName().'.'.$font->getExtension(), $text); - - if($box === FALSE) { - awImage::drawError("Class FileFontDriver: Unable to get font average width."); - } - - list(, , $x2, $y2, , , $x1, $y1) = $box; - - return abs($x2 - $x1) / strlen($text); - - } - -} - -registerClass('FileFontDriver'); - -// Include ARTICHOW_DRIVER by default to preserve backward compatibility. -require_once dirname(__FILE__).'/drivers/'.ARTICHOW_DRIVER.'.class.php'; - diff --git a/modules/graphartichow/artichow/inc/Font.class.php b/modules/graphartichow/artichow/inc/Font.class.php deleted file mode 100644 index 79267bde4..000000000 --- a/modules/graphartichow/artichow/inc/Font.class.php +++ /dev/null @@ -1,262 +0,0 @@ -string($this, $text, $point, $width); - - } - -} - -registerClass('Font', TRUE); - -/** - * Class for fonts that cannot be transformed, - * like the built-in PHP fonts for example. - * - * @package Artichow - */ -class awPHPFont extends awFont { - - /** - * The used font identifier - * - * @var int - */ - public $font; - - public function __construct($font = NULL) { - parent::__construct(); - - if($font !== NULL) { - $this->font = (int)$font; - } - } - -} - -registerClass('PHPFont'); - -/** - * Class for fonts that can be transformed (rotated, skewed, etc.), - * like TTF or FDB fonts for example. - * - * @package Artichow - */ -class awFileFont extends awFont { - - /** - * The name of the font, without the extension - * - * @var string - */ - protected $name; - - /** - * The size of the font - * - * @var int - */ - protected $size; - - /** - * The font filename extension - * - * @var string - */ - protected $extension; - - public function __construct($name, $size) { - parent::__construct(); - - $this->setName($name); - $this->setSize($size); - } - - /** - * Set the name of the font. The $name variable can contain the full path, - * or just the filename. Artichow will try to do The Right Thing, - * as well as set the extension property correctly if possible. - * - * @param string $name - */ - public function setName($name) { - $fontInfo = pathinfo((string)$name); - - if(strpos($fontInfo['dirname'], '/') !== 0) { - // Path is not absolute, use ARTICHOW_FONT - $name = ARTICHOW_FONT.DIRECTORY_SEPARATOR.$fontInfo['basename']; - $fontInfo = pathinfo($name); - } - - $this->name = $fontInfo['dirname'].DIRECTORY_SEPARATOR.$fontInfo['basename']; - - if(array_key_exists('extension', $fontInfo) and $fontInfo['extension'] !== '') { - $this->setExtension($fontInfo['extension']); - } - } - - /** - * Return the name of the font, i.e. the absolute path and the filename, without the extension. - * - * @return string - */ - public function getName() { - return $this->name; - } - - /** - * Set the size of the font, in pixels - * - * @param int $size - */ - public function setSize($size) { - $this->size = (int)$size; - } - - /** - * Return the size of the font, in pixels - * - * @return int - */ - public function getSize() { - return $this->size; - } - - /** - * Set the extension, without the dot - * - * @param string $extension - */ - public function setExtension($extension) { - $this->extension = (string)$extension; - } - - /** - * Get the filename extension for that font - * - * @return string - */ - public function getExtension() { - return $this->extension; - } - -} - -registerClass('FileFont'); - -/** - * Class representing TTF fonts - * - * @package Artichow - */ -class awTTFFont extends awFileFont { - - public function __construct($name, $size) { - parent::__construct($name, $size); - - if($this->getExtension() === NULL) { - $this->setExtension('ttf'); - } - } - -} - -registerClass('TTFFont'); - - - -$php = ''; - -for($i = 1; $i <= 5; $i++) { - - $php .= ' - class awFont'.$i.' extends awPHPFont { - - public function __construct() { - parent::__construct('.$i.'); - } - - } - '; - - if(ARTICHOW_PREFIX !== 'aw') { - $php .= ' - class '.ARTICHOW_PREFIX.'Font'.$i.' extends awFont'.$i.' { - } - '; - } - -} - -eval($php); - -$php = ''; - -foreach($fonts as $font) { - - $php .= ' - class aw'.$font.' extends awFileFont { - - public function __construct($size) { - parent::__construct(\''.$font.'\', $size); - } - - } - '; - - if(ARTICHOW_PREFIX !== 'aw') { - $php .= ' - class '.ARTICHOW_PREFIX.$font.' extends aw'.$font.' { - } - '; - } - -} - -eval($php); - - - -/* - * Environment modification for GD2 and TTF fonts - */ -if(function_exists('putenv')) { - putenv('GDFONTPATH='.ARTICHOW_FONT); -} - diff --git a/modules/graphartichow/artichow/inc/Gradient.class.php b/modules/graphartichow/artichow/inc/Gradient.class.php deleted file mode 100644 index d9d95ed1d..000000000 --- a/modules/graphartichow/artichow/inc/Gradient.class.php +++ /dev/null @@ -1,135 +0,0 @@ -from = $from; - $this->to = $to; - - } - -} - -registerClass('Gradient', TRUE); - - -/** - * Create a linear gradient - * - * @package Artichow - */ -class awLinearGradient extends awGradient { - - /** - * Gradient angle - * - * @var int - */ - public $angle; - - /** - * Build the linear gradient - * - * @param awColor $from From color - * @param awColor $to To color - * @param int $angle Gradient angle - */ - public function __construct($from, $to, $angle) { - - parent::__construct( - $from, $to - ); - - $this->angle = (int)$angle; - - } - -} - -registerClass('LinearGradient'); - - -/** - * Create a bilinear gradient - * - * @package Artichow - */ -class awBilinearGradient extends awLinearGradient { - - /** - * Gradient center - * - * @var float Center between 0 and 1 - */ - public $center; - - /** - * Build the bilinear gradient - * - * @param awColor $from From color - * @param awColor $to To color - * @param int $angle Gradient angle - * @param int $center Gradient center - */ - public function __construct($from, $to, $angle, $center = 0.5) { - - parent::__construct( - $from, $to, $angle - ); - - $this->center = (float)$center; - - } - -} - -registerClass('BilinearGradient'); - -/** - * Create a radial gradient - * - * @package Artichow - */ -class awRadialGradient extends awGradient { - -} - -registerClass('RadialGradient'); - diff --git a/modules/graphartichow/artichow/inc/Grid.class.php b/modules/graphartichow/artichow/inc/Grid.class.php deleted file mode 100644 index 2b02a53ee..000000000 --- a/modules/graphartichow/artichow/inc/Grid.class.php +++ /dev/null @@ -1,290 +0,0 @@ -color = new awColor(210, 210, 210); - $this->background = new awColor(255, 255, 255, 100); - - } - - /** - * Hide grid ? - * - * @param bool $hide - */ - public function hide($hide = TRUE) { - $this->hide = (bool)$hide; - } - - /** - * Hide horizontal lines ? - * - * @param bool $hideHorizontal - */ - public function hideHorizontal($hide = TRUE) { - $this->hideHorizontal = (bool)$hide; - } - - /** - * Hide vertical lines ? - * - * @param bool $hideVertical - */ - public function hideVertical($hide = TRUE) { - $this->hideVertical = (bool)$hide; - } - - /** - * Change grid color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->color = $color; - } - - /** - * Remove grid background - */ - public function setNoBackground() { - $this->background = NULL; - } - - /** - * Change grid background color - * - * @param awColor $color - */ - public function setBackgroundColor(awColor $color) { - $this->background = $color; - } - - /** - * Change line type - * - * @param int $type - */ - public function setType($type) { - $this->type = (int)$type; - } - - /** - * Change grid interval - * - * @param int $hInterval - * @param int $vInterval - */ - public function setInterval($hInterval, $vInterval) { - $this->interval = array((int)$hInterval, (int)$vInterval); - } - - /** - * Set grid space - * - * @param int $left Left space in pixels - * @param int $right Right space in pixels - * @param int $top Top space in pixels - * @param int $bottom Bottom space in pixels - */ - public function setSpace($left, $right, $top, $bottom) { - $this->space = array((int)$left, (int)$right, (int)$top, (int)$bottom); - } - - /** - * Change the current grid - * - * @param array $xgrid Vertical lines - * @param array $ygrid Horizontal lines - */ - public function setGrid($xgrid, $ygrid) { - - if(empty($this->xgrid)) { - $this->xgrid = $xgrid; - } - if(empty($this->ygrid)) { - $this->ygrid = $ygrid; - } - - } - - /** - * Draw grids - * - * @param awDriver $driver A driver object - * @param int $x1 - * @param int $y1 - * @param int $x2 - * @param int $y2 - */ - public function draw(awDriver $driver, $x1, $y1, $x2, $y2) { - - if($this->background instanceof awColor) { - - // Draw background color - $driver->filledRectangle( - $this->background, - awLine::build($x1, $y1, $x2, $y2) - ); - - } - - if($this->hide === FALSE) { - - $this->drawGrid( - $driver, - $this->color, - $this->hideVertical ? array() : $this->xgrid, - $this->hideHorizontal ? array() : $this->ygrid, - $x1, $y1, $x2, $y2, - $this->type, - $this->space, - $this->interval[0], - $this->interval[1] - ); - - } - - } - - private function drawGrid( - awDriver $driver, awColor $color, - $nx, $ny, $x1, $y1, $x2, $y2, - $type, $space, $hInterval, $vInterval - ) { - - list($left, $right, $top, $bottom) = $space; - - $width = $x2 - $x1 - $left - $right; - $height = $y2 - $y1 - $top - $bottom; - - foreach($nx as $key => $n) { - - if(($key % $vInterval) === 0) { - - $pos = (int)round($x1 + $left + $n * $width); - $driver->line( - $color, - new awLine( - new awPoint($pos, $y1), - new awPoint($pos, $y2), - $type - ) - ); - - } - - } - - foreach($ny as $key => $n) { - - if(($key % $hInterval) === 0) { - - $pos = (int)round($y1 + $top + $n * $height); - $driver->line( - $color, - new awLine( - new awPoint($x1, $pos), - new awPoint($x2, $pos), - $type - ) - ); - - } - - } - - } - -} - -registerClass('Grid'); diff --git a/modules/graphartichow/artichow/inc/Label.class.php b/modules/graphartichow/artichow/inc/Label.class.php deleted file mode 100644 index 43bbae5af..000000000 --- a/modules/graphartichow/artichow/inc/Label.class.php +++ /dev/null @@ -1,587 +0,0 @@ -set($label); - } else if(is_string($label)) { - $this->set(array($label)); - } - - if($font === NULL) { - $font = new awFont2; - } - - $this->setFont($font); - $this->setAngle($angle); - - if($color instanceof awColor) { - $this->setColor($color); - } else { - $this->setColor(new awColor(0, 0, 0)); - } - - $this->move = new awPoint(0, 0); - - $this->border = new awBorder; - $this->border->hide(); - - } - - /** - * Get an element of the label from its key - * - * @param int $key Element key - * @return string A value - */ - public function get($key) { - return array_key_exists($key, $this->texts) ? $this->texts[$key] : NULL; - } - - /** - * Get all labels - * - * @return array - */ - public function all() { - return $this->texts; - } - - /** - * Set one or several labels - * - * @param array $labels Array of string or a string - */ - public function set($labels) { - - if(is_array($labels)) { - $this->texts = $labels; - } else { - $this->texts = array((string)$labels); - } - - } - - /** - * Count number of texts in the label - * - * @return int - */ - public function count() { - return is_array($this->texts) ? count($this->texts) : 0; - } - - /** - * Set a callback function for labels - * - * @param string $function - */ - public function setCallbackFunction($function) { - $this->function = is_null($function) ? $function : (string)$function; - } - - /** - * Return the callback function for labels - * - * @return string - */ - public function getCallbackFunction() { - return $this->function; - } - - /** - * Change labels format - * - * @param string $format New format (printf style: %.2f for example) - */ - public function setFormat($format) { - $function = 'label'.time().'_'.(microtime() * 1000000); - eval('function '.$function.'($value) { - return sprintf("'.addcslashes($format, '"').'", $value); - }'); - $this->setCallbackFunction($function); - } - - /** - * Change font for label - * - * @param awFont $font New font - * @param awColor $color Font color (can be NULL) - */ - public function setFont(awFont $font, $color = NULL) { - $this->font = $font; - if($color instanceof awColor) { - $this->setColor($color); - } - } - - /** - * Change font angle - * - * @param int $angle New angle - */ - public function setAngle($angle) { - $this->angle = (int)$angle; - } - - /** - * Change font color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->color = $color; - } - - /** - * Change text background - * - * @param mixed $background - */ - public function setBackground($background) { - $this->background = $background; - } - - /** - * Change text background color - * - * @param Color - */ - public function setBackgroundColor(awColor $color) { - $this->background = $color; - } - - /** - * Change text background gradient - * - * @param Gradient - */ - public function setBackgroundGradient(awGradient $gradient) { - $this->background = $gradient; - } - - /** - * Change padding - * - * @param int $left Left padding - * @param int $right Right padding - * @param int $top Top padding - * @param int $bottom Bottom padding - */ - public function setPadding($left, $right, $top, $bottom) { - $this->padding = array((int)$left, (int)$right, (int)$top, (int)$bottom); - } - - /** - * Hide all labels ? - * - * @param bool $hide - */ - public function hide($hide = TRUE) { - $this->hide = (bool)$hide; - } - - /** - * Show all labels ? - * - * @param bool $show - */ - public function show($show = TRUE) { - $this->hide = (bool)!$show; - } - - /** - * Hide a key - * - * @param int $key The key to hide - */ - public function hideKey($key) { - $this->hideKey[$key] = TRUE; - } - - /** - * Hide a value - * - * @param int $value The value to hide - */ - public function hideValue($value) { - $this->hideValue[] = $value; - } - - /** - * Hide first label - * - * @param bool $hide - */ - public function hideFirst($hide) { - $this->hideFirst = (bool)$hide; - } - - /** - * Hide last label - * - * @param bool $hide - */ - public function hideLast($hide) { - $this->hideLast = (bool)$hide; - } - - /** - * Set label interval - * - * @param int - */ - public function setInterval($interval) { - - $this->interval = (int)$interval; - - } - - /** - * Change label position - * - * @param int $x Add this interval to X coord - * @param int $y Add this interval to Y coord - */ - public function move($x, $y) { - - $this->move = $this->move->move($x, $y); - - } - - /** - * Change alignment - * - * @param int $h Horizontal alignment - * @param int $v Vertical alignment - */ - public function setAlign($h = NULL, $v = NULL) { - if($h !== NULL) { - $this->hAlign = (int)$h; - } - if($v !== NULL) { - $this->vAlign = (int)$v; - } - } - - /** - * Get a text from the labele - * - * @param mixed $key Key in the array text - * @return Text - */ - public function getText($key) { - - if(is_array($this->texts) and array_key_exists($key, $this->texts)) { - - $value = $this->texts[$key]; - - if(is_string($this->function)) { - $value = call_user_func($this->function, $value); - } - - $text = new awText($value); - $text->setFont($this->font); - $text->setAngle($this->angle); - $text->setColor($this->color); - - if($this->background instanceof awColor) { - $text->setBackgroundColor($this->background); - } else if($this->background instanceof awGradient) { - $text->setBackgroundGradient($this->background); - } - - $text->border = $this->border; - - if($this->padding !== NULL) { - call_user_func_array(array($text, 'setPadding'), $this->padding); - } - - return $text; - - } else { - return NULL; - } - - } - - /** - * Get max width of all texts - * - * @param awDriver $driver A driver - * @return int - */ - public function getMaxWidth(awDriver $driver) { - - return $this->getMax($driver, 'getTextWidth'); - - } - - /** - * Get max height of all texts - * - * @param awDriver $driver A driver - * @return int - */ - public function getMaxHeight(awDriver $driver) { - - return $this->getMax($driver, 'getTextHeight'); - - } - - /** - * Draw the label - * - * @param awDriver $driver - * @param awPoint $p Label center - * @param int $key Text position in the array of texts (default to zero) - */ - public function draw(awDriver $driver, awPoint $p, $key = 0) { - - if(($key % $this->interval) !== 0) { - return; - } - - // Hide all labels - if($this->hide) { - return; - } - - // Key is hidden - if(array_key_exists($key, $this->hideKey)) { - return; - } - - // Hide first label - if($key === 0 and $this->hideFirst) { - return; - } - - // Hide last label - if($key === count($this->texts) - 1 and $this->hideLast) { - return; - } - - $text = $this->getText($key); - - if($text !== NULL) { - - // Value must be hidden - if(in_array($text->getText(), $this->hideValue)) { - return; - } - - $x = $p->x; - $y = $p->y; - - // Get padding - list($left, $right, $top, $bottom) = $text->getPadding(); - -// $font = $text->getFont(); - $width = $driver->getTextWidth($text); - $height = $driver->getTextHeight($text); - - switch($this->hAlign) { - - case awLabel::RIGHT : - $x -= ($width + $right); - break; - - case awLabel::CENTER : - $x -= ($width - $left + $right) / 2; - break; - - case awLabel::LEFT : - $x += $left; - break; - - } - - switch($this->vAlign) { - - case awLabel::TOP : - $y -= ($height + $bottom); - break; - - case awLabel::MIDDLE : - $y -= ($height - $top + $bottom) / 2; - break; - - case awLabel::BOTTOM : - $y += $top; - break; - - } - - $driver->string($text, $this->move->move($x, $y)); - - } - - } - - protected function getMax(awDriver $driver, $function) { - - $max = NULL; - - foreach($this->texts as $key => $text) { - - $text = $this->getText($key); - $font = $text->getFont(); - - if(is_null($max)) { - $max = $font->{$function}($text); - } else { - $max = max($max, $font->{$function}($text)); - } - - } - - return $max; - - } - -} - -registerClass('Label'); diff --git a/modules/graphartichow/artichow/inc/Legend.class.php b/modules/graphartichow/artichow/inc/Legend.class.php deleted file mode 100644 index bbfd64a03..000000000 --- a/modules/graphartichow/artichow/inc/Legend.class.php +++ /dev/null @@ -1,709 +0,0 @@ -shadow = new awShadow(awShadow::LEFT_BOTTOM); - $this->border = new awBorder; - - $this->textMargin = new awSide(4); - $this->setModel($model); - - } - - /** - * Set a predefined model for the legend - * - * @param int $model - */ - public function setModel($model) { - - $this->setBackgroundColor(new awColor(255, 255, 255, 15)); - $this->setPadding(8, 8, 8, 8); - $this->setTextFont(new awFont2); - $this->shadow->setSize(3); - - switch($model) { - - case awLegend::MODEL_RIGHT : - - $this->setColumns(1); - $this->setAlign(awLegend::RIGHT, awLegend::MIDDLE); - $this->setPosition(0.96, 0.50); - - break; - - case awLegend::MODEL_BOTTOM : - - $this->setRows(1); - $this->setAlign(awLegend::CENTER, awLegend::TOP); - $this->setPosition(0.50, 0.92); - - break; - - default : - - $this->setPosition(0.5, 0.5); - - break; - - } - - } - - /** - * Hide legend ? - * - * @param bool $hide TRUE to hide legend, FALSE otherwise - */ - public function hide($hide = TRUE) { - $this->hide = (bool)$hide; - } - - /** - * Show legend ? - * - * @param bool $show - */ - public function show($show = TRUE) { - $this->hide = (bool)!$show; - } - - - /** - * Add a Legendable object to the legend - * - * @param awLegendable $legendable - * @param string $title Legend title - * @param int $type Legend type (default to awLegend::LINE) - */ - public function add(awLegendable $legendable, $title, $type = awLegend::LINE) { - - $legend = array($legendable, $title, $type); - - $this->legends[] = $legend; - - } - - /** - * Change legend padding - * - * @param int $left - * @param int $right - * @param int $top - * @param int $bottom - */ - public function setPadding($left, $right, $top, $bottom) { - $this->padding = array((int)$left, (int)$right, (int)$top, (int)$bottom); - } - - /** - * Change space between each legend - * - * @param int $space - */ - public function setSpace($space) { - $this->space = (int)$space; - } - - /** - * Change alignment - * - * @param int $h Horizontal alignment - * @param int $v Vertical alignment - */ - public function setAlign($h = NULL, $v = NULL) { - if($h !== NULL) { - $this->hAlign = (int)$h; - } - if($v !== NULL) { - $this->vAlign = (int)$v; - } - } - - /** - * Change number of columns - * - * @param int $columns - */ - public function setColumns($columns) { - $this->rows = NULL; - $this->columns = (int)$columns; - } - - /** - * Change number of rows - * - * @param int $rows - */ - public function setRows($rows) { - $this->columns = NULL; - $this->rows = (int)$rows; - } - - /** - * Change legend position - * X and Y positions must be between 0 and 1. - * - * @param float $x - * @param float $y - */ - public function setPosition($x = NULL, $y = NULL) { - $x = (is_null($x) and !is_null($this->position)) ? $this->position->x : $x; - $y = (is_null($y) and !is_null($this->position)) ? $this->position->y : $y; - - $this->position = new awPoint($x, $y); - } - - /** - * Get legend position - * - * @return Point - */ - public function getPosition() { - return $this->position; - } - - /** - * Change text font - * - * @param awFont $font - */ - public function setTextFont(awFont $font) { - $this->textFont = $font; - } - - /** - * Change text margin - * - * @param int $left - * @param int $right - */ - public function setTextMargin($left, $right) { - $this->textMargin->set($left, $right); - } - - /** - * Change text color - * - * @param awColor $color - */ - public function setTextColor(awColor $color) { - $this->textColor = $color; - } - - /** - * Change background - * - * @param mixed $background - */ - public function setBackground($background) { - $this->background = $background; - } - - /** - * Change background color - * - * @param awColor $color - */ - public function setBackgroundColor(awColor $color) { - $this->background = $color; - } - - /** - * Change background gradient - * - * @param awGradient $gradient - */ - public function setBackgroundGradient(awGradient $gradient) { - $this->background = $gradient; - } - - /** - * Count the number of Legendable objects in the legend - * - * @return int - */ - public function count() { - return count($this->legends); - } - - public function draw(awDriver $driver) { - - if($this->hide) { - return; - } - - $count = $this->count(); - - // No legend to print - if($count === 0) { - return; - } - - // Get text widths and heights of each element of the legend - $widths = array(); - $heights = array(); - $texts = array(); - for($i = 0; $i < $count; $i++) { - list(, $title, ) = $this->legends[$i]; - $text = new awText( - $title, - $this->textFont, - $this->textColor, - 0 - ); -// $font = $text->getFont(); - $widths[$i] = $driver->getTextWidth($text) + $this->textMargin->left + $this->textMargin->right; - $heights[$i] = $driver->getTextHeight($text); - $texts[$i] = $text; - } - - // Maximum height of the font used - $heightMax = array_max($heights); - - // Get number of columns - if($this->columns !== NULL) { - $columns = $this->columns; - } else if($this->rows !== NULL) { - $columns = ceil($count / $this->rows); - } else { - $columns = $count; - } - - // Number of rows - $rows = (int)ceil($count / $columns); - - // Get maximum with of each column - $widthMax = array(); - for($i = 0; $i < $count; $i++) { - // Get column width - $column = $i % $columns; - if(array_key_exists($column, $widthMax) === FALSE) { - $widthMax[$column] = $widths[$i]; - } else { - $widthMax[$column] = max($widthMax[$column], $widths[$i]); - } - } - - $width = $this->padding[0] + $this->padding[1] - $this->space; - for($i = 0; $i < $columns; $i++) { - $width += $this->space + 5 + 10 + $widthMax[$i]; - } - - $height = ($heightMax + $this->space) * $rows - $this->space + $this->padding[2] + $this->padding[3]; - - // Look for legends position - list($x, $y) = $driver->getSize(); - - $p = new awPoint( - $this->position->x * $x, - $this->position->y * $y - ); - - switch($this->hAlign) { - - case awLegend::CENTER : - $p->x -= $width / 2; - break; - - case awLegend::RIGHT : - $p->x -= $width; - break; - - } - - switch($this->vAlign) { - - case awLegend::MIDDLE : - $p->y -= $height / 2; - break; - - case awLegend::BOTTOM : - $p->y -= $height; - break; - - } - - // Draw legend shadow - $this->shadow->draw( - $driver, - $p, - $p->move($width, $height), - awShadow::OUT - ); - - // Draw legends base - $this->drawBase($driver, $p, $width, $height); - - // Draw each legend - for($i = 0; $i < $count; $i++) { - - list($component, $title, $type) = $this->legends[$i]; - - $column = $i % $columns; - $row = (int)floor($i / $columns); - - // Get width of all previous columns - $previousColumns = 0; - for($j = 0; $j < $column; $j++) { - $previousColumns += $this->space + 10 + 5 + $widthMax[$j]; - } - - // Draw legend text - $driver->string( - $texts[$i], - $p->move( - $this->padding[0] + $previousColumns + 10 + 5 + $this->textMargin->left, - $this->padding[2] + $row * ($heightMax + $this->space) + $heightMax / 2 - $heights[$i] / 2 - ) - ); - - // Draw legend icon - switch($type) { - - case awLegend::LINE : - case awLegend::MARK : - case awLegend::MARKONLY : - - // Get vertical position - $x = $this->padding[0] + $previousColumns; - $y = $this->padding[2] + $row * ($heightMax + $this->space) + $heightMax / 2 - $component->getLegendLineThickness(); - - // Draw two lines - if($component->getLegendLineColor() !== NULL) { - - $color = $component->getLegendLineColor(); - - if($color instanceof awColor and $type !== awLegend::MARKONLY) { - - $driver->line( - $color, - new awLine( - $p->move( - $x, // YaPB ?? - $y + $component->getLegendLineThickness() / 2 - ), - $p->move( - $x + 10, - $y + $component->getLegendLineThickness() / 2 - ), - $component->getLegendLineStyle(), - $component->getLegendLineThickness() - ) - ); - - unset($color); - - } - - } - - if($type === awLegend::MARK or $type === awLegend::MARKONLY) { - - $mark = $component->getLegendMark(); - - if($mark !== NULL) { - $mark->draw( - $driver, - $p->move( - $x + 5.5, - $y + $component->getLegendLineThickness() / 2 - ) - ); - } - - unset($mark); - - } - - break; - - case awLegend::BACKGROUND : - - // Get vertical position - $x = $this->padding[0] + $previousColumns; - $y = $this->padding[2] + $row * ($heightMax + $this->space) + $heightMax / 2 - 5; - - $from = $p->move( - $x, - $y - ); - - $to = $p->move( - $x + 10, - $y + 10 - ); - - $background = $component->getLegendBackground(); - - if($background !== NULL) { - - $driver->filledRectangle( - $component->getLegendBackground(), - new awLine($from, $to) - ); - - // Draw rectangle border - $this->border->rectangle( - $driver, - $from->move(0, 0), - $to->move(0, 0) - ); - - } - - unset($background, $from, $to); - - break; - - } - - } - - } - - private function drawBase(awDriver $driver, awPoint $p, $width, $height) { - - $this->border->rectangle( - $driver, - $p, - $p->move($width, $height) - ); - - $size = $this->border->visible() ? 1 : 0; - - $driver->filledRectangle( - $this->background, - new awLine( - $p->move($size, $size), - $p->move($width - $size, $height - $size) - ) - ); - - } - -} - -registerClass('Legend'); - -/** - * You can add a legend to components which implements this interface - * - * @package Artichow - */ -interface awLegendable { - - /** - * Get the line type - * - * @return int - */ - public function getLegendLineStyle(); - - /** - * Get the line thickness - * - * @return int - */ - public function getLegendLineThickness(); - - /** - * Get the color of line - * - * @return Color - */ - public function getLegendLineColor(); - - /** - * Get the background color or gradient of an element of the component - * - * @return Color, Gradient - */ - public function getLegendBackground(); - - /** - * Get a Mark object - * - * @return Mark - */ - public function getLegendMark(); - -} - -registerInterface('Legendable'); diff --git a/modules/graphartichow/artichow/inc/Mark.class.php b/modules/graphartichow/artichow/inc/Mark.class.php deleted file mode 100644 index d89437f24..000000000 --- a/modules/graphartichow/artichow/inc/Mark.class.php +++ /dev/null @@ -1,489 +0,0 @@ -fill = new awColor(255, 0, 0, 0); - $this->border = new awBorder; - $this->border->hide(); - - $this->move = new awPoint(0, 0); - - } - - /** - * Change mark position - * - * @param int $x Add this interval to X coord - * @param int $y Add this interval to Y coord - */ - public function move($x, $y) { - - $this->move = $this->move->move($x, $y); - - } - - /** - * Hide marks ? - * - * @param bool $hide TRUE to hide marks, FALSE otherwise - */ - public function hide($hide = TRUE) { - $this->hide = (bool)$hide; - } - - /** - * Show marks ? - * - * @param bool $show - */ - public function show($show = TRUE) { - $this->hide = (bool)!$show; - } - - /** - * Change mark type - * - * @param int $size Size in pixels - */ - public function setSize($size) { - $this->size = (int)$size; - } - - /** - * Change mark type - * - * @param int $type New mark type - * @param int $size Mark size (can be NULL) - */ - public function setType($type, $size = NULL) { - $this->type = (int)$type; - if($size !== NULL) { - $this->setSize($size); - } - } - - /** - * Fill the mark with a color or a gradient - * - * @param mixed $fill A color or a gradient - */ - public function setFill($fill) { - if($fill instanceof awColor or $fill instanceof awGradient) { - $this->fill = $fill; - } - } - - /** - * Set an image - * Only for awMark::IMAGE type. - * - * @param Image An image - */ - public function setImage(awImage $image) { - $this->image = $image; - } - - /** - * Draw the mark - * - * @param awDriver $driver - * @param awPoint $point Mark center - */ - public function draw(awDriver $driver, awPoint $point) { - - // Hide marks ? - if($this->hide) { - return; - } - - // Check if we can print marks - if($this->type !== NULL) { - - $this->driver = $driver; - $realPoint = $this->move->move($point->x, $point->y); - - switch($this->type) { - - case awMark::CIRCLE : - $this->drawCircle($realPoint); - break; - - case awMark::SQUARE : - $this->drawSquare($realPoint); - break; - - case awMark::TRIANGLE : - $this->drawTriangle($realPoint); - break; - - case awMark::INVERTED_TRIANGLE : - $this->drawTriangle($realPoint, TRUE); - break; - - case awMark::RHOMBUS : - $this->drawRhombus($realPoint); - break; - - case awMark::CROSS : - $this->drawCross($realPoint); - break; - - case awMark::PLUS : - $this->drawCross($realPoint, TRUE); - break; - - case awMark::IMAGE : - $this->drawImage($realPoint); - break; - - case awMark::STAR : - $this->changeType('star'); - $this->draw($driver, $point); - break; - - case awMark::PAPERCLIP : - $this->changeType('paperclip'); - $this->draw($driver, $point); - break; - - case awMark::BOOK : - $this->changeType('book'); - $this->draw($driver, $point); - break; - - } - - } - - } - - protected function changeType($image) { - $this->setType(awMARK::IMAGE); - $this->setImage(new awFileImage(ARTICHOW_IMAGE.DIRECTORY_SEPARATOR.$image.'.png')); - } - - protected function drawCircle(awPoint $point) { - - $this->driver->filledEllipse( - $this->fill, - $point, - $this->size, $this->size - ); - - $this->border->ellipse( - $this->driver, - $point, - $this->size, $this->size - ); - - } - - protected function drawSquare(awPoint $point) { - - list($x, $y) = $point->getLocation(); - - $x1 = (int)($x - $this->size / 2); - $x2 = $x1 + $this->size; - $y1 = (int)($y - $this->size / 2); - $y2 = $y1 + $this->size; - - $this->border->rectangle($this->driver, new awPoint($x1, $y1), new awPoint($x2, $y2)); - - $size = $this->border->visible() ? 1 : 0; - - $this->driver->filledRectangle( - $this->fill, - new awLine( - new awPoint($x1 + $size, $y1 + $size), - new awPoint($x2 - $size, $y2 - $size) - ) - ); - - } - - protected function drawTriangle(awPoint $point, $inverted = FALSE) { - - list($x, $y) = $point->getLocation(); - - $size = $this->size; - - $triangle = new awPolygon; - // Set default style and thickness - $triangle->setStyle(awPolygon::SOLID); - $triangle->setThickness(1); - - if($inverted === TRUE) { - // Bottom of the triangle - $triangle->append(new awPoint($x, $y + $size / sqrt(3))); - - // Upper left corner - $triangle->append(new awPoint($x - $size / 2, $y - $size / (2 * sqrt(3)))); - - // Upper right corner - $triangle->append(new awPoint($x + $size / 2, $y - $size / (2 * sqrt(3)))); - } else { - // Top of the triangle - $triangle->append(new awPoint($x, $y - $size / sqrt(3))); - - // Lower left corner - $triangle->append(new awPoint($x - $size / 2, $y + $size / (2 * sqrt(3)))); - - // Lower right corner - $triangle->append(new awPoint($x + $size / 2, $y + $size / (2 * sqrt(3)))); - } - - $this->driver->filledPolygon($this->fill, $triangle); - - if($this->border->visible()) { - $this->border->polygon($this->driver, $triangle); - } - } - - protected function drawRhombus(awPoint $point) { - - list($x, $y) = $point->getLocation(); - - $rhombus = new awPolygon; - // Set default style and thickness - $rhombus->setStyle(awPolygon::SOLID); - $rhombus->setThickness(1); - - // Top of the rhombus - $rhombus->append(new awPoint($x, $y - $this->size / 2)); - - // Right of the rhombus - $rhombus->append(new awPoint($x + $this->size / 2, $y)); - - // Bottom of the rhombus - $rhombus->append(new awPoint($x, $y + $this->size / 2)); - - // Left of the rhombus - $rhombus->append(new awPoint($x - $this->size / 2, $y)); - - $this->driver->filledPolygon($this->fill, $rhombus); - - if($this->border->visible()) { - $this->border->polygon($this->driver, $rhombus); - } - } - - protected function drawCross(awPoint $point, $upright = FALSE) { - - list($x, $y) = $point->getLocation(); - - if($upright === TRUE) { - $x11 = (int)($x); - $y11 = (int)($y - $this->size / 2); - $x12 = (int)($x); - $y12 = (int)($y + $this->size / 2); - - $y21 = (int)($y); - $y22 = (int)($y); - } else { - $x11 = (int)($x - $this->size / 2); - $y11 = (int)($y + $this->size / 2); - $x12 = (int)($x + $this->size / 2); - $y12 = (int)($y - $this->size / 2); - - $y21 = (int)($y - $this->size / 2); - $y22 = (int)($y + $this->size / 2); - } - - $x21 = (int)($x - $this->size / 2); - $x22 = (int)($x + $this->size / 2); - - $this->driver->line( - $this->fill, - new awLine( - new awPoint($x11, $y11), - new awPoint($x12, $y12) - ) - ); - - $this->driver->line( - $this->fill, - new awLine( - new awPoint($x21, $y21), - new awPoint($x22, $y22) - ) - ); - } - - protected function drawImage(awPoint $point) { - - if($this->image instanceof awImage) { - - $width = $this->image->width; - $height = $this->image->height; - - list($x, $y) = $point->getLocation(); - - $x1 = (int)($x - $width / 2); - $x2 = $x1 + $width; - $y1 = (int)($y - $width / 2); - $y2 = $y1 + $height; - - $this->border->rectangle($this->driver, new awPoint($x1 - 1, $y1 - 1), new awPoint($x2 + 1, $y2 + 1)); - - $this->driver->copyImage($this->image, new awPoint($x1, $y1), new awPoint($x2, $y2)); - - } - - } - -} - -registerClass('Mark'); diff --git a/modules/graphartichow/artichow/inc/Math.class.php b/modules/graphartichow/artichow/inc/Math.class.php deleted file mode 100644 index 0f1334b00..000000000 --- a/modules/graphartichow/artichow/inc/Math.class.php +++ /dev/null @@ -1,831 +0,0 @@ -style = (int)$style; - } - - /** - * Return shape style - * - * @return int - */ - public function getStyle() { - return $this->style; - } - - /** - * Change shape thickness - * - * @param int $thickness Shape thickness in pixels - */ - public function setThickness($thickness) { - $this->thickness = (int)$thickness; - } - - /** - * Return shape thickness - * - * @return int - */ - public function getThickness() { - return $this->thickness; - } - - /** - * Hide the shape - * - * @param bool $hide - */ - public function hide($hide) { - $this->hide = (bool)$hide; - } - - /** - * Show the shape - * - * @param bool $shape - */ - public function show($shape) { - $this->hide = (bool)!$shape; - } - - /** - * Is the line hidden ? - * - * @return bool - */ - public function isHidden() { - return $this->hide; - } - -} - -registerClass('Shape', TRUE); - -/** - * Describe a point - * - * @package Artichow - */ -class awPoint extends awShape { - - /** - * X coord - * - * @var float - */ - public $x; - - /** - * Y coord - * - * @var float - */ - public $y; - - /** - * Build a new awpoint - * - * @param float $x - * @param float $y - */ - public function __construct($x, $y) { - - $this->setLocation($x, $y); - - } - - /** - * Change X value - * - * @param float $x - */ - public function setX($x) { - $this->x = (float)$x; - } - - /** - * Change Y value - * - * @param float $y - */ - public function setY($y) { - $this->y = (float)$y; - } - - /** - * Change point location - * - * @param float $x - * @param float $y - */ - public function setLocation($x, $y) { - $this->setX($x); - $this->setY($y); - } - - /** - * Get point location - * - * @param array Point location - */ - public function getLocation() { - return array($this->x, $this->y); - } - - /** - * Get distance to another point - * - * @param awPoint $p A point - * @return float - */ - public function getDistance(awPoint $p) { - - return sqrt(pow($p->x - $this->x, 2) + pow($p->y - $this->y, 2)); - - } - - /** - * Move the point to another location - * - * @param Point A Point with the new awlocation - */ - public function move($x, $y) { - - return new awPoint( - $this->x + $x, - $this->y + $y - ); - - } - -} - -registerClass('Point'); - - -/** - * Describe a line - * - * @package Artichow - */ -class awLine extends awShape { - - /** - * Line first point - * - * @param Point - */ - public $p1; - - /** - * Line second point - * - * @param Point - */ - public $p2; - - /** - * The line slope (the m in y = mx + p) - * - * @param float - */ - private $slope; - - /** - * The y-intercept value of the line (the p in y = mx + p) - * - * @param float - */ - private $origin; - - /** - * Build a new awline - * - * @param awPoint $p1 First point - * @param awPoint $p2 Second point - * @param int $type Style of line (default to solid) - * @param int $thickness Line thickness (default to 1) - */ - public function __construct($p1 = NULL, $p2 = NULL, $type = awLine::SOLID, $thickness = 1) { - - $this->setLocation($p1, $p2); - $this->setStyle($type); - $this->setThickness($thickness); - - } - - /** - * Build a line from 4 coords - * - * @param int $x1 Left position - * @param int $y1 Top position - * @param int $x2 Right position - * @param int $y2 Bottom position - */ - public static function build($x1, $y1, $x2, $y2) { - - return new awLine( - new awPoint($x1, $y1), - new awPoint($x2, $y2) - ); - - } - - /** - * Change X values of the line - * - * @param int $x1 Begin value - * @param int $x2 End value - */ - public function setX($x1, $x2) { - $this->p1->setX($x1); - $this->p2->setX($x2); - - // Resets slope and origin values so they are - // recalculated when and if needed. - $this->slope = NULL; - $this->origin = NULL; - } - - /** - * Change Y values of the line - * - * @param int $y1 Begin value - * @param int $y2 End value - */ - public function setY($y1, $y2) { - $this->p1->setY($y1); - $this->p2->setY($y2); - - // Resets slope and origin values so they are - // recalculated when and if needed. - $this->slope = NULL; - $this->origin = NULL; - } - - /** - * Change line location - * - * @param awPoint $p1 First point - * @param awPoint $p2 Second point - */ - public function setLocation($p1, $p2) { - if(is_null($p1) or $p1 instanceof awPoint) { - $this->p1 = $p1; - } - if(is_null($p2) or $p2 instanceof awPoint) { - $this->p2 = $p2; - } - - // Resets slope and origin values so they are - // recalculated when and if needed. - $this->slope = NULL; - $this->origin = NULL; - } - - /** - * Get line location - * - * @param array Line location - */ - public function getLocation() { - return array($this->p1, $this->p2); - } - - /** - * Get the line size - * - * @return float - */ - public function getSize() { - - $square = pow($this->p2->x - $this->p1->x, 2) + pow($this->p2->y - $this->p1->y, 2); - return sqrt($square); - - } - - /** - * Calculate the line slope - * - */ - private function calculateSlope() { - if($this->isHorizontal()) { - $this->slope = 0; - } else { - $slope = ($this->p1->y - $this->p2->y) / ($this->p1->x - $this->p2->x); - - $this->slope = $slope; - } - } - - /** - * Calculate the y-intercept value of the line - * - */ - private function calculateOrigin() { - if($this->isHorizontal()) { - $this->origin = $this->p1->y; // Or p2->y - } else { - $y1 = $this->p1->y; - $y2 = $this->p2->y; - $x1 = $this->p1->x; - $x2 = $this->p2->x; - - $origin = ($y2 * $x1 - $y1 * $x2) / ($x1 - $x2); - - $this->origin = $origin; - } - } - - /** - * Calculate the slope and y-intercept value of the line - * - */ - private function calculateEquation() { - $this->calculateSlope(); - $this->calculateOrigin(); - } - - /** - * Get the line slope value - * - * @return float - */ - public function getSlope() { - if($this->isVertical()) { - return NULL; - } elseif($this->slope !== NULL) { - return $this->slope; - } else { - $this->calculateSlope(); - return $this->slope; - } - } - - /** - * Get the line y-intercept value - * - * @return float - */ - public function getOrigin() { - if($this->isVertical()) { - return NULL; - } elseif($this->origin !== NULL) { - return $this->origin; - } else { - $this->calculateOrigin(); - return $this->origin; - } - } - - /** - * Get the line equation - * - * @return array An array containing the slope and y-intercept value of the line - */ - public function getEquation() { - $slope = $this->getSlope(); - $origin = $this->getOrigin(); - - return array($slope, $origin); - } - - /** - * Return the x coordinate of a point on the line - * given its y coordinate. - * - * @param float $y The y coordinate of the Point - * @return float $x The corresponding x coordinate - */ - public function getXFrom($y) { - $x = NULL; - - if($this->isVertical()) { - list($p, ) = $this->getLocation(); - $x = $p->x; - } else { - list($slope, $origin) = $this->getEquation(); - - if($slope !== 0) { - $y = (float)$y; - $x = ($y - $origin) / $slope; - } - } - - return $x; - } - - /** - * Return the y coordinate of a point on the line - * given its x coordinate. - * - * @param float $x The x coordinate of the Point - * @return float $y The corresponding y coordinate - */ - public function getYFrom($x) { - $y = NULL; - - if($this->isHorizontal()) { - list($p, ) = $this->getLocation(); - $y = $p->y; - } else { - list($slope, $origin) = $this->getEquation(); - - if($slope !== NULL) { - $x = (float)$x; - $y = $slope * $x + $origin; - } - } - - return $y; - } - - /** - * Test if the line can be considered as a point - * - * @return bool - */ - public function isPoint() { - return ($this->p1->x === $this->p2->x and $this->p1->y === $this->p2->y); - } - - /** - * Test if the line is a vertical line - * - * @return bool - */ - public function isVertical() { - return ($this->p1->x === $this->p2->x); - } - - /** - * Test if the line is an horizontal line - * - * @return bool - */ - public function isHorizontal() { - return ($this->p1->y === $this->p2->y); - } - - /** - * Returns TRUE if the line is going all the way from the top - * to the bottom of the polygon surrounding box. - * - * @param $polygon Polygon A Polygon object - * @return bool - */ - public function isTopToBottom(awPolygon $polygon) { - list($xMin, $xMax) = $polygon->getBoxXRange(); - list($yMin, $yMax) = $polygon->getBoxYRange(); - - if($this->isHorizontal()) { - return FALSE; - } else { - if($this->p1->y < $this->p2->y) { - $top = $this->p1; - $bottom = $this->p2; - } else { - $top = $this->p2; - $bottom = $this->p1; - } - - return ( - $this->isOnBoxTopSide($top, $xMin, $xMax, $yMin) - and - $this->isOnBoxBottomSide($bottom, $xMin, $xMax, $yMax) - ); - } - } - - /** - * Returns TRUE if the line is going all the way from the left side - * to the right side of the polygon surrounding box. - * - * @param $polygon Polygon A Polygon object - * @return bool - */ - public function isLeftToRight(awPolygon $polygon) { - list($xMin, $xMax) = $polygon->getBoxXRange(); - list($yMin, $yMax) = $polygon->getBoxYRange(); - - if($this->isVertical()) { - return FALSE; - } else { - if($this->p1->x < $this->p2->x) { - $left = $this->p1; - $right = $this->p2; - } else { - $left = $this->p2; - $right = $this->p1; - } - } - - return ( - $this->isOnBoxLeftSide($left, $yMin, $yMax, $xMin) - and - $this->isOnBoxRightSide($right, $yMin, $yMax, $xMax) - ); - } - - private function isOnBoxTopSide(awPoint $point, $xMin, $xMax, $yMin) { - if( - $point->y === $yMin - and - $point->x >= $xMin - and - $point->x <= $xMax - ) { - return TRUE; - } else { - return FALSE; - } - } - - private function isOnBoxBottomSide(awPoint $point, $xMin, $xMax, $yMax) { - if( - $point->y === $yMax - and - $point->x >= $xMin - and - $point->x <= $xMax - ) { - return TRUE; - } else { - return FALSE; - } - } - - private function isOnBoxLeftSide(awPoint $point, $yMin, $yMax, $xMin) { - if( - $point->x === $xMin - and - $point->y >= $yMin - and - $point->y <= $yMax - ) { - return TRUE; - } else { - return FALSE; - } - } - - private function isOnBoxRightSide(awPoint $point, $yMin, $yMax, $xMax) { - if( - $point->x === $xMax - and - $point->y >= $yMin - and - $point->y <= $yMax - ) { - return TRUE; - } else { - return FALSE; - } - } - -} - -registerClass('Line'); - -/** - * A vector is a type of line - * The sense of the vector goes from $p1 to $p2. - * - * @package Artichow - */ -class awVector extends awLine { - - /** - * Get vector angle in radians - * - * @return float - */ - public function getAngle() { - - if($this->isPoint()) { - return 0.0; - } - - $size = $this->getSize(); - - $width = ($this->p2->x - $this->p1->x); - $height = ($this->p2->y - $this->p1->y) * -1; - - if($width >= 0 and $height >= 0) { - return acos($width / $size); - } else if($width <= 0 and $height >= 0) { - return acos($width / $size); - } else { - $height *= -1; - if($width >= 0 and $height >= 0) { - return 2 * M_PI - acos($width / $size); - } else if($width <= 0 and $height >= 0) { - return 2 * M_PI - acos($width / $size); - } - } - - } - -} - -registerClass('Vector'); - - -/** - * Describe a polygon - * - * @package Artichow - */ -class awPolygon extends awShape { - - /** - * Polygon points - * - * @var array - */ - protected $points = array(); - - /** - * Set a point in the polygon - * - * @param int $pos Point position - * @param awPoint $point - */ - public function set($pos, $point) { - if(is_null($point) or $point instanceof awPoint) { - $this->points[$pos] = $point; - } - } - - /** - * Add a point at the end of the polygon - * - * @param awPoint $point - */ - public function append($point) { - if(is_null($point) or $point instanceof awPoint) { - $this->points[] = $point; - } - } - - /** - * Get a point at a position in the polygon - * - * @param int $pos Point position - * @return Point - */ - public function get($pos) { - return $this->points[$pos]; - } - - /** - * Count number of points in the polygon - * - * @return int - */ - public function count() { - return count($this->points); - } - - /** - * Returns all points in the polygon - * - * @return array - */ - public function all() { - return $this->points; - } - - /** - * Returns the different lines formed by the polygon vertices - * - * @return array - */ - public function getLines() { - $lines = array(); - $count = $this->count(); - - for($i = 0; $i < $count - 1; $i++) { - $lines[] = new Line($this->get($i), $this->get($i + 1)); - } - - // "Close" the polygon - $lines[] = new Line($this->get($count - 1), $this->get(0)); - - return $lines; - } - - /** - * Get the upper-left and lower-right points - * of the bounding box around the polygon - * - * @return array An array of two Point objects - */ - public function getBoxPoints() { - $count = $this->count(); - $x = $y = array(); - - for($i = 0; $i < $count; $i++) { - $point = $this->get($i); - - list($x[], $y[]) = $point->getLocation(); - } - - $upperLeft = new Point(min($x), min($y)); - $lowerRight = new Point(max($x), max($y)); - - return array($upperLeft, $lowerRight); - } - - /** - * Return the range of the polygon on the y axis, - * i.e. the minimum and maximum y value of any point in the polygon - * - * @return array - */ - public function getBoxYRange() { - list($p1, $p2) = $this->getBoxPoints(); - - list(, $yMin) = $p1->getLocation(); - list(, $yMax) = $p2->getLocation(); - - return array($yMin, $yMax); - } - - /** - * Return the range of the polygon on the x axis, - * i.e. the minimum and maximum x value of any point in the polygon - * - * @return array - */ - public function getBoxXRange() { - list($p1, $p2) = $this->getBoxPoints(); - - list($xMin, ) = $p1->getLocation(); - list($xMax, ) = $p2->getLocation(); - - return array($xMin, $xMax); - } - -} - -registerClass('Polygon'); diff --git a/modules/graphartichow/artichow/inc/Shadow.class.php b/modules/graphartichow/artichow/inc/Shadow.class.php deleted file mode 100644 index 1d528db5c..000000000 --- a/modules/graphartichow/artichow/inc/Shadow.class.php +++ /dev/null @@ -1,405 +0,0 @@ -setPosition($position); - } - - /** - * Hide shadow ? - * - * @param bool $hide - */ - public function hide($hide = TRUE) { - $this->hide = (bool)$hide; - } - - /** - * Show shadow ? - * - * @param bool $show - */ - public function show($show = TRUE) { - $this->hide = (bool)!$show; - } - - /** - * Change shadow size - * - * @param int $size - * @param bool $smooth Smooth the shadow (facultative argument) - */ - public function setSize($size, $smooth = NULL) { - $this->size = (int)$size; - if($smooth !== NULL) { - $this->smooth($smooth); - } - } - - /** - * Change shadow color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->color = $color; - } - - /** - * Change shadow position - * - * @param int $position - */ - public function setPosition($position) { - $this->position = (int)$position; - } - - /** - * Smooth shadow ? - * - * @param bool $smooth - */ - public function smooth($smooth) { - $this->smooth = (bool)$smooth; - } - - /** - * Get the space taken by the shadow - * - * @return Side - */ - public function getSpace() { - - return new awSide( - ($this->position === awShadow::LEFT_TOP or $this->position === awShadow::LEFT_BOTTOM) ? $this->size : 0, - ($this->position === awShadow::RIGHT_TOP or $this->position === awShadow::RIGHT_BOTTOM) ? $this->size : 0, - ($this->position === awShadow::LEFT_TOP or $this->position === awShadow::RIGHT_TOP) ? $this->size : 0, - ($this->position === awShadow::LEFT_BOTTOM or $this->position === awShadow::RIGHT_BOTTOM) ? $this->size : 0 - ); - - } - - /** - * Draw shadow - * - * @param awDriver $driver - * @param awPoint $p1 Top-left point - * @param awPoint $p2 Right-bottom point - * @param int Drawing mode - */ - public function draw(awDriver $driver, awPoint $p1, awPoint $p2, $mode) { - - if($this->hide) { - return; - } - - if($this->size <= 0) { - return; - } - - $driver = clone $driver; - - $color = ($this->color instanceof awColor) ? $this->color : new awColor(125, 125, 125); - - switch($this->position) { - - case awShadow::RIGHT_BOTTOM : - - if($mode === awShadow::OUT) { - $t1 = $p1->move(0, 0); - $t2 = $p2->move($this->size + 1, $this->size + 1); - } else { // PHP 4 compatibility - $t1 = $p1->move(0, 0); - $t2 = $p2->move(0, 0); - } - - $width = $t2->x - $t1->x; - $height = $t2->y - $t1->y; - - $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint($width - $this->size, $this->size), - new awPoint($width - 1, $height - 1) - ) - ); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint($this->size, $height - $this->size), - new awPoint($width - $this->size - 1, $height - 1) - ) - ); - - $this->smoothPast($driver, $color, $width, $height); - - break; - - case awShadow::LEFT_TOP : - - if($mode === awShadow::OUT) { - $t1 = $p1->move(- $this->size, - $this->size); - $t2 = $p2->move(0, 0); - } else { // PHP 4 compatibility - $t1 = $p1->move(0, 0); - $t2 = $p2->move(0, 0); - } - - $width = $t2->x - $t1->x; - $height = $t2->y - $t1->y; - - $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); - - $height = max($height + 1, $this->size); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint(0, 0), - new awPoint($this->size - 1, $height - $this->size - 1) - ) - ); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint($this->size, 0), - new awPoint($width - $this->size - 1, $this->size - 1) - ) - ); - - $this->smoothPast($driver, $color, $width, $height); - - break; - - case awShadow::RIGHT_TOP : - - if($mode === awShadow::OUT) { - $t1 = $p1->move(0, - $this->size); - $t2 = $p2->move($this->size + 1, 0); - } else { // PHP 4 compatibility - $t1 = $p1->move(0, 0); - $t2 = $p2->move(0, 0); - } - - $width = $t2->x - $t1->x; - $height = $t2->y - $t1->y; - - $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); - - $height = max($height + 1, $this->size); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint($width - $this->size, 0), - new awPoint($width - 1, $height - $this->size - 1) - ) - ); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint($this->size, 0), - new awPoint($width - $this->size - 1, $this->size - 1) - ) - ); - - $this->smoothFuture($driver, $color, $width, $height); - - break; - - case awShadow::LEFT_BOTTOM : - - if($mode === awShadow::OUT) { - $t1 = $p1->move(- $this->size, 0); - $t2 = $p2->move(0, $this->size + 1); - } else { // PHP 4 compatibility - $t1 = $p1->move(0, 0); - $t2 = $p2->move(0, 0); - } - - $width = $t2->x - $t1->x; - $height = $t2->y - $t1->y; - - $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint(0, $this->size), - new awPoint($this->size - 1, $height - 1) - ) - ); - - $driver->filledRectangle( - $color, - new awLine( - new awPoint($this->size, $height - $this->size), - new awPoint($width - $this->size - 1, $height - 1) - ) - ); - - $this->smoothFuture($driver, $color, $width, $height); - - break; - - } - - } - - private function smoothPast(awDriver $driver, awColor $color, $width, $height) { - - if($this->smooth) { - - for($i = 0; $i < $this->size; $i++) { - for($j = 0; $j <= $i; $j++) { - $driver->point( - $color, - new awPoint($i, $j + $height - $this->size) - ); - } - } - - for($i = 0; $i < $this->size; $i++) { - for($j = 0; $j <= $i; $j++) { - $driver->point( - $color, - new awPoint($width - $this->size + $j, $i) - ); - } - } - - } - - } - - private function smoothFuture(awDriver $driver, awColor $color, $width, $height) { - - if($this->smooth) { - - for($i = 0; $i < $this->size; $i++) { - for($j = 0; $j <= $i; $j++) { - $driver->point( - $color, - new awPoint($i, $this->size - $j - 1) - ); - } - } - - for($i = 0; $i < $this->size; $i++) { - for($j = 0; $j <= $i; $j++) { - $driver->point( - $color, - new awPoint($width - $this->size + $j, $height - $i - 1) - ); - } - } - - } - } - -} - -registerClass('Shadow'); diff --git a/modules/graphartichow/artichow/inc/Text.class.php b/modules/graphartichow/artichow/inc/Text.class.php deleted file mode 100644 index 663444425..000000000 --- a/modules/graphartichow/artichow/inc/Text.class.php +++ /dev/null @@ -1,233 +0,0 @@ -setText($text); - $this->setFont($font); - - // Set default color to black - if($color === NULL) { - $color = new awColor(0, 0, 0); - } - - $this->setColor($color); - $this->setAngle($angle); - - $this->border = new awBorder; - $this->border->hide(); - - } - - /** - * Get text - * - * @return string - */ - public function getText() { - return $this->text; - } - - /** - * Change text - * - * @param string $text New text - */ - public function setText($text) { - $this->text = (string)$text; - $this->text = str_replace("\r", "", $text); - } - - /** - * Change text font - * - * @param Font - */ - public function setFont(awFont $font) { - $this->font = $font; - } - - /** - * Get text font - * - * @return int - */ - public function getFont() { - return $this->font; - } - - /** - * Change text angle - * - * @param int - */ - public function setAngle($angle) { - $this->angle = (int)$angle; - } - - /** - * Get text angle - * - * @return int - */ - public function getAngle() { - return $this->angle; - } - - /** - * Change text color - * - * @param Color - */ - public function setColor(awColor $color) { - $this->color = $color; - } - - /** - * Get text color - * - * @return Color - */ - public function getColor() { - return $this->color; - } - - /** - * Change text background - * - * @param mixed $background - */ - public function setBackground($background) { - if($background instanceof awColor) { - $this->setBackgroundColor($background); - } elseif($background instanceof awGradient) { - $this->setBackgroundGradient($background); - } - } - - /** - * Change text background color - * - * @param awColor $color - */ - public function setBackgroundColor(awColor $color) { - $this->background = $color; - } - - /** - * Change text background gradient - * - * @param awGradient $gradient - */ - public function setBackgroundGradient(awGradient $gradient) { - $this->background = $gradient; - } - - /** - * Get text background - * - * @return Color, Gradient - */ - public function getBackground() { - return $this->background; - } - - /** - * Change padding - * - * @param int $left Left padding - * @param int $right Right padding - * @param int $top Top padding - * @param int $bottom Bottom padding - */ - public function setPadding($left, $right, $top, $bottom) { - $this->padding = array((int)$left, (int)$right, (int)$top, (int)$bottom); - } - - /** - * Get current padding - * - * @return array - */ - public function getPadding() { - return $this->padding; - } - -} - -registerClass('Text'); - diff --git a/modules/graphartichow/artichow/inc/Tick.class.php b/modules/graphartichow/artichow/inc/Tick.class.php deleted file mode 100644 index 4bfc46b80..000000000 --- a/modules/graphartichow/artichow/inc/Tick.class.php +++ /dev/null @@ -1,343 +0,0 @@ -setSize($size); - $this->setNumber($number); - $this->setColor(new awBlack); - $this->style = awTick::IN; - - } - - /** - * Change ticks style - * - * @param int $style - */ - public function setStyle($style) { - $this->style = (int)$style; - } - - /** - * Get ticks style - * - * @return int - */ - public function getStyle() { - return $this->style; - } - - /** - * Change ticks color - * - * @param awColor $color - */ - public function setColor(awColor $color) { - $this->color = $color; - } - - /** - * Change ticks size - * - * @param int $size - */ - public function setSize($size) { - $this->size = (int)$size; - } - - /** - * Change interval of ticks - * - * @param int $interval - */ - public function setInterval($interval) { - $this->interval = (int)$interval; - } - - /** - * Get interval between each tick - * - * @return int - */ - public function getInterval() { - return $this->interval; - } - - /** - * Change number of ticks - * - * @param int $number - */ - public function setNumber($number) { - $this->number = (int)$number; - } - - /** - * Get number of ticks - * - * @return int - */ - public function getNumber() { - return $this->number; - } - - /** - * Change number of ticks relative to others ticks - * - * @param awTick $tick Ticks reference - * @param int $number Number of ticks - */ - public function setNumberByTick(awTick $tick, $number) { - - $this->numberByTick = array($tick, (int)$number); - - } - - /** - * Hide ticks - * - * @param bool $hide - */ - public function hide($hide) { - $this->hide = (bool)$hide; - } - - /** - * Hide first tick - * - * @param bool $hide - */ - public function hideFirst($hide) { - $this->hideFirst = (bool)$hide; - } - - /** - * Hide last tick - * - * @param bool $hide - */ - public function hideLast($hide) { - $this->hideLast = (bool)$hide; - } - - /** - * Draw ticks on a vector - * - * @param awDriver $driver A driver - * @param awVector $vector A vector - */ - public function draw(awDriver $driver, awVector $vector) { - - if($this->numberByTick !== NULL) { - list($tick, $number) = $this->numberByTick; - $this->number = 1 + ($tick->getNumber() - 1) * ($number + 1); - $this->interval = $tick->getInterval(); - } - - if($this->number < 2 or $this->hide) { - return; - } - - $angle = $vector->getAngle(); - // echo "INIT:".$angle."
"; - switch($this->style) { - - case awTick::IN : - $this->drawTicks($driver, $vector, NULL, $angle + M_PI / 2); - break; - - case awTick::OUT : - $this->drawTicks($driver, $vector, $angle + 3 * M_PI / 2, NULL); - break; - - default : - $this->drawTicks($driver, $vector, $angle + M_PI / 2, $angle + 3 * M_PI / 2); - break; - - } - - } - - protected function drawTicks(awDriver $driver, awVector $vector, $from, $to) { - - // Draw last tick - if($this->hideLast === FALSE) { - - //echo ''; - if(($this->number - 1) % $this->interval === 0) { - $this->drawTick($driver, $vector->p2, $from, $to); - } - //echo ''; - - } - - $number = $this->number - 1; - $size = $vector->getSize(); - - // Get tick increment in pixels - $inc = $size / $number; - - // Check if we must hide the first tick - $start = $this->hideFirst ? $inc : 0; - $stop = $inc * $number; - - $position = 0; - - for($i = $start; round($i, 6) < $stop; $i += $inc) { - - if($position % $this->interval === 0) { - $p = $vector->p1->move( - round($i * cos($vector->getAngle()), 6), - round($i * sin($vector->getAngle() * -1), 6) - ); - $this->drawTick($driver, $p, $from, $to); - } - - $position++; - - } - //echo '

'; - } - - protected function drawTick(awDriver $driver, awPoint $p, $from, $to) { -// echo $this->size.':'.$angle.'|'.cos($angle).'/'; - // The round avoid some errors in the calcul - // For example, 12.00000008575245 becomes 12 - $p1 = $p; - $p2 = $p; - - if($from !== NULL) { - $p1 = $p1->move( - round($this->size * cos($from), 6), - round($this->size * sin($from) * -1, 6) - ); - } - - if($to !== NULL) { - $p2 = $p2->move( - round($this->size * cos($to), 6), - round($this->size * sin($to) * -1, 6) - ); - } - //echo $p1->x.':'.$p2->x.'('.$p1->y.':'.$p2->y.')'.'/'; - $vector = new awVector( - $p1, $p2 - ); - - $driver->line( - $this->color, - $vector - ); - - } - -} - -registerClass('Tick'); diff --git a/modules/graphartichow/artichow/inc/Tools.class.php b/modules/graphartichow/artichow/inc/Tools.class.php deleted file mode 100644 index 05ca3342e..000000000 --- a/modules/graphartichow/artichow/inc/Tools.class.php +++ /dev/null @@ -1,174 +0,0 @@ -set($left, $right, $top, $bottom); - } - - - /** - * Change side values - * - * @param mixed $left - * @param mixed $right - * @param mixed $top - * @param mixed $bottom - */ - public function set($left = NULL, $right = NULL, $top = NULL, $bottom = NULL) { - - if($left !== NULL) { - $this->left = (float)$left; - } - if($right !== NULL) { - $this->right = (float)$right; - } - if($top !== NULL) { - $this->top = (float)$top; - } - if($bottom !== NULL) { - $this->bottom = (float)$bottom; - } - - } - - - /** - * Add values to each side - * - * @param mixed $left - * @param mixed $right - * @param mixed $top - * @param mixed $bottom - */ - public function add($left = NULL, $right = NULL, $top = NULL, $bottom = NULL) { - - if($left !== NULL) { - $this->left += (float)$left; - } - if($right !== NULL) { - $this->right += (float)$right; - } - if($top !== NULL) { - $this->top += (float)$top; - } - if($bottom !== NULL) { - $this->bottom += (float)$bottom; - } - - } - -} - -registerClass('Side'); diff --git a/modules/graphartichow/artichow/inc/drivers/gd.class.php b/modules/graphartichow/artichow/inc/drivers/gd.class.php deleted file mode 100644 index dcf2f33be..000000000 --- a/modules/graphartichow/artichow/inc/drivers/gd.class.php +++ /dev/null @@ -1,1335 +0,0 @@ -driverString = 'gd'; - } - - public function init(awImage $image) { - - if($this->resource === NULL) { - - $this->setImageSize($image->width, $image->height); - - // Create image - $this->resource = imagecreatetruecolor($this->imageWidth, $this->imageHeight); - if(!$this->resource) { - awImage::drawError("Class Image: Unable to create a graph."); - } - - imagealphablending($this->resource, TRUE); - - // Antialiasing is now handled by the Driver object - $this->setAntiAliasing($image->getAntiAliasing()); - - // Original color - $this->filledRectangle( - new awWhite, - new awLine( - new awPoint(0, 0), - new awPoint($this->imageWidth, $this->imageHeight) - ) - ); - - $shadow = $image->shadow; - if($shadow !== NULL) { - $shadow = $shadow->getSpace(); - $p1 = new awPoint($shadow->left, $shadow->top); - $p2 = new awPoint($this->imageWidth - $shadow->right - 1, $this->imageHeight - $shadow->bottom - 1); - - - // Draw image background - $this->filledRectangle($image->getBackground(), new awLine($p1, $p2)); - - // Draw image border - $image->border->rectangle($this, $p1, $p2); - } - - } - } - - public function initFromFile(awFileImage $fileImage, $file) { - - $image = @getimagesize((string)$file); - - if($image and in_array($image[2], array(2, 3))) { - - $fileImage->setSize($image[0], $image[1]); - - switch($image[2]) { - - case 2 : - $this->resource = imagecreatefromjpeg($file); - break; - - case 3 : - $this->resource = imagecreatefrompng($file); - break; - - } - - $this->setImageSize($fileImage->width, $fileImage->height); - } else { - awImage::drawError("Class FileImage: Artichow does not support the format of this image (must be in PNG or JPEG)"); - } - } - - public function setImageSize($width, $height) { - - $this->imageWidth = $width; - $this->imageHeight = $height; - - } - - public function setPosition($x, $y) { - - // Calculate absolute position - $this->x = round($x * $this->imageWidth - $this->w / 2); - $this->y = round($y * $this->imageHeight - $this->h / 2); - - } - - public function setAbsPosition($x, $y) { - - $this->x = $x; - $this->y = $y; - - } - - public function movePosition($x, $y) { - - $this->x += (int)$x; - $this->y += (int)$y; - - } - - public function setSize($w, $h) { - - // Calcul absolute size - $this->w = round($w * $this->imageWidth); - $this->h = round($h * $this->imageHeight); - - return $this->getSize(); - - } - - public function setAbsSize($w, $h) { - - $this->w = $w; - $this->h = $h; - - return $this->getSize(); - - } - - public function getSize() { - - return array($this->w, $this->h); - - } - - public function setAntiAliasing($bool) { - - if(function_exists('imageantialias')) { - imageantialias($this->resource, (bool)$bool); - - $this->antiAliasing = (bool)$bool; - } elseif ($bool == true) { - awImage::drawErrorFile('missing-anti-aliasing'); - } - } - - public function getColor(awColor $color) { - - if($color->alpha === 0 or function_exists('imagecolorallocatealpha') === FALSE) { - $gdColor = imagecolorallocate($this->resource, $color->red, $color->green, $color->blue); - } else { - $gdColor = imagecolorallocatealpha($this->resource, $color->red, $color->green, $color->blue, $color->alpha); - } - - return $gdColor; - } - - public function copyImage(awImage $image, awPoint $p1, awPoint $p2) { - - list($x1, $y1) = $p1->getLocation(); - list($x2, $y2) = $p2->getLocation(); - - $driver = $image->getDriver(); - imagecopy($this->resource, $driver->resource, $this->x + $x1, $this->y + $y1, 0, 0, $x2 - $x1, $y2 - $y1); - - } - - public function copyResizeImage(awImage $image, awPoint $d1, awPoint $d2, awPoint $s1, awPoint $s2, $resample = TRUE) { - - if($resample) { - $function = 'imagecopyresampled'; - } else { - $function = 'imagecopyresized'; - } - - $driver = $image->getDriver(); - - $function( - $this->resource, - $driver->resource, - $this->x + $d1->x, $this->y + $d1->y, - $s1->x, $s1->y, - $d2->x - $d1->x, $d2->y - $d1->y, - $s2->x - $s1->x, $s2->y - $s1->y - ); - - } - - public function string(awText $text, awPoint $point, $width = NULL) { - - $font = $text->getFont(); - - // Can we deal with that font? - if($this->isCompatibleWithFont($font) === FALSE) { - awImage::drawError('Class GDDriver: Incompatible font type (\''.get_class($font).'\')'); - } - - // Check which FontDriver to use - if($font instanceof awPHPFont) { - $fontDriver = $this->phpFontDriver; - } else { - $fontDriver = $this->fileFontDriver; - } - - if($text->getBackground() !== NULL or $text->border->visible()) { - - list($left, $right, $top, $bottom) = $text->getPadding(); - - $textWidth = $fontDriver->getTextWidth($text, $this); - $textHeight = $fontDriver->getTextHeight($text, $this); - - $x1 = floor($point->x - $left); - $y1 = floor($point->y - $top); - $x2 = $x1 + $textWidth + $left + $right; - $y2 = $y1 + $textHeight + $top + $bottom; - - $this->filledRectangle( - $text->getBackground(), - awLine::build($x1, $y1, $x2, $y2) - ); - - $text->border->rectangle( - $this, - new awPoint($x1 - 1, $y1 - 1), - new awPoint($x2 + 1, $y2 + 1) - ); - - } - - $fontDriver->string($this, $text, $point, $width); - - } - - public function point(awColor $color, awPoint $p) { - - if($p->isHidden() === FALSE) { - $rgb = $this->getColor($color); - imagesetpixel($this->resource, $this->x + round($p->x), $this->y + round($p->y), $rgb); - } - - } - - public function line(awColor $color, awLine $line) { - - if($line->thickness > 0 and $line->isHidden() === FALSE) { - - $rgb = $this->getColor($color); - $thickness = $line->thickness; - - list($p1, $p2) = $line->getLocation(); - - $this->startThickness($thickness); - - switch($line->getStyle()) { - - case awLine::SOLID : - imageline($this->resource, $this->x + round($p1->x), $this->y + round($p1->y), $this->x + round($p2->x), $this->y + round($p2->y), $rgb); - break; - - case awLine::DOTTED : - $size = sqrt(pow($p2->y - $p1->y, 2) + pow($p2->x - $p1->x, 2)); - $cos = ($p2->x - $p1->x) / $size; - $sin = ($p2->y - $p1->y) / $size; - for($i = 0; $i <= $size; $i += 2) { - $p = new awPoint( - round($i * $cos + $p1->x), - round($i * $sin + $p1->y) - ); - $this->point($color, $p); - } - break; - - case awLine::DASHED : - $width = $p2->x - $p1->x; - $height = $p2->y - $p1->y; - $size = sqrt(pow($height, 2) + pow($width, 2)); - - if($size == 0) { - return; - } - - $cos = $width / $size; - $sin = $height / $size; - - $functionX = ($width > 0) ? 'min' : 'max'; - $functionY = ($height > 0) ? 'min' : 'max'; - - for($i = 0; $i <= $size; $i += 6) { - - $t1 = new awPoint( - round($i * $cos + $p1->x), - round($i * $sin + $p1->y) - ); - - $t2 = new awPoint( - round($functionX(($i + 3) * $cos, $width) + $p1->x), - round($functionY(($i + 3) * $sin, $height) + $p1->y) - ); - - $this->line($color, new awLine($t1, $t2)); - - } - break; - - } - - $this->stopThickness($thickness); - - } - - } - - public function arc(awColor $color, awPoint $center, $width, $height, $from, $to) { - - imagefilledarc( - $this->resource, - $this->x + $center->x, $this->y + $center->y, - $width, $height, - $from, $to, - $this->getColor($color), - IMG_ARC_EDGED | IMG_ARC_NOFILL - ); - - } - - public function filledArc(awColor $color, awPoint $center, $width, $height, $from, $to) { - - imagefilledarc( - $this->resource, - $this->x + $center->x, $this->y + $center->y, - $width, $height, - $from, $to, - $this->getColor($color), - IMG_ARC_PIE - ); - - } - - public function ellipse(awColor $color, awPoint $center, $width, $height) { - - list($x, $y) = $center->getLocation(); - - $rgb = $this->getColor($color); - imageellipse( - $this->resource, - $this->x + $x, - $this->y + $y, - $width, - $height, - $rgb - ); - - } - - public function filledEllipse($background, awPoint $center, $width, $height) { - - if($background instanceof awColor) { - - list($x, $y) = $center->getLocation(); - - $rgb = $this->getColor($background); - - imagefilledellipse( - $this->resource, - $this->x + $x, - $this->y + $y, - $width, - $height, - $rgb - ); - - } else if($background instanceof awGradient) { - - list($x, $y) = $center->getLocation(); - - $x1 = $x - round($width / 2); - $y1 = $y - round($height / 2); - $x2 = $x1 + $width; - $y2 = $y1 + $height; - - $gradientDriver = new awGDGradientDriver($this); - $gradientDriver->filledEllipse( - $background, - $x1, $y1, - $x2, $y2 - ); - - } - - } - - public function rectangle(awColor $color, awLine $line) { - - list($p1, $p2) = $line->getLocation(); - - switch($line->getStyle()) { - - case awLine::SOLID : - $thickness = $line->getThickness(); - $this->startThickness($thickness); - $rgb = $this->getColor($color); - imagerectangle($this->resource, $this->x + $p1->x, $this->y + $p1->y, $this->x + $p2->x, $this->y + $p2->y, $rgb); - $this->stopThickness($thickness); - break; - - default : - - $side = clone $line; - - - - // Top side - $side->setLocation( - new awPoint($p1->x, $p1->y), - new awPoint($p2->x, $p1->y) - ); - $this->line($color, $side); - - // Right side - $side->setLocation( - new awPoint($p2->x, $p1->y), - new awPoint($p2->x, $p2->y) - ); - $this->line($color, $side); - - // Bottom side - $side->setLocation( - new awPoint($p1->x, $p2->y), - new awPoint($p2->x, $p2->y) - ); - $this->line($color, $side); - - // Left side - $side->setLocation( - new awPoint($p1->x, $p1->y), - new awPoint($p1->x, $p2->y) - ); - $this->line($color, $side); - - break; - - } - - } - - public function filledRectangle($background, awLine $line) { - - $p1 = $line->p1; - $p2 = $line->p2; - - if($background instanceof awColor) { - $rgb = $this->getColor($background); - imagefilledrectangle($this->resource, $this->x + $p1->x, $this->y + $p1->y, $this->x + $p2->x, $this->y + $p2->y, $rgb); - } else if($background instanceof awGradient) { - $gradientDriver = new awGDGradientDriver($this); - $gradientDriver->filledRectangle($background, $p1, $p2); - } - - } - - public function polygon(awColor $color, awPolygon $polygon) { - - switch($polygon->getStyle()) { - - case awPolygon::SOLID : - $thickness = $polygon->getThickness(); - $this->startThickness($thickness); - $points = $this->getPolygonPoints($polygon); - $rgb = $this->getColor($color); - imagepolygon($this->resource, $points, $polygon->count(), $rgb); - $this->stopThickness($thickness); - break; - - default : - - if($polygon->count() > 1) { - - $prev = $polygon->get(0); - - $line = new awLine; - $line->setStyle($polygon->getStyle()); - $line->setThickness($polygon->getThickness()); - - for($i = 1; $i < $polygon->count(); $i++) { - $current = $polygon->get($i); - $line->setLocation($prev, $current); - $this->line($color, $line); - $prev = $current; - } - - // Close the polygon - $line->setLocation($prev, $polygon->get(0)); - $this->line($color, $line); - - } - - } - - } - - public function filledPolygon($background, awPolygon $polygon) { - - if($background instanceof awColor) { - - $points = $this->getPolygonPoints($polygon); - $rgb = $this->getColor($background); - - imagefilledpolygon($this->resource, $points, $polygon->count(), $rgb); - - } else if($background instanceof awGradient) { - - $gradientDriver = new awGDGradientDriver($this); - $gradientDriver->filledPolygon($background, $polygon); - - } - - } - - public function send(awImage $image) { - - $this->drawImage($image); - - } - - public function get(awImage $image) { - - return $this->drawImage($image, TRUE, FALSE); - - } - - public function getTextWidth(awText $text) { - $font = $text->getFont(); - - if($font instanceof awPHPFont) { - $fontDriver = $this->phpFontDriver; - } else { - $fontDriver = $this->fileFontDriver; - } - - return $fontDriver->getTextWidth($text, $this); - } - - public function getTextHeight(awText $text) { - $font = $text->getFont(); - - if($font instanceof awPHPFont) { - $fontDriver = $this->phpFontDriver; - } else { - $fontDriver = $this->fileFontDriver; - } - - return $fontDriver->getTextHeight($text, $this); - } - - protected function isCompatibleWithFont(awFont $font) { - if($font instanceof awFDBFont) { - return FALSE; - } else { - return TRUE; - } - } - - private function drawImage(awImage $image, $return = FALSE, $header = TRUE) { - - $format = $image->getFormatString(); - - // Test if format is available - if((imagetypes() & $image->getFormat()) === FALSE) { - awImage::drawError("Class Image: Format '".$format."' is not available on your system. Check that your PHP has been compiled with the good libraries."); - } - - // Get some infos about this image - switch($format) { - case 'jpeg' : - $function = 'imagejpeg'; - break; - case 'png' : - $function = 'imagepng'; - break; - case 'gif' : - $function = 'imagegif'; - break; - } - - // Send headers to the browser - if($header === TRUE) { - $image->sendHeaders(); - } - - if($return) { - ob_start(); - } - - $function($this->resource); - - if($return) { - return ob_get_clean(); - } - } - - private function getPolygonPoints(awPolygon $polygon) { - - $points = array(); - - foreach($polygon->all() as $point) { - $points[] = $point->x + $this->x; - $points[] = $point->y + $this->y; - } - - return $points; - - } - - private function startThickness($thickness) { - - if($thickness > 1) { - - // Beurk :'( - if($this->antiAliasing and function_exists('imageantialias')) { - imageantialias($this->resource, FALSE); - } - imagesetthickness($this->resource, $thickness); - - } - - } - - private function stopThickness($thickness) { - - if($thickness > 1) { - - if($this->antiAliasing and function_exists('imageantialias')) { - imageantialias($this->resource, TRUE); - } - imagesetthickness($this->resource, 1); - - } - - } - - -} - -registerClass('GDDriver'); - -/** - * To your gradients - * - * @package Artichow - */ - -class awGDGradientDriver { - - /** - * A driver - * - * @var awGDDriver - */ - protected $driver; - - /** - * Build your GDGradientDriver - * - * @var awGDDriver $driver - */ - public function __construct(awGDDriver $driver) { - - $this->driver = $driver; - - } - - public function drawFilledFlatTriangle(awGradient $gradient, awPoint $a, awPoint $b, awPoint $c) { - - if($gradient->angle !== 0) { - awImage::drawError("Class GDGradientDriver: Flat triangles can only be used with 0 degree gradients."); - } - - // Look for right-angled triangle - if($a->x !== $b->x and $b->x !== $c->x) { - awImage::drawError("Class GDGradientDriver: Not right-angled flat triangles are not supported yet."); - } - - if($a->x === $b->x) { - $d = $a; - $e = $c; - } else { - $d = $c; - $e = $a; - } - - $this->init($gradient, $b->y - $d->y); - - for($i = $c->y + 1; $i < $b->y; $i++) { - - $color = $this->color($i - $d->y); - $pos = ($i - $d->y) / ($b->y - $d->y); - - $p1 = new awPoint($e->x, $i); - $p2 = new awPoint(1 + floor($e->x - $pos * ($e->x - $d->x)), $i); - - $this->driver->filledRectangle($color, new awLine($p1, $p2)); - - unset($color); - - } - - } - - protected function drawFilledTriangle(awGradient $gradient, awPolygon $polygon) { - - if($gradient->angle === 0) { - $this->drawFilledTriangleVertically($gradient, $polygon); - } elseif($gradient->angle === 90) { - $this->drawFilledTriangleHorizontally($gradient, $polygon); - } - - } - - private function drawFilledTriangleVertically(awGradient $gradient, awPolygon $polygon) { - list($yMin, $yMax) = $polygon->getBoxYRange(); - - $this->init($gradient, $yMax - $yMin); - - // Get the triangle line we will draw our lines from - $fromLine = NULL; - $lines = $polygon->getLines(); - - $count = count($lines); - - // Pick the side of the triangle going from the top - // to the bottom of the surrounding box - for($i = 0; $i < $count; $i++) { - if($lines[$i]->isTopToBottom($polygon)) { - list($fromLine) = array_splice($lines, $i, 1); - break; - } - } - - // If for some reason the three points are aligned, - // $fromLine will still be NULL - if($fromLine === NULL) { - return; - } - - $fillLine = NULL; - for($y = round($yMin); $y < round($yMax); $y++) { - - $fromX = $fromLine->getXFrom($y); - - $toX = array(); - foreach($lines as $line) { - $xValue = $line->getXFrom($y); - - if(!is_null($xValue)) { - $toX[] = $xValue; - } - } - - if(count($toX) === 1) { - $fillLine = new Line( - new Point($fromX, $y), - new Point($toX[0], $y) - ); - } else { - - $line1 = new Line( - new Point($fromX, $y), - new Point($toX[0], $y) - ); - $line2 = new Line( - new Point($fromX, $y), - new Point($toX[1], $y) - ); - - if($line1->getSize() < $line2->getSize()) { - $fillLine = $line1; - } else { - $fillLine = $line2; - } - } - - if(!$fillLine->isPoint()) { - $color = $this->color($y - $yMin); - $this->driver->line($color, $fillLine); - - unset($color); - } - } - - } - - private function drawFilledTriangleHorizontally(awGradient $gradient, awPolygon $polygon) { - list($xMin, $xMax) = $polygon->getBoxXRange(); - - $this->init($gradient, $xMax - $xMin); - - // Get the triangle line we will draw our lines from - $fromLine = NULL; - $lines = $polygon->getLines(); - - $count = count($lines); - - // Pick the side of the triangle going all the way - // from the left side to the right side of the surrounding box - for($i = 0; $i < $count; $i++) { - if($lines[$i]->isLeftToRight($polygon)) { - list($fromLine) = array_splice($lines, $i, 1); - break; - } - } - - // If for some reason the three points are aligned, - // $fromLine will still be NULL - if($fromLine === NULL) { - return; - } - - $fillLine = NULL; - for($x = round($xMin); $x < round($xMax); $x++) { - - $fromY = floor($fromLine->getYFrom($x)); - - $toY = array(); - foreach($lines as $line) { - $yValue = $line->getYFrom($x); - - if(!is_null($yValue)) { - $toY[] = floor($yValue); - } - } - - if(count($toY) === 1) { - $fillLine = new Line( - new Point($x, $fromY), - new Point($x, $toY[0]) - ); - } else { - - $line1 = new Line( - new Point($x, $fromY), - new Point($x, $toY[0]) - ); - $line2 = new Line( - new Point($x, $fromY), - new Point($x, $toY[1]) - ); - - if($line1->getSize() < $line2->getSize()) { - $fillLine = $line1; - } else { - $fillLine = $line2; - } - } - - $color = $this->color($x - $xMin); - if($fillLine->isPoint()) { - $this->driver->point($color, $fillLine->p1); - } elseif($fillLine->getSize() >= 1) { - $this->driver->line($color, $fillLine); - } - unset($color); - } - - } - - public function filledRectangle(awGradient $gradient, awPoint $p1, awPoint $p2) { - - list($x1, $y1) = $p1->getLocation(); - list($x2, $y2) = $p2->getLocation(); - - if($y1 < $y2) { - $y1 ^= $y2 ^= $y1 ^= $y2; - } - - if($x2 < $x1) { - $x1 ^= $x2 ^= $x1 ^= $x2; - } - - if($gradient instanceof awLinearGradient) { - $this->rectangleLinearGradient($gradient, new awPoint($x1, $y1), new awPoint($x2, $y2)); - } else { - awImage::drawError("Class GDGradientDriver: This gradient is not supported by rectangles."); - } - - } - - public function filledPolygon(awGradient $gradient, awPolygon $polygon) { - - if($gradient instanceof awLinearGradient) { - $this->polygonLinearGradient($gradient, $polygon); - } else { - awImage::drawError("Class GDGradientDriver: This gradient is not supported by polygons."); - } - - } - - protected function rectangleLinearGradient(awLinearGradient $gradient, awPoint $p1, awPoint $p2) { - - list($x1, $y1) = $p1->getLocation(); - list($x2, $y2) = $p2->getLocation(); - - if($y1 - $y2 > 0) { - - if($gradient->angle === 0) { - - $this->init($gradient, $y1 - $y2); - - for($i = $y2; $i <= $y1; $i++) { - - $color = $this->color($i - $y2); - - $p1 = new awPoint($x1, $i); - $p2 = new awPoint($x2, $i); - - $this->driver->filledRectangle($color, new awLine($p1, $p2)); - - unset($color); - - } - - } else if($gradient->angle === 90) { - - $this->init($gradient, $x2 - $x1); - - for($i = $x1; $i <= $x2; $i++) { - - $color = $this->color($i - $x1); - - $p1 = new awPoint($i, $y2); - $p2 = new awPoint($i, $y1); - - $this->driver->filledRectangle($color, new awLine($p1, $p2)); - - unset($color); - - } - - } - - } - - } - - public function filledEllipse(awGradient $gradient, $x1, $y1, $x2, $y2) { - - if($y1 < $y2) { - $y1 ^= $y2 ^= $y1 ^= $y2; - } - - if($x2 < $x1) { - $x1 ^= $x2 ^= $x1 ^= $x2; - } - - if($gradient instanceof awRadialGradient) { - $this->ellipseRadialGradient($gradient, $x1, $y1, $x2, $y2); - } else if($gradient instanceof awLinearGradient) { - $this->ellipseLinearGradient($gradient, $x1, $y1, $x2, $y2); - } else { - awImage::drawError("Class GDGradientDriver: This gradient is not supported by ellipses."); - } - - } - - protected function ellipseRadialGradient(awGradient $gradient, $x1, $y1, $x2, $y2) { - - if($y1 - $y2 > 0) { - - if($y1 - $y2 != $x2 - $x1) { - awImage::drawError("Class GDGradientDriver: Radial gradients are only implemented on circle, not ellipses."); - } - - $c = new awPoint($x1 + ($x2 - $x1) / 2, $y1 + ($y2 - $y1) / 2); - $r = ($x2 - $x1) / 2; - $ok = array(); - - // Init gradient - $this->init($gradient, $r); - - for($i = 0; $i <= $r; $i += 0.45) { - - $p = ceil((2 * M_PI * $i)); - - if($p > 0) { - $interval = 360 / $p; - } else { - $interval = 360; - } - - $color = $this->color($i); - - for($j = 0; $j < 360; $j += $interval) { - - $rad = ($j / 360) * (2 * M_PI); - - $x = round($i * cos($rad)); - $y = round($i * sin($rad)); - - $l = sqrt($x * $x + $y * $y); - - if($l <= $r) { - - if( - array_key_exists((int)$x, $ok) === FALSE or - array_key_exists((int)$y, $ok[$x]) === FALSE - ) { - - // Print the point - $this->driver->point($color, new awPoint($c->x + $x, $c->y + $y)); - - $ok[(int)$x][(int)$y] = TRUE; - - } - - } - - } - - unset($color); - - } - - } - - } - - protected function ellipseLinearGradient(awGradient $gradient, $x1, $y1, $x2, $y2) { - - // Gauche->droite : 90° - - if($y1 - $y2 > 0) { - - if($y1 - $y2 != $x2 - $x1) { - awImage::drawError("Class GDGradientDriver: Linear gradients are only implemented on circle, not ellipses."); - } - - $r = ($x2 - $x1) / 2; - - // Init gradient - $this->init($gradient, $x2 - $x1); - - for($i = -$r; $i <= $r; $i++) { - - $h = sin(acos($i / $r)) * $r; - - $color = $this->color($i + $r); - - if($gradient->angle === 90) { - - // Print the line - $p1 = new awPoint( - $x1 + $i + $r, - round(max($y2 + $r - $h + 1, $y2)) - ); - - $p2 = new awPoint( - $x1 + $i + $r, - round(min($y1 - $r + $h - 1, $y1)) - ); - - } else { - - // Print the line - $p1 = new awPoint( - round(max($x1 + $r - $h + 1, $x1)), - $y2 + $i + $r - ); - - $p2 = new awPoint( - round(min($x2 - $r + $h - 1, $x2)), - $y2 + $i + $r - ); - - } - - $this->driver->filledRectangle($color, new awLine($p1, $p2)); - - unset($color); - - } - - } - - } - - protected function polygonLinearGradient(awLinearGradient $gradient, awPolygon $polygon) { - - $count = $polygon->count(); - - if($count >= 4) { - - $left = $polygon->get(0); - $right = $polygon->get($count - 1); - - if($gradient->angle === 0) { - - // Get polygon maximum and minimum - $offset = $polygon->get(0); - $max = $min = $offset->y; - for($i = 1; $i < $count - 1; $i++) { - $offset = $polygon->get($i); - $max = max($max, $offset->y); - $min = min($min, $offset->y); - } - - $this->init($gradient, $max - $min); - - $prev = $polygon->get(1); - - $sum = 0; - - for($i = 2; $i < $count - 1; $i++) { - - $current = $polygon->get($i); - - $interval = 1; - - if($i !== $count - 2) { - $current->x -= $interval; - } - - if($current->x - $prev->x > 0) { - - // Draw rectangle - $x1 = $prev->x; - $x2 = $current->x; - $y1 = max($prev->y, $current->y); - $y2 = $left->y; - - $gradient = new awLinearGradient( - $this->color($max - $min - ($y2 - $y1)), - $this->color($max - $min), - 0 - ); - - if($y1 > $y2) { - $y2 = $y1; - } - - $this->driver->filledRectangle( - $gradient, - awLine::build($x1, $y1, $x2, $y2) - ); - - $top = ($prev->y < $current->y) ? $current : $prev; - $bottom = ($prev->y >= $current->y) ? $current : $prev; - - $gradient = new awLinearGradient( - $this->color($bottom->y - $min), - $this->color($max - $min - ($y2 - $y1)), - 0 - ); - - - $gradientDriver = new awGDGradientDriver($this->driver); - $gradientDriver->drawFilledFlatTriangle( - $gradient, - new awPoint($prev->x, min($prev->y, $current->y)), - $top, - new awPoint($current->x, min($prev->y, $current->y)) - ); - unset($gradientDriver); - - $sum += $current->x - $prev->x; - - } - - $prev = $current; - $prev->x += $interval; - - } - - } else if($gradient->angle === 90) { - - $width = $right->x - $left->x; - $this->init($gradient, $width); - - $pos = 1; - $next = $polygon->get($pos++); - - $this->next($polygon, $pos, $prev, $next); - - for($i = 0; $i <= $width; $i++) { - - $x = $left->x + $i; - - $y1 = round($prev->y + ($next->y - $prev->y) * (($i + $left->x - $prev->x) / ($next->x - $prev->x))); - $y2 = $left->y; - - // Draw line - $color = $this->color($i); - // YaPB : PHP does not handle alpha on lines - $this->driver->filledRectangle($color, awLine::build($x, $y1, $x, $y2)); - - unset($color); - - // Jump to next point - if($next->x == $i + $left->x) { - - $this->next($polygon, $pos, $prev, $next); - - } - - } - - } - - } else if($count === 3) { - $this->drawFilledTriangle( - $gradient, - $polygon - ); - } - - } - - private function next($polygon, &$pos, &$prev, &$next) { - - do { - $prev = $next; - $next = $polygon->get($pos++); - } - while($next->x - $prev->x == 0 and $pos < $polygon->count()); - - } - - /** - * Start colors - * - * @var int - */ - private $r1, $g1, $b1, $a1; - - /** - * Stop colors - * - * @var int - */ - private $r2, $g2, $b2, $a2; - - /** - * Gradient size in pixels - * - * @var int - */ - private $size; - - - private function init(awGradient $gradient, $size) { - - list( - $this->r1, $this->g1, $this->b1, $this->a1 - ) = $gradient->from->rgba(); - - list( - $this->r2, $this->g2, $this->b2, $this->a2 - ) = $gradient->to->rgba(); - - $this->size = $size; - } - - private function color($pos) { - - return new awColor( - $this->getRed($pos), - $this->getGreen($pos), - $this->getBlue($pos), - $this->getAlpha($pos) - ); - - } - - - private function getRed($pos) { - if((float)$this->size !== 0.0) { - return (int)round($this->r1 + ($pos / $this->size) * ($this->r2 - $this->r1)); - } else { - return 0; - } - } - - private function getGreen($pos) { - if((float)$this->size !== 0.0) { - return (int)round($this->g1 + ($pos / $this->size) * ($this->g2 - $this->g1)); - } else { - return 0; - } - } - - private function getBlue($pos) { - if((float)$this->size !== 0.0) { - return (int)round($this->b1 + ($pos / $this->size) * ($this->b2 - $this->b1)); - } else { - return 0; - } - } - - private function getAlpha($pos) { - if((float)$this->size !== 0.0) { - return (int)round(($this->a1 + ($pos / $this->size) * ($this->a2 - $this->a1)) / 127 * 100); - } else { - return 0; - } - } - -} - -registerClass('GDGradientDriver'); - -/* - * Check for GD2 - */ -if(function_exists('imagecreatetruecolor') === FALSE) { - awImage::drawErrorFile('missing-gd2'); -} - diff --git a/modules/graphartichow/artichow/inc/drivers/index.php b/modules/graphartichow/artichow/inc/drivers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/inc/drivers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/artichow/inc/drivers/ming.class.php b/modules/graphartichow/artichow/inc/drivers/ming.class.php deleted file mode 100644 index aee0ae7db..000000000 --- a/modules/graphartichow/artichow/inc/drivers/ming.class.php +++ /dev/null @@ -1,773 +0,0 @@ -driverString = 'ming'; - - // Nice defaults - ming_setScale(20.0); - ming_useswfversion(6); - - } - - /** - * Initialize the driver for a particular awImage object - * - * @param awImage $image - */ - public function init(awImage $image) { - - if($this->movie === NULL) { - $this->setImageSize($image->width, $image->height); - - // Create movie - $this->movie = new SWFMovie(); - if(!$this->movie) { - awImage::drawError("Class Image: Unable to create a graph."); - } - - $this->movie->setDimension($image->width, $image->height); - - $this->setAntiAliasing($image->getAntiAliasing()); - - // Original color - $this->filledRectangle( - new awWhite, - new awLine( - new awPoint(0, 0), - new awPoint($this->imageWidth, $this->imageHeight) - ) - ); - - $shadow = $image->shadow; - if($shadow !== NULL) { - $shadow = $shadow->getSpace(); - $p1 = new awPoint($shadow->left, $shadow->top); - $p2 = new awPoint($this->imageWidth - $shadow->right - 1, $this->imageHeight - $shadow->bottom - 1); - - // Draw image background - $this->filledRectangle($image->getBackground(), new awLine($p1, $p2)); - - // Draw image border - $image->border->rectangle($this, $p1, $p2); - } - } - } - - /** - * Initialize the Driver for a particular FileImage object - * - * @param awFileImage $fileImage The FileImage object to work on - * @param string $file Image filename - */ - public function initFromFile(awFileImage $fileImage, $file) { - - } - - /** - * Change the image size - * - * @param int $width Image width - * @param int $height Image height - */ - public function setImageSize($width, $height) { - $this->imageWidth = $width; - $this->imageHeight = $height; - } - - /** - * Inform the driver of the position of your image - * - * @param float $x Position on X axis of the center of the component - * @param float $y Position on Y axis of the center of the component - */ - public function setPosition($x, $y) { - // Calculate absolute position - $this->x = round($x * $this->imageWidth - $this->w / 2); - $this->y = round($y * $this->imageHeight - $this->h / 2); - } - - /** - * Inform the driver of the position of your image - * This method need absolutes values - * - * @param int $x Left-top corner X position - * @param int $y Left-top corner Y position - */ - public function setAbsPosition($x, $y) { - $this->x = $x; - $this->y = $y; - } - - /** - * Move the position of the image - * - * @param int $x Add this value to X axis - * @param int $y Add this value to Y axis - */ - public function movePosition($x, $y) { - $this->x += (int)$x; - $this->y += (int)$y; - } - - /** - * Inform the driver of the size of your image - * Height and width must be between 0 and 1. - * - * @param int $w Image width - * @param int $h Image height - * @return array Absolute width and height of the image - */ - public function setSize($w, $h) { - - // Calcul absolute size - $this->w = round($w * $this->imageWidth); - $this->h = round($h * $this->imageHeight); - - return $this->getSize(); - - } - - /** - * Inform the driver of the size of your image - * You can set absolute size with this method. - * - * @param int $w Image width - * @param int $h Image height - */ - public function setAbsSize($w, $h) { - $this->w = $w; - $this->h = $h; - - return $this->getSize(); - } - - /** - * Get the size of the component handled by the driver - * - * @return array Absolute width and height of the component - */ - public function getSize() { - return array($this->w, $this->h); - } - - /** - * Turn antialiasing on or off - * - * @var bool $bool - */ - public function setAntiAliasing($bool) { - if($this->movie !== NULL) { - - $actionscript = ' - _quality = "%s"; - '; - - if((bool)$bool) { - $actionscript = sprintf($actionscript, 'high'); - } else { - $actionscript = sprintf($actionscript, 'low'); - } - - $this->movie->add(new SWFAction(str_replace("\r", "", $actionscript))); - } - } - - /** - * When passed a Color object, returns the corresponding - * color identifier (driver dependant). - * - * @param awColor $color A Color object - * @return array $rgba A color identifier representing the color composed of the given RGB components - */ - public function getColor(awColor $color) { - - // Ming simply works with R, G, B and Alpha values. - list($red, $green, $blue, $alpha) = $color->rgba(); - - // However, the Ming alpha channel ranges from 255 (opaque) to 0 (transparent), - // while the awColor alpha channel ranges from 0 (opaque) to 100 (transparent). - // First, we convert from 0-100 to 0-255. - $alpha = (int)($alpha * 255 / 100); - - // Then from 0-255 to 255-0. - $alpha = abs($alpha - 255); - - return array($red, $green, $blue, $alpha); - } - - /** - * Draw an image here - * - * @param awImage $image Image - * @param int $p1 Image top-left point - * @param int $p2 Image bottom-right point - */ - public function copyImage(awImage $image, awPoint $p1, awPoint $p2) { - - } - - /** - * Draw an image here - * - * @param awImage $image Image - * @param int $d1 Destination top-left position - * @param int $d2 Destination bottom-right position - * @param int $s1 Source top-left position - * @param int $s2 Source bottom-right position - * @param bool $resample Resample image ? (default to TRUE) - */ - public function copyResizeImage(awImage $image, awPoint $d1, awPoint $d2, awPoint $s1, awPoint $s2, $resample = TRUE) { - - } - - /** - * Draw a string - * - * @var awText $text Text to print - * @param awPoint $point Draw the text at this point - * @param int $width Text max width - */ - public function string(awText $text, awPoint $point, $width = NULL) { - $font = $text->getFont(); - - // Can we deal with that font? - if($this->isCompatibleWithFont($font) === FALSE) { - awImage::drawError('Class MingDriver: Incompatible font type (\''.get_class($font).'\')'); - } - - // Ming can only work with awFileFont objects for now - // (i.e. awFDBFont, or awTuffy et al.) - $fontDriver = $this->fileFontDriver; - - if($text->getBackground() !== NULL or $text->border->visible()) { - - list($left, $right, $top, $bottom) = $text->getPadding(); - - $textWidth = $fontDriver->getTextWidth($text, $this); - $textHeight = $fontDriver->getTextHeight($text, $this); - - $x1 = floor($point->x - $left); - $y1 = floor($point->y - $top); - $x2 = $x1 + $textWidth + $left + $right; - $y2 = $y1 + $textHeight + $top + $bottom; - - $this->filledRectangle( - $text->getBackground(), - awLine::build($x1, $y1, $x2, $y2) - ); - - $text->border->rectangle( - $this, - new awPoint($x1 - 1, $y1 - 1), - new awPoint($x2 + 1, $y2 + 1) - ); - - } - - $fontDriver->string($this, $text, $point, $width); - } - - /** - * Draw a pixel - * - * @param awColor $color Pixel color - * @param awPoint $p - */ - public function point(awColor $color, awPoint $p) { - if($p->isHidden() === FALSE) { - list($red, $green, $blue, $alpha) = $this->getColor($color); - - $point = new SWFShape(); - $point->setLine(1, $red, $green, $blue, $alpha); - $point->movePenTo($this->x + round($p->x), $this->y + round($p->y)); - $point->drawLine(0.5, 0.5); - $point->movePen(-0.5, 0); - $point->drawLine(0.5, -0.5); - - $this->movie->add($point); - } - } - - /** - * Draw a colored line - * - * @param awColor $color Line color - * @param awLine $line - * @param int $thickness Line tickness - */ - public function line(awColor $color, awLine $line) { - if($line->getThickness() > 0 and $line->isHidden() === FALSE) { - - list($red, $green, $blue, $alpha) = $this->getColor($color); - - $mingLine = new SWFShape(); - $mingLine->setLine($line->getThickness(), $red, $green, $blue, $alpha); - - list($p1, $p2) = $line->getLocation(); - - $mingLine->movePenTo($this->x + round($p1->x), $this->y + round($p1->y)); - - switch($line->getStyle()) { - - case awLine::SOLID : - $mingLine->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y)); - $this->movie->add($mingLine); - break; - - case awLine::DOTTED : - $size = sqrt(pow($p2->y - $p1->y, 2) + pow($p2->x - $p1->x, 2)); - $cos = ($p2->x - $p1->x) / $size; - $sin = ($p2->y - $p1->y) / $size; - - for($i = 0; $i <= $size; $i += 2) { - $p = new awPoint( - round($i * $cos + $p1->x), - round($i * $sin + $p1->y) - ); - $this->point($color, $p); - } - - break; - - case awLine::DASHED : - $width = $p2->x - $p1->x; - $height = $p2->y - $p1->y; - $size = sqrt(pow($height, 2) + pow($width, 2)); - - if($size == 0) { - return; - } - - $cos = $width / $size; - $sin = $height / $size; - - $functionX = ($width > 0) ? 'min' : 'max'; - $functionY = ($height > 0) ? 'min' : 'max'; - - for($i = 0; $i <= $size; $i += 6) { - - $t1 = new awPoint( - round($i * $cos + $p1->x), - round($i * $sin + $p1->y) - ); - - $t2 = new awPoint( - round($functionX(($i + 3) * $cos, $width) + $p1->x), - round($functionY(($i + 3) * $sin, $height) + $p1->y) - ); - - $this->line($color, new awLine($t1, $t2)); - - } - - break; - - } - - } - - } - - /** - * Draw a color arc - - * @param awColor $color Arc color - * @param awPoint $center Point center - * @param int $width Ellipse width - * @param int $height Ellipse height - * @param int $from Start angle - * @param int $to End angle - */ - public function arc(awColor $color, awPoint $center, $width, $height, $from, $to) { - - } - - /** - * Draw an arc with a background color - * - * @param awColor $color Arc background color - * @param awPoint $center Point center - * @param int $width Ellipse width - * @param int $height Ellipse height - * @param int $from Start angle - * @param int $to End angle - */ - public function filledArc(awColor $color, awPoint $center, $width, $height, $from, $to) { - - } - - /** - * Draw a colored ellipse - * - * @param awColor $color Ellipse color - * @param awPoint $center Ellipse center - * @param int $width Ellipse width - * @param int $height Ellipse height - */ - public function ellipse(awColor $color, awPoint $center, $width, $height) { - - } - - /** - * Draw an ellipse with a background - * - * @param mixed $background Background (can be a color or a gradient) - * @param awPoint $center Ellipse center - * @param int $width Ellipse width - * @param int $height Ellipse height - */ - public function filledEllipse($background, awPoint $center, $width, $height) { - - } - - /** - * Draw a colored rectangle - * - * @param awColor $color Rectangle color - * @param awLine $line Rectangle diagonale - * @param awPoint $p2 - */ - public function rectangle(awColor $color, awLine $line) { - list($p1, $p2) = $line->getLocation(); - - // Get Red, Green, Blue and Alpha values for the line - list($r, $g, $b, $a) = $this->getColor($color); - - // Calculate the coordinates of the two other points of the rectangle - $p3 = new Point($p1->x, $p2->y); - $p4 = new Point($p2->x, $p1->y); - - - $side = clone $line; - - - - // Draw the four sides of the rectangle, clockwise - if( - ($p1->x <= $p2->x and $p1->y <= $p2->y) - or - ($p1->x >= $p2->x and $p1->y >= $p2->y) - ) { - $side->setLocation($p1, $p4); - $this->line($color, $side); - - $side->setLocation($p4, $p2); - $this->line($color, $side); - - $side->setLocation($p2, $p3); - $this->line($color, $side); - - $side->setLocation($p3, $p1); - $this->line($color, $side); - } else { - $side->setLocation($p1, $p3); - $this->line($color, $side); - - $side->setLocation($p3, $p2); - $this->line($color, $side); - - $side->setLocation($p2, $p4); - $this->line($color, $side); - - $side->setLocation($p4, $p1); - $this->line($color, $side); - } - } - - /** - * Draw a rectangle with a background - * - * @param mixed $background Background (can be a color or a gradient) - * @param awLine $line Rectangle diagonale - */ - public function filledRectangle($background, awLine $line) { - list($p1, $p2) = $line->getLocation(); - - // Common shape settings - $shape = new SWFShape(); - $shape->setLine(0); - - if($background instanceof awColor) { - - // Get the Red, Green, Blue and Alpha values - list($r, $g, $b, $a) = $this->getColor($background); - $shape->setRightFill($r, $g, $b, $a); - - } else if($background instanceof awGradient) { - - // Get the Gradient object as an SWFGradient one - list($flashGradient, $style) = $this->getGradient($background); - - $fill = $shape->addFill($flashGradient, $style); - - // Angles between Artichow and Ming don't match. - // Don't use abs() or vertical gradients get inverted. - $angle = $background->angle - 90; - $fill->rotateTo($angle); - - // Move the gradient based on the position of the rectangle we're drawing - $centerX = min($p1->x, $p2->y) + abs($p1->x - $p2->x) / 2; - $centerY = min($p1->y, $p2->y) + abs($p1->y - $p2->y) / 2; - $fill->moveTo($centerX, $centerY); - - // Ming draws its gradients on a 1600x1600 image, - // so we have to resize it. - if($angle === -90) { - $ratio = abs($p1->y - $p2->y) / 1600; - } else { - $ratio = abs($p1->x - $p2->x) / 1600; - } - $fill->scaleTo($ratio); - - $shape->setRightFill($fill); - - } - - // Set starting position - $shape->movePenTo($this->x + round($p1->x), $this->y + round($p1->y)); - - // Depending on the points' relative positions, - // we have two drawing possibilities - if( - ($p1->x <= $p2->x and $p1->y <= $p2->y) - or - ($p1->x >= $p2->x and $p1->y >= $p2->y) - ) { - $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p1->y)); - $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y)); - $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p2->y)); - $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p1->y)); - } else { - $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p2->y)); - $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y)); - $shape->drawLineTo($this->x + round($p2->x), $this->y + round($p1->y)); - $shape->drawLineTo($this->x + round($p1->x), $this->y + round($p1->y)); - } - - $this->movie->add($shape); - } - - /** - * Draw a polygon - * - * @param awColor $color Polygon color - * @param Polygon A polygon - */ - public function polygon(awColor $color, awPolygon $polygon) { - $points = $polygon->all(); - $count = count($points); - - if($count > 1) { - - $side = new awLine; - $side->setStyle($polygon->getStyle()); - $side->setThickness($polygon->getThickness()); - - $prev = $points[0]; - - for($i = 1; $i < $count; $i++) { - $current = $points[$i]; - $side->setLocation($prev, $current); - $this->line($color, $side); - $prev = $current; - } - - // Close the polygon - $side->setLocation($prev, $points[0]); - $this->line($color, $side); - } - } - - /** - * Draw a polygon with a background - * - * @param mixed $background Background (can be a color or a gradient) - * @param Polygon A polygon - */ - public function filledPolygon($background, awPolygon $polygon) { - $shape = new SWFShape(); - - if($background instanceof awColor) { - list($red, $green, $blue, $alpha) = $this->getColor($background); - - $shape->setRightFill($red, $green, $blue, $alpha); - } elseif($background instanceof awGradient) { - list($flashGradient, $style) = $this->getGradient($background); - - $fill = $shape->addFill($flashGradient, $style); - - list($xMin, $xMax) = $polygon->getBoxXRange(); - list($yMin, $yMax) = $polygon->getBoxYRange(); - - if($background->angle === 0) { - $fill->scaleTo(($yMax - $yMin) / 1600); - } else { - $fill->scaleTo(($xMax - $xMin) / 1600); - } - $fill->moveTo($xMin + ($xMax - $xMin) / 2, $yMin + ($yMax - $yMin) / 2); - - $shape->setRightFill($fill); - } - - $points = $polygon->all(); - $count = count($points); - - if($count > 1) { - - $prev = $points[0]; - - $shape->movePenTo($prev->x, $prev->y); - - for($i = 1; $i < $count; $i++) { - $current = $points[$i]; - $shape->drawLineTo($current->x, $current->y); - } - - // Close the polygon - $shape->drawLineTo($prev->x, $prev->y); - - $this->movie->add($shape); - - } - } - - /** - * Sends the image, as well as the correct HTTP headers, to the browser - * - * @param awImage $image The Image object to send - */ - public function send(awImage $image) { - $this->drawImage($image); - } - - /** - * Get the image as binary data - * - * @param awImage $image - */ - public function get(awImage $image) { - return $this->drawImage($image, TRUE, FALSE); - } - - public function getTextWidth(awText $text) { - $font = $text->getFont(); - if($this->isCompatibleWithFont($font) === FALSE) { - awImage::drawError('Class MingDriver: Incompatible font type (\''.get_class($font).'\')'); - } - - // Ming only supports FileFont - $fontDriver = $this->fileFontDriver; - - return $fontDriver->getTextWidth($text, $this); - } - - public function getTextHeight(awText $text) { - $font = $text->getFont(); - if($this->isCompatibleWithFont($font) === FALSE) { - awImage::drawError('Class MingDriver: Incompatible font type (\''.get_class($font).'\')'); - } - - // Ming only supports FileFont - $fontDriver = $this->fileFontDriver; - - return $fontDriver->getTextHeight($text, $this); - } - - protected function isCompatibleWithFont(awFont $font) { - if($font instanceof awTTFFont or $font instanceof awPHPFont) { - return FALSE; - } else { - return TRUE; - } - } - - private function drawImage(awImage $image, $return = FALSE, $header = TRUE) { - - // Send headers to the browser - if($header === TRUE) { - $image->sendHeaders(); - } - - if($return) { - ob_start(); - } - - $this->movie->output(); - - if($return) { - return ob_get_clean(); - } - } - - /** - * Convert an awGradient object to an SWFGradient one. - * Returns an object as well as the style of the Flash gradient. - * - * @param awGradient $gradient The awGradient object to convert - * @return array - */ - private function getGradient(awGradient $gradient) { - $flashGradient = new SWFGradient(); - - // Get RGBA values for the gradient boundaries - list($r1, $g1, $b1, $a1) = $this->getColor($gradient->from); - list($r2, $g2, $b2, $a2) = $this->getColor($gradient->to); - - $flashGradient->addEntry(0, $r1, $g1, $b1, $a1); - - if($gradient instanceof awBilinearGradient) { - - $flashGradient->addEntry($gradient->center, $r2, $g2, $b2, $a2); - $flashGradient->addEntry(1, $r1, $g1, $b1, $a1); - - return array($flashGradient, SWFFILL_LINEAR_GRADIENT); - } else { - - $flashGradient->addEntry(1, $r2, $g2, $b2, $a2); - - if($gradient instanceof awLinearGradient) { - return array($flashGradient, SWFFILL_LINEAR_GRADIENT); - } else { - return array($flashGradient, SWFFILL_RADIAL_GRADIENT); - } - } - } -// abstract private function getPolygonPoints(awPolygon $polygon); - -} - -registerClass('MingDriver'); - -/* - * Check for ming presence - */ -if(function_exists('ming_useswfversion') === FALSE) { - awImage::drawErrorFile('missing-ming'); -} - diff --git a/modules/graphartichow/artichow/inc/index.php b/modules/graphartichow/artichow/inc/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/inc/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/artichow/index.php b/modules/graphartichow/artichow/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/artichow/patterns/BarDepth.php b/modules/graphartichow/artichow/patterns/BarDepth.php deleted file mode 100644 index eaf822f4b..000000000 --- a/modules/graphartichow/artichow/patterns/BarDepth.php +++ /dev/null @@ -1,84 +0,0 @@ -barShadow->setSize(2); - $plot->barShadow->smooth(TRUE); - $plot->barShadow->setColor(new Color(160, 160, 160, 10)); - - return $plot; - - } - - public function create() { - - $group = new PlotGroup; - $group->setSpace(2, 2, 2, 0); - $group->setPadding(30, 10, NULL, NULL); - - $group->grid->hideVertical(TRUE); - $group->grid->setType(Line::DASHED); - - $yForeground = $this->getArg('yForeground'); - $yBackground = $this->getArg('yBackground'); - - $legendForeground = $this->getArg('legendForeground'); - $legendBackground = $this->getArg('legendBackground'); - - $colorForeground = $this->getArg('colorForeground', new LightBlue(10)); - $colorBackground = $this->getArg('colorBackground', new Orange(25)); - - if($yForeground === NULL) { - awImage::drawError("Class BarDepthPattern: Argument 'yForeground' must not be NULL."); - } - - // Background - if($yBackground !== NULL) { - - $plot = $this->getPlot($yBackground, 6); - $plot->setBarColor($colorBackground); - - $group->add($plot); - if($legendBackground !== NULL) { - $group->legend->add($plot, $legendBackground, Legend::BACKGROUND); - } - - } - - // Foreground - $plot = $this->getPlot($yForeground, 0); - $plot->setBarColor($colorForeground); - - $group->add($plot); - if($legendForeground !== NULL) { - $group->legend->add($plot, $legendForeground, Legend::BACKGROUND); - } - - $group->axis->bottom->hideTicks(TRUE); - - $group->legend->shadow->setSize(0); - $group->legend->setAlign(Legend::CENTER); - $group->legend->setSpace(6); - $group->legend->setTextFont(new Tuffy(8)); - $group->legend->setPosition(0.50, 0.10); - $group->legend->setBackgroundColor(new Color(255, 255, 255, 10)); - $group->legend->setColumns(2); - - return $group; - - } - -} diff --git a/modules/graphartichow/artichow/patterns/LightLine.php b/modules/graphartichow/artichow/patterns/LightLine.php deleted file mode 100644 index 156d9aa66..000000000 --- a/modules/graphartichow/artichow/patterns/LightLine.php +++ /dev/null @@ -1,49 +0,0 @@ -getArg('legend'); - - $y = $this->getArg('y'); - - if($y === NULL) { - awImage::drawError("Class LightLinePattern: Argument 'y' must not be NULL."); - } - - $plot = new LinePlot($y); - $plot->setSize(0.7, 1); - $plot->setCenter(0.35, 0.5); - $plot->setPadding(35, 15, 35, 30); - $plot->setColor(new Orange()); - $plot->setFillColor(new LightOrange(80)); - - $plot->grid->setType(Line::DASHED); - - $plot->mark->setType(Mark::CIRCLE); - $plot->mark->setFill(new MidRed); - $plot->mark->setSize(6); - - $plot->legend->setPosition(1, 0.5); - $plot->legend->setAlign(Legend::LEFT); - $plot->legend->shadow->smooth(TRUE); - - if($legend !== NULL) { - $plot->legend->add($plot, $legend, Legend::MARK); - } - - return $plot; - - } - -} diff --git a/modules/graphartichow/artichow/patterns/index.php b/modules/graphartichow/artichow/patterns/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/artichow/patterns/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/config.xml b/modules/graphartichow/config.xml deleted file mode 100755 index 100d73b6b..000000000 --- a/modules/graphartichow/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - graphartichow - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/modules/graphartichow/graphartichow.php b/modules/graphartichow/graphartichow.php deleted file mode 100644 index 9a606804e..000000000 --- a/modules/graphartichow/graphartichow.php +++ /dev/null @@ -1,369 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class GraphArtichow extends ModuleGraphEngine -{ - private $_graph; - private $_plot = array(); //for simple-layer graphics - private $_group = NULL; //for multi-layer graphics - private $_error = 0; - - function __construct($type = null) - { - if ($type != null) - { - require_once(dirname(__FILE__).'/artichow/Graph.class.php'); - $this->_graph = new Graph(); - $this->_graph->setAntiAliasing(function_exists('imageantialias')); - parent::__construct($type); - } - else - { - $this->name = 'graphartichow'; - $this->tab = 'administration'; - $this->version = 1.0; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - Module::__construct(); - - $this->displayName = $this->l('Artichow'); - $this->description = $this->l('Artichow is a library that enables the display of simple picture-based graphs using PHP and GD.'); - } - } - - function install() - { - return (parent::install() AND $this->registerHook('GraphEngine')); - } - - public static function hookGraphEngine($params, $drawer) - { - return ''; - } - - private function drawLine($values) - { - require_once(dirname(__FILE__).'/artichow/LinePlot.class.php'); - // Single layer - if (!isset($values[0]) OR !is_array($values[0])) - { - $this->_plot = new LinePlot(array_values($values)); - $this->_plot->setFillGradient(new LinearGradient(new Color(255, 246, 211, 20), new Color(240, 225, 160, 50), 90)); - $this->_plot->setColor(new Color(80, 50, 0, 0)); - } - // Multiple layers - else - { - $tabColors = array(new Color(120, 120, 30, 10), new Color(66, 127, 195, 10), new Color(195, 65, 60, 10), new Color(85, 163, 57, 10), new Color(255, 35, 152, 10)); - $tabFilledColors = array(new Color(120, 120, 30, 90), new Color(66, 127, 195, 90), new Color(195, 65, 60, 90), new Color(85, 163, 57, 90), new Color(255, 35, 152, 90)); - - $this->_group = new PlotGroup; - $i = 0; - foreach ($values as $val) - { - $this->_plot[$i] = new LinePlot(array_values($val)); - $this->_plot[$i]->setColor($tabColors[$i % 5]); - $this->_plot[$i]->setFillColor($tabFilledColors[$i % 5]); - $this->_group->add($this->_plot[$i]); - $i++; - } - } - } - - private function drawColumn($values) - { - require_once(dirname(__FILE__).'/artichow/BarPlot.class.php'); - - if (!is_array($values[0])) //simpleline - { - $this->_plot = new BarPlot(array_values($values)); - $this->_plot->label->set(array_values($values)); - $this->_plot->label->setColor(new Color(110, 110, 110)); - $this->_plot->label->move(0, -7); - $this->_plot->label->setAlign(Positionable::CENTER, NULL); - $this->_plot->setBarGradient(new LinearGradient(new Color(254, 255, 216), new Color(233, 231, 218), 90)); - $this->_plot->barBorder->setColor(new Color(115, 115, 150)); - $this->_plot->barShadow->setSize(1); - $this->_plot->barShadow->setColor(new Color(215, 215, 215)); - $this->_plot->barShadow->setPosition(Shadow::RIGHT_TOP); - $this->_plot->barShadow->smooth(TRUE); - } - else - { - $tabColors = array(new Color(120, 120, 30, 10), new Color(66, 127, 195, 10), new Color(195, 65, 60, 10), new Color(85, 163, 57, 10), new Color(255, 35, 152, 10)); - $tabFilledColors = array(new Color(120, 120, 30, 90), new Color(66, 127, 195, 90), new Color(195, 65, 60, 90), new Color(85, 163, 57, 90), new Color(255, 35, 152, 90)); - - $this->_group = new PlotGroup; - $i = 0; - foreach ($values as $val) - { - $this->_plot[$i] = new BarPlot(array_values($val)); - $this->_plot[$i]->label->set(array_values($val)); - $this->_plot[$i]->label->setColor($tabColors[$i % 5]); - $this->_plot[$i]->label->move(0, -7); - $this->_plot[$i]->label->setAlign(Positionable::CENTER, NULL); - $this->_plot[$i]->setBarColor($tabFilledColors[$i % 5]); - $this->_plot[$i]->barBorder->setColor($tabColors[$i % 5]); - $this->_plot[$i]->barShadow->setSize(1); - $this->_plot[$i]->barShadow->setColor(new Color(215, 215, 215)); - $this->_plot[$i]->barShadow->setPosition(Shadow::RIGHT_TOP); - $this->_plot[$i]->barShadow->smooth(TRUE); - $this->_group->add($this->_plot[$i]); - $i++; - } - } - } - - private function setErrorImage() - { - require_once(dirname(__FILE__).'/artichow/BarPlot.class.php'); - - $this->_plot = new BarPlot(array(0)); - $this->_type = 'column'; - $this->_plot->setSize(0, 0); - $this->_plot->setCenter(-20, -20); - } - - private function drawPie($values) - { - require_once(dirname(__FILE__).'/artichow/Pie.class.php'); - $exploder = array(); - $counter = sizeof($values); - - $this->_plot = new Pie(array_values($values), Pie::COLORED); - $this->_plot->set3D(10); - $this->_plot->setLabelPrecision(2); - $this->_plot->setLabelPosition(2); - $this->_plot->legend->shadow->setSize(1); - $this->_plot->legend->setModel(Legend::MODEL_BOTTOM); - $this->_plot->legend->setPosition(NULL, 0.87); - $this->_plot->setSize(0.90, 0.90); - for ($i = 0; $i < $counter; $i++) - $exploder[$i] = 8; - $this->_plot->explode($exploder); - } - - private function drawLineColumn($y_max) - { - if ($this->_group == NULL) - { - $this->_plot->setYMax($y_max); - $this->_plot->setSize(1, 1); - $this->_plot->setCenter(0.508, 0.53); - $this->_plot->setPadding(28, 10, NULL, 40); - } - else - { - foreach ($this->_plot as $plot) - $plot->setYMax($y_max); - $this->_group->setYMax($y_max); - $this->_group->setSize(1, 1); - $this->_group->setCenter(0.508, 0.53); - $this->_group->setPadding(28, 10, NULL, 40); - } - } - - public function createValues($values) - { - // $this->_values = array(); - // if (!isset($this->_values[0]) || !is_array($this->_values[0])) - // foreach ($values as $value) - // $this->_values[] = $value; - // else - // { - // foreach ($values as $i => $layerValue) - // { - // $this->_values[$i] = array(); - // foreach ($values[$i] as $value) - // $this->_values[$i][] = $value; - // } - // } - // $values = $this->_values; - - if (sizeof($values) == 0) - { - $this->setErrorImage(); - return; - } - switch ($this->_type) - { - case 'pie': - $this->drawPie($values); - break; - case 'line': - $this->drawLine($values); - $this->drawLineColumn($this->getYMax($values)); - break; - case 'column': - default: - $this->drawColumn($values); - $this->drawLineColumn($this->getYMax($values)); - break; - } - } - - public function setSize($width, $height) - { - if (Validate::isUnsignedInt($width) AND Validate::isUnsignedInt($height)) - $this->_graph->setSize($width, $height); - } - - public function setLegend($legend) - { - $this->_legend = array(); - if (!isset($this->_legend[0]) || !is_array($this->_legend[0])) - foreach ($legend as $label) - $this->_legend[] = $label; - else - { - foreach ($legend as $i => $layerlabel) - { - $this->_legend[$i] = array(); - foreach ($legend[$i] as $label) - $this->_legend[$i][] = $label; - } - } - $legend = $this->_legend; - - if ($this->_plot == NULL && $this->_group == NULL) - return; - foreach ($legend as $k => $val) - $legend[$k] = html_entity_decode(htmlentities(html_entity_decode($val), ENT_NOQUOTES, 'utf-8')); - switch ($this->_type) - { - case 'pie': - $this->_plot->setLegend($legend); - break; - case 'column': - default: - if ($this->_group == NULL) - { - if (isset($this->_plot->xAxis, $this->_plot->yAxis, $this->_plot->grid)) - { - $this->_plot->xAxis->setLabelText($legend); - $this->_plot->xAxis->label->setFont(new Tuffy(7)); - $this->_plot->yAxis->setLabelPrecision(0); - $this->_plot->grid->setType(Line::DASHED); - } - } - else - { - if (isset($this->_group->axis->bottom, $this->_group->axis->left, $this->_group->grid)) - { - $this->_group->axis->bottom->setLabelText($legend); - $this->_group->axis->bottom->label->setFont(new Tuffy(7)); - $this->_group->axis->left->setLabelPrecision(0); - $this->_group->grid->setType(Line::DASHED); - } - } - break; - } - } - - public function setTitles($titles) - { - if ($this->_plot == NULL && $this->_group == NULL) - return; - if (isset($titles['main'])) - { - if (is_array($titles['main']) && $this->_group != NULL) - { - $i = 0; - foreach ($titles['main'] as $key => $val) - if ($key != 0) - $this->_group->legend->add($this->_plot[$i++], $val, ($this->_type == 'line') ? Legend::LINE : Legend::BACKGROUND); - $titles['main'] = $titles['main'][0]; - } - $this->_graph->title->set($titles['main']); - $this->_graph->title->setFont(new Tuffy(10)); - $this->_graph->title->setAlign(Positionable::CENTER, Positionable::MIDDLE); - } - if (isset($titles['x'])) - { - if ($this->_plot != NULL && !is_array($this->_plot)) - { - $this->_plot->xAxis->title->set($titles['x']); - $this->_plot->xAxis->title->setFont(new Tuffy(10)); - $this->_plot->xAxis->setTitleAlignment(Label::RIGHT); - } - else - { - $this->_group->axis->bottom->title->set($titles['x']); - $this->_group->axis->bottom->title->setFont(new Tuffy(10)); - $this->_group->axis->bottom->setTitleAlignment(Label::RIGHT); - } - } - if (isset($titles['y'])) - { - if ($this->_plot != NULL && !is_array($this->_plot)) - { - $this->_plot->yAxis->title->set($titles['y']); - $this->_plot->yAxis->title->setFont(new Tuffy(10)); - $this->_plot->yAxis->setTitleAlignment(Label::TOP); - } - else - { - $this->_group->axis->left->title->set($titles['y']); - $this->_group->axis->left->title->setFont(new Tuffy(10)); - $this->_group->axis->left->setTitleAlignment(Label::TOP); - } - } - } - - public function draw() - { - if ($this->_plot != NULL && !is_array($this->_plot)) - $this->_graph->add($this->_plot); - if ($this->_group != NULL) - $this->_graph->add($this->_group); - $this->_graph->draw(); - } - - private function getYMax($values) - { - $max = 0; - if (isset($values[0]) && is_array($values[0])) - { - foreach ($values as $val) - foreach ($val as $k => $nb) - if ($nb > $max) - $max = $nb; - } - else - { - foreach ($values as $k => $val) - if ($val > $max) - $max = $val; - } - return ($max < 4) ? 4 : (round($max, 0)); - } -} - - diff --git a/modules/graphartichow/index.php b/modules/graphartichow/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphartichow/logo.gif b/modules/graphartichow/logo.gif deleted file mode 100644 index ed937ee8b..000000000 Binary files a/modules/graphartichow/logo.gif and /dev/null differ diff --git a/modules/graphartichow/logo.png b/modules/graphartichow/logo.png deleted file mode 100755 index 6d14c7270..000000000 Binary files a/modules/graphartichow/logo.png and /dev/null differ diff --git a/modules/graphartichow/translations/index.php b/modules/graphartichow/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphartichow/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphgooglechart/config.xml b/modules/graphgooglechart/config.xml deleted file mode 100755 index b8e82ca3a..000000000 --- a/modules/graphgooglechart/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - graphgooglechart - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/modules/graphgooglechart/graphgooglechart.php b/modules/graphgooglechart/graphgooglechart.php deleted file mode 100644 index 738b8b44d..000000000 --- a/modules/graphgooglechart/graphgooglechart.php +++ /dev/null @@ -1,247 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class GraphGoogleChart extends ModuleGraphEngine -{ - private $_width; - private $_height; - private $_values; - private $_legend; - private $_titles; - - function __construct($type = null) - { - if ($type != null) - { - parent::__construct($type); - } - else - { - $this->name = 'graphgooglechart'; - $this->tab = 'administration'; - $this->version = 1.0; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - Module::__construct(); - - $this->displayName = $this->l('Google Chart'); - $this->description = $this->l('The Google Chart API lets you dynamically generate charts.'); - } - } - - function install() - { - return (parent::install() AND $this->registerHook('GraphEngine')); - } - - public static function hookGraphEngine($params, $drawer) - { - return ''; - } - - - public function createValues($values) - { - $this->_values = $values; - } - - public function setSize($width, $height) - { - $this->_width = $width; - $this->_height = $height; - } - - public function setLegend($legend) - { - $this->_legend = $legend; - } - - public function setTitles($titles) - { - $this->_titles = $titles; - } - - private function getChbh($sizeof_values) - { - $chbh = 12; - - if ($sizeof_values < 25) - $chbh += 4; - if ($sizeof_values < 20) - $chbh += 4; - if ($sizeof_values < 15) - $chbh += 8; - if ($sizeof_values < 10) - $chbh += 14; - return ($chbh); - } - - private function drawColumn($max_y) - { - if (!isset($this->_values[0]) || !is_array($this->_values[0])) - $sizeof_values = sizeof($this->_values); - else - $sizeof_values = sizeof($this->_values[0]); - $url = 'bvs&chxt=x,y&chxr=1,0,'.$max_y.'&chbh='.$this->getChbh($sizeof_values).'&chg=0,12.5&chxl=0:|'; - for ($i = 0; $i < $sizeof_values; $i++) - if (!isset($this->_values[0]) || !is_array($this->_values[0])) - { - if (isset($this->_values[$i])) - $this->_values[$i] = ($this->_values[$i] * 100) / $max_y; - else - $this->_values[$i] = 0; - } - else - foreach ($this->_values as $k => $value) - { - if (!isset($this->_values[$k][$i])) - $this->_values[$k][$i] = 0; - $this->_values[$k][$i] = ($this->_values[$k][$i] * 100) / $max_y; - } - return ($url); - } - - private function drawLine($max_y) - { - return ('lc'./*&chxt=x,y*/'&chbh='.$this->getChbh(sizeof($this->_values)).'&chg=0,12.5&chxl=0:|'); - } - - private function drawPie() - { - return ('p3&chl='); - } - - public function draw() - { - $url = 'http://chart.apis.google.com/chart?cht='; - $legend = ''; - $values = ''; - $scale = ''; - - switch ($this->_type) - { - case 'pie': - $url .= $this->drawPie(); - break; - case 'line': - $url .= $this->drawLine($this->getYMax($this->_values)); - case 'column': - default: - $url .= $this->drawColumn($this->getYMax($this->_values)); - break; - } - - foreach ($this->_legend as $label) - $legend .= $label.'|'; - $url .= htmlentities(urlencode(html_entity_decode(rtrim($legend, '|')))); - - if (!isset($this->_values[0]) || !is_array($this->_values[0])) - { - foreach ($this->_values as $label) - $values .= ($label ? $label : '0').','; - $url .= '&chd=t:'.urlencode(rtrim($values, ',')); - } - else - { - $i = 0; - $url .= '&chd=t:'; - foreach ($this->_values as $val) - { - $values = ''; - if ($i++ > 0) - $url .= '|'; - foreach ($val as $label) - $values .= ($label ? $label : '0').','; - $url .= urlencode(rtrim($values, ',')); - } - } - - $url .= '&chs='.(int)($this->_width).'x'.(int)($this->_height); - if (!isset($this->_values[0]) || !is_array($this->_values[0])) - $url .= (isset($this->_titles['main'])) ? '&chtt='.urlencode($this->_titles['main']) : ''; - else - { - $url .= $this->getStringColor(sizeof($this->_values)); - $i = 0; - foreach ($this->_titles['main'] as $val) - { - if ($i == 0 && !empty($this->_titles['main'])) - $url .= '&chtt='.urlencode($this->_titles['main'][$i]); - else if ($i == 1) - $url .= '&chdl='; - else if ($i > 1) - $url .= '|'; - if ($i != 0) - $url .= urlencode($this->_titles['main'][$i]); - $i++; - } - } - header("Content-type: image/png"); - readfile($url); - } - - private function getYMax($values) - { - $max = 0; - if (!isset($this->_values[0]) || !is_array($this->_values[0])) - { - foreach ($values as $k => $val) - if ($val > $max) - $max = $val; - } - else - { - foreach ($values as $value) - foreach ($value as $val) - if ($val > $max) - $max = $val; - } - return ($max < 4) ? 4 : (round($max, 0)); - } - - private function getStringColor($nb_colors) - { - $tabColors = array('ffb649', '427fc3', 'ff0000', '55a339', 'ff2398'); - $color = ''; - if ($nb_colors > 1) - { - $color = '&chco='; - for ($i = 0; $i < $nb_colors; $i++) - { - if ($i > 0) - $color .= ','; - $color .= $tabColors[$i % 5]; - } - } - return $color; - } -} - - diff --git a/modules/graphgooglechart/index.php b/modules/graphgooglechart/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphgooglechart/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphgooglechart/logo.gif b/modules/graphgooglechart/logo.gif deleted file mode 100644 index 4f5d64543..000000000 Binary files a/modules/graphgooglechart/logo.gif and /dev/null differ diff --git a/modules/graphgooglechart/logo.png b/modules/graphgooglechart/logo.png deleted file mode 100755 index 6d14c7270..000000000 Binary files a/modules/graphgooglechart/logo.png and /dev/null differ diff --git a/modules/graphgooglechart/translations/index.php b/modules/graphgooglechart/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphgooglechart/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphnvd3/graphnvd3.php b/modules/graphnvd3/graphnvd3.php index bf0d25e40..14685e5cd 100644 --- a/modules/graphnvd3/graphnvd3.php +++ b/modules/graphnvd3/graphnvd3.php @@ -78,8 +78,8 @@ class GraphNvD3 extends ModuleGraphEngine nv.models.lineChart()', 'pie' => ' nv.models.pieChart() - .x(function(d) {return d.label}) - .y(function(d) {return d.value}) + .x(function(d) { return d.label; }) + .y(function(d) { return d.value; }) .showLabels(true) .showLegend(false)' ); @@ -150,12 +150,17 @@ class GraphNvD3 extends ModuleGraphEngine { $nvd3_values = array(); if (Tools::getValue('type') == 'pie') + { foreach ($this->_values as $x => $y) $nvd3_values[] = array('label' => $this->_legend[$x], 'value' => $y); + $array['data'] = $nvd3_values; + } else + { foreach ($this->_values as $x => $y) $nvd3_values[] = array('x' => $x, 'y' => $y); - $array['data'][] = array('values' => $nvd3_values, 'key' => $this->_titles['main']); + $array['data'][] = array('values' => $nvd3_values, 'key' => $this->_titles['main']); + } } else foreach ($this->_values as $layer => $gross_values) diff --git a/modules/graphvisifire/config.xml b/modules/graphvisifire/config.xml deleted file mode 100755 index a03c9923b..000000000 --- a/modules/graphvisifire/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - graphvisifire - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/modules/graphvisifire/graphvisifire.php b/modules/graphvisifire/graphvisifire.php deleted file mode 100644 index c6fcb4557..000000000 --- a/modules/graphvisifire/graphvisifire.php +++ /dev/null @@ -1,186 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class GraphVisifire extends ModuleGraphEngine -{ - private $_xml; - private $_values = NULL; - private $_legend = NULL; - private $_titles = NULL; - - function __construct($type = null) - { - if ($type != null) - { - $this->_xml = '_xml .= ' Theme="Theme1" View3D="True"'; - else - $this->_xml .= ' Theme="Theme2" ColorSet="Visifire2" UniqueColors="True"'; - $this->_xml .= '>'; - parent::__construct($type); - } - else - { - $this->name = 'graphvisifire'; - $this->tab = 'administration'; - $this->version = 1.0; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - Module::__construct(); - - $this->displayName = $this->l('Visifire'); - $this->description = $this->l('Visifire is a set of open-source data visualization components -- Powered by Microsoft Silverlight 2 (beta 2).'); - } - } - - function install() - { - return (parent::install() AND $this->registerHook('GraphEngine')); - } - - public static function hookGraphEngine($params, $drawer) - { - static $divid = 1; - return ' -
- -
'; - } - - public function createValues($values) - { - $this->_values = array(); - if (!is_array($values[array_rand($values)])) - foreach ($values as $value) - $this->_values[] = $value; - else - { - foreach ($values as $i => $layerValue) - { - $this->_values[$i] = array(); - foreach ($layerValue as $value) - $this->_values[$i][] = $value; - } - } - } - - public function setSize($width, $height) - { - // Unavailable - } - - public function setLegend($legend) - { - $this->_legend = array(); - if (!is_array($legend[array_rand($legend)])) - foreach ($legend as $label) - $this->_legend[] = $label; - else - { - foreach ($legend as $i => $layerlabel) - { - $this->_legend[$i] = array(); - foreach ($layerlabel as $label) - $this->_legend[$i][] = $label; - } - } - } - - public function setTitles($titles) - { - $this->_titles = $titles; - if (isset($titles['main']) && !is_array($titles['main'])) - $this->_xml .= ''; - if (is_array($titles['main']) && isset($titles['main'][0])) - $this->_xml .= ''; - if (isset($titles['x'])) - $this->_xml .= ''; - if (isset($titles['y'])) - $this->_xml .= ''; - } - - public function draw() - { - header('content-type: text/xml'); - if ($this->_values != NULL && $this->_legend != NULL) - { - if (!isset($this->_values[0]) || !is_array($this->_values[0])) - $size = sizeof($this->_values); - else - $size = sizeof($this->_values[0]); - if ($size == sizeof($this->_legend)) - { - if (!is_array($this->_values[array_rand($this->_values)])) - { - $this->_xml .= ''; - for ($i = 0; $i < $size; $i++) - { - $this->_xml .= '_xml .= 'AxisLabel=" '.str_replace('<', '<', str_replace('>', '>', str_replace('&', '&', str_replace('"', "'", $this->_legend[$i])))).'" '; - $this->_xml .= 'YValue="'.$this->_values[$i].'"'; - if ($this->_type == 'pie') - $this->_xml .= ' ExplodeOffset="0.2"'; - $this->_xml .= '/>'; - } - $this->_xml .= ''; - } - else - { - foreach ($this->_values as $layer => $values) - { - $this->_xml .= ''; - foreach ($values as $i => $value) - { - $this->_xml .= '_xml .= 'AxisLabel=" '.str_replace('<', '<', str_replace('>', '>', str_replace('&', '&', str_replace('"', "'", $this->_legend[$i])))).'" '; - $this->_xml .= 'YValue="'.$value.'"'; - if ($this->_type == 'pie') - $this->_xml .= ' ExplodeOffset="0.2"'; - $this->_xml .= '/>'; - } - $this->_xml .= ''; - } - } - } - } - $this->_xml .= '
'; - echo $this->_xml; - exit(1); - } -} - - diff --git a/modules/graphvisifire/index.php b/modules/graphvisifire/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphvisifire/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphvisifire/logo.gif b/modules/graphvisifire/logo.gif deleted file mode 100644 index df365f2d3..000000000 Binary files a/modules/graphvisifire/logo.gif and /dev/null differ diff --git a/modules/graphvisifire/logo.png b/modules/graphvisifire/logo.png deleted file mode 100644 index 3bdcda870..000000000 Binary files a/modules/graphvisifire/logo.png and /dev/null differ diff --git a/modules/graphvisifire/translations/index.php b/modules/graphvisifire/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphvisifire/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphvisifire/visifire/Visifire.js b/modules/graphvisifire/visifire/Visifire.js deleted file mode 100644 index 6cf9d76c1..000000000 --- a/modules/graphvisifire/visifire/Visifire.js +++ /dev/null @@ -1,353 +0,0 @@ -/* - Copyright (C) 2008 Webyog Softworks Private Limited - - This file is a part of Visifire Charts. - - Visifire is a free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - You should have received a copy of the GNU General Public License - along with Visifire Charts. If not, see . - - If GPL is not suitable for your products or company, Webyog provides Visifire - under a flexible commercial license designed to meet your specific usage and - distribution requirements. If you have already obtained a commercial license - from Webyog, you can use this file under those license terms. -*/ - -if(!window.Visifire) -{ - // Visifire class - window.Visifire = function(pXapPath, pId, pWidth, pHeight, pBackground) - { - this.id = null; - this.logLevel = 1; // Determines whether to log or not. - this.xapPath = "Visifire.xap"; // Default is taken as Visifire.xap in the same directory. - this.targetElement = null; - this.dataXml = null; - this.dataUri = null; - this.listeners = null; - this.elements = new Array("Chart", "DataPoint", "Title", "AxisX", "AxisY", "Legend"); - this.events = new Array("MouseLeftButtonDown", "MouseLeftButtonUp", "MouseMove", "MouseEnter", "MouseLeave"); - this.windowless = false; - this.width = null; - this.height = null; - this.background = null; - - // pId not present - if(Number(pId)) - { - if(pHeight) - this.background = pHeight; - - pHeight = pWidth; - pWidth = pId; - } - else // pId present - { - this.id = pId; - - if(pBackground) - this.background = pBackground; - } - - if(pXapPath) - this.xapPath = pXapPath; - - if(pWidth) - this.width = pWidth; - - if(pHeight) - this.height = pHeight; - - this._uThisObject = this; - - this.index = ++Visifire._slCount; - } - - window.Visifire._slCount = 0; - - Visifire.prototype.setWindowlessState = function(pWindowless) - { - if(pWindowless != null) - { - this.windowless = Boolean(pWindowless); - } - } - - Visifire.prototype._getSlControl = function () - { - var _uThisObject = this; - if(_uThisObject.id != null) - { - var slControl = document.getElementById(_uThisObject.id); - return slControl; - } - - return null; - } - - Visifire.prototype.isLoaded = function() - { - var slControl = this._getSlControl(); - try - { - if(slControl.Content.wrapper != null) - return true; - } - catch(ex) - { - return false; - } - } - Visifire.prototype.isDataLoaded = function() - { - var slControl = this._getSlControl(); - - return slControl.Content.wrapper.IsDataLoaded; - } - Visifire.prototype.setSize = function(pWidth,pHeight) - { - var slControl = this._getSlControl(); - if(slControl != null) - { - slControl.width = pWidth; - slControl.height = pHeight; - slControl.Content.wrapper.Resize(pWidth,pHeight); - } - else - { - this.width = pWidth; - this.height = pHeight; - } - } - - Visifire.prototype.setDataXml = function(pDataXml) - { - var slControl = this._getSlControl(); - - if(slControl != null && this.dataXml != null) - { - slControl.Content.wrapper.AddDataXML(pDataXml); - } - - this.dataXml = pDataXml; - } - - - Visifire.prototype.setDataUri = function(pDataUri) - { - var slControl = this._getSlControl(); - - if(slControl != null && this.dataUri != null) - { - slControl.Content.wrapper.AddDataUri(pDataUri); - } - - this.dataUri = pDataUri; - } - - Visifire.prototype.setLogLevel = function(level) - { - if(level != null) - { - this.logLevel = level; - } - } - - Visifire.prototype._isString = function() - { - if (typeof arguments[0] == 'string') return true; - - if (typeof arguments[0] == 'object') - { - var criterion = arguments[0].constructor.toString().match(/string/i); - return (criterion != null); - } - - return false; - } - - Visifire.prototype._validateChartElement = function(pElement) - { - if(this.logLevel != 0) - { - for(var i = 0; i < this.elements.length; i++) - if(this.elements[i] == pElement) - return; - - alert('Error occurred while attaching event.\nUnknown element "' + pElement + '".'); - } - } - - Visifire.prototype._validateEvent = function(pEvent) - { - if(this.logLevel != 0) - { - for(var i = 0; i < this.events.length; i++) - if(this.events[i] == pEvent) - return; - - alert('Error occurred while attaching event.\nUnsupported event type "' + pEvent + '".'); - } - } - - Visifire.prototype.attachEvent = function(pElement, pEvent, pCallBack) - { - var _uThisObject = this; - - _uThisObject._validateChartElement(pElement); - _uThisObject._validateEvent(pEvent); - - if(pEvent && pElement && pCallBack) - { - if(_uThisObject.listeners == null) - _uThisObject.listeners = {}; - - if(_uThisObject.listeners[pEvent] == null) - _uThisObject.listeners[pEvent] = new Array(); - - if(!window["dispatchEvent" + _uThisObject.index]) - window["dispatchEvent" + _uThisObject.index] = function(args) - { - if(_uThisObject.listeners[args.Event] != null) - { - var listener = _uThisObject.listeners[args.Event]; - if(listener.length != 0) - { - for (var i = 0; i < listener.length; i++) - { - if ((listener[i].event == args.Event) && (listener[i].element == args.Element)) - { - args.ControlId = _uThisObject.id; - - if(_uThisObject._isString(listener[i].fire)) - eval(listener[i].fire + "(args)"); - else - listener[i].fire(args); - } - } - } - } - }; - - _uThisObject.listeners[pEvent].push({element: pElement, event: pEvent, fire: pCallBack}); - } - } - - Visifire.prototype._render = function(pTargetElement) - { - var _uThisObject = this; - var width; - var height; - - _uThisObject.targerElement = (typeof(pTargetElement) == "string")?document.getElementById(pTargetElement):pTargetElement; - - if(_uThisObject.width != null) - width = _uThisObject.width; - else if(_uThisObject.targerElement.offsetWidth != 0) - width = _uThisObject.targerElement.offsetWidth; - else - width = 500; - - if(_uThisObject.height != null) - height = _uThisObject.height; - else if(_uThisObject.targerElement.offsetHeight != 0) - height = _uThisObject.targerElement.offsetHeight; - else - height = 300; - - if(!_uThisObject.id) - { - _uThisObject.id = 'VisifireControl' + _uThisObject.index; - } - - var html = ''; - - html += '' - + '' - + ''; - html += '"; - html += '' - + '' - + '' - + '' - + 'Get Microsoft Silverlight' - + '
You need Microsoft Silverlight to view Visifire Charts.' - + '
You can install it by clicking on this link.' - + '
Please restart the browser after installation.' - + '
' - + '
'; - - this.targerElement.innerHTML = html; - } - - Visifire.prototype._reRender = function(pSlControl) - { - pSlControl.Content.wrapper.ReRenderChart(); - } - - Visifire.prototype.render = function(pTargetElement) - { - var slControl = this._getSlControl(); - - if(slControl == null) - { - this._render(pTargetElement); - } - else - { - this._reRender(slControl); - } - } -} \ No newline at end of file diff --git a/modules/graphvisifire/visifire/Visifire.xap b/modules/graphvisifire/visifire/Visifire.xap deleted file mode 100644 index 5896c90db..000000000 Binary files a/modules/graphvisifire/visifire/Visifire.xap and /dev/null differ diff --git a/modules/graphvisifire/visifire/index.php b/modules/graphvisifire/visifire/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphvisifire/visifire/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphxmlswfcharts/config.xml b/modules/graphxmlswfcharts/config.xml deleted file mode 100755 index 77bc65834..000000000 --- a/modules/graphxmlswfcharts/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - graphxmlswfcharts - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/modules/graphxmlswfcharts/graphxmlswfcharts.php b/modules/graphxmlswfcharts/graphxmlswfcharts.php deleted file mode 100644 index 72e75bb9b..000000000 --- a/modules/graphxmlswfcharts/graphxmlswfcharts.php +++ /dev/null @@ -1,258 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * Statistics - * @category stats - * - * @author PrestaShop - * @copyright PrestaShop - * @license http://www.opensource.org/licenses/afl-3.0.php Open-source licence 3.0 - * @version 1.4 - */ - -if (!defined('_PS_VERSION_')) - exit; - -class GraphXmlSwfCharts extends ModuleGraphEngine -{ - private $_xml; - private $_values = NULL; - private $_legend = NULL; - private $_legend_more = ''; - private $_titles = ''; - - function __construct($type = null) - { - if ($type != null) - { - $this->_xml = ''; - parent::__construct($type); - } - else - { - $this->name = 'graphxmlswfcharts'; - $this->tab = 'administration'; - $this->version = 1.0; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - Module::__construct(); - - $this->displayName = $this->l('XML/SWF Charts'); - $this->description = $this->l('XML/SWF Charts are simple, yet powerful tools using Adobe Flash to create attractive web charts and graphs from dynamic data.'); - } - } - - function install() - { - return (parent::install() AND $this->registerHook('GraphEngine')); - } - - public static function hookGraphEngine($params, $drawer) - { - return ' - - - - - - '; - } - - private function drawColumn() - { - $this->_xml .= ' - - - - - - '; - } - - private function drawLine() - { - $this->drawColumn(); - $this->_xml .= 'A3B6DAC3413C5A6C83CA9A515B775155AA26FF2398427FC3 - '; - } - - private function drawPie($counter) - { - $this->_xml .= ' - - - 427FC3 - C3413C - 5A6C83 - CA9A51 - 5B7751 - 55AA26 - FF2398 - - '; - for ($i = 0; $i < $counter; $i++) - $this->_xml .= '9'; - $this->_xml .= ''; - $this->_legend_more = ' bullet="circle"'; - } - - public function createValues($values) - { - $this->_values = $values; - $this->_xml .= ''.$this->_type.''; - - switch ($this->_type) - { - case 'pie': - $this->drawPie(sizeof($values)); - break; - case 'line': - $this->drawLine(); - break; - case 'column': - default: - $this->drawColumn(); - $this->_xml .= 'A3B6DAC3413C5A6C83CA9A515B775155AA26FF2398427FC3'; - break; - } - } - - public function setSize($width, $height) - { - if (isset($width) && !empty($width)) - $this->_width = $width; - else - $this->_width = 550; - if (isset($height) && !empty($height)) - $this->_height = $height; - else - $this->_height = 270; - } - - public function setLegend($legend) - { - $this->_legend = $legend; - $this->_xml .= '_legend_more.' layout="horizontal" font="arial" bold="true" size="13" color="000000" alpha="85" shadow="low" transition="dissolve" delay="0.5" duration="0.25" fill_color="D4D4D4" fill_alpha="0" line_color="D4D4D4" line_alpha="0" line_thickness="0" />'; - } - - public function setTitles($titles) - { - $this->_titles = $titles; - $this->_xml .= ''; - if (isset($titles['main'])) - { - if ($this->_type == 'pie') - $this->_xml .= ''.$titles['main'].''; - } - if ($this->_type != 'pie' AND isset($titles['x']) AND isset($titles['y'])) - { - $this->_xml .= ''.$titles['x'].''; - $this->_xml .= ''.$titles['y'].''; - } - $this->_xml .= ''; - } - - public function draw() - { - header('content-type: text/xml'); - - $this->_xml .= ''; - foreach ($this->_legend as $value) - $this->_xml .= ''.$value.''; - $this->_xml .= ''; - - if (!isset($this->_values[0]) || !is_array($this->_values[0])) - { - $this->_xml .= ''.$this->_titles['main'].''; - foreach ($this->_values as $value) - $this->_xml .= ''. (($value > 0) ? $value : -$value) .''; //si jamais la valeur est n�gative... logiquement ne devrait jamais arriver - $this->_xml .= ''; - } - else - { - $i = 1; - foreach ($this->_values as $value) - { - $this->_xml .= ''; - if (isset($this->_titles['main'][$i])) - $this->_xml .= ''.$this->_titles['main'][$i].''; - foreach ($value as $val) - $this->_xml .= ''.$val.''; - $this->_xml .= ''; - $i++; - } - } - $this->_xml .= ''; - $this->_xml .= ''; - echo $this->_xml; - } -} diff --git a/modules/graphxmlswfcharts/index.php b/modules/graphxmlswfcharts/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphxmlswfcharts/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphxmlswfcharts/logo.gif b/modules/graphxmlswfcharts/logo.gif deleted file mode 100644 index 98919ed13..000000000 Binary files a/modules/graphxmlswfcharts/logo.gif and /dev/null differ diff --git a/modules/graphxmlswfcharts/logo.png b/modules/graphxmlswfcharts/logo.png deleted file mode 100755 index c02f04f7e..000000000 Binary files a/modules/graphxmlswfcharts/logo.png and /dev/null differ diff --git a/modules/graphxmlswfcharts/translations/index.php b/modules/graphxmlswfcharts/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphxmlswfcharts/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphxmlswfcharts/xml_swf_charts/AC_RunActiveContent.js b/modules/graphxmlswfcharts/xml_swf_charts/AC_RunActiveContent.js deleted file mode 100644 index 39c294bbd..000000000 --- a/modules/graphxmlswfcharts/xml_swf_charts/AC_RunActiveContent.js +++ /dev/null @@ -1,292 +0,0 @@ -//v1.7 -// Flash Player Version Detection -// Detect Client Browser type -// Copyright 2005-2007 Adobe Systems Incorporated. All rights reserved. -var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; -var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; -var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; - -function ControlVersion() -{ - var version; - var axo; - var e; - - // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry - - try { - // version will be set for 7.X or greater players - axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); - version = axo.GetVariable("$version"); - } catch (e) { - } - - if (!version) - { - try { - // version will be set for 6.X players only - axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); - - // installed player is some revision of 6.0 - // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, - // so we have to be careful. - - // default to the first public version - version = "WIN 6,0,21,0"; - - // throws if AllowScripAccess does not exist (introduced in 6.0r47) - axo.AllowScriptAccess = "always"; - - // safe to call for 6.0r47 or greater - version = axo.GetVariable("$version"); - - } catch (e) { - } - } - - if (!version) - { - try { - // version will be set for 4.X or 5.X player - axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); - version = axo.GetVariable("$version"); - } catch (e) { - } - } - - if (!version) - { - try { - // version will be set for 3.X player - axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); - version = "WIN 3,0,18,0"; - } catch (e) { - } - } - - if (!version) - { - try { - // version will be set for 2.X player - axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); - version = "WIN 2,0,0,11"; - } catch (e) { - version = -1; - } - } - - return version; -} - -// JavaScript helper required to detect Flash Player PlugIn version information -function GetSwfVer(){ - // NS/Opera version >= 3 check for Flash plugin in plugin array - var flashVer = -1; - - if (navigator.plugins != null && navigator.plugins.length > 0) { - if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { - var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; - var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; - var descArray = flashDescription.split(" "); - var tempArrayMajor = descArray[2].split("."); - var versionMajor = tempArrayMajor[0]; - var versionMinor = tempArrayMajor[1]; - var versionRevision = descArray[3]; - if (versionRevision == "") { - versionRevision = descArray[4]; - } - if (versionRevision[0] == "d") { - versionRevision = versionRevision.substring(1); - } else if (versionRevision[0] == "r") { - versionRevision = versionRevision.substring(1); - if (versionRevision.indexOf("d") > 0) { - versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); - } - } - var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; - } - } - // MSN/WebTV 2.6 supports Flash 4 - else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; - // WebTV 2.5 supports Flash 3 - else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; - // older WebTV supports Flash 2 - else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; - else if ( isIE && isWin && !isOpera ) { - flashVer = ControlVersion(); - } - return flashVer; -} - -// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available -function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) -{ - versionStr = GetSwfVer(); - if (versionStr == -1 ) { - return false; - } else if (versionStr != 0) { - if(isIE && isWin && !isOpera) { - // Given "WIN 2,0,0,11" - tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] - tempString = tempArray[1]; // "2,0,0,11" - versionArray = tempString.split(","); // ['2', '0', '0', '11'] - } else { - versionArray = versionStr.split("."); - } - var versionMajor = versionArray[0]; - var versionMinor = versionArray[1]; - var versionRevision = versionArray[2]; - - // is the major.revision >= requested major.revision AND the minor version >= requested minor - if (versionMajor > parseFloat(reqMajorVer)) { - return true; - } else if (versionMajor == parseFloat(reqMajorVer)) { - if (versionMinor > parseFloat(reqMinorVer)) - return true; - else if (versionMinor == parseFloat(reqMinorVer)) { - if (versionRevision >= parseFloat(reqRevision)) - return true; - } - } - return false; - } -} - -function AC_AddExtension(src, ext) -{ - if (src.indexOf('?') != -1) - return src.replace(/\?/, ext+'?'); - else - return src + ext; -} - -function AC_Generateobj(objAttrs, params, embedAttrs) -{ - var str = ''; - if (isIE && isWin && !isOpera) - { - str += ' '; - } - str += ''; - } - else - { - str += ' -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/lnno.swf b/modules/graphxmlswfcharts/xml_swf_charts/charts_library/lnno.swf deleted file mode 100644 index 65cf9553f..000000000 Binary files a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/lnno.swf and /dev/null differ diff --git a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/mxno.swf b/modules/graphxmlswfcharts/xml_swf_charts/charts_library/mxno.swf deleted file mode 100644 index 82500fb0d..000000000 Binary files a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/mxno.swf and /dev/null differ diff --git a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pi3d.swf b/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pi3d.swf deleted file mode 100644 index 7a4c1174c..000000000 Binary files a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pi3d.swf and /dev/null differ diff --git a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/piim.swf b/modules/graphxmlswfcharts/xml_swf_charts/charts_library/piim.swf deleted file mode 100644 index e232d1762..000000000 Binary files a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/piim.swf and /dev/null differ diff --git a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pino.swf b/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pino.swf deleted file mode 100644 index 94fbcdcc1..000000000 Binary files a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pino.swf and /dev/null differ diff --git a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pono.swf b/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pono.swf deleted file mode 100644 index 7f872a900..000000000 Binary files a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/pono.swf and /dev/null differ diff --git a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/scno.swf b/modules/graphxmlswfcharts/xml_swf_charts/charts_library/scno.swf deleted file mode 100644 index f8d22a4e2..000000000 Binary files a/modules/graphxmlswfcharts/xml_swf_charts/charts_library/scno.swf and /dev/null differ diff --git a/modules/graphxmlswfcharts/xml_swf_charts/index.php b/modules/graphxmlswfcharts/xml_swf_charts/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/graphxmlswfcharts/xml_swf_charts/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file