/**
  * {@inheritdoc}
  */
 function validate(\Payment $payment, \PaymentMethod $payment_method, $strict)
 {
     parent::validate($payment, $payment_method, $strict);
     if (!($library = libraries_detect('stripe-php')) || empty($library['installed'])) {
         throw new \PaymentValidationException(t('The stripe-php library could not be found.'));
     }
 }
Exemple #2
0
 /**
  * Scan plugin directories and get information from e_libraries.php files.
  */
 function pluginsPage()
 {
     e107_require_once(e_PLUGIN . 'libraries/libraries.php');
     $mes = e107::getMessage();
     $tpl = e107::getTemplate('libraries');
     $sc = e107::getScBatch('libraries', true);
     $tp = e107::getParser();
     $addonsList = libraries_update_addon_list();
     $summ = count($addonsList);
     $message = str_replace('[summ]', $summ, LAN_PLUGIN_LIBRARIES_ADMIN_03);
     $mes->addInfo($message);
     $this->addTitle(LAN_PLUGIN_LIBRARIES_ADMIN_02);
     $output = $mes->render();
     $libraries = libraries_info();
     $output .= $tp->parseTemplate($tpl['TABLE']['HEADER']);
     foreach ($libraries as $machine_name => $info) {
         $details = libraries_detect($machine_name);
         $sc->setVars(array('name' => $details['name'], 'plugin' => varset($details['plugin'], false), 'theme' => varset($details['theme'], false), 'vendor' => $details['vendor url'], 'download' => $details['download url'], 'installed' => array('status' => $details['installed'], 'error' => varset($details['error'], ''), 'message' => varset($details['error message'], ''))));
         $output .= $tp->parseTemplate($tpl['TABLE']['ROW'], true, $sc);
     }
     $output .= $tp->parseTemplate($tpl['TABLE']['FOOTER']);
     return $output;
 }
Exemple #3
0
 /**
  * Return the version of the Openlayers library in use.
  *
  * @return string
  *   Return the version of the Openlayers library in the filesystem.
  */
 public static function getLocalLibraryVersion()
 {
     $version = FALSE;
     if ($path = libraries_get_path('openlayers3')) {
         $library = libraries_detect('openlayers3');
         $options = array('file' => 'build/ol.js', 'pattern' => '@Version: (.*)@', 'lines' => 3);
         $library['library path'] = $path;
         if ($version = libraries_get_version($library, $options)) {
             $version = substr($version, 1);
         }
     }
     return $version;
 }
 /**
  * Return information about the Openlayers 3 if installed.
  *
  * @return array|false
  */
 public static function getLibrary()
 {
     return libraries_detect('openlayers3');
 }
 /**
  * Tests the applying of callbacks.
  */
 function testCallbacks()
 {
     $expected = array('name' => 'Example callback', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', 'version' => '1', 'versions' => array('1' => array('variants' => array('example_variant' => array('info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied')), 'info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied')), 'variants' => array('example_variant' => array('info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied')), 'callbacks' => array('info' => array('_libraries_test_info_callback'), 'pre-detect' => array('_libraries_test_pre_detect_callback'), 'post-detect' => array('_libraries_test_post_detect_callback'), 'pre-load' => array('_libraries_test_pre_load_callback'), 'post-load' => array('_libraries_test_post_load_callback')), 'info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied', 'module' => 'libraries_test');
     libraries_info_defaults($expected, 'example_callback');
     // Test a callback in the 'info' group.
     $expected['info callback'] = 'applied (top-level)';
     $expected['versions']['1']['info callback'] = 'applied (version 1)';
     $expected['versions']['1']['variants']['example_variant']['info callback'] = 'applied (version 1, variant example_variant)';
     $expected['variants']['example_variant']['info callback'] = 'applied (variant example_variant)';
     $library = libraries_info('example_callback');
     $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
     $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
     $this->assertEqual($library, $expected, 'Prepare callback was applied correctly.');
     // Test a callback in the 'pre-detect' and 'post-detect' phases.
     // Successfully detected libraries should only contain version information
     // for the detected version and thus, be marked as installed.
     unset($expected['versions']);
     $expected['installed'] = TRUE;
     // Additionally, version-specific properties of the detected version are
     // supposed to override the corresponding top-level properties.
     $expected['info callback'] = 'applied (version 1)';
     $expected['variants']['example_variant']['installed'] = TRUE;
     $expected['variants']['example_variant']['info callback'] = 'applied (version 1, variant example_variant)';
     // Version-overloading takes place after the 'pre-detect' callbacks have
     // been applied.
     $expected['pre-detect callback'] = 'applied (version 1)';
     $expected['post-detect callback'] = 'applied (top-level)';
     $expected['variants']['example_variant']['pre-detect callback'] = 'applied (version 1, variant example_variant)';
     $expected['variants']['example_variant']['post-detect callback'] = 'applied (variant example_variant)';
     $library = libraries_detect('example_callback');
     $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
     $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
     $this->assertEqual($library, $expected, 'Detect callback was applied correctly.');
     // Test a callback in the 'pre-load' and 'post-load' phases.
     // Successfully loaded libraries should only contain information about the
     // already loaded variant.
     unset($expected['variants']);
     $expected['loaded'] = 0;
     $expected['pre-load callback'] = 'applied (top-level)';
     $expected['post-load callback'] = 'applied (top-level)';
     $library = libraries_load('example_callback');
     $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
     $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
     $this->assertEqual($library, $expected, 'Pre-load and post-load callbacks were applied correctly.');
     // This is not recommended usually and is only used for testing purposes.
     drupal_static_reset('libraries_load');
     // Successfully loaded library variants are supposed to contain the specific
     // variant information only.
     $expected['info callback'] = 'applied (version 1, variant example_variant)';
     $expected['pre-detect callback'] = 'applied (version 1, variant example_variant)';
     $expected['post-detect callback'] = 'applied (variant example_variant)';
     $library = libraries_load('example_callback', 'example_variant');
     $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
     $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
     $this->assertEqual($library, $expected, 'Pre-detect and post-detect callbacks were applied correctly to a variant.');
 }
 /**
  * Validate the correct version for thumbnail options.
  */
 public function validateMinimumVersion22(array &$element, FormStateInterface $form_state)
 {
     $lib = libraries_detect('flexslider');
     if (!isset($lib['version'])) {
         drupal_set_message(t('Unable to detect FlexSlider library version. Some options may not function properly. Please review the README.md file for installation instructions.'), 'warning');
     } else {
         $version = $lib['version'];
         $required = "2.2";
         if ($element['#value'] && !version_compare($version, $required, '>=')) {
             $form_state->setError($element, t('To use %name you must install FlexSlider version !required or higher.', array('%name' => $element['#title'], '!required' => \Drupal\Core\Link::fromTextAndUrl($required, \Drupal\Core\Url::fromUri('https://github.com/woothemes/FlexSlider/tree/version/2.2')))));
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getLibrary($force_local = FALSE, $reset = FALSE)
 {
     // We use our own static cache to lazy-load the lib. Libraries API detection
     // has a static cache, but as we may be bypassing full local detection in
     // certain situations, we can't always use it.
     $library =& self::$library;
     if (!$library || $reset) {
         // See if we have been passed version details in the URL. If so we bypass
         // local detection and build our own libraries array.
         $query = \Drupal::request()->query->all();
         if (!empty($query['jb-version']) && !$force_local) {
             juicebox_library_info($library);
             $version_number = Html::escape($query['jb-version']);
             if (!empty($query['jb-pro'])) {
                 $library['pro'] = TRUE;
                 $version = 'Pro';
             } else {
                 $version = 'Lite';
             }
             $library['version'] = $version . ' ' . $version_number;
             juicebox_library_post_detect($library);
         } else {
             $library = libraries_detect('juicebox');
         }
     }
     return $library;
 }
Exemple #8
0
/**
 * Loads a library.
 *
 * @param $name
 *   The name of the library to load.
 * @param $variant
 *   The name of the variant to load. Note that only one variant of a library can be loaded within a single request.
 *   The variant that has been passed first is used; different variant names in subsequent calls are ignored.
 *
 * @return
 *   An associative array of the library information as returned from libraries_info(). The top-level properties contain
 *   the effective definition of the library (variant) that has been loaded. Additionally:
 *   - installed: Whether the library is installed, as determined by libraries_detect_library().
 *   - loaded: Either the amount of library files that have been loaded, or FALSE if the library could not be loaded.
 *   See MYPLUGIN_libraries::libraries_info() for more information.
 */
function libraries_load($name, $variant = null)
{
    static $loaded;
    if (!isset($loaded[$name])) {
        $library = libraries_detect($name);
        // TODO: cache.
        /*
        $cache = e107::getCache();
        $cacheID = 'libraries_' . $name;
        
        $library = $cache->retrieve($cacheID, false, true, true);
        if($library)
        {
        	$library = unserialize($library);
        }
        else
        {
        	$library = libraries_detect($name);
        	$data = serialize($library);
        	$cache->set($cacheID, $data, true);
        }
        */
        // Exit early if the library was not found.
        if ($library === false) {
            $loaded[$name] = $library;
            return $loaded[$name];
        }
        // If a variant was specified, override the top-level properties with the variant properties.
        if (isset($variant)) {
            // Ensure that the $variant key exists, and if it does not, set its 'installed' property to FALSE by
            // default. This will prevent the loading of the library files below.
            $library['variants'] += array($variant => array('installed' => false));
            $library = array_merge($library, $library['variants'][$variant]);
        }
        // Regardless of whether a specific variant was requested or not, there can only be one variant of a library
        // within a single request.
        unset($library['variants']);
        // TODO:
        // Invoke callbacks in the 'pre-dependencies-load' group.
        libraries_invoke('pre-dependencies-load', $library);
        // If the library (variant) is installed, load it.
        $library['loaded'] = false;
        if ($library['installed']) {
            // Load library dependencies.
            if (isset($library['dependencies'])) {
                foreach ($library['dependencies'] as $dependency) {
                    libraries_load($dependency);
                }
            }
            // TODO:
            // Invoke callbacks in the 'pre-load' group.
            libraries_invoke('pre-load', $library);
            // Load all the files associated with the library.
            $library['loaded'] = libraries_load_files($library);
            // TODO:
            // Invoke callbacks in the 'post-load' group.
            libraries_invoke('post-load', $library);
        }
        $loaded[$name] = $library;
    }
    return $loaded[$name];
}