本文整理汇总了PHP中JModelAdmin类的典型用法代码示例。如果您正苦于以下问题:PHP JModelAdmin类的具体用法?PHP JModelAdmin怎么用?PHP JModelAdmin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JModelAdmin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstructorAppliesConfiguration
/**
* Test JModelAdmin::__construct
*
* @since 3.4
*
* @return void
*
* @testdox Constructor applies configuration
*/
public function testConstructorAppliesConfiguration()
{
$config = array('event_after_delete' => 'event_after_delete', 'event_after_save' => 'event_after_save', 'event_before_delete' => 'event_before_delete', 'event_before_save' => 'event_before_save', 'event_change_state' => 'event_change_state', 'text_prefix' => 'text_prefix');
$this->object->__construct($config);
// Check if config was applied correctly
foreach ($config as $key => $value) {
if ($key == "text_prefix") {
$this->assertEquals(strtoupper($value), TestReflection::getValue($this->object, $key));
} else {
$this->assertEquals($value, TestReflection::getValue($this->object, $key));
}
}
}
示例2: validate
public function validate($form, $data, $group = null)
{
// Prepare the data.
$data["level"] = implode(",", $data["level"]);
return parent::validate($form, $data, $group);
// TODO: Change the autogenerated stub
}
示例3: getItem
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
$item->assistance = $item->params['assistance'];
}
return $item;
}
示例4: save
public function save($form)
{
$canDo = JoaktreeHelper::getActions();
$msg = JText::_('JTAPPS_MESSAGE_NOSAVE');
if ($canDo->get('core.create') || $canDo->get('core.edit')) {
$ret = parent::save($form);
if ($ret) {
$msg = JText::_('JT_MESSAGE_SAVED');
}
// Bind the rules.
if (isset($form['rules'])) {
$actions = array();
$tmp = array();
$tmp[0] = '';
foreach ($data['rules'] as $action => $identities) {
$identities = array_diff($identities, $tmp);
$actions[$action] = $identities;
}
$table = $this->getTable();
$rules = new JRules($actions);
$table->setRules($rules);
}
}
return $msg;
}
示例5: getItem
/**
* Method to get a single record.
*
* @param integer The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
//debug::msg('model->getItem');
if ($item = parent::getItem($pk)) {
}
return $item;
}
示例6: save
function save($data)
{
$courses_csv = implode(',', $data['courses']);
$data['courses'] = $courses_csv;
$return = parent::save($data);
return $return;
}
示例7: getItem
/**
* Method to get a category.
*
* @param integer An optional id of the object to get, otherwise the id from the model state is used.
* @return mixed Category data object on success, false on failure.
* @since 1.6
*/
public function getItem($pk = null)
{
if ($result = parent::getItem($pk)) {
// Prime required properties.
if (empty($result->id)) {
$result->parent_id = $this->getState('category.parent_id');
$result->extension = $this->getState('category.extension');
}
// Convert the metadata field to an array.
$registry = new JRegistry();
$registry->loadJSON($result->metadata);
$result->metadata = $registry->toArray();
// Convert the created and modified dates to local user time for display in the form.
jimport('joomla.utilities.date');
$tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
if (intval($result->created_time)) {
$date = new JDate($result->created_time);
$date->setTimezone($tz);
$result->created_time = $date->toMySQL(true);
} else {
$result->created_time = null;
}
if (intval($result->modified_time)) {
$date = new JDate($result->modified_time);
$date->setTimezone($tz);
$result->modified_time = $date->toMySQL(true);
} else {
$result->modified_time = null;
}
}
return $result;
}
示例8: save
public function save($data)
{
if (!empty($data['payment_type'])) {
$data['payment_type'] = json_encode($data['payment_type']);
}
return parent::save($data);
}
示例9: prepareTable
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$date = JFactory::getDate();
$user = JFactory::getUser();
parent::prepareTable($table);
}
示例10: save
public function save($data)
{
$success = parent::save($data);
if ($success) {
// request option list
$values = JRequest::getVar('joomdoc_option_value', array(), 'default', 'array');
$labels = JRequest::getVar('joomdoc_option_label', array(), 'default', 'array');
// prepare database table
$option = JTable::getInstance('Option', JOOMDOC_TABLE_PREFIX);
/* @var $option JoomDOCTableOption */
$option->field = $this->getState($this->getName() . '.id');
$option->ordering = 0;
$query = $this->getDbo()->getQuery(true);
$query->select('id')->from('#__joomdoc_option')->where('field = ' . (int) $option->field);
$ids = $this->getDbo()->setQuery($query)->loadColumn();
$sid = array();
foreach ($values as $id => $value) {
$option->id = in_array($id, $ids) ? $id : null;
$option->value = $value;
$option->label = $labels[$id];
$option->ordering++;
$option->store();
$sid[] = (int) $option->id;
}
$query->clear()->delete('#__joomdoc_option')->where('field = ' . (int) $option->field);
if ($sid) {
$query->where('id NOT IN (' . implode(', ', $sid) . ')');
}
$this->getDbo()->setQuery($query)->query();
}
return $success;
}
示例11: getItem
/**
* Method to get a single comment.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
$item->content_id = (string) $item->content_id . ' - ' . $this->_getContentTitle($item->id);
}
return $item;
}
示例12: getItem
public function getItem($pk = null)
{
$item = parent::getItem($pk);
$item->selections = new Registry($item->selections);
$item->selections = $item->selections->toArray();
return $item;
}
示例13: delete
/**
* Override delete method to add the image processing
*/
public function delete(&$pks)
{
// standard joomla delete
$delete = parent::delete($pks);
if (!$delete) {
return false;
}
// delete images
$imageHelper = new CHPanelHelperImage(JComponentHelper::getParams('com_chpanel'));
foreach ($pks as $pk) {
// delete hotel image file
$imageHelper->deleteImage($pk, 'hotels');
// delete hotel gallery images
$query_images = $this->_db->getQuery(true)->select('id')->from('#__chpanel_images')->where("`hotel_id` = " . (int) $pk);
$images_ids = $this->_db->setQuery($query_images)->loadColumn();
if (count($images_ids)) {
// delete images files
foreach ($images_ids as $image_id) {
$imageHelper->deleteImage($image_id, 'images');
}
// db delete images
$query_delete_images = $this->_db->getQuery(true)->delete('#__chpanel_images')->where("`hotel_id` = " . (int) $pk);
$this->_db->setQuery($query_delete_images)->query();
}
}
// delete hotel translations
$this->_db->setQuery("DELETE FROM `#__chpanel_translations` WHERE `hotel_id` IN(" . implode(',', $pks) . ")")->query();
return true;
}
示例14: preprocessForm
/**
* Auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
* @since 3.0
*/
protected function preprocessForm(JForm $form, $data, $group = 'jevents')
{
// Association content items
$app = JFactory::getApplication();
$assoc = false && JLanguageAssociations::isEnabled() && JFactory::getApplication()->isAdmin();
if ($assoc) {
$languages = JLanguageHelper::getLanguages('lang_code');
$addform = new SimpleXMLElement('<form />');
$fields = $addform->addChild('fields');
$fields->addAttribute('name', 'associations');
$fieldset = $fields->addChild('fieldset');
$fieldset->addAttribute('name', 'item_associations');
$fieldset->addAttribute('description', 'COM_JEVENTS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
$add = false;
foreach ($languages as $tag => $language) {
if (empty($data->language) || $tag != $data->language) {
$add = true;
$field = $fieldset->addChild('field');
$field->addAttribute('name', $tag);
$field->addAttribute('type', 'modal_article');
$field->addAttribute('language', $tag);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
}
}
if ($add) {
$form->load($addform, false);
}
}
parent::preprocessForm($form, $data, $group);
}
示例15: array
/**
* Constructor
*
* @since 0.9
*/
function __construct()
{
parent::__construct();
$cid = JRequest::getVar('cid', array(0), '', 'array');
JArrayHelper::toInteger($cid, array(0));
$this->setId($cid[0]);
}