/** * Constructor * @param string $pluginName Plugin name. * @param string $version Plugin version. * @param string $path Path to plugin. */ public function __construct($pluginName, $version, $path) { $this->pluginName = $pluginName; $this->pluginPath = $path; /* Class loader */ $this->loader = new Rsc_ClassLoader(); /* Modules resolver */ $this->resolver = new Rsc_Resolver($this); /* Config */ $this->config = new Rsc_Config($this->defaults); $this->config->setDefaultPath(untrailingslashit($path) . '/app/configs'); try { $this->config->load('@app/global.php'); } catch (Exception $e) { } $this->config->add('plugin_name', $this->pluginName); $this->config->add('plugin_version', $version); $this->config->add('plugin_path', $path); /* Dispatcher */ $this->dispatcher = new Rsc_Dispatcher($this); }
/** * 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; }