135 public static function handleEvent($a_event,
ilWikiPage $a_page_obj, $a_user_id = null, array $a_additional_data = null)
144 if (!$a_user_id || $a_user_id == ANONYMOUS_USER_ID) {
148 switch ((
int) $a_event) {
149 case self::EVENT_PAGE_CREATED:
150 self::handlePageCreated($a_page_obj, $a_user_id);
153 case self::EVENT_PAGE_UPDATED:
154 self::handlePageUpdated($a_page_obj, $a_user_id, $a_additional_data);
157 case self::EVENT_PAGE_READ:
158 self::handlePageRead($a_page_obj, $a_user_id);
161 case self::EVENT_PAGE_DELETED:
162 self::handlePageDeletion($a_page_obj, $a_user_id);
165 case self::EVENT_PAGE_RATING:
166 self::handlePageRating($a_page_obj, $a_user_id);
181 return date(
"Y-m-d H:00:00");
194 protected static function writeData($a_table, array $a_primary, array $a_values)
198 $ilDB = $DIC->database();
200 $tstamp = self::getTimestamp();
201 $a_primary[
"ts"] = array(
"timestamp", $tstamp);
203 $ilAtomQuery =
$ilDB->buildAtomQuery();
204 $ilAtomQuery->addTableLock($a_table);
206 $ilAtomQuery->addQueryCallable(
207 function (
ilDBInterface $ilDB) use ($a_table, $a_primary, $a_values, $tstamp, &$is_update) {
209 foreach ($a_primary as $column => $value) {
210 $primary[] = $column .
" = " . $ilDB->
quote($value[1], $value[0]);
212 $primary = implode(
" AND ", $primary);
214 $set = $ilDB->
query(
"SELECT ts FROM " . $a_table .
215 " WHERE " . $primary);
217 $is_update = (bool) $ilDB->
numRows($set);
222 foreach ($a_values as $column => $value) {
223 if ($value[0] ==
"increment") {
224 $values[] = $column .
" = " . $column .
"+1";
225 } elseif ($value[0] ==
"decrement") {
226 $values[] = $column .
" = " . $column .
"-1";
228 $values[] = $column .
" = " . $ilDB->
quote($value[1], $value[0]);
233 $sql =
"UPDATE " . $a_table .
235 " WHERE " . $primary;
239 $a_values = array_merge($a_primary, $a_values);
240 $a_values[
"ts_day"] = array(
"text", substr($tstamp, 0, 10));
241 $a_values[
"ts_hour"] = array(
"integer", (
int) substr($tstamp, 11, 2));
244 foreach ($a_values as $column => $value) {
246 if ($value[0] ==
"increment") {
247 $value[0] =
"integer";
248 } elseif ($value[0] ==
"decrement") {
249 $value[0] =
"integer";
257 $sql =
"INSERT INTO " . $a_table .
275 protected static function writeStat($a_wiki_id, $a_values)
278 "wiki_id" => array(
"integer", $a_wiki_id)
280 self::writeData(
"wiki_stat", $primary, $a_values);
293 "wiki_id" => array(
"integer", $a_wiki_id),
294 "page_id" => array(
"integer", $a_page_id),
296 self::writeData(
"wiki_stat_page", $primary, $a_values);
310 "wiki_id" => array(
"integer", $a_wiki_id),
311 "page_id" => array(
"integer", $a_page_id),
312 "user_id" => array(
"integer", $a_user_id)
314 self::writeData(
"wiki_stat_page_user", $primary, $a_values);
327 "wiki_id" => array(
"integer", $a_wiki_id),
328 "user_id" => array(
"integer", $a_user_id)
330 self::writeData(
"wiki_stat_user", $primary, $a_values);
353 include_once
"Services/Rating/classes/class.ilRating.php";
382 "num_pages" => array(
"integer", self::countPages($a_page_obj->
getWikiId())),
383 "del_pages" => array(
"integer", 0),
384 "avg_rating" => array(
"integer", 0)
393 "new_pages" => array(
"increment", 1)
408 self::writeStatPageUser(
410 $a_page_obj->
getId(),
413 "changes" => array(
"increment", 1)
419 "int_links" => array(
"integer", $a_page_data[
"int_links"]),
420 "ext_links" => array(
"integer", $a_page_data[
"ext_links"]),
421 "footnotes" => array(
"integer", $a_page_data[
"footnotes"]),
422 "num_words" => array(
"integer", $a_page_data[
"num_words"]),
423 "num_chars" => array(
"integer", $a_page_data[
"num_chars"]),
424 "num_ratings" => array(
"integer", 0),
425 "avg_rating" => array(
"integer", 0)
439 self::writeStatPageUser(
441 $a_page_obj->
getId(),
444 "read_events" => array(
"increment", 1)
459 $ilDB = $DIC->database();
463 " FROM wiki_stat_page" .
464 " WHERE wiki_id = " .
$ilDB->quote($a_page_obj->
getWikiId(),
"integer") .
465 " AND page_id = " .
$ilDB->quote($a_page_obj->
getId(),
"integer") .
468 $set =
$ilDB->query($sql);
471 if (
$ilDB->numRows($set)) {
476 "int_links" => array(
"integer",
$data[
"int_links"]),
477 "ext_links" => array(
"integer",
$data[
"ext_links"]),
478 "footnotes" => array(
"integer",
$data[
"footnotes"]),
479 "num_words" => array(
"integer",
$data[
"num_words"]),
480 "num_chars" => array(
"integer",
$data[
"num_chars"]),
481 "num_ratings" => array(
"integer",
$data[
"num_ratings"]),
482 "avg_rating" => array(
"integer",
$data[
"avg_rating"]),
488 $ilDB->manipulate(
"UPDATE wiki_stat_page" .
489 " SET deleted = " .
$ilDB->quote(1,
"integer") .
490 " WHERE page_id = " .
$ilDB->quote($a_page_obj->
getId(),
"integer") .
491 " AND wiki_id = " .
$ilDB->quote($a_page_obj->
getWikiId(),
"integer"));
494 $rating = self::getAverageRating($a_page_obj->
getWikiId());
498 "del_pages" => array(
"increment", 1),
499 "num_pages" => array(
"integer", self::countPages($a_page_obj->
getWikiId())),
500 "avg_rating" => array(
"integer", $rating[
"avg"] * 100)
514 $rating = self::getAverageRating($a_page_obj->
getWikiId(), $a_page_obj->
getId());
519 $a_page_obj->
getId(),
521 "num_ratings" => array(
"integer", $rating[
"cnt"]),
522 "avg_rating" => array(
"integer", $rating[
"avg"] * 100),
526 $rating = self::getAverageRating($a_page_obj->
getWikiId());
529 $is_update = self::writeStat(
532 "avg_rating" => array(
"integer", $rating[
"avg"] * 100)
541 "num_pages" => array(
"integer", self::countPages($a_page_obj->
getWikiId()))
552 protected static function getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, $a_table, $a_field, $a_aggr_value, $a_sub_field = null, $a_sub_id = null, $a_build_full_period =
false)
556 $ilDB = $DIC->database();
561 $sql =
"SELECT ts_day, " . sprintf($a_aggr_value, $a_field) .
" " . $a_field;
562 if ($a_table ==
"wiki_stat_page" && $a_sub_field) {
563 $sql .=
", MAX(deleted) deleted";
565 $sql .=
" FROM " . $a_table .
566 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
567 " AND ts_day >= " .
$ilDB->quote($a_day_from,
"text") .
568 " AND ts_day <= " .
$ilDB->quote($a_day_to,
"text");
569 if (!$a_build_full_period) {
571 $sql .=
" AND " . $a_field .
" > " .
$ilDB->quote(0,
"integer") .
572 " AND " . $a_field .
" IS NOT NULL";
575 $sql .=
" AND " . $a_sub_field .
" = " .
$ilDB->quote($a_sub_id,
"integer");
577 $sql .=
" GROUP BY ts_day" .
579 $set =
$ilDB->query($sql);
581 $res[
$row[
"ts_day"]] = $row[$a_field];
583 $deleted = max($row[
"deleted"], $deleted);
586 if ($a_build_full_period) {
587 $period_first = $a_day_from;
588 $period_last = $a_day_to;
591 if ($a_table ==
"wiki_stat_page" && $a_sub_field && $deleted) {
592 $sql =
"SELECT MAX(ts_day) last_day, MIN(ts_day) first_day" .
593 " FROM " . $a_table .
594 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
595 " AND " . $a_sub_field .
" = " .
$ilDB->quote($a_sub_id,
"integer");
596 $set =
$ilDB->query($sql);
598 $last_day =
$row[
"last_day"];
599 if ($last_day < $period_last) {
600 $period_last = $last_day;
602 $first_day =
$row[
"first_day"];
603 if ($first_day > $period_first) {
604 $period_first = $first_day;
608 $last_before_period = null;
609 if (!
$res[$a_day_from]) {
610 $last_before_period = self::getWikiLast($a_wiki_id, $a_day_from, $a_table, $a_field, $a_sub_field, $a_sub_id);
614 self::buildFullPeriodData(
$res, $period_first, $period_last, $last_before_period);
620 protected static function getWikiLast($a_wiki_id, $a_day_from, $a_table, $a_field, $a_sub_field = null, $a_sub_id = null)
624 $ilDB = $DIC->database();
627 $sql =
"SELECT MAX(" . $a_field .
") latest" .
628 " FROM " . $a_table .
629 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
630 " AND ts_day < " .
$ilDB->quote($a_day_from,
"text");
632 $sql .=
" AND " . $a_sub_field .
" = " .
$ilDB->quote($a_sub_id,
"integer");
634 $sql .=
" GROUP BY ts_day" .
635 " ORDER BY ts_day DESC";
637 $set =
$ilDB->query($sql);
638 $last_before_period =
$ilDB->fetchAssoc($set);
639 return $last_before_period[
"latest"];
642 protected static function getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to, $a_table, $a_field, $a_aggr_by, $a_aggr_value, $a_aggr_sub, $a_sub_field = null, $a_sub_id = null, $a_build_full_period =
false)
646 $ilDB = $DIC->database();
650 if (!$a_build_full_period) {
651 $sql =
"SELECT ts_day, " . sprintf($a_aggr_value, $a_field) .
" " . $a_field .
654 " SELECT ts_day, " . sprintf($a_aggr_sub, $a_field) .
" " . $a_field .
655 " FROM " . $a_table .
656 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
657 " AND ts_day >= " .
$ilDB->quote($a_day_from,
"text") .
658 " AND ts_day <= " .
$ilDB->quote($a_day_to,
"text") .
659 " AND " . $a_field .
" > " .
$ilDB->quote(0,
"integer") .
660 " AND " . $a_field .
" IS NOT NULL";
662 $sql .=
" AND " . $a_sub_field .
" = " .
$ilDB->quote($a_sub_id,
"integer");
664 $sql .=
" GROUP BY ts_day, " . $a_aggr_by .
668 $set =
$ilDB->query($sql);
670 $res[
$row[
"ts_day"]] = $row[$a_field];
673 $tmp = $all_aggr_ids = $deleted_in_period = $first_day_in_period = array();
675 if ($a_table !=
"wiki_stat_page") {
676 echo "can only build full period averages for wiki_stat_page";
683 " SELECT " . $a_aggr_by .
", MAX(deleted) deleted, MAX(ts_day) last_day, MIN(ts_day) first_day" .
684 " FROM " . $a_table .
685 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
686 " GROUP BY " . $a_aggr_by .
688 " WHERE first_day <= " .
$ilDB->quote($a_day_to,
"text") .
689 " AND (last_day >= " .
$ilDB->quote($a_day_from,
"text") .
690 " OR deleted = " .
$ilDB->quote(0,
"integer") .
")";
691 $set =
$ilDB->query($sql);
693 $all_aggr_ids[] =
$row[$a_aggr_by];
696 if (
$row[
"deleted"] &&
$row[
"last_day"] < $a_day_to) {
697 $deleted_in_period[
$row[$a_aggr_by]] = $row[
"last_day"];
700 if (
$row[
"first_day"] > $a_day_from) {
701 $first_day_in_period[
$row[$a_aggr_by]] = $row[
"first_day"];
706 $sql =
" SELECT ts_day, " . $a_aggr_by .
", " . sprintf($a_aggr_sub, $a_field) .
" " . $a_field .
707 " FROM " . $a_table .
708 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
709 " AND ts_day >= " .
$ilDB->quote($a_day_from,
"text") .
710 " AND ts_day <= " .
$ilDB->quote($a_day_to,
"text");
711 $sql .=
" GROUP BY ts_day, " . $a_aggr_by;
712 $set =
$ilDB->query($sql);
714 if (!in_array(
$row[$a_aggr_by], $all_aggr_ids)) {
715 var_dump(
"unexpected wiki_stat_page_entry",
$row);
717 $tmp[
$row[$a_aggr_by]][
$row[
"ts_day"]] = $row[$a_field];
721 foreach ($all_aggr_ids as $aggr_by_id) {
723 if (!is_array($tmp[$aggr_by_id])) {
724 $tmp[$aggr_by_id] = array();
728 $last_before_period = null;
729 if (!$tmp[$aggr_by_id][$a_day_from]) {
730 $last_before_period = self::getWikiLast($a_wiki_id, $a_day_from, $a_table, $a_field, $a_aggr_by, $aggr_by_id);
734 $first_period_day = isset($first_day_in_period[$aggr_by_id])
735 ? $first_day_in_period[$aggr_by_id]
739 $last_period_day = isset($deleted_in_period[$aggr_by_id])
740 ? $deleted_in_period[$aggr_by_id]
744 self::buildFullPeriodData($tmp[$aggr_by_id], $first_period_day, $last_period_day, $last_before_period,
true);
747 foreach ($tmp[$aggr_by_id] as $day => $value) {
748 $res[$day][$aggr_by_id] = $value;
754 switch ($a_aggr_value) {
764 var_dump(
"unsupport aggr " . $a_aggr_value);
773 protected static function buildFullPeriodData(array &$a_res, $a_day_from, $a_day_to, $a_last_before_period, $a_allow_zero =
false)
778 $today = date(
"Y-m-d");
779 $current = explode(
"-", $a_day_from);
784 if ($current <= $today) {
786 if ($last !== null) {
790 elseif ($a_last_before_period || $a_allow_zero) {
791 $a_res[
$current] = $a_last_before_period;
798 $current = explode(
"-", $current);
799 $current = date(
"Y-m-d", mktime(0, 0, 1, $current[1], $current[2] + 1, $current[0]));
810 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat",
"num_pages",
"MAX(%s)", null, null,
true);
815 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_user",
"new_pages",
"SUM(%s)");
820 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_user",
"new_pages",
"user_id",
"AVG(%s)",
"SUM(%s)");
825 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat",
"del_pages",
"SUM(%s)");
830 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page_user",
"read_events",
"SUM(%s)");
837 $ilDB = $DIC->database();
841 $sql =
"SELECT ts_day, COUNT(DISTINCT(page_id)) num_changed_pages" .
842 " FROM wiki_stat_page_user" .
843 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
844 " AND ts_day >= " .
$ilDB->quote($a_day_from,
"text") .
845 " AND ts_day <= " .
$ilDB->quote($a_day_to,
"text") .
846 " AND changes > " .
$ilDB->quote(0,
"integer") .
847 " AND changes IS NOT NULL" .
850 $set =
$ilDB->query($sql);
852 $res[
$row[
"ts_day"]] = $row[
"num_changed_pages"];
862 $ilDB = $DIC->database();
866 $sql =
"SELECT ts_day, AVG(num_changed_pages) num_changed_pages" .
869 " SELECT ts_day, COUNT(DISTINCT(page_id)) num_changed_pages" .
870 " FROM wiki_stat_page_user" .
871 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
872 " AND ts_day >= " .
$ilDB->quote($a_day_from,
"text") .
873 " AND ts_day <= " .
$ilDB->quote($a_day_to,
"text") .
874 " AND changes > " .
$ilDB->quote(0,
"integer") .
875 " AND changes IS NOT NULL" .
876 " GROUP BY ts_day, user_id" .
880 $set =
$ilDB->query($sql);
882 $res[
$row[
"ts_day"]] = $row[
"num_changed_pages"];
888 protected static function getWikiUserEditPages($a_wiki_id, $a_day_from, $a_day_to, $a_sub_field = null, $a_sub_id = null)
892 $ilDB = $DIC->database();
896 $sql =
"SELECT ts_day, COUNT(DISTINCT(user_id)) num_changed_users" .
897 " FROM wiki_stat_page_user" .
898 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
899 " AND ts_day >= " .
$ilDB->quote($a_day_from,
"text") .
900 " AND ts_day <= " .
$ilDB->quote($a_day_to,
"text") .
901 " AND changes > " .
$ilDB->quote(0,
"integer") .
902 " AND changes IS NOT NULL";
904 $sql .=
" AND " . $a_sub_field .
" = " .
$ilDB->quote($a_sub_id,
"integer");
906 $sql .=
" GROUP BY ts_day" .
908 $set =
$ilDB->query($sql);
910 $res[
$row[
"ts_day"]] = $row[
"num_changed_users"];
920 $ilDB = $DIC->database();
924 $sql =
"SELECT ts_day, AVG(num_changed_users) num_changed_users" .
927 " SELECT ts_day, COUNT(DISTINCT(user_id)) num_changed_users" .
928 " FROM wiki_stat_page_user" .
929 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
930 " AND ts_day >= " .
$ilDB->quote($a_day_from,
"text") .
931 " AND ts_day <= " .
$ilDB->quote($a_day_to,
"text") .
932 " AND changes > " .
$ilDB->quote(0,
"integer") .
933 " AND changes IS NOT NULL" .
934 " GROUP BY ts_day, page_id" .
938 $set =
$ilDB->query($sql);
940 $res[
$row[
"ts_day"]] = $row[
"num_changed_users"];
948 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_ratings",
"SUM(%s)");
953 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_ratings",
"page_id",
"AVG(%s)",
"SUM(%s)");
958 $res = self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat",
"avg_rating",
"AVG(%s)");
960 foreach (array_keys(
$res) as $day) {
970 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"int_links",
"page_id",
"SUM(%s)",
"MAX(%s)", null, null,
true);
975 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"int_links",
"page_id",
"AVG(%s)",
"MAX(%s)", null, null,
true);
980 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"ext_links",
"page_id",
"SUM(%s)",
"MAX(%s)", null, null,
true);
985 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"ext_links",
"page_id",
"AVG(%s)",
"MAX(%s)", null, null,
true);
988 protected static function getWikiWords($a_wiki_id, $a_day_from, $a_day_to)
990 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_words",
"page_id",
"SUM(%s)",
"MAX(%s)", null, null,
true);
995 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_words",
"page_id",
"AVG(%s)",
"MAX(%s)", null, null,
true);
1000 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_chars",
"page_id",
"SUM(%s)",
"MAX(%s)", null, null,
true);
1005 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_chars",
"page_id",
"AVG(%s)",
"MAX(%s)", null, null,
true);
1010 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"footnotes",
"page_id",
"SUM(%s)",
"MAX(%s)", null, null,
true);
1015 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"footnotes",
"page_id",
"AVG(%s)",
"MAX(%s)", null, null,
true);
1025 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page_user",
"changes",
"SUM(%s)",
"page_id", $a_page_id);
1030 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page_user",
"changes",
"user_id",
"AVG(%s)",
"SUM(%s)",
"page_id", $a_page_id);
1035 return self::getWikiUserEditPages($a_wiki_id, $a_day_from, $a_day_to,
"page_id", $a_page_id);
1040 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page_user",
"read_events",
"SUM(%s)",
"page_id", $a_page_id);
1045 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"int_links",
"MAX(%s)",
"page_id", $a_page_id,
true);
1050 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"ext_links",
"MAX(%s)",
"page_id", $a_page_id,
true);
1055 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_words",
"MAX(%s)",
"page_id", $a_page_id,
true);
1060 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_chars",
"MAX(%s)",
"page_id", $a_page_id,
true);
1065 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"footnotes",
"MAX(%s)",
"page_id", $a_page_id,
true);
1070 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to,
"wiki_stat_page",
"num_ratings",
"SUM(%s)",
"page_id", $a_page_id);
1082 $ilDB = $DIC->database();
1087 $set =
$ilDB->query(
"SELECT DISTINCT(SUBSTR(ts_day, 1, 7)) " .
$ilDB->quoteIdentifier(
"month") .
1088 " FROM wiki_stat_page_user" .
1089 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
1090 " AND ts_day IS NOT NULL");
1091 while (
$row =
$ilDB->fetchAssoc($set)) {
1101 self::KEY_FIGURE_WIKI_NUM_PAGES
1102 ,self::KEY_FIGURE_WIKI_NEW_PAGES
1103 ,self::KEY_FIGURE_WIKI_NEW_PAGES_AVG
1104 ,self::KEY_FIGURE_WIKI_EDIT_PAGES
1105 ,self::KEY_FIGURE_WIKI_EDIT_PAGES_AVG
1106 ,self::KEY_FIGURE_WIKI_DELETED_PAGES
1107 ,self::KEY_FIGURE_WIKI_READ_PAGES
1108 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES
1109 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG
1110 ,self::KEY_FIGURE_WIKI_NUM_RATING
1111 ,self::KEY_FIGURE_WIKI_NUM_RATING_AVG
1112 ,self::KEY_FIGURE_WIKI_RATING_AVG
1113 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS
1114 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG
1115 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS
1116 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG
1117 ,self::KEY_FIGURE_WIKI_WORDS
1118 ,self::KEY_FIGURE_WIKI_WORDS_AVG
1119 ,self::KEY_FIGURE_WIKI_CHARS
1120 ,self::KEY_FIGURE_WIKI_CHARS_AVG
1121 ,self::KEY_FIGURE_WIKI_FOOTNOTES
1122 ,self::KEY_FIGURE_WIKI_FOOTNOTES_AVG
1129 self::KEY_FIGURE_WIKI_PAGE_CHANGES
1130 ,self::KEY_FIGURE_WIKI_PAGE_CHANGES_AVG
1131 ,self::KEY_FIGURE_WIKI_PAGE_USER_EDIT
1132 ,self::KEY_FIGURE_WIKI_PAGE_READ
1133 ,self::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS
1134 ,self::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS
1135 ,self::KEY_FIGURE_WIKI_PAGE_WORDS
1136 ,self::KEY_FIGURE_WIKI_PAGE_CHARS
1137 ,self::KEY_FIGURE_WIKI_PAGE_FOOTNOTES
1138 ,self::KEY_FIGURE_WIKI_PAGE_RATINGS
1146 $lng = $DIC->language();
1150 self::KEY_FIGURE_WIKI_NUM_PAGES =>
$lng->txt(
"wiki_stat_num_pages")
1151 ,self::KEY_FIGURE_WIKI_NEW_PAGES =>
$lng->txt(
"wiki_stat_new_pages")
1152 ,self::KEY_FIGURE_WIKI_NEW_PAGES_AVG =>
$lng->txt(
"wiki_stat_new_pages_avg")
1153 ,self::KEY_FIGURE_WIKI_EDIT_PAGES =>
$lng->txt(
"wiki_stat_edit_pages")
1154 ,self::KEY_FIGURE_WIKI_EDIT_PAGES_AVG =>
$lng->txt(
"wiki_stat_edit_pages_avg")
1155 ,self::KEY_FIGURE_WIKI_DELETED_PAGES =>
$lng->txt(
"wiki_stat_deleted_pages")
1156 ,self::KEY_FIGURE_WIKI_READ_PAGES =>
$lng->txt(
"wiki_stat_read_pages")
1157 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES =>
$lng->txt(
"wiki_stat_user_edit_pages")
1158 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG =>
$lng->txt(
"wiki_stat_user_edit_pages_avg")
1159 ,self::KEY_FIGURE_WIKI_NUM_RATING =>
$lng->txt(
"wiki_stat_num_rating")
1160 ,self::KEY_FIGURE_WIKI_NUM_RATING_AVG =>
$lng->txt(
"wiki_stat_num_rating_avg")
1161 ,self::KEY_FIGURE_WIKI_RATING_AVG =>
$lng->txt(
"wiki_stat_rating_avg")
1162 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS =>
$lng->txt(
"wiki_stat_internal_links")
1163 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG =>
$lng->txt(
"wiki_stat_internal_links_avg")
1164 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS =>
$lng->txt(
"wiki_stat_external_links")
1165 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG =>
$lng->txt(
"wiki_stat_external_links_avg")
1166 ,self::KEY_FIGURE_WIKI_WORDS =>
$lng->txt(
"wiki_stat_words")
1167 ,self::KEY_FIGURE_WIKI_WORDS_AVG =>
$lng->txt(
"wiki_stat_words_avg")
1168 ,self::KEY_FIGURE_WIKI_CHARS =>
$lng->txt(
"wiki_stat_chars")
1169 ,self::KEY_FIGURE_WIKI_CHARS_AVG =>
$lng->txt(
"wiki_stat_chars_avg")
1170 ,self::KEY_FIGURE_WIKI_FOOTNOTES =>
$lng->txt(
"wiki_stat_footnotes")
1171 ,self::KEY_FIGURE_WIKI_FOOTNOTES_AVG =>
$lng->txt(
"wiki_stat_footnotes_avg")
1173 ,self::KEY_FIGURE_WIKI_PAGE_CHANGES =>
$lng->txt(
"wiki_stat_page_changes")
1174 ,self::KEY_FIGURE_WIKI_PAGE_CHANGES_AVG =>
$lng->txt(
"wiki_stat_page_changes_avg")
1175 ,self::KEY_FIGURE_WIKI_PAGE_USER_EDIT =>
$lng->txt(
"wiki_stat_page_user_edit")
1176 ,self::KEY_FIGURE_WIKI_PAGE_READ =>
$lng->txt(
"wiki_stat_page_read")
1177 ,self::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS =>
$lng->txt(
"wiki_stat_page_internal_links")
1178 ,self::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS =>
$lng->txt(
"wiki_stat_page_external_links")
1179 ,self::KEY_FIGURE_WIKI_PAGE_WORDS =>
$lng->txt(
"wiki_stat_page_words")
1180 ,self::KEY_FIGURE_WIKI_PAGE_CHARS =>
$lng->txt(
"wiki_stat_page_characters")
1181 ,self::KEY_FIGURE_WIKI_PAGE_FOOTNOTES =>
$lng->txt(
"wiki_stat_page_footnotes")
1182 ,self::KEY_FIGURE_WIKI_PAGE_RATINGS =>
$lng->txt(
"wiki_stat_page_ratings")
1185 return $map[$a_figure];
1190 switch ($a_figure) {
1191 case self::KEY_FIGURE_WIKI_NUM_PAGES:
1192 return self::getWikiNumPages($a_wiki_id, $a_from, $a_to);
1194 case self::KEY_FIGURE_WIKI_NEW_PAGES:
1195 return self::getWikiNewPagesSum($a_wiki_id, $a_from, $a_to);
1197 case self::KEY_FIGURE_WIKI_NEW_PAGES_AVG:
1198 return self::getWikiNewPagesAvg($a_wiki_id, $a_from, $a_to);
1200 case self::KEY_FIGURE_WIKI_EDIT_PAGES:
1201 return self::getWikiEditPagesSum($a_wiki_id, $a_from, $a_to);
1203 case self::KEY_FIGURE_WIKI_EDIT_PAGES_AVG:
1204 return self::getWikiEditPagesAvg($a_wiki_id, $a_from, $a_to);
1206 case self::KEY_FIGURE_WIKI_DELETED_PAGES:
1207 return self::getWikiDeletedPages($a_wiki_id, $a_from, $a_to);
1209 case self::KEY_FIGURE_WIKI_READ_PAGES:
1210 return self::getWikiReadPages($a_wiki_id, $a_from, $a_to);
1212 case self::KEY_FIGURE_WIKI_USER_EDIT_PAGES:
1213 return self::getWikiUserEditPages($a_wiki_id, $a_from, $a_to);
1215 case self::KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG:
1216 return self::getWikiUserEditPages($a_wiki_id, $a_from, $a_to);
1218 case self::KEY_FIGURE_WIKI_NUM_RATING:
1219 return self::getWikiNumRating($a_wiki_id, $a_from, $a_to);
1221 case self::KEY_FIGURE_WIKI_NUM_RATING_AVG:
1222 return self::getWikiNumRatingAvg($a_wiki_id, $a_from, $a_to);
1224 case self::KEY_FIGURE_WIKI_RATING_AVG:
1225 return self::getWikiRatingAvg($a_wiki_id, $a_from, $a_to);
1227 case self::KEY_FIGURE_WIKI_INTERNAL_LINKS:
1228 return self::getWikiInternalLinks($a_wiki_id, $a_from, $a_to);
1230 case self::KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG:
1231 return self::getWikiInternalLinksAvg($a_wiki_id, $a_from, $a_to);
1233 case self::KEY_FIGURE_WIKI_EXTERNAL_LINKS:
1234 return self::getWikiExternalLinks($a_wiki_id, $a_from, $a_to);
1236 case self::KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG:
1237 return self::getWikiExternalLinksAvg($a_wiki_id, $a_from, $a_to);
1239 case self::KEY_FIGURE_WIKI_WORDS:
1240 return self::getWikiWords($a_wiki_id, $a_from, $a_to);
1242 case self::KEY_FIGURE_WIKI_WORDS_AVG:
1243 return self::getWikiWordsAvg($a_wiki_id, $a_from, $a_to);
1245 case self::KEY_FIGURE_WIKI_CHARS:
1246 return self::getWikiCharacters($a_wiki_id, $a_from, $a_to);
1248 case self::KEY_FIGURE_WIKI_CHARS_AVG:
1249 return self::getWikiCharactersAvg($a_wiki_id, $a_from, $a_to);
1251 case self::KEY_FIGURE_WIKI_FOOTNOTES:
1252 return self::getWikiFootnotes($a_wiki_id, $a_from, $a_to);
1254 case self::KEY_FIGURE_WIKI_FOOTNOTES_AVG:
1255 return self::getWikiFootnotesAvg($a_wiki_id, $a_from, $a_to);
1261 switch ($a_figure) {
1262 case self::KEY_FIGURE_WIKI_PAGE_CHANGES:
1263 return self::getWikiPageChanges($a_wiki_id, $a_page_id, $a_from, $a_to);
1265 case self::KEY_FIGURE_WIKI_PAGE_CHANGES_AVG:
1266 return self::getWikiPageChangesAvg($a_wiki_id, $a_page_id, $a_from, $a_to);
1268 case self::KEY_FIGURE_WIKI_PAGE_USER_EDIT:
1269 return self::getWikiPageUserEdit($a_wiki_id, $a_page_id, $a_from, $a_to);
1271 case self::KEY_FIGURE_WIKI_PAGE_READ:
1272 return self::getWikiPageRead($a_wiki_id, $a_page_id, $a_from, $a_to);
1274 case self::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS:
1275 return self::getWikiPageInternalLinks($a_wiki_id, $a_page_id, $a_from, $a_to);
1277 case self::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS:
1278 return self::getWikiPageExternalLinks($a_wiki_id, $a_page_id, $a_from, $a_to);
1280 case self::KEY_FIGURE_WIKI_PAGE_FOOTNOTES:
1281 return self::getWikiPageFootnotes($a_wiki_id, $a_page_id, $a_from, $a_to);
1283 case self::KEY_FIGURE_WIKI_PAGE_WORDS:
1284 return self::getWikiPageWords($a_wiki_id, $a_page_id, $a_from, $a_to);
1286 case self::KEY_FIGURE_WIKI_PAGE_CHARS:
1287 return self::getWikiPageCharacters($a_wiki_id, $a_page_id, $a_from, $a_to);
1289 case self::KEY_FIGURE_WIKI_PAGE_RATINGS:
1290 return self::getWikiPageRatings($a_wiki_id, $a_page_id, $a_from, $a_to);
1298 foreach (self::getFigures() as $figure) {
1299 $res[$figure] = self::getFigureTitle($figure);
1309 foreach (self::getFiguresPage() as $figure) {
1310 $res[$figure] = self::getFigureTitle($figure);
const KEY_FIGURE_WIKI_PAGE_USER_EDIT
static getWikiInternalLinksAvg($a_wiki_id, $a_day_from, $a_day_to)
static getWikiWords($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_NUM_RATING
const KEY_FIGURE_WIKI_WORDS
static writeStat($a_wiki_id, $a_values)
Write data to wiki_stat.
const KEY_FIGURE_WIKI_FOOTNOTES
const KEY_FIGURE_WIKI_USER_EDIT_PAGES
static getWikiPageChanges($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_PAGE_RATINGS
getWikiId()
Get Wiki Object Id.
const KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG
const KEY_FIGURE_WIKI_PAGE_READ
static getWikiFootnotesAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_FOOTNOTES_AVG
static getWikiPageWords($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiEditPagesAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_NEW_PAGES_AVG
const KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS
static getWikiExternalLinksAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_INTERNAL_LINKS
static getWikiCharacters($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_NUM_RATING_AVG
const KEY_FIGURE_WIKI_NUM_PAGES
static writeStatPageUser($a_wiki_id, $a_page_id, $a_user_id, $a_values)
Write data to wiki_stat_page_user.
static buildFullPeriodData(array &$a_res, $a_day_from, $a_day_to, $a_last_before_period, $a_allow_zero=false)
const KEY_FIGURE_WIKI_PAGE_CHARS
const KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS
static getWikiPageRead($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiLast($a_wiki_id, $a_day_from, $a_table, $a_field, $a_sub_field=null, $a_sub_id=null)
static getFigureData($a_wiki_id, $a_figure, $a_from, $a_to)
static getWikiPageRatings($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG
static getWikiUserEditPagesAvg($a_wiki_id, $a_day_from, $a_day_to)
static getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, $a_table, $a_field, $a_aggr_value, $a_sub_field=null, $a_sub_id=null, $a_build_full_period=false)
const KEY_FIGURE_WIKI_PAGE_FOOTNOTES
static getWikiDeletedPages($a_wiki_id, $a_day_from, $a_day_to)
static getWikiNewPagesAvg($a_wiki_id, $a_day_from, $a_day_to)
static getWikiRatingAvg($a_wiki_id, $a_day_from, $a_day_to)
static handlePageRead(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page read.
static getWikiPageFootnotes($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiPageUserEdit($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiExternalLinks($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_EXTERNAL_LINKS
static handlePageRating(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page rating.
static getWikiEditPagesSum($a_wiki_id, $a_day_from, $a_day_to)
static getTimestamp()
Get current time frame (hourly)
static getAverageRating($a_wiki_id, $a_page_id=null)
Get average rating for wiki or wiki page.
static getWikiNumRating($a_wiki_id, $a_day_from, $a_day_to)
static getWikiNewPagesSum($a_wiki_id, $a_day_from, $a_day_to)
static getWikiNumRatingAvg($a_wiki_id, $a_day_from, $a_day_to)
foreach($_POST as $key=> $value) $res
static getWikiPageExternalLinks($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static countPages($a_wiki_id)
Count pages in wiki.
static getFigureDataPage($a_wiki_id, $a_page_id, $a_figure, $a_from, $a_to)
static getFigureOptions()
static writeData($a_table, array $a_primary, array $a_values)
Write data to DB.
static handlePageCreated(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page creation.
const KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG
static getOverallRatingForObject($a_obj_id, $a_obj_type, $a_sub_obj_id=null, $a_sub_obj_type=null, $a_category_id=null)
Get overall rating for an object.
const KEY_FIGURE_WIKI_RATING_AVG
const KEY_FIGURE_WIKI_EDIT_PAGES_AVG
static handleEvent($a_event, ilWikiPage $a_page_obj, $a_user_id=null, array $a_additional_data=null)
Handle wiki page event.
static getWikiPageChangesAvg($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_CHARS
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.
static writeStatUser($a_wiki_id, $a_user_id, $a_values)
Write to wiki_stat_user.
static getWikiPageInternalLinks($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiNumPages($a_wiki_id, $a_day_from, $a_day_to)
static getFigureTitle($a_figure)
static getWikiReadPages($a_wiki_id, $a_day_from, $a_day_to)
static handlePageDeletion(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page deletion.
const KEY_FIGURE_WIKI_NEW_PAGES
static handlePageUpdated(ilWikiPage $a_page_obj, $a_user_id, array $a_page_data=null)
Handle wiki page update.
query($query)
Run a (read-only) Query on the database.
const KEY_FIGURE_WIKI_EDIT_PAGES
const KEY_FIGURE_WIKI_CHARS_AVG
static getWikiInternalLinks($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_PAGE_WORDS
static writeStatPage($a_wiki_id, $a_page_id, $a_values)
Write data to wiki_stat_page.
static getFigureOptionsPage()
static getWikiCharactersAvg($a_wiki_id, $a_day_from, $a_day_to)
static getWikiUserEditPages($a_wiki_id, $a_day_from, $a_day_to, $a_sub_field=null, $a_sub_id=null)
static getWikiWordsAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_READ_PAGES
const KEY_FIGURE_WIKI_WORDS_AVG
manipulate($query)
Run a (write) Query on the database.
static getWikiPageCharacters($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getAvailableMonths($a_wiki_id)
static getWikiFootnotes($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_DELETED_PAGES
const KEY_FIGURE_WIKI_PAGE_CHANGES
static getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to, $a_table, $a_field, $a_aggr_by, $a_aggr_value, $a_aggr_sub, $a_sub_field=null, $a_sub_id=null, $a_build_full_period=false)
const KEY_FIGURE_WIKI_PAGE_CHANGES_AVG