/** * Factory method to create the settings model. * @return GridGallery_Galleries_Model_Settings */ protected function createSettingsModel() { $model = new GridGallery_Galleries_Model_Settings(); $model->setDebugEnabled($this->debugEnabled); if ($this->logger && method_exists($model, 'setLogger')) { $model->setLogger($this->logger); } return $model; }
/** * Creates the new gallery from the HTTP request * @param Rsc_Http_Request $request The HTTP request * @param Rsc_Lang $lang The instance of the language class * @param Rsc_Config $config * @return bool TRUE on success, FALSE otherwise */ public function createFromRequest(Rsc_Http_Request $request, Rsc_Lang $lang, Rsc_Config $config) { if (!($title = $request->post->get('title'))) { $title = $lang->translate('Unnamed gallery'); } $title = htmlspecialchars($request->post->get('title'), ENT_QUOTES); $res = $this->add($title); if ($res) { $id = $this->db->insert_id; $config->load('@galleries/presets.php'); $presets = $config->get('gallery_presets'); $data = $presets[$request->post->get('preset', 1)]; $settings = new GridGallery_Galleries_Model_Settings(); $settings->save($id, unserialize($data)); return true; } return false; }
/** * Returns the gallery settings from the database. * If gallery is not configured, then default settings will be loaded. * @param int $galleryId Gallery identifier. * @return array */ public function getGallerySettings($galleryId) { $model = new GridGallery_Galleries_Model_Settings(); if (null === ($settings = $model->get((int) $galleryId))) { $config = $this->getEnvironment()->getConfig(); $config->load('@galleries/settings.php'); $settings = unserialize($config->get('gallery_settings')); } return $settings; }