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; }
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'); }
/** * Gets the value of an element and runs it through fHTML::encode() * * @param string $element The element to get - array elements can be accessed via `[sub-key]` syntax, and thus `[` and `]` can not be used in element names * @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::encode(), or the default value if it has not been set */ public function encode($element, $default_value = NULL) { return fHTML::encode($this->get($element, $default_value)); }
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title><?php echo fHTML::encode($title . TITLE_SUFFIX); ?> </title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php if (isset($meta_description)) { ?> <meta name="description" content="<?php echo $meta_description; ?> "> <?php } ?> <?php if (isset($meta_author)) { ?> <meta name="author" content="<?php echo $meta_author; ?> "> <?php } ?> <link href="<?php echo ASSET_CSS;
<?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';
/** * Retrieves a value from the record and prepares it for output into an HTML form element. * * Below are the transformations performed: * * - **varchar, char, text**: will run through fHTML::encode(), if `TRUE` is passed the text will be run through fHTML::convertNewLinks() and fHTML::makeLinks() * - **float**: 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::encode() * - **all other data types**: the value will be run through fHTML::encode() * * @param string $column The name of the column to retrieve * @param string $formatting The formatting string * @return string The encoded value for the column specified */ protected function encode($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); $schema = fORMSchema::retrieve($class); $table = fORM::tablize($class); $column_type = $schema->getColumnInfo($table, $column, 'type'); // Ensure the programmer is calling the function properly if ($column_type == 'blob') { throw new fProgrammerException('The column specified, %s, does not support forming because it is a blob column', $column); } if ($formatting !== NULL && in_array($column_type, array('boolean', 'integer'))) { 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); } $value = $value->format($formatting); } // Other objects if (is_object($value) && is_callable(array($value, '__toString'))) { $value = $value->__toString(); } elseif (is_object($value)) { $value = (string) $value; } // Make sure we don't mangle a non-float value if ($column_type == 'float' && is_numeric($value)) { $column_decimal_places = $schema->getColumnInfo($table, $column, 'decimal_places'); // 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_decimal_places !== NULL) { $decimal_places = $column_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::encode($value))); } // Anything that has gotten to here is a string value or is not the proper data type for the column that contains it return fHTML::encode($value); }
/** * Gets a value from ::get() and passes it through fHTML::encode() * * @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 encoded value */ public static function encode($key, $cast_to = NULL, $default_value = NULL) { return fHTML::encode(self::get($key, $cast_to, $default_value)); }
/** * 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>'; }
"><?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';
} include VIEW_PATH . '/delete.php'; // --------------------------------- // } elseif ('edit' == $action) { try { $setting = new Setting(array('name' => $setting_name, 'owner_id' => $owner_id)); if (fRequest::isPost()) { $setting->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $setting->store(); fMessaging::create('affected', fURL::get(), $setting->getFriendlyName()); fMessaging::create('success', fURL::get(), 'The setting ' . $setting->getFriendlyName() . ' was successfully updated'); fURL::redirect(Setting::makeURL('list', $setting_type, NULL, $owner_id)); } } catch (fNotFoundException $e) { fMessaging::create('error', fURL::get(), 'The Setting requested, ' . fHTML::encode($setting_name) . ', could not be found'); fURL::redirect(Setting::makeUrl('list')); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_setting.php'; // --------------------------------- // } elseif ('add' == $action) { $setting = new Setting(); if ('user' == $setting_type) { $list_plugin_settings = $plugin_user_settings; } else { $list_plugin_settings = $plugin_settings; } if (!array_key_exists($setting_name, $list_plugin_settings)) { $setting_name = '';
<?php include '../inc/init.php'; include '../inc/flourishDB.php'; header('Content-type: application/json; charset=utf-8'); $readings = fRecordSet::build('Reading', array('is_verified=' => 1, 'reading_date>' => array(new fDate('-2 days'))), NULL, 100, 0); echo '{"results":['; $datastreams = ""; $jsonData = ""; foreach ($readings as $reading) { $user = $reading->createUser(); $unit = $reading->createUnit(); $datastreams .= '{"title": "' . $user->getFirstName() . ' ' . $user->getLastName() . '",' . '"title_jp": "",' . '"description": "Equipment used: ' . rtrim(fHTML::encode($reading->getEquipment())) . '",' . '"source": "rdtn.org",' . '"creator": "rdtn.org",' . '"feed": "http://www.rdtn.org/feeds/readings/' . $reading->getReadingId() . '.json",' . '"location": {"lon":' . $reading->getLng() . ', "lat":' . $reading->getLat() . ', "name": ""},' . '"id":' . $reading->getReadingId() . ',' . '"datastreams": ['; $success = false; //foreach($stationdatas as $stationdata){ //$sa = $stationdata->getSa(); //if($sa!=-888 && $sa!=-999){ $datastreams .= '{"at": "' . $reading->getReadingDate() . '",' . '"max_value": "' . $reading->getReadingValue() . '",' . '"min_value": "' . $reading->getReadingValue() . '",' . '"current_value": "' . $reading->getReadingValue() . '",' . '"id": "' . $reading->getReadingId() . '",' . '"unit": {"type": "' . $unit->getUnitType() . '","label": "' . $unit->getUnitLabel() . '","symbol": "' . $unit->getUnitSymbol() . '"}}'; $success = true; // break; //} //} if ($success) { //close and append $datastreams .= ']},'; $jsonData .= $datastreams; } $datastreams = ""; } echo rtrim($jsonData, ','); echo '], "itemsPerPage": ' . $readings->count() . ', "startIndex": 0, "totalResults": ' . $readings->count(TRUE) . '}';
// --------------------------------- // } elseif ('edit' == $action) { if ($group_id == $GLOBALS['DEFAULT_GROUP_ID']) { fURL::redirect(Group::makeUrl('list')); } else { try { $group = new Group($group_id); if (fRequest::isPost()) { $group->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $group->store(); fMessaging::create('success', "/" . Group::makeURL("list"), 'The Group ' . $group->getName() . ' was successfully updated'); fURL::redirect(Group::makeUrl('list')); } } catch (fNotFoundException $e) { fMessaging::create('error', "/" . Group::makeUrl('list'), 'The Group requested, ' . fHTML::encode($group_id) . ', could not be found'); fURL::redirect(Group::makeUrl('list')); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_group.php'; } // --------------------------------- // } elseif ('add' == $action) { $group = new Group(); if (fRequest::isPost()) { try { $group->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $group->store(); $group_url = fURL::redirect(Group::makeUrl('list'));
} elseif ('edit' == $action) { try { $subscription = new Subscription($subscription_id); $check = new Check($subscription->getCheck_Id()); if (fRequest::isPost()) { $subscription->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $subscription->store(); fMessaging::create('affected', fURL::get(), $check->getName()); fMessaging::create('success', fURL::get(), 'The subscription to check ' . $check->getName(). ' was successfully updated'); //fURL::redirect($manage_url); } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The subscription requested ' . fHTML::encode($check_id) . ' could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_subscription.php'; // --------------------------------- // } elseif ('add' == $action) { $subscription = new Subscription(); //Load details of the check we are going to subscribe to $check = new Check($check_id); if (fRequest::isPost()) {
} ?> </td> <?php } ?> <td><?php echo $r->getTimeCost(); ?> </td> <td><?php echo $r->getMemoryCost(); ?> </td> <td><?php echo fHTML::encode($r->getLanguageName()); ?> </td> <td><?php echo $r->getSubmitDatetime(); ?> </td> </tr> <?php } ?> </tbody> </table> <?php $meta_refresh = Variable::getInteger('status-refresh', 30); include __DIR__ . '/../layout/footer.php';
<?php $title = $this->problem->getTitle(); include __DIR__ . '/../layout/header.php'; ?> <div class="page-header"> <h1><?php echo $this->problem->getId(); ?> . <?php echo fHTML::encode($this->problem->getTitle()); ?> </h1> </div> <div class="row"> <article class="span9"><?php echo Markdown($this->problem->getDescription()); ?> </article> <aside class="span3"> <div class="well"> <a class="btn btn-primary btn-large" href="<?php echo SITE_BASE; ?> /submit?problem=<?php echo $this->problem->getId(); ?> ">提交此题</a> </div> </aside> </div>
$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');
<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';
/** * @dataProvider encodeProvider */ public function testEncode($input, $output) { $this->assertEquals($output, fHTML::encode($input)); }
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());
fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php'; // --------------------------------- // } elseif ('edit' == $action) { try { $check = new Check($check_id); if (fRequest::isPost()) { $check->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $check->store(); fMessaging::create('affected', fURL::get(), $check->getName()); fMessaging::create('success', fURL::get(), 'The check ' . $check->getName() . ' was successfully updated'); } } catch (fNotFoundException $e) { fMessaging::create('error', fURL::get(), 'The check requested, ' . fHTML::encode($check_id) . ', could not be found'); fURL::redirect($check_list_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit.php'; // --------------------------------- // } elseif ('add' == $action) { $check = new Check(); if (fRequest::isPost()) { try { $check->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $check->store(); fMessaging::create('affected', fURL::get(), $check->getName()); fMessaging::create('success', fURL::get(), 'The check ' . $check->getName() . ' was successfully created');
/** * 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; }
// --------------------------------- // } elseif ('edit' == $action) { try { $subscription = new Subscription($subscription_id); $check = new Check($subscription->getCheckId()); $check_id = $subscription->getCheckId(); if (fRequest::isPost()) { $subscription->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $subscription->store(); fMessaging::create('affected', fURL::get(), $check->getName()); fMessaging::create('success', fURL::get(), 'The subscription to check ' . $check->getName() . ' was successfully updated'); //fURL::redirect($manage_url); } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The subscription requested ' . fHTML::encode($check_id) . ' could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_subscription.php'; // --------------------------------- // } elseif ('add' == $action) { $subscription = new Subscription(); //Load details of the check we are going to subscribe to $check = new Check($check_id); if (fRequest::isPost()) { try { $subscription->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $subscription->store();
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'; } }
<?php } ?> </td> <td><a href="<?php echo SITE_BASE; ?> /problem/<?php echo $p->getId(); ?> "><?php echo fHTML::encode($p->getTitle()); ?> </a></td> <td><?php echo fHTML::encode($p->getAuthor()); ?> </td> <td><?php echo $p->getRatio(); ?> % (<?php echo $p->getAcceptCount(); ?> /<?php echo $p->getSubmitCount(); ?> )</td> <td><a href="<?php echo SITE_BASE; ?>
/** * 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>'; }
} include VIEW_PATH . '/delete.php'; // --------------------------------- // } elseif ('edit' == $action) { try { $line = new Line($line_id); $graph = new Graph($line->getGraphId()); if (fRequest::isPost()) { $line->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $line->store(); fMessaging::create('affected', fURL::get(), $graph->getName()); fMessaging::create('success', fURL::getWithQueryString(), 'The Line ' . $line->getAlias() . ' was successfully updated'); } } catch (fNotFoundException $e) { fMessaging::create('error', Graph::makeUrl('edit', $graph), 'The Line requested, ' . fHTML::encode($line_id) . ', could not be found'); fURL::redirect(Graph::makeUrl('edit', $graph)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_line.php'; // --------------------------------- // } elseif ('add' == $action) { $line = new Line(); $graph = new Graph($graph_id); if (fRequest::isPost()) { try { $line->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $line->store(); $graph_url = Graph::makeUrl('edit', $graph);
/** * Encodes a file for output into an HTML `input` tag * * @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 encode($object, &$values, &$old_values, &$related_records, &$cache, $method_name, $parameters) { list($action, $column) = fORM::parseMethod($method_name); $filename = $values[$column] instanceof fFile ? $values[$column]->getName() : NULL; if ($filename && strpos($values[$column]->getPath(), self::TEMP_DIRECTORY . DIRECTORY_SEPARATOR . $filename) !== FALSE) { $filename = self::TEMP_DIRECTORY . DIRECTORY_SEPARATOR . $filename; } return fHTML::encode($filename); }
</thead> <tbody> <?php foreach ($this->report->fetchQuestions() as $question) { ?> <tr> <td><?php echo $question->getCategoryName(); ?> </td> <td class="timestamp"><?php echo $question->getAskTime(); ?> </td> <td><?php echo fHTML::encode($question->getQuestion()); ?> </td> <?php if (!strlen($question->getAnswer()) and $this->report->allowAnswer()) { ?> <td colspan="2"> <form class="form-inline" action="<?php echo SITE_BASE; ?> /question/<?php echo $question->getId(); ?> /reply" method="POST"> <textarea name="reply"></textarea> <button type="submit" class="btn btn-mini">回复</button>