本文整理汇总了PHP中alternator函数的典型用法代码示例。如果您正苦于以下问题:PHP alternator函数的具体用法?PHP alternator怎么用?PHP alternator使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了alternator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Index Function
*
* @return string
*/
public function index()
{
// get most recent 10 entries from DB
$this->_EE->db->select('entry_id, channel_id, name, comment_date');
$this->_EE->db->from('comments');
$this->_EE->db->order_by('comment_date DESC');
$this->_EE->db->limit(10);
$comments = $this->_EE->db->get();
// generate table HTML
$display = '';
if ($comments->num_rows() > 0) {
foreach ($comments->result() as $comment) {
$display .= '
<tr class="' . alternator('odd', 'even') . '">
<td><a href="' . BASE . AMP . '">' . $comment->name . '</a></td>
<td>' . date('m/d/Y', $comment->comment_date) . '</td>
</tr>';
}
} else {
$display = '<tr><td colspan="2"><center>No comments have been posted.</center></td></tr>';
}
return '
<table>
<thead><tr><th>Name</th><th>Comment Date</th></tr></thead>
<tbody>' . $display . '</tbody>
</table>
';
}
示例2: index
/**
* Index Function
*
* @return string
*/
public function index()
{
// get most recent 10 entries from DB
$this->_EE->db->select('entry_id, channel_id, title, entry_date');
$this->_EE->db->from('channel_titles');
$this->_EE->db->order_by('entry_date DESC');
$this->_EE->db->limit(10);
$entries = $this->_EE->db->get();
// generate table HTML
$display = '';
if ($entries->num_rows() > 0) {
foreach ($entries->result() as $entry) {
$display .= '
<tr class="' . alternator('odd', 'even') . '">
<td><a href="' . BASE . AMP . 'D=cp' . AMP . 'C=content_publish' . AMP . 'M=entry_form' . AMP . 'channel_id=' . $entry->channel_id . AMP . 'entry_id=' . $entry->entry_id . '">' . $entry->title . '</a></td>
<td>' . date('m/d/Y', $entry->entry_date) . '</td>
</tr>';
}
} else {
$display = '<tr><td colspan="2"><center>No entries have been created.</center></td></tr>';
}
return '
<table>
<thead><tr><th>Title</th><th>Entry Date</th></tr></thead>
<tbody>' . $display . '</tbody>
</table>
';
}
示例3: index
/**
* Index Function
*
* @return string
*/
public function index()
{
// get most recent 10 members from DB
$this->_EE->db->select('member_id, username, join_date');
$this->_EE->db->from('members');
$this->_EE->db->order_by('join_date DESC');
$this->_EE->db->limit(10);
$results = $this->_EE->db->get();
// generate table HTML
$display = '';
if ($results->num_rows() > 0) {
foreach ($results->result() as $row) {
$display .= '
<tr class="' . alternator('odd', 'even') . '">
<td><a href="' . BASE . AMP . 'D=cp' . AMP . 'C=myaccount' . AMP . 'id=' . $row->member_id . '">' . $row->username . '</a></td>
<td>' . date('n/j/Y', $row->join_date) . '</td>
</tr>';
}
} else {
$display = '<tr><td colspan="2"><center>No members have joined yet.</center></td></tr>';
}
return '
<table>
<thead><tr><th>Username</th><th>Join Date</th></tr></thead>
<tbody>' . $display . '</tbody>
</table>
';
}
示例4: foo
function foo($x, $k)
{
foreach ($x as $j) {
loop:
echo "{$j}: ";
echo $k;
echo "\n";
if (alternator()) {
goto loop;
}
echo "ok\n";
}
echo "done\n";
}
示例5: alternator
?>
</li>
<li class="<?php
echo alternator('even', '');
?>
">
<label for="captions">Captions</label>
<?php
echo form_dropdown('captions', array('true' => 'On', 'false' => 'Off'), $options['captions']);
?>
</li>
<li class="<?php
echo alternator('even', '');
?>
">
<label for="captions">Theme</label>
<?php
echo form_dropdown('theme', array('default' => 'Default', 'bar' => 'Bar', 'dark' => 'Dark', 'light' => 'Light'), $options['theme']);
?>
</li>
<li class="<?php
echo alternator('even', '');
?>
">
<label for="captions">Settings</label>
<?php
echo form_textarea('settings', $options['settings']);
?>
</li>
</fieldset>
</ul>
示例6: alternator
<li class="<?php
echo alternator('even', '');
?>
">
<label for="restricted_to[]"><?php
echo lang('nav:restricted_to');
?>
</label>
<?php
echo form_multiselect('restricted_to[]', array(0 => lang('global:select-any')) + $group_options, strpos($link->restricted_to, ",") ? explode(",", $link->restricted_to) : $link->restricted_to, 'size="' . (($count = count($group_options)) > 1 ? $count : 2) . '"');
?>
</li>
<li class="<?php
echo alternator('', 'even');
?>
">
<label for="class"><?php
echo lang('nav:class_label');
?>
</label>
<?php
echo form_input('class', $link->class);
?>
</li>
</ul>
<div class="buttons float-left padding-top">
<?php
$this->load->view('admin/partials/buttons', array('buttons' => array('save', 'cancel')));
示例7:
<th>
<div align="center">
Space
</div>
</th>
<th>
<div align="center">
Actions
</div>
</th>
</tr>
<?php
foreach($users->result() as $user)
{
?>
<tr <?=alternator('class="odd"', 'class="even"')?>>
<td>
<div align="center">
<input type="checkbox" id="check-<?php echo $user->id?>" name="users[]" value="<?php echo $user->id?>" />
<?php echo $user->id?>
</div>
</td>
<td><div align="center"><?php echo $user->id?></div></td>
<td><div align="center"><?php echo $user->username?></div></td>
<td><div align="center"><?php echo $user->email?></div></td>
<td><div align="center"><?php echo $this->functions->getFilesizePrefix($this->files_db->getFilesUseageSpace($user->id))?></div></td>
<td>
<div align="center">
<?php
if($user->status == 0 and $user->id != 1)
{
示例8: foreach
if ($panels['logs']) {
?>
<div id="debug-log" class="top" style="display: none;">
<h1>logs & msgs</h1>
<table cellspacing="0" cellpadding="0">
<tr align="left">
<th width="1%">#</th>
<th width="200">time</th>
<th width="100">level</th>
<th>message</th>
</tr>
<?php
foreach ((array) $logs as $id => $log) {
?>
<tr class="<?php
echo alternator('odd', 'even');
?>
">
<td><?php
echo $id + 1;
?>
</td>
<td><?php
echo $log[0];
?>
</td>
<td><?php
echo $log[1];
?>
</td>
<td><?php
示例9: foreach
</td>
</tr>
<tr>
<td colspan="2">
<table class="table-details" width="100%" border="0" cellpadding="0" cellspacing="0">
<thead>
<?php $thStyle = 'color: #35abee; font-weight: normal; background: #fbfbfb; border-bottom: 2px solid #d1d1d1; border-top: 2px solid #d1d1d1; text-align: left; padding: 20px; border-right: 1px solid #f0f0f0;'; ?>
<tr>
<th style="<?php echo $thStyle; ?>">Retailer</th>
<th style="<?php echo $thStyle; ?>">Price</th>
<th style="<?php echo $thStyle; ?>">+/-</th>
</tr>
</thead>
<tbody>
<?php foreach ($product['prices'] as $site => $priceDetails) : ?>
<?php $alt = alternator('odd', 'even'); ?>
<?php if ($site == 'average') : ?>
<?php $avgStyle = 'background: #fffbd2 !important; padding: 20px; border-right: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0;'; ?>
<tr>
<td style="<?php echo $avgStyle ?>"><?php echo ucfirst($site) ?></td>
<td style="<?php echo $avgStyle ?> color: #00b2c2; font-weight: bold;"><?php echo $priceDetails['priceStr'] ?></td>
<td style="<?php echo $avgStyle ?>"><?php echo $priceDetails['diffStr'] ?></td>
</tr>
<?php else : ?>
<tr>
<?php $tdStyle = 'padding: 20px; border-right: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0;'; ?>
<?php
if ($alt == 'even') {
示例10: alternator
</div>
<div class="BlueBox">
<h2>Society email address</h2>
<p><strong>Society email is not set up</strong></p>
<p>
If you have a society account with the university you can register it with The Yorker.
This makes it easy to send emails from the soc email address and optionally allows you to
see an unread email count on the [vip] homepage.
</p>
<p>Click register to set up your soc account.</p>
<input type="button" class="button" value="Register" />
</div>
<div class="<?php
echo alternator('blue', 'grey');
?>
_box">
<form>
<H2>Society email address</H2>
<P><strong>Society email set up as "The Yorker <soc25@york.ac.uk>"</strong></P>
<input type="button" class="button" value="Change" />
<input type="button" class="button" value="Remove" />
<P>
Unread mail counter:
<input type="radio" name="socUnreadCounter" value="enabled" checked="checked" /> Enabled
<input type="radio" name="socUnreadCounter" value="disabled" /> Disabled
</P>
<P>The unread mail counter allows you to see how many unread emails are in your soc email inbox from the [vip] homepage</P>
<input type="button" class="button" value="Save" />
示例11: lang
<h2><?php echo lang('themes.theme_label') . ' ' . lang('themes.options'); ?></h2>
<?php if ($options_array): ?>
<div class="padding-top">
<?php echo form_open('admin/themes/options/' . $slug, 'class="crud options-form"');?>
<?php echo form_hidden('slug', $slug); ?>
<ol>
<?php foreach($options_array as $option): ?>
<li id="<?php echo $option->slug; ?>" class="<?php echo alternator('even', ''); ?>">
<label for="<?php echo $option->slug; ?>"><?php echo $option->title; ?></label>
<div class="width-40 <?php echo 'type-' . $option->type; ?>">
<?php echo $controller->form_control($option); ?><br/>
<div class="clear-both text-small1" style="margin-left: 160px;"><?php echo $option->description; ?></div>
</div>
<br class="clear-both" />
</li>
<?php endforeach; ?>
</ol>
<div class="buttons float-left padding-top">
<?php $this->load->view('admin/partials/buttons', array('buttons' => array('re-index') )); ?>
</div>
<div class="buttons float-right padding-top">
<?php $this->load->view('admin/partials/buttons', array('buttons' => array('save', 'cancel') )); ?>
</div>
<?php echo form_close(); ?>
</div>
示例12: lang
<!-- Available Widgets Area -->
<table>
<tbody style="border-bottom: none">
<tr>
<!-- Available Widgets -->
<td valign="top" width="50%">
<span class="widget-instructions float-right spacer-right"><?php echo lang('widgets.instructions')?></span>
<h3><?php echo lang('widgets.available_title')?></h3>
<?php if ($available_widgets): ?>
<!-- Available Widget List -->
<ul id="available-widgets">
<?php foreach($available_widgets as $widget): ?>
<li id="widget-<?php echo $widget->slug; ?>" class="widget-box" style="<?php echo alternator('clear:both;', '', '', ''); ?>">
<h3><?php echo $widget->title; ?></h3>
<div class="widget-box-body">
<p class="description"><?php echo $widget->description; ?></p>
<p class="author"><?php echo lang('widgets.widget_author').': '.($widget->website ? anchor($widget->website, $widget->author, array('target'=>'_blank')) : $widget->author); ?>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p><?php echo lang('widgets.no_available_widgets'); ?></p>
<?php endif; ?>
</td>
示例13: excel
function excel($division = 5)
{
/** Include PHPExcel */
require_once 'PHPExcel.php';
$divisionname = $this->_divisionname($division);
// $cellval = trim(iconv("UTF-8","ISO-8859-1",$cell->getValue())," \t\n\r\0\x0B\xA0");
$this->load->helper('date');
$locale = 'da';
date_default_timezone_set('Europe/London');
$now = Date("H:i d-m-Y");
// Create a workbook
$objPHPExcel = new PHPExcel();
PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
$objPHPExcel->getProperties()->setCreator("KBHFF Medlemssystem");
$objPHPExcel->getProperties()->setLastModifiedBy("KBHFF Medlemssystem {$now}");
$objPHPExcel->getProperties()->setTitle(utf8_decode($divisionname) . ' medlemsliste');
$objPHPExcel->getProperties()->setSubject("Medlemsliste");
$objPHPExcel->getProperties()->setDescription('KBHFF ' . $divisionname . "medlemsliste udskrevet {$now}");
$objPHPExcel->getProperties()->setKeywords("KBHFF medlemsliste");
$objPHPExcel->getProperties()->setCategory("medlemsliste");
$objPHPExcel->getSheet(0);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle(substr($divisionname . ' ' . Date("H.i d-m-Y"), 0, 31));
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->getTabColor()->setRGB('33cc66');
// Creating a title
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->getStyle('A1:I1')->getFont()->setSize(13)->getColor()->setARGB(PHPExcel_Style_Color::COLOR_DARKGREEN);
$objWorksheet->setCellValueByColumnAndRow(0, 1, 'Medlem #');
$objWorksheet->setCellValueByColumnAndRow(1, 1, 'Fornavn');
$objWorksheet->setCellValueByColumnAndRow(2, 1, 'Mellemnavn');
$objWorksheet->setCellValueByColumnAndRow(3, 1, 'Efternavn');
$objWorksheet->setCellValueByColumnAndRow(4, 1, 'Email');
$objWorksheet->setCellValueByColumnAndRow(5, 1, 'Telefon');
$objWorksheet->setCellValueByColumnAndRow(6, 1, 'Oprettet');
$objWorksheet->setCellValueByColumnAndRow(7, 1, 'Aktiv');
$objWorksheet->setCellValueByColumnAndRow(8, 1, 'Note');
// Autoset widths
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->getColumnDimension('A')->setAutoSize(true);
$objWorksheet->getColumnDimension('B')->setAutoSize(true);
$objWorksheet->getColumnDimension('C')->setAutoSize(true);
$objWorksheet->getColumnDimension('D')->setAutoSize(true);
$objWorksheet->getColumnDimension('E')->setAutoSize(true);
$objWorksheet->getColumnDimension('F')->setAutoSize(true);
$objWorksheet->getColumnDimension('G')->setAutoSize(true);
$objWorksheet->getColumnDimension('H')->setAutoSize(true);
$objWorksheet->getColumnDimension('I')->setAutoSize(true);
if ($division > 0) {
$select = ', ff_division_members where ff_division_members.member = ff_persons.uid AND ff_division_members.division = ' . (int) $division;
}
$query = $this->db->query('SELECT uid,firstname, middlename, lastname, email, tel, created, active, remark FROM (ff_persons) left join ff_persons_info on (ff_persons.uid = ff_persons_info.puid) ' . $select . ' order by firstname');
$rowformat1 = array('font' => array('bold' => false), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'd9ffe2')));
$rowformat2 = array('font' => array('bold' => false));
$currentrow = 2;
foreach ($query->result() as $row) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow(0, $currentrow, "{$row->uid}")->setCellValueByColumnAndRow(1, $currentrow, "{$row->firstname}")->setCellValueByColumnAndRow(2, $currentrow, "{$row->middlename}")->setCellValueByColumnAndRow(3, $currentrow, "{$row->lastname}")->setCellValueByColumnAndRow(4, $currentrow, "{$row->email}")->setCellValueByColumnAndRow(5, $currentrow, "{$row->tel}")->setCellValueByColumnAndRow(6, $currentrow, "{$row->created}")->setCellValueByColumnAndRow(7, $currentrow, "{$row->active}")->setCellValueByColumnAndRow(8, $currentrow, "{$row->remark}");
$dynformat = alternator('rowformat1', 'rowformat2');
$format = ${$dynformat};
$objPHPExcel->getActiveSheet()->getStyle('A' . $currentrow . ':I' . $currentrow)->applyFromArray($format);
$currentrow++;
}
// Align
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
$objPHPExcel->getActiveSheet()->getStyle('F1:F' . $highestRow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('A1:A' . $highestRow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
// Set repeated headers
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
// Specify printing area
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$objPHPExcel->getActiveSheet()->getPageSetup()->setPrintArea('A1:' . $highestColumn . $highestRow);
// Redirect output to a clients web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="KBHFF medlemsliste ' . $divisionname . ' ' . $now . '.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// always modified
header('Cache-Control: cache, must-revalidate');
// HTTP/1.1
header('Pragma: public');
// HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
示例14: string_helper
public function string_helper()
{
$this->load->helper('string');
$this->htmlp(random_string('alnum', 16));
$this->htmlp(increment_string('file', '_'));
// "file_1"
$this->htmlp(increment_string('file', '-', 2));
// "file-2"
$this->htmlp(increment_string('file_4'));
// "file_5"
for ($i = 0; $i < 10; $i++) {
$this->htmlp(alternator('one', 'two', 'three', 'four', 'five'));
}
$string = "|repeat";
$this->htmlp(repeater($string, 30));
// DEPRECATED
$string = "http://example.com//index.php";
$this->htmlp(reduce_double_slashes($string));
// results in "http://example.com/index.php"
$string = "/this/that/theother/";
$this->htmlp(trim_slashes($string));
// results in this/that/theother
$string = "Fred, Bill,, Joe, Jimmy";
$string = reduce_multiples($string, ",");
//results in "Fred, Bill, Joe, Jimmy"
$this->htmlp($string);
$string = ",Fred, Bill,, Joe, Jimmy,";
$string = reduce_multiples($string, ", ", TRUE);
//results in "Fred, Bill, Joe, Jimmy"
$this->htmlp($string);
$string = "Joe's \"dinner\"";
$string = quotes_to_entities($string);
//results in "Joe's "dinner""
$this->htmlp($string);
$string = "Joe's \"dinner\"";
$string = strip_quotes($string);
//results in "Joes dinner"
$this->htmlp($string);
}
示例15: if
<?php if ( $gallery_images !== FALSE ): ?>
<?php foreach ( $gallery_images as $image ): ?>
<li>
<a href="<?php echo site_url() . 'admin/files/edit/' . $image->file_id; ?>" class="modal">
<?php echo img(array('src' => site_url() . 'files/thumb/' . $image->file_id, 'alt' => $image->name, 'title' => 'Title: ' . $image->name . ' -- Caption: ' . $image->description)); ?>
<?php echo form_hidden('action_to[]', $image->id); ?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<div class="clear-both"></div>
</li>
<?php endif; ?>
<li style="display: none;" class="images-placeholder <?php echo alternator('', 'even'); ?>">
<label for="gallery_images"><?php echo lang('galleries.preview_label'); ?></label>
<div class="clear-both"></div>
<ul id="gallery_images_list">
</ul>
<div class="clear-both"></div>
</li>
</ol>
</div>
<!-- Design tab -->
<div id="gallery-design">