/** * Constructor. * * @param array $config An optional associative array of configuration settings. */ public function __construct($config = array()) { parent::__construct($config); $app = JFactory::getApplication(); if (!isset($config['model'])) { $config['model'] = $app->input->get('model', null, 'cmd'); } if (!isset($config['limit'])) { $config['limit'] = $app->input->get('limit', 0, 'uint'); } if (!isset($config['limitstart'])) { $config['limitstart'] = $app->input->get('limitstart', 0, 'uint'); } if (!isset($config['total'])) { $config['total'] = $app->input->get('total', 0, 'uint'); } $this->model = $config['model']; $this->limit = $config['limit']; $this->limitstart = $config['limitstart']; $this->total = $config['total']; // Validate requested model $valid_models = PFdatagenHelper::getModelList(); if (!isset($valid_models[$this->model])) { $this->model = null; } }
/** * Display the view * */ public function display($tpl = null) { $this->models = PFdatagenHelper::getModelList(); // Check for errors if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } if ($this->getLayout() !== 'modal') { $this->addToolbar(); } parent::display($tpl); }
/** * Generates the item data and then returns it * * @return array $data Item data */ protected function getFormData() { $nulldate = $this->getDbo()->getNullDate(); $project = PFdatagenHelper::getRandomProject(); $milestone = PFdatagenHelper::getRandomMilestone($project->id); $data = array(); $data['project_id'] = $project->id; $data['milestone_id'] = rand(0, 100) <= 50 ? 0 : ($milestone == false ? 0 : $milestone->id); $data['title'] = PFdatagenHelper::getRandomString(64, 'Task List - '); $data['description'] = PFdatagenHelper::getRandomString(255); $data['created'] = PFdatagenHelper::getRandomPastDateTime($project->created, 0); $data['created_by'] = PFdatagenHelper::getRandomUserId(); $data['modified_by'] = PFdatagenHelper::getRandomUserId(50); $data['modified'] = PFdatagenHelper::getRandomPastDateTime($data['created'], $data['modified_by'] ? 0 : 100); $data['state'] = PFdatagenHelper::getRandomState(); $data['rules'] = PFdatagenHelper::getRandomUserGroupIds($data['milestone_id'] ? $milestone->access : $project->access); $data['access'] = $data['milestone_id'] ? $milestone->access : $project->access; return $data; }
/** * Generates the item data and then returns it * * @return array $data Item data */ protected function getFormData() { $nulldate = $this->getDbo()->getNullDate(); $project = PFdatagenHelper::getRandomProject(); $data = array(); $data['project_id'] = $project->id; $data['title'] = PFdatagenHelper::getRandomString(64, 'Milestone - '); $data['description'] = PFdatagenHelper::getRandomText(); $data['created'] = PFdatagenHelper::getRandomPastDateTime($project->created, 0); $data['created_by'] = PFdatagenHelper::getRandomUserId(); $data['modified_by'] = PFdatagenHelper::getRandomUserId(50); $data['modified'] = PFdatagenHelper::getRandomPastDateTime($data['created'], $data['modified_by'] ? 0 : 100); $data['state'] = PFdatagenHelper::getRandomState(); $data['start_date'] = PFdatagenHelper::getRandomPastDateTime($project->start_date == $nulldate ? 30 : $project->start_date); $data['end_date'] = PFdatagenHelper::getRandomFutureDateTime($project->end_date == $nulldate ? 90 : $project->end_date); $data['rules'] = PFdatagenHelper::getRandomUserGroupIds($project->access); $data['access'] = $project->access; $data['labels'] = PFdatagenHelper::getRandomLabelIds($project->id, 'com_pfmilestones.milestone'); return $data; }
/** * Generates the item data and then returns it * * @return array $data Item data */ protected function getFormData() { $nulldate = $this->getDbo()->getNullDate(); $project = PFdatagenHelper::getRandomProject(); if (!$project) { return false; } $data = array(); $parent_access = $project->access; $data['project_id'] = $project->id; $data['title'] = PFdatagenHelper::getRandomString(64, 'Topic - '); $data['description'] = PFdatagenHelper::getRandomText(); $data['created'] = PFdatagenHelper::getRandomPastDateTime($project->created, 0); $data['created_by'] = PFdatagenHelper::getRandomUserId(); $data['modified_by'] = PFdatagenHelper::getRandomUserId(50); $data['modified'] = PFdatagenHelper::getRandomPastDateTime($data['created'], $data['modified_by'] ? 0 : 100); $data['state'] = PFdatagenHelper::getRandomState(); $data['rules'] = PFdatagenHelper::getRandomUserGroupIds($parent_access); $data['access'] = $parent_access; return $data; }
/** * Generates the item data and then returns it * * @return array $data Item data */ protected function getFormData() { $nulldate = $this->getDbo()->getNullDate(); $project = PFdatagenHelper::getRandomProject(); $task = PFdatagenHelper::getRandomTask($project->id); if (!$task) { return false; } $data = array(); $parent_access = $project->access; $data['project_id'] = $project->id; $data['task_id'] = $task->id; $data['task_title'] = $task->title; $data['description'] = PFdatagenHelper::getRandomText(); $data['log_date'] = PFdatagenHelper::getRandomPastDateTime($task->created, 0); $data['log_time'] = $this->getRandomTaskTime(); $data['billable'] = $this->getRandomBillable(); $data['rate'] = PFdatagenHelper::getRandomTaskRate($task->rate ? $task->rate : 0); $data['created'] = PFdatagenHelper::getRandomPastDateTime($task->created, 0); $data['created_by'] = PFdatagenHelper::getRandomUserId(); $data['modified_by'] = PFdatagenHelper::getRandomUserId(50); $data['modified'] = PFdatagenHelper::getRandomPastDateTime($data['created'], $data['modified_by'] ? 0 : 100); $data['state'] = PFdatagenHelper::getRandomState(); $data['rules'] = PFdatagenHelper::getRandomUserGroupIds($parent_access); $data['access'] = $parent_access; return $data; }
/** * Returns a list of project labels * * @return array */ protected function getRandomLabels() { // 50% chance that no labels are created if (rand(1, 100) <= 50) { return array(); } $labels = array(); $elements = array('com_pfprojects.project', 'com_pfmilestones.milestone', 'com_pftasks.task', 'com_pfforum.topic', 'com_pfrepo.directory', 'com_pfrepo.note', 'com_pfrepo.file'); $styles = array('', 'label-success', 'label-warning', 'label-important', 'label-info', 'label-inverse'); foreach ($elements as $element) { $data = array('title' => array(), 'style' => array(), 'id' => array()); $i = 0; $x = 0; while ($i < 5) { // 50% chance that the label is created if (rand(0, 100) <= 50) { $data['title'][$x] = PFdatagenHelper::getRandomString(24, 'Label - '); $data['style'][$x] = $styles[rand(0, 5)]; $data['id'][$x] = ''; $x++; } $i++; } if ($x) { $labels[$element] = $data; } } return $labels; }
/** * Returns up to 5 random user id's * * @return array $users The user id's */ protected function getRandomUsers() { $users = array(); $i = 0; while ($i < 5) { $uid = PFdatagenHelper::getRandomUserId(); if (!in_array($uid, $users)) { $users[] = $uid; } $i++; } return $users; }