• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Web类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Web的典型用法代码示例。如果您正苦于以下问题:PHP Web类的具体用法?PHP Web怎么用?PHP Web使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Web类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:35,代码来源:index.php


示例2: ajaxEditFavorites_ALL

/**
 * updates or removes favorited item 
 *
 * @author Steve Ryan, [email protected], 2015
 **/
function ajaxEditFavorites_ALL(Web $w)
{
    $id = $w->request("id");
    $class = $w->request("class");
    $user = $w->Auth->user();
    $cmd = $w->request("cmd");
    if (!empty($id) && !empty($class) && !empty($user) && !empty($cmd)) {
        if ($cmd == "add") {
            $favorite = new Favorite($w);
            $favorite->object_class = $class;
            $favorite->object_id = $id;
            $favorite->user_id = $user->id;
            $favorite->insertOrUpdate();
            echo $w->Favorite->getFavoriteButton($id, $class);
        } else {
            if ($cmd == "remove") {
                $favorite = $w->Favorite->getDataByObject($id, $class);
                if (get_class($favorite) == "Favorite" && $favorite->id > 0) {
                    $favorite->delete();
                }
                echo $w->Favorite->getFavoriteButton($id, $class);
            } else {
                echo "Invalid request";
            }
        }
    } else {
        echo "Invalid request";
    }
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:34,代码来源:ajaxEditFavorites.php


示例3: 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']);
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:28,代码来源:listtaskgroups.php


示例4: delete_ALL

function delete_ALL(Web $w)
{
    $p = $w->pathMatch("id");
    if (empty($p['id'])) {
        $w->error("Group not found", "/admin-groups");
    }
    $group = $w->Auth->getUser($p['id']);
    if (empty($group->id)) {
        $w->error("Group not found", "/admin-groups");
    }
    $group->delete();
    $roles = $group->getRoles();
    if (!empty($roles)) {
        foreach ($roles as $role) {
            $group->removeRole($role);
        }
    }
    $members = $w->Auth->getGroupMembers($option['group_id']);
    if ($members) {
        foreach ($members as $member) {
            $member->delete();
        }
    }
    $w->msg("Group deleted", "/admin-groups");
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:25,代码来源:delete.php


示例5: taskAjaxTypetoPriority_ALL

function taskAjaxTypetoPriority_ALL(Web &$w)
{
    $priority = array();
    // split the query string into type, group and assignee
    list($type, $group, $assignee) = preg_split('/_/', $w->request('id'));
    // organise criteria
    $who = $assignee != "" ? $assignee : null;
    $where = "";
    if ($group != "") {
        $where .= "task_group_id = " . $group . " and ";
    }
    if ($type != "") {
        $where .= "task_type = '" . $type . "' and ";
    }
    $where .= "is_closed = 0";
    // get priorities from available task list
    $tasks = $w->Task->getTasks($who, $where);
    if ($tasks) {
        foreach ($tasks as $task) {
            if (!array_key_exists($task->priority, $priority)) {
                $priority[$task->priority] = array($task->priority, $task->priority);
            }
        }
    }
    if (!$priority) {
        $priority = array(array("No assigned Tasks", ""));
    }
    // load priority dropdown and return
    $priority = Html::select("tpriority", $priority, null);
    $w->setLayout(null);
    $w->out(json_encode($priority));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:32,代码来源:taskAjaxTypetoPriority.php


示例6: get_GET

function get_GET(Web &$w)
{
    $w->setLayout(null);
    $p = $w->pathMatch("classname", "id");
    $token = $w->request("token");
    $w->out($w->Rest->getJson($p['classname'], $p['id'], $token));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:get.php


示例7: 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);
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:26,代码来源:listwidgets.php


示例8: taskAjaxPrioritytoStatus_ALL

function taskAjaxPrioritytoStatus_ALL(Web &$w)
{
    $status = array();
    // split query string into proirity, type, group and assignee
    list($priority, $type, $group, $assignee) = preg_split('/_/', $w->request('id'));
    // organise criteria
    $who = $assignee != "" ? $assignee : null;
    $where = "";
    if ($group != "") {
        $where .= "task_group_id = " . $group . " and ";
    }
    if ($type != "") {
        $where .= "task_type = '" . $type . "' and ";
    }
    if ($priority != "") {
        $where .= "priority = '" . $priority . "' and ";
    }
    $where .= "is_closed = 0";
    // get statuses from available tasks
    $tasks = $w->Task->getTasks($who, $where);
    if ($tasks) {
        foreach ($tasks as $task) {
            if (!array_key_exists($task->status, $status)) {
                $status[$task->status] = array($task->status, $task->status);
            }
        }
    }
    if (!$status) {
        $status = array(array("No assigned Tasks", ""));
    }
    // load status dropdown and return
    $status = Html::select("status", $status, null);
    $w->setLayout(null);
    $w->out(json_encode($status));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:35,代码来源:taskAjaxPrioritytoStatus.php


示例9: taskAjaxGrouptoType_ALL

function taskAjaxGrouptoType_ALL(Web &$w)
{
    $types = array();
    // split query string into group and assignee
    list($group, $assignee) = preg_split('/_/', $w->request('id'));
    // organise criteria
    $who = $assignee != "" ? $assignee : null;
    $where = "";
    if ($group != "") {
        $where .= "task_group_id = " . $group . " and ";
    }
    $where .= "is_closed = 0";
    // get task types from available task list
    $tasks = $w->Task->getTasks($who, $where);
    if ($tasks) {
        foreach ($tasks as $task) {
            if (!array_key_exists($task->task_type, $types)) {
                $types[$task->task_type] = array($task->getTypeTitle(), $task->task_type);
            }
        }
    }
    if (!$types) {
        $types = array(array("No assigned Tasks", ""));
    }
    // load type dropdown and return
    $tasktypes = Html::select("tasktypes", $types, null);
    $w->setLayout(null);
    $w->out(json_encode($tasktypes));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:29,代码来源:taskAjaxGrouptoType.php


示例10: moreInfo_GET

/**
* Display member and permission infomation
*
* @param <type> $w
*/
function moreInfo_GET(Web &$w)
{
    $option = $w->pathMatch("group_id");
    $w->Admin->navigation($w, $w->Auth->getUser($option['group_id'])->login);
    if ($w->Auth->user()->is_admin || $w->Auth->getRoleForLoginUser($option['group_id'], $w->Auth->user()->id) == "owner") {
        $w->ctx("addMember", Html::box("/admin/groupmember/" . $option['group_id'], "New Member", true));
    }
    $w->ctx("editPermission", Html::b("/admin/permissionedit/" . $option['group_id'], "Edit Permissions"));
    //fill in member table;
    $table = array(array("Name", "Role", "Operations"));
    $groupMembers = $w->Auth->getGroupMembers($option['group_id']);
    if ($groupMembers) {
        foreach ($groupMembers as $groupMember) {
            $line = array();
            $style = $groupMember->role == "owner" ? "<div style=\"color:red;\">" : "<div style=\"color:blue;\">";
            $name = $groupMember->getUser()->is_group == 1 ? $groupMember->getUser()->login : $groupMember->getUser()->getContact()->getFullName();
            $line[] = $style . $name . "</div>";
            $line[] = $style . $groupMember->role . "</div>";
            if ($w->Auth->user()->is_admin || $w->Auth->getRoleForLoginUser($option['group_id'], $w->Auth->user()->id) == "owner") {
                $line[] = Html::a("/admin/memberdelete/" . $option['group_id'] . "/" . $groupMember->id, "Delete", null, null, "Are you sure you want to delete this member?");
            } else {
                $line[] = null;
            }
            $table[] = $line;
        }
    }
    $w->ctx("memberList", Html::table($table, null, "tablesorter", true));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:33,代码来源:moreInfo.php


示例11: editworkentry_POST

function editworkentry_POST(Web $w)
{
    list($workentry_id) = $w->pathMatch("id");
    if (empty($workentry_id)) {
        $w->error("Missing an ID");
    }
    $we = $w->Bend->getWorkEntryForId($workentry_id);
    if (empty($we)) {
        $w->error("No work entry found for this id: " . $workentry_id);
    }
    $we->fill($_POST);
    if (empty($we->user_id)) {
        $we->user_id = $w->Auth->user()->id;
    }
    // now get the category
    if (!empty($_POST['category_3'])) {
        $we->bend_work_category_id = $_POST['category_3'];
    } else {
        if (!empty($_POST['category_2'])) {
            $we->bend_work_category_id = $_POST['category_2'];
        } else {
            if (!empty($_POST['category_1'])) {
                $we->bend_work_category_id = $_POST['category_1'];
            }
        }
    }
    // TODO check work period, etc.
    $we->update();
    $w->msg("Work hours recorded", "/bend-workhours/list");
}
开发者ID:careck,项目名称:bendms,代码行数:30,代码来源:editworkentry.php


示例12: printqueue_GET

function printqueue_GET(Web $w)
{
    $print_folder = FILE_ROOT . "print";
    $path = realpath($print_folder);
    // Check if folder exists
    if ($path === false) {
        // Make print folder (If you specify a full path, use the recursion flag because it seems to crash without it in unix)
        // Other wise you would need to chdir to the parent folder, create and change back to wherever execution currently was at
        mkdir($print_folder, 0777, true);
        $path = realpath($print_folder);
    }
    $exclude = array("THUMBS.db");
    $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
    $table_data = array();
    $table_header = array("Name", "Size", "Date Created", "Actions");
    foreach ($objects as $name => $object) {
        $filename = $object->getFilename();
        // Ignore files starting with '.' and in exclude array
        if ($filename[0] === '.' || in_array($filename, $exclude)) {
            continue;
        }
        $table_data[] = array(Html::a("/uploads/print/" . $filename, $filename), humanReadableBytes($object->getSize()), date("H:i d/m/Y", filectime($name)), Html::box("/admin/printfile?filename=" . urlencode($name), "Print", true) . " " . Html::b("/admin/deleteprintfile?filename=" . urlencode($name), "Delete", "Are you sure you want to remove this file? (This is irreversible)"));
    }
    $w->out(Html::table($table_data, null, "tablesorter", $table_header));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:25,代码来源:printqueue.php


示例13: taskAjaxSelectbyTaskGroup_ALL

function taskAjaxSelectbyTaskGroup_ALL(Web $w)
{
    $p = $w->pathMatch("taskgroup_id");
    $taskgroup = $w->Task->getTaskGroup($p['taskgroup_id']);
    if (empty($taskgroup->id)) {
        return;
    }
    $tasktypes = $taskgroup != "" ? $w->Task->getTaskTypes($taskgroup->task_group_type) : array();
    $priority = $taskgroup != "" ? $w->Task->getTaskPriority($taskgroup->task_group_type) : array();
    $members = $taskgroup != "" ? $w->Task->getMembersBeAssigned($taskgroup->id) : array();
    sort($members);
    $typetitle = $taskgroup != "" ? $taskgroup->getTypeTitle() : "";
    $typedesc = $taskgroup != "" ? $taskgroup->getTypeDescription() : "";
    // if user cannot assign tasks in this group, leave 'first_assignee' blank for owner/member to delegate
    $members = $taskgroup->getCanIAssign() ? $members : array(array("Default", ""));
    // create dropdowns loaded with respective data
    $ttype = Html::select("task_type", $tasktypes, null);
    $prior = Html::select("priority", $priority, null);
    $mem = Html::select("assignee_id", $members, null);
    // first_
    $taskgroup_link = $taskgroup->isOwner($w->Auth->user()) ? "<a href=\"" . $w->localUrl("task-group/viewmembergroup/" . $taskgroup->id) . "\">" . $taskgroup->title . "</a>" : $taskgroup->title;
    $tasktext = "<table style='width: 100%;'>" . "<tr><td class=section colspan=2>Task Group Description</td></tr>" . "<tr><td><b>Task Group</td><td>" . $taskgroup_link . "</td></tr>" . "<tr><td><b>Task Type</b></td><td>" . $typetitle . "</td></tr>" . "<tr valign=top><td><b>Description</b></td><td>" . $typedesc . "</td></tr>" . "</table>";
    // return as array of arrays
    $result = array($ttype, $prior, $mem, $tasktext, Html::select("status", $taskgroup->getTypeStatus(), null, null, null, null));
    $w->setLayout(null);
    $w->out(json_encode($result));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:27,代码来源:taskAjaxSelectbyTaskGroup.php


示例14: reportAjaxCategorytoType_ALL

function reportAjaxCategorytoType_ALL(Web $w)
{
    $type = array();
    list($category, $module) = preg_split('/_/', $w->request('id'));
    // organise criteria
    $who = $w->session('user_id');
    $where = array();
    if (!empty($module)) {
        $where['report.module'] = $module;
    }
    if (!empty($category)) {
        $where['report.category'] = $category;
    }
    // get report categories from available report list
    $reports = $w->Report->getReportsbyUserWhere($who, $where);
    if ($reports) {
        foreach ($reports as $report) {
            $arrtype = preg_split("/,/", $report->sqltype);
            foreach ($arrtype as $rtype) {
                $rtype = trim($rtype);
                if (!array_key_exists(strtolower($rtype), $type)) {
                    $type[strtolower($rtype)] = array(strtolower($rtype), strtolower($rtype));
                }
            }
        }
    }
    if (empty($type)) {
        $type = array(array("No Reports", ""));
    }
    $w->setLayout(null);
    $w->out(json_encode(Html::select("type", $type)));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:32,代码来源:reportAjaxCategorytoType.php


示例15: deletereport_ALL

function deletereport_ALL(Web &$w)
{
    $p = $w->pathMatch("id");
    // if there is  report ID in the URL ...
    if ($p['id']) {
        // get report details
        $rep = $w->Report->getReportInfo($p['id']);
        // if report exists, delete
        if ($rep) {
            $rep->is_deleted = 1;
            $rep->update();
            // need to check if there is a feed associated with this report
            $feed = $w->Report->getFeedInfobyReportId($rep->id);
            // if feed exists, set is_deleted flag. ie. delete feed as well as report
            if ($feed) {
                $feed->is_deleted = 1;
                $feed->update();
            }
            // return
            $w->msg("Report deleted", "/report/index/");
        } else {
            $w->msg("Report no longer exists?", "/report/index/");
        }
    }
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:25,代码来源:deletereport.php


示例16: listfavorite_ALL

/**
 * Partial action that lists favorite objects
 * @author Steve Ryan [email protected] 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);
    }
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:31,代码来源:listfavorite.php


示例17: printview_GET

function printview_GET(Web &$w)
{
    $p = $w->pathMatch("table", "id");
    $attachments = $w->service("File")->getAttachments($p['table'], $p['$id']);
    $w->ctx("attachments", $attachments);
    $w->setLayout(null);
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:printview.php


示例18: atfile_GET

function atfile_GET(Web &$w)
{
    $p = $w->pathMatch("id");
    $id = str_replace(".jpg", "", $p['id']);
    $attachment = $w->service("File")->getAttachment($id);
    $w->sendFile(FILE_ROOT . $attachment->fullpath);
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:atfile.php


示例19: composer_ALL

function composer_ALL(Web $w)
{
    echo "<pre>" . file_get_contents(ROOT_PATH . '/log/composer.log') . "</pre>";
    // Collect dependencies
    $dependencies_array = array();
    foreach ($w->modules() as $module) {
        $dependencies = Config::get("{$module}.dependencies");
        if (!empty($dependencies)) {
            $dependencies_array = array_merge($dependencies, $dependencies_array);
        }
    }
    $json_obj = array();
    $json_obj["config"] = array();
    $json_obj["config"]["vendor-dir"] = 'composer/vendor';
    $json_obj["config"]["cache-dir"] = 'composer/cache';
    $json_obj["config"]["bin-dir"] = 'composer/bin';
    $json_obj["require"] = $dependencies_array;
    // Need to change dir so composer can find the json file
    chdir(SYSTEM_PATH);
    // Create the JSON file
    file_put_contents(SYSTEM_PATH . "/composer.json", json_encode($json_obj, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_FORCE_OBJECT));
    //Create the commands
    $input = new ArrayInput(array('command' => 'update', '--prefer-dist' => 'true'));
    $filestream = new StreamOutput(fopen(ROOT_PATH . '/log/composer.log', 'w'));
    //Create the application and run it with the commands
    $application = new Application();
    $exitcode = $application->run($input, $filestream);
    // Change dir back to root
    chdir(ROOT_PATH);
    // This doesn't happen for some reason
    $w->msg("Composer update return exit code " . $exitcode . " (0 is OK)<br/>Check the /log/composer.log for output", "/admin");
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:32,代码来源:composer.php


示例20: 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]);
}
开发者ID:careck,项目名称:bendms,代码行数:7,代码来源:admin.php



注:本文中的Web类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP WebApp类代码示例发布时间:2022-05-23
下一篇:
PHP Weapon类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap