当前位置: 首页>>代码示例>>PHP>>正文


PHP Ajax::run方法代码示例

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


在下文中一共展示了Ajax::run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

Ajax::run('getRelations', 'both', function () {
    $current_user = wp_get_current_user();
    $ret = [];
    // need to get the evaluations a user is associated with
    // in order to get the corresponding unique relations
    $unique_relation_ids = [];
    if (0 !== $current_user->ID) {
        $evaluations = null;
        if ('administrator' === $current_user->roles[0]) {
            $evaluations = get_posts(['post_type' => 'evaluation', 'posts_per_page' => -1]);
        } else {
            $evaluations = UserModel::getRelations($current_user->ID);
        }
        foreach ($evaluations as $key => $evaluation) {
            $evaluation_pod = pods('evaluation', (int) $evaluation->ID);
            $relation = $evaluation_pod->field('relation');
            if (!$relation) {
                continue;
            }
            if (!in_array($relation['ID'], $unique_relation_ids)) {
                $relation_pod = pods('relation', $relation['ID']);
                if (!$relation_pod) {
                    continue;
                }
                $ret[] = ['company' => $relation_pod->field('company'), 'agency' => $relation_pod->field('agency'), 'brand' => $relation_pod->field('brand'), 'country' => $relation_pod->field('country'), 'period_year' => $relation_pod->field('period_year'), 'period_quarter' => $relation_pod->field('period_quarter'), '180_360' => $evaluation_pod->field('180_360'), 'post' => $relation];
                $unique_relation_ids[] = $relation['ID'];
            }
        }
    }
    // response output
    header("Content-Type: application/json");
    echo json_encode($ret);
    exit;
});
开发者ID:strikles,项目名称:php,代码行数:34,代码来源:reporting.php

示例2: json_decode

    $filename = $type . '_' . $limesurvey_id . '_questions.json';
    $questions = json_decode(file_get_contents(CABSPATH . 'cache/' . $filename), true);
    $user_role = $_POST['userRole'];
    // response output
    header("Content-Type: application/json");
    echo json_encode($questions[$user_role]);
    exit;
});
/**
 *
 */
Ajax::run('genRelationSurveys', 'both', function () {
    $evaluation_id = $_REQUEST['evaluation_id'];
    $evaluation_pod = pods('evaluation', $evaluation_id);
    $relation = $evaluation_pod->field('relation');
    $relation_pod = pods('relation', $relation['ID']);
    $relation_type = $evaluation_pod->field('180_360');
    $relation_steps = EvaluationModel::getSteps($relation_type);
    $survey_ids = [];
    foreach ($relation_steps as $key => $curr_step) {
        $questions_type = $curr_step === '360' ? 'company' : 'agency';
        $limesurvey_id = EvaluationModel::surveyID($evaluation_id, $curr_step);
        $survey_ids[] = $limesurvey_id;
        $groups = LimesurveyModel::generateGroupsJsonCache($limesurvey_id, $questions_type);
        LimesurveyModel::generateQuestionsJsonCache($limesurvey_id, $questions_type, $groups);
    }
    // response output
    header("Content-Type: application/json");
    echo json_encode($survey_ids);
    exit;
});
开发者ID:strikles,项目名称:php,代码行数:31,代码来源:limesurvey.php


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