public function createChart($chart_type) { $chart = null; if ($chart_classname = $this->getChartClassname($chart_type)) { $dao = new GraphOnTrackers_ChartDao(CodendiDataAccess::instance()); $default_title = 'Untitled ' . $chart_type; $default_description = ''; $default_width = call_user_func(array($chart_classname, 'getDefaultWidth')); $default_height = call_user_func(array($chart_classname, 'getDefaultHeight')); $id = $dao->create($this->id, $chart_type, $default_title, $default_description, $default_width, $default_height); $rank = $dao->getRank($id); $chart = call_user_func(array($chart_classname, 'create'), $this, $id, $rank, $default_title, $default_description, $default_width, $default_height); } return $chart; }
/** * Update the properties of the chart * * @return boolean true if the update is successful */ public function update($row) { $db_update_needed = false; foreach (array('rank', 'title', 'description', 'width', 'height') as $prop) { if (isset($row[$prop]) && $this->{$prop} != $row[$prop]) { $this->{$prop} = $row[$prop]; $db_update_needed = true; } } $updated = false; if ($db_update_needed) { $dao = new GraphOnTrackers_ChartDao(CodendiDataAccess::instance()); $updated = $dao->updateById($this->id, $this->graphic_report->getId(), $this->rank, $this->title, $this->description, $this->width, $this->height); } return $this->updateSpecificProperties($row) && $updated; }