/**
  *
  * Utility function that loads all the drivers
  * in the drivers directory
  * @throws ServiceDriverException
  */
 private static final function loadDrivers()
 {
     // if the pointer is null, then we sould load the drivers
     if (self::$drivers == null) {
         // create a new array
         self::$drivers = array();
         // get all files in the drivers folders
         $drivers = General::listStructure(OEMBED_DRIVERS_DIR, '/class.service[a-zA-Z0-9]+.php/', false, 'asc');
         // for each file found
         foreach ($drivers['filelist'] as $class) {
             $class = basename($class);
             try {
                 // include the class code
                 require_once OEMBED_DRIVERS_DIR . $class;
                 // get class name
                 $class = str_replace(array('class.', '.php'), '', $class);
                 // create new instance
                 $class = new $class($url);
                 // add the class to the stack
                 self::$drivers[$class->getName()] = $class;
             } catch (Exception $ex) {
                 throw new ServiceDriverException($url, $ex);
             }
         }
     }
 }
예제 #2
0
 public function appendFormattedElement(XMLElement $wrapper, StdClass $settings, StdClass $data, $entry_id = null)
 {
     $wrapper->setAttribute('id', $data->{'id'});
     $title = new XMLElement('title');
     $title->setValue(General::sanitize($data->{'title'}));
     $title->setAttribute('handle', Lang::createHandle($data->{'title'}));
     $wrapper->appendChild($title);
     $wrapper->appendChild(new XMLElement('url', General::sanitize($data->{'url'})));
     $wrapper->appendChild(new XMLElement('thumbnail', General::sanitize($data->{'thumb'})));
     $wrapper->appendChild(new XMLElement('driver', General::sanitize($data->{'driver'})));
     // Enable better error handling:
     libxml_use_internal_errors(true);
     $driver = ServiceDispatcher::getServiceDriver($data->{'url'});
     $xml = new DOMDocument();
     $xml->loadXML($data->{'xml'});
     // Ignore any errors:
     libxml_clear_errors();
     // Find the root element:
     $root = $xml->getElementsByTagName($driver->getRootTagName())->item(0);
     // Data was found:
     if ($root instanceof DOMNode) {
         $oembed = new XMLElement('oembed');
         foreach ($root->childNodes as $node) {
             $element = new XMLElement($node->tagName);
             $element->setValue(General::sanitize($node->textContent));
             $oembed->appendChild($element);
         }
         $wrapper->appendChild($oembed);
     } else {
         $error = new XMLElement('error');
         $error->setValue(__('Error while loading the xml into the document'));
         $wrapper->appendChild($error);
     }
 }
예제 #3
0
 public static function updateFieldData_Driver()
 {
     $tbl = self::FIELD_TBL_NAME;
     // allow all drivers for fields that already exists
     $drivers = MySQL::cleanValue(implode(',', ServiceDispatcher::getAllDriversNames()));
     return Symphony::Database()->query("\n\t\t\t\tUPDATE `{$tbl}`\n\t\t\t\t\tSET `driver` = '{$drivers}'\n\t\t\t");
 }