/** * @see sfValidatorBase */ protected function doClean($value) { $clean = (string) $value; if ($this->getOption('strip')) { $clean = aHtml::simplify($clean, $this->getOptionOrFalse('allowed_tags'), $this->getOptionOrFalse('complete'), $this->getOptionOrFalse('allowed_attributes'), $this->getOptionOrFalse('allowed_styles')); } else { throw new sfException('That should not happen strip is set in configure in sfValidatorHtml'); } $clean = parent::doClean($clean); return $clean; }
/** * DOCUMENT ME * @param mixed $values * @return mixed */ public function updateObject($values = null) { $object = parent::updateObject($values); // Do some postvalidation of what parent::updateObject did // (it would be nice to turn this into an sfValidator subclass) $object->setDescription(aHtml::simplify($object->getDescription(), "<p><br><b><i><strong><em><ul><li><ol><a>")); // The tags field is not a native Doctrine field // so we can't rely on parent::updateObject to sort out // whether to use $values or $this->getValue. So we need // to sanitize and figure out what set of values to use // (embedded forms get a $values parameter, non-embedded // use $this->values) if (is_null($values)) { $values = $this->values; } // Slashes break routes in most server configs. Do NOT force case of tags. $values['tags'] = str_replace('/', '-', isset($values['tags']) ? $values['tags'] : ''); $object->setTags($values['tags']); return $object; }
public function updateObject($values = null) { $object = parent::updateObject($values); // Do some postvalidation of what parent::updateObject did // (it would be nice to turn this into an sfValidator subclass) $object->setDescription(aHtml::simplify($object->getDescription(), "<p><br><b><i><strong><em><ul><li><ol><a>")); // The tags field is not a native Doctrine field // so we can't rely on parent::updateObject to sort out // whether to use $values or $this->getValue. So we need // to sanitize and figure out what set of values to use // (embedded forms get a $values parameter, non-embedded // use $this->values) if (is_null($values)) { $values = $this->values; } // Now we're ready to play // We like all-lowercase tags for consistency $values['tags'] = strtolower($values['tags']); $object->setTags($values['tags']); $object->setOwnerId(sfContext::getInstance()->getUser()->getGuardUser()->getId()); return $object; }
/** * * This function returns a basic HTML representation of your slot's comments * (passing the default settings of aHtml::simplify, for instance). Used for Google Calendar * buttons, RSS feeds and similar * @return string */ public function getBasicHtml() { return aHtml::simplify($this->value); }
</a> <?php } else { ?> <?php echo $feedItem->getTitle(); ?> <?php } ?> </li> <?php $date = $feedItem->getPubDate(); ?> <?php if ($date) { ?> <li class="date"><?php echo $dateFormat ? date($dateFormat, $date) : aDate::pretty($date) . ' ' . aDate::time($date); ?> </li> <?php } ?> <li class="description"><?php echo auto_link_text(aHtml::simplify($feedItem->getDescription(), $markup, false, isset($attributes) ? $attributes : false, isset($styles) ? $styles : false)); ?> </li> </ul> </li>
<li class="a-feed-item"> <ul> <li class="title"><?php echo link_to_if($feedItem->getLink() && $links, $feedItem->getTitle(), $feedItem->getLink()); ?> </li> <?php $date = $feedItem->getPubDate(); ?> <li class="date"><?php echo $dateFormat ? date($dateFormat, $date) : aDate::pretty($date) . ' ' . aDate::time($date); ?> </li> <li class="description"><?php echo aHtml::simplify($feedItem->getDescription(), $markup); ?> </li> </ul> </li>
/** * 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 \\/\\>| |\\s)*\\<img.*?src="[^\\"]+[^\\>]*\\>(?:\\<br \\/\\>| |\\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]; // & 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; }