本文整理汇总了PHP中fHTML类的典型用法代码示例。如果您正苦于以下问题:PHP fHTML类的具体用法?PHP fHTML怎么用?PHP fHTML使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fHTML类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findOptionByMainCategoryCode
static function findOptionByMainCategoryCode($key)
{
$tempRecords = self::findByMainCategoryCode($key);
foreach ($tempRecords as $tempRecord) {
fHTML::printOption($tempRecord->prepareDescription() . " [" . $tempRecord->prepareCategoryCode() . "]", $tempRecord->prepareId());
}
}
示例2: getRow
public function getRow($row)
{
$r = array();
$r[0] = $row;
// rank
$id = $text = $this->owners[$row - 1]['id'];
if (strlen($name = $this->owners[$row - 1]['name'])) {
$text .= ' ' . $name;
}
$id = fHTML::encode($id);
$text = fHTML::encode($text);
if (empty($id)) {
$r[1] = $text;
} else {
$r[1] = '<a href="' . SITE_BASE . "/status?owner={$id}\">{$text}</a>";
}
$n = count($this->headers);
for ($i = 2; $i < $n; $i++) {
if ($this->scores[$row - 1][$i - 2] == '-') {
$r[$i] = $this->scores[$row - 1][$i - 2];
} else {
if ($i < $n - 3) {
$r[$i] = '<a href="' . SITE_BASE . "/status?owner={$id}&problem={$this->headers[$i]}\">{$this->scores[$row - 1][$i - 2]}</a>";
} else {
if ($i < $n - 2) {
$r[$i] = '<a href="' . SITE_BASE . "/status?owner={$id}&verdict=1\">{$this->scores[$row - 1][$i - 2]}</a>";
} else {
$r[$i] = $this->scores[$row - 1][$i - 2];
}
}
}
}
return $r;
}
示例3: findAllOption
static function findAllOption($default = null)
{
$tempRecords = self::findAll();
foreach ($tempRecords as $tempRecord) {
fHTML::printOption($tempRecord->prepareName(), $tempRecord->prepareId(), $default);
}
}
示例4: findCurrentMonthOption
static function findCurrentMonthOption($month, $year)
{
$tempRecords = self::findCurrentMonth($month, $year);
foreach ($tempRecords as $tempRecord) {
fHTML::printOption($tempRecord->prepareCountry() . " [" . $tempRecord->prepareExchange(2) . "]", $tempRecord->prepareId(), null);
}
}
示例5: findAllOption
static function findAllOption()
{
$tempRecords = self::findAll();
foreach ($tempRecords as $tempRecord) {
fHTML::printOption($tempRecord->prepareDescription() . " [" . $tempRecord->prepareCategoryCode() . "]", $tempRecord->prepareCategoryCode());
}
}
示例6: findAllOption
static function findAllOption()
{
$tempRecords = self::findAll();
foreach ($tempRecords as $tempRecord) {
fHTML::printOption($tempRecord->prepareId(), $tempRecord->prepareId());
}
}
示例7: index
public function index()
{
$this->cache_control('private', 5);
if ($pid = fRequest::get('id', 'integer')) {
Util::redirect('/problem/' . $pid);
}
$view_any = User::can('view-any-problem');
$this->page = fRequest::get('page', 'integer', 1);
$this->title = trim(fRequest::get('title', 'string'));
$this->author = trim(fRequest::get('author', 'string'));
$this->problems = Problem::find($view_any, $this->page, $this->title, $this->author);
$this->page_url = SITE_BASE . '/problems?';
if (!empty($this->title)) {
$this->page_url .= 'title=' . fHTML::encode($this->title) . '&';
}
if (!empty($this->author)) {
$this->page_url .= 'author=' . fHTML::encode($this->author) . '&';
}
$this->page_url .= 'page=';
$this->page_records = $this->problems;
$this->nav_class = 'problems';
$this->render('problem/index');
}
示例8: printOption
/**
* Prints an `option` tag with the provided value, using the selected value to determine if the option should be marked as selected
*
* @param string $text The text to display in the option tag
* @param string $value The value for the option
* @param string $selected_value If the value is the same as this, the option will be marked as selected
* @return void
*/
public static function printOption($text, $value, $selected_value = NULL)
{
$selected = FALSE;
if ($value == $selected_value || is_array($selected_value) && in_array($value, $selected_value)) {
$selected = TRUE;
}
echo '<option value="' . fHTML::encode($value) . '"';
if ($selected) {
echo ' selected="selected"';
}
echo '>' . fHTML::prepare($text) . '</option>';
}
示例9: printPiece
/**
* Prints out a piece of a template
*
* @param string $template The name of the template to print
* @param string $piece The piece of the template to print
* @param array $data The data to replace the variables with
* @return void
*/
private static function printPiece($template, $name, $data)
{
if (!isset(self::$templates[$template]['pieces'][$name])) {
throw new fProgrammerException('The template piece, %s, was not specified when defining the %s template', $name, $template);
}
$piece = self::$templates[$template]['pieces'][$name];
preg_match_all('#\\{\\{ (\\w+)((?:\\|\\w+)+)? \\}\\}#', $piece, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$variable = $match[1];
$value = !isset($data[$variable]) ? NULL : $data[$variable];
if (isset($match[2])) {
$filters = array_slice(explode('|', $match[2]), 1);
foreach ($filters as $filter) {
if (!in_array($filter, self::$filters)) {
throw new fProgrammerException('The filter specified, %1$s, is invalid. Must be one of: %2$s.', $filter, join(', ', self::$filters));
}
if (!strlen($value)) {
continue;
}
if ($filter == 'inflect') {
$value = fGrammar::inflectOnQuantity($data['total_records'], $value);
} elseif ($filter == 'lower') {
$value = fUTF8::lower($value);
} elseif ($filter == 'url_encode') {
$value = urlencode($value);
} elseif ($filter == 'humanize') {
$value = fGrammar::humanize($value);
}
}
}
$piece = preg_replace('#' . preg_quote($match[0], '#') . '#', fHTML::encode($value), $piece, 1);
}
echo $piece;
}
示例10: prepare
/**
* Gets the value of an element and runs it through fHTML::prepare()
*
* @param string $element The element to get
* @param mixed $default_value The value to return if the element has not been set
* @return mixed The value of the element specified run through fHTML::prepare(), or the default value if it has not been set
*/
public function prepare($element, $default_value = NULL)
{
return fHTML::prepare($this->get($element, $default_value));
}
示例11: show
/**
* Retrieves a message, removes it from the session and prints it - will not print if no content
*
* The message will be printed in a `p` tag if it does not contain
* any block level HTML, otherwise it will be printed in a `div` tag.
*
* @param mixed $name The name or array of names of the message(s) to show, or `'*'` to show all
* @param string $recipient The intended recipient
* @param string $css_class Overrides using the `$name` as the CSS class when displaying the message - only used if a single `$name` is specified
* @return boolean If one or more messages was shown
*/
public static function show($name, $recipient = NULL, $css_class = NULL)
{
if ($recipient === NULL) {
$recipient = '{default}';
}
// Find all messages if * is specified
if (is_string($name) && $name == '*') {
fSession::open();
$prefix = __CLASS__ . '::' . $recipient . '::';
$keys = array_keys($_SESSION);
$name = array();
foreach ($keys as $key) {
if (strpos($key, $prefix) === 0) {
$name[] = substr($key, strlen($prefix));
}
}
}
// Handle showing multiple messages
if (is_array($name)) {
$shown = FALSE;
$names = $name;
foreach ($names as $name) {
$class = trim(self::$class . ' ' . $name);
$class = $css_class === NULL ? $class : $css_class;
$shown = fHTML::show(self::retrieve($name, $recipient), $class, TRUE) || $shown;
}
return $shown;
}
$class = self::$class . ' ' . $name;
$class = $css_class === NULL ? $class : $css_class;
// Handle a single message
return fHTML::show(self::retrieve($name, $recipient), $class, TRUE);
}
示例12:
"><?php
echo fHTML::prepare($v->getName());
?>
</h3>
<a href="#variables">[list]</a>
<?php
if (User::can('set-variable')) {
?>
<a href="?edit=<?php
echo fHTML::encode($v->getName());
?>
#set_variable">[edit]</a>
<a href="?remove=<?php
echo fHTML::encode($v->getName());
?>
#set_variable">[remove]</a>
<?php
}
?>
<pre><?php
echo fHTML::encode($v->getValue());
?>
</pre>
<?php
}
?>
</fieldset>
</form>
<?php
}
include __DIR__ . '/../layout/footer.php';
示例13: catch
if (fRequest::isPost()) {
$user->populate();
if ($GLOBALS['ALLOW_HTTP_AUTH'] && $user->getUserId() != 1) {
$password = 'basic_auth';
} else {
$password = fCryptography::hashPassword($user->getPassword());
$user->setPassword($password);
}
fRequest::validateCSRFToken(fRequest::get('token'));
$user->store();
fMessaging::create('affected', User::makeUrl('list'), $user->getUsername());
fMessaging::create('success', User::makeUrl('list'), 'The user ' . $user->getUsername() . ' was successfully updated');
fURL::redirect(User::makeUrl('list'));
}
} catch (fNotFoundException $e) {
fMessaging::create('error', User::makeUrl('list'), 'The user requested, ' . fHTML::encode($user_id) . ', could not be found');
fURL::redirect(User::makeUrl('list'));
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
include VIEW_PATH . '/add_edit_user.php';
// --------------------------------- //
} elseif ('add' == $action) {
$user = new User();
if (fRequest::isPost()) {
try {
$user->populate();
if ($GLOBALS['ALLOW_HTTP_AUTH']) {
$password = 'basic_auth';
} else {
$password = fCryptography::hashPassword($user->getPassword());
示例14: prepareMoneyColumn
/**
* Prepares a money column by calling fMoney::format()
*
* @internal
*
* @param fActiveRecord $object The fActiveRecord instance
* @param array &$values The current values
* @param array &$old_values The old values
* @param array &$related_records Any records related to this record
* @param array &$cache The cache array for the record
* @param string $method_name The method that was called
* @param array $parameters The parameters passed to the method
* @return string The formatted monetary value
*/
public static function prepareMoneyColumn($object, &$values, &$old_values, &$related_records, &$cache, $method_name, $parameters)
{
list($action, $column) = fORM::parseMethod($method_name);
if (empty($values[$column])) {
return $values[$column];
}
$value = $values[$column];
$remove_zero_fraction = FALSE;
if (count($parameters)) {
$remove_zero_fraction = $parameters[0];
}
if ($value instanceof fMoney) {
$value = $value->format($remove_zero_fraction);
}
return fHTML::prepare($value);
}
示例15: prepareNumberColumn
/**
* Prepares a number column by calling fNumber::format()
*
* @internal
*
* @param fActiveRecord $object The fActiveRecord instance
* @param array &$values The current values
* @param array &$old_values The old values
* @param array &$related_records Any records related to this record
* @param array &$cache The cache array for the record
* @param string $method_name The method that was called
* @param array $parameters The parameters passed to the method
* @return string The formatted link
*/
public static function prepareNumberColumn($object, &$values, &$old_values, &$related_records, &$cache, $method_name, $parameters)
{
list($action, $subject) = fORM::parseMethod($method_name);
$column = fGrammar::underscorize($subject);
$class = get_class($object);
$table = fORM::tablize($class);
$schema = fORMSchema::retrieve($class);
$column_info = $schema->getColumnInfo($table, $column);
$value = $values[$column];
if ($value instanceof fNumber) {
if ($column_info['type'] == 'float') {
$decimal_places = isset($parameters[0]) ? (int) $parameters[0] : $column_info['decimal_places'];
if ($decimal_places !== NULL) {
$value = $value->trunc($decimal_places)->format();
} else {
$value = $value->format();
}
} else {
$value = $value->format();
}
}
return fHTML::prepare($value);
}