ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 785 of file class.ilWikiStat.php.

786 {
787 // build full data for period
788 $safety = 0;
789 $last = null;
790 $today = date("Y-m-d");
791 $current = explode("-", $a_day_from);
792 $current = date("Y-m-d", mktime(0, 0, 1, $current[1], $current[2], $current[0]));
793 while($current <= $a_day_to &&
794 ++$safety < 1000)
795 {
796 if(!isset($a_res[$current]))
797 {
798 if($current <= $today)
799 {
800 // last existing value in period
801 if($last !== null)
802 {
803 $a_res[$current] = $last;
804 }
805 // last existing value before period
806 else if($a_last_before_period || $a_allow_zero)
807 {
808 $a_res[$current] = $a_last_before_period;
809 }
810 }
811 }
812 else
813 {
814 $last = $a_res[$current];
815 }
816
817 $current = explode("-", $current);
818 $current = date("Y-m-d", mktime(0, 0, 1, $current[1], $current[2]+1, $current[0]));
819 }
820 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())

References 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 351 of file class.ilWikiStat.php.

352 {
353 return sizeof(ilWikiPage::getAllWikiPages($a_wiki_id));
354 }
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 1095 of file class.ilWikiStat.php.

1096 {
1097 global $ilDB;
1098
1099 $res = array();
1100
1101 // because of read_events this db table is updated most often
1102 $set = $ilDB->query("SELECT DISTINCT(SUBSTR(ts_day, 1, 7)) ".$ilDB->quoteIdentifier("month").
1103 " FROM wiki_stat_page_user".
1104 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
1105 " AND ts_day IS NOT NULL");
1106 while($row = $ilDB->fetchAssoc($set))
1107 {
1108 $res[] = $row["month"];
1109 }
1110
1111 return $res;
1112 }
global $ilDB

References $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 363 of file class.ilWikiStat.php.

364 {
365 include_once "Services/Rating/classes/class.ilRating.php";
366
367 if(!$a_page_id)
368 {
370 $a_wiki_id,
371 "wiki");
372 }
373 else
374 {
376 $a_wiki_id,
377 "wiki",
378 $a_page_id,
379 "wpg");
380 }
381 }
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 1202 of file class.ilWikiStat.php.

1203 {
1204 switch($a_figure)
1205 {
1207 return self::getWikiNumPages($a_wiki_id, $a_from, $a_to);
1208
1210 return self::getWikiNewPagesSum($a_wiki_id, $a_from, $a_to);
1211
1213 return self::getWikiNewPagesAvg($a_wiki_id, $a_from, $a_to);
1214
1216 return self::getWikiEditPagesSum($a_wiki_id, $a_from, $a_to);
1217
1219 return self::getWikiEditPagesAvg($a_wiki_id, $a_from, $a_to);
1220
1222 return self::getWikiDeletedPages($a_wiki_id, $a_from, $a_to);
1223
1225 return self::getWikiReadPages($a_wiki_id, $a_from, $a_to);
1226
1228 return self::getWikiUserEditPages($a_wiki_id, $a_from, $a_to);
1229
1231 return self::getWikiUserEditPages($a_wiki_id, $a_from, $a_to);
1232
1234 return self::getWikiNumRating($a_wiki_id, $a_from, $a_to);
1235
1237 return self::getWikiNumRatingAvg($a_wiki_id, $a_from, $a_to);
1238
1240 return self::getWikiRatingAvg($a_wiki_id, $a_from, $a_to);
1241
1243 return self::getWikiInternalLinks($a_wiki_id, $a_from, $a_to);
1244
1246 return self::getWikiInternalLinksAvg($a_wiki_id, $a_from, $a_to);
1247
1249 return self::getWikiExternalLinks($a_wiki_id, $a_from, $a_to);
1250
1252 return self::getWikiExternalLinksAvg($a_wiki_id, $a_from, $a_to);
1253
1255 return self::getWikiWords($a_wiki_id, $a_from, $a_to);
1256
1258 return self::getWikiWordsAvg($a_wiki_id, $a_from, $a_to);
1259
1261 return self::getWikiCharacters($a_wiki_id, $a_from, $a_to);
1262
1264 return self::getWikiCharactersAvg($a_wiki_id, $a_from, $a_to);
1265
1267 return self::getWikiFootnotes($a_wiki_id, $a_from, $a_to);
1268
1270 return self::getWikiFootnotesAvg($a_wiki_id, $a_from, $a_to);
1271 }
1272 }
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 1274 of file class.ilWikiStat.php.

1275 {
1276 switch($a_figure)
1277 {
1279 return self::getWikiPageChanges($a_wiki_id, $a_page_id, $a_from, $a_to);
1280
1282 return self::getWikiPageChangesAvg($a_wiki_id, $a_page_id, $a_from, $a_to);
1283
1285 return self::getWikiPageUserEdit($a_wiki_id, $a_page_id, $a_from, $a_to);
1286
1288 return self::getWikiPageRead($a_wiki_id, $a_page_id, $a_from, $a_to);
1289
1291 return self::getWikiPageInternalLinks($a_wiki_id, $a_page_id, $a_from, $a_to);
1292
1294 return self::getWikiPageExternalLinks($a_wiki_id, $a_page_id, $a_from, $a_to);
1295
1297 return self::getWikiPageFootnotes($a_wiki_id, $a_page_id, $a_from, $a_to);
1298
1300 return self::getWikiPageWords($a_wiki_id, $a_page_id, $a_from, $a_to);
1301
1303 return self::getWikiPageCharacters($a_wiki_id, $a_page_id, $a_from, $a_to);
1304
1306 return self::getWikiPageRatings($a_wiki_id, $a_page_id, $a_from, $a_to);
1307 }
1308 }
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 1310 of file class.ilWikiStat.php.

1311 {
1312 $res = array();
1313
1314 foreach(self::getFigures() as $figure)
1315 {
1316 $res[$figure] = self::getFigureTitle($figure);
1317 }
1318
1319 return $res;
1320 }
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 1322 of file class.ilWikiStat.php.

1323 {
1324 $res = array();
1325
1326 foreach(self::getFiguresPage() as $figure)
1327 {
1328 $res[$figure] = self::getFigureTitle($figure);
1329 }
1330
1331 return $res;
1332 }

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 1114 of file class.ilWikiStat.php.

1115 {
1116 return array(
1117 self::KEY_FIGURE_WIKI_NUM_PAGES
1118 ,self::KEY_FIGURE_WIKI_NEW_PAGES
1119 ,self::KEY_FIGURE_WIKI_NEW_PAGES_AVG
1120 ,self::KEY_FIGURE_WIKI_EDIT_PAGES
1121 ,self::KEY_FIGURE_WIKI_EDIT_PAGES_AVG
1122 ,self::KEY_FIGURE_WIKI_DELETED_PAGES
1123 ,self::KEY_FIGURE_WIKI_READ_PAGES
1124 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES
1125 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG
1126 ,self::KEY_FIGURE_WIKI_NUM_RATING
1127 ,self::KEY_FIGURE_WIKI_NUM_RATING_AVG
1128 ,self::KEY_FIGURE_WIKI_RATING_AVG
1129 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS
1130 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG
1131 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS
1132 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG
1133 ,self::KEY_FIGURE_WIKI_WORDS
1134 ,self::KEY_FIGURE_WIKI_WORDS_AVG
1135 ,self::KEY_FIGURE_WIKI_CHARS
1136 ,self::KEY_FIGURE_WIKI_CHARS_AVG
1137 ,self::KEY_FIGURE_WIKI_FOOTNOTES
1138 ,self::KEY_FIGURE_WIKI_FOOTNOTES_AVG
1139 );
1140 }

◆ getFiguresPage()

static ilWikiStat::getFiguresPage ( )
static

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

1143 {
1144 return array(
1145 self::KEY_FIGURE_WIKI_PAGE_CHANGES
1146 ,self::KEY_FIGURE_WIKI_PAGE_CHANGES_AVG
1147 ,self::KEY_FIGURE_WIKI_PAGE_USER_EDIT
1148 ,self::KEY_FIGURE_WIKI_PAGE_READ
1149 ,self::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS
1150 ,self::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS
1151 ,self::KEY_FIGURE_WIKI_PAGE_WORDS
1152 ,self::KEY_FIGURE_WIKI_PAGE_CHARS
1153 ,self::KEY_FIGURE_WIKI_PAGE_FOOTNOTES
1154 ,self::KEY_FIGURE_WIKI_PAGE_RATINGS
1155 );
1156 }

◆ getFigureTitle()

static ilWikiStat::getFigureTitle (   $a_figure)
static

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

1159 {
1160 global $lng;
1161
1162 $map = array(
1163 // wiki
1164 self::KEY_FIGURE_WIKI_NUM_PAGES => $lng->txt("wiki_stat_num_pages")
1165 ,self::KEY_FIGURE_WIKI_NEW_PAGES => $lng->txt("wiki_stat_new_pages")
1166 ,self::KEY_FIGURE_WIKI_NEW_PAGES_AVG => $lng->txt("wiki_stat_new_pages_avg")
1167 ,self::KEY_FIGURE_WIKI_EDIT_PAGES => $lng->txt("wiki_stat_edit_pages")
1168 ,self::KEY_FIGURE_WIKI_EDIT_PAGES_AVG => $lng->txt("wiki_stat_edit_pages_avg")
1169 ,self::KEY_FIGURE_WIKI_DELETED_PAGES => $lng->txt("wiki_stat_deleted_pages")
1170 ,self::KEY_FIGURE_WIKI_READ_PAGES => $lng->txt("wiki_stat_read_pages")
1171 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES => $lng->txt("wiki_stat_user_edit_pages")
1172 ,self::KEY_FIGURE_WIKI_USER_EDIT_PAGES_AVG => $lng->txt("wiki_stat_user_edit_pages_avg")
1173 ,self::KEY_FIGURE_WIKI_NUM_RATING => $lng->txt("wiki_stat_num_rating")
1174 ,self::KEY_FIGURE_WIKI_NUM_RATING_AVG => $lng->txt("wiki_stat_num_rating_avg")
1175 ,self::KEY_FIGURE_WIKI_RATING_AVG => $lng->txt("wiki_stat_rating_avg")
1176 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS => $lng->txt("wiki_stat_internal_links")
1177 ,self::KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG => $lng->txt("wiki_stat_internal_links_avg")
1178 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS => $lng->txt("wiki_stat_external_links")
1179 ,self::KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG => $lng->txt("wiki_stat_external_links_avg")
1180 ,self::KEY_FIGURE_WIKI_WORDS => $lng->txt("wiki_stat_words")
1181 ,self::KEY_FIGURE_WIKI_WORDS_AVG => $lng->txt("wiki_stat_words_avg")
1182 ,self::KEY_FIGURE_WIKI_CHARS => $lng->txt("wiki_stat_chars")
1183 ,self::KEY_FIGURE_WIKI_CHARS_AVG => $lng->txt("wiki_stat_chars_avg")
1184 ,self::KEY_FIGURE_WIKI_FOOTNOTES => $lng->txt("wiki_stat_footnotes")
1185 ,self::KEY_FIGURE_WIKI_FOOTNOTES_AVG => $lng->txt("wiki_stat_footnotes_avg")
1186 // page
1187 ,self::KEY_FIGURE_WIKI_PAGE_CHANGES => $lng->txt("wiki_stat_page_changes")
1188 ,self::KEY_FIGURE_WIKI_PAGE_CHANGES_AVG => $lng->txt("wiki_stat_page_changes_avg")
1189 ,self::KEY_FIGURE_WIKI_PAGE_USER_EDIT => $lng->txt("wiki_stat_page_user_edit")
1190 ,self::KEY_FIGURE_WIKI_PAGE_READ => $lng->txt("wiki_stat_page_read")
1191 ,self::KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS => $lng->txt("wiki_stat_page_internal_links")
1192 ,self::KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS => $lng->txt("wiki_stat_page_external_links")
1193 ,self::KEY_FIGURE_WIKI_PAGE_WORDS => $lng->txt("wiki_stat_page_words")
1194 ,self::KEY_FIGURE_WIKI_PAGE_CHARS => $lng->txt("wiki_stat_page_characters")
1195 ,self::KEY_FIGURE_WIKI_PAGE_FOOTNOTES => $lng->txt("wiki_stat_page_footnotes")
1196 ,self::KEY_FIGURE_WIKI_PAGE_RATINGS => $lng->txt("wiki_stat_page_ratings")
1197 );
1198
1199 return $map[$a_figure];
1200 }
global $lng
Definition: privfeed.php:17

References $lng.

Referenced by 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 180 of file class.ilWikiStat.php.

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

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 543 of file class.ilWikiStat.php.

544 {
545 global $ilDB;
546
547 $res = array();
548 $deleted = null;
549
550 $sql = "SELECT ts_day, ".sprintf($a_aggr_value, $a_field)." ".$a_field;
551 if($a_table == "wiki_stat_page" && $a_sub_field)
552 {
553 $sql .= ", MAX(deleted) deleted";
554 }
555 $sql .= " FROM ".$a_table.
556 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
557 " AND ts_day >= ".$ilDB->quote($a_day_from, "text").
558 " AND ts_day <= ".$ilDB->quote($a_day_to, "text");
559 if(!$a_build_full_period)
560 {
561 // to build full period data we need all values in DB
562 $sql .= " AND ".$a_field." > ".$ilDB->quote(0, "integer").
563 " AND ".$a_field." IS NOT NULL";
564 }
565 if($a_sub_field)
566 {
567 $sql .= " AND ".$a_sub_field." = ".$ilDB->quote($a_sub_id, "integer");
568 }
569 $sql .= " GROUP BY ts_day".
570 " ORDER BY ts_day";
571 $set = $ilDB->query($sql);
572 while($row = $ilDB->fetchAssoc($set))
573 {
574 $res[$row["ts_day"]] = $row[$a_field];
575
576 $deleted = max($row["deleted"], $deleted);
577 }
578
579 if($a_build_full_period)
580 {
581 $period_first = $a_day_from;
582 $period_last = $a_day_to;
583
584 // check if sub was deleted in period
585 if($a_table == "wiki_stat_page" && $a_sub_field && $deleted)
586 {
587 $sql = "SELECT MAX(ts_day) last_day, MIN(ts_day) first_day".
588 " FROM ".$a_table.
589 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
590 " AND ".$a_sub_field." = ".$ilDB->quote($a_sub_id, "integer");
591 $set = $ilDB->query($sql);
592 $row = $ilDB->fetchAssoc($set);
593 $last_day = $row["last_day"];
594 if($last_day < $period_last)
595 {
596 $period_last = $last_day;
597 }
598 $first_day = $row["first_day"];
599 if($first_day > $period_first)
600 {
601 $period_first = $first_day;
602 }
603 }
604
605 $last_before_period = null;
606 if(!$res[$a_day_from])
607 {
608 $last_before_period = self::getWikiLast($a_wiki_id, $a_day_from, $a_table, $a_field, $a_sub_field, $a_sub_id);
609 }
610
611 // no need to allow zero here as we are not building averages
612 self::buildFullPeriodData($res, $period_first, $period_last, $last_before_period);
613 }
614
615 return $res;
616 }
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 $ilDB, $res, $row, buildFullPeriodData(), and getWikiLast().

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 639 of file class.ilWikiStat.php.

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

References $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 1015 of file class.ilWikiStat.php.

1016 {
1017 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);
1018 }
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 1020 of file class.ilWikiStat.php.

1021 {
1022 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);
1023 }

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 842 of file class.ilWikiStat.php.

843 {
844 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat", "del_pages", "SUM(%s)");
845 }
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 876 of file class.ilWikiStat.php.

877 {
878 global $ilDB;
879
880 $res = array();
881
882 $sql = "SELECT ts_day, AVG(num_changed_pages) num_changed_pages".
883 " FROM (".
884 // subquery to build average per user
885 " SELECT ts_day, COUNT(DISTINCT(page_id)) num_changed_pages".
886 " FROM wiki_stat_page_user".
887 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
888 " AND ts_day >= ".$ilDB->quote($a_day_from, "text").
889 " AND ts_day <= ".$ilDB->quote($a_day_to, "text").
890 " AND changes > ".$ilDB->quote(0, "integer").
891 " AND changes IS NOT NULL".
892 " GROUP BY ts_day, user_id".
893 ") aggr_user".
894 " GROUP BY ts_day".
895 " ORDER BY ts_day";
896 $set = $ilDB->query($sql);
897 while($row = $ilDB->fetchAssoc($set))
898 {
899 $res[$row["ts_day"]] = $row["num_changed_pages"];
900 }
901
902 return $res;
903 }

References $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 852 of file class.ilWikiStat.php.

853 {
854 global $ilDB;
855
856 $res = array();
857
858 $sql = "SELECT ts_day, COUNT(DISTINCT(page_id)) num_changed_pages".
859 " FROM wiki_stat_page_user".
860 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
861 " AND ts_day >= ".$ilDB->quote($a_day_from, "text").
862 " AND ts_day <= ".$ilDB->quote($a_day_to, "text").
863 " AND changes > ".$ilDB->quote(0, "integer").
864 " AND changes IS NOT NULL".
865 " GROUP BY ts_day".
866 " ORDER BY ts_day";
867 $set = $ilDB->query($sql);
868 while($row = $ilDB->fetchAssoc($set))
869 {
870 $res[$row["ts_day"]] = $row["num_changed_pages"];
871 }
872
873 return $res;
874 }

References $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 995 of file class.ilWikiStat.php.

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

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 1000 of file class.ilWikiStat.php.

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

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 1025 of file class.ilWikiStat.php.

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

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 1030 of file class.ilWikiStat.php.

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

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 985 of file class.ilWikiStat.php.

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

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 990 of file class.ilWikiStat.php.

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

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 618 of file class.ilWikiStat.php.

619 {
620 global $ilDB;
621
622 // get last existing value before period (zero is valid)
623 $sql = "SELECT MAX(".$a_field.") latest".
624 " FROM ".$a_table.
625 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
626 " AND ts_day < ".$ilDB->quote($a_day_from, "text");
627 if($a_sub_field)
628 {
629 $sql .= " AND ".$a_sub_field." = ".$ilDB->quote($a_sub_id, "integer");
630 }
631 $sql .= " GROUP BY ts_day".
632 " ORDER BY ts_day DESC";
633 $ilDB->setLimit(1);
634 $set = $ilDB->query($sql);
635 $last_before_period = $ilDB->fetchAssoc($set);
636 return $last_before_period["latest"];
637 }

References $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 837 of file class.ilWikiStat.php.

838 {
839 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_user", "new_pages", "user_id", "AVG(%s)", "SUM(%s)");
840 }

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 832 of file class.ilWikiStat.php.

833 {
834 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_user", "new_pages", "SUM(%s)");
835 }

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 827 of file class.ilWikiStat.php.

828 {
829 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat", "num_pages", "MAX(%s)", null, null, true);
830 }

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 962 of file class.ilWikiStat.php.

963 {
964 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page", "num_ratings", "SUM(%s)");
965 }

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 967 of file class.ilWikiStat.php.

968 {
969 return self::getWikiAggrSub($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page", "num_ratings", "page_id", "AVG(%s)", "SUM(%s)");
970 }

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 1040 of file class.ilWikiStat.php.

1041 {
1042 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page_user", "changes", "SUM(%s)", "page_id", $a_page_id);
1043 }

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 1045 of file class.ilWikiStat.php.

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

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 1075 of file class.ilWikiStat.php.

1076 {
1077 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);
1078 }

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 1065 of file class.ilWikiStat.php.

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

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 1080 of file class.ilWikiStat.php.

1081 {
1082 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page", "footnotes", "MAX(%s)", "page_id", $a_page_id, true);
1083 }

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 1060 of file class.ilWikiStat.php.

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

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 1085 of file class.ilWikiStat.php.

1086 {
1087 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page", "num_ratings", "SUM(%s)", "page_id", $a_page_id);
1088 }

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 1055 of file class.ilWikiStat.php.

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

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 1050 of file class.ilWikiStat.php.

1051 {
1052 return self::getWikiUserEditPages($a_wiki_id, $a_day_from, $a_day_to, "page_id", $a_page_id);
1053 }

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 1070 of file class.ilWikiStat.php.

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

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 972 of file class.ilWikiStat.php.

973 {
974 $res = self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat", "avg_rating", "AVG(%s)");
975
976 foreach(array_keys($res) as $day)
977 {
978 // int-to-float
979 $res[$day] = $res[$day]/100;
980 }
981
982 return $res;
983 }

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 847 of file class.ilWikiStat.php.

848 {
849 return self::getWikiAggr($a_wiki_id, $a_day_from, $a_day_to, "wiki_stat_page_user", "read_events", "SUM(%s)");
850 }

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 905 of file class.ilWikiStat.php.

906 {
907 global $ilDB;
908
909 $res = array();
910
911 $sql = "SELECT ts_day, COUNT(DISTINCT(user_id)) num_changed_users".
912 " FROM wiki_stat_page_user".
913 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
914 " AND ts_day >= ".$ilDB->quote($a_day_from, "text").
915 " AND ts_day <= ".$ilDB->quote($a_day_to, "text").
916 " AND changes > ".$ilDB->quote(0, "integer").
917 " AND changes IS NOT NULL";
918 if($a_sub_field)
919 {
920 $sql .= " AND ".$a_sub_field." = ".$ilDB->quote($a_sub_id, "integer");
921 }
922 $sql .= " GROUP BY ts_day".
923 " ORDER BY ts_day";
924 $set = $ilDB->query($sql);
925 while($row = $ilDB->fetchAssoc($set))
926 {
927 $res[$row["ts_day"]] = $row["num_changed_users"];
928 }
929
930 return $res;
931 }

References $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 933 of file class.ilWikiStat.php.

934 {
935 global $ilDB;
936
937 $res = array();
938
939 $sql = "SELECT ts_day, AVG(num_changed_users) num_changed_users".
940 " FROM (".
941 // subquery to build average per page
942 " SELECT ts_day, COUNT(DISTINCT(user_id)) num_changed_users".
943 " FROM wiki_stat_page_user".
944 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id, "integer").
945 " AND ts_day >= ".$ilDB->quote($a_day_from, "text").
946 " AND ts_day <= ".$ilDB->quote($a_day_to, "text").
947 " AND changes > ".$ilDB->quote(0, "integer").
948 " AND changes IS NOT NULL".
949 " GROUP BY ts_day, page_id".
950 ") aggr_user".
951 " GROUP BY ts_day".
952 " ORDER BY ts_day";
953 $set = $ilDB->query($sql);
954 while($row = $ilDB->fetchAssoc($set))
955 {
956 $res[$row["ts_day"]] = $row["num_changed_users"];
957 }
958
959 return $res;
960 }

References $ilDB, $res, and $row.

◆ getWikiWords()

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

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

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

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 1010 of file class.ilWikiStat.php.

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

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 $ilUser;
138
139 if(!$a_user_id)
140 {
141 $a_user_id = $ilUser->getId();
142 }
143 if(!$a_user_id || $a_user_id == ANONYMOUS_USER_ID)
144 {
145 return;
146 }
147
148 switch((int)$a_event)
149 {
151 self::handlePageCreated($a_page_obj, $a_user_id);
152 break;
153
155 self::handlePageUpdated($a_page_obj, $a_user_id, $a_additional_data);
156 break;
157
159 self::handlePageRead($a_page_obj, $a_user_id);
160 break;
161
163 self::handlePageDeletion($a_page_obj, $a_user_id);
164 break;
165
167 self::handlePageRating($a_page_obj, $a_user_id);
168 break;
169
170 default:
171 return;
172 }
173 }
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 $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 389 of file class.ilWikiStat.php.

390 {
391 // wiki: num_pages (count)
392 self::writeStat($a_page_obj->getWikiId(),
393 array(
394 "num_pages" => array("integer", self::countPages($a_page_obj->getWikiId())),
395 "del_pages" => array("integer", 0),
396 "avg_rating" => array("integer", 0)
397 ));
398
399 // user: new_pages+1
400 self::writeStatUser($a_page_obj->getWikiId(), $a_user_id,
401 array(
402 "new_pages" => array("increment", 1)
403 ));
404 }
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 $ilDB;
458
459 // copy last entry to have deletion timestamp
460 $sql = "SELECT * ".
461 " FROM wiki_stat_page".
462 " WHERE wiki_id = ".$ilDB->quote($a_page_obj->getWikiId(), "integer").
463 " AND page_id = ".$ilDB->quote($a_page_obj->getId(), "integer") .
464 " ORDER BY ts DESC";
465 $ilDB->setLimit(1);
466 $set = $ilDB->query($sql);
467
468 // #15748
469 if($ilDB->numRows($set))
470 {
471 $data = $ilDB->fetchAssoc($set);
472
473 // see self::handlePageUpdated()
474 $values = array(
475 "int_links" => array("integer", $data["int_links"]),
476 "ext_links" => array("integer", $data["ext_links"]),
477 "footnotes" => array("integer", $data["footnotes"]),
478 "num_words" => array("integer", $data["num_words"]),
479 "num_chars" => array("integer", $data["num_chars"]),
480 "num_ratings" => array("integer", $data["num_ratings"]),
481 "avg_rating" => array("integer", $data["avg_rating"]),
482 );
483 self::writeStatPage((int) $a_page_obj->getWikiId(), $a_page_obj->getId(), $values);
484 }
485
486 // mark all page entries as deleted
487 $ilDB->manipulate("UPDATE wiki_stat_page".
488 " SET deleted = ".$ilDB->quote(1, "integer").
489 " WHERE page_id = ".$ilDB->quote($a_page_obj->getId(), "integer").
490 " AND wiki_id = ".$ilDB->quote($a_page_obj->getWikiId(), "integer"));
491
492 // wiki: del_pages+1, num_pages (count), avg_rating
493 $rating = self::getAverageRating($a_page_obj->getWikiId());
494 self::writeStat($a_page_obj->getWikiId(),
495 array(
496 "del_pages" => array("increment", 1),
497 "num_pages" => array("integer", self::countPages($a_page_obj->getWikiId())),
498 "avg_rating" => array("integer", $rating["avg"]*100)
499 ));
500 }
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, $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 508 of file class.ilWikiStat.php.

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

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 440 of file class.ilWikiStat.php.

441 {
442 // page_user: read_events+1
443 self::writeStatPageUser($a_page_obj->getWikiId(), $a_page_obj->getId(), $a_user_id,
444 array(
445 "read_events" => array("increment", 1)
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 413 of file class.ilWikiStat.php.

414 {
415 // page_user: changes+1
416 self::writeStatPageUser($a_page_obj->getWikiId(), $a_page_obj->getId(), $a_user_id,
417 array(
418 "changes" => array("increment", 1)
419 ));
420
421 // page: see ilWikiPage::afterUpdate()
422 $values = array(
423 "int_links" => array("integer", $a_page_data["int_links"]),
424 "ext_links" => array("integer", $a_page_data["ext_links"]),
425 "footnotes" => array("integer", $a_page_data["footnotes"]),
426 "num_words" => array("integer", $a_page_data["num_words"]),
427 "num_chars" => array("integer", $a_page_data["num_chars"]),
428 "num_ratings" => array("integer", 0),
429 "avg_rating" => array("integer", 0)
430 );
431 self::writeStatPage($a_page_obj->getWikiId(), $a_page_obj->getId(), $values);
432 }

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 195 of file class.ilWikiStat.php.

196 {
197 global $ilDB;
198
199 $tstamp = self::getTimestamp();
200 $a_primary["ts"] = array("timestamp", $tstamp);
201
202 $ilAtomQuery = $ilDB->buildAtomQuery();
203 $ilAtomQuery->addTableLock($a_table);
204
205 $ilAtomQuery->addQueryCallable(
206 function(ilDBInterface $ilDB) use($a_table, $a_primary, $a_values, $tstamp, &$is_update){
207
208 $primary = array();
209 foreach($a_primary as $column => $value)
210 {
211 $primary[] = $column." = ".$ilDB->quote($value[1], $value[0]);
212 }
213 $primary = implode(" AND ", $primary);
214
215 $set = $ilDB->query("SELECT ts FROM ".$a_table.
216 " WHERE ".$primary);
217
218 $is_update = (bool)$ilDB->numRows($set);
219
220 // update (current timeframe)
221 if($is_update)
222 {
223 $values = array();
224 foreach($a_values as $column => $value)
225 {
226 if($value[0] == "increment")
227 {
228 $values[] = $column." = ".$column."+1";
229 }
230 else if($value[0] == "decrement")
231 {
232 $values[] = $column." = ".$column."-1";
233 }
234 else
235 {
236 $values[] = $column." = ".$ilDB->quote($value[1], $value[0]);
237 }
238 }
239 $values = implode(", ", $values);
240
241 $sql = "UPDATE ".$a_table.
242 " SET ".$values.
243 " WHERE ".$primary;
244 }
245 // insert (no entry yet for current time frame)
246 else
247 {
248 $a_values = array_merge($a_primary, $a_values);
249 $a_values["ts_day"] = array("text", substr($tstamp, 0, 10));
250 $a_values["ts_hour"] = array("integer", (int)substr($tstamp, 11, 2));
251
252 $values = array();
253 foreach($a_values as $column => $value)
254 {
255 $columns[] = $column;
256 if($value[0] == "increment")
257 {
258 $value[0] = "integer";
259 }
260 else if($value[0] == "decrement")
261 {
262 $value[0] = "integer";
263 $value[1] = 0;
264 }
265 $values[] = $ilDB->quote($value[1], $value[0]);
266 }
267 $values = implode(", ", $values);
268 $columns = implode(", ", $columns);
269
270 $sql = "INSERT INTO ".$a_table.
271 " (".$columns.")".
272 " VALUES (".$values.")";
273 }
274 $ilDB->manipulate($sql);
275 });
276 $ilAtomQuery->run();
277
278 return $is_update;
279 }
$column
Definition: 39dropdown.php:62
if(! $in) $columns
Definition: Utf8Test.php:45
static getTimestamp()
Get current time frame (hourly)
Interface ilDBInterface.

References $column, $columns, $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 287 of file class.ilWikiStat.php.

288 {
289 $primary = array(
290 "wiki_id" => array("integer", $a_wiki_id)
291 );
292 self::writeData("wiki_stat", $primary, $a_values);
293 }
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 302 of file class.ilWikiStat.php.

303 {
304 $primary = array(
305 "wiki_id" => array("integer", $a_wiki_id),
306 "page_id" => array("integer", $a_page_id),
307 );
308 self::writeData("wiki_stat_page", $primary, $a_values);
309 }

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 319 of file class.ilWikiStat.php.

320 {
321 $primary = array(
322 "wiki_id" => array("integer", $a_wiki_id),
323 "page_id" => array("integer", $a_page_id),
324 "user_id" => array("integer", $a_user_id)
325 );
326 self::writeData("wiki_stat_page_user", $primary, $a_values);
327 }

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 336 of file class.ilWikiStat.php.

337 {
338 $primary = array(
339 "wiki_id" => array("integer", $a_wiki_id),
340 "user_id" => array("integer", $a_user_id)
341 );
342 self::writeData("wiki_stat_user", $primary, $a_values);
343 }

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: