Пример #1
0
 function test_reset_named_cycle()
 {
     $this->assertEqual("red", cycle("red", "green", "yellow", array("name" => "numbers")));
     $this->assertEqual("green", cycle("red", "green", "yellow", array("name" => "numbers")));
     reset_cycle("numbers");
     $this->assertEqual("red", cycle("red", "green", "yellow", array("name" => "numbers")));
 }
Пример #2
0
 public function testCyclerResets()
 {
     foreach (array('brown', 'brown', 'brown', 'brown') as $color) {
         $cycle = cycle('brown', 'green', 'red', 'green');
         $this->assertEquals($color, $cycle);
         cycler::reset_cycler();
     }
 }
Пример #3
0
<br>
			<?php 
echo $webboard_quizs->pagination();
?>
			<table class="list" id="weblinks-list">
				<tr>
					<th>หัวข้อ</th>
					<th>หมวดหมู่</th>
					<th width="130"></th>
				</tr>
				
				<?php 
foreach ($webboard_quizs as $webboard_quiz) {
    ?>
				<tr <?php 
    echo cycle();
    ?>
>
					<td><?php 
    echo $webboard_quiz->title;
    ?>
</td>
					<td><?php 
    echo lang_decode($webboard_quiz->category->name, 'th');
    ?>
</td>
					<td><a href="faqs/admin/faqs/form/<?php 
    echo $webboard_quiz->id;
    ?>
">ส่งไปยังรายการคำถาม</a></div>
					</td>
Пример #4
0
    /* Check method in select version. */
    if ($version) {
        $hasMethod = false;
        foreach ($moduleActions as $action => $actionLabel) {
            if (strpos($changelogs, ",{$moduleName}-{$actionLabel},") !== false) {
                $hasMethod = true;
                break;
            }
        }
        if (!$hasMethod) {
            continue;
        }
    }
    ?>
    <tr class='f-14px <?php 
    echo cycle('even, bg-gray');
    ?>
'>
      <th class='a-right w-150px'><?php 
    echo $this->lang->{$moduleName}->common;
    echo html::selectAll($moduleName, 'checkbox');
    ?>
</td>
      <td id='<?php 
    echo $moduleName;
    ?>
' class='pv-10px'>
        <?php 
    $i = 1;
    ?>
        <?php 
Пример #5
0
 /**
  * New function
  *
  * Description of new function
  *
  * @access  private
  * @param   none
  * @return  output
  */
 private function _message_view_format($messages = array())
 {
     $message_format = array();
     foreach ($messages as $key => $message) {
         $message_format[] = array('cycle' => cycle('', 'alt'), 'status' => $message['status'] == 1 ? 'read' : 'unread', 'mail_id' => $message['mail_id'], 'unread_img' => '<img src="/images/icons/newmail.png" ' . ($message['status'] == 1 ? 'style="visibility:hidden;" title="Mark as unread"' : 'title="Mark as read"') . ' />', 'subject' => $message['subject'], 'sender' => $message['username'], 'timestamp' => _datadate($message['date']));
     }
     return $message_format;
 }
Пример #6
0
        <td>Invalid filename</td>
      </tr>
      <?php 
    }
}
?>
      
      <?php 
if ($this->invalid_folders) {
    foreach (range(0, count($this->invalid_folders) - 1) as $i) {
        ?>
      <tr id="ef<?php 
        echo $i;
        ?>
" class="<?php 
        echo cycle('even', 'odd');
        ?>
">
        <td class="err"><?php 
        echo substr($this->invalid_folders[$i], 0, 105);
        ?>
</td>
        <td>Invalid folder</td>
      </tr>
      <?php 
    }
}
?>
      
      <?php 
if ($this->files) {
Пример #7
0
<?php

require 'Benchmark/Timer.php';
$timer = new Benchmark_Timer();
$mysql = new mysqli("localhost", "testuser", "testpass", "test");
$points = array(1000, 10000, 100000, 500000, 1000000);
foreach ($points as $val) {
    flush_mysql();
    $startmark = $val . ' start';
    $stopmark = $val . ' stop';
    $timer->setMarker($startmark);
    cycle($val);
    $timer->setMarker($stopmark);
    print $val . ': ' . $timer->timeElapsed($startmark, $stopmark) . "\n";
}
$mysql->close();
function flush_mysql()
{
    global $mysql;
    $mysql->query("DROP TABLE IF EXISTS `php_insert_bm`");
    $mysql->query("DROP TABLE IF EXISTS `php_insert_bm_coords`");
    $mysql->query("CREATE TABLE `php_insert_bm_coords`(\n    `id` int unsigned not null auto_increment,\n    `x` int not null,\n    `y` int not null,\n    PRIMARY KEY (`id`)\n  )");
    $mysql->query("CREATE TABLE `php_insert_bm`(\n    `id` int unsigned not null auto_increment,\n    `text` varchar(255) not null,\n    `count` int not null,\n    `coords_id` int unsigned not null,\n    PRIMARY KEY (`id`)\n  )");
    # empty init entries
    $mysql->query("INSERT php_insert_bm_coords(x,y) VALUES(0, 0)");
    $mysql->query("INSERT php_insert_bm(text, count, coords_id) VALUES('', 0, " . $mysql->insert_id . ')');
}
function cycle($c)
{
    global $mysql;
    for ($i = 0; $i < $c; $i++) {
Пример #8
0
?>
		</th>	
	</tr>
	<tr class="even form_users_list">
	<?php 
$i = 1;
//Counter
foreach ($users as $user) {
    ?>
		<?php 
    if ($i > $cols) {
        $i = 1;
        ?>
			</tr><tr class="<?php 
        if (function_exists('cycle')) {
            echo cycle("odd", "even");
        } else {
            echo "even";
        }
        ?>
">
		<?php 
    }
    ?>
		<td>
			<label><input <?php 
    if ($type) {
        ?>
onchange="usersField.add_to_list(<?php 
        echo $user['id'];
        ?>
Пример #9
0
    if ($staff == true) {
        ?>
						<div class="checkbox_holder">
							<input class="multi_select" id="select_all_topics" type="checkbox" name="select_all_topics" value="0" style="top: -14px;" />
						</div>
					<?php 
    }
    ?>
				</th>
			</tr>
		</thead>
		<?php 
    foreach ($topics as $topic) {
        ?>
			<tr class="<?php 
        echo cycle('', 'alt');
        ?>
 <?php 
        echo $topic['topic_type'];
        ?>
">
				<td class="selectable">
					<img src="/images/avatars/<?php 
        echo $topic['topic_author'];
        ?>
_headshot.png?1340621489" alt="" style="float:left; width:42px;height:42px;margin:-5px 5px 0 -6px;">
					<?php 
        if ($topic['topic_status'] == "locked") {
            echo '<img src="/images/icons/lock.png" alt="Locked:">';
        }
        ?>
Пример #10
0
 function run_query($q, $extra_field = null)
 {
     $q = $this->prepare_query($q, $extra_field);
     $m = $this->m;
     $db = DB::get_instance();
     $rows = $db->prepare_execute_fetch_all($q);
     $more_results = false;
     if (count($rows) == $this->limit + 1) {
         $more_results = true;
         array_pop($rows);
         # remove the extra row
     }
     cycle(array('bg1', 'bg0'));
     $this->stat = array();
     $descr = array();
     if ($this->query_restriction) {
         array_push($descr, "Condition: " . $this->query_restriction);
     }
     if ($this->interval) {
         array_push($descr, $this->make_interval_selection($this->interval));
     }
     $m->append(ax_p($descr));
     $table = ax_table_class('results');
     $table->append_child($this->make_table_header());
     $table->append_children($this->make_table_rows($rows));
     $table->append_child($this->make_table_footer());
     $m->append($table);
     $m->append($this->make_results_summary(count($rows), $more_results));
     $m->append(ax_p(array(ax_raw('Generated with query:<br /><textarea class="query">'), $q, ax_raw('</textarea>'))));
 }
    </caption>
    <tr class='colhead'>
      <th><?php 
echo $lang->group->module;
?>
</th>
      <th><?php 
echo $lang->group->method;
?>
</th>
    </tr>
    <?php 
foreach ($lang->resource as $moduleName => $moduleActions) {
    ?>
    <tr class='f-14px <?php 
    echo cycle('even, bg-yellow');
    ?>
'>
      <th class='a-right'><?php 
    echo $this->lang->{$moduleName}->common;
    echo html::selectAll($moduleName, 'checkbox');
    ?>
</td>
      <td id='<?php 
    echo $moduleName;
    ?>
' class='pv-10px'>
        <?php 
    $i = 1;
    ?>
        <?php 
Пример #12
0
    check_valid_list_to($to);
    $ashiato = \mixi\library\recent_ashiato();
    send_ashiato($from, $ashiato);
}
// Order the server to parse your most recent Mixi messages and send you a list of the last 10.
// Also parses the profiles of the users involved, so you can keep a copy in the db.
function refresh_mixi_messages($mail_connection, $message)
{
    $from = $message->from;
    $to = $message->to;
    check_valid_from($from);
    check_valid_list_to($to);
    $website = new Website();
    $website->cookies();
    \mixi\library\connect($website);
    $messages = \mixi\library\download_messages_and_profiles($website);
    $messages = \mixi\library\all_ashiato($website, 1);
    send($from, $messages);
}
// All errors are saved to the file define below.  Probably
// should move it to the CONSTANTS file...
function error($string)
{
    error_log($string, 3, "/tmp/FAILURE.txt");
}
// This is the cycle of the program.
// Login, Get list of messages,
// retrieve each message and
// then perform an action if necessary.
cycle();
Пример #13
0
{
    return array_map('intval', explode(' ', $line));
}
function remove_non_loop($numbers)
{
    // Remove numbers from array that only appear once (not part of the cycle)
    for ($i = 0, $c = count($numbers); $i < $c; $i++) {
        if (!in_array($numbers[$i], array_slice($numbers, $i + 1))) {
            // Set to false, rather than unset() so we don't have to worry about sparse indexing
            $numbers[$i] = false;
        }
    }
    // array_values to reindex the array
    return array_values(array_filter($numbers, function ($x) {
        return $x !== false;
    }));
}
function cycle($line)
{
    $numbers = remove_non_loop(parse($line));
    for ($i = 1; $i < count($numbers); $i++) {
        if ($numbers[0] == $numbers[$i]) {
            return implode(' ', array_slice($numbers, 0, $i));
        }
    }
    return '';
}
$filename = strpos($argv[0], 'Matthew\\Dropbox') !== false ? 'data.txt' : $argv[1];
foreach (file($filename) as $line) {
    echo cycle($line) . PHP_EOL;
}
Пример #14
0
function question_form2($question, $key)
{
    if ($question->type == "text") {
        ?>
		<li class="q text">
			<table width="100%">
				<tr><th>ข้อที่ <?php 
        echo ++$key;
        ?>
</th><td><?php 
        echo $question->question;
        ?>
</td></tr>
				<tr><th>คำตอบ</th><td><input type="text" name="answer[<?php 
        echo $question->id;
        ?>
]" value="" class="full"  /></td></tr>
			</table>
			<input type="hidden" name="type[]" value="text" />
			<input type="hidden" name="question_id[]" value="<?php 
        echo $question->id;
        ?>
" />
		</li>
<?php 
    }
    if ($question->type == "textarea") {
        ?>
		<li class="q textarea">
			<table width="100%">
				<tr><th>ข้อที่ <?php 
        echo ++$key;
        ?>
</th><td><?php 
        echo $question->question;
        ?>
</td></tr>
				<tr><th style="vertical-align:top; padding:5px 0 0;">คำตอบ</th><td><textarea name="answer[<?php 
        echo $question->id;
        ?>
]" class="full" ></textarea></td></tr>
			</table>
			<input type="hidden" name="type[]" value="textarea" />
			<input type="hidden" name="question_id[]" value="<?php 
        echo $question->id;
        ?>
" />
		</li>
<?php 
    }
    if ($question->type == "radio") {
        $answer = "คำตอบ";
        ?>
		<li class="q radio">
			<table width="100%">
				<tr><th>ข้อที่ <?php 
        echo ++$key;
        ?>
</th><td><?php 
        echo $question->question;
        ?>
</td></tr>
				<?php 
        foreach ($question->choice->order_by('id', 'asc')->get() as $choice) {
            ?>
				<tr>
					<th><?php 
            echo $answer;
            ?>
</th>
					<td>
						<input type="radio" name="answer[<?php 
            echo $question->id;
            ?>
]" value="<?php 
            echo $choice->id;
            ?>
" /> 
						<?php 
            echo $choice->name;
            ?>
					</td>
				</tr>
				<?php 
            $answer = '';
            ?>
				<?php 
        }
        ?>
				<?php 
        if ($question->other == 1) {
            ?>
				<tr>
					<th><?php 
            echo $answer;
            ?>
</th>
					<td>
						<input type="radio" name="answer[<?php 
            echo $question->id;
            ?>
]" value="other" /> อื่นๆ โปรดระบุ
						<input type="text" name="other[<?php 
            echo $question->id;
            ?>
]" value="" style="width:70%" />
					</td>
				</tr>
				<?php 
        }
        ?>
			</table>
			<input type="hidden" name="type[]" value="radio" />
			<input type="hidden" name="question_id[]" value="<?php 
        echo $question->id;
        ?>
" />
		</li>
<?php 
    }
    if ($question->type == "checkbox") {
        $answer = "คำตอบ";
        ?>
		<li class="q checkbox">
			<table width="100%">
				<tr><th>ข้อที่ <?php 
        echo ++$key;
        ?>
</th><td><?php 
        echo $question->question;
        ?>
</td></tr>
				<?php 
        foreach ($question->choice->order_by('id', 'asc')->get() as $choice) {
            ?>
				<tr>
					<th><?php 
            echo $answer;
            ?>
</th>
					<td>
						<input type="checkbox" name="answer[<?php 
            echo $question->id;
            ?>
][]" value="<?php 
            echo $choice->id;
            ?>
" /> 
						<?php 
            echo $choice->name;
            ?>
					</td>
				</tr>
				<?php 
            $answer = '';
            ?>
				<?php 
        }
        ?>
				<?php 
        if ($question->other == 1) {
            ?>
				<tr>
					<th><?php 
            echo $answer;
            ?>
</th>
					<td>
						<input type="checkbox" name="answer[<?php 
            echo $question->id;
            ?>
][]" value="other" /> อื่นๆ โปรดระบุ
						<input type="text" name="other[<?php 
            echo $question->id;
            ?>
]" value="" style="width:70%" />
					</td>
				</tr>
				<?php 
        }
        ?>
			</table>
			<input type="hidden" name="type[]" value="checkbox" />
			<input type="hidden" name="question_id[]" value="<?php 
        echo $question->id;
        ?>
" />
		</li>
<?php 
    }
    if ($question->type == "scale") {
        $optional = json_decode($question->optional, TRUE);
        ?>
		<li class="q scale">
			<table width="100%">
				<tr><th>ข้อที่ <?php 
        echo ++$key;
        ?>
</th><td><?php 
        echo $question->question;
        ?>
</td></tr>
				<tr>
					<td colspan="2">
						<table>
						<tr>
							<th></th>
							<td class="noborder"></td>
							<?php 
        for ($i = $question->min; $i <= $question->max; $i++) {
            ?>
							<td class="num noborder"><?php 
            echo $i ? $i : 0;
            ?>
</td>
							<?php 
        }
        ?>
							<td class="noborder"></td>
						</tr>
						<tr>
							<th>คำตอบ</th>
							<td><?php 
        echo $optional[0];
        ?>
</td>
							<?php 
        for ($i = $question->min; $i <= $question->max; $i++) {
            ?>
							<td><input class="num" type="radio" name="answer[<?php 
            echo $question->id;
            ?>
]" value="<?php 
            echo $i;
            ?>
" /></td>
							<?php 
        }
        ?>
							<td><?php 
        echo $optional[1];
        ?>
</td>
						</tr>
						</table>
					</td>
				</tr>
		
				

			</table>
			<input type="hidden" name="type[]" value="scale" />
			<input type="hidden" name="question_id[]" value="<?php 
        echo $question->id;
        ?>
" />
		</li>
<?php 
    }
    if ($question->type == "grid") {
        $optional = json_decode($question->optional, TRUE);
        ?>
		<li class="q grid">
			<table width="100%">
				<tr><th>ข้อที่ <?php 
        echo ++$key;
        ?>
</th><td><?php 
        echo $question->question;
        ?>
</td></tr>
				<tr>
					<th></th>
					<td>
						<table>
						<tr>
							<td class="noborder"></td>
							<?php 
        for ($i = 1; $i <= $question->range; $i++) {
            ?>
							<td style="background:#EEE; width:80px;"><?php 
            echo @$optional[$i - 1] ? $optional[$i - 1] : $i;
            ?>
</td>
							<?php 
        }
        ?>
						</tr>
						<?php 
        foreach ($question->choice->order_by('id', 'asc')->get() as $key => $choice) {
            ?>
						<tr <?php 
            echo cycle();
            ?>
>
							<td style="text-align:left;"><?php 
            echo ++$key . '. ' . $choice->name;
            ?>
</td>
							<?php 
            for ($i = $question->range; $i >= 1; $i--) {
                ?>
<td><input type="radio" name="answer[<?php 
                echo $question->id;
                ?>
][<?php 
                echo $choice->id;
                ?>
]" value="<?php 
                echo $i;
                ?>
" /></td><?php 
            }
            ?>
						</tr>
						<?php 
        }
        ?>
						</table>
					</td>
				</tr>
			</table>
			<input type="hidden" name="type[]" value="grid" />
			<input type="hidden" name="question_id[]" value="<?php 
        echo $question->id;
        ?>
" />
		</li>
<?php 
    }
}