public function configure()
 {
     parent::configure();
     unset($this['embed']);
     $this->setValidator('service_url', new sfValidatorUrl(array('required' => true, 'trim' => true), array('required' => "Not a valid YouTube URL")));
     $this->widgetSchema->setFormFormatterName('aAdmin');
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe');
 }
 public function updateObject($values = null)
 {
     $object = parent::updateObject($values);
     // If possible, get the width and height from the embed tag rather
     // than from the thumbnail the user uploaded, which is likely to be
     // a mismatch quite often. If the embed tag has percentages we don't
     // want to match, just let the thumbnail dimensions win
     if (preg_match("/width\\s*=\\s*([\"'])(\\d+)\\1/i", $object->embed, $matches)) {
         $object->width = $matches[2];
     }
     if (preg_match("/height\\s*=\\s*([\"'])(\\d+)\\1/i", $object->embed, $matches)) {
         $object->height = $matches[2];
     }
     // Put placeholders in the embed/applet/object tags
     $object->embed = preg_replace(array("/width\\s*=\\s*([\"'])\\d+%?\\1/i", "/height\\s*=\\s*([\"'])\\d+%?\\1/i", "/alt\\s*\\s*([\"']).*?\\1/i"), array("width=\"_WIDTH_\"", "height=\"_HEIGHT_\"", "alt=\"_TITLE_\""), $object->embed);
     return $object;
 }
Example #3
0
echo a_('Add by Embed Code');
?>
</h3>
<p><?php 
echo a_("You can paste almost any embed code below. You can also paste a URL for the following services: ");
?>
  <?php 
$list = array();
?>
  <?php 
echo implode(a_(', '), aMediaTools::getEmbedServiceNames());
?>
</p>

<?php 
$form = new aMediaVideoForm();
?>
<form id="a-media-video-add-by-embed-form" class="a-media-search-form" method="post" action="<?php 
echo url_for("aMedia/editVideo");
?>
">
	<div class="a-form-row a-hidden">
  	<?php 
// If you tamper with this, the next form will be missing a default radio button choice
?>
    <?php 
echo $form['view_is_secure']->render();
?>
  	<?php 
echo $form->renderHiddenFields();
?>
Example #4
0
 /**
  * DOCUMENT ME
  * @param SimpleXMLElement $slot
  * @return mixed
  */
 protected function parseSlotForeignHtml(SimpleXMLElement $slot, $title = null, &$counters = null)
 {
     $n = 1;
     $html = $slot->value->__toString();
     $segments = aString::splitAndCaptureAtEarliestMatch($html, array('/\\<a href=\\"[^\\"]+\\"[^\\>]*>\\s*(?:\\<br \\/\\>|&nbsp;|\\s)*\\<img.*?src="[^\\"]+[^\\>]*\\>(?:\\<br \\/\\>|&nbsp;|\\s)*\\<\\/a\\>/is', '/\\<img.*?src="[^\\"]+".*?\\>/is', '/\\<object.*?\\>.*?\\<\\/object\\>/is', '/\\<iframe.*?\\>.*?\\<\\/iframe\\>/is'));
     foreach ($segments as $segment) {
         $mediaItem = null;
         if (preg_match('/\\<object.*?\\>.*?\\<\\/object\\>|\\<iframe.*?\\>.*?\\<\\/iframe\\>/is', $segment)) {
             $form = new aMediaVideoForm();
             $result = $form->classifyEmbed($segment);
             if ($result['ok']) {
                 $info = array('title' => isset($result['serviceInfo']['title']) ? $result['serviceInfo']['title'] : $title . ' video ' . $n, 'embed' => $result['embed'], 'width' => isset($result['width']) ? $result['width'] : null, 'height' => isset($result['height']) ? $result['height'] : null, 'format' => isset($result['format']) ? $result['format'] : null, 'type' => 'video', 'tags' => isset($result['serviceInfo']['tags']) ? preg_split('/\\s*,\\s*/', $result['serviceInfo']['tags']) : array(), 'service_url' => isset($result['serviceInfo']['url']) ? $result['serviceInfo']['url'] : null);
                 $mediaId = $this->findOrAddVideo($info);
                 $slotInfos[] = array('type' => 'aVideo', 'mediaId' => $mediaId);
                 $n++;
             }
         } elseif (preg_match('/<img.*?src="(.*?)".*?>/is', $segment, $matches)) {
             $src = $matches[1];
             // &amp; won't work if we don't decode it to & before passing it to the server
             $src = html_entity_decode($src);
             $mediaId = $this->findOrAddMediaItem($src, 'id');
             if (preg_match('/href="(.*?)"/', $segment, $matches)) {
                 $url = $matches[1];
             }
             // $mediaItem->save();
             if (!is_null($mediaId)) {
                 $slotInfo = array('type' => 'aImage', 'mediaId' => $mediaId, 'value' => array());
                 if (isset($url)) {
                     $slotInfo = array('type' => 'aButton', 'value' => array('url' => $url, 'title' => ''), 'mediaId' => $mediaId);
                 }
                 $slotInfos[] = $slotInfo;
             }
         } else {
             $slotInfos[] = array('type' => 'aRichText', 'value' => aHtml::simplify($segment));
         }
     }
     return $slotInfos;
 }