本文整理汇总了PHP中JModelLegacy::getState方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelLegacy::getState方法的具体用法?PHP JModelLegacy::getState怎么用?PHP JModelLegacy::getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelLegacy
的用法示例。
在下文中一共展示了JModelLegacy::getState方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSaveHook
/**
* Update the ordered items in post save hook
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$order_id = $model->getState($model->getName() . '.id');
$data = JFactory::getApplication()->input->post->getArray(array('jform' => array('ordered' => 'array', 'deleted' => 'array')));
// We add order items right on order edit view
foreach ($data['jform']['ordered'] as $item) {
$item['order_id'] = $order_id;
$model = JModelLegacy::getInstance('OrderItem', 'DZProductModel');
$form = $model->getForm($item, false);
if (!$form) {
continue;
}
$validItem = $model->validate($form, $item);
if ($validItem === false) {
continue;
}
if (!$model->save($validItem)) {
continue;
}
}
// Make sure the submitted deleted ids are all integer
JArrayHelper::toInteger($data['jform']['deleted']);
// Remove items
$model = JModelLegacy::getInstance('OrderItem', 'DZProductModel');
$model->delete($data['jform']['deleted']);
}
示例2: getState
/**
* Overridden method to get model state variables.
*
* @param string $property Optional parameter name.
* @param mixed $default The default value to use if no state property exists by name.
* @return object The property where specified, the state object where omitted.
* @since 1.6
*/
public function getState($property = null, $default = null)
{
// if the model state is uninitialized lets set some values we will need from the request.
if ($this->__state_set === false) {
$this->__state_set = true;
}
$value = parent::getState($property);
return is_null($value) ? $default : $value;
}
示例3: testGetState
/**
* Tests the getState method.
*
* @since 12.3
*
* @return void
*/
public function testGetState()
{
$state = $this->fixture->getState();
$this->assertTrue($state instanceof JObject);
$stateSet = TestReflection::getValue($this->fixture, '__state_set');
$this->assertTrue($stateSet === true);
$this->fixture->setState('foo.bar', 'baz');
$this->assertEquals('baz', $this->fixture->getState('foo.bar'));
$this->assertEquals('defaultVal', $this->fixture->getState('non.existent', 'defaultVal'));
$this->assertNull($this->fixture->getState('non.existent'));
}
示例4: getState
function getState($property = null, $default = null) {
static $set;
if (!$set) {
$folder = JFactory::getApplication()->input->get('folder', '');
$this->setState('folder', $folder);
$set = true;
}
return parent::getState($property);
}
示例5: getState
public function getState($property = null, $default = null)
{
static $set;
if (!$set) {
$input = JFactory::getApplication()->input;
$fieldid = $input->get('fieldid', '');
$this->setState('field.id', $fieldid);
$set = true;
}
return parent::getState($property, $default);
}
示例6: getState
function getState($property = null, $default = null)
{
static $set;
if (!$set) {
$folder = JRequest::getVar('folder', '', '', 'path');
$this->setState('folder', $folder);
$parent = str_replace("\\", "/", dirname($folder));
$parent = $parent == '.' ? null : $parent;
$this->setState('parent', $parent);
$set = true;
}
return parent::getState($property, $default);
}
示例7: getState
public function getState($property = null, $default = null)
{
static $set;
if (!$set) {
$input = JFactory::getApplication()->input;
$folder = $input->get('folder', '', 'path');
$this->setState('folder', $folder);
$parent = str_replace("\\", "/", dirname($folder));
$parent = $parent == '.' ? null : $parent;
$this->setState('parent', $parent);
$set = true;
}
return parent::getState($property, $default);
}
示例8: postSaveHook
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$app = JFactory::getApplication();
$task = $this->getTask();
switch ($task) {
case 'save2new':
$app->setUserState('com_modules.add.module.extension_id', $model->getState('module.extension_id'));
break;
default:
$app->setUserState('com_modules.add.module.extension_id', null);
break;
}
$app->setUserState('com_modules.add.module.params', null);
}
示例9: getState
/**
* Overridden method to get model state variables.
*
* @param string $property Optional parameter name.
* @param mixed $default The default value to use if no state property exists by name.
* @return object The property where specified, the state object where omitted.
* @since 1.6
*/
public function getState($property = null, $default = null)
{
// if the model state is uninitialized lets set some values we will need from the request.
if ($this->__state_set === false) {
$app = JFactory::getApplication();
$this->setState('action', $step = $app->getUserState('com_kunena.install.action', null));
$this->setState('step', $step = $app->getUserState('com_kunena.install.step', 0));
$this->setState('task', $task = $app->getUserState('com_kunena.install.task', 0));
$this->setState('version', $task = $app->getUserState('com_kunena.install.version', null));
if ($step == 0) {
$app->setUserState('com_kunena.install.status', array());
}
$this->setState('status', $app->getUserState('com_kunena.install.status'));
$this->__state_set = true;
}
$value = parent::getState($property);
return is_null($value) ? $default : $value;
}
示例10: testGetStateReturnsDefaultValue
/**
*Tests the getState method.
*
* @since 12.3
*
* @return void
*
* @testdox getState() returns default value
*/
public function testGetStateReturnsDefaultValue()
{
$this->assertEquals('defaultVal', $this->fixture->getState('non.existent', 'defaultVal'));
$this->assertNull($this->fixture->getState('non.existent'));
}
示例11: postSaveHook
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$authority = $model->getState('request.authority');
//$id = $model->getState('form.id');
if ($validData['payment']['payment_type'] == 'ACCELERATION_CARDS' && $authority) {
$this->setMessage(JText::_('COM_SIBDIET_REQUEST_SAVED_ONLINE_PAYMENT'));
//$this->setRedirect(JRoute::_('index.php?&option=com_sibdiet&view=onlinepayment&id=' . $id, false));
$this->setRedirect('https://www.zarinpal.com/pg/StartPay/' . $authority);
} elseif ($validData['payment']['payment_type'] == '') {
$this->setMessage(JText::_('COM_SIBDIET_REQUEST_SAVED_NO_PAYMENT'));
$this->setRedirect(JRoute::_('index.php?option=com_sibdiet&view=requests', false));
} else {
$this->setMessage(JText::_('COM_SIBDIET_REQUEST_SAVED'));
$this->setRedirect(JRoute::_('index.php?option=com_sibdiet&view=requests', false));
}
$this->redirect();
}
示例12: postSaveHook
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$task = $this->getTask();
if ($task == 'save' || $task == 'apply') {
$isNew = $model->getState('editevent.new');
$id = $model->getState('editevent.id');
$enabled = JPluginHelper::isEnabled('jem', 'mailer');
if ($enabled) {
JPluginHelper::importPlugin('jem', 'mailer');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onEventEdited', array($id, $isNew));
} else {
JError::raiseNotice(100, JText::_('COM_JEM_GLOBAL_MAILERPLUGIN_DISABLED'));
}
}
}
示例13: postSaveHook
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param jmodel $model The data model object.
* @param array $data The validated data.
*
* @return void
*/
protected function postSaveHook(JModelLegacy $model, $data = array())
{
$task = $this->getTask();
$id = (int) $model->getState('form.id');
switch ($task) {
case 'save2copy':
case 'save2new':
// No redirect because its already set
break;
case 'save2tasklist':
$link = JRoute::_(PFtasksHelperRoute::getTasksRoute() . '&task=tasklistform.add&milestone_id=' . $id);
$this->setRedirect($link);
break;
case 'save2task':
$link = JRoute::_(PFtasksHelperRoute::getTasksRoute() . '&task=taskform.add&milestone_id=' . $id);
$this->setRedirect($link);
break;
default:
$this->setRedirect(JRoute::_($this->getReturnPage()));
break;
}
}