File modules/cms/ui/action/index/IndexEditAction.class.php
Last commit: Sun Jan 5 23:14:07 2025 +0100 Jan Dankert New UI feature: Show a timeline in the start page.
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 $max = 0; 46 foreach( $changes as $change ) { 47 $idx = date('Ymd',$change['lastchange_date']); 48 $days[ $idx ] = intval(@$days[$idx]) + 1; 49 } 50 51 // maximum of all days 52 foreach( $days as $dayCount ) { 53 $max = max($max,$dayCount); 54 } 55 $days = array_map( function ($dayCount) use ($max) { 56 $maxHeight = 25; 57 $height = floor($maxHeight*$dayCount/$max); 58 return str_repeat("\xe2\x80\x8a",$height); 59 },$days); 60 61 $timeline = array_map( function( $change ) { 62 // already loaded per SQL 63 //$change['username'] = ((new User($change['userid']))->load()->getName()); 64 if ( $change['pageid'] ) { 65 $change['action'] = 'page'; 66 $change['id' ] = $change['pageid']; 67 } 68 if ( $change['fileid'] ) { 69 $change['action'] = 'file'; 70 $change['id' ] = $change['fileid']; 71 } 72 if ( $change['templateid'] ) { 73 $change['action'] = 'template'; 74 $change['id' ] = $change['templateid']; 75 } 76 return $change; 77 },$changes ); 78 79 $this->setTemplateVar('timeline',$timeline ); 80 $this->setTemplateVar('days' ,$days ); 81 } 82 83 $this->setTemplateVar('isAdmin' ,$this->userIsAdmin() ); 84 } 85 86 87 public function post() { 88 } 89 }
Downloadmodules/cms/ui/action/index/IndexEditAction.class.php
History 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.