本文整理汇总了PHP中Web::ctx方法的典型用法代码示例。如果您正苦于以下问题:PHP Web::ctx方法的具体用法?PHP Web::ctx怎么用?PHP Web::ctx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web::ctx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index_ALL
/**
* @hook example_add_row_action(array(<ExampleData> 'data', <String> 'actions')
* @param Web $w
*/
function index_ALL(Web $w)
{
// adding data to the template context
$w->ctx("message", "Example Data List");
// get the list of data objects
$listdata = $w->Example->getAllData();
// prepare table data
$t[] = array("Title", "Data", "Actions");
// table header
if (!empty($listdata)) {
foreach ($listdata as $d) {
$row = array();
$row[] = $d->title;
$row[] = $d->data;
// prepare action buttons for each row
$actions = array();
if ($d->canEdit($w->Auth->user())) {
$actions[] = Html::box("/example/edit/" . $d->id, "Edit", true);
}
if ($d->canDelete($w->Auth->user())) {
$actions[] = Html::b("/example/delete/" . $d->id, "Delete", "Really delete?");
}
// allow any other module to add actions here
$actions = $w->callHook("example", "add_row_action", array("data" => $d, "actions" => $actions));
$row[] = implode(" ", $actions);
$t[] = $row;
}
}
// create the html table and put into template context
$w->ctx("table", Html::table($t, "table", "tablesorter", true));
}
示例2: admin_ALL
function admin_ALL(Web $w)
{
History::add("Workhours Admin");
$w->ctx("workperiods", $w->Bend->getAllWorkPeriods());
$w->ctx("focusgroups", $w->Bend->getTopLevelWorkCategories());
$w->enqueueStyle(["uri" => "/modules/bend/assets/css/bend.css", "weight" => 500]);
}
示例3: useredit_POST
/**
* Handle User Edit form submission
*
* @param <type> $w
*/
function useredit_POST(Web &$w)
{
$w->pathMatch("id");
$errors = $w->validate(array(array("login", ".+", "Login is mandatory")));
if ($_REQUEST['password'] && $_REQUEST['password'] != $_REQUEST['password2']) {
$error[] = "Passwords don't match";
}
$user = $w->Auth->getObject("User", $w->ctx('id'));
if (!$user) {
$errors[] = "User does not exist";
}
if (sizeof($errors) != 0) {
$w->error(implode("<br/>\n", $errors), "/admin/useredit/" . $w->ctx("id"));
}
$user->login = $_REQUEST['login'];
$user->fill($_REQUEST);
if ($_REQUEST['password']) {
$user->setPassword($_REQUEST['password']);
} else {
$user->password = null;
}
$user->is_admin = isset($_REQUEST['is_admin']) ? 1 : 0;
$user->is_active = isset($_REQUEST['is_active']) ? 1 : 0;
$user->update();
$contact = $user->getContact();
if ($contact) {
$contact->fill($_REQUEST);
$contact->private_to_user_id = null;
$contact->update();
}
$w->callHook("admin", "account_changed", $user);
$w->msg("User " . $user->login . " updated.", "/admin/users");
}
示例4: listwidgets_ALL
function listwidgets_ALL(Web $w, $params)
{
$module = null;
if (!empty($params["module"])) {
$module = $params["module"];
} else {
$module = $w->_module;
}
$widgets = $w->Widget->getWidgetsForModule($module, $w->Auth->user()->id);
$filter_widgets = array();
if (!empty($widgets)) {
// Filter out widgets in an inactive class
$filter_widgets = array_filter($widgets, function ($widget) use($w) {
return $w->isClassActive($widget->widget_name);
});
foreach ($filter_widgets as &$widget) {
// Give each widget_config db object an instance of the matching class
$widget_class = null;
$widgetname = $widget->widget_name;
$widget->widget_class = new $widgetname($w, $widget);
}
}
$w->ctx("columns", 3);
$w->ctx("widgets", $filter_widgets);
$w->ctx("module", $module);
}
示例5: listtaskgroups_ALL
function listtaskgroups_ALL(Web $w, $params = array())
{
$taskgroups = $params['taskgroups'];
$should_filter = !empty($params['should_filter']) ? $params['should_filter'] : false;
$filter_closed_tasks = !empty($params['filter_closed_tasks']) ? $params['filter_closed_tasks'] : false;
if ($should_filter) {
$taskgroups = array_filter($taskgroups, function ($taskgroup) use($w, $filter_closed_tasks) {
// First check if there are tasks
$tasks = $taskgroup->getTasks();
if (count($tasks) == 0) {
return false;
} else {
// Check if any of the tasks are accessible to the user
$tasks = array_filter($tasks, function ($task) use($w, $filter_closed_tasks) {
if ($filter_closed_tasks && $task->isStatusClosed()) {
return false;
} else {
return $task->getCanIView();
}
});
// If there are tasks that the user can view then show the taskgroup
return count($tasks) > 0;
}
});
}
$w->ctx("taskgroups", $taskgroups);
$w->ctx("redirect", $params['redirect']);
}
示例6: listcomments_ALL
function listcomments_ALL(Web $w, $params)
{
$object = $params['object'];
$redirect = $params['redirect'];
$w->ctx("comments", $w->Comment->getCommentsForTable($object->getDbTableName(), $object->id));
$w->ctx("redirect", $redirect);
$w->ctx("object", $object);
}
示例7: displaycomment_ALL
function displaycomment_ALL(Web $w, $params)
{
if (!empty($params['redirect'])) {
$w->ctx("redirect", $params['redirect']);
}
if (!empty($params['displayOnly'])) {
$w->ctx("displayOnly", true);
}
$w->ctx("c", $params['object']);
}
示例8: showtaskgroup_ALL
function showtaskgroup_ALL(Web $w, $params)
{
$taskgroup = $params["taskgroup"];
if (!empty($taskgroup)) {
$taskgroup->tasks = $w->Task->getTasksbyGroupId($taskgroup->id);
$taskgroup->statuses = $w->Task->getTaskTypeStatus($taskgroup->task_group_type);
$w->ctx("taskgroup", $taskgroup);
}
$w->ctx("redirect", !empty($params["redirect"]) ? $params["redirect"] : "/");
}
示例9: showperiod_GET
function showperiod_GET(Web $w)
{
list($id) = $w->pathMatch("a");
$wp = $w->Bend->getWorkperiodForId($id);
if (empty($wp)) {
$w->error("Workperiod does not exist", "/bend-workhours/admin");
}
History::add("Work Period: " . formatDate($wp->d_start));
$w->ctx("workperiod", $wp);
$w->ctx("categories", $w->Bend->getTopLevelWorkCategories());
$w->ctx("households", $w->Bend->getAllHouseholds());
}
示例10: example_listener_POST_ACTION
/**
* This function is called AFTER the action was executed
*
* @param unknown $w
*/
function example_listener_POST_ACTION(Web $w)
{
// you can find out which objects have changed
$updated = $w->ctx("db_updated");
// returns array("classname" => array($id1, $id2, ..), ..);
$deleted = $w->ctx("db_deleted");
// returns array("classname" => array($id1, $id2, ..), ..);
$inserts = $w->ctx("db_inserts");
// returns array("classname" => array($id1, $id2, ..), ..);
// you can redirect the request.. but maybe you shouldn't!
$w->redirect("/main");
}
示例11: printers_GET
function printers_GET(Web $w)
{
$printers = $w->Printer->getPrinters();
$table_data = array();
$table_header = array("Name", "Server", "Port", "Actions");
if (!empty($printers)) {
foreach ($printers as $printer) {
$table_data[] = array($printer->name, $printer->server, $printer->port, Html::box("/admin/editprinter/{$printer->id}", "Edit", true) . Html::b("/admin/deleteprinter/{$printer->id}", "Delete", "Are you sure you want to delete this printer?"));
}
}
$w->ctx("table_header", $table_header);
$w->ctx("table_data", $table_data);
}
示例12: navigation
/**
* Channels naivgation function
* @return none
*/
public function navigation(Web $w, $title = null, $prenav = null)
{
if ($title) {
$w->ctx("title", $title);
}
$nav = $prenav ? $prenav : array();
if ($w->Auth->loggedIn()) {
$w->menuLink("channels/listchannels", "List Channels", $nav);
$w->menuLink("channels/listprocessors", "List Processors", $nav);
$w->menuLink("channels/listmessages", "List Messages", $nav);
}
$w->ctx("navigation", $nav);
return $nav;
}
示例13: listfavorite_ALL
/**
* Partial action that lists favorite objects
* @author Steve Ryan steve@2pisoftware.com 2015
*/
function listfavorite_ALL(Web $w, $params)
{
$user = $w->Auth->user();
if (!empty($user)) {
$results = $w->Favorite->getDataByUser($user->id);
$favoritesCategorised = array();
$service = new DBService($w);
if (!empty($results)) {
foreach ($results as $k => $favorite) {
if (!array_key_exists($favorite->object_class, $favoritesCategorised)) {
$favoritesCategorised[$favorite->object_class] = array();
}
$realObject = $service->getObject($favorite->object_class, $favorite->object_id);
if (!empty($realObject)) {
$templateData = array();
$templateData['title'] = $realObject->printSearchTitle();
$templateData['url'] = $realObject->printSearchUrl();
$templateData['listing'] = $realObject->printSearchListing();
if ($realObject->canList($user) && $realObject->canView($user)) {
array_push($favoritesCategorised[$favorite->object_class], $templateData);
}
}
}
}
$w->ctx('categorisedFavorites', $favoritesCategorised);
}
}
示例14: profile_GET
function profile_GET(Web &$w)
{
$p = $w->pathMatch("box");
$user = $w->Auth->user();
$contact = $user->getContact();
if ($user) {
$w->ctx("title", "Administration - Profile - " . $user->login);
} else {
$w->error("User does not exist.");
}
$lines = array();
$lines[] = array("Change Password", "section");
$lines[] = array("Password", "password", "password", "");
$lines[] = array("Repeat Password", "password", "password2", "");
$lines[] = array("Contact Details", "section");
$lines[] = array("First Name", "text", "firstname", $contact ? $contact->firstname : "");
$lines[] = array("Last Name", "text", "lastname", $contact ? $contact->lastname : "");
$lines[] = array("Communication", "section");
$lines[] = array("Home Phone", "text", "homephone", $contact ? $contact->homephone : "");
$lines[] = array("Work Phone", "text", "workphone", $contact ? $contact->workphone : "");
$lines[] = array("Private Mobile", "text", "priv_mobile", $contact ? $contact->priv_mobile : "");
$lines[] = array("Work Mobile", "text", "mobile", $contact ? $contact->mobile : "");
$lines[] = array("Fax", "text", "fax", $contact ? $contact->fax : "");
$lines[] = array("Email", "text", "email", $contact ? $contact->email : "");
$lines[] = array("Redirect URL", "text", "redirect_url", $user->redirect_url);
$f = Html::form($lines, $w->localUrl("/auth/profile"), "POST", "Update");
if ($p['box']) {
$w->setLayout(null);
$f = "<h2>Edit Profile</h2>" . $f;
}
$w->out($f);
}
示例15: atdel_GET
function atdel_GET(Web &$w)
{
$p = $w->pathMatch("id", "url");
$att = $w->service("File")->getAttachment($p['id']);
if ($att) {
$w->ctx('attach_id', $att->id);
$w->ctx('attach_table', $att->parent_table);
$w->ctx('attach_table_id', $att->parent_id);
$w->ctx('attach_title', $att->title);
$w->ctx('attach_description', $att->description);
$att->delete();
$w->msg("Attachment deleted.", "/" . str_replace(" ", "/", $p['url']));
} else {
$w->error("Attachment does not exist.", "/" . str_replace(" ", "/", $p['url']));
}
}