本文整理汇总了PHP中Whups::urlFor方法的典型用法代码示例。如果您正苦于以下问题:PHP Whups::urlFor方法的具体用法?PHP Whups::urlFor怎么用?PHP Whups::urlFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Whups
的用法示例。
在下文中一共展示了Whups::urlFor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _title
/**
*/
protected function _title()
{
if (($query = $this->_getQuery()) && $query->name) {
return Horde::link(Whups::urlFor('query', empty($query->slug) ? array('id' => $query->id) : array('slug' => $query->slug))) . htmlspecialchars($query->name) . '</a>';
}
return $this->getName();
}
示例2: _content
/**
*/
protected function _content()
{
global $whups_driver;
$queues = Whups::permissionsFilter($whups_driver->getQueues(), 'queue', Horde_Perms::READ);
$qsummary = $whups_driver->getQueueSummary(array_keys($queues));
if (!$qsummary) {
return '<p class="horde-content"><em>' . _("There are no open tickets.") . '</em></p>';
}
$summary = $types = array();
foreach ($qsummary as $queue) {
$types[$queue['type']] = $queue['type'];
if (!isset($summary[$queue['id']])) {
$summary[$queue['id']] = $queue;
}
$summary[$queue['id']][$queue['type']] = $queue['open_tickets'];
}
$html = '<thead><tr>';
$sortby = 'queue_name';
foreach (array_merge(array('queue_name' => _("Queue")), $types) as $column => $name) {
$html .= '<th' . ($sortby == $column ? ' class="sortdown"' : '') . '>' . $name . '</th>';
}
$html .= '</tr></thead><tbody>';
foreach ($summary as $queue) {
$html .= '<tr><td>' . Horde::link(Whups::urlFor('queue', $queue, true), $queue['description']) . htmlspecialchars($queue['name']) . '</a></td>';
foreach ($types as $type) {
$html .= '<td>' . (isset($queue[$type]) ? $queue[$type] : ' ') . '</td>';
}
$html .= '</tr>';
}
$GLOBALS['page_output']->addScriptFile('tables.js', 'horde');
return '<table id="whups_block_queuesummary" class="horde-table sortable" style="width:100%">' . $html . '</tbody></table>';
}
示例3: _autolink
protected function _autolink($matches)
{
$url = Whups::urlFor('ticket', $matches[2]);
$link = '<strong>' . Horde::link($url, 'View ' . $matches[0]) . $matches[0] . '</a></strong>';
$state = $GLOBALS['whups_driver']->getTicketState($matches[2]);
if ($state['state_category'] == 'resolved') {
$link = '<del>' . $link . '</del>';
}
return $link;
}
示例4: sprintf
Horde_Registry::appInit('whups');
// See if we were passed a slug or id. Slug is tried first.
$slug = Horde_Util::getFormData('slug');
if ($slug) {
$queue = $whups_driver->getQueueBySlugInternal($slug);
$id = $queue['id'];
} else {
$id = Horde_Util::getFormData('id');
$queue = $whups_driver->getQueue($id);
}
if (!$id) {
$notification->push(_("Invalid queue"), 'horde.error');
Horde::url($prefs->getValue('whups_default_view') . '.php', true)->redirect();
}
Whups::addFeedLink();
$page_output->ajax = true;
$page_output->header(array('title' => sprintf(_("Open tickets in %s"), $queue['name'])));
$notification->notify(array('listeners' => 'status'));
$criteria = array('queue' => $id, 'category' => array('unconfirmed', 'new', 'assigned'));
try {
$tickets = $whups_driver->getTicketsByProperties($criteria);
Whups::sortTickets($tickets);
$values = Whups::getSearchResultColumns();
$self = Whups::urlFor('queue', $queue);
$results = new Whups_View_Results(array('title' => sprintf(_("Open tickets in %s"), $queue['name']), 'results' => $tickets, 'values' => $values, 'url' => $self));
$session->set('whups', 'last_search', $self);
$results->html();
} catch (Whups_Exception $e) {
$notification->push(sprintf(_("There was an error locating tickets in this queue: %s"), $e->getMessage()), 'horde.error');
}
$page_output->footer();
示例5: foreach
$whups_query = $qManager->getQueryBySlug($slug);
} else {
$whups_query = $qManager->getQuery(Horde_Util::getFormData('query'));
}
if (!isset($whups_query) || $whups_query->parameters || !$whups_query->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
exit;
}
$tickets = $whups_driver->executeQuery($whups_query, $vars);
if (!count($tickets)) {
exit;
}
Whups::sortTickets($tickets, 'date_updated', 'desc');
$cnt = 0;
foreach (array_keys($tickets) as $i) {
$description = 'Type: ' . $tickets[$i]['type_name'] . '; State: ' . $tickets[$i]['state_name'];
$items[$i]['title'] = htmlspecialchars(sprintf('[%s] %s', $tickets[$i]['id'], $tickets[$i]['summary']));
$items[$i]['description'] = htmlspecialchars($description);
$items[$i]['url'] = Whups::urlFor('ticket', $tickets[$i]['id'], true, -1);
$items[$i]['pubDate'] = htmlspecialchars(date('r', $tickets[$i]['timestamp']));
}
$template = $injector->createInstance('Horde_Template');
$template->set('xsl', Horde_Themes::getFeedXsl());
$template->set('pubDate', htmlspecialchars(date('r')));
$template->set('title', htmlspecialchars($whups_query->name ? $whups_query->name : _("Query Results")));
$template->set('items', $items, true);
$url_param = isset($slug) ? array('slug' => $slug) : array('id' => Horde_Util::getFormData('query'));
$template->set('url', Whups::urlFor('query', $url_param, true, -1));
$template->set('rss_url', Whups::urlFor('query_rss', $url_param, true, -1));
$template->set('description', htmlspecialchars(sprintf(_("Tickets matching the query \"%s\"."), $whups_query->name)));
$browser->downloadHeaders((isset($slug) ? $slug : 'query') . '.rss', 'text/xml', true);
echo $template->fetch(WHUPS_TEMPLATES . '/rss/items.rss');
示例6: download
/**
* @throws Whups_Exception
*/
public function download(Horde_Variables $vars)
{
global $injector, $whups_driver;
switch ($vars->actionID) {
case 'download_file':
// Get the ticket details first.
if (empty($vars->ticket)) {
exit;
}
$details = $whups_driver->getTicketDetails($vars->ticket);
// Check permissions on this ticket.
if (!count(Whups::permissionsFilter($whups_driver->getHistory($vars->ticket), 'comment', Horde_Perms::READ))) {
throw new Whups_Exception(sprintf(_("You are not allowed to view ticket %d."), $vars->ticket));
}
try {
$vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create();
} catch (Horde_Exception $e) {
throw new Whups_Exception(_("The VFS backend needs to be configured to enable attachment uploads."));
}
try {
return array('data' => $vfs->read(Whups::VFS_ATTACH_PATH . '/' . $vars->ticket, $vars->file), 'name' => $vars->file);
} catch (Horde_Vfs_Exception $e) {
throw new Whups_Exception(sprintf(_("Access denied to %s"), $vars->file));
}
break;
case 'report':
$_templates = Horde::loadConfiguration('templates.php', '_templates', 'whups');
$tpl = $vars->template;
if (empty($_templates[$tpl])) {
throw new Whups_Exception(_("The requested template does not exist."));
}
if ($_templates[$tpl]['type'] != 'searchresults') {
throw new Whups_Exception(_("This is not a search results template."));
}
// Fetch all unresolved tickets assigned to the current user.
$info = array('id' => explode(',', $vars->ids));
$tickets = $whups_driver->getTicketsByProperties($info);
foreach ($tickets as $id => $info) {
$tickets[$id]['#'] = $id + 1;
$tickets[$id]['link'] = Whups::urlFor('ticket', $info['id'], true, -1);
$tickets[$id]['date_created'] = strftime('%x', $info['timestamp']);
$tickets[$id]['owners'] = Whups::getOwners($info['id']);
$tickets[$id]['owner_name'] = Whups::getOwners($info['id'], false, true);
$tickets[$id]['owner_email'] = Whups::getOwners($info['id'], true, false);
if (!empty($info['date_assigned'])) {
$tickets[$id]['date_assigned'] = strftime('%x', $info['date_assigned']);
}
if (!empty($info['date_resolved'])) {
$tickets[$id]['date_resolved'] = strftime('%x', $info['date_resolved']);
}
// If the template has a callback function defined for data
// filtering, call it now.
if (!empty($_templates[$tpl]['callback'])) {
array_walk($tickets[$id], $_templates[$tpl]['callback']);
}
}
Whups::sortTickets($tickets, isset($_templates[$tpl]['sortby']) ? $_templates[$tpl]['sortby'] : null, isset($_templates[$tpl]['sortdir']) ? $_templates[$tpl]['sortdir'] : null);
$template = $injector->createInstance('Horde_Template');
$template->set('tickets', $tickets);
$template->set('now', strftime('%x'));
$template->set('values', Whups::getSearchResultColumns(null, true));
return array('data' => $template->parse($_templates[$tpl]['template']), 'name' => isset($_templates[$tpl]['filename']) ? $_templates[$tpl]['filename'] : 'report.html');
}
}
示例7: listTimeObjects
/**
* Lists tickets with due dates as time objects.
*
* @param array $categories The time categories (from listTimeObjectCategories) to list.
* @param mixed $start The start date of the period.
* @param mixed $end The end date of the period.
*/
public function listTimeObjects($categories, $start, $end)
{
global $whups_driver;
$start = new Horde_Date($start);
$start_ts = $start->timestamp();
$end = new Horde_Date($end);
$end_ts = $end->timestamp();
$criteria['owner'] = Whups::getOwnerCriteria($GLOBALS['registry']->getAuth());
/* @TODO Use $categories */
$category = 'due';
switch ($category) {
case 'assigned':
$label = _("Assigned");
$criteria['ass'] = true;
break;
case 'created':
$label = _("Created");
break;
case 'due':
$label = _("Due");
$criteria['nores'] = true;
break;
case 'resolved':
$label = _("Resolved");
$criteria['res'] = true;
break;
}
try {
$tickets = $whups_driver->getTicketsByProperties($criteria);
} catch (Whups_Exception $e) {
return array();
}
$objects = array();
foreach ($tickets as $ticket) {
switch ($category) {
case 'assigned':
$t_start = $ticket['date_assigned'];
break;
case 'created':
$t_start = $ticket['timestamp'];
break;
case 'due':
if (empty($ticket['due'])) {
continue 2;
}
$t_start = $ticket['due'];
break;
case 'resolved':
$t_start = $ticket['date_resolved'];
break;
}
if ($t_start + 1 < $start_ts || $t_start > $end_ts) {
continue;
}
$t = new Whups_Ticket($ticket['id'], $ticket);
$objects[$ticket['id']] = array('title' => sprintf('%s: [#%s] %s', $label, $ticket['id'], $ticket['summary']), 'description' => $t->toString(), 'id' => $ticket['id'], 'start' => date('Y-m-d\\TH:i:s', $t_start), 'end' => date('Y-m-d\\TH:i:s', $t_start + 1), 'params' => array('id' => $ticket['id']), 'link' => Whups::urlFor('ticket', $ticket['id'], true));
}
return $objects;
}
示例8: foreach
$criteria['queue'] = $id;
}
$tickets = $whups_driver->getTicketsByProperties($criteria);
if (!count($tickets)) {
exit;
}
Whups::sortTickets($tickets, 'date_updated', 'desc');
$cnt = 0;
foreach (array_keys($tickets) as $i) {
if ($limit > 0 && $cnt++ == $limit) {
break;
}
$description = 'Type: ' . $tickets[$i]['type_name'] . '; State: ' . $tickets[$i]['state_name'];
$items[$i]['title'] = htmlspecialchars(sprintf('[%s] %s', $tickets[$i]['id'], $tickets[$i]['summary']));
$items[$i]['description'] = htmlspecialchars($description);
$items[$i]['url'] = Whups::urlFor('ticket', $tickets[$i]['id'], true, -1);
$items[$i]['pubDate'] = htmlspecialchars(date('r', $tickets[$i]['timestamp']));
}
$template = $injector->createInstance('Horde_Template');
$template->set('xsl', Horde_Themes::getFeedXsl());
$template->set('pubDate', htmlspecialchars(date('r')));
if (isset($type) && isset($queue['name'])) {
$rss_title = sprintf(_("%s %s tickets in %s"), $state_display, $type['name'], $queue['name']);
} elseif (isset($type)) {
$rss_title = sprintf(_("%s %s tickets in all queues"), $state_display, $type['name']);
} elseif (isset($queue['name'])) {
$rss_title = sprintf(_("%s tickets in %s"), $state_display, $queue['name']);
} else {
$rss_title = sprintf(_("%s tickets in all queues"), $state_display);
}
$template->set('title', htmlspecialchars($rss_title));
示例9: notify
/**
* Notifies all appropriate people of the creation/update of this ticket.
*
* @param string $author Who created/changed the ticket?
* @param boolean $isNew Is this a new ticket or a change to an existing
* one?
* @param array $listeners The list of listener that should receive the
* notification, with user names as keys and user
* roles as values. If empty, the list will be
* created automatically.
*/
public function notify($author, $isNew, $listeners = array())
{
global $conf, $whups_driver;
/* Get the attributes for this ticket. */
$attributes = $whups_driver->getAttributesForType($this->get('type'));
$fields = array('queue' => _("Queue"), 'version' => _("Version"), 'type' => _("Type"), 'state' => _("State"), 'priority' => _("Priority"), 'due' => _("Due"));
$field_names = array_merge($fields, array(_("Created By"), _("Updated By"), _("Summary"), _("Owners"), _("New Attachment"), _("Deleted Attachment")));
foreach ($attributes as $attribute) {
$field_names[] = $attribute['human_name'];
}
/* Find the longest translated field name. */
$length = 0;
foreach ($field_names as $field_name) {
$length = max($length, Horde_String::length($field_name));
}
$wrap_break = "\n" . str_repeat(' ', $length + 2) . '| ';
$wrap_width = 73 - $length;
/* Ticket URL. */
$url = sprintf(_("Ticket URL: %s"), Whups::urlFor('ticket', $this->_id, true, -1));
/* Ticket properties. */
$table = "------------------------------------------------------------------------------\n" . ' ' . Horde_String::pad(_("Ticket"), $length) . ' | ' . $this->_id . "\n" . ' ' . Horde_String::pad($isNew ? _("Created By") : _("Updated By"), $length) . ' | ' . Whups::formatUser($author) . "\n";
if (isset($this->_changes['summary'])) {
$table .= '-' . Horde_String::pad(_("Summary"), $length) . ' | ' . Horde_String::wrap($this->_changes['summary']['from'], $wrap_width, $wrap_break) . "\n" . '+' . Horde_String::pad(_("Summary"), $length) . ' | ' . Horde_String::wrap($this->get('summary'), $wrap_width, $wrap_break) . "\n";
} else {
$table .= ' ' . Horde_String::pad(_("Summary"), $length) . ' | ' . Horde_String::wrap($this->get('summary'), $wrap_width, $wrap_break) . "\n";
}
foreach ($fields as $field => $label) {
if ($name = $this->get($field . '_name')) {
if (isset($this->_changes[$field])) {
$table .= '-' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->_changes[$field]['from_name'], $wrap_width, $wrap_break) . "\n" . '+' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($name, $wrap_width, $wrap_break) . "\n";
} else {
$table .= ' ' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($name, $wrap_width, $wrap_break) . "\n";
}
}
}
/* Attribute changes. */
foreach ($attributes as $id => $attribute) {
$attribute_id = 'attribute_' . $id;
$label = $attribute['human_name'];
if (isset($this->_changes[$attribute_id])) {
$table .= '-' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->_changes[$attribute_id]['from'], $wrap_width, $wrap_break) . "\n" . '+' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->_changes[$attribute_id]['to'], $wrap_width, $wrap_break) . "\n";
} else {
$table .= ' ' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->get($attribute_id), $wrap_width, $wrap_break) . "\n";
}
}
/* Show any change in ticket owners. */
$owners = $oldOwners = Horde_String::wrap(Whups::getOwners($this->_id, false, true), $wrap_width, $wrap_break);
if (isset($this->_changes['oldowners'])) {
$oldOwners = Horde_String::wrap(Whups::getOwners($this->_id, false, true, $this->_changes['oldowners']), $wrap_width, $wrap_break);
}
if ($owners != $oldOwners) {
$table .= '-' . Horde_String::pad(_("Owners"), $length) . ' | ' . $oldOwners . "\n" . '+' . Horde_String::pad(_("Owners"), $length) . ' | ' . $owners . "\n";
} else {
$table .= ' ' . Horde_String::pad(_("Owners"), $length) . ' | ' . $owners . "\n";
}
/* New Attachments. */
if (isset($this->_changes['attachment'])) {
$table .= '+' . Horde_String::pad(_("New Attachment"), $length) . ' | ' . $this->_changes['attachment']['to']['name'] . "\n";
}
if (!empty($this->_changes['attachments'])) {
foreach ($this->_changes['attachments']['to'] as $attachment) {
$table .= '+' . Horde_String::pad(_("New Attachment"), $length) . ' | ' . $attachment['name'] . "\n";
}
}
/* Deleted Attachments. */
if (isset($this->_changes['delete-attachment'])) {
$table .= '+' . Horde_String::pad(_("Deleted Attachment"), $length) . ' | ' . $this->_changes['delete-attachment']['to'] . "\n";
}
$table .= "------------------------------------------------------------------------------";
/* Build message template. */
$view = new Horde_View(array('templatePath' => WHUPS_BASE . '/config'));
$view->ticket_url = $url;
$view->table = $table;
$view->dont_reply = empty($conf['mail']['reply']);
$view->date = strftime($GLOBALS['prefs']->getValue('date_format'));
$view->auth_name = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create()->getValue('fullname');
if (empty($view->auth_name)) {
$view->auth_name = $GLOBALS['registry']->getAuth('bare');
}
/* Get queue specific notification message text, if available. */
$message_file = WHUPS_BASE . '/config/' . ($isNew ? 'create_email.plain' : 'notify_email.plain');
if (file_exists($message_file . '.' . $this->get('queue') . '.php')) {
$message_file .= '.' . $this->get('queue') . '.php';
} elseif (file_exists($message_file . '.local.php')) {
$message_file .= '.local.php';
} else {
$message_file .= '.php';
}
$message_file = basename($message_file);
//.........这里部分代码省略.........
示例10: _
$tickets = $whups_driver->executeQuery($whups_query, $vars);
$session->set('whups', 'last_search', Horde::url('query/run.php'));
}
if ($whups_query->id) {
$page_output->addLinkTag($whups_query->feedLink());
}
$title = $whups_query->name ? $whups_query->name : _("Query Results");
Whups::addFeedLink();
$page_output->ajax = true;
$page_output->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
echo $tabs->render($vars->get('action') ? $vars->get('action') : 'run');
if (!is_null($tickets)) {
Whups::sortTickets($tickets);
$subscription = null;
if (isset($whups_query->id)) {
$params = empty($whups_query->slug) ? array('id' => $whups_query->id) : array('slug' => $whups_query->slug);
$subscription = Horde::link(Whups::urlFor('query_rss', $params, true, -1), _("Subscribe to this query")) . Horde::img('feed.png', _("Subscribe to this query")) . '</a>';
}
$results = new Whups_View_Results(array('title' => $title, 'results' => $tickets, 'extra' => $subscription, 'values' => Whups::getSearchResultColumns(), 'url' => Horde::url('query/run.php')));
$results->html();
} else {
$form->open($renderer, $vars, 'query/run.php');
$renderer->beginActive($form->getTitle());
$renderer->renderFormActive($form, $vars);
$renderer->submit(_("Execute Query"));
$renderer->end();
$form->close($renderer);
}
$page_output->footer();
$session->set('whups', 'query', $whups_query);
示例11: feedLink
/**
* Returns <link> data for this query's feed.
*
* @return array Link data.
*/
public function feedLink()
{
return array('href' => Whups::urlFor('query_rss', empty($this->slug) ? array('id' => $this->id) : array('slug' => $this->slug), true, -1), 'title' => $this->name);
}
示例12: array
if (!$ticket) {
exit;
}
// Get the ticket details first.
$details = $whups_driver->getTicketDetails($ticket);
// Check permissions on this ticket.
if (!count(Whups::permissionsFilter(array($details['queue'] => ''), 'queue', Horde_Perms::READ))) {
exit;
}
$history = Whups::permissionsFilter($whups_driver->getHistory($ticket), 'comment', Horde_Perms::READ);
$items = array();
$self = Whups::urlFor('ticket', $ticket, true, -1);
foreach (array_keys($history) as $i) {
if (!isset($history[$i]['comment_text'])) {
continue;
}
$items[$i]['title'] = htmlspecialchars(substr($history[$i]['comment_text'], 0, 60));
$items[$i]['description'] = htmlspecialchars($history[$i]['comment_text']);
$items[$i]['pubDate'] = htmlspecialchars(date('r', $history[$i]['timestamp']));
$items[$i]['url'] = $self . '#t' . $i;
}
$template = $injector->createInstance('Horde_Template');
$template->set('xsl', Horde_Themes::getFeedXsl());
$template->set('pubDate', htmlspecialchars(date('r')));
$template->set('title', htmlspecialchars($details['summary']));
$template->set('items', $items, true);
$template->set('url', Whups::urlFor('ticket', $ticket, true));
$template->set('rss_url', Whups::urlFor('ticket_rss', $ticket, true));
$template->set('description', htmlspecialchars($details['summary']));
$browser->downloadHeaders($details['summary'] . '.rss', 'text/xml', true);
echo $template->fetch(WHUPS_TEMPLATES . '/rss/items.rss');