ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilWikiStat Class Reference

Wiki statistics class. More...

+ Collaboration diagram for ilWikiStat:

Static Public Member Functions

static handleEvent ($a_event, ilWikiPage $a_page_obj, $a_user_id=null, array $a_additional_data=null)
 Handle wiki page event. More...
 
static handlePageCreated (ilWikiPage $a_page_obj, $a_user_id)
 Handle wiki page creation. More...
 
static handlePageUpdated (ilWikiPage $a_page_obj, $a_user_id, array $a_page_data=null)
 Handle wiki page update. More...
 
static handlePageRead (ilWikiPage $a_page_obj, $a_user_id)
 Handle wiki page read. More...
 
static handlePageDeletion (ilWikiPage $a_page_obj, $a_user_id)
 Handle wiki page deletion. More...
 
static handlePageRating (ilWikiPage $a_page_obj, $a_user_id)
 Handle wiki page rating. More...
 
static getAvailableMonths ($a_wiki_id)
 
static getFigures ()
 
static getFiguresPage ()
 
static getFigureTitle ($a_figure)
 
static getFigureData ($a_wiki_id, $a_figure, $a_from, $a_to)
 
static getFigureDataPage ($a_wiki_id, $a_page_id, $a_figure, $a_from, $a_to)
 
static getFigureOptions ()
 
static getFigureOptionsPage ()
 

Data Fields

const EVENT_PAGE_CREATED = 1
 
const EVENT_PAGE_UPDATED = 2
 
const EVENT_PAGE_READ = 3
 
const EVENT_PAGE_DELETED = 4
 
const EVENT_PAGE_RATING = 5
 
const KEY_FIGURE_WIKI_NUM_PAGES = 1
 
const KEY_FIGURE_WIKI_NEW_PAGES = 2
 
const KEY_FIGURE_WIKI_NEW_PAGES_AVG = 3
 
const KEY_FIGURE_WIKI_EDIT_PAGES = 4
 
const KEY_FIGURE_WIKI_EDIT_PAGES_AVG = 5
 
const KEY_FIGURE_WIKI_DELETED_PAGES = 6
 
const KEY_FIGURE_WIKI_READ_PAGES = 7
 
const KEY_FIGURE_WIKI_USER_EDIT_PAGES = 8
 
const KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG = 9
 
const KEY_FIGURE_WIKI_NUM_RATING = 10
 
const KEY_FIGURE_WIKI_NUM_RATING_AVG = 11
 
const KEY_FIGURE_WIKI_RATING_AVG = 12
 
const KEY_FIGURE_WIKI_INTERNAL_LINKS = 13
 
const KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG = 14
 
const KEY_FIGURE_WIKI_EXTERNAL_LINKS = 15
 
const KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG = 16
 
const KEY_FIGURE_WIKI_WORDS = 17
 
const KEY_FIGURE_WIKI_WORDS_AVG = 18
 
const KEY_FIGURE_WIKI_CHARS = 19
 
const KEY_FIGURE_WIKI_CHARS_AVG = 20
 
const KEY_FIGURE_WIKI_FOOTNOTES = 21
 
const KEY_FIGURE_WIKI_FOOTNOTES_AVG = 22
 
const KEY_FIGURE_WIKI_PAGE_CHANGES = 23
 
const KEY_FIGURE_WIKI_PAGE_CHANGES_AVG = 24
 
const KEY_FIGURE_WIKI_PAGE_USER_EDIT = 25
 
const KEY_FIGURE_WIKI_PAGE_READ = 26
 
const KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS = 27
 
const KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS = 28
 
const KEY_FIGURE_WIKI_PAGE_WORDS = 29
 
const KEY_FIGURE_WIKI_PAGE_CHARS = 30
 
const KEY_FIGURE_WIKI_PAGE_FOOTNOTES = 31
 
const KEY_FIGURE_WIKI_PAGE_RATINGS = 32
 

Static Protected Member Functions

static getTimestamp ()
 Get current time frame (hourly) More...
 
static writeData ($a_table, array $a_primary, array $a_values)
 Write data to DB. More...
 
static writeStat ($a_wiki_id, $a_values)
 Write data to wiki_stat. More...
 
static writeStatPage ($a_wiki_id, $a_page_id, $a_values)
 Write data to wiki_stat_page. More...
 
static writeStatPageUser ($a_wiki_id, $a_page_id, $a_user_id, $a_values)
 Write data to wiki_stat_page_user. More...
 
static writeStatUser ($a_wiki_id, $a_user_id, $a_values)
 Write to wiki_stat_user. More...
 
static countPages ($a_wiki_id)
 Count pages in wiki. More...
 
static getAverageRating ($a_wiki_id, $a_page_id=null)
 Get average rating for wiki or wiki page. More...
 
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)
 
static getWikiLast ($a_wiki_id, $a_day_from, $a_table, $a_field, $a_sub_field=null, $a_sub_id=null)
 
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)
 
static buildFullPeriodData (array &$a_res, $a_day_from, $a_day_to, $a_last_before_period, $a_allow_zero=false)
 
static getWikiNumPages ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiNewPagesSum ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiNewPagesAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiDeletedPages ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiReadPages ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiEditPagesSum ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiEditPagesAvg ($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 getWikiUserEditPagesAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiNumRating ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiNumRatingAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiRatingAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiInternalLinks ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiInternalLinksAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiExternalLinks ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiExternalLinksAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiWords ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiWordsAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiCharacters ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiCharactersAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiFootnotes ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiFootnotesAvg ($a_wiki_id, $a_day_from, $a_day_to)
 
static getWikiPageChanges ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 
static getWikiPageChangesAvg ($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 getWikiPageRead ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 
static getWikiPageInternalLinks ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 
static getWikiPageExternalLinks ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 
static getWikiPageWords ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 
static getWikiPageCharacters ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 
static getWikiPageFootnotes ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 
static getWikiPageRatings ($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
 

Detailed Description

Wiki statistics class.

Timestamp / Current Record

  • If an event occurs the current timestamp is calculated, for not this is the timestamp without minuts/seconds 2014-01-14 07:34:45 -> 2014-01-14 07:00:00 (i.e. we count "per hour" and the numbers represent 07:00:00 to 07:59:59)

Table / Primary Key / Stats / Events

  • wiki_stat pk: wiki_id, timestamp
              (1) number of pages             ev: page created, page deleted
                                                              action: count pages of wiki and replace number in current record
    
              (2) deleted pages               ev: page deleted
                                                              action: increment number in current record +1
    
              (3) average rating              ev: rating saved
                                                              [action: do (10), then for current records in wiki_stat_page: sum average rating / number of records where average rating is > 0]
                                                      REVISION action: do (10), then build average rating from wiki page rating records NOT wiki_stat_page
    
  • wiki_stat_page pk: wiki_id, page_id, timestamp
              (4) internal links              ev: page saved
                                                              action: count internal links and replace number in current record
    
              (5) external links              see internal links
    
              (6) footnotes                   see internal links
    
              (7) ratings                             ev: rating saved
                                                              action: count ratings and replace number in current record
    
              (8)     words                           see internal links
    
              (9) characters                  see internal links
    
              (10) average rating             ev: rating saved
                                                              sum ratings / number of ratings (0 if no rating given)
    
  • wiki_stat_user pk: wiki_id, user_id, timestamp
              (11) new pages                  ev: page created
                                                              action: increment number of user in current record + 1
    
  • wiki_stat_page_user pk: wiki_id, page_id, user_id, timestamp
      (12) changes                    ev: page saved
                                                      action: increment number of user/page in current record + 1
    
      (13) read                               ev: page read
                                                      action: increment number of user/page in current record + 1
    

Events

  • page created (empty) (1) (11)
  • page deleted (1) (2)
  • page saved (content) (4) (5) (6) (8) (9) (12)
  • page read (13)
  • rating saved (3) (10)

Deleted pages

All historic records are kept. A current wiki_stat_page record with all values 0 is replaced/created. (?)

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.d.nosp@m.e
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 81 of file class.ilWikiStat.php.

Member Function Documentation

◆ buildFullPeriodData()

static ilWikiStat::buildFullPeriodData ( array &  $a_res,
  $a_day_from,
  $a_day_to,
  $a_last_before_period,
  $a_allow_zero = false 
)
staticprotected

Definition at line 773 of file class.ilWikiStat.php.

774 {
775 // build full data for period
776 $safety = 0;
777 $last = null;
778 $today = date("Y-m-d");
779 $current = explode("-", $a_day_from);
780 $current = date("Y-m-d", mktime(0, 0, 1, $current[1], $current[2], $current[0]));
781 while ($current <= $a_day_to &&
782 ++$safety < 1000) {
783 if (!isset($a_res[$current])) {
784 if ($current <= $today) {
785 // last existing value in period
786 if ($last !== null) {
787 $a_res[$current] = $last;
788 }
789 // last existing value before period
790 elseif ($a_last_before_period || $a_allow_zero) {
791 $a_res[$current] = $a_last_before_period;
792 }
793 }
794 } else {
795 $last = $a_res[$current];
796 }
797
798 $current = explode("-", $current);
799 $current = date("Y-m-d", mktime(0, 0, 1, $current[1], $current[2]+1, $current[0]));
800 }
801 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())

References $current, and date.

Referenced by getWikiAggr(), and getWikiAggrSub().

+ Here is the caller graph for this function:

◆ countPages()

static ilWikiStat::countPages (   $a_wiki_id)
staticprotected

Count pages in wiki.

Parameters
int$a_wiki_id
Returns
int

Definition at line 339 of file class.ilWikiStat.php.

340 {
341 return sizeof(ilWikiPage::getAllWikiPages($a_wiki_id));
342 }
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.

References ilWikiPage\getAllWikiPages().

+ Here is the call graph for this function:

◆ getAvailableMonths()

static ilWikiStat::getAvailableMonths (   $a_wiki_id)
static

Definition at line 1078 of file class.ilWikiStat.php.

1079 {
1080 global $DIC;
1081
1082 $ilDB = $DIC->database();
1083
1084 $res = array();
1085
1086 // because of read_events this db table is updated most often
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)) {
1092 $res[] = $row["month"];
1093 }
1094
1095 return $res;
1096 }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB

References $DIC, $ilDB, $res, and $row.

Referenced by ilWikiStatGUI\viewToolbar().

+ Here is the caller graph for this function:

◆ getAverageRating()

static ilWikiStat::getAverageRating (   $a_wiki_id,
  $a_page_id = null 
)
staticprotected

Get average rating for wiki or wiki page.

Parameters
int$a_wiki_id
int$a_page_id
Returns
array

Definition at line 351 of file class.ilWikiStat.php.

352 {
353 include_once "Services/Rating/classes/class.ilRating.php";
354
355 if (!$a_page_id) {
357 $a_wiki_id,
358 "wiki"
359 );
360 } else {
362 $a_wiki_id,
363 "wiki",
364 $a_page_id,
365 "wpg"
366 );
367 }
368 }
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.

References ilRating\getOverallRatingForObject().

Referenced by handlePageDeletion(), and handlePageRating().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFigureData()

static ilWikiStat::getFigureData (   $a_wiki_id,
  $a_figure,
  $a_from,
  $a_to 
)
static

Definition at line 1188 of file class.ilWikiStat.php.

1189 {
1190 switch ($a_figure) {
1192 return self::getWikiNumPages($a_wiki_id, $a_from, $a_to);
1193
1195 return self::getWikiNewPagesSum($a_wiki_id, $a_from, $a_to);
1196
1198 return self::getWikiNewPagesAvg($a_wiki_id, $a_from, $a_to);
1199
1201 return self::getWikiEditPagesSum($a_wiki_id, $a_from, $a_to);
1202
1204 return self::getWikiEditPagesAvg($a_wiki_id, $a_from, $a_to);
1205
1207 return self::getWikiDeletedPages($a_wiki_id, $a_from, $a_to);
1208
1210 return self::getWikiReadPages($a_wiki_id, $a_from, $a_to);
1211
1213 return self::getWikiUserEditPages($a_wiki_id, $a_from, $a_to);
1214
1216 return self::getWikiUserEditPages($a_wiki_id, $a_from, $a_to);
1217
1219 return self::getWikiNumRating($a_wiki_id, $a_from, $a_to);
1220
1222 return self::getWikiNumRatingAvg($a_wiki_id, $a_from, $a_to);
1223
1225 return self::getWikiRatingAvg($a_wiki_id, $a_from, $a_to);
1226
1228 return self::getWikiInternalLinks($a_wiki_id, $a_from, $a_to);
1229
1231 return self::getWikiInternalLinksAvg($a_wiki_id, $a_from, $a_to);
1232
1234 return self::getWikiExternalLinks($a_wiki_id, $a_from, $a_to);
1235
1237 return self::getWikiExternalLinksAvg($a_wiki_id, $a_from, $a_to);
1238
1240 return self::getWikiWords($a_wiki_id, $a_from, $a_to);
1241
1243 return self::getWikiWordsAvg($a_wiki_id, $a_from, $a_to);
1244
1246 return self::getWikiCharacters($a_wiki_id, $a_from, $a_to);
1247
1249 return self::getWikiCharactersAvg($a_wiki_id, $a_from, $a_to);
1250
1252 return self::getWikiFootnotes($a_wiki_id, $a_from, $a_to);
1253
1255 return self::getWikiFootnotesAvg($a_wiki_id, $a_from, $a_to);
1256 }
1257 }
static getWikiInternalLinksAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_NUM_RATING_AVG
static getWikiWordsAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_NUM_RATING
const KEY_FIGURE_WIKI_DELETED_PAGES
static getWikiDeletedPages($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_WORDS
static getWikiExternalLinks($a_wiki_id, $a_day_from, $a_day_to)
static getWikiNumRatingAvg($a_wiki_id, $a_day_from, $a_day_to)
static getWikiReadPages($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_INTERNAL_LINKS
static getWikiNewPagesSum($a_wiki_id, $a_day_from, $a_day_to)
static getWikiEditPagesAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_WORDS_AVG
const KEY_FIGURE_WIKI_READ_PAGES
static getWikiNewPagesAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_NEW_PAGES
const KEY_FIGURE_WIKI_EDIT_PAGES
const KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG
static getWikiInternalLinks($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG
static getWikiWords($a_wiki_id, $a_day_from, $a_day_to)
static getWikiEditPagesSum($a_wiki_id, $a_day_from, $a_day_to)
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)
const KEY_FIGURE_WIKI_FOOTNOTES
static getWikiExternalLinksAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_FOOTNOTES_AVG
const KEY_FIGURE_WIKI_EXTERNAL_LINKS
const KEY_FIGURE_WIKI_CHARS_AVG
static getWikiNumPages($a_wiki_id, $a_day_from, $a_day_to)
static getWikiRatingAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_USER_EDIT_PAGES
const KEY_FIGURE_WIKI_NUM_PAGES
const KEY_FIGURE_WIKI_CHARS
const KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG
static getWikiFootnotesAvg($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_NEW_PAGES_AVG
const KEY_FIGURE_WIKI_RATING_AVG
static getWikiFootnotes($a_wiki_id, $a_day_from, $a_day_to)
static getWikiCharacters($a_wiki_id, $a_day_from, $a_day_to)
static getWikiNumRating($a_wiki_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_EDIT_PAGES_AVG

References getWikiCharacters(), getWikiCharactersAvg(), getWikiDeletedPages(), getWikiEditPagesAvg(), getWikiEditPagesSum(), getWikiExternalLinks(), getWikiExternalLinksAvg(), getWikiFootnotes(), getWikiFootnotesAvg(), getWikiInternalLinks(), getWikiInternalLinksAvg(), getWikiNewPagesAvg(), getWikiNewPagesSum(), getWikiNumPages(), getWikiNumRating(), getWikiNumRatingAvg(), getWikiRatingAvg(), getWikiReadPages(), getWikiUserEditPages(), getWikiWords(), getWikiWordsAvg(), KEY_FIGURE_WIKI_CHARS, KEY_FIGURE_WIKI_CHARS_AVG, KEY_FIGURE_WIKI_DELETED_PAGES, KEY_FIGURE_WIKI_EDIT_PAGES, KEY_FIGURE_WIKI_EDIT_PAGES_AVG, KEY_FIGURE_WIKI_EXTERNAL_LINKS, KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG, KEY_FIGURE_WIKI_FOOTNOTES, KEY_FIGURE_WIKI_FOOTNOTES_AVG, KEY_FIGURE_WIKI_INTERNAL_LINKS, KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG, KEY_FIGURE_WIKI_NEW_PAGES, KEY_FIGURE_WIKI_NEW_PAGES_AVG, KEY_FIGURE_WIKI_NUM_PAGES, KEY_FIGURE_WIKI_NUM_RATING, KEY_FIGURE_WIKI_NUM_RATING_AVG, KEY_FIGURE_WIKI_RATING_AVG, KEY_FIGURE_WIKI_READ_PAGES, KEY_FIGURE_WIKI_USER_EDIT_PAGES, KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG, KEY_FIGURE_WIKI_WORDS, and KEY_FIGURE_WIKI_WORDS_AVG.

Referenced by ilWikiStatGUI\getChartData(), and ilWikiStatGUI\getListData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFigureDataPage()

static ilWikiStat::getFigureDataPage (   $a_wiki_id,
  $a_page_id,
  $a_figure,
  $a_from,
  $a_to 
)
static

Definition at line 1259 of file class.ilWikiStat.php.

1260 {
1261 switch ($a_figure) {
1263 return self::getWikiPageChanges($a_wiki_id, $a_page_id, $a_from, $a_to);
1264
1266 return self::getWikiPageChangesAvg($a_wiki_id, $a_page_id, $a_from, $a_to);
1267
1269 return self::getWikiPageUserEdit($a_wiki_id, $a_page_id, $a_from, $a_to);
1270
1272 return self::getWikiPageRead($a_wiki_id, $a_page_id, $a_from, $a_to);
1273
1275 return self::getWikiPageInternalLinks($a_wiki_id, $a_page_id, $a_from, $a_to);
1276
1278 return self::getWikiPageExternalLinks($a_wiki_id, $a_page_id, $a_from, $a_to);
1279
1281 return self::getWikiPageFootnotes($a_wiki_id, $a_page_id, $a_from, $a_to);
1282
1284 return self::getWikiPageWords($a_wiki_id, $a_page_id, $a_from, $a_to);
1285
1287 return self::getWikiPageCharacters($a_wiki_id, $a_page_id, $a_from, $a_to);
1288
1290 return self::getWikiPageRatings($a_wiki_id, $a_page_id, $a_from, $a_to);
1291 }
1292 }
const KEY_FIGURE_WIKI_PAGE_READ
static getWikiPageWords($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS
static getWikiPageInternalLinks($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiPageRatings($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_PAGE_RATINGS
static getWikiPageChangesAvg($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiPageChanges($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiPageCharacters($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_PAGE_CHANGES
const KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS
static getWikiPageUserEdit($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
const KEY_FIGURE_WIKI_PAGE_USER_EDIT
const KEY_FIGURE_WIKI_PAGE_CHANGES_AVG
const KEY_FIGURE_WIKI_PAGE_FOOTNOTES
const KEY_FIGURE_WIKI_PAGE_CHARS
const KEY_FIGURE_WIKI_PAGE_WORDS
static getWikiPageRead($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiPageExternalLinks($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)
static getWikiPageFootnotes($a_wiki_id, $a_page_id, $a_day_from, $a_day_to)

References getWikiPageChanges(), getWikiPageChangesAvg(), getWikiPageCharacters(), getWikiPageExternalLinks(), getWikiPageFootnotes(), getWikiPageInternalLinks(), getWikiPageRatings(), getWikiPageRead(), getWikiPageUserEdit(), getWikiPageWords(), KEY_FIGURE_WIKI_PAGE_CHANGES, KEY_FIGURE_WIKI_PAGE_CHANGES_AVG, KEY_FIGURE_WIKI_PAGE_CHARS, KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS, KEY_FIGURE_WIKI_PAGE_FOOTNOTES, KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS, KEY_FIGURE_WIKI_PAGE_RATINGS, KEY_FIGURE_WIKI_PAGE_READ, KEY_FIGURE_WIKI_PAGE_USER_EDIT, and KEY_FIGURE_WIKI_PAGE_WORDS.

Referenced by ilWikiStatGUI\getChartData(), and ilWikiStatGUI\getListData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFigureOptions()

static ilWikiStat::getFigureOptions ( )
static

Definition at line 1294 of file class.ilWikiStat.php.

1295 {
1296 $res = array();
1297
1298 foreach (self::getFigures() as $figure) {
1299 $res[$figure] = self::getFigureTitle($figure);
1300 }
1301
1302 return $res;
1303 }
static getFigureTitle($a_figure)

References $res, and getFigureTitle().

Referenced by ilWikiStatGUI\getListData(), and ilWikiStatGUI\viewToolbar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFigureOptionsPage()

static ilWikiStat::getFigureOptionsPage ( )
static

Definition at line 1305 of file class.ilWikiStat.php.

1306 {
1307 $res = array();
1308
1309 foreach (self::getFiguresPage() as $figure) {
1310 $res[$figure] = self::getFigureTitle($figure);
1311 }
1312
1313 return $res;
1314 }

References $res, and getFigureTitle().

Referenced by ilWikiStatGUI\getListData(), and ilWikiStatGUI\viewToolbar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFigures()

static ilWikiStat::getFigures ( )
static

Definition at line 1098 of file class.ilWikiStat.php.

1099 {
1100 return array(
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
1123 );
1124 }

◆ getFiguresPage()

static ilWikiStat::getFiguresPage ( )
static

Definition at line 1126 of file class.ilWikiStat.php.

1127 {
1128 return array(
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
1139 );
1140 }

◆ getFigureTitle()

static ilWikiStat::getFigureTitle (   $a_figure)
static

Definition at line 1142 of file class.ilWikiStat.php.

1143 {
1144 global $DIC;
1145
1146 $lng = $DIC->language();
1147
1148 $map = array(
1149 // wiki
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")
1172 // page
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")
1183 );
1184
1185 return $map[$a_figure];
1186 }
global $lng
Definition: privfeed.php:17

References $DIC, and $lng.

Referenced by ilWikiStatGUI\export(), getFigureOptions(), getFigureOptionsPage(), and ilWikiStatGUI\renderGraph().

+ Here is the caller graph for this function:

◆ getTimestamp()

static ilWikiStat::getTimestamp ( )
staticprotected

Get current time frame (hourly)

Returns
string

Definition at line 179 of file class.ilWikiStat.php.

180 {
181 return date("Y-m-d H:00:00");
182 }

References date.

Referenced by writeData().

+ Here is the caller graph for this function:

◆ getWikiAggr()

static ilWikiStat::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 
)
staticprotected

Definition at line 552 of file class.ilWikiStat.php.

553 {
554 global $DIC;
555
556 $ilDB = $DIC->database();
557
558 $res = array();
559 $deleted = null;
560
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";
564 }
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) {
570 // to build full period data we need all values in DB
571 $sql .= " AND " . $a_field . " > " . $ilDB->quote(0, "integer") .
572 " AND " . $a_field . " IS NOT NULL";
573 }
574 if ($a_sub_field) {
575 $sql .= " AND " . $a_sub_field . " = " . $ilDB->quote($a_sub_id, "integer");
576 }
577 $sql .= " GROUP BY ts_day" .
578 " ORDER BY ts_day";
579 $set = $ilDB->query($sql);
580 while ($row = $ilDB->fetchAssoc($set)) {
581 $res[$row["ts_day"]] = $row[$a_field];
582
583 $deleted = max($row["deleted"], $deleted);
584 }
585
586 if ($a_build_full_period) {
587 $period_first = $a_day_from;
588 $period_last = $a_day_to;
589
590 // check if sub was deleted in period
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);
597 $row = $ilDB->fetchAssoc($set);
598 $last_day = $row["last_day"];
599 if ($last_day < $period_last) {
600 $period_last = $last_day;
601 }
602 $first_day = $row["first_day"];
603 if ($first_day > $period_first) {
604 $period_first = $first_day;
605 }
606 }
607
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);
611 }
612
613 // no need to allow zero here as we are not building averages
614 self::buildFullPeriodData($res, $period_first, $period_last, $last_before_period);
615 }
616
617 return $res;
618 }
sprintf('%.4f', $callTime)
static buildFullPeriodData(array &$a_res, $a_day_from, $a_day_to, $a_last_before_period, $a_allow_zero=false)
static getWikiLast($a_wiki_id, $a_day_from, $a_table, $a_field, $a_sub_field=null, $a_sub_id=null)

References $DIC, $ilDB, $res, $row, buildFullPeriodData(), getWikiLast(), and sprintf.

Referenced by getWikiDeletedPages(), getWikiNewPagesSum(), getWikiNumPages(), getWikiNumRating(), getWikiPageChanges(), getWikiPageCharacters(), getWikiPageExternalLinks(), getWikiPageFootnotes(), getWikiPageInternalLinks(), getWikiPageRatings(), getWikiPageRead(), getWikiPageWords(), getWikiRatingAvg(), and getWikiReadPages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiAggrSub()

static ilWikiStat::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 
)
staticprotected

Definition at line 642 of file class.ilWikiStat.php.

643 {
644 global $DIC;
645
646 $ilDB = $DIC->database();
647
648 $res = array();
649
650 if (!$a_build_full_period) {
651 $sql = "SELECT ts_day, " . sprintf($a_aggr_value, $a_field) . " " . $a_field .
652 " FROM (" .
653 // subquery to build average per $a_aggr_by
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";
661 if ($a_sub_field) {
662 $sql .= " AND " . $a_sub_field . " = " . $ilDB->quote($a_sub_id, "integer");
663 }
664 $sql .= " GROUP BY ts_day, " . $a_aggr_by .
665 ") aggr_sub" .
666 " GROUP BY ts_day" .
667 " ORDER BY ts_day";
668 $set = $ilDB->query($sql);
669 while ($row = $ilDB->fetchAssoc($set)) {
670 $res[$row["ts_day"]] = $row[$a_field];
671 }
672 } else {
673 $tmp = $all_aggr_ids = $deleted_in_period = $first_day_in_period = array();
674
675 if ($a_table != "wiki_stat_page") {
676 echo "can only build full period averages for wiki_stat_page";
677 exit();
678 }
679
680 // as current period can be totally empty, gather existing subs
681 $sql = " SELECT *" .
682 " FROM (" .
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 .
687 ") aggr_sub" .
688 " WHERE first_day <= " . $ilDB->quote($a_day_to, "text") . // not created after period
689 " AND (last_day >= " . $ilDB->quote($a_day_from, "text") . // (deleted in/after period
690 " OR deleted = " . $ilDB->quote(0, "integer") . ")"; // or still existing)
691 $set = $ilDB->query($sql);
692 while ($row = $ilDB->fetchAssoc($set)) {
693 $all_aggr_ids[] = $row[$a_aggr_by];
694
695 // if deleted in period we need the last day
696 if ($row["deleted"] && $row["last_day"] < $a_day_to) {
697 $deleted_in_period[$row[$a_aggr_by]] = $row["last_day"];
698 }
699 // if created in period we need the first day
700 if ($row["first_day"] > $a_day_from) {
701 $first_day_in_period[$row[$a_aggr_by]] = $row["first_day"];
702 }
703 }
704
705 // we need to build average manually after completing period data (zero is valid)
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);
713 while ($row = $ilDB->fetchAssoc($set)) {
714 if (!in_array($row[$a_aggr_by], $all_aggr_ids)) {
715 var_dump("unexpected wiki_stat_page_entry", $row);
716 }
717 $tmp[$row[$a_aggr_by]][$row["ts_day"]] = $row[$a_field];
718 }
719
720 // build full period for each sub
721 foreach ($all_aggr_ids as $aggr_by_id) {
722 // last of entry of sub is before period
723 if (!is_array($tmp[$aggr_by_id])) {
724 $tmp[$aggr_by_id] = array();
725 }
726
727 // get last value before period to add missing entries in period
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);
731 }
732
733 // if sub was created in period (see above), shorten period accordingly
734 $first_period_day = isset($first_day_in_period[$aggr_by_id])
735 ? $first_day_in_period[$aggr_by_id]
736 : $a_day_from;
737
738 // if sub was deleted in period (see above), shorten period accordingly
739 $last_period_day = isset($deleted_in_period[$aggr_by_id])
740 ? $deleted_in_period[$aggr_by_id]
741 : $a_day_to;
742
743 // allow zero as we need to correct number of valid subs per day (see below - AVG)
744 self::buildFullPeriodData($tmp[$aggr_by_id], $first_period_day, $last_period_day, $last_before_period, true);
745
746 // distribute sub to days
747 foreach ($tmp[$aggr_by_id] as $day => $value) {
748 $res[$day][$aggr_by_id] = $value;
749 }
750 }
751
752 // build average over subs
753 foreach ($res as $day => $values) {
754 switch ($a_aggr_value) {
755 case "AVG(%s)":
756 $res[$day] = array_sum($values)/sizeof($values);
757 break;
758
759 case "SUM(%s)":
760 $res[$day] = array_sum($values);
761 break;
762
763 default:
764 var_dump("unsupport aggr " . $a_aggr_value);
765 break;
766 }
767 }
768 }
769
770 return $res;
771 }

References $DIC, $ilDB, $res, $row, buildFullPeriodData(), exit, getWikiLast(), and sprintf.

Referenced by getWikiCharacters(), getWikiCharactersAvg(), getWikiExternalLinks(), getWikiExternalLinksAvg(), getWikiFootnotes(), getWikiFootnotesAvg(), getWikiInternalLinks(), getWikiInternalLinksAvg(), getWikiNewPagesAvg(), getWikiNumRatingAvg(), getWikiPageChangesAvg(), getWikiWords(), and getWikiWordsAvg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiCharacters()

static ilWikiStat::getWikiCharacters (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 998 of file class.ilWikiStat.php.

999 {
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);
1001 }
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)

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiCharactersAvg()

static ilWikiStat::getWikiCharactersAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1003 of file class.ilWikiStat.php.

1004 {
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);
1006 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiDeletedPages()

static ilWikiStat::getWikiDeletedPages (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 823 of file class.ilWikiStat.php.

824 {
825 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat", "del_pages", "SUM(%s)");
826 }
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)

References getWikiAggr().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiEditPagesAvg()

static ilWikiStat::getWikiEditPagesAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 858 of file class.ilWikiStat.php.

859 {
860 global $DIC;
861
862 $ilDB = $DIC->database();
863
864 $res = array();
865
866 $sql = "SELECT ts_day, AVG(num_changed_pages) num_changed_pages" .
867 " FROM (" .
868 // subquery to build average per user
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" .
877 ") aggr_user" .
878 " GROUP BY ts_day" .
879 " ORDER BY ts_day";
880 $set = $ilDB->query($sql);
881 while ($row = $ilDB->fetchAssoc($set)) {
882 $res[$row["ts_day"]] = $row["num_changed_pages"];
883 }
884
885 return $res;
886 }

References $DIC, $ilDB, $res, and $row.

Referenced by getFigureData().

+ Here is the caller graph for this function:

◆ getWikiEditPagesSum()

static ilWikiStat::getWikiEditPagesSum (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 833 of file class.ilWikiStat.php.

834 {
835 global $DIC;
836
837 $ilDB = $DIC->database();
838
839 $res = array();
840
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" .
848 " GROUP BY ts_day" .
849 " ORDER BY ts_day";
850 $set = $ilDB->query($sql);
851 while ($row = $ilDB->fetchAssoc($set)) {
852 $res[$row["ts_day"]] = $row["num_changed_pages"];
853 }
854
855 return $res;
856 }

References $DIC, $ilDB, $res, and $row.

Referenced by getFigureData().

+ Here is the caller graph for this function:

◆ getWikiExternalLinks()

static ilWikiStat::getWikiExternalLinks (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 978 of file class.ilWikiStat.php.

979 {
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);
981 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiExternalLinksAvg()

static ilWikiStat::getWikiExternalLinksAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 983 of file class.ilWikiStat.php.

984 {
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);
986 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiFootnotes()

static ilWikiStat::getWikiFootnotes (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1008 of file class.ilWikiStat.php.

1009 {
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);
1011 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiFootnotesAvg()

static ilWikiStat::getWikiFootnotesAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1013 of file class.ilWikiStat.php.

1014 {
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);
1016 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiInternalLinks()

static ilWikiStat::getWikiInternalLinks (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 968 of file class.ilWikiStat.php.

969 {
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);
971 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiInternalLinksAvg()

static ilWikiStat::getWikiInternalLinksAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 973 of file class.ilWikiStat.php.

974 {
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);
976 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiLast()

static ilWikiStat::getWikiLast (   $a_wiki_id,
  $a_day_from,
  $a_table,
  $a_field,
  $a_sub_field = null,
  $a_sub_id = null 
)
staticprotected

Definition at line 620 of file class.ilWikiStat.php.

621 {
622 global $DIC;
623
624 $ilDB = $DIC->database();
625
626 // get last existing value before period (zero is valid)
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");
631 if ($a_sub_field) {
632 $sql .= " AND " . $a_sub_field . " = " . $ilDB->quote($a_sub_id, "integer");
633 }
634 $sql .= " GROUP BY ts_day" .
635 " ORDER BY ts_day DESC";
636 $ilDB->setLimit(1);
637 $set = $ilDB->query($sql);
638 $last_before_period = $ilDB->fetchAssoc($set);
639 return $last_before_period["latest"];
640 }

References $DIC, and $ilDB.

Referenced by getWikiAggr(), and getWikiAggrSub().

+ Here is the caller graph for this function:

◆ getWikiNewPagesAvg()

static ilWikiStat::getWikiNewPagesAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 818 of file class.ilWikiStat.php.

819 {
820 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_user", "new_pages", "user_id", "AVG(%s)", "SUM(%s)");
821 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiNewPagesSum()

static ilWikiStat::getWikiNewPagesSum (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 813 of file class.ilWikiStat.php.

814 {
815 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_user", "new_pages", "SUM(%s)");
816 }

References getWikiAggr().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiNumPages()

static ilWikiStat::getWikiNumPages (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 808 of file class.ilWikiStat.php.

809 {
810 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat", "num_pages", "MAX(%s)", null, null, true);
811 }

References getWikiAggr().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiNumRating()

static ilWikiStat::getWikiNumRating (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 946 of file class.ilWikiStat.php.

947 {
948 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page", "num_ratings", "SUM(%s)");
949 }

References getWikiAggr().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiNumRatingAvg()

static ilWikiStat::getWikiNumRatingAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 951 of file class.ilWikiStat.php.

952 {
953 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page", "num_ratings", "page_id", "AVG(%s)", "SUM(%s)");
954 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageChanges()

static ilWikiStat::getWikiPageChanges (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1023 of file class.ilWikiStat.php.

1024 {
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);
1026 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageChangesAvg()

static ilWikiStat::getWikiPageChangesAvg (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1028 of file class.ilWikiStat.php.

1029 {
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);
1031 }

References getWikiAggrSub().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageCharacters()

static ilWikiStat::getWikiPageCharacters (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1058 of file class.ilWikiStat.php.

1059 {
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);
1061 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageExternalLinks()

static ilWikiStat::getWikiPageExternalLinks (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1048 of file class.ilWikiStat.php.

1049 {
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);
1051 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageFootnotes()

static ilWikiStat::getWikiPageFootnotes (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1063 of file class.ilWikiStat.php.

1064 {
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);
1066 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageInternalLinks()

static ilWikiStat::getWikiPageInternalLinks (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1043 of file class.ilWikiStat.php.

1044 {
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);
1046 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageRatings()

static ilWikiStat::getWikiPageRatings (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1068 of file class.ilWikiStat.php.

1069 {
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);
1071 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageRead()

static ilWikiStat::getWikiPageRead (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1038 of file class.ilWikiStat.php.

1039 {
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);
1041 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageUserEdit()

static ilWikiStat::getWikiPageUserEdit (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1033 of file class.ilWikiStat.php.

1034 {
1035 return self::getWikiUserEditPages($a_wiki_id, $a_day_from, $a_day_to, "page_id", $a_page_id);
1036 }

References getWikiUserEditPages().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiPageWords()

static ilWikiStat::getWikiPageWords (   $a_wiki_id,
  $a_page_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 1053 of file class.ilWikiStat.php.

1054 {
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);
1056 }

References getWikiAggr().

Referenced by getFigureDataPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiRatingAvg()

static ilWikiStat::getWikiRatingAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 956 of file class.ilWikiStat.php.

957 {
958 $res = self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat", "avg_rating", "AVG(%s)");
959
960 foreach (array_keys($res) as $day) {
961 // int-to-float
962 $res[$day] = $res[$day]/100;
963 }
964
965 return $res;
966 }

References $res, and getWikiAggr().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiReadPages()

static ilWikiStat::getWikiReadPages (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 828 of file class.ilWikiStat.php.

829 {
830 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page_user", "read_events", "SUM(%s)");
831 }

References getWikiAggr().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiUserEditPages()

static ilWikiStat::getWikiUserEditPages (   $a_wiki_id,
  $a_day_from,
  $a_day_to,
  $a_sub_field = null,
  $a_sub_id = null 
)
staticprotected

Definition at line 888 of file class.ilWikiStat.php.

889 {
890 global $DIC;
891
892 $ilDB = $DIC->database();
893
894 $res = array();
895
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";
903 if ($a_sub_field) {
904 $sql .= " AND " . $a_sub_field . " = " . $ilDB->quote($a_sub_id, "integer");
905 }
906 $sql .= " GROUP BY ts_day" .
907 " ORDER BY ts_day";
908 $set = $ilDB->query($sql);
909 while ($row = $ilDB->fetchAssoc($set)) {
910 $res[$row["ts_day"]] = $row["num_changed_users"];
911 }
912
913 return $res;
914 }

References $DIC, $ilDB, $res, and $row.

Referenced by getFigureData(), and getWikiPageUserEdit().

+ Here is the caller graph for this function:

◆ getWikiUserEditPagesAvg()

static ilWikiStat::getWikiUserEditPagesAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 916 of file class.ilWikiStat.php.

917 {
918 global $DIC;
919
920 $ilDB = $DIC->database();
921
922 $res = array();
923
924 $sql = "SELECT ts_day, AVG(num_changed_users) num_changed_users" .
925 " FROM (" .
926 // subquery to build average per page
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" .
935 ") aggr_user" .
936 " GROUP BY ts_day" .
937 " ORDER BY ts_day";
938 $set = $ilDB->query($sql);
939 while ($row = $ilDB->fetchAssoc($set)) {
940 $res[$row["ts_day"]] = $row["num_changed_users"];
941 }
942
943 return $res;
944 }

References $DIC, $ilDB, $res, and $row.

◆ getWikiWords()

static ilWikiStat::getWikiWords (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 988 of file class.ilWikiStat.php.

989 {
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);
991 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWikiWordsAvg()

static ilWikiStat::getWikiWordsAvg (   $a_wiki_id,
  $a_day_from,
  $a_day_to 
)
staticprotected

Definition at line 993 of file class.ilWikiStat.php.

994 {
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);
996 }

References getWikiAggrSub().

Referenced by getFigureData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleEvent()

static ilWikiStat::handleEvent (   $a_event,
ilWikiPage  $a_page_obj,
  $a_user_id = null,
array  $a_additional_data = null 
)
static

Handle wiki page event.

Parameters
int$a_event
ilWikiPage$a_page_obj
int$a_user_id
int$a_additional_data

Definition at line 135 of file class.ilWikiStat.php.

136 {
137 global $DIC;
138
139 $ilUser = $DIC->user();
140
141 if (!$a_user_id) {
142 $a_user_id = $ilUser->getId();
143 }
144 if (!$a_user_id || $a_user_id == ANONYMOUS_USER_ID) {
145 return;
146 }
147
148 switch ((int) $a_event) {
150 self::handlePageCreated($a_page_obj, $a_user_id);
151 break;
152
154 self::handlePageUpdated($a_page_obj, $a_user_id, $a_additional_data);
155 break;
156
158 self::handlePageRead($a_page_obj, $a_user_id);
159 break;
160
162 self::handlePageDeletion($a_page_obj, $a_user_id);
163 break;
164
166 self::handlePageRating($a_page_obj, $a_user_id);
167 break;
168
169 default:
170 return;
171 }
172 }
const EVENT_PAGE_RATING
const EVENT_PAGE_UPDATED
static handlePageUpdated(ilWikiPage $a_page_obj, $a_user_id, array $a_page_data=null)
Handle wiki page update.
const EVENT_PAGE_READ
static handlePageDeletion(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page deletion.
static handlePageCreated(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page creation.
const EVENT_PAGE_CREATED
const EVENT_PAGE_DELETED
static handlePageRead(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page read.
static handlePageRating(ilWikiPage $a_page_obj, $a_user_id)
Handle wiki page rating.
$ilUser
Definition: imgupload.php:18

References $DIC, $ilUser, EVENT_PAGE_CREATED, EVENT_PAGE_DELETED, EVENT_PAGE_RATING, EVENT_PAGE_READ, EVENT_PAGE_UPDATED, handlePageCreated(), handlePageDeletion(), handlePageRating(), handlePageRead(), and handlePageUpdated().

Referenced by ilWikiPage\afterUpdate(), ilWikiPage\create(), ilWikiPage\delete(), ilWikiPageGUI\increaseViewCount(), and ilWikiPageGUI\updateStatsRating().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlePageCreated()

static ilWikiStat::handlePageCreated ( ilWikiPage  $a_page_obj,
  $a_user_id 
)
static

Handle wiki page creation.

Parameters
ilWikiPage$a_page_obj
int$a_user_id

Definition at line 376 of file class.ilWikiStat.php.

377 {
378 // wiki: num_pages (count)
380 $a_page_obj->getWikiId(),
381 array(
382 "num_pages" => array("integer", self::countPages($a_page_obj->getWikiId())),
383 "del_pages" => array("integer", 0),
384 "avg_rating" => array("integer", 0)
385 )
386 );
387
388 // user: new_pages+1
390 $a_page_obj->getWikiId(),
391 $a_user_id,
392 array(
393 "new_pages" => array("increment", 1)
394 )
395 );
396 }
getWikiId()
Get Wiki Object Id.
static writeStat($a_wiki_id, $a_values)
Write data to wiki_stat.
static writeStatUser($a_wiki_id, $a_user_id, $a_values)
Write to wiki_stat_user.

References ilWikiPage\getWikiId(), writeStat(), and writeStatUser().

Referenced by handleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlePageDeletion()

static ilWikiStat::handlePageDeletion ( ilWikiPage  $a_page_obj,
  $a_user_id 
)
static

Handle wiki page deletion.

Parameters
ilWikiPage$a_page_obj
int$a_user_id

Definition at line 455 of file class.ilWikiStat.php.

456 {
457 global $DIC;
458
459 $ilDB = $DIC->database();
460
461 // copy last entry to have deletion timestamp
462 $sql = "SELECT * " .
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") .
466 " ORDER BY ts DESC";
467 $ilDB->setLimit(1);
468 $set = $ilDB->query($sql);
469
470 // #15748
471 if ($ilDB->numRows($set)) {
472 $data = $ilDB->fetchAssoc($set);
473
474 // see self::handlePageUpdated()
475 $values = array(
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"]),
483 );
484 self::writeStatPage((int) $a_page_obj->getWikiId(), $a_page_obj->getId(), $values);
485 }
486
487 // mark all page entries as deleted
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"));
492
493 // wiki: del_pages+1, num_pages (count), avg_rating
494 $rating = self::getAverageRating($a_page_obj->getWikiId());
496 $a_page_obj->getWikiId(),
497 array(
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)
501 )
502 );
503 }
static writeStatPage($a_wiki_id, $a_page_id, $a_values)
Write data to wiki_stat_page.
static getAverageRating($a_wiki_id, $a_page_id=null)
Get average rating for wiki or wiki page.

References $data, $DIC, $ilDB, getAverageRating(), ilPageObject\getId(), ilWikiPage\getWikiId(), writeStat(), and writeStatPage().

Referenced by handleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlePageRating()

static ilWikiStat::handlePageRating ( ilWikiPage  $a_page_obj,
  $a_user_id 
)
static

Handle wiki page rating.

Parameters
ilWikiPage$a_page_obj
int$a_user_id

Definition at line 511 of file class.ilWikiStat.php.

512 {
513 // do page first!
514 $rating = self::getAverageRating($a_page_obj->getWikiId(), $a_page_obj->getId());
515
516 // wiki_stat_page: num_ratings, avg_rating
518 $a_page_obj->getWikiId(),
519 $a_page_obj->getId(),
520 array(
521 "num_ratings" => array("integer", $rating["cnt"]),
522 "avg_rating" => array("integer", $rating["avg"]*100),
523 )
524 );
525
526 $rating = self::getAverageRating($a_page_obj->getWikiId());
527
528 // wiki_stat: avg_rating
529 $is_update = self::writeStat(
530 $a_page_obj->getWikiId(),
531 array(
532 "avg_rating" => array("integer", $rating["avg"]*100)
533 )
534 );
535
536 if (!$is_update) {
537 // wiki: num_pages (count)
539 $a_page_obj->getWikiId(),
540 array(
541 "num_pages" => array("integer", self::countPages($a_page_obj->getWikiId()))
542 )
543 );
544 }
545 }

References getAverageRating(), ilPageObject\getId(), ilWikiPage\getWikiId(), writeStat(), and writeStatPage().

Referenced by handleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlePageRead()

static ilWikiStat::handlePageRead ( ilWikiPage  $a_page_obj,
  $a_user_id 
)
static

Handle wiki page read.

Parameters
ilWikiPage$a_page_obj
int$a_user_id

Definition at line 436 of file class.ilWikiStat.php.

437 {
438 // page_user: read_events+1
440 $a_page_obj->getWikiId(),
441 $a_page_obj->getId(),
442 $a_user_id,
443 array(
444 "read_events" => array("increment", 1)
445 )
446 );
447 }
static writeStatPageUser($a_wiki_id, $a_page_id, $a_user_id, $a_values)
Write data to wiki_stat_page_user.

References ilPageObject\getId(), ilWikiPage\getWikiId(), and writeStatPageUser().

Referenced by handleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlePageUpdated()

static ilWikiStat::handlePageUpdated ( ilWikiPage  $a_page_obj,
  $a_user_id,
array  $a_page_data = null 
)
static

Handle wiki page update.

Parameters
ilWikiPage$a_page_obj
int$a_user_id
array$a_page_data

Definition at line 405 of file class.ilWikiStat.php.

406 {
407 // page_user: changes+1
409 $a_page_obj->getWikiId(),
410 $a_page_obj->getId(),
411 $a_user_id,
412 array(
413 "changes" => array("increment", 1)
414 )
415 );
416
417 // page: see ilWikiPage::afterUpdate()
418 $values = array(
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)
426 );
427 self::writeStatPage($a_page_obj->getWikiId(), $a_page_obj->getId(), $values);
428 }

References ilPageObject\getId(), ilWikiPage\getWikiId(), writeStatPage(), and writeStatPageUser().

Referenced by handleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeData()

static ilWikiStat::writeData (   $a_table,
array  $a_primary,
array  $a_values 
)
staticprotected

Write data to DB.

  • Handles update/insert depending on time frame
  • supports increment/decrement custom values
Parameters
string$a_table
array$a_primary
array$a_values

Definition at line 194 of file class.ilWikiStat.php.

195 {
196 global $DIC;
197
198 $ilDB = $DIC->database();
199
200 $tstamp = self::getTimestamp();
201 $a_primary["ts"] = array("timestamp", $tstamp);
202
203 $ilAtomQuery = $ilDB->buildAtomQuery();
204 $ilAtomQuery->addTableLock($a_table);
205
206 $ilAtomQuery->addQueryCallable(
207 function (ilDBInterface $ilDB) use ($a_table, $a_primary, $a_values, $tstamp, &$is_update) {
208 $primary = array();
209 foreach ($a_primary as $column => $value) {
210 $primary[] = $column . " = " . $ilDB->quote($value[1], $value[0]);
211 }
212 $primary = implode(" AND ", $primary);
213
214 $set = $ilDB->query("SELECT ts FROM " . $a_table .
215 " WHERE " . $primary);
216
217 $is_update = (bool) $ilDB->numRows($set);
218
219 // update (current timeframe)
220 if ($is_update) {
221 $values = array();
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";
227 } else {
228 $values[] = $column . " = " . $ilDB->quote($value[1], $value[0]);
229 }
230 }
231 $values = implode(", ", $values);
232
233 $sql = "UPDATE " . $a_table .
234 " SET " . $values .
235 " WHERE " . $primary;
236 }
237 // insert (no entry yet for current time frame)
238 else {
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));
242
243 $values = array();
244 foreach ($a_values as $column => $value) {
245 $columns[] = $column;
246 if ($value[0] == "increment") {
247 $value[0] = "integer";
248 } elseif ($value[0] == "decrement") {
249 $value[0] = "integer";
250 $value[1] = 0;
251 }
252 $values[] = $ilDB->quote($value[1], $value[0]);
253 }
254 $values = implode(", ", $values);
255 $columns = implode(", ", $columns);
256
257 $sql = "INSERT INTO " . $a_table .
258 " (" . $columns . ")" .
259 " VALUES (" . $values . ")";
260 }
261 $ilDB->manipulate($sql);
262 }
263 );
264 $ilAtomQuery->run();
265
266 return $is_update;
267 }
$column
Definition: 39dropdown.php:62
if(! $in) $columns
Definition: Utf8Test.php:45
static getTimestamp()
Get current time frame (hourly)
Interface ilDBInterface.

References $column, $columns, $DIC, $ilDB, and getTimestamp().

Referenced by writeStat(), writeStatPage(), writeStatPageUser(), and writeStatUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeStat()

static ilWikiStat::writeStat (   $a_wiki_id,
  $a_values 
)
staticprotected

Write data to wiki_stat.

Parameters
int$a_wiki_id
array$a_values

Definition at line 275 of file class.ilWikiStat.php.

276 {
277 $primary = array(
278 "wiki_id" => array("integer", $a_wiki_id)
279 );
280 self::writeData("wiki_stat", $primary, $a_values);
281 }
static writeData($a_table, array $a_primary, array $a_values)
Write data to DB.

References writeData().

Referenced by handlePageCreated(), handlePageDeletion(), and handlePageRating().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeStatPage()

static ilWikiStat::writeStatPage (   $a_wiki_id,
  $a_page_id,
  $a_values 
)
staticprotected

Write data to wiki_stat_page.

Parameters
int$a_wiki_id
int$a_page_id
array$a_values

Definition at line 290 of file class.ilWikiStat.php.

291 {
292 $primary = array(
293 "wiki_id" => array("integer", $a_wiki_id),
294 "page_id" => array("integer", $a_page_id),
295 );
296 self::writeData("wiki_stat_page", $primary, $a_values);
297 }

References writeData().

Referenced by handlePageDeletion(), handlePageRating(), and handlePageUpdated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeStatPageUser()

static ilWikiStat::writeStatPageUser (   $a_wiki_id,
  $a_page_id,
  $a_user_id,
  $a_values 
)
staticprotected

Write data to wiki_stat_page_user.

Parameters
int$a_wiki_id
int$a_page_id
int$a_user_id
array$a_values

Definition at line 307 of file class.ilWikiStat.php.

308 {
309 $primary = array(
310 "wiki_id" => array("integer", $a_wiki_id),
311 "page_id" => array("integer", $a_page_id),
312 "user_id" => array("integer", $a_user_id)
313 );
314 self::writeData("wiki_stat_page_user", $primary, $a_values);
315 }

References writeData().

Referenced by handlePageRead(), and handlePageUpdated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeStatUser()

static ilWikiStat::writeStatUser (   $a_wiki_id,
  $a_user_id,
  $a_values 
)
staticprotected

Write to wiki_stat_user.

Parameters
int$a_wiki_id
int$a_user_id
array$a_values

Definition at line 324 of file class.ilWikiStat.php.

325 {
326 $primary = array(
327 "wiki_id" => array("integer", $a_wiki_id),
328 "user_id" => array("integer", $a_user_id)
329 );
330 self::writeData("wiki_stat_user", $primary, $a_values);
331 }

References writeData().

Referenced by handlePageCreated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ EVENT_PAGE_CREATED

const ilWikiStat::EVENT_PAGE_CREATED = 1

Definition at line 83 of file class.ilWikiStat.php.

Referenced by ilWikiPage\create(), and handleEvent().

◆ EVENT_PAGE_DELETED

const ilWikiStat::EVENT_PAGE_DELETED = 4

Definition at line 86 of file class.ilWikiStat.php.

Referenced by ilWikiPage\delete(), and handleEvent().

◆ EVENT_PAGE_RATING

const ilWikiStat::EVENT_PAGE_RATING = 5

Definition at line 87 of file class.ilWikiStat.php.

Referenced by handleEvent(), and ilWikiPageGUI\updateStatsRating().

◆ EVENT_PAGE_READ

const ilWikiStat::EVENT_PAGE_READ = 3

Definition at line 85 of file class.ilWikiStat.php.

Referenced by handleEvent(), and ilWikiPageGUI\increaseViewCount().

◆ EVENT_PAGE_UPDATED

const ilWikiStat::EVENT_PAGE_UPDATED = 2

Definition at line 84 of file class.ilWikiStat.php.

Referenced by ilWikiPage\afterUpdate(), and handleEvent().

◆ KEY_FIGURE_WIKI_CHARS

const ilWikiStat::KEY_FIGURE_WIKI_CHARS = 19

Definition at line 107 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_CHARS_AVG

const ilWikiStat::KEY_FIGURE_WIKI_CHARS_AVG = 20

Definition at line 108 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_DELETED_PAGES

const ilWikiStat::KEY_FIGURE_WIKI_DELETED_PAGES = 6

Definition at line 94 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_EDIT_PAGES

const ilWikiStat::KEY_FIGURE_WIKI_EDIT_PAGES = 4

Definition at line 92 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_EDIT_PAGES_AVG

const ilWikiStat::KEY_FIGURE_WIKI_EDIT_PAGES_AVG = 5

Definition at line 93 of file class.ilWikiStat.php.

Referenced by getFigureData().

◆ KEY_FIGURE_WIKI_EXTERNAL_LINKS

const ilWikiStat::KEY_FIGURE_WIKI_EXTERNAL_LINKS = 15

Definition at line 103 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG

const ilWikiStat::KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG = 16

Definition at line 104 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_FOOTNOTES

const ilWikiStat::KEY_FIGURE_WIKI_FOOTNOTES = 21

Definition at line 109 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_FOOTNOTES_AVG

const ilWikiStat::KEY_FIGURE_WIKI_FOOTNOTES_AVG = 22

Definition at line 110 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_INTERNAL_LINKS

const ilWikiStat::KEY_FIGURE_WIKI_INTERNAL_LINKS = 13

Definition at line 101 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG

const ilWikiStat::KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG = 14

Definition at line 102 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_NEW_PAGES

const ilWikiStat::KEY_FIGURE_WIKI_NEW_PAGES = 2

Definition at line 90 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_NEW_PAGES_AVG

const ilWikiStat::KEY_FIGURE_WIKI_NEW_PAGES_AVG = 3

Definition at line 91 of file class.ilWikiStat.php.

Referenced by getFigureData().

◆ KEY_FIGURE_WIKI_NUM_PAGES

const ilWikiStat::KEY_FIGURE_WIKI_NUM_PAGES = 1

◆ KEY_FIGURE_WIKI_NUM_RATING

const ilWikiStat::KEY_FIGURE_WIKI_NUM_RATING = 10

Definition at line 98 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_NUM_RATING_AVG

const ilWikiStat::KEY_FIGURE_WIKI_NUM_RATING_AVG = 11

Definition at line 99 of file class.ilWikiStat.php.

Referenced by getFigureData().

◆ KEY_FIGURE_WIKI_PAGE_CHANGES

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_CHANGES = 23

◆ KEY_FIGURE_WIKI_PAGE_CHANGES_AVG

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_CHANGES_AVG = 24

Definition at line 113 of file class.ilWikiStat.php.

Referenced by getFigureDataPage().

◆ KEY_FIGURE_WIKI_PAGE_CHARS

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_CHARS = 30

Definition at line 119 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS = 28

Definition at line 117 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_PAGE_FOOTNOTES

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_FOOTNOTES = 31

Definition at line 120 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS = 27

Definition at line 116 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_PAGE_RATINGS

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_RATINGS = 32

Definition at line 121 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_PAGE_READ

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_READ = 26

Definition at line 115 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_PAGE_USER_EDIT

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_USER_EDIT = 25

Definition at line 114 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_PAGE_WORDS

const ilWikiStat::KEY_FIGURE_WIKI_PAGE_WORDS = 29

Definition at line 118 of file class.ilWikiStat.php.

Referenced by getFigureDataPage(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_RATING_AVG

const ilWikiStat::KEY_FIGURE_WIKI_RATING_AVG = 12

Definition at line 100 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_READ_PAGES

const ilWikiStat::KEY_FIGURE_WIKI_READ_PAGES = 7

Definition at line 95 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_USER_EDIT_PAGES

const ilWikiStat::KEY_FIGURE_WIKI_USER_EDIT_PAGES = 8

Definition at line 96 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG

const ilWikiStat::KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG = 9

Definition at line 97 of file class.ilWikiStat.php.

Referenced by getFigureData().

◆ KEY_FIGURE_WIKI_WORDS

const ilWikiStat::KEY_FIGURE_WIKI_WORDS = 17

Definition at line 105 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().

◆ KEY_FIGURE_WIKI_WORDS_AVG

const ilWikiStat::KEY_FIGURE_WIKI_WORDS_AVG = 18

Definition at line 106 of file class.ilWikiStat.php.

Referenced by getFigureData(), and ilWikiStatGUI\renderGraph().


The documentation for this class was generated from the following file: