本文整理汇总了PHP中SettingsForm::initData方法的典型用法代码示例。如果您正苦于以下问题:PHP SettingsForm::initData方法的具体用法?PHP SettingsForm::initData怎么用?PHP SettingsForm::initData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SettingsForm
的用法示例。
在下文中一共展示了SettingsForm::initData方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manage
function manage($verb, $args)
{
if (parent::manage($verb, $args)) {
return true;
}
if (!$this->getEnabled()) {
return false;
}
switch ($verb) {
case 'settings':
$journal =& Request::getJournal();
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, null, 'plugins');
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
break;
default:
return false;
}
return true;
}
示例2: manage
/**
* @see Plugin::manage()
*/
function manage($args, $request)
{
switch ($request->getUserVar('verb')) {
case 'settings':
$context = $request->getContext();
AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_PKP_MANAGER);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->register_function('plugin_url', array($this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $context->getId());
if ($request->getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
return new JSONMessage(true);
}
} else {
$form->initData();
}
return new JSONMessage(true, $form->fetch($request));
}
return parent::manage($args, $request);
}
示例3: manage
/**
* @see PKPPlugin::manage()
*/
function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
{
$returner = true;
$request = $this->getRequest();
$journal = $request->getJournal();
$this->addLocaleData();
switch ($verb) {
case 'settings':
AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_PKP_MANAGER);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->register_function('plugin_url', array($this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
if ($request->getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
$request->redirect(null, null, 'plugins');
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
break;
case 'enable':
$this->updateSetting($journal->getId(), 'enabled', true);
$message = NOTIFICATION_TYPE_SWORD_ENABLED;
$returner = false;
break;
case 'disable':
$this->updateSetting($journal->getId(), 'enabled', false);
$message = NOTIFICATION_TYPE_PLUGIN_DISABLED;
$messageParams = array('pluginName' => $this->getDisplayName());
$returner = false;
break;
case 'createDepositPoint':
case 'editDepositPoint':
$templateMgr = TemplateManager::getManager($request);
$templateMgr->register_function('plugin_url', array($this, 'smartyPluginUrl'));
$depositPointId = array_shift($args);
if ($depositPointId == '') {
$depositPointId = null;
} else {
$depositPointId = (int) $depositPointId;
}
$this->import('DepositPointForm');
$form = new DepositPointForm($this, $journal->getId(), $depositPointId);
if ($request->getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
$request->redirect(null, null, null, array('generic', $this->getName(), 'settings'));
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
break;
case 'deleteDepositPoint':
$journalId = $journal->getId();
$depositPointId = (int) array_shift($args);
$depositPoints = $this->getSetting($journalId, 'depositPoints');
unset($depositPoints[$depositPointId]);
$this->updateSetting($journalId, 'depositPoints', $depositPoints);
$request->redirect(null, null, null, array('generic', 'SwordPlugin', 'settings'));
break;
}
return $returner;
}
示例4: manage
function manage($verb, $args, &$message)
{
if (!parent::manage($verb, $args, $message)) {
return false;
}
switch ($verb) {
case 'settings':
$journal =& Request::getJournal();
Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_MANAGER));
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, null, 'plugins');
return false;
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
return true;
default:
// Unknown management verb
assert(false);
return false;
}
}
示例5: manage
function manage($verb, $args, &$message)
{
$returner = true;
$journal =& Request::getJournal();
$this->addLocaleData();
switch ($verb) {
case 'settings':
Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_MANAGER));
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, null, 'plugins');
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
break;
case 'enable':
$this->updateSetting($journal->getId(), 'enabled', true);
$message = Locale::translate('plugins.generic.sword.enabled');
$returner = false;
break;
case 'disable':
$this->updateSetting($journal->getId(), 'enabled', false);
$message = Locale::translate('plugins.generic.sword.disabled');
$returner = false;
break;
case 'createDepositPoint':
case 'editDepositPoint':
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$depositPointId = array_shift($args);
if ($depositPointId == '') {
$depositPointId = null;
} else {
$depositPointId = (int) $depositPointId;
}
$this->import('DepositPointForm');
$form = new DepositPointForm($this, $journal->getId(), $depositPointId);
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, null, null, array('generic', $this->getName(), 'settings'));
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
break;
case 'deleteDepositPoint':
$journalId = $journal->getId();
$depositPointId = (int) array_shift($args);
$depositPoints = $this->getSetting($journalId, 'depositPoints');
unset($depositPoints[$depositPointId]);
$this->updateSetting($journalId, 'depositPoints', $depositPoints);
Request::redirect(null, null, null, array('generic', 'SwordPlugin', 'settings'));
break;
}
return $returner;
}
示例6: manage
/**
* Execute a management verb on this plugin
* @param $verb string
* @param $args array
* @param $message string Result status message
* @param $messageParams array Parameters for the message key
* @return boolean
*/
function manage($verb, $args, &$message, &$messageParams)
{
if (!parent::manage($verb, $args, $message, $messageParams)) {
return false;
}
switch ($verb) {
case 'settings':
$journal =& Request::getJournal();
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
return false;
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
return true;
default:
// Unknown management verb
assert(false);
return false;
}
}
示例7: manage
function manage($verb, $args, &$message)
{
$returner = true;
$journal =& Request::getJournal();
switch ($verb) {
case 'settings':
Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_MANAGER));
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, null, 'plugins');
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
break;
case 'enable':
$this->updateSetting($journal->getId(), 'enabled', true);
$message = Locale::translate('plugins.generic.webfeed.enabled');
$returner = false;
break;
case 'disable':
$this->updateSetting($journal->getId(), 'enabled', false);
$message = Locale::translate('plugins.generic.webfeed.disabled');
$returner = false;
break;
}
return $returner;
}
示例8: manage
/**
* Perform management functions
*/
function manage($verb, $args, &$message, &$messageParams)
{
if (!parent::manage($verb, $args, $message, $messageParams)) {
return false;
}
switch ($verb) {
case 'settings':
$journal =& Request::getJournal();
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$pageCrumbs = array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'manager'), 'user.role.manager'), array(Request::url(null, 'manager', 'plugins'), __('manager.plugins'), true));
$templateMgr->assign('pageHierarchy', $pageCrumbs);
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
$form->readInputData();
if (Request::getUserVar('addBlock')) {
// Add a block
$editData = true;
$blocks = $form->getData('blocks');
array_push($blocks, '');
$form->_data['blocks'] = $blocks;
} else {
if (($delBlock = Request::getUserVar('delBlock')) && count($delBlock) == 1) {
// Delete an block
$editData = true;
list($delBlock) = array_keys($delBlock);
$delBlock = (int) $delBlock;
$blocks = $form->getData('blocks');
if (isset($blocks[$delBlock]) && !empty($blocks[$delBlock])) {
$deletedBlocks = explode(':', $form->getData('deletedBlocks'));
array_push($deletedBlocks, $blocks[$delBlock]);
$form->setData('deletedBlocks', join(':', $deletedBlocks));
}
array_splice($blocks, $delBlock, 1);
$form->_data['blocks'] = $blocks;
} else {
if (Request::getUserVar('save')) {
$editData = true;
$form->execute();
} else {
$form->initData();
}
}
}
if (!isset($editData) && $form->validate()) {
$form->execute();
$form->display();
exit;
} else {
$form->display();
exit;
}
return true;
default:
// Unknown management verb
assert(false);
return false;
}
}
示例9: manage
/**
* @see PKPPlugin::manage()
*/
function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
{
if (!parent::manage($verb, $args, $message, $messageParams)) {
return false;
}
$request =& $this->getRequest();
switch ($verb) {
case 'settings':
$journal = $request->getJournal();
$templateMgr = TemplateManager::getManager($request);
$templateMgr->register_function('plugin_url', array($this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $journal->getId());
$form->readInputData();
if ($request->getUserVar('addBlock')) {
// Add a block
$editData = true;
$blocks = $form->getData('blocks');
array_push($blocks, '');
$form->_data['blocks'] = $blocks;
} else {
if (($delBlock = $request->getUserVar('delBlock')) && count($delBlock) == 1) {
// Delete an block
$editData = true;
list($delBlock) = array_keys($delBlock);
$delBlock = (int) $delBlock;
$blocks = $form->getData('blocks');
if (isset($blocks[$delBlock]) && !empty($blocks[$delBlock])) {
$deletedBlocks = explode(':', $form->getData('deletedBlocks'));
array_push($deletedBlocks, $blocks[$delBlock]);
$form->setData('deletedBlocks', join(':', $deletedBlocks));
}
array_splice($blocks, $delBlock, 1);
$form->_data['blocks'] = $blocks;
} else {
if ($request->getUserVar('save')) {
$editData = true;
$form->execute();
} else {
$form->initData();
}
}
}
if (!isset($editData) && $form->validate()) {
$form->execute();
$form->display();
exit;
} else {
$form->display();
exit;
}
return true;
default:
// Unknown management verb
assert(false);
return false;
}
}
示例10: manage
function manage($verb, $args, &$message)
{
$returner = true;
$conference =& Request::getConference();
switch ($verb) {
case 'settings':
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$this->import('SettingsForm');
$form = new SettingsForm($this, $conference->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
$returner = false;
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
break;
case 'enable':
$this->updateSetting($conference->getId(), 0, 'enabled', true);
$message = __('plugins.generic.announcementfeed.enabled');
$returner = false;
break;
case 'disable':
$this->updateSetting($conference->getId(), 0, 'enabled', false);
$message = __('plugins.generic.announcementfeed.enabled');
$returner = false;
break;
}
return $returner;
}
示例11: manage
/**
* @see GenericPlugin::manage()
*/
function manage($verb, $args, &$message, &$messageParams)
{
if (!parent::manage($verb, $args, $message, $messageParams)) {
return false;
}
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$journal =& Request::getJournal();
switch ($verb) {
case 'connect':
$this->import('classes.form.DataverseAuthForm');
$form = new DataverseAuthForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, 'manager', 'plugin', array('generic', $this->getName(), 'select'));
return false;
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
return true;
case 'select':
$this->import('classes.form.DataverseSelectForm');
$form = new DataverseSelectForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, 'manager', 'plugin', array('generic', $this->getName(), 'settings'));
return false;
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
return true;
case 'settings':
$this->import('classes.form.SettingsForm');
$form = new SettingsForm($this, $journal->getId());
if (Request::getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
Request::redirect(null, 'manager', 'plugin', array('generic'));
return false;
} else {
$form->display();
}
} else {
$form->initData();
$form->display();
}
return true;
default:
// Unknown management verb
assert(false);
return false;
}
}
示例12: manage
/**
* Perform management functions
*/
function manage($verb, $args)
{
$returner = true;
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
$pageCrumbs = array(array(Request::url(null, null, 'user'), 'navigation.user'), array(Request::url(null, null, 'manager'), 'user.role.manager'));
$conference =& Request::getConference();
switch ($verb) {
case 'enable':
$this->setEnabled(true);
break;
case 'disable':
$this->setEnabled(false);
break;
case 'settings':
$pageCrumbs[] = array(Request::url(null, null, 'manager', 'plugins'), Locale::translate('manager.plugins'), true);
$templateMgr->assign('pageHierarchy', $pageCrumbs);
$this->import('SettingsForm');
$form = new SettingsForm($this, $conference->getId());
$form->readInputData();
if (Request::getUserVar('addBlock')) {
// Add a block
$editData = true;
//$blocks = is_null($form->getData('blocks'))?array():$form->getData('blocks');
$blocks = $form->getData('blocks');
array_push($blocks, '');
$form->_data['blocks'] = $blocks;
} else {
if (($delBlock = Request::getUserVar('delBlock')) && count($delBlock) == 1) {
// Delete an block
$editData = true;
list($delBlock) = array_keys($delBlock);
$delBlock = (int) $delBlock;
$blocks = $form->getData('blocks');
if (isset($blocks[$delBlock]) && !empty($blocks[$delBlock])) {
$deletedBlocks = explode(':', $form->getData('deletedBlocks'));
array_push($deletedBlocks, $blocks[$delBlock]);
$form->setData('deletedBlocks', join(':', $deletedBlocks));
}
array_splice($blocks, $delBlock, 1);
$form->_data['blocks'] = $blocks;
} else {
if (Request::getUserVar('save')) {
$editData = true;
$form->execute();
} else {
$form->initData();
}
}
}
if (!isset($editData) && $form->validate()) {
$form->execute();
$form->display();
exit;
} else {
$form->display();
exit;
}
$returner = true;
break;
}
$returner = false;
}
示例13: manage
/**
* @see GenericPlugin::manage()
*/
function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
{
if (!parent::manage($verb, $args, $message, $messageParams, $pluginModalContent)) {
return false;
}
$request = $this->getRequest();
$router = $request->getRouter();
$context = $router->getContext($request);
$this->import('SettingsForm');
$form = new SettingsForm($this, $context->getId());
$templateMgr =& TemplateManager::getManager();
$templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
switch ($verb) {
case 'settings':
$form->initData();
$pluginModalContent = $form->fetch($request);
return true;
case 'save':
$form->readInputData();
if ($form->validate()) {
$form->execute();
$message = NOTIFICATION_TYPE_SUCCESS;
$messageParams = array('contents' => __('plugins.generic.alm.settings.saved'));
return false;
} else {
$pluginModalContent = $form->fetch($request);
}
default:
// Unknown management verb
assert(false);
}
return false;
}