本文整理汇总了PHP中Get::safe方法的典型用法代码示例。如果您正苦于以下问题:PHP Get::safe方法的具体用法?PHP Get::safe怎么用?PHP Get::safe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Get
的用法示例。
在下文中一共展示了Get::safe方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tpl_list_heading
function tpl_list_heading($colname, $format = "<th%s>%s</th>")
{
global $proj, $page;
$imgbase = '<img src="%s" alt="%s" />';
$class = '';
$html = eL($colname);
if ($colname == 'comments' || $colname == 'attachments') {
$html = sprintf($imgbase, $page->get_image(substr($colname, 0, -1)), $html);
}
if (Get::val('order') == $colname) {
$class = ' class="orderby"';
$sort1 = Get::safe('sort', 'desc') == 'desc' ? 'asc' : 'desc';
$sort2 = Get::safe('sort2', 'desc');
$order2 = Get::safe('order2');
$html .= ' ' . sprintf($imgbase, $page->get_image(Get::val('sort')), Get::safe('sort'));
} else {
$sort1 = 'desc';
if (in_array($colname, array('project', 'tasktype', 'category', 'openedby', 'assignedto'))) {
$sort1 = 'asc';
}
$sort2 = Get::safe('sort', 'desc');
$order2 = Get::safe('order');
}
$new_order = array('order' => $colname, 'sort' => $sort1, 'order2' => $order2, 'sort2' => $sort2);
$html = sprintf('<a title="%s" href="%s">%s</a>', eL('sortthiscolumn'), Filters::noXSS(CreateURL('index', $proj->id, null, array_merge($_GET, $new_order))), $html);
return sprintf($format, $class, $html);
}
示例2: export_task_list
function export_task_list()
{
global $tasks, $fs, $sort, $orderby;
if (!is_array($tasks)) {
return;
}
$indexes = array('id' => 'task_id', 'project' => 'project_title', 'tasktype' => 'task_type', 'category' => 'category_name', 'severity' => 'task_severity', 'priority' => 'task_priority', 'summary' => 'item_summary', 'dateopened' => 'date_opened', 'status' => 'status_name', 'openedby' => 'opened_by_name', 'assignedto' => 'assigned_to_name', 'lastedit' => 'max_date', 'reportedin' => 'product_version', 'dueversion' => 'closedby_version', 'duedate' => 'due_date', 'comments' => 'num_comments', 'votes' => 'num_votes', 'attachments' => 'num_attachments', 'dateclosed' => 'date_closed', 'progress' => 'percent_complete', 'os' => 'os_name', 'private' => 'mark_private', 'supertask' => 'supertask_id');
// first line of .csv will be project name
$result = "Project: " . $tasks[0]['project_title'] . " - " . date("H:i:s d-m-Y") . "\r\n\r\n";
// insert column headers
$result .= '"ID","Category","Task Type","Severity","Summary","Status","Progress"' . "\r\n";
// sort the tasks into the order selected by the user. Set
// global vars for use by sort comparison function
$sort = Get::safe('sort', 'desc') == 'desc' ? 'desc' : 'asc';
$field = Get::safe('order', 'id');
if ($field == '') {
$field = 'id';
}
$orderby = $indexes[$field];
usort($tasks, "do_cmp");
// sort the items
// for each task create a line showing values
// get the items
foreach ($tasks as $task) {
$array = array($task['task_id'], $task['category_name'], $task['task_type'], $fs->severities[$task['task_severity']], $task['item_summary'], $task['status_name'], $task['percent_complete']);
// create comma seperated values from array and append it to $result
$result .= implode(',', $array) . "\r\n";
}
// now send data to user to download to their machine. First create
// HTML header
$outfile = "tasklist_" . date("Y-m-d") . ".csv";
// name user sees to save file as
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=' . $outfile);
header('Content-Transfer-Encoding: text');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . strlen($result));
ob_clean();
flush();
// finally send out our data
printf("%s", $result);
}
示例3: export_task_list
function export_task_list()
{
global $tasks, $fs, $user, $sort, $orderby, $proj;
if (!is_array($tasks)) {
return;
}
# TODO enforcing user permissions on allowed fields
# TODO Flyspray 1.1 or later: selected fields by user request, saved user settings, tasklist settings or project defined list which fields should appear in an export
# TODO Flyspray 1.1 or later: export in .ods open document spreadsheet, .xml ....
$indexes = array('id' => 'task_id', 'project' => 'project_title', 'tasktype' => 'task_type', 'category' => 'category_name', 'severity' => 'task_severity', 'priority' => 'task_priority', 'summary' => 'item_summary', 'dateopened' => 'date_opened', 'status' => 'status_name', 'openedby' => 'opened_by_name', 'assignedto' => 'assigned_to_name', 'lastedit' => 'max_date', 'reportedin' => 'product_version', 'dueversion' => 'closedby_version', 'duedate' => 'due_date', 'comments' => 'num_comments', 'votes' => 'num_votes', 'attachments' => 'num_attachments', 'dateclosed' => 'date_closed', 'progress' => 'percent_complete', 'os' => 'os_name', 'private' => 'mark_private', 'supertask' => 'supertask_id', 'detailed_desc' => 'detailed_desc');
# we can put this info also in the filename ...
#$projectinfo = array('Project ', $tasks[0]['project_title'], date("H:i:s d-m-Y") );
// sort the tasks into the order selected by the user. Set
// global vars for use by sort comparison function
$sort = Get::safe('sort', 'desc') == 'desc' ? 'desc' : 'asc';
$field = Get::safe('order', 'id');
if ($field == '') {
$field = 'id';
}
$orderby = $indexes[$field];
usort($tasks, "do_cmp");
$outfile = str_replace(' ', '_', $tasks[0]['project_title']) . '_' . date("Y-m-d") . '.csv';
#header('Content-Type: application/csv');
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename=' . $outfile);
header('Content-Transfer-Encoding: text');
header('Expires: 0');
header('Cache-Control: must-revalidate');
#header('Pragma: public');
#header('Content-Length: '.strlen($result)); # unknown at this time..
ob_clean();
flush();
$output = fopen('php://output', 'w');
#fputcsv($output, $projectinfo);
$headings = array('ID', 'Category', 'Task Type', 'Severity', 'Summary', 'Status', 'Progress', $user->perms('view_estimated_effort') ? 'Estimated Effort' : '', 'Description');
# TODO maybe if user just want localized headings for nonenglish speaking audience..
#$headings= array('ID','Category','Task Type','Severity','Summary','Status','Progress');
fputcsv($output, $headings);
foreach ($tasks as $task) {
$row = array($task['task_id'], $task['category_name'], $task['task_type'], $fs->severities[$task['task_severity']], $task['item_summary'], $task['status_name'], $task['percent_complete'], $user->perms('view_estimated_effort') && $proj->prefs['use_effort_tracking'] ? $task['estimated_effort'] : '', $task['detailed_desc']);
fputcsv($output, $row);
}
fclose($output);
exit;
}
示例4: tpl_list_heading
function tpl_list_heading($colname, $coldisplay, $format = "<th%s>%s</th>")
{
global $proj, $page;
$imgbase = '<img src="%s" alt="%s" />';
$class = '';
$html = $coldisplay;
$colname = strtolower($colname);
if ($colname == 'comments' || $colname == 'attachments') {
$html = sprintf($imgbase, $page->get_image(substr($colname, 0, -1)), $html);
}
if (Get::val('order') == $colname) {
$class = ' class="orderby"';
$sort1 = Get::safe('sort', 'desc') == 'desc' ? 'asc' : 'desc';
$sort2 = Get::safe('sort2', 'desc');
$order2 = Get::safe('order2');
$html .= ' ' . sprintf($imgbase, $page->get_image(Get::val('sort')), Get::safe('sort'));
} else {
$sort1 = 'desc';
$sort2 = Get::safe('sort', 'desc');
$order2 = Get::safe('order');
}
$new_order = array('order' => $colname, 'sort' => $sort1, 'order2' => $order2, 'sort2' => $sort2);
$html = sprintf('<a title="%s" href="%s">%s</a>', L('sortthiscolumn'), Filters::noXSS($page->url(array('index', 'proj' . $proj->id), array_merge($_GET, $new_order))), $html);
return sprintf($format, $class, $html);
}