本文整理汇总了PHP中JArrayHelper::fromObject方法的典型用法代码示例。如果您正苦于以下问题:PHP JArrayHelper::fromObject方法的具体用法?PHP JArrayHelper::fromObject怎么用?PHP JArrayHelper::fromObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArrayHelper
的用法示例。
在下文中一共展示了JArrayHelper::fromObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_postinstall_eaccelerator_action
/**
* Disables the unsupported eAccelerator caching method, replacing it with the
* "file" caching method.
*
* @return void
*
* @since 3.2
*/
function admin_postinstall_eaccelerator_action()
{
$prev = new JConfig();
$prev = JArrayHelper::fromObject($prev);
$data = array('cacheHandler' => 'file');
$data = array_merge($prev, $data);
$config = new Registry('config');
$config->loadArray($data);
jimport('joomla.filesystem.path');
jimport('joomla.filesystem.file');
// Set the configuration file path.
$file = JPATH_CONFIGURATION . '/configuration.php';
// Get the new FTP credentials.
$ftp = JClientHelper::getCredentials('ftp', true);
// Attempt to make the file writeable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
}
// Attempt to write the configuration file as a PHP class named JConfig.
$configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
if (!JFile::write($file, $configuration)) {
JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
return;
}
// Attempt to make the file unwriteable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
}
}
示例2: save
function save($data)
{
// Get the previous configuration.
if (is_object($data)) {
$data = JArrayHelper::fromObject($data);
}
$prev = JTheFactoryHelper::getConfig();
$prev = JArrayHelper::fromObject($prev);
$data = array_merge($prev, $data);
$configfile = JTheFactoryAdminHelper::getConfigFile();
$config = new JRegistry('config');
$config->loadArray($data);
jimport('joomla.filesystem.path');
jimport('joomla.filesystem.file');
jimport('joomla.client.helper');
// Get the new FTP credentials.
$ftp = JClientHelper::getCredentials('ftp', true);
// Attempt to make the file writeable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($configfile) && !JPath::setPermissions($configfile, '0644')) {
JError::raiseNotice(101, JText::_('FACTORY_SETTINGS_FILE_IS_NOT_WRITABLE'));
}
// Attempt to write the configuration file as a PHP class named JConfig.
$configString = $config->toString('PHP', array('class' => ucfirst(APP_PREFIX) . "Config", 'closingtag' => false));
if (!JFile::write($configfile, $configString)) {
JError::raiseWarning(101, JText::_('FACTORY_SETTINGS_FILE_WRITE_FAILED'));
return false;
}
// Attempt to make the file unwriteable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($configfile) && !JPath::setPermissions($configfile, '0444')) {
JError::raiseNotice(101, JText::_('FACTORY_SETTINGS_FILE_IS_NOT_WRITABLE'));
}
return true;
}
示例3: renderTableData
/**
* shows the data formatted for the table view
* @param string data
* @param object all the data in the tables current row
* @return string formatted value
*/
function renderTableData($data, $oAllRowsData)
{
$str = '';
$params =& $this->getParams();
$w = $params->get('fb_gm_table_mapwidth');
$h = $params->get('fb_gm_table_mapheight');
$z = $params->get('fb_gm_table_zoomlevel');
if (strstr($data, GROUPSPLITTER)) {
$data = explode(GROUPSPLITTER, $data);
foreach ($data as $d) {
if ($params->get('fb_gm_staticmap_tableview')) {
$str .= $this->_staticMap($d, $w, $h);
} else {
if ($params->get('fb_gm_staticmap_tableview_type_coords', 'num') == 'dms') {
$str .= $this->_dmsformat($d);
} else {
$str .= $this->_microformat($d);
}
}
}
} else {
if ($params->get('fb_gm_staticmap_tableview')) {
$str .= $this->_staticMap($data, $w, $h, $z, 0, true, JArrayHelper::fromObject($oAllRowsData));
} else {
if ($params->get('fb_gm_staticmap_tableview_type_coords', 'num') == 'dms') {
$str .= $this->_dmsformat($data);
} else {
$str .= $this->_microformat($data);
}
}
}
return $str;
}
示例4: _renderListData
/**
* @access private
*
* @param string data
* @param object all the data in the tables current row
* @return string formatted value
*/
function _renderListData($data, $oAllRowsData)
{
//$data = explode(GROUPSPLITTER2, $data);
$data = FabrikWorker::JSONtoData($data, true);
$listModel = $this->getlistModel();
$params = $this->getParams();
if (is_array($data)) {
if (count($data) == 1) { $data[1] = $data[0];}
if (empty($data[1]) && empty($data[0])) {
return '';
}
$target = $params->get('link_target', '');
if ($listModel->getOutPutFormat() != 'rss') {
if (empty($data[1])) {
$link = $data[0];
}
else {
$smart_link = $params->get('link_smart_link', false);
if ($smart_link || $target == 'mediabox') {
$smarts = $this->_getSmartLinkType( $data[1]);
$link = "<a href=\"" . $data[1] . "\" rel=\"lightbox[" . $smarts['type'] . " " . $smarts['width'] . " " . $smarts['height'] . "]\">" . $data[0] . "</a>";
}
else {
$link = "<a href=\"" . $data[1] . "\" target=\"" .$target . "\">" . $data[0] . "</a>";
}
}
} else {
$link = $data[1];
}
$w = new FabrikWorker();
$link = $listModel->parseMessageForRowHolder($link, JArrayHelper::fromObject($oAllRowsData));
return $link;
}
return $data;
}
示例5: edit
public function edit($key = null, $urlVar = null)
{
$app = JFactory::getApplication();
$recordId = $app->input->getInt('id', 0);
$response = array('status' => 1, 'error' => false, 'error_message' => '', 'message' => '', 'object' => array());
try {
parent::edit($key, $urlVar);
} catch (Exception $e) {
$response['status'] = 0;
$response['error'] = true;
$response['error_message'] = $e->getMessage();
echo json_encode($response);
$app->close();
}
$model = $this->getModel();
$item = $model->getItem($recordId);
if (empty($item) || empty($item->id)) {
$response['status'] = 0;
$response['error'] = true;
$response['error_message'] = JText::_('COM_DJREVIEWS_ERROR_REVIEW_NOT_EXIST');
} else {
$response['object'] = JArrayHelper::fromObject($item, true);
}
echo json_encode($response);
$app->close();
}
示例6: _displayForm
/**
* Displays the form
* @param string $tpl
*/
public function _displayForm($tpl)
{
JHtml::_('behavior.formvalidation');
$db = JFactory::getDBO();
$uri = JFactory::getURI();
$user = JFactory::getUser();
$form = $this->get('Form');
$lists = array();
$editor = JFactory::getEditor();
//get the item
$item = $this->get('item');
//Get Versions
$model = $this->getModel();
$archive = strtolower($item->name);
$item->files = $model->getFiles($archive);
if (!version_compare(JVERSION, '3.0', 'lt')) {
$form->bind(JArrayHelper::fromObject($item));
} else {
$form->bind($item);
}
$isNew = $item->id < 1;
// Edit or Create?
if ($isNew) {
// initialise new record
$item->published = 1;
}
$lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
$this->form = $form;
$this->lists = $lists;
$this->item = $item;
$this->isNew = $isNew;
parent::display($tpl);
}
示例7: _displayForm
/**
* Displays the form
* @param string $tpl
*/
public function _displayForm($tpl)
{
jimport('joomla.form.formvalidator');
JHTML::stylesheet('fields.css', 'administrator/components/com_szavazasok/assets/');
$db =& JFactory::getDBO();
$uri =& JFactory::getURI();
$user =& JFactory::getUser();
$form = $this->get('Form');
$lists = array();
$editor =& JFactory::getEditor();
//get the item
$item =& $this->get('item');
if (!version_compare(JVERSION, '3.0', 'lt')) {
$form->bind(JArrayHelper::fromObject($item));
} else {
$form->bind($item);
}
$isNew = $item->id < 1;
// Edit or Create?
if ($isNew) {
// initialise new record
$item->published = 1;
}
$lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
$this->assign('form', $form);
$this->assignRef('lists', $lists);
$this->assignRef('editor', $editor);
$this->assignRef('item', $item);
$this->assignRef('isNew', $isNew);
parent::display($tpl);
}
示例8: getFieldHTML
/**
* Method to get the HTML output for specific fields
**/
function getFieldHTML($field, $showRequired = ' *')
{
$fieldType = strtolower($field->type);
if (is_array($field)) {
jimport('joomla.utilities.arrayhelper');
$field = JArrayHelper::toObject($field);
}
CFactory::load('libraries' . DS . 'fields', $fieldType);
$class = 'CFields' . ucfirst($fieldType);
if (is_object($field->options)) {
$field->options = JArrayHelper::fromObject($field->options);
}
// Clean the options
if (!empty($field->options) && !is_array($field->options)) {
array_walk($field->options, array('JString', 'trim'));
}
// Escape the field name
$field->name = $this->escape($field->name);
if (!isset($field->value)) {
$field->value = '';
}
if (class_exists($class)) {
$object = new $class();
if (method_exists($object, 'getFieldHTML')) {
$html = $object->getFieldHTML($field, $showRequired);
return $html;
}
}
return JText::sprintf('CC UNKNOWN USER PROFILE TYPE', $class, $fieldType);
}
示例9: 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;
}
}
示例10: renderListData
/**
* Shows the data formatted for the list view
*
* @param string $data elements data
* @param object &$thisRow all the data in the lists current row
*
* @return string formatted value
*/
public function renderListData($data, &$thisRow)
{
$listModel = $this->getListModel();
$params = $this->getParams();
$w = $params->get('fb_gm_table_mapwidth');
$h = $params->get('fb_gm_table_mapheight');
$z = $params->get('fb_gm_table_zoomlevel');
$data = FabrikWorker::JSONtoData($data, true);
foreach ($data as $i => &$d) {
if ($params->get('fb_gm_staticmap_tableview')) {
$d = $this->_staticMap($d, $w, $h, null, $i, true, JArrayHelper::fromObject($thisRow));
}
if ($params->get('icon_folder') == '1') {
// $$$ rob was returning here but that stoped us being able to use links and icons together
$d = $this->_replaceWithIcons($d, 'list', $listModel->getTmpl());
} else {
if (!$params->get('fb_gm_staticmap_tableview')) {
$d = $params->get('fb_gm_staticmap_tableview_type_coords', 'num') == 'dms' ? $this->_dmsformat($d) : $this->_microformat($d);
}
}
$d = $this->rollover($d, $thisRow, 'list');
$d = $listModel->_addLink($d, $this, $thisRow, $i);
}
return $this->renderListDataFinal($data);
}
示例11: readList
/**
* Read list
*
* @param object $data $limitStart, $limit, $filterSearch,
* $filters, $ordering, $orderingDirection, $language
*
* @return array
*/
public function readList($data)
{
// We are setting the operation of the webservice to Read
$this->setOperation('read');
$dataGet = $this->webservice->options->get('dataGet', array());
if (is_object($dataGet)) {
$dataGet = JArrayHelper::fromObject($dataGet);
}
$dataGet['list']['limitstart'] = isset($data->limitStart) ? (int) $data->limitStart : 0;
$dataGet['list']['limit'] = isset($data->limit) ? (int) $data->limit : 20;
$dataGet['filter']['search'] = isset($data->filterSearch) ? (string) $data->filterSearch : '';
$filters = RApiHalHelper::getFilterFields($this->webservice->configuration->operations->read->list, true);
foreach ($filters as $filter) {
$dataGet['filter'][$filter] = isset($data->filters->{$filter}) ? $data->filters->{$filter} : '';
}
$dataGet['list']['ordering'] = isset($data->ordering) ? (string) $data->ordering : '';
$dataGet['list']['direction'] = isset($data->orderingDirection) ? (string) $data->orderingDirection : '';
// Handle different language switch
$this->setLanguage(isset($data->language) ? (string) $data->language : '');
$this->webservice->options->set('dataGet', $dataGet);
$this->webservice->options->set('task', '');
$this->webservice->options->set('filterOutResourcesGroups', array('_links', '_messages'));
$this->webservice->options->set('filterResourcesSpecific', 'listItem');
$this->webservice->execute();
$arr = $this->webservice->hal->toArray();
$outputResources = RApiSoapHelper::getOutputResources($this->webservice->configuration->operations->read->list, 'listItem', true);
if ($arr['_embedded'] && $arr['_embedded']['item']) {
$response = RApiSoapHelper::selectListResources($outputResources, $arr['_embedded']['item']);
} else {
$response = array();
}
$final = new stdClass();
$final->list = $response;
return $final;
}
示例12: getPivot
/**
* create the pivot data
* @return array of objects - first being the headings, subsequent the data
*/
public function getPivot()
{
$model = $this->formModel->getTableModel();
$params =& $model->getParams();
$val = FabrikString::safeColName($params->get('pivot_value', ''));
$xCol = FabrikString::safeColName($params->get('pivot_xcol', ''));
$yCol = FabrikString::safeColName($params->get('pivot_ycol', ''));
$db =& $model->getDb();
$table =& $model->getTable();
$join = $model->_buildQueryJoin();
$where = $model->_buildQueryWhere();
$db->setQuery("SELECT DISTINCT {$yCol} FROM {$table->db_table_name}");
$yCols = $db->loadResultArray();
$query = "select name,\n";
$data = array();
foreach ($yCols as $c) {
$data[] = "SUM({$val}*(1-abs(sign(" . $yCol . "-" . $c . ")))) as exam" . $c . "\n";
}
$query .= implode(",", $data);
$query .= "\nFROM " . $table->db_table_name . " {$join} {$where} group by {$xCol}";
$db->setQuery($query);
$data = $db->loadObjectList();
$headings = JArrayHelper::toObject(array_keys(JArrayHelper::fromObject($data[0])));
array_unshift($data, $headings);
return $data;
}
示例13: _loadConfig
function _loadConfig()
{
$jconf = new JConfig();
$jconf->password = '*******';
$jconf->ftp_pass = '*******';
$jconf->secret = '*******';
$this->data['Joomla Configuration'] = JArrayHelper::fromObject($jconf);
}
示例14: renderTableData
/**
* shows the data formatted for the table view
* @param string data
* @param object all the data in the tables current row
* @return string formatted value
*/
function renderTableData($data, $oAllRowsData)
{
$fullName = $this->_getQRElement()->getFullName();
$data = $oAllRowsData->{$fullName};
$data = $this->_getQRElement()->getQRValue($data, JArrayHelper::fromObject($oAllRowsData));
$data = $this->_renderTableData($data);
return parent::renderTableData($data, $oAllRowsData);
}
示例15: onAfterProcess
/**
* process the plugin, called when form is submitted
*
* @param object $params
* @param object form
*/
function onAfterProcess($params, &$formModel)
{
$this->formModel = $formModel;
$emailData = $this->getEmailData();
$post = JRequest::get('post');
if (!array_key_exists('fabrik_mailchimp_signup', $post)) {
return;
}
$listId = $params->get('mailchimp_listid');
$apiKey = $params->get('mailchimp_apikey');
if ($apiKey == '') {
JError::raiseNotice(500, 'Mailchimp: no api key specified');
return;
}
if ($listId == '') {
JError::raiseNotice(500, 'Mailchimp: no list id specified');
return;
}
$api = new MCAPI($params->get('mailchimp_apikey'));
$opts = array();
$emailKey = $formModel->getElement($params->get('mailchimp_email'), true)->getFullName();
$firstNameKey = $formModel->getElement($params->get('mailchimp_firstname'), true)->getFullName();
if ($params->get('mailchimp_lastname') !== '') {
$lastNameKey = $formModel->getElement($params->get('mailchimp_lastname'), true)->getFullName();
$lname = $formModel->_formDataWithTableName[$lastNameKey];
$opts['LNAME'] = $lname;
}
$email = $formModel->_formDataWithTableName[$emailKey];
$fname = $formModel->_formDataWithTableName[$firstNameKey];
$opts['FNAME'] = $fname;
$w = new FabrikWorker();
$groupOpts = json_decode($params->get('mailchimp_groupopts', "[]"));
if (!empty($groupOpts)) {
foreach ($groupOpts as $groupOpt) {
$groups = array();
if (isset($groupOpt->groups)) {
$groupOpt->groups = $w->parseMessageForPlaceHolder($groupOpt->groups, $emailData);
$groups[] = JArrayHelper::fromObject($groupOpt);
//array('name'=>'Your Interests:', 'groups'=>'Bananas,Apples')
}
}
$opts['GROUPINGS'] = $groups;
}
// By default this sends a confirmation email - you will not see new members
// until the link contained in it is clicked!
$emailType = $params->get('mailchimp_email_type', 'html');
$doubleOptin = (bool) $params->get('mailchimp_double_optin', true);
$updateExisting = (bool) $params->get('mailchimp_update_existing');
$retval = $api->listSubscribe($listId, $email, $opts, $emailType, $doubleOptin, $updateExisting);
if ($api->errorCode) {
$formModel->_arErrors['mailchimp_error'] = true;
JError::raiseNotice(500, $api->errorCode . ':' . $api->errorMessage);
return false;
} else {
return true;
}
}