static function findOptionByMainCategoryCode($key) { $tempRecords = self::findByMainCategoryCode($key); foreach ($tempRecords as $tempRecord) { fHTML::printOption($tempRecord->prepareDescription() . " [" . $tempRecord->prepareCategoryCode() . "]", $tempRecord->prepareId()); } }
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; }
static function findAllOption($default = null) { $tempRecords = self::findAll(); foreach ($tempRecords as $tempRecord) { fHTML::printOption($tempRecord->prepareName(), $tempRecord->prepareId(), $default); } }
static function findCurrentMonthOption($month, $year) { $tempRecords = self::findCurrentMonth($month, $year); foreach ($tempRecords as $tempRecord) { fHTML::printOption($tempRecord->prepareCountry() . " [" . $tempRecord->prepareExchange(2) . "]", $tempRecord->prepareId(), null); } }
static function findAllOption() { $tempRecords = self::findAll(); foreach ($tempRecords as $tempRecord) { fHTML::printOption($tempRecord->prepareDescription() . " [" . $tempRecord->prepareCategoryCode() . "]", $tempRecord->prepareCategoryCode()); } }
static function findAllOption() { $tempRecords = self::findAll(); foreach ($tempRecords as $tempRecord) { fHTML::printOption($tempRecord->prepareId(), $tempRecord->prepareId()); } }
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'); }
/** * 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>'; }
/** * 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; }
/** * 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)); }
/** * 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); }
"><?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';
if (fRequest::isPost()) { $user->populate(); if ($GLOBALS['ALLOW_HTTP_AUTH'] && $user->getUserId() != 1) { $password = '******'; } 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 = '******'; } else { $password = fCryptography::hashPassword($user->getPassword());
/** * 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); }
/** * 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); }
<?php fHTML::sendHeader(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->get('lang'); ?> " lang="<?php echo $this->get('lang'); ?> "> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="google-site-verification" content="vWXUlrnTL08knWQIGwumeb38qgYZlsrXc5VReJ1bUbs" /> <meta name="viewport" content="width=device-width, initial-scale=1"/> <meta property="og:title" content="Safecast" /> <meta property="og:type" content="website" /> <meta property="og:url" content="http://www.safecast.org" /> <meta property="og:image" content="http://www.safecast.org/images/logo.png" /> <meta property="og:site_name" content="Safecast" /> <meta property="fb:admins" content="595809984" /> <meta name="description" content="Safecast is a website that aggregates radioactivity data from throughout the world in order to provide real-time hyper-local information about the status of the Japanese nuclear crisis."> <meta name="keywords" content="japan,fukushima,radiation,nuclear,reactor,geiger,counter,RDTN,Safecast"> <title><?php echo $this->prepare('title'); echo strpos($this->get('title'), 'Safecast') === FALSE ? ' - Safecast' : ''; ?> </title> <base href="<?php
/** * Prints a sortable column header `a` tag * * The a tag will include the CSS class `'sortable_column'` and the * direction being sorted, `'asc'` or `'desc'`. * * {{{ * #!php * fCRUD::printSortableColumn('name', 'Name'); * }}} * * would create the following HTML based on the page context * * {{{ * #!html * <!-- If name is the current sort column in the asc direction, the output would be --> * <a href="?sort=name&dir=desc" class="sorted_column asc">Name</a> * * <!-- If name is not the current sort column, the output would be --> * <a href="?sort-name&dir=asc" class="sorted_column">Name</a> * }}} * * @param string $column The column to create the sortable header for * @param string $column_name This will override the humanized version of the column * @return void */ public static function printSortableColumn($column, $column_name = NULL) { if ($column_name === NULL) { $column_name = fGrammar::humanize($column); } if (self::$sort_column == $column) { $sort = $column; $direction = self::$sort_direction == 'asc' ? 'desc' : 'asc'; } else { $sort = $column; $direction = 'asc'; } $columns = array_merge(array('sort', 'dir'), array_keys(self::$search_values)); $values = array_merge(array($sort, $direction), array_values(self::$search_values)); $url = fHTML::encode(fURL::get() . fURL::replaceInQueryString($columns, $values)); $css_class = self::$sort_column == $column ? ' ' . self::$sort_direction : ''; $column_name = fHTML::prepare($column_name); echo '<a href="' . $url . '" class="sortable_column' . $css_class . '">' . $column_name . '</a>'; }
/** * Gets a value from ::get() and passes it through fHTML::prepare() * * @param string $key The key to get the value of * @param string $cast_to Cast the value to this data type * @param mixed $default_value If the parameter is not set in the `DELETE`/`PUT` post data, `$_POST` or `$_GET`, use this value instead * @return string The prepared value */ public static function prepare($key, $cast_to = NULL, $default_value = NULL) { return fHTML::prepare(self::get($key, $cast_to, $default_value)); }
<select name="over_under" class="span3"> <? foreach ($over_under_array as $value => $text) { fHTML::printOption($text, $value, $check->getOverUnder()); } ?> </select> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="check-visibility">Visibility<em>*</em></label> <div class="input"> <select name="visibility" class="span3"> <? foreach ($visibility_array as $value => $text) { fHTML::printOption($text, $value, $check->getVisibility()); } ?> </select> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="check-repeat_delay">Repeat Delay<em>*</em></label> <div class="input"> <?php $check_delay = (is_null($check->getRepeatDelay()) ? 30 : $check->encodeRepeatDelay()); ?> <input id="check-repeat_delay" class="span3" type="text" size="20" name="repeat_delay" value="<?=$check_delay; ?>" /> </div> </div><!-- /clearfix --> </fieldset> <fieldset>
</p> <p>Target : <?php echo Check::constructTarget($check); ?> </p> <p id="graphiteGraph"><?php echo Check::showGraph($check); ?> </p> <div class="row"> <div class="col-md-4"> <select id="graphiteDateRange" class="form-control"> <?php $dateRange = array('-12hours' => '12 Hours', '-1days' => '1 Day', '-3days' => '3 Days', '-7days' => '7 Days', '-14days' => '14 Days', '-30days' => '30 Days', '-60days' => '60 Days'); foreach ($dateRange as $value => $text) { fHTML::printOption($text, $value, '-3days'); } ?> </select> </div> <div class="col-md-4"> <input class="btn btn-primary" type="submit" value="Reload Graph" onClick="reloadGraphiteGraph()"/> </div> </div> </fieldset> </div> <?php } ?> </div> </div>
?> " /> </div> <div class="form-group"> <label for="dashboard-refresh_rate">Refresh Rate (in seconds)</label> <input id="dashboard-refresh_rate" class="form-control" type="text" size="30" name="refresh_rate" value="<?php echo $dashboard->getRefreshRate(); ?> " /> </div> <div class="form-group"> <label for="dashboard-group">Group</label> <select name="group_id" class="form-control"> <?php foreach (Group::findAll() as $group) { fHTML::printOption($group->getName(), $group->getGroupId(), $action == 'add' ? $filter_group_id : $dashboard->getGroupId()); } ?> </select> </div> <div class="actions"> <input class="btn btn-primary" type="submit" value="Save" /> <input class="btn btn-default" type="submit" name="action::delete" value="Delete" onclick="return confirm('Do you really want to delete this dashboard ?');" /> <a href="<?php echo Dashboard::makeUrl('view', $dashboard); ?> " class="btn btn-default">View</a> <a href="<?php echo Dashboard::makeURL('export', $dashboard); ?> " target="_blank" class="btn btn-default">Export</a>
/** * Changes a string into a URL-friendly string * * @param string $string The string to convert * @return void */ public static function makeFriendly($string) { $string = fHTML::decode(fUTF8::ascii($string)); $string = strtolower(trim($string)); $string = str_replace("'", '', $string); $string = preg_replace('#[^a-z0-9\\-]+#', '_', $string); $string = preg_replace('#_{2,}#', '_', $string); $string = preg_replace('#_-_#', '-', $string); return preg_replace('#(^_+|_+$)#D', '', $string); }
foreach ($subscriptions as $sub) { $user_id = $sub['user_id']; if (!in_array($user_id, $alt_ids) && $user_id != $id_user_session) { $user = new User($sub['user_id']); $recipients[] = array("mail" => $user->getEmail(), "name" => $user->getUsername()); } } if (!empty($recipients)) { // Send the mail to everybody notify_multiple_users($user_session, $recipients, $subject_mail, $content_mail); fMessaging::create('success', fURL::get(), 'The mail "' . $subject_mail . '" was successfully sent to all the users who subscribe to "' . $check->getName() . '"'); } else { fMessaging::create('error', fURL::get(), "Nobody subscribe to this check"); } } } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The check requested, ' . fHTML::encode($check_id) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } $page_num = fRequest::get('page', 'int', 1); $url_redirect = CheckResult::makeURL('list', $check) . "&page=" . $page_num; fURL::redirect($url_redirect); } else { $page_num = fRequest::get('page', 'int', 1); $check_results = CheckResult::findAll($check_id, false, $GLOBALS['PAGE_SIZE'], $page_num); include VIEW_PATH . '/list_check_results.php'; } }
$sort = fRequest::getValid('sort', array('name'), 'name'); $sortby = fRequest::getValid('sortby', array('asc', 'desc'), 'asc'); // --------------------------------- // if ('edit' == $action) { try { $dashboard = new Dashboard($dashboard_id); $graphs = Graph::findAll($dashboard_id); if (fRequest::isPost()) { $dashboard->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $dashboard->store(); fMessaging::create('affected', fURL::get(), $dashboard->getName()); fMessaging::create('success', fURL::get(), 'The Dashboard ' . $dashboard->getName() . ' was successfully updated'); } } catch (fNotFoundException $e) { fMessaging::create('error', Dashboard::makeUrl('list'), 'The Dashboard requested ' . fHTML::encode($dashboard_id) . 'could not be found'); fURL::redirect(Dashboard::makeUrl('list')); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_dashboard.php'; // --------------------------------- // } elseif ('add' == $action) { $dashboard = new Dashboard(); if (fRequest::isPost()) { try { $dashboard->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $dashboard->store(); fMessaging::create('affected', fURL::get(), $dashboard->getName()); fMessaging::create('success', fURL::get(), 'The Dashboard ' . $dashboard->getName() . ' was successfully created');
/** * Retrieves a value from the record and prepares it for output into html. * * Below are the transformations performed: * * - **varchar, char, text**: will run through fHTML::prepare(), if `TRUE` is passed the text will be run through fHTML::convertNewLinks() and fHTML::makeLinks() * - **boolean**: will return `'Yes'` or `'No'` * - **integer**: will add thousands/millions/etc. separators * - **float**: will add thousands/millions/etc. separators and takes 1 parameter to specify the number of decimal places * - **date, time, timestamp**: `format()` will be called on the fDate/fTime/fTimestamp object with the 1 parameter specified * - **objects**: the object will be converted to a string by `__toString()` or a `(string)` cast and then will be run through fHTML::prepare() * * @param string $column The name of the column to retrieve * @param mixed $formatting The formatting parameter, if applicable * @return string The formatted value for the column specified */ protected function prepare($column, $formatting = NULL) { $column_exists = array_key_exists($column, $this->values); $method_name = 'get' . fGrammar::camelize($column, TRUE); $method_exists = method_exists($this, $method_name); if (!$column_exists && !$method_exists) { throw new fProgrammerException('The column specified, %s, does not exist', $column); } if ($column_exists) { $class = get_class($this); $table = fORM::tablize($class); $schema = fORMSchema::retrieve($class); $column_info = $schema->getColumnInfo($table, $column); $column_type = $column_info['type']; // Ensure the programmer is calling the function properly if ($column_type == 'blob') { throw new fProgrammerException('The column specified, %s, can not be prepared because it is a blob column', $column); } if ($formatting !== NULL && in_array($column_type, array('integer', 'boolean'))) { throw new fProgrammerException('The column specified, %s, does not support any formatting options', $column); } // If the column doesn't exist, we are just pulling the // value from a get method, so treat it as text } else { $column_type = 'text'; } // Grab the value for empty value checking $value = $this->{$method_name}(); // Date/time objects if (is_object($value) && in_array($column_type, array('date', 'time', 'timestamp'))) { if ($formatting === NULL) { throw new fProgrammerException('The column specified, %s, requires one formatting parameter, a valid date() formatting string', $column); } return $value->format($formatting); } // Other objects if (is_object($value) && is_callable(array($value, '__toString'))) { $value = $value->__toString(); } elseif (is_object($value)) { $value = (string) $value; } // Ensure the value matches the data type specified to prevent mangling if ($column_type == 'boolean' && is_bool($value)) { return $value ? 'Yes' : 'No'; } if ($column_type == 'integer' && is_numeric($value)) { return number_format($value, 0, '', ','); } if ($column_type == 'float' && is_numeric($value)) { // If the user passed in a formatting value, use it if ($formatting !== NULL && is_numeric($formatting)) { $decimal_places = (int) $formatting; // If the column has a pre-defined number of decimal places, use that } elseif ($column_info['decimal_places'] !== NULL) { $decimal_places = $column_info['decimal_places']; // This figures out how many decimal places are part of the current value } else { $value_parts = explode('.', $value); $decimal_places = !isset($value_parts[1]) ? 0 : strlen($value_parts[1]); } return number_format($value, $decimal_places, '.', ','); } // Turn line-breaks into breaks for text fields and add links if ($formatting === TRUE && in_array($column_type, array('varchar', 'char', 'text'))) { return fHTML::makeLinks(fHTML::convertNewlines(fHTML::prepare($value))); } // Anything that has gotten to here is a string value, or is not the // proper data type for the column, so we just make sure it is marked // up properly for display in HTML return fHTML::prepare($value); }
<a href="<?php echo SITE_BASE; ?> /problem/<?php echo $this->record->getProblemId(); ?> "> <?php echo $this->record->getProblemId(); ?> </a> <a href="<?php echo SITE_BASE; ?> /submit?problem=<?php echo $this->record->getProblemId(); ?> " rel="tooltip" data-placement="right" title="重新提交" class="icon-repeat"></a> </li> <li>语言:<?php echo fHTML::encode($this->record->getLanguageName()); ?> </li> <li>提交时间:<?php echo $this->record->getSubmitDatetime(); ?> </li> </ul> </div> <?php include __DIR__ . '/../layout/footer.php';
<?php $title = $this->page_title; include __DIR__ . '/../layout/header.php'; ?> <div class="page-header"> <h1><?php echo fHTML::encode($title); ?> </h1> </div> <article><?php echo Markdown($this->page_content); ?> </article> <?php include __DIR__ . '/../layout/footer.php';
</div> </div><!-- /clearfix --> <div class="clearfix"> <label for="dashboard-description">Description<em>*</em></label> <div class="input"> <textarea class="span3" id="dashboard-description" name="description" rows="3"><?=$dashboard->encodeDescription(); ?></textarea> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="dashboard-columns">Columns<em>*</em></label> <div class="input"> <select name="columns" class="span3"> <? $columns = array('1' => '1', '2' => '2', '3' => '3'); foreach ($columns as $value => $text) { fHTML::printOption($text, $value, $dashboard->getColumns()); } ?> </select> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="dashboard-graph_width">Graph Width<em>*</em></label> <div class="input"> <input id="dashboard-graph_width" class="span3" type="text" size="30" name="graph_width" value="<?=$dashboard->encodeGraphWidth(); ?>" /> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="dashboard-graph_height">Graph Height<em>*</em></label> <div class="input"> <input id="dashboard-graph_height" class="span3" type="text" size="30" name="graph_height" value="<?=$dashboard->encodeGraphHeight(); ?>" />
/** * Prepares a file for output into HTML by returning filename or the web server path to the file * * @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 void */ public static function prepare($object, &$values, &$old_values, &$related_records, &$cache, $method_name, $parameters) { list($action, $column) = fORM::parseMethod($method_name); if (sizeof($parameters) > 1) { throw new fProgrammerException('The column specified, %s, does not accept more than one parameter', $column); } $translate_to_web_path = empty($parameters[0]) ? FALSE : TRUE; $value = $values[$column]; if ($value instanceof fFile) { $path = $translate_to_web_path ? $value->getPath(TRUE) : $value->getName(); } else { $path = NULL; } return fHTML::prepare($path); }
/** * Changes a string into a URL-friendly string * * @param string $string The string to convert * @param integer $max_length The maximum length of the friendly URL * @param string $delimiter The delimiter to use between words, defaults to `_` * @param string |$string * @param string |$delimiter * @return string The URL-friendly version of the string */ public static function makeFriendly($string, $max_length = NULL, $delimiter = NULL) { // This allows omitting the max length, but including a delimiter if ($max_length && !is_numeric($max_length)) { $delimiter = $max_length; $max_length = NULL; } $string = fHTML::decode(fUTF8::ascii($string)); $string = strtolower(trim($string)); $string = str_replace("'", '', $string); if (!strlen($delimiter)) { $delimiter = '_'; } $delimiter_replacement = strtr($delimiter, array('\\' => '\\\\', '$' => '\\$')); $delimiter_regex = preg_quote($delimiter, '#'); $string = preg_replace('#[^a-z0-9\\-_]+#', $delimiter_replacement, $string); $string = preg_replace('#' . $delimiter_regex . '{2,}#', $delimiter_replacement, $string); $string = preg_replace('#_-_#', '-', $string); $string = preg_replace('#(^' . $delimiter_regex . '+|' . $delimiter_regex . '+$)#D', '', $string); $length = strlen($string); if ($max_length && $length > $max_length) { $last_pos = strrpos($string, $delimiter, ($length - $max_length - 1) * -1); if ($last_pos < ceil($max_length / 2)) { $last_pos = $max_length; } $string = substr($string, 0, $last_pos); } return $string; }