getTypeData($rid, self::$table); $this->typeData = $td['images']; $this->images = preg_split("/;/", $this->typeData); } } /** * @Secured('roles' = {'authenticated'}, 'valid' = {}) * */ public function actionSave() { $this->updateData($_POST); $this->save(); $_SESSION['krihvel_notice'] = gettext("Saved"); return array('rid' => $this->getResourceID(), 'mode' => 'compile'); } /** * @Secured('roles' = {'authenticated'}, 'valid' = {}) * */ public function actionAddImages() { global $kdb; $pi = preg_split("/;/", $_POST['imgs']); $newimgs = array(); foreach ($pi as $p) { $t = substr($p, 3); if ( is_numeric($t) ) { $newimgs[] = substr($p, 3); } } $kdb->query("DELETE FROM gallery WHERE resourceID=".$this->getResourceID()); $kdb->query("INSERT INTO gallery VALUES (".$this->getResourceID().", '".implode(";", $newimgs)."')"); $_SESSION['krihvel_notice'] = gettext("Saved"); return array('rid' => $this->getResourceID(), 'mode' => 'view'); } static function getThumbnail($rid) { return "plugins/gallery/gallery.gif"; } public function getAllImages() { global $user, $kdb; $imgs = $kdb->getResourcesByType('image', array('userId' => $user->getId())); return $imgs; } public function getAddedImages() { return $this->images; } public function listImages() { global $kdb; $res = array(); foreach ( $this->images as $imId ) { if ( is_numeric($imId) ) { $x = $kdb->getResourcesByType('image', array('resourceID' => $imId)); if ( count($x) == 1 ) { $res[] = $x[0]; } } } return $res; } } ?>