openGraphData = new OpenGraphData(); $this->sqlite = $this->loadHelper('sqlite'); $this->serviceNews = new ServiceNews($this->sqlite); $this->servicePriority = new ServicePriority($this->sqlite); $this->serviceDependence = new ServiceDependence($this->sqlite); $this->serviceStream = new ServiceStream($this->sqlite); $pluginName = $this->getPluginName(); if (!$this->sqlite) { msg($pluginName . ': This plugin requires the sqlite plugin. Please install it.'); } if (!$this->sqlite->init('newsfeed', DOKU_PLUGIN . $pluginName . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR) ) { msg($pluginName . ': Cannot initialize database.'); } switch ($this->getConf('contest')) { default: case 'fykos': $this->renderer = new FykosRenderer($this); break; case 'vyfuk': $this->renderer = new VyfukRenderer($this); break; } } /** * @param $streamId integer * @return integer[] */ private function allParentDependence(int $streamId): array { $streamIds = []; $res = $this->sqlite->query('SELECT * FROM dependence WHERE parent=?', $streamId); foreach ($this->sqlite->res2arr($res) as $row) { $streamIds[] = $row['child']; } return $streamIds; } /** * @param $streamId integer * @param array $arr * @return void */ public function fullParentDependence(int $streamId, array &$arr): void { foreach ($this->allParentDependence($streamId) as $newStreamId) { if (!in_array($newStreamId, $arr)) { $arr[] = $newStreamId; $this->fullParentDependence($newStreamId, $arr); } } } }