本文整理汇总了PHP中JArrayHelper::toObject方法的典型用法代码示例。如果您正苦于以下问题:PHP JArrayHelper::toObject方法的具体用法?PHP JArrayHelper::toObject怎么用?PHP JArrayHelper::toObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArrayHelper
的用法示例。
在下文中一共展示了JArrayHelper::toObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCanEdit
/**
* Can the row be edited
*
* @param object $params plugin params
* @param object $listModel list model
* @param object $row current row to test
*
* @return boolean
*/
public function onCanEdit($params, $listModel, $row)
{
// If $row is null, we were called from the table's canEdit() in a per-table rather than per-row context,
// and we don't have an opinion on per-table edit permissions, so just return true.
if (is_null($row) || is_null($row[0])) {
return true;
}
if (is_array($row[0])) {
$data = JArrayHelper::toObject($row[0]);
} else {
$data = $row[0];
}
$field = str_replace('.', '___', $params->get('caneditrow_field'));
// If they provided some PHP to eval, we ignore the other settings and just run their code
$caneditrow_eval = $params->get('caneditrow_eval', '');
// $$$ rob if no can edit field selected in admin return true
if (trim($field) == '' && trim($caneditrow_eval) == '') {
return true;
}
if (!empty($caneditrow_eval)) {
$w = new FabrikWorker();
$data = JArrayHelper::fromObject($data);
$caneditrow_eval = $w->parseMessageForPlaceHolder($caneditrow_eval, $data);
$caneditrow_eval = @eval($caneditrow_eval);
FabrikWorker::logEval($caneditrow_eval, 'Caught exception on eval in can edit row : %s');
return $caneditrow_eval;
} else {
// No PHP given, so just do a simple match on the specified element and value settings.
if ($params->get('caneditrow_useraw', '0') == '1') {
$field .= '_raw';
}
$value = $params->get('caneditrow_value');
return $data->{$field} == $value;
}
}
示例2: stdclass
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure. FIGYELEM!!! alternativák tömb is!!!!!
*/
public function &getItem($id = null)
{
$db = JFactory::getDBO();
if ($this->_item === null) {
$this->_item = false;
if (empty($id)) {
$id = $this->getState('alternativak.id');
}
// Get a level row instance.
$table = JTable::getInstance('Alternativak', 'Table');
// Attempt to load the row.
if ($id == null | $id == 0) {
// rekord init felvitelhez
$user = JFactory::getUser();
$this->_item = new stdclass();
$this->_item->id = 0;
$this->_item->megnevezes = '';
$this->_item->leiras = '';
$this->_item->temakor_id = JRequest::getVar('temakor', 0);
$this->_item->szavazas_id = JRequest::getVar('szavazas', 0);
$this->_item->letrehozo = $user->id;
$this->_item->letrehozva = date('Y-m-d H:i:s');
} else {
if ($table->load($id)) {
// Convert the JTable to a clean JObject.
$this->_item = JArrayHelper::toObject($table->getProperties(1), 'JObject');
} else {
if ($error = $table->getError()) {
$this->setError($error);
}
}
}
}
return $this->_item;
}
示例3: Exception
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function &getData($id = null)
{
if ($this->_item === null) {
$this->_item = false;
if (empty($id)) {
$id = $this->getState('user.id');
}
// Get a level row instance.
$table = $this->getTable();
// Attempt to load the row.
if ($table !== false && $table->load($id)) {
$user = JFactory::getUser();
$id = $table->id;
$canEdit = $user->authorise('core.edit', 'com_db8download') || $user->authorise('core.create', 'com_db8download');
if (!$canEdit && $user->authorise('core.edit.own', 'com_db8download')) {
$canEdit = $user->id == $table->created_by;
}
if (!$canEdit) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 500);
}
// Check published state.
if ($published = $this->getState('filter.published')) {
if ($table->state != $published) {
return $this->_item;
}
}
// Convert the JTable to a clean JObject.
$properties = $table->getProperties(1);
$this->_item = JArrayHelper::toObject($properties, 'JObject');
}
}
return $this->_item;
}
示例4: getItem
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
* @return mixed $item Object on success, false on failure.
*/
public function getItem($pk = null)
{
$pk = !empty($pk) ? (int) $pk : (int) $this->getState($this->getName() . '.id');
$table = $this->getTable();
if ($pk > 0) {
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError()) {
$this->setError($table->getError());
return false;
}
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$item = JArrayHelper::toObject($properties, 'JObject');
// Convert attributes to JRegistry params
$item->params = new JRegistry();
$item->params->loadString($item->attribs);
$item->attribs = $item->params->toArray();
// Get the attachments
$item->attachment = array();
if (PFApplicationHelper::exists('com_pfrepo')) {
$attachments = $this->getInstance('Attachments', 'PFrepoModel');
$item->attachment = $attachments->getItems('com_pfforum.topic', $item->id);
}
// Get the labels
$model_labels = $this->getInstance('Labels', 'PFModel');
$item->labels = $model_labels->getConnections('com_pfforum.topic', $item->id);
return $item;
}
示例5:
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function &getItem($id = null)
{
if ($this->_item === null) {
$this->_item = false;
if (empty($id)) {
$id = $this->getState('weblink.id');
}
// Get a level row instance.
$table = JTable::getInstance('Weblink', 'WeblinksTable');
// Attempt to load the row.
if ($table->load($id)) {
// Check published state.
if ($published = $this->getState('filter.published')) {
if ($table->state != $published) {
return $this->_item;
}
}
// Convert the JTable to a clean JObject.
$properties = $table->getProperties(1);
$this->_item = JArrayHelper::toObject($properties, 'JObject');
} else {
if ($error = $table->getError()) {
$this->setError($error);
}
}
}
return $this->_item;
}
示例6: getItem
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
* @return mixed $item Object on success, false on failure.
*/
public function getItem($pk = null)
{
$pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
$table = $this->getTable();
if ($pk > 0) {
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError()) {
$this->setError($table->getError());
return false;
}
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$item = JArrayHelper::toObject($properties, 'JObject');
// Convert attributes to JRegistry params
$item->params = new JRegistry();
$item->params->loadString($item->attribs);
$item->attribs = $item->params->toArray();
// Convert seconds back to minutes
if ($item->log_time > 0) {
$item->log_time = round($item->log_time / 60);
}
return $item;
}
示例7: emailFriend
function emailFriend()
{
JRequest::checkToken() or jexit('Invalid Token');
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_member.php';
$app = JFactory::getApplication();
if (JobBoardHelper::verifyHumans()) {
if (!JobBoardMemberHelper::matchHumanCode(JRequest::getString('human_ver', ''))) {
$post = JArrayHelper::toObject(JRequest::get('post'));
$post->errors = 1;
if (isset($post->human_ver)) {
unset($post->human_ver);
}
$app->setUserState('com_jobboard.sfields', $post);
$app->redirect(JRoute::_('index.php?option=com_jobboard&view=share&errors=1&job_id=' . $post->job_id . '&Itemid=' . JRequest::getInt('Itemid')), JText::_('COM_JOBBOARD_FORM_CAPTCHA_FAILMSG'), 'error');
return;
}
}
$message = new JObject();
$message->job_id = JRequest::getVar('job_id', '', '', 'int');
$catid = JRequest::getVar('catid', '', '', 'int');
$message->job_title = JRequest::getVar('job_title', '', '', 'string');
$message->job_city = JRequest::getVar('job_city', '', '', 'string');
$message->personal_message = JRequest::getVar('personal_message', '', '', 'string');
$uri =& JURI::getInstance();
$message->link = $uri->getScheme() . '://' . $uri->getHost() . JRequest::getVar('job_path', '', '', 'string');
$fields_valid = $this->validateFields();
$message->sender_email = $fields_valid->sender_email;
$message->sender_name = $fields_valid->sender_name;
$message->rec_emails = $fields_valid->rec_emails;
if ($fields_valid->errors === true) {
$errmsg = $fields_valid->errmsg . '</ul>';
$app->setUserState('sfields', $message);
$link = JRoute::_('index.php?option=com_jobboard&view=share&errors=1&job_id=' . $message->job_id . '&Itemid=' . $itemid);
$this->setRedirect($link, $errmsg, '');
return;
} else {
if (stristr($message->rec_emails, ',') === TRUE) {
$rec_emailarray = explode(',', $message->rec_emails);
foreach ($rec_emailarray as $email_recipient) {
$this->sendEmail($message, trim($email_recipient));
}
} else {
$this->sendEmail($message, trim($message->rec_emails));
}
$mesgModel =& $this->getModel('Message');
$saved = $mesgModel->saveMessage($message);
if ($saved) {
$msg = ' ' . JText::_('SEND_MSG_SUCCESS');
$link = JRoute::_('index.php?option=com_jobboard&view=job&id=' . $message->job_id, false);
$this->setRedirect($link, $msg, '');
return;
} else {
$msg = ' ' . JText::_('ERR_WAIT');
$link = JRoute::_('index.php?option=com_jobboard&view=job&id=' . $message->job_id, false);
$this->setRedirect($link, $msg, '');
return;
}
}
parent::display();
}
示例8: __construct
public function __construct(JDocumentHTML $template)
{
if (!$template instanceof JDocumentHTML) {
return false;
}
$this->_template = $template;
$this->_params = $template->params;
$menu = JFactory::getApplication()->getMenu();
$activeMenu = $menu->getActive();
//merge menu params with template params
jimport('joomla.utilities.arrayhelper');
$params = array_merge($activeMenu->params->toArray(), $this->_params->toArray());
$this->params = JArrayHelper::toObject($params, 'JRegistry');
// check for position
$this->show_top = $template->countModules('top');
$this->show_top_left = $template->countModules('top-left');
$this->show_top_center = $template->countModules('top-center');
$this->show_top_right = $template->countModules('top-right');
$this->show_user1 = $template->countModules('user1');
$this->show_user2 = $template->countModules('user2');
$this->show_user3 = $template->countModules('user3');
$this->show_content_header = $template->countModules('content-header');
$this->show_content_footer = $template->countModules('content-footer');
$this->show_left = $template->countModules('left');
$this->show_right = $template->countModules('right');
$this->show_bottom_left = $template->countModules('bottom-left');
$this->show_bottom_center = $template->countModules('bottom-center');
$this->show_bottom_right = $template->countModules('bottom-right');
$this->show_bottom = $template->countModules('bottom');
$this->show_bottom_socials = $template->countModules('bottom-socials');
$this->show_footer = $template->countModules('footer');
}
示例9: onContentPrepareForm
/**
* Event method that runs on content preparation
*
* @param JForm $form The form object
* @param integer $data The form data
*
* @return bool
*/
public function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
$name = $form->getName();
if (!in_array($name, array('com_content.article'))) {
return true;
}
$include_categories = $this->params->get('include_categories');
if (empty($include_categories)) {
return true;
}
if (empty($data)) {
$input = JFactory::getApplication()->input;
$data = (object) $input->post->get('jform', array(), 'array');
}
if (is_array($data)) {
jimport('joomla.utilities.arrayhelper');
$data = JArrayHelper::toObject($data);
}
if (empty($data->catid)) {
return true;
}
if (!in_array($data->catid, $include_categories)) {
return true;
}
JForm::addFormPath(__DIR__ . '/form');
$form->loadFile('form');
if (!empty($data->id)) {
$data = $this->loadTest($data);
}
return true;
}
示例10: JObject
/**
* 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)
{
// Initialise variables.
$pk = !empty($pk) ? $pk : (int) $this->getState('user.id');
$false = false;
// Get a row instance.
$table =& $this->getTable();
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError()) {
$this->setError($table->getError());
return $false;
}
// Prime required properties.
if (empty($table->id)) {
// Prepare data for a new record.
}
// Convert to the JObject before adding other data.
$value = JArrayHelper::toObject($table->getProperties(1), 'JObject');
$value->profile = new JObject();
// Get the dispatcher and load the users plugins.
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('user');
// Trigger the data preparation event.
$results = $dispatcher->trigger('onPrepareUserProfileData', array($table->id, &$value));
// Convert the params field to an array.
$registry = new JRegistry();
$registry->loadJSON($value->params);
$value->params = $registry->toArray();
return $value;
}
示例11: getFabrikItem
/**
* Decorate the J2Store product information with its related Fabrik record
*
* @param $product
*
* @return object
*/
private function getFabrikItem(&$product)
{
list($component, $listId) = explode('.', $product->product_source);
$key = $listId . '.' . $product->product_source_id;
static $sets;
if (!is_array($sets)) {
$sets = array();
}
if (!isset($sets[$key])) {
JModelLegacy::addIncludePath(COM_FABRIK_FRONTEND . '/models', 'FabrikFEModel');
/** @var FabrikFEModelList $listModel */
$listModel = JModelLegacy::getInstance('List', 'FabrikFEModel');
$listModel->setId($listId);
$formModel = $listModel->getFormModel();
$formModel->setRowId($product->product_source_id);
$row = $formModel->getData();
$params = $formModel->getParams();
$index = array_search('j2store', (array) $params->get('plugins', array(), 'array'));
$w = new FabrikWorker();
$plugIn = FabrikWorker::getPluginManager()->loadPlugIn('j2store', 'form');
// Set params relative to plugin render order
$plugInParams = $plugIn->setParams($params, $index);
$context = new stdClass();
$context->title = $w->parseMessageForPlaceHolder($plugInParams->get('j2store_product_name'), $row);
$context->published = $w->parseMessageForPlaceHolder($plugInParams->get('j2store_enabled'), $row);
$objectRow = JArrayHelper::toObject($row);
$context->viewLink = $listModel->viewDetailsLink($objectRow);
$context->editLink = $listModel->editLink($objectRow);
$context->id = $objectRow->__pk_val;
$sets[$key] = $context;
}
//echo "<pre>";print_r($sets);echo "</pre>";
return $sets[$key];
}
示例12:
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function &getData($id = null)
{
if ($this->_item === null) {
$this->_item = false;
if (empty($id)) {
$id = $this->getState('vistamapa.id');
}
// Get a level row instance.
$table = $this->getTable();
// Attempt to load the row.
if ($table->load($id)) {
// Check published state.
if ($published = $this->getState('filter.published')) {
if ($table->state != $published) {
return $this->_item;
}
}
// Convert the JTable to a clean JObject.
$properties = $table->getProperties(1);
$this->_item = JArrayHelper::toObject($properties, 'JObject');
}
}
$this->_item->nom_entidad = JText::_('COM_MAPA_MAPVENEZUELA_NOM_ENTIDAD_OPTION_' . $this->_item->nom_entidad);
$this->_item->col_entidad = JText::_('COM_MAPA_MAPVENEZUELA_COL_ENTIDAD_OPTION_' . $this->_item->col_entidad);
return $this->_item;
}
示例13: getItem
/**
* @param null $pk
* @return array|mixed|object
* @throws Exception
*/
public function getItem($pk = NULL)
{
$id = JFactory::getApplication()->input->get('id', NULL, 'INT');
//判断$id 是否存在 存在调用数据库 不存在为$item 赋空值
if ($id) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*')->from($db->quoteName('#__gasmanagement'))->where($db->quoteName('id') . "=" . $db->quote($id));
$db->setQuery($query);
try {
$item = $db->loadObject();
} catch (Exception $e) {
$this->setError($e->getMessage());
}
if (!$item) {
$item = array('id' => '', 'name' => '', 'brand' => '', 'standard' => '');
$item = JArrayHelper::toObject($item, 'JObject');
}
return $item;
} else {
$item = array('id' => '', 'name' => '', 'brand' => '', 'standard' => '');
$item = JArrayHelper::toObject($item, 'JObject');
return $item;
}
}
示例14: _exportCSV
function _exportCSV($ids)
{
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.ms-excel');
header('Content-disposition: attachment; filename="users.csv"');
$model = CFactory::getModel('Profile');
$lang =& JFactory::getLanguage();
$lang->load('com_community', JPATH_ROOT);
foreach ($ids as $id) {
$user = CFactory::getUser($id);
$profile = $model->getEditableProfile($id, $user->getProfileType());
$profileType = JTable::getInstance('MultiProfile', 'CTable');
$profileType->load($user->getProfileType());
echo $user->id . ',' . $profileType->getName() . ',' . $user->name . ',' . $user->username . ',' . $user->email . ',' . $user->getThumbAvatar() . ',' . $user->getAvatar() . ',' . $user->getKarmaPoint() . ',';
echo $user->registerDate . ',' . $user->lastvisitDate . ',' . $user->block . ',' . $user->getStatus() . ',' . $user->getViewCount() . ',' . $user->getAlias() . ',' . $user->getFriendCount();
foreach ($profile['fields'] as $group => $groupFields) {
foreach ($groupFields as $field) {
$field = JArrayHelper::toObject($field);
$field->value = $field->value;
echo $field->value . ",";
}
}
echo "\r\n";
}
exit;
}
示例15:
/**
* Method to get an ojbect.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function &getItem($id = null)
{
if ($this->_item === null) {
$this->_item = false;
if (empty($id)) {
$id = $this->getState('temakorok.id');
}
// Get a level row instance.
$table = JTable::getInstance('Temakorok', 'Table');
// Attempt to load the row.
if ($table->load($id)) {
// Convert the JTable to a clean JObject.
$this->_item = JArrayHelper::toObject($table->getProperties(1), 'JObject');
$db = JFactory::getDBO();
$db->setQuery('select * from #__beallitasok where id = (10+' . $id . ')');
$res = $db->loadObject();
if ($res) {
$this->_item->json = $res->json;
} else {
$this->_item->json = '{}';
}
} else {
if ($error = $table->getError()) {
$this->setError($error);
}
}
}
return $this->_item;
}