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


PHP comment::get_comments方法代码示例

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


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

示例1: get_comments

 /**
  * Return a list of comments
  *
  * @param string $contextlevel ('system, course, user', etc..)
  * @param int $instanceid
  * @param string $component the name of the component
  * @param int $itemid the item id
  * @param string $area comment area
  * @param int $page page number
  * @return array of comments and warnings
  * @since Moodle 2.9
  */
 public static function get_comments($contextlevel, $instanceid, $component, $itemid, $area = '', $page = 0)
 {
     $warnings = array();
     $arrayparams = array('contextlevel' => $contextlevel, 'instanceid' => $instanceid, 'component' => $component, 'itemid' => $itemid, 'area' => $area, 'page' => $page);
     $params = self::validate_parameters(self::get_comments_parameters(), $arrayparams);
     $context = self::get_context_from_params($params);
     self::validate_context($context);
     require_capability('moodle/comment:view', $context);
     $args = new stdClass();
     $args->context = $context;
     $args->area = $params['area'];
     $args->itemid = $params['itemid'];
     $args->component = $params['component'];
     $commentobject = new comment($args);
     $comments = $commentobject->get_comments($params['page']);
     // False means no permissions to see comments.
     if ($comments === false) {
         throw new moodle_exception('nopermissions', 'error', '', 'view comments');
     }
     foreach ($comments as $key => $comment) {
         list($comments[$key]->content, $comments[$key]->format) = external_format_text($comment->content, $comment->format, $context->id, $params['component'], '', 0);
     }
     $results = array('comments' => $comments, 'warnings' => $warnings);
     return $results;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:37,代码来源:external.php

示例2: array

                echo json_encode($result);
                die;
            }
        }
        break;
    case 'delete':
        $comment_record = $DB->get_record('comments', array('id' => $commentid));
        if ($manager->can_delete($commentid) || $comment_record->userid == $USER->id) {
            if ($manager->delete($commentid)) {
                $result = array('client_id' => $client_id, 'commentid' => $commentid);
                echo json_encode($result);
                die;
            }
        }
        break;
    case 'get':
    default:
        if ($manager->can_view()) {
            $comments = $manager->get_comments($page);
            $result = array('list' => $comments, 'count' => $manager->count(), 'pagination' => $manager->get_pagination($page), 'client_id' => $client_id);
            echo json_encode($result);
            die;
        }
        break;
}
if (!isloggedin()) {
    // tell user to log in to view comments
    echo json_encode(array('error' => 'require_login'));
}
// ignore request
die;
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:comment_ajax.php

示例3: util_get_comments_array

 function util_get_comments_array($entity, $id, $options = array())
 {
     global $TPL;
     $current_user =& singleton("current_user");
     $rows = array();
     $new_rows = array();
     // Need to get timeSheet comments too for task comments
     if ($entity == "task") {
         $rows = comment::get_comments($entity, $id);
         has("time") and $rows2 = timeSheetItem::get_timeSheetItemComments($id);
         $rows or $rows = array();
         $rows2 or $rows2 = array();
         $rows = array_merge($rows, $rows2);
         if (is_array($rows)) {
             usort($rows, array("comment", "sort_task_comments_callback_func"));
         }
     } else {
         $rows = comment::get_comments($entity, $id);
     }
     $e = new $entity();
     $e->set_id($id);
     $e->select();
     $all_parties = $e->get_all_parties();
     foreach ((array) $rows as $v) {
         unset($children);
         foreach ((array) $v["children"] as $c) {
             $children[] = comment::get_one_comment_array($c, $all_parties);
         }
         $children and $v["children"] = $children;
         $new_rows[] = comment::get_one_comment_array($v, $all_parties);
     }
     return (array) $new_rows;
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:33,代码来源:comment.inc.php

示例4: array

                    }
                }
            }
        }
        break;
    case 'delete':
        $result = $comment->delete($commentid);
        if ($result === true) {
            echo json_encode(array('client_id' => $client_id, 'commentid' => $commentid));
        } else {
            if ($result == COMMENT_ERROR_INSUFFICIENT_CAPS) {
                $err->error = get_string('nopermissiontoeditcomment');
                echo json_encode($err);
            } else {
                if ($result == COMMENT_ERROR_DB) {
                    $err->error = get_string('dbupdatefailed');
                    echo json_encode($err);
                }
            }
        }
        break;
    case 'get':
    default:
        $ret = array();
        $comments = $comment->get_comments($page);
        $ret['list'] = $comments;
        $ret['pagination'] = $comment->get_pagination($page);
        $ret['client_id'] = $client_id;
        echo json_encode($ret);
        exit;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:comment_ajax.php

示例5:

	case "quotes-authors-%author%-%quote_id%":
 		$quotes_temp = quote::get_quotes(array(
			"q_id" => $a_path[3]
		));
    $context["quotes"] = $quotes_temp;

		if (strlen($quotes_temp[0]["author_born_death"])>0)
		{
			$author_born_death = " (" . $quotes_temp[0]["author_born_death"] . ")";
		}
		$context["h1"] = $quotes_temp[0]["author_name"] . " " . $context["labels"]["quotes_clean"];
		$context["fake_h1"] = $quotes_temp[0]["author_name"] . $author_born_death;
		$context["profession"] = $quotes_temp[0]["author_profession_parsed"];
		$context["title"] = $quotes_temp[0]["author_name_wo_brackets"] . " " . $context["labels"]["quotes_clean"];
    $context["keywords"] = $smarty_q->tpl_vars['keywords']->value . ", " . tag::get_keywords_for_author_meta_description($a_path[2], $quotes_temp);
    $context["comments"] = comment::get_comments(array("quote_id"=>$a_path[3]));

    /*
		$quotes_temp = quote::get_quotes(array(
			"q_id" => $a_path[3]
		));
		$smarty_q->assign("quotes", $quotes_temp);
		if (strlen($quotes_temp[0]["author_born_death"])>0)
		{
			$author_born_death = " (" . $quotes_temp[0]["author_born_death"] . ")";
		}
		$smarty_q->assign("h1", $quotes_temp[0]["author_name"] . " " . _("quotes"));
		$smarty_q->assign("fake_h1", $quotes_temp[0]["author_name"] . $author_born_death);
		$smarty_q->assign("profession",  $quotes_temp[0]["author_profession_parsed"]);
		$smarty_q->assign ("title", $quotes_temp[0]["author_name_wo_brackets"] . " " . _("quotes"));
		$smarty_q->assign("googlead01_position", quote::get_googlead01_position($quotes_temp));
开发者ID:hkirsman,项目名称:tsitaat_com,代码行数:31,代码来源:index.php


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