Skip to content

Instantly share code, notes, and snippets.

@somatonic
Created May 23, 2012 15:01
Show Gist options
  • Save somatonic/2775731 to your computer and use it in GitHub Desktop.
Save somatonic/2775731 to your computer and use it in GitHub Desktop.
dashboard.module
<?php
/*
*
*
*
*/
class ProcessDashboard extends Process {
protected $sel_lastedited = 'sort=-modified, limit=50, status!=unpublished, status=published, include=hidden, check_access=1';
protected $sel_unpublished = 'sort=-modified, status=unpublished';
//protected $selAll = 'sort=-modified, status!=unpublished, status=published, include=hidden, check_access=1';
public static function getModuleInfo() {
return array(
'title' => 'Process Dashboard',
'summary' => 'Show important information to the user',
'version' => 001,
'permission' => 'page-edit'
);
}
public function ___execute() {
$out = '';
/* LastModified */
$fieldset = $this->modules->get("InputfieldFieldset");
$field = $this->modules->get("InputfieldMarkup");
$field->label = "Last Modified Pages";
//$field->description = "Shows last modified pages";
$field->collapsed = Inputfield::collapsedYes;
$table = $this->modules->get('MarkupAdminDataTable');
$table->setSortable(false);
$table->setEncodeEntities(false);
$header = array('Title','Status','modified','by user');
$table->headerRow($header);
$rows = array();
$pageArr = $this->pages->get('/')->find($this->sel_lastedited);
foreach($pageArr as $p){
$status = '';
$status = $p->is(Page::statusUnpublished) ? "unpublished" : 'published';
$status .= $p->is(Page::statusLocked) ? " | locked" : '';
$status .= $p->is(Page::statusTrash) ? " | trashed" : '';
$status .= $p->is(Page::statusHidden) ? " | hidden" : '';
$editUrl = "{$this->config->urls->admin}page/edit/?id={$p->id}";
$rows[] = $p->editable() ? "<a href='{$editUrl}'>".$p->get('title|name|id').'</a>' : $p->get('title|name|id');
$rows[] = $status;
$rows[] = date('Y.m.d H:i:s',$p->modified);
$rows[] = $p->modifiedUser->name;
$table->row($rows);
$rows = null;
}
$field->value = $table->render();
$fieldset->add($field);
$out .= $fieldset->render();
unset($pageArray);
/* Unpublished */
$fieldset = $this->modules->get("InputfieldFieldset");
$field = $this->modules->get("InputfieldMarkup");
$field->label = "Unpublished Pages";
//$field->description = "Shows last modified pages";
$field->collapsed = Inputfield::collapsedNo;
$table = $this->modules->get('MarkupAdminDataTable');
$table->setSortable(false);
$table->setEncodeEntities(false);
$header = array('Title','Status','modified','by user');
$table->headerRow($header);
$rows = array();
$offset = 5*$this->input->pageNum-5;
$pageArr = $this->pages->find("start=$offset, limit=5,".$this->sel_unpublished);
//$results = $pageArr->find("limit=10");
$pagination = $pageArr->renderPager();
foreach($pageArr as $p){
$status = '';
$status = $p->is(Page::statusUnpublished) ? "unpublished" : 'published';
$status .= $p->is(Page::statusLocked) ? " | locked" : '';
$status .= $p->is(Page::statusTrash) ? " | trashed" : '';
$status .= $p->is(Page::statusHidden) ? " | hidden" : '';
$editUrl = "{$this->config->urls->admin}page/edit/?id={$p->id}";
$rows[] = $p->editable() ? "<a href='{$editUrl}' style='opacity:0.7'><s>".$p->get('title|name|id').'</s></a>' : $p->get('title|name|id');
$rows[] = $status;
$rows[] = date('Y.m.d H:i:s',$p->modified);
$rows[] = $p->modifiedUser->name;
$table->row($rows);
$rows = null;
}
$field->value = $table->render();
$fieldset->add($field);
$out .= $fieldset->render();
$out .= $pagination;
return $out;
}
public function getTotal(){
return $this->pages->get('/about/')->find($this->selAll)->count();
}
}?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment