/** * Return singleton * @return Application_Model_ProfilesMapper */ public static function i() { if (self::$instance === null) { self::$instance = new Application_Model_ProfilesMapper(); } return self::$instance; }
/** * Restore backupped profiles * This is not a trigger of plugin API. It's called by Backupper plugin */ function restoreItems($items) { $models = Application_Model_ProfilesMapper::i()->fetchAll(); // cleaning up all shares foreach ($models as $model) { Application_Model_ProfilesMapper::i()->delete($model); } foreach (@$items['profiles'] as $modelInfo) { $model = new Application_Model_Profile(); $model->setArg(@$modelInfo['arg'])->setCondProviders(@$modelInfo['cond_providers'] !== '' ? @$modelInfo['cond_providers'] : null)->setCondFormats(@$modelInfo['cond_formats'] !== '' ? @$modelInfo['cond_formats'] : null)->setCondDevices(@$modelInfo['cond_devices'] !== '' ? @$modelInfo['cond_devices'] : null)->setLabel(@$modelInfo['label'])->setWeight(@$modelInfo['weight']); // i don't set id, or db adapter will try to update old data that i cleaned Application_Model_ProfilesMapper::i()->save($model); } return X_Env::_('p_profiles_backupper_restoreditems') . ": " . count($items['profiles']); }
/** * @return Application_Form_Device */ protected function initForm() { $form = new Application_Form_Device(); $profiles = Application_Model_ProfilesMapper::i()->fetchAll(); $profilesMO = array(); foreach ($profiles as $profile) { $profilesMO[(string) $profile->getId()] = "{$profile->getId()} - {$profile->getLabel()}"; } $guis = X_VlcShares_Plugins::broker()->getPlugins(); $guisMO = array(); foreach ($guis as $gui) { if ($gui instanceof X_VlcShares_Plugins_RendererInterface) { $guisMO[get_class($gui)] = "{$gui->getName()} - {$gui->getDescription()}"; } } $form->setProfilesValues($profilesMO)->setAltProfilesValues($profilesMO)->setGuisValues($guisMO); return $form; }
private function _initConfigsForm($configs, $posts = null) { if ($this->configForm === null) { $this->configForm = new Application_Form_Configs($configs); $this->configForm->setAction($this->_helper->url('save', 'configs')); $languages = array(); foreach (new DirectoryIterator(APPLICATION_PATH . "/../languages/") as $entry) { if ($entry->isFile() && pathinfo($entry->getFilename(), PATHINFO_EXTENSION) == 'ini') { if (count(explode('.', $entry->getFilename())) == 2) { $languages[$entry->getFilename()] = $entry->getFilename(); } } } try { $this->configForm->general_languageFile->setMultiOptions($languages); } catch (Exception $e) { X_Debug::w("No language settings? O_o"); } try { $this->configForm->general_debug_level->setMultiOptions(array('-1' => '-1: ' . X_Env::_('config_debug_level_optforced'), '0' => '0: ' . X_Env::_('config_debug_level_optfatal'), '1' => '1: ' . X_Env::_('config_debug_level_opterror'), '2' => '2: ' . X_Env::_('config_debug_level_optwarning'), '3' => '3: ' . X_Env::_('config_debug_level_optinfo'))); } catch (Exception $e) { X_Debug::w("No debug level settings? O_o"); } try { $this->configForm->vlc_version->setMultiOptions(array('1.1.x' => '<= 1.1.x', '2.x' => '2.x')); } catch (Exception $e) { X_Debug::w("No vlc version setting? O_o"); } try { $_guis = X_VlcShares_Plugins::broker()->getPlugins(); $guis = array(); foreach ($_guis as $gui) { if ($gui instanceof X_VlcShares_Plugins_RendererInterface) { $guis[get_class($gui)] = "{$gui->getName()} - {$gui->getDescription()}"; } } $this->configForm->helpers_devices_gui->setMultiOptions($guis); } catch (Exception $e) { X_Debug::w("No gui settings"); } try { $_profiles = Application_Model_ProfilesMapper::i()->fetchAll(); foreach ($_profiles as $profile) { $profiles[$profile->getId()] = "{$profile->getId()} - {$profile->getLabel()}"; } $this->configForm->helpers_devices_profile->setMultiOptions($profiles); } catch (Exception $e) { X_Debug::w("No gui settings"); } } if ($posts !== null && is_array($posts)) { $this->configForm->isValid($posts); } return $this->configForm; }
private function prepareGeneralElementsForm(Application_Form_AutoConfigs $form) { try { if ($form->getElement('general_languageFile')) { $languages = array(); foreach (new DirectoryIterator(APPLICATION_PATH . "/../languages/") as $entry) { if ($entry->isFile() && pathinfo($entry->getFilename(), PATHINFO_EXTENSION) == 'ini') { if (count(explode('.', $entry->getFilename())) == 2) { $languages[$entry->getFilename()] = $entry->getFilename(); } } } $form->general_languageFile->setMultiOptions($languages); } } catch (Exception $e) { //X_Debug::w("No language settings? O_o"); } try { if ($form->getElement('general_debug_level')) { $form->general_debug_level->setMultiOptions(array('-1' => '-1: ' . X_Env::_('config_debug_level_optforced'), '0' => '0: ' . X_Env::_('config_debug_level_optfatal'), '1' => '1: ' . X_Env::_('config_debug_level_opterror'), '2' => '2: ' . X_Env::_('config_debug_level_optwarning'), '3' => '3: ' . X_Env::_('config_debug_level_optinfo'))); } } catch (Exception $e) { //X_Debug::w("No debug level settings? O_o"); } try { if ($form->getElement('vlc_version')) { $form->vlc_version->setMultiOptions(array('1.1.x' => '<= 1.1.x', '2.x' => '2.x')); } } catch (Exception $e) { //X_Debug::w("No vlc version setting? O_o"); } try { if ($form->getElement('helpers_devices_gui')) { $_guis = X_VlcShares_Plugins::broker()->getPlugins(); $guis = array(); foreach ($_guis as $gui) { if ($gui instanceof X_VlcShares_Plugins_RendererInterface) { $guis[get_class($gui)] = "{$gui->getName()} - {$gui->getDescription()}"; } } $form->helpers_devices_gui->setMultiOptions($guis); } } catch (Exception $e) { //X_Debug::w("No gui settings"); } try { if ($form->getElement('helpers_devices_profile')) { $_profiles = Application_Model_ProfilesMapper::i()->fetchAll(); foreach ($_profiles as $profile) { $profiles[$profile->getId()] = "{$profile->getId()} - {$profile->getLabel()}"; } $form->helpers_devices_profile->setMultiOptions($profiles); } } catch (Exception $e) { //X_Debug::w("No gui settings"); } }
function editAction() { $id = $this->getRequest()->getParam('id', false); if ($id === false) { $this->_helper->flashMessenger(X_Env::_('p_profiles_err_invaliddata')); $this->_helper->redirector('index', 'profiles'); } $profile = new Application_Model_Profile(); Application_Model_ProfilesMapper::i()->find($id, $profile); if (is_null($profile->getId())) { $this->_helper->flashMessenger(X_Env::_('p_profiles_err_invaliddata')); $this->_helper->redirector('index', 'profiles'); } $defaults = array('id' => $profile->getId(), 'label' => $profile->getLabel(), 'arg' => $profile->getArg(), 'link' => $profile->getLink()); /* $form = new Application_Form_FileSystemShare(); $form->setAction($this->_helper->url('save', 'filesystem')); */ $form = $this->_initForm(); $form->setDefaults($defaults); $this->view->form = $form; }