Author: Nick Sagona, III (dev@nolainteractive.com)
Inheritance: extends Pop\Image\AbstractRasterImage
コード例 #1
0
 /**
  * Index method
  *
  * @return void
  */
 public function index()
 {
     if (DB_INTERFACE != '' && DB_NAME != '') {
         Response::redirect(BASE_PATH . APP_URI);
     } else {
         $install = new Model\Install(array('title' => $this->i18n->__('Installation')));
         $form = new Form\Install($this->request->getBasePath() . $this->request->getRequestUri() . '?lang=' . $this->i18n->getLanguage() . '_' . $this->i18n->getLocale(), 'post');
         if (!\Pop\Image\Gd::isInstalled() && !\Pop\Image\Imagick::isInstalled()) {
             $install->set('error', 'Neither the GD or Imagick extensions are installed. Phire CMS 2.0 requires one of them to be installed for graphic manipulation to fully function properly. You can continue with the install, but you will not be able to upload or manipulate image graphics until one of the image extensions is installed.');
         }
         if ($this->request->isPost()) {
             $form->setFieldValues($this->request->getPost(), array('strip_tags' => null, 'htmlentities' => array(ENT_QUOTES, 'UTF-8')));
             if ($form->isValid()) {
                 $install->config($form);
                 $url = isset($install->configWritable) && $install->configWritable ? BASE_PATH . $form->app_uri . '/install/user' : BASE_PATH . APP_URI . '/install/config';
                 Response::redirect($url . '?lang=' . POP_LANG);
             } else {
                 $install->set('form', $form);
                 $this->view = View::factory($this->viewPath . '/index.phtml', $install->getData());
                 $this->view->set('i18n', $this->i18n);
                 $this->send();
             }
         } else {
             $install->set('form', $form);
             $this->view = View::factory($this->viewPath . '/index.phtml', $install->getData());
             $this->view->set('i18n', $this->i18n);
             $this->send();
         }
     }
 }
コード例 #2
0
ファイル: Graph.php プロジェクト: nicksagona/PopPHP
 /**
  * Constructor
  *
  * Instantiate the graph object.
  *
  * @param array   $options
  * @param boolean $forceGd
  * @throws Exception
  * @return \Pop\Graph\Graph
  */
 public function __construct($options, $forceGd = false)
 {
     if (!isset($options['filename'])) {
         throw new Exception('Error: You must pass a filename in the $options parameter.');
     }
     if (isset($options['width']) && isset($options['height']) && is_numeric($options['width']) && is_numeric($options['height'])) {
         $this->width = $options['width'];
         $this->height = $options['height'];
     } else {
         throw new Exception('Error: You must either pass a valid width and height or a valid image in the $options parameter.');
     }
     if (isset($options['background']) && is_array($options['background']) && count($options['background']) == 3) {
         $background = new Rgb($options['background'][0], $options['background'][1], $options['background'][2]);
     } else {
         $background = null;
     }
     $this->fontColor = new Rgb(0, 0, 0);
     $this->axisColor = new Rgb(0, 0, 0);
     $this->showXColor = new Rgb(200, 200, 200);
     $this->showYColor = new Rgb(200, 200, 200);
     if (stripos($options['filename'], '.pdf') !== false) {
         $this->adapter = new Pdf($options['filename'], null, $this->width, $this->height);
     } else {
         if (stripos($options['filename'], '.svg') !== false) {
             $class = '\\Pop\\Image\\Svg';
         } else {
             if ($forceGd || !\Pop\Image\Imagick::isInstalled()) {
                 $class = '\\Pop\\Image\\Gd';
             } else {
                 $class = '\\Pop\\Image\\Imagick';
             }
         }
         $this->adapter = new $class($options['filename'], $this->width, $this->height, $background);
     }
 }
コード例 #3
0
ファイル: Config.php プロジェクト: akinyeleolubodun/PhireCMS2
 /**
  * Get configuration values
  *
  * @return void
  */
 public function getAll()
 {
     $cfg = Table\Config::getConfig();
     $config = array();
     $formattedConfig = array();
     foreach ($cfg->rows as $c) {
         $config[$c->setting] = $c->setting == 'media_allowed_types' || $c->setting == 'media_actions' ? $value = unserialize($c->value) : $c->value;
     }
     $sysVersion = $config['system_version'];
     $latest = '';
     $handle = fopen('http://update.phirecms.org/system/version', 'r');
     if ($handle !== false) {
         $latest = trim(stream_get_contents($handle));
         fclose($handle);
     }
     if (version_compare(\Phire\Project::VERSION, $latest) < 0 && $this->data['acl']->isAuth('Phire\\Controller\\Phire\\Config\\IndexController', 'update')) {
         $sysVersion .= ' (<a href="' . BASE_PATH . APP_URI . '/config/update">' . $this->i18n->__('Update to') . ' ' . $latest . '</a>?)';
     }
     // Set server config settings
     $formattedConfig['server'] = array('system_version' => $sysVersion, 'system_domain' => $config['system_domain'], 'system_document_root' => $config['system_document_root'], 'system_base_path' => BASE_PATH, 'system_application_path' => APP_PATH, 'system_content_path' => CONTENT_PATH, 'server_operating_system' => $config['server_operating_system'], 'server_software' => $config['server_software'], 'database_version' => $config['database_version'], 'php_version' => $config['php_version'], 'installed_on' => date($this->config->datetime_format, strtotime($config['installed_on'])), 'updated_on' => $config['updated_on'] != '0000-00-00 00:00:00' ? date($this->config->datetime_format, strtotime($config['updated_on'])) : '(' . $this->i18n->__('Never') . ')');
     // Set site title form element
     $siteTitle = new Element('text', 'site_title', $config['site_title']);
     $siteTitle->setAttributes('size', 85)->setAttributes('style', 'padding: 5px;');
     // Set system title form element
     $systemTitle = new Element('text', 'system_title', $config['system_title']);
     $systemTitle->setAttributes('size', 85)->setAttributes('style', 'padding: 5px;');
     // Set system email form element
     $systemEmail = new Element('text', 'system_email', $config['system_email']);
     $systemEmail->setAttributes('size', 85)->setAttributes('style', 'padding: 5px;');
     // Set system email form element
     $replyEmail = new Element('text', 'reply_email', $config['reply_email']);
     $replyEmail->setAttributes('size', 85)->setAttributes('style', 'padding: 5px;');
     // Set separator form element
     $separator = new Element('text', 'separator', $config['separator']);
     $separator->setAttributes('size', 3)->setAttributes('style', 'padding: 5px;');
     // Set default language form element
     $langs = I18n::getLanguages();
     foreach ($langs as $key => $value) {
         $langs[$key] = substr($value, 0, strpos($value, ' ('));
     }
     $lang = new Element\Select('default_language', $langs, $config['default_language'], '                    ');
     // Set date and time format form element
     $datetime = $this->getDateTimeFormat($config['datetime_format']);
     // Set max media size form element
     $maxSize = new Element('text', 'media_max_filesize', $this->getMaxSize($config['media_max_filesize']));
     $maxSize->setAttributes('size', 10)->setAttributes('style', 'padding: 3px;');
     // Set page limit form element
     $pageLimit = new Element('text', 'pagination_limit', $config['pagination_limit']);
     $pageLimit->setAttributes('size', 10)->setAttributes('style', 'padding: 3px;');
     // Set page range form element
     $pageRange = new Element('text', 'pagination_range', $config['pagination_range']);
     $pageRange->setAttributes('size', 10)->setAttributes('style', 'padding: 3px;');
     // Set media actions and media types form elements
     $mediaConfig = $this->getMediaConfig($config['media_actions']);
     $mediaTypes = $this->getMediaAllowedTypes($config['media_allowed_types']);
     $imageAdapters = array('Gd' => 'Gd');
     if (\Pop\Image\Imagick::isInstalled()) {
         $imageAdapters['Imagick'] = 'Imagick';
     }
     $phpLimits = array('post_max_size' => str_replace(array('M', 'K'), array(' MB', ' KB'), strtoupper(ini_get('post_max_size'))), 'upload_max_filesize' => str_replace(array('M', 'K'), array(' MB', ' KB'), strtoupper(ini_get('upload_max_filesize'))), 'max_file_uploads' => str_replace(array('M', 'K'), array(' MB', ' KB'), strtoupper(ini_get('max_file_uploads'))));
     $phpLimitsString = '';
     foreach ($phpLimits as $limit => $limitValue) {
         $phpLimitsString .= '<span style="padding: 0 5px 0 5px;">' . $this->i18n->__(ucwords(str_replace('_', ' ', $limit))) . ': ' . '<strong>' . $limitValue . '</strong></span>';
     }
     $formattedConfig['settings'] = array('site_title' => $siteTitle, 'system_title' => $systemTitle, 'system_email' => $systemEmail, 'reply_email' => $replyEmail, 'separator' => $separator, 'default_language' => $lang, 'datetime_format' => $datetime, 'media_allowed_types' => $mediaTypes, 'media_max_filesize' => '                    ' . $maxSize . ' &nbsp;&nbsp;&nbsp; [<strong style="color: #f00; padding: 0 0 0 5px;">PHP ' . $this->i18n->__('Limits') . ':</strong> ' . $phpLimitsString . ']', 'media_actions' => $mediaConfig, 'media_image_adapter' => new Element\Select('media_image_adapter', $imageAdapters, $config['media_image_adapter'], '                    '), 'pagination_limit' => '                    ' . $pageLimit, 'pagination_range' => '                    ' . $pageRange, 'force_ssl' => new Element\Radio('force_ssl', array('1' => $this->i18n->__('Yes'), '0' => $this->i18n->__('No')), $config['force_ssl'], '                    '), 'live' => new Element\Radio('live', array('1' => $this->i18n->__('Yes'), '0' => $this->i18n->__('No')), $config['live'], '                    '));
     $this->data['config'] = new \ArrayObject($formattedConfig, \ArrayObject::ARRAY_AS_PROPS);
 }
コード例 #4
0
 /**
  * Edit action method
  *
  * @param  int $id
  * @return void
  */
 public function edit($id)
 {
     $library = new Model\MediaLibrary();
     $library->getById($id);
     $this->prepareView('media/libraries/edit.phtml');
     $this->view->title = 'Media Libraries';
     $this->view->library_name = $library->name;
     $fields = $this->application->config()['forms']['Phire\\Media\\Form\\MediaLibrary'];
     if (\Pop\Image\Gd::isInstalled()) {
         $fields[0]['adapter']['value']['Gd'] = 'Gd';
     }
     if (\Pop\Image\Imagick::isInstalled()) {
         $fields[0]['adapter']['value']['Imagick'] = 'Imagick';
     }
     if (\Pop\Image\Gmagick::isInstalled()) {
         $fields[0]['adapter']['value']['Gmagick'] = 'Gmagick';
     }
     $fields[1]['name']['attributes']['onkeyup'] .= ' phire.changeTitle(this.value);';
     $this->view->form = new Form\MediaLibrary($fields);
     $this->view->form->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($library->toArray());
     if ($this->request->isPost()) {
         $this->view->form->setFieldValues($this->request->getPost());
         if ($this->view->form->isValid()) {
             $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter();
             $library = new Model\MediaLibrary();
             $library->update($this->view->form->getFields());
             $this->view->id = $library->id;
             $this->sess->setRequestValue('saved', true);
             $this->redirect(BASE_PATH . APP_URI . '/media/libraries/edit/' . $library->id);
         }
     }
     $this->send();
 }
コード例 #5
0
ファイル: Imagick.php プロジェクト: nicksagona/PopPHP
 /**
  * Overlay an image onto the current image.
  *
  * @param  string     $ovr
  * @param  int|string $x
  * @param  int|string $y
  * @return \Pop\Image\Imagick
  */
 public function overlay($ovr, $x = 0, $y = 0)
 {
     $overlayImage = new \Imagick($ovr);
     if ($this->opacity < 1) {
         $overlayImage->setImageOpacity($this->opacity);
     }
     $this->resource->compositeImage($overlayImage, $this->overlay, $x, $y);
     return $this;
 }
コード例 #6
0
ファイル: Captcha.php プロジェクト: nicksagona/PopPHP
 /**
  * Constructor
  *
  * Instantiate a CAPTCHA image object. Valid options are:
  *
  *     $options = array(
  *         'width'      => 75,
  *         'height'     => 25,
  *         'background' => array(200, 200, 200) // R, G, B values for the background color
  *     );
  *
  *     $options = array(
  *         'image'  => 'some-image-background,gif'
  *     );
  *
  * This $forceGd flag forces the object to use the Gd extension. If both are
  * installed, it will default to Imagick unless this flag is set to true.
  *
  * @param array   $options
  * @param boolean $forceGd
  * @throws Exception
  * @return \Pop\Image\Captcha
  */
 public function __construct(array $options, $forceGd = false)
 {
     // Check that at least one of the image extensions is installed
     if (!Gd::isInstalled() && !Imagick::isInstalled()) {
         throw new Exception('Error: At least either the GD or Imagick extension must be installed.');
     }
     if ($forceGd) {
         $class = 'Pop\\Image\\Gd';
     } else {
         $class = Imagick::isInstalled() ? 'Pop\\Image\\Imagick' : 'Pop\\Image\\Gd';
     }
     // Parse through the options
     if (isset($options['image']) && file_exists($options['image'])) {
         $image = $options['image'];
         $w = null;
         $h = null;
     } else {
         if (isset($options['width']) && isset($options['height']) && is_numeric($options['width']) && is_numeric($options['height'])) {
             $image = 'pop-captcha.gif';
             $w = $options['width'];
             $h = $options['height'];
         } else {
             throw new Exception('Error: You must either pass a valid width and height or a valid image in the $options parameter.');
         }
     }
     if (isset($options['background']) && is_array($options['background']) && count($options['background']) == 3) {
         $background = new Rgb($options['background'][0], $options['background'][1], $options['background'][2]);
     } else {
         $background = null;
     }
     // Create new image object
     $this->image = new $class($image, $w, $h, $background);
 }
コード例 #7
0
ファイル: imagick.php プロジェクト: nicksagona/PopPHP
<?php

require_once '../../bootstrap.php';
use Pop\Color\Space\Rgb;
use Pop\Image\Imagick;
try {
    $imagick = new Imagick('../assets/images/test.jpg');
    $imagick->invert()->swirl(90)->save('../tmp/test.jpg');
    // Calling the destructor destroys the image resource as well
    unset($imagick);
    echo 'Image saved.';
} catch (\Exception $e) {
    echo $e->getMessage();
}
コード例 #8
0
ファイル: ImagickTest.php プロジェクト: nicksagona/PopPHP
 public function testStaticImageFormats()
 {
     $this->assertGreaterThan(1, count(Imagick::formats()));
 }