本文整理汇总了PHP中DataUtil::purifyHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP DataUtil::purifyHtml方法的具体用法?PHP DataUtil::purifyHtml怎么用?PHP DataUtil::purifyHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataUtil
的用法示例。
在下文中一共展示了DataUtil::purifyHtml方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCopy
public function testCopy()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = Yii::app()->user->userModel;
$project = new Project();
$project->name = 'Project 1';
$project->owner = $user;
$project->description = 'Description';
$user = UserTestHelper::createBasicUser('Steven');
$account = new Account();
$account->owner = $user;
$account->name = DataUtil::purifyHtml("Tom & Jerry's Account");
$this->assertTrue($account->save());
$id = $account->id;
unset($account);
$account = Account::getById($id);
$this->assertEquals("Tom & Jerry's Account", $account->name);
$contact = ContactTestHelper::createContactByNameForOwner('Jerry', $user);
$opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Jerry Opp', $user);
$this->assertTrue($project->save());
$this->assertEquals(1, count($project->auditEvents));
$id = $project->id;
$project->forget();
unset($project);
$project = Project::getById($id);
ProjectZurmoControllerUtil::resolveProjectManyManyAccountsFromPost($project, array('accountIds' => $account->id));
ProjectZurmoControllerUtil::resolveProjectManyManyContactsFromPost($project, array('contactIds' => $contact->id));
ProjectZurmoControllerUtil::resolveProjectManyManyOpportunitiesFromPost($project, array('opportunityIds' => $opportunity->id));
$this->assertEquals('Project 1', $project->name);
$this->assertEquals('Description', $project->description);
$this->assertEquals(1, $project->accounts->count());
$this->assertEquals(1, $project->contacts->count());
$this->assertEquals(1, $project->opportunities->count());
$task = TaskTestHelper::createTaskByNameWithProjectAndStatus('MyFirstKanbanTask', Yii::app()->user->userModel, $project, Task::STATUS_IN_PROGRESS);
$kanbanItem1 = KanbanItem::getByTask($task->id);
$this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem1->type);
$this->assertEquals($task->project->id, $kanbanItem1->kanbanRelatedItem->id);
$copyToProject = new Project();
ProjectZurmoCopyModelUtil::copy($project, $copyToProject);
ProjectZurmoCopyModelUtil::processAfterCopy($project, $copyToProject);
$this->assertTrue($copyToProject->save());
$this->assertEquals($copyToProject->name, $project->name);
$this->assertEquals($copyToProject->description, $project->description);
$this->assertEquals($copyToProject->status, $project->status);
$project = Project::getByName('Project 1');
$this->assertEquals(2, count($project));
$tasks = Task::getAll();
$this->assertEquals(2, count($tasks));
}
示例2: testPurifyHtml
public function testPurifyHtml()
{
$text = '<b>This</b> is <a href="http://www.zurmo.com">valid text</a>';
$purifiedText = DataUtil::purifyHtml($text);
$this->assertEquals($text, $purifiedText);
$text = "<IMG SRC=JaVaScRiPt:alert('XSS')>";
// Not Coding Standard
$purifiedText = DataUtil::purifyHtml($text);
$this->assertEquals('', $purifiedText);
$text = "Valid text.<SCRIPT>alert('XSS')</SCRIPT>";
$purifiedText = DataUtil::purifyHtml($text);
$this->assertEquals('Valid text.', $purifiedText);
$text = "<SCRIPT>alert('XSS')</SCRIPT>Valid text.";
$purifiedText = DataUtil::purifyHtml($text);
$this->assertEquals('Valid text.', $purifiedText);
}
示例3: testCreateAndGetProjectById
public function testCreateAndGetProjectById()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = Yii::app()->user->userModel;
$project = new Project();
$project->name = 'Project 1';
$project->owner = $user;
$project->description = 'Description';
$user = UserTestHelper::createBasicUser('Steven');
$account = new Account();
$account->owner = $user;
$account->name = DataUtil::purifyHtml("Tom & Jerry's Account");
$this->assertTrue($account->save());
$id = $account->id;
unset($account);
$account = Account::getById($id);
$this->assertEquals("Tom & Jerry's Account", $account->name);
//$project->accounts->add($account);
$contact = ContactTestHelper::createContactByNameForOwner('Jerry', $user);
//$project->contacts->add($contact);
$opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Jerry Opp', $user);
//$project->opportunities->add($opportunity);
$this->assertTrue($project->save());
$this->assertEquals(1, count($project->auditEvents));
$id = $project->id;
$project->forget();
unset($project);
$project = Project::getById($id);
ProjectZurmoControllerUtil::resolveProjectManyManyAccountsFromPost($project, array('accountIds' => $account->id));
ProjectZurmoControllerUtil::resolveProjectManyManyContactsFromPost($project, array('contactIds' => $contact->id));
ProjectZurmoControllerUtil::resolveProjectManyManyOpportunitiesFromPost($project, array('opportunityIds' => $opportunity->id));
$this->assertEquals('Project 1', $project->name);
$this->assertEquals('Description', $project->description);
$this->assertEquals(1, $project->accounts->count());
$this->assertEquals(1, $project->contacts->count());
$this->assertEquals(1, $project->opportunities->count());
//Try saving a second project
$project = new Project();
$project->name = 'Project 2';
$project->owner = $user;
$project->description = 'Description';
$this->assertTrue($project->save());
$this->assertEquals(1, count($project->auditEvents));
}
示例4: testCreateAndGetAccountById
/**
* @depends testConfirmAccountNameIdElementStillImplementsCorrectInterfaceFromParent
*/
public function testCreateAndGetAccountById()
{
$user = UserTestHelper::createBasicUser('Steven');
$account = new Account();
$account->owner = $user;
$account->name = DataUtil::purifyHtml("Tom & Jerry's Account");
$this->assertEquals("Tom & Jerry's Account", $account->name);
$this->assertTrue($account->save());
$id = $account->id;
unset($account);
$account = Account::getById($id);
$this->assertEquals("Tom & Jerry's Account", $account->name);
$account->name = 'Test Account';
$account->officePhone = '1234567890';
$this->assertTrue($account->save());
$id = $account->id;
unset($account);
$account = Account::getById($id);
$this->assertEquals('Test Account', $account->name);
$this->assertEquals('1234567890', $account->officePhone);
}
示例5: resolveMessageSubjectAndContentAndSendSystemMessage
/**
* Resolve system message to be sent, and send it
* @param string $messageType
* @param ImapMessage $originalMessage
* @return boolean
* @throws NotSupportedException
*/
protected function resolveMessageSubjectAndContentAndSendSystemMessage($messageType, $originalMessage)
{
$sendNotification = false;
switch ($messageType) {
case "OwnerNotExist":
$subject = Zurmo::t('EmailMessagesModule', 'Invalid email address');
$textContent = Zurmo::t('EmailMessagesModule', 'Email address does not exist in system') . "\n\n" . $originalMessage->textBody;
$htmlContent = Zurmo::t('EmailMessagesModule', 'Email address does not exist in system') . "<br\\><br\\>" . $originalMessage->htmlBody;
$sendNotification = true;
break;
case "SenderNotExtracted":
$subject = Zurmo::t('EmailMessagesModule', "Sender info can't be extracted from email message");
$textContent = Zurmo::t('EmailMessagesModule', "Sender info can't be extracted from email message") . "\n\n" . $originalMessage->textBody;
$htmlContent = Zurmo::t('EmailMessagesModule', "Sender info can't be extracted from email message") . "<br\\><br\\>" . $originalMessage->htmlBody;
break;
case "RecipientNotExtracted":
$subject = Zurmo::t('EmailMessagesModule', "Recipient info can't be extracted from email message");
$textContent = Zurmo::t('EmailMessagesModule', "Recipient info can't be extracted from email message") . "\n\n" . $originalMessage->textBody;
$htmlContent = Zurmo::t('EmailMessagesModule', "Recipient info can't be extracted from email message") . "<br\\><br\\>" . $originalMessage->htmlBody;
break;
case "EmailMessageNotValidated":
$subject = Zurmo::t('EmailMessagesModule', 'Email message could not be validated');
$textContent = Zurmo::t('EmailMessagesModule', 'Email message could not be validated') . "\n\n" . $originalMessage->textBody;
$htmlContent = Zurmo::t('EmailMessagesModule', 'Email message could not be validated') . "<br\\><br\\>" . $originalMessage->htmlBody;
break;
case "EmailMessageNotSaved":
$subject = Zurmo::t('EmailMessagesModule', 'Email message could not be saved');
$textContent = Zurmo::t('EmailMessagesModule', 'Email message could not be saved') . "\n\n" . $originalMessage->textBody;
$htmlContent = Zurmo::t('EmailMessagesModule', 'Email message could not be saved') . "<br\\><br\\>" . $originalMessage->htmlBody;
break;
default:
throw new NotSupportedException();
}
if ($sendNotification) {
$notificationMessage = new NotificationMessage();
$notificationMessage->textContent = $textContent;
$notificationMessage->htmlContent = DataUtil::purifyHtml($htmlContent);
$rules = new EmailMessageOwnerNotExistNotificationRules();
NotificationsUtil::submit($notificationMessage, $rules);
} else {
return EmailMessageHelper::sendSystemEmail($subject, array($originalMessage->fromEmail), $textContent, $htmlContent);
}
}
示例6: sanitizeHiddenAttributeValue
/**
* @param $attributeName
* @param $value
* @return string
*/
public static function sanitizeHiddenAttributeValue($attributeName, $value)
{
$designerType = ModelAttributeToDesignerTypeUtil::getDesignerType(new Contact(false), $attributeName);
$sanitizedAttributeValue = $value;
if ($designerType == 'Date' && !empty($value)) {
$sanitizedAttributeValue = DateTimeUtil::resolveValueForDateDBFormatted($value);
}
if ($designerType == 'DateTime' && !empty($value)) {
$sanitizedAttributeValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero($value);
}
return DataUtil::purifyHtml($sanitizedAttributeValue);
}
示例7: createNotificationMessage
/**
* Creates notification message for new comment
* @param $model
* @param Comment $comment
* @return NotificationMessage
*/
protected static function createNotificationMessage($model, Comment $comment)
{
$notificationMessage = new NotificationMessage();
$url = static::getUrlToEmail($model);
$shortUrl = ShortUrlUtil::createShortUrl($url);
$textContent = Zurmo::t('CommentsModule', 'Hello, {lineBreak} {updaterName} added a new comment to the ' . '{strongStartTag}{modelName}{strongEndTag}: {lineBreak}' . '"{commentDescription}." {lineBreak}{lineBreak} {url} ', array('{lineBreak}' => "\n", '{strongStartTag}' => null, '{strongEndTag}' => null, '{updaterName}' => strval($comment->createdByUser), '{modelName}' => $model->getModelLabelByTypeAndLanguage('SingularLowerCase'), '{commentDescription}' => strval($comment), '{url}' => $shortUrl));
$notificationMessage->textContent = $textContent;
$htmlContent = Zurmo::t('CommentsModule', 'Hello, {lineBreak} {updaterName} added a new comment to the ' . '{strongStartTag}{url}{strongEndTag}: {lineBreak}' . '"{commentDescription}."', array('{lineBreak}' => "<br/>", '{strongStartTag}' => '<strong>', '{strongEndTag}' => '</strong>', '{updaterName}' => strval($comment->createdByUser), '{commentDescription}' => strval($comment), '{url}' => ZurmoHtml::link($model->getModelLabelByTypeAndLanguage('SingularLowerCase'), $url, array('target' => '_blank'))));
$notificationMessage->htmlContent = DataUtil::purifyHtml($htmlContent);
return $notificationMessage;
}