当前位置: 首页>>代码示例>>PHP>>正文


PHP Ad::fromName方法代码示例

本文整理汇总了PHP中Ad::fromName方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::fromName方法的具体用法?PHP Ad::fromName怎么用?PHP Ad::fromName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ad的用法示例。


在下文中一共展示了Ad::fromName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 function execute($par)
 {
     $this->getParams();
     $html = '';
     $error = false;
     $renderedAds = array();
     try {
         $campaign = new AdCampaign($this->campaignName);
         $ads = $campaign->getAds();
         foreach ($ads as $ad) {
             $renderedAds[] = Ad::fromName($ad['name'])->renderHtml();
         }
     } catch (MWException $e) {
         wfDebugLog('Promoter', $e->getMessage());
         $error = $e->getMessage();
     }
     if ($this->isPreview) {
         $this->setHeaders();
         if ($error) {
             $html = "Exception {$error}.";
         } else {
             $html = '<div id="adPreview clearfix">';
             foreach ($renderedAds as $ad) {
                 $html .= '<div class="col-sm-4">' . $ad . '</div>';
             }
             $html .= '</div>';
         }
         $this->getOutput()->addHTML($html);
     } else {
         $this->getOutput()->disable();
         $this->sendHeaders();
         print_r($renderedAds);
     }
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:34,代码来源:SpecialCampaignAdsLoader.php

示例2: execute

 function execute($par)
 {
     $this->getParams();
     $html = '';
     $chosenAd = null;
     $error = false;
     try {
         $adChooser = new AdChooser($this->campaignName, $this->anonymous);
         $chosenAd = $adChooser->chooseAd();
         $chosenAd = Ad::fromName($chosenAd['name']);
         $html = $chosenAd->renderHtml();
     } catch (MWException $e) {
         wfDebugLog('Promoter', $e->getMessage());
         $error = $e->getMessage();
     }
     if ($this->isPreview) {
         $this->setHeaders();
         $html = $error ? "Exception {$error}." : '<div id="adPreview" class="col-md-3 col-sm-4">' . $html . '</div>';
         $this->getOutput()->addHTML($html);
     } else {
         $this->getOutput()->disable();
         $this->sendHeaders();
         if ($error) {
             echo "mw.promoter.insertAd( false /* due to internal exception ({$error}) */ );";
         } else {
             echo $this->getJsData($chosenAd);
         }
     }
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:29,代码来源:SpecialAdRandom.php

示例3: renderGallery

 /**
  * Parser hook handler for {{#articletype}}
  *
  * @param Parser $parser : Parser instance available to render
  *  wikitext into html, or parser methods.
  *
  * @return string: HTML to insert in the page.
  */
 public static function renderGallery($input, array $args, Parser $parser, PPFrame $frame)
 {
     $parser->getOutput()->addModules('ext.promoter.gallery');
     $pageName = $parser->getTitle()->getText();
     try {
         $renderedAds = array();
         $adChooser = new AdChooser($pageName, !$parser->getUser()->isLoggedIn());
         $ads = $adChooser->getAds();
         foreach ($ads as $ad) {
             $renderedAds[] = Ad::fromName($ad['name'])->renderHtml();
         }
     } catch (AdCampaignExistenceException $e) {
         wfDebugLog('Promoter', $e->getMessage());
         //@todo i18n
         return '<span class="error">No campaign for this page</span>';
     } catch (MWException $e) {
         wfDebugLog('Promoter', $e->getMessage());
         return '<span class="error text-danger">An error occurred [' . $e->getMessage() . ']</span>';
     }
     $html = '<div class="promotion-gallery hidden hidden-print">' . '<h5 class="sr-only">זוהי גלריה המקדמת ערכים שונים באתר.</h5>' . '<div class="gallery-controls">' . '<span class="sr-only">בכל רגע מוצגות 3 ידיעות בגלריה. ניתן להציג ידיעה נוספת או לחזור לאחור באמצעות הכפתורים הבאים, או באמצעות מקשי החיצים כאשר הפוקוס הוא על הגלריה</span>' . '<a href="#" class="owl-prev"><span class="fa fa-chevron-right fa-lg" title="הקודם"></span><span class="sr-only">הצגת הידיעה הקודמת</span></a>' . '<a href="#" class="owl-next"><span class="fa fa-chevron-left fa-lg" title="הבא"></span><span class="sr-only">הצגת הידיעה הבאה</span></a>' . '</div>';
     if ($args['title']) {
         $html .= '<div class="header">' . $args['title'] . '</div>';
     }
     $html .= '<div class="owl-carousel clearfix" tabindex="0">' . implode('', $renderedAds) . '</div>' . '</div>';
     return $html;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:34,代码来源:PromoterGallery.php

示例4: formatRow

 /**
  * Generate the content of each table row (1 row = 1 ad)
  *
  * @param $row object: database row
  *
  * @return string HTML
  */
 function formatRow($row)
 {
     // Begin ad row
     $htmlOut = Xml::openElement('tr');
     if ($this->editable) {
         // Remove box
         $htmlOut .= Xml::tags('td', array('valign' => 'top'), Xml::check('removeAds[]', false, array('value' => $row->ad_name, 'onchange' => $this->onRemoveChange)));
     }
     // Preview
     $ad = Ad::fromName($row->ad_name);
     $htmlOut .= Xml::tags('td', array('valign' => 'top'), $ad->linkToPreview());
     // End ad row
     $htmlOut .= Xml::closeElement('tr');
     return $htmlOut;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:22,代码来源:AdPager.php

示例5: formatRow

 /**
  * Generate the content of each table row (1 row = 1 ad)
  */
 function formatRow($row)
 {
     // Begin ad row
     $htmlOut = Xml::openElement('tr');
     if ($this->editable) {
         // Add box
         $htmlOut .= Xml::tags('td', array('valign' => 'top'), Xml::check('addAds[]', '', array('value' => $row->ad_name)));
         // Weight select
         $htmlOut .= Xml::tags('td', array('valign' => 'top', 'class' => 'pr-weight'), Xml::listDropDown("weight[{$row->ad_id}]", Promoter::dropDownList($this->msg('promoter-weight')->text(), range(0, 100, 5)), '', '25', '', ''));
     }
     // Link and Preview
     $ad = Ad::fromName($row->ad_name);
     $htmlOut .= Xml::tags('td', array('valign' => 'top'), $ad->linkToPreview());
     // End ad row
     $htmlOut .= Xml::closeElement('tr');
     return $htmlOut;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:20,代码来源:PromoterPager.php

示例6: getHistoricalAd

 /**
  * FIXME: a little thin, it's just enough to get the job done
  *
  * @param $name
  * @param $ts
  * @return array|null ad settings as an associative array, with these properties:
  *    display_anon: 0/1 whether the ad is displayed to anonymous users
  *    display_account: 0/1 same, for logged-in users
  */
 static function getHistoricalAd($name, $ts)
 {
     $id = Ad::fromName($name)->getId();
     $dbr = PRDatabase::getDb();
     $newestLog = $dbr->selectRow("pr_ad_log", array("log_id" => "MAX(adlog_id)"), array("adlog_timestamp <= {$ts}", "adlog_ad_id = {$id}"), __METHOD__);
     if ($newestLog->log_id === null) {
         return null;
     }
     $row = $dbr->selectRow("pr_ad_log", array("display_anon" => "adlog_end_anon", "display_account" => "adlog_end_account"), array("adlog_id = {$newestLog->log_id}"), __METHOD__);
     $ad['display_anon'] = (int) $row->display_anon;
     $ad['display_account'] = (int) $row->display_account;
     return $ad;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:22,代码来源:Ad.php

示例7: processSaveAdAction

 protected function processSaveAdAction($formData)
 {
     $ad = Ad::fromName($this->adName);
     /* --- Ad settings --- */
     $ad->setAllocation(in_array('anonymous', $formData['display-to']), in_array('user', $formData['display-to']));
     $ad->setCaption($formData['ad-title']);
     $ad->setMainLink($formData['ad-link']);
     $ad->setBodyContent($formData['ad-body']);
     $ad->save($this->getUser());
     return null;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:11,代码来源:SpecialPromoterAds.php

示例8: removeAdFor

 /**
  * Remove an ad assignment from a campaign
  */
 static function removeAdFor($campaignName, $adName)
 {
     $dbw = PRDatabase::getDb();
     $dbw->begin();
     $campaignId = AdCampaign::getCampaignId($campaignName);
     $adId = Ad::fromName($adName)->getId();
     $dbw->delete('pr_adlinks', array('ad_id' => $adId, 'cmp_id' => $campaignId));
     $dbw->commit();
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:12,代码来源:AdCampaign.php

示例9: assignedAdsForm

 /**
  * Create form for managing ads assigned to a campaign
  */
 function assignedAdsForm($campaign)
 {
     $dbr = PRDatabase::getDb();
     $res = $dbr->select(array('campaigns' => 'pr_campaigns', 'adlinks' => 'pr_adlinks', 'ads' => 'pr_ads'), array('ads.ad_id', 'ads.ad_name', 'adlinks.adl_weight'), array('campaigns.cmp_name' => $campaign, 'campaigns.cmp_id = adlinks.cmp_id', 'adlinks.ad_id = ads.ad_id'), __METHOD__, array('ORDER BY' => 'campaigns.cmp_id'));
     // No ads found
     if ($dbr->numRows($res) < 1) {
         return '';
     }
     if ($this->editable) {
         $readonly = array();
     } else {
         $readonly = array('disabled' => 'disabled');
     }
     $weights = array();
     $ads = array();
     foreach ($res as $row) {
         $ads[] = $row;
         $weights[] = $row->adl_weight;
     }
     $isBalanced = count(array_unique($weights)) === 1;
     // Build Assigned ads HTML
     $htmlOut = Html::hidden('change', 'weight');
     $htmlOut .= Xml::fieldset($this->msg('promoter-assigned-ads')->text());
     // Equal weight ads
     $htmlOut .= Xml::openElement('tr');
     $htmlOut .= Xml::tags('td', array(), Xml::label($this->msg('promoter-balanced')->text(), 'balanced'));
     $htmlOut .= Xml::tags('td', array(), Xml::check('balanced', $isBalanced, array_replace($readonly, array('value' => $campaign, 'id' => 'balanced'))));
     $htmlOut .= Xml::closeElement('tr');
     $htmlOut .= Xml::openElement('table', array('cellpadding' => 9, 'width' => '100%'));
     if ($this->editable) {
         $htmlOut .= Xml::element('th', array('align' => 'left', 'width' => '5%'), $this->msg("promoter-remove")->text());
     }
     $htmlOut .= Xml::element('th', array('align' => 'left', 'width' => '5%', 'class' => 'pr-weight'), $this->msg('promoter-weight')->text());
     /*
     $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ),
     	$this->msg( 'promoter-bucket' )->text() );
     */
     $htmlOut .= Xml::element('th', array('align' => 'left', 'width' => '70%'), $this->msg('promoter-ads')->text());
     // Table rows
     foreach ($ads as $row) {
         $htmlOut .= Xml::openElement('tr');
         if ($this->editable) {
             // Remove
             $htmlOut .= Xml::tags('td', array('valign' => 'top'), Xml::check('removeAds[]', false, array('value' => $row->ad_name)));
         }
         // Weight
         $htmlOut .= Xml::tags('td', array('valign' => 'top', 'class' => 'pr-weight'), $this->weightDropDown("weight[{$row->ad_id}]", $row->adl_weight));
         // Ad
         $ad = Ad::fromName($row->ad_name);
         $htmlOut .= Xml::tags('td', array('valign' => 'top'), $ad->linkToPreview());
         $htmlOut .= Xml::closeElement('tr');
     }
     $htmlOut .= Xml::closeElement('table');
     $htmlOut .= Xml::closeElement('fieldset');
     return $htmlOut;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:59,代码来源:SpecialPromoter.php


注:本文中的Ad::fromName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。