本文整理汇总了PHP中JModelLegacy::getItem方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelLegacy::getItem方法的具体用法?PHP JModelLegacy::getItem怎么用?PHP JModelLegacy::getItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelLegacy
的用法示例。
在下文中一共展示了JModelLegacy::getItem方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$sport_id = $item->get('id');
$this->saveconfigs($sport_id);
$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=cfgsport&layout=edit&id=' . $sport_id, false));
}
示例2: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$map_id = $item->get('id');
$mapimage = $item->get('mapimage');
$this->prepare_fileupload($map_id, $mapimage);
//in case new HR file added
$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=omap&layout=edit&id=' . $map_id, false));
}
示例3: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$sub_id = $item->get('id');
$sport_id = $item->get('sport_id');
$this->saveomap();
$split_id = $this->prepare_fileupload($sub_id, $sport_id);
//in case new HR file added
$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=session&layout=edit&sub_id=' . $sub_id . '&split_id=' . $split_id, false));
}
示例4: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$media_id = $item->get('id');
$mediafile = JRequest::getVar('filename');
$model->storeimage($mediafile, $media_id);
$this->prepare_fileupload($media_id, $mediafile);
//in case new m fedia file added
//$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=media&layout=edit&id='.$media_id, false));
}
示例5: postSaveHook
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$id = $item->get('id');
if ($id) {
if ($validData['saveresult'] == 1) {
//Create a new datatable if it doesn't allready exist
if (!$model->createDataTables($id)) {
$this->setMessage($model->getError());
}
}
}
}
示例6: postSaveHook
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$id = $item->get('id');
$fid = $item->get('fid');
if ($fid && $id) {
$db = JFactory::getDbo();
// Test if data must be saved in DB for this form
$query = ' SELECT * from #__visforms c where c.id=' . $fid . ' ';
$db->setQuery($query);
$forms = $db->loadObjectList();
if (count($forms) > 0) {
$rowTable = $forms[0];
if ($rowTable->saveresult == 1) {
$model->createDataTableFields($fid, $id);
}
}
}
}
示例7: 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 3.1
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$task = $this->getTask();
$item = $model->getItem();
if (isset($item->params) && is_array($item->params)) {
$registry = new JRegistry();
$registry->loadArray($item->params);
$item->params = (string) $registry;
}
if (isset($item->metadata) && is_array($item->metadata)) {
$registry = new JRegistry();
$registry->loadArray($item->metadata);
$item->metadata = (string) $registry;
}
$id = $item->id;
return;
}
示例8: postSaveHook
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
//A: inform log table about the new issue
if ($validData['id'] == 0) {
$log = JTable::getInstance('Log', 'ImcTable', array());
$catTitle = ImcFrontendHelper::getCategoryNameByCategoryId($validData['catid']);
$data2['id'] = 0;
$data2['state'] = 1;
$data2['action'] = JText::_('COM_IMC_LOGS_ACTION_INITIAL_COMMIT');
$data2['issueid'] = $model->getItem()->get('id');
$data2['stepid'] = $validData['stepid'];
$data2['description'] = JText::_('COM_IMC_LOGS_ACTION_INITIAL_COMMIT') . ' ' . JText::_('COM_IMC_LOGS_AT_CATEGORY') . ' ' . $catTitle;
$data2['created'] = $validData['created'];
$data2['created_by'] = $validData['created_by'];
$data2['updated'] = $validData['created'];
$data2['language'] = $validData['language'];
$data2['rules'] = $validData['rules'];
if (!$log->bind($data2)) {
JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
}
if (!$log->save($data2)) {
JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
}
try {
$dispatcher = JEventDispatcher::getInstance();
$results = $dispatcher->trigger('onAfterNewIssueAdded', array($model, $validData));
// Check the returned results. This is for plugins that don't throw
// exceptions when they encounter serious errors.
if (in_array(false, $results)) {
throw new Exception($dispatcher->getError(), 500);
}
} catch (Exception $e) {
// Handle a caught exception.
throw $e;
}
} else {
//a. check for step modification
if (isset($validData['is_step_modified']) && $validData['is_step_modified'] === 'true') {
$user = JFactory::getUser();
$log = JTable::getInstance('Log', 'ImcTable', array());
$data2['id'] = 0;
$data2['state'] = 1;
$data2['action'] = JText::_('COM_IMC_LOGS_ACTION_STEP_MODIFIED');
$data2['issueid'] = $validData['id'];
$data2['stepid'] = $validData['stepid'];
$data2['description'] = $validData['step_modified_description'];
$data2['created'] = $validData['updated'];
$data2['created_by'] = $user->id;
$data2['updated'] = $validData['updated'];
$data2['language'] = $validData['language'];
$data2['rules'] = $validData['rules'];
if (!$log->bind($data2)) {
JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
}
if (!$log->save($data2)) {
JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
}
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onAfterStepModified', array($model, $validData));
}
//b. check for category modification
if (isset($validData['is_category_modified']) && $validData['is_category_modified'] === 'true') {
$user = JFactory::getUser();
$log = JTable::getInstance('Log', 'ImcTable', array());
$data2['id'] = 0;
$data2['state'] = 1;
$data2['action'] = JText::_('COM_IMC_LOGS_ACTION_CATEGORY_MODIFIED');
$data2['issueid'] = $validData['id'];
$data2['stepid'] = $validData['stepid'];
$data2['description'] = $validData['category_modified_description'];
$data2['created'] = $validData['updated'];
$data2['created_by'] = $user->id;
$data2['updated'] = $validData['updated'];
$data2['language'] = $validData['language'];
$data2['rules'] = $validData['rules'];
if (!$log->bind($data2)) {
JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
}
if (!$log->save($data2)) {
JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
}
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onAfterCategoryModified', array($model, $validData));
}
}
//B: move any images only if record is new
if ($validData['id'] == 0) {
//check if any files uploaded
$obj = json_decode($validData['photo']);
if (empty($obj->files)) {
return;
}
$srcDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $obj->id;
$dstDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $model->getItem()->get('id');
$success = rename($srcDir, $dstDir);
if ($success) {
//update photo json isnew, id
unset($obj->isnew);
$obj->id = $model->getItem()->get('id');
$photo = json_encode($obj);
//.........这里部分代码省略.........
示例9: getItem
public function getItem($pk = null)
{
$item = parent::getItem($pk);
return $item;
}
示例10: 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 3.1
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
if (isset($item->params) && is_array($item->params)) {
$registry = new Registry($item->params);
$item->params = (string) $registry;
}
if (isset($item->metadata) && is_array($item->metadata)) {
$registry = new Registry($item->metadata);
$item->metadata = (string) $registry;
}
}
示例11: onAfterSave
/**
* Executes after the row is saved and saves the category relationship info
*
* @param JModelLegacy $model - the model
* @param array $data - the valid data
*
* @return bool
*/
public function onAfterSave($model, $data)
{
$db = JFactory::getDbo();
$cats = $data['catid'];
$item = $model->getItem();
/**
* Let's wipe out the customfield-category table
* I always have to do that, otherwise I could have some problems when
* a field changes from 'all' to 'category'
*/
$query = $db->getQuery(true)->delete('#__compojoom_customfields_cats')->where('compojoom_customfields_id = ' . $item->id);
if (!$db->setQuery($query)->execute()) {
$this->setError(JText::_('COM_HOTSPOTS_CUSTOMFIELDS_ERR_DELETE_CATS'));
return false;
}
if ($cats && $data['show'] == 'category') {
$query = $db->getQuery(true)->insert('#__compojoom_customfields_cats')->columns('compojoom_customfields_id, catid');
foreach ($cats as $cat) {
if (!$cat) {
continue;
}
$query->values($item->id . ', ' . $cat);
}
if (!$db->setQuery($query)->execute()) {
$this->setError(JText::_('COM_HOTSPOTS_CUSTOMFIELDS_ERR_INSERT_CATS'));
return false;
}
}
return true;
}
示例12: 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())
{
$task = $this->getTask();
$item = $model->getItem();
if (!$model->getsports($item->user_id)) {
$model->createsports($item->user_id);
$model->createportlets($item->user_id);
$model->createmediadirs($item->user_id);
}
//print_r($item);print_r($task);exit;
if ($task == 'save') {
$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=htraininglogs', false));
}
}