File modules/cms/ui/action/index/IndexEditAction.class.php

Last commit: Mon Jan 6 22:48:11 2025 +0100	Jan Dankert	New: Now it is possible to remove and create new login/api token for a user; new API authorization with the authorization scheme "api".
1 <?php 2 namespace cms\ui\action\index; 3 use cms\action\Method; 4 use cms\model\User; 5 use cms\ui\action\IndexAction; 6 use cms\ui\themes\ThemeStyle; 7 use language\Messages; 8 use util\Html; 9 use util\Session; 10 use util\UIUtils; 11 use cms\base\Configuration as C; 12 use cms\action\RequestParams; 13 use cms\auth\Auth; 14 use cms\auth\AuthRunner; 15 use cms\base\Configuration; 16 use cms\base\Startup; 17 use cms\model\BaseObject; 18 use cms\model\Project; 19 use cms\model\Value; 20 use cms\ui\themes\Theme; 21 use Exception; 22 use util\json\JSON; 23 use logger\Logger; 24 use util\Less; 25 use \util\exception\ObjectNotFoundException; 26 27 /** 28 * Main action, displayed after starting the UI. 29 * 30 * @package cms\ui\action\index 31 */ 32 class IndexEditAction extends IndexAction implements Method { 33 34 public function view() { 35 36 if ( $this->currentUser ) 37 { 38 $changes = $this->currentUser->getValueChanges( time()-(60*60*24*30)); 39 40 $days = []; 41 for( $ts = time()-(60*60*24*30); $ts <= time(); $ts+=60*60*24 ) { 42 $days[ date('Ymd',$ts) ] = 0; 43 } 44 45 foreach( $changes as $change ) { 46 $idx = date('Ymd',$change['lastchange_date']); 47 $days[ $idx ] = intval(@$days[$idx]) + 1; 48 } 49 50 // maximum of all days 51 $max = 1; // not 0, to prevent Division by zero. 52 foreach( $days as $dayCount ) { 53 $max = max($max,$dayCount); 54 } 55 56 $days = array_map( function ($dayCount) use ($max) { 57 $maxHeight = 25; 58 $height = floor($maxHeight*$dayCount/$max); 59 return str_repeat("\xe2\x80\x8a",$height); 60 },$days); 61 62 $timeline = array_map( function( $change ) { 63 // already loaded per SQL 64 //$change['username'] = ((new User($change['userid']))->load()->getName()); 65 if ( $change['pageid'] ) { 66 $change['action'] = 'page'; 67 $change['id' ] = $change['pageid']; 68 } 69 if ( $change['fileid'] ) { 70 $change['action'] = 'file'; 71 $change['id' ] = $change['fileid']; 72 } 73 if ( $change['templateid'] ) { 74 $change['action'] = 'template'; 75 $change['id' ] = $change['templateid']; 76 } 77 return $change; 78 },$changes ); 79 80 $this->setTemplateVar('timeline',$timeline ); 81 $this->setTemplateVar('days' ,$days ); 82 } 83 84 $this->setTemplateVar('isAdmin' ,$this->userIsAdmin() ); 85 } 86 87 88 public function post() { 89 } 90 }
Download modules/cms/ui/action/index/IndexEditAction.class.php
History Mon, 6 Jan 2025 22:48:11 +0100 Jan Dankert New: Now it is possible to remove and create new login/api token for a user; new API authorization with the authorization scheme "api". Sun, 5 Jan 2025 23:14:07 +0100 Jan Dankert New UI feature: Show a timeline in the start page. Thu, 18 Feb 2021 01:55:01 +0100 Jan Dankert New: Action for displaying a navigation while no other action is selected.