isInstalled() публичный статический Метод

Check if GD is installed.
public static isInstalled ( ) : boolean
Результат boolean
 /**
  * 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
 /**
  * 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();
 }
Пример #3
0
 /**
  * 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);
 }