PHP printf Examples

PHP printf - 30 examples found. These are the top rated real world PHP examples of printf extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
2
/**
 * This function outputs a 404 "Not Found" error message
 *
 * @since 1.6
 */
function genesis_404()
{
    echo genesis_html5() ? '<article class="entry">' : '<div class="post hentry">';
    printf('<h1 class="entry-title">%s</h1>', apply_filters('genesis_404_entry_title', __('Not found, error 404', 'genesis')));
    echo '<div class="entry-content">';
    if (genesis_html5()) {
        echo apply_filters('genesis_404_entry_content', '<p>' . sprintf(__('The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it by using the search form below.', 'genesis'), trailingslashit(home_url())) . '</p>');
        get_search_form();
    } else {
        ?>

			<p><?php 
        printf(__('The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it with the information below.', 'genesis'), trailingslashit(home_url()));
        ?>
</p>



	<?php 
    }
    if (!genesis_html5()) {
        genesis_sitemap('h4');
    } elseif (genesis_a11y('404-page')) {
        echo '<h2>' . __('Sitemap', 'genesis') . '</h2>';
        genesis_sitemap('h3');
    }
    echo '</div>';
    echo genesis_html5() ? '</article>' : '</div>';
}
    /**
     * Missing plugins warning.
     */
    public function missing_plugins_warning()
    {
        if ($this->missing) {
            $missing = '';
            $missing_slugs = array();
            $counter = 0;
            foreach ($this->missing as $title => $data) {
                $url = $data['url'];
                $missing_slugs[] = 'wpml-missing-' . sanitize_title_with_dashes($data['slug']);
                $counter++;
                if (sizeof($this->missing) == $counter) {
                    $sep = '';
                } elseif (sizeof($this->missing) - 1 == $counter) {
                    $sep = ' ' . __('and', 'wpml-translation-management') . ' ';
                } else {
                    $sep = ', ';
                }
                $missing .= '<a href="' . $url . '">' . $title . '</a>' . $sep;
            }
            $missing_slugs_classes = implode(' ', $missing_slugs);
            ?>
			<div class="message error wpml-admin-notice wpml-gfml-inactive <?php 
            echo $missing_slugs_classes;
            ?>
"><p><?php 
            printf(__('Gravity Forms Multilingual is enabled but not effective. It requires %s in order to work.', 'wpml-translation-management'), $missing);
            ?>
</p></div>
			<?php 
        }
    }
Example #3
1
/**
 * Echo message about minimum WordPress Version
 */
function _pb_minimum_wp()
{
    global $pb_minimum_wp;
    echo '<div id="message" class="error fade"><p>';
    printf(__('Pressbooks will not work with your version of WordPress. Pressbooks requires a dedicated install of WordPress Multi-Site, version %s or greater. Please upgrade WordPress if you would like to use Pressbooks.', 'pressbooks'), $pb_minimum_wp);
    echo '</p></div>';
}
Example #4
1
function commentlist($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    ?>
    <li id="li-comment-<?php 
    comment_ID();
    ?>
">
        <div id="comment-<?php 
    comment_ID();
    ?>
" <?php 
    comment_class('comment_item clear');
    ?>
>
            <div class="comment_meta">Posted on <?php 
    printf(__('%1$s'), get_comment_date());
    ?>
 by <?php 
    printf(__('<cite class="fn">%s</cite>'), get_comment_author_link());
    ?>
</div>
            <div class="comment_text"><?php 
    comment_text();
    ?>
</div>
        </div>
<?php 
}
Example #5
1
 function processPacket($packetData)
 {
     $packet = new dhcpPacket();
     $packet->parse($packetData);
     $processor = new dhcpRequestProcessor($this, $this->packetProcessor, $this->storage, $packet);
     if ($responsePacket = $processor->getResponse()) {
         $responseData = $responsePacket->build();
         $this->verbosity && (print "Sending response" . "\n");
         $ciaddr = $packet->getClientAddress();
         if ($ciaddr == '0.0.0.0') {
             $this->verbosity && (print "Switching to broadcast address...\n");
             $ciaddr = '255.255.255.255';
         }
         $this->verbosity && (print "Attempting to send response packet to " . $ciaddr . "\n");
         $numBytesSent = socket_sendto($this->socket, $responseData, strlen($responseData), 0, $ciaddr, 68);
         if ($numBytesSent === FALSE) {
             $this->verbosity && (print "send failed for specific address, broadcast.\n");
             $numBytesSent = socket_sendto($this->socket, $responseData, strlen($responseData), 0, "255.255.255.255", 68);
             $numBytesSent === FALSE && $this->verbosity && printf('socket send error: %s\\n', socket_strerror(socket_last_error($this->socket)));
         }
         $numBytesSent && $this->verbosity && (print "Response packet sent.\n");
     } else {
         $this->verbosity && (print "Packet ignored\n");
     }
 }
Example #6
1
function AddTextAdsExample(AdWordsUser $user, $adGroupId)
{
    // Get the service, which loads the required classes.
    $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
    $numAds = 5;
    $operations = array();
    for ($i = 0; $i < $numAds; $i++) {
        // Create text ad.
        $textAd = new TextAd();
        $textAd->headline = 'Cruise #' . uniqid();
        $textAd->description1 = 'Visit the Red Planet in style.';
        $textAd->description2 = 'Low-gravity fun for everyone!';
        $textAd->displayUrl = 'www.example.com';
        $textAd->finalUrls = array('http://www.example.com');
        // Create ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->adGroupId = $adGroupId;
        $adGroupAd->ad = $textAd;
        // Set additional settings (optional).
        $adGroupAd->status = 'PAUSED';
        // Create operation.
        $operation = new AdGroupAdOperation();
        $operation->operand = $adGroupAd;
        $operation->operator = 'ADD';
        $operations[] = $operation;
    }
    // Make the mutate request.
    $result = $adGroupAdService->mutate($operations);
    // Display results.
    foreach ($result->value as $adGroupAd) {
        printf("Text ad with headline '%s' and ID '%s' was added.\n", $adGroupAd->ad->headline, $adGroupAd->ad->id);
    }
}
 public static function tearDownAfterClass()
 {
     if (!self::$timing) {
         echo "\n";
         return;
     }
     $class = get_called_class();
     echo "Timing results : {$class}\n";
     $s = sprintf("%40s %6s %9s %9s %4s\n", 'name', 'count', 'total', 'avg', '% best');
     echo str_repeat('=', strlen($s)) . "\n";
     echo $s;
     echo str_repeat('-', strlen($s)) . "\n";
     array_walk(self::$timing, function (&$value, $key) {
         $value['avg'] = round($value['total'] / $value['count'] * 1000000, 3);
     });
     usort(self::$timing, function ($a, $b) {
         $at = $a['avg'];
         $bt = $b['avg'];
         return $at === $bt ? 0 : ($at < $bt ? -1 : 1);
     });
     $best = self::$timing[0]['avg'];
     foreach (self::$timing as $timing) {
         printf("%40s %6d %7.3fms %7.3fus %4.1f%%\n", $timing['name'], $timing['count'], round($timing['total'] * 1000, 3), $timing['avg'], round($timing['avg'] / $best * 100, 3));
     }
     echo str_repeat('-', strlen($s)) . "\n\n";
     printf("\nTiming compensated for avg overhead for: timeIt of %.3fus and startTimer/endTimer of %.3fus per invocation\n\n", self::$timeItOverhead * 1000000, self::$startEndOverhead * 1000000);
     parent::tearDownAfterClass();
 }
Example #8
0
 /**
  * Displays the server list
  */
 function rows($result)
 {
     global $fmdb;
     $num_rows = $fmdb->num_rows;
     $results = $fmdb->last_result;
     if (currentUserCan('build_server_configs', $_SESSION['module'])) {
         $bulk_actions_list = array(__('Upgrade'), __('Build Config'));
         $title_array[] = array('title' => '<input type="checkbox" class="tickall" onClick="toggle(this, \'server_list[]\')" />', 'class' => 'header-tiny');
     } else {
         $bulk_actions_list = null;
     }
     if (!$result) {
         printf('<p id="table_edits" class="noresult" name="servers">%s</p>', __('There are no firewall servers.'));
     } else {
         echo @buildBulkActionMenu($bulk_actions_list, 'server_id_list');
         $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'servers');
         $title_array[] = array('class' => 'header-tiny');
         $title_array = array_merge($title_array, array(__('Hostname'), __('Method'), __('Firewall Type'), __('Version'), __('Config File')));
         $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions');
         echo displayTableHeader($table_info, $title_array);
         for ($x = 0; $x < $num_rows; $x++) {
             $this->displayRow($results[$x]);
         }
         echo "</tbody>\n</table>\n";
     }
 }
 /**
  * Create Icinga Web 2's configuration directory
  *
  * USAGE:
  *
  *  icingacli setup config directory [options]
  *
  * OPTIONS:
  *
  *  --config=<directory>    Path to Icinga Web 2's configuration files [/etc/icingaweb2]
  *
  *  --mode=<mode>           The access mode to use [2770]
  *
  *  --group=<group>         Owner group for the configuration directory [icingaweb2]
  *
  * EXAMPLES:
  *
  *  icingacli setup config directory
  *
  *  icingacli setup config directory --mode=2775 --config=/opt/icingaweb2/etc
  */
 public function directoryAction()
 {
     $configDir = trim($this->params->get('config', $this->app->getConfigDir()));
     if (strlen($configDir) === 0) {
         $this->fail($this->translate('The argument --config expects a path to Icinga Web 2\'s configuration files'));
     }
     $group = trim($this->params->get('group', 'icingaweb2'));
     if (strlen($group) === 0) {
         $this->fail($this->translate('The argument --group expects a owner group for the configuration directory'));
     }
     $mode = trim($this->params->get('mode', '2770'));
     if (strlen($mode) === 0) {
         $this->fail($this->translate('The argument --mode expects an access mode for the configuration directory'));
     }
     if (!file_exists($configDir) && !@mkdir($configDir)) {
         $e = error_get_last();
         $this->fail(sprintf($this->translate('Can\'t create configuration directory %s: %s'), $configDir, $e['message']));
     }
     if (!@chmod($configDir, octdec($mode))) {
         $e = error_get_last();
         $this->fail(sprintf($this->translate('Can\'t change the mode of the configuration directory to %s: %s'), $mode, $e['message']));
     }
     if (!@chgrp($configDir, $group)) {
         $e = error_get_last();
         $this->fail(sprintf($this->translate('Can\'t change the group of %s to %s: %s'), $configDir, $group, $e['message']));
     }
     printf($this->translate('Successfully created configuration directory %s') . PHP_EOL, $configDir);
 }
Example #10
0
 function endElement($parser, $tagName)
 {
     if ($tagName == "ITEM") {
         if ($this->status) {
             print "[{$this->status}] ";
         }
         printf("<a href='%s' target='_content'>%s</a>", trim($this->link), htmlspecialchars(trim($this->title)));
         #printf("<p>%s</p>",
         #  htmlspecialchars(trim($this->description)));
         if ($this->date) {
             $date = trim($this->date);
             $date[10] = " ";
             # 2003-07-11T12:08:33+09:00
             # http://www.w3.org/TR/NOTE-datetime
             $zone = str_replace(":", "", substr($date, 19));
             $time = strtotime(substr($date, 0, 19) . $zone);
             $date = date("@ m-d [h:i a]", $time);
             printf(" %s<br />\n", htmlspecialchars(trim($date)));
         } else {
             printf("<br />\n");
         }
         $this->title = "";
         $this->description = "";
         $this->link = "";
         $this->date = "";
         $this->status = "";
         $this->insideitem = false;
     }
 }
    public function display()
    {
        $this->echoOptionHeader();
        ?>
<select name="<?php 
        echo $this->getID();
        ?>
"><?php 
        foreach ($this->settings['options'] as $value => $label) {
            // this is if we have option groupings
            if (is_array($label)) {
                ?>
<optgroup label="<?php 
                echo $value;
                ?>
"><?php 
                foreach ($label as $subValue => $subLabel) {
                    printf("<option value=\"%s\" %s>%s</option>", $subValue, selected($this->getValue(), $subValue, false), $subLabel);
                }
                ?>
</optgroup><?php 
                // this is for normal list of options
            } else {
                printf("<option value=\"%s\" %s>%s</option>", $value, selected($this->getValue(), $value, false), $label);
            }
        }
        ?>
</select><?php 
        $this->echoOptionFooter();
    }
Example #12
0
 /**
  * @brief Button to output
  **/
 function printBtn()
 {
     if ($this->nextUrl) {
         $url = $this->nextUrl;
         printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
     }
     if ($this->prevUrl) {
         $url = $this->prevUrl;
         printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
     }
     // Select Language
     if (!parent::isLangChange()) {
         $url = getUrl('', 'lcm', '1', 'sel_lang', Context::getLangType(), 'return_uri', Context::get('current_url'));
         printf('<a href="%s">%s</a><br>%s', $url, 'Language : ' . Context::getLang('select_lang'), "\n");
     } else {
         printf('<a href="%s">%s</a><br>%s', Context::get('return_uri'), Context::getLang('lang_return'), "\n");
     }
     if ($this->upperUrl) {
         $url = $this->upperUrl;
         printf('<btn href="%s" name="%s">%s', $url->url, $url->text, "\n");
     }
     if ($this->homeUrl) {
         $url = $this->homeUrl;
         printf('<a btn="%s" href="%s">%s</a><br>%s', $url->text, $url->url, $url->text, "\n");
     }
 }
/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $filePath the path of the file to download the report to
 */
function DownloadCriteriaReportExample(AdWordsUser $user, $filePath)
{
    // Load the service, so that the required classes are available.
    $user->LoadService('ReportDefinitionService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria', 'CriteriaType', 'Impressions', 'Clicks', 'Cost');
    // Optional: use predicate to filter out paused criteria.
    $selector->predicates[] = new Predicate('Status', 'NOT_IN', array('PAUSED'));
    // Create report definition.
    $reportDefinition = new ReportDefinition();
    $reportDefinition->selector = $selector;
    $reportDefinition->reportName = 'Criteria performance report #' . uniqid();
    $reportDefinition->dateRangeType = 'LAST_7_DAYS';
    $reportDefinition->reportType = 'CRITERIA_PERFORMANCE_REPORT';
    $reportDefinition->downloadFormat = 'CSV';
    // Exclude criteria that haven't recieved any impressions over the date range.
    $reportDefinition->includeZeroImpressions = false;
    // Set additional options.
    $options = array('version' => ADWORDS_VERSION);
    // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to
    //     suppress headers or summary rows.
    // $options['skipReportHeader'] = true;
    // $options['skipColumnHeader'] = true;
    // $options['skipReportSummary'] = true;
    // Optional: Set includeZeroImpressions to include zero impression rows in
    //     the report output.
    // $options['includeZeroImpressions'] = true;
    // Download report.
    ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
    printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath);
}
 /**
  * ScaffoldActionForm を生成する
  * 
  * @access public
  * @param $model string テーブル名
  * @param $modelDefine array モデル定義
  * @param $formDef array フォーム定義
  */
 function &generate($model, $modelDefine, $formDef)
 {
     $table_id = $this->_getTableId($model);
     $project_id = $this->ctl->getAppId();
     $dir = $this->ctl->getDirectory('action_form');
     if ($dir == null) {
         $dir = $this->ctl->getDirectory('app') . "/action_form/";
     }
     $file = "{$project_id}_{$table_id}_ActionForm.php";
     // Macro
     $macro = array();
     $macro['model'] = $model;
     $macro['modelName'] = $table_id;
     $macro['modelUName'] = strtoupper($table_id);
     $macro['project_id'] = $project_id;
     $macro['column_name_file'] = $this->_getColumnNamePath($table_id);
     $macro['form_define'] = $this->_getActionFormDefine($formDef);
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     $skelton = "skel.scaffold-actionform.php";
     // ファイル生成
     $path = "{$dir}{$file}";
     Ethna_Util::mkdir(dirname($path), 0755);
     if (file_exists($path)) {
         printf("file [%s] already exists -> skip\n", $path);
     } else {
         if ($this->_generateFile($skelton, $path, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $path);
         } else {
             printf("action script(s) successfully created [%s]\n", $path);
         }
     }
     $true = true;
     return $true;
 }
Example #15
0
function pla_rdelete($server, $dn)
{
    # We delete all children, not only the visible children in the tree
    $children = $server->getContainerContents($dn, null, 0, '(objectClass=*)', LDAP_DEREF_NEVER);
    if (!is_array($children) || count($children) == 0) {
        printf('<span style="white-space: nowrap;">%s %s...', _('Deleting'), $dn);
        if ($server->delete($dn)) {
            printf(' <span style="color:green">%s</span></span><br />', _('Success'));
            return true;
        } else {
            system_message(array('title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($dn)), 'body' => ldap_error_msg($server->getErrorMessage(null), $server->getErrorNum(null)), 'type' => 'error'));
        }
    } else {
        foreach ($children as $child_dn) {
            pla_rdelete($server, $child_dn);
        }
        printf('<span style="white-space: nowrap;">%s %s...', _('Deleting'), $dn);
        if ($server->delete($dn)) {
            printf(' <span style="color:green">%s</span></span><br />', _('Success'));
            return true;
        } else {
            system_message(array('title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($dn)), 'body' => ldap_error_msg($server->getErrorMessage(null), $server->getErrorNum(null)), 'type' => 'error'));
        }
    }
}
Example #16
0
 public function read(DOMElement $e) {
     $tn = end(explode(':',$e->tagName));
     switch($tn) {
       case 'function':
       
         foreach($e->childNodes as $cnn) {
             if (typeOf($cnn) == 'DOMElement') {
                 $cnt = end(explode(':',$cnn->tagName));
                 if ($cnt == 'from') {
                     $this->from[] = $cnn->nodeValue;
                 } elseif ($cnt == 'to') {
                     $this->to = $cnn->nodeValue;
                 } else {
                     printf("Warning: Didn't expect %s here\n", $cnn->nodeName); 
                 }
             }
         }
         
         printf(__astr("[\b{phprefactor}] Refactoring{%s} --> %s\n"), join(', ',$this->from), $this->to);
         break;
         
       default:
         printf("I don't know what to do with %s!\n", $tn);
         
     }
 }
Example #17
0
function sandbox_10_ping($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    extract($args, EXTR_SKIP);
    ?>
<li <?php 
    comment_class(sandbox_comment_class(false));
    ?>
 id="comment-<?php 
    comment_ID();
    ?>
">
	<div class="comment-author"><?php 
    printf(__('By %1$s on %2$s at %3$s', 'sandbox'), get_comment_author_link(), get_comment_date(), get_comment_time());
    edit_comment_link(__('Edit', 'sandbox'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>');
    ?>
</div>
<?php 
    if ($comment->comment_approved == '0') {
        _e('\\t\\t\\t\\t\\t<span class="unapproved">Your trackback is awaiting moderation.</span>\\n', 'sandbox');
    }
    ?>
	<?php 
    comment_text();
}
/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $campaignId the id of the campaign to modify
 * @param float $bidModifier the multiplier to set on the campaign
 */
function SetBidModifierExample(AdWordsUser $user, $campaignId, $bidModifier)
{
    // Get the CampaignCriterionService, also loads classes
    $campaignCriterionService = $user->GetService("CampaignCriterionService", ADWORDS_VERSION);
    // Create Mobile Platform. The ID can be found in the documentation.
    // https://developers.google.com/adwords/api/docs/appendix/platforms
    $mobile = new Platform();
    $mobile->id = 30001;
    // HighEndMobile = 30001
    // Create criterion with modified bid.
    $criterion = new CampaignCriterion();
    $criterion->campaignId = $campaignId;
    $criterion->criterion = $mobile;
    $criterion->bidModifier = $bidModifier;
    // Create SET operation.
    $operation = new CampaignCriterionOperation();
    $operation->operator = "SET";
    $operation->operand = $criterion;
    // Update campaign criteria.
    $results = $campaignCriterionService->mutate(array($operation));
    // Display campaign criteria.
    if (count($results->value)) {
        foreach ($results->value as $campaignCriterion) {
            printf("Campaign criterion with campaign ID '%s', criterion ID '%s', " . "and type '%s' was modified with bid %.2f.\n", $campaignCriterion->campaignId, $campaignCriterion->criterion->id, $campaignCriterion->criterion->type, $campaignCriterion->bidModifier);
        }
        return true;
    }
    print "No campaign criterias were modified.";
}
 /**
  * ScaffoldSmartyPlugin を生成する
  * 
  * @access public
  */
 function &generate()
 {
     $app_dir = $this->ctl->getDirectory('app');
     $app_path = ucfirst($this->ctl->getAppId()) . '_ScaffoldSmartyPlugin.php';
     $macro = array();
     $macro['project_id'] = $this->ctl->getAppId();
     $macro['file_path'] = $app_path;
     $user_macro = $this->_getUserMacro();
     $macro = array_merge($macro, $user_macro);
     // ファイル生成
     $filePath = "{$app_dir}/{$app_path}";
     Ethna_Util::mkdir(dirname($filePath), 0755);
     $skelton = "skel.scaffold-smartyPlugin.php";
     if (file_exists($filePath)) {
         printf("file [%s] already exists -> skip\n", $filePath);
     } else {
         if ($this->_generateFile($skelton, $filePath, $macro) == false) {
             printf("[warning] file creation failed [%s]\n", $filePath);
         } else {
             printf("action script(s) successfully created [%s]\n", $filePath);
         }
     }
     $true = true;
     return $true;
 }
Example #20
0
function ShowHeader($header)
{
    $len = strlen($header);
    $width = (int) ((80 - $len) / 2) + $len;
    $format = "\n%" . $width . "s\n\n";
    printf($format, $header);
}
/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function GetAccountAlertsExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $alertService = $user->GetService('AlertService', ADWORDS_VERSION);
    // Create alert query.
    $alertQuery = new AlertQuery();
    $alertQuery->clientSpec = 'ALL';
    $alertQuery->filterSpec = 'ALL';
    $alertQuery->types = array('ACCOUNT_BUDGET_BURN_RATE', 'ACCOUNT_BUDGET_ENDING', 'ACCOUNT_ON_TARGET', 'CAMPAIGN_ENDED', 'CAMPAIGN_ENDING', 'CREDIT_CARD_EXPIRING', 'DECLINED_PAYMENT', 'MANAGER_LINK_PENDING', 'MISSING_BANK_REFERENCE_NUMBER', 'PAYMENT_NOT_ENTERED', 'TV_ACCOUNT_BUDGET_ENDING', 'TV_ACCOUNT_ON_TARGET', 'TV_ZERO_DAILY_SPENDING_LIMIT', 'USER_INVITE_ACCEPTED', 'USER_INVITE_PENDING', 'ZERO_DAILY_SPENDING_LIMIT');
    $alertQuery->severities = array('GREEN', 'YELLOW', 'RED');
    $alertQuery->triggerTimeSpec = 'ALL_TIME';
    // Create selector.
    $selector = new AlertSelector();
    $selector->query = $alertQuery;
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $alertService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $alert) {
                printf("Alert of type '%s' and severity '%s' for account '%d' was " . "found.\n", $alert->alertType, $alert->alertSeverity, $alert->clientCustomerId);
            }
        } else {
            print "No alerts were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
Example #22
0
 /**
  * @param IComponent $component
  * @param string $name
  * @param IComponent $insertBefore
  * @return Container
  * @throws InvalidArgumentException
  */
 public function addComponent(IComponent $component, $name, $insertBefore = NULL)
 {
     if (!$component instanceof Form) {
         throw new InvalidArgumentException(printf('Form must be instance of Nette\\Forms\\Form, %s given.', get_class($component)));
     }
     return parent::addComponent($component, $name, $insertBefore);
 }
Example #23
0
  function Render()
  {
    global $currentUser;
    if (!$currentUser)
      return;

    if (!$currentUser->CanSubmitItems())
      return;

    echo "\n\n";
    echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";

    echo "  <h2>".$this->title."</h2>\n";
    echo "  <div class='content'>\n";

    $width = 15;

    $g = glob(POUET_CONTENT_LOCAL."avatars/*.gif");
    shuffle($g);
    $g = array_slice($g,0,$width * $width);

    echo "<ul id='avatargallery'>\n";
    foreach($g as $v)
      printf("  <li><img src='".POUET_CONTENT_URL."avatars/%s' alt='%s' title='%s'/></li>\n",basename($v),basename($v),basename($v));
    echo "</ul>\n";

    echo "  </div>\n";
    echo "</div>\n";
  }
Example #24
0
function main($argc, $argv)
{
    /****************************
     * Model specific variables *
     ****************************/
    $noNodes = 0;
    $noStreams = 0;
    $solve_as = APPROX;
    // or EXACT;
    $pop = 3.0;
    $think = 0.1;
    /************************
     * Initialize the model *
     ************************/
    /* Give model a name and initialize internal PDQ variables */
    PDQ_Init("Closed Queue");
    printf("**** %s ****:\n", $solve_as == EXACT ? "EXACT" : "APPROX");
    /* Define the workload and circuit type */
    $noStreams = PDQ_CreateClosed("w1", TERM, 1.0 * $pop, $think);
    /* Define the queueing center */
    $noNodes = PDQ_CreateNode("node", CEN, FCFS);
    /* Define service demand */
    PDQ_SetDemand("node", "w1", 0.1);
    /*******************
     * Solve the model *
     *******************/
    PDQ_Solve($solve_as);
    PDQ_Report();
}
Example #25
0
    /**
     * Render the content of the category dropdown
     *
     * @return HTML
     */
    public function render_content()
    {
        if (!empty($this->cats)) {
            ?>

            <label>
                <span class="customize-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
                <select <?php 
            $this->link();
            ?>
>
                    <?php 
            // Add an empty default option
            printf('<option value="0">' . esc_html('Disable Featured Posts', 'wedge') . '</option>');
            printf('<option value="0">--</option>');
            foreach ($this->cats as $cat) {
                printf('<option value="%s" %s>%s</option>', $cat->term_id, selected($this->value(), $cat->term_id, false), $cat->name);
            }
            ?>
            </select>
            </label>

        <?php 
        }
    }
/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $filePath the path of the file to download the report to
 */
function DownloadCriteriaReportWithAwqlExample(AdWordsUser $user, $filePath, $reportFormat)
{
    // Optional: Set clientCustomerId to get reports of your child accounts
    // $user->SetClientCustomerId('INSERT_CLIENT_CUSTOMER_ID_HERE');
    // Prepare a date range for the last week. Instead you can use 'LAST_7_DAYS'.
    $dateRange = sprintf('%d,%d', date('Ymd', strtotime('-7 day')), date('Ymd', strtotime('-1 day')));
    // Create report query.
    $reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, ' . 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT ' . 'WHERE Status IN [ENABLED, PAUSED] DURING ' . $dateRange;
    // Set additional options.
    $options = array('version' => ADWORDS_VERSION);
    // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to
    //     suppress headers or summary rows.
    // $options['skipReportHeader'] = true;
    // $options['skipColumnHeader'] = true;
    // $options['skipReportSummary'] = true;
    //
    // Optional: Set useRawEnumValues to return enum values instead of enum
    //     display values.
    // $options['useRawEnumValues'] = false;
    //
    // Optional: Set includeZeroImpressions to include zero impression rows in
    //     the report output.
    // $options['includeZeroImpressions'] = true;
    // Download report.
    $reportUtils = new ReportUtils();
    $reportUtils->DownloadReportWithAwql($reportQuery, $filePath, $user, $reportFormat, $options);
    printf("Report was downloaded to '%s'.\n", $filePath);
}
    /**
     * Render the content on the theme customizer page
     */
    public function render_content()
    {
        if (!empty($this->menus)) {
            ?>
                <label>
                    <span class="customize-menu-dropdown"><?php 
            echo esc_html($this->label);
            ?>
</span>
                    <select name="<?php 
            echo $this->id;
            ?>
" id="<?php 
            echo $this->id;
            ?>
">
                    <?php 
            foreach ($this->menus as $menu) {
                printf('<option value="%s" %s>%s</option>', $menu->term_id, selected($this->value(), $menu->term_id, false), $menu->name);
            }
            ?>
                    </select>
                </label>
            <?php 
        }
    }
/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $campaignId the ID of the campaign to get targeting criteria
 *     for
 */
function GetCampaignTargetingCriteriaExample(AdWordsUser $user, $campaignId)
{
    // Get the service, which loads the required classes.
    $campaignCriterionService = $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('Id', 'CriteriaType');
    // Create predicates.
    $selector->predicates[] = new Predicate('CampaignId', 'IN', array($campaignId));
    $selector->predicates[] = new Predicate('CriteriaType', 'IN', array('LANGUAGE', 'LOCATION', 'AGE_RANGE', 'CARRIER', 'OPERATING_SYSTEM_VERSION', 'GENDER', 'POLYGON', 'PROXIMITY', 'PLATFORM'));
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $campaignCriterionService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $campaignCriterion) {
                printf("Campaign targeting criterion with ID '%s' and type '%s' was " . "found.\n", $campaignCriterion->criterion->id, $campaignCriterion->criterion->CriterionType);
            }
        } else {
            print "No campaign targeting criteria were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $adGroupId the id of the ad group containing the ad
 * @param string $adId the ID of the ad
 */
function PauseAdExample(AdWordsUser $user, $adGroupId, $adId)
{
    // Get the service, which loads the required classes.
    $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
    // Create ad using an existing ID. Use the base class Ad instead of TextAd to
    // avoid having to set ad-specific fields.
    $ad = new Ad();
    $ad->id = $adId;
    // Create ad group ad.
    $adGroupAd = new AdGroupAd();
    $adGroupAd->adGroupId = $adGroupId;
    $adGroupAd->ad = $ad;
    // Update the status.
    $adGroupAd->status = 'PAUSED';
    // Create operation.
    $operation = new AdGroupAdOperation();
    $operation->operand = $adGroupAd;
    $operation->operator = 'SET';
    $operations = array($operation);
    // Make the mutate request.
    $result = $adGroupAdService->mutate($operations);
    // Display result.
    $adGroupAd = $result->value[0];
    printf("Ad of type '%s' with id '%s' has updated status '%s'.\n", $adGroupAd->ad->AdType, $adGroupAd->ad->id, $adGroupAd->status);
}
Example #30
0
 public function getContent()
 {
     //статическая часть контента
     echo '<div class="container">
 <!-- Example row of columns -->
 <div class="row">
     <div class="col-md-9">
     <div class="articles">';
     //динамическая часть
     //        $result = DB::query("SELECT id, title, description, date, img_src FROM  articles ORDER BY date DESC");
     //        $this->getMessageQueryErr($result, __FUNCTION__);
     $result = Articles::getArticles(0, 5);
     foreach ($result as $key => $value) {
         printf("<article class='media'>\n                        <h2 class='media-heading'>%s</h2>\n                        <p>%s</p>\n                        <div class='media-body'>\n                            <img class='img-responsive'  src='%s' >\n                            <p>%s </p>\n                            <p><a class='btn btn-default' href='?option=view&id_article=%s' role='button'>View details &raquo;</a></p>\n                        </div>\n                   </article>", $value[title], $value[date], $value[img_src], $value[description], $value[id]);
     }
     echo "</div>";
     echo "<button class='btn btn-primary btn-lg next'>Показать еще</button>";
     /*while ($content = $result->fetch_object()) {
                 printf("<article class='media'>
                             <h2 class='media-heading'>%s</h2>
                             <p>%s</p>
     
                             <div class='media-body'>
                                 <img class='img-responsive'  src='%s' >
                                 <p>%s </p>
                                 <p><a class='btn btn-default' href='?option=view&id_article=%s' role='button'>View details &raquo;</a></p>
                             </div>
                        </article>", $content->title,$content->date, $content->img_src, $content->description, $content->id);
             }*/
     //статическая часть
     echo "</div>";
 }