本文整理汇总了PHP中Ad::isValidAdName方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::isValidAdName方法的具体用法?PHP Ad::isValidAdName怎么用?PHP Ad::isValidAdName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ad
的用法示例。
在下文中一共展示了Ad::isValidAdName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAd
/**
* Create a new ad
*
* @param $name string name of ad
* @param $body string content of ad
* @param $caption string caption/heading of ad
* @param $mainlink string main link for the ad (link caption to page)
* @param $user User causing the change
* @param bool|int $displayAnon integer flag for display to anonymous users
* @param bool|int $displayUser integer flag for display to logged in users
*
* @return bool true or false depending on whether ad was successfully added
*/
static function addAd($name, $body, $caption, $mainlink, $user, $displayAnon = true, $displayUser = true)
{
//if ( $name == '' || !Ad::isValidAdName( $name ) || $body == '' ) {
if ($name == '' || !Ad::isValidAdName($name)) {
return 'promoter-null-string';
}
$ad = Ad::newFromName($name);
if ($ad->exists()) {
return 'promoter-ad-exists';
}
$ad->setAllocation($displayAnon, $displayUser);
$ad->setCaption($caption);
$ad->setMainLink($mainlink);
$ad->setBodyContent($body);
$ad->save($user);
return true;
}
示例2: showAdEditor
/**
* Display the ad editor and process edits
*/
protected function showAdEditor()
{
$out = $this->getOutput();
$out->addModules('ext.promoter.adminUi.adEditor');
if (!Ad::isValidAdName($this->adName)) {
throw new ErrorPageError('campaignad', 'promoter-generic-error');
}
$out->setPageTitle($this->adName);
$out->setSubtitle(Linker::link(SpecialPage::getTitleFor('Randompage'), $this->msg('promoter-live-preview'), array('class' => 'pr-ad-list-element-label-text'), array('ad' => $this->adName)));
// Generate the form
$formDescriptor = $this->generateAdEditForm($this->adName);
// Now begin form processing
$htmlForm = new PromoterHtmlForm($formDescriptor, $this->getContext(), 'promoter');
$htmlForm->setSubmitCallback(array($this, 'processEditAd'));
$htmlForm->loadData();
$formResult = $htmlForm->tryAuthorizedSubmit();
if ($this->adFormRedirectRequired) {
return;
}
// Recreate the form because something could have changed
$formDescriptor = $this->generateAdEditForm($this->adName);
$htmlForm = new PromoterHtmlForm($formDescriptor, $this->getContext(), 'promoter');
$htmlForm->setSubmitCallback(array($this, 'processEditAd'))->setId('pr-ad-editor');
// Push the form back to the user
$htmlForm->suppressDefaultSubmit()->setId('pr-ad-editor')->setDisplayFormat('div')->prepareForm()->displayForm($formResult);
$ad = Ad::fromName($this->adName);
$linkedCampaigns = $ad->getLinkedCampaignNames();
$htmlList = "<h2>" . wfMessage('promoter-ad-linked-campaigns')->text() . "</h2>";
if (empty($linkedCampaigns)) {
$htmlList .= wfMessage('promoter-ad-linked-campaigns-empty')->text();
} else {
$htmlList .= "<ul>";
foreach ($linkedCampaigns as $linkedCampaign) {
$htmlList .= "<li>{$linkedCampaign}</li>";
}
$htmlList .= "</ul>";
}
$this->getOutput()->addHTML($htmlList);
}