本文整理汇总了PHP中FArrayHelper::fromObject方法的典型用法代码示例。如果您正苦于以下问题:PHP FArrayHelper::fromObject方法的具体用法?PHP FArrayHelper::fromObject怎么用?PHP FArrayHelper::fromObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FArrayHelper
的用法示例。
在下文中一共展示了FArrayHelper::fromObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAjax_download
/**
* Not really an AJAX call, we just use the pluginAjax method so we can run this
* method for handling scripted downloads.
*
* @return void
*/
public function onAjax_download()
{
$input = $this->app->input;
$this->setId($input->getInt('element_id'));
$this->loadMeForAjax();
$this->getElement();
$params = $this->getParams();
$url = $input->server->get('HTTP_REFERER', '', 'string');
$this->lang->load('com_fabrik.plg.element.fabrikfileupload', JPATH_ADMINISTRATOR);
$rowId = $input->get('rowid', '', 'string');
$repeatCount = $input->getInt('repeatcount', 0);
$listModel = $this->getListModel();
$row = $listModel->getRow($rowId, false, true);
if (!$this->canView()) {
$this->app->enqueueMessage(FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_PERMISSION'));
$this->app->redirect($url);
exit;
}
if (empty($rowId)) {
$errMsg = FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE');
$errMsg .= FabrikHelperHTML::isDebug() ? ' (empty rowid)' : '';
$this->app->enqueueMessage($errMsg);
$this->app->redirect($url);
exit;
}
if (empty($row)) {
$errMsg = FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE');
$errMsg .= FabrikHelperHTML::isDebug() ? " (no such row)" : '';
$this->app->enqueueMessage($errMsg);
$this->app->redirect($url);
exit;
}
$aclEl = $this->getFormModel()->getElement($params->get('fu_download_acl', ''), true);
if (!empty($aclEl)) {
$aclEl = $aclEl->getFullName();
$aclElRaw = $aclEl . '_raw';
$groups = $this->user->getAuthorisedViewLevels();
$canDownload = in_array($row->{$aclElRaw}, $groups);
if (!$canDownload) {
$this->app->enqueueMessage(FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_PERMISSION'));
$this->app->redirect($url);
}
}
$storage = $this->getStorage();
$elName = $this->getFullName(true, false);
$filePath = $row->{$elName};
$filePath = FabrikWorker::JSONtoData($filePath, false);
$filePath = is_object($filePath) ? FArrayHelper::fromObject($filePath) : (array) $filePath;
$filePath = FArrayHelper::getValue($filePath, $repeatCount);
$filePath = $storage->getFullPath($filePath);
$fileContent = $storage->read($filePath);
if ($fileContent !== false) {
$thisFileInfo = $storage->getFileInfo($filePath);
if ($thisFileInfo === false) {
$errMsg = FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE');
$errMsg .= FabrikHelperHTML::isDebug(true) ? ' (path: ' . $filePath . ')' : '';
$this->app->enqueueMessage($errMsg);
$this->app->redirect($url);
exit;
}
// Some time in the past
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Accept-Ranges: bytes');
header('Content-Length: ' . $thisFileInfo['filesize']);
header('Content-Type: ' . $thisFileInfo['mime_type']);
header('Content-Disposition: attachment; filename="' . $thisFileInfo['filename'] . '"');
// Serve up the file
echo $fileContent;
// $this->downloadEmail($row, $filePath);
$this->downloadHit($rowId, $repeatCount);
$this->downloadLog($row, $filePath);
// And we're done.
exit;
} else {
$this->app->enqueueMessage(FText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE'));
$this->app->redirect($url);
exit;
}
}
示例2: replace
//.........这里部分代码省略.........
return;
}
$model->setId($listId);
$formModel = $model->getFormModel();
$groups = $formModel->getGroupsHiarachy();
foreach ($groups as $groupModel) {
$elements = $groupModel->getMyElements();
foreach ($elements as &$elementModel) {
// $$$ rob 26/05/2011 changed it so that you can pick up joined elements without specifying plugin
// param 'element' as joinx[x][fullname] but simply 'fullname'
if ($element == $elementModel->getFullName(true, false)) {
$activeEl = $elementModel;
continue 2;
}
}
}
// $$$ hugh in case they have a typo in their elementname
if (empty($activeEl) || !$activeEl->isPublished()) {
throw new RuntimeException('You are trying to embed an element called ' . $element . ' which is not present in the list or has been unpublished');
}
if ($rowId === '') {
$rows = $model->getData();
$group = array_shift($rows);
$row = array_shift($group);
$res = $row->{$element};
} else {
$this->_setRequest($unused);
$row = $model->getRow($rowId, false, true);
if (substr($element, JString::strlen($element) - 4, JString::strlen($element)) !== '_raw') {
$element = $element . '_raw';
}
// $$$ hugh - need to pass all row data, or calc elements that use {placeholders} won't work
//$defaultData = is_object($row) ? get_object_vars($row) : $row;
$defaultData = is_object($row) ? FArrayHelper::fromObject($row, true) : $row;
/* $$$ hugh - if we don't do this, our passed data gets blown away when render() merges the form data
* not sure why, but apparently if you do $foo =& $bar and $bar is NULL ... $foo ends up NULL
*/
$activeEl->getFormModel()->data = $defaultData;
$activeEl->editable = false;
// Set row id for things like user element
$origRowId = $input->get('rowid');
$input->set('rowid', $rowId);
// Set detail view for things like youtube element
$origView = $input->get('view');
$input->set('view', 'details');
$defaultData = (array) $defaultData;
unset($activeEl->defaults);
if ($repeatCounter === 'all') {
$repeat = $activeEl->getGroupModel()->repeatCount();
$res = array();
for ($j = 0; $j < $repeat; $j++) {
$res[] = $activeEl->render($defaultData, $j);
}
$res = count($res) > 1 ? '<ul><li>' . implode('</li><li>', $res) . '</li></ul>' : $res[0];
} else {
$res = $activeEl->render($defaultData, $repeatCounter);
$ref = $activeEl->elementJavascript($repeatCounter);
}
$input->set('rowid', $origRowId);
$input->set('view', $origView);
$this->resetRequest();
}
return $res;
}
if (!isset($viewName)) {
return;
示例3: onUpdateAdmin
/**
* From admin the user has authorize the plugin for this app.
* Lets store the data for it.
* As we are in a pop up window we need to set some js to update the parent window's
* parameters
*
* @return void
*/
public function onUpdateAdmin()
{
$input = $this->app->input;
$formModel = $this->buildModel($input->getInt('formid'));
$params = $formModel->getParams();
$renderOrder = $input->get('repeatCounter');
$consumerKey = FArrayHelper::fromObject($params->get('twitter_consumer_key'));
$consumerKey = $consumerKey[$renderOrder];
$consumerSecret = FArrayHelper::fromObject($params->get('twitter_consumer_secret'));
$consumerSecret = $consumerSecret[$renderOrder];
$connection = new TwitterOAuth($consumerKey, $consumerSecret, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
/* Request access tokens from twitter */
$access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_REQUEST['oauth_verifier']));
// Save the access token to the element params
$formModel = JModelLegacy::getInstance('Form', 'FabrikFEModel');
$formModel->setId($input->getInt('formid'));
$row = $formModel->getForm();
$params = $formModel->getParams();
$opts = $params->toArray();
$counter = $input->get('repeatCounter');
$pairs = array('twitter_oauth_token' => 'oauth_token', 'twitter_oauth_token_secret' => 'oauth_token_secret', 'twitter_oauth_user' => 'screen_name');
$js = array();
$jsValues = array();
foreach ($pairs as $paramname => $requestname) {
$tokens = (array) FArrayHelper::getValue($opts, $paramname);
$newtokens = array();
for ($i = 0; $i <= $counter; $i++) {
$newtokens[$i] = $i == $counter ? $access_token[$requestname] : '';
$jsid = '#jform_params_' . $paramname . '-' . $i;
//$js[] = "window.opener.document.getElement('$jsid').value = '$newtokens[$i]';";
$jsValues[] = array($jsid, $newtokens[$i]);
}
$opts[$paramname] = $newtokens;
}
$json = json_encode($jsValues);
$row->params = json_encode($opts);
$row->store();
$langFile = 'com_fabrik.plg.form.fabriktwitter';
$this->lang->load($langFile, JPATH_ADMINISTRATOR, null, true);
// If we had already authorized the app then we will still be in the admin page - so update the fields:
echo FText::_('PLG_FORM_TWITTER_CREDENTIALS_SAVED');
$document = JFactory::getDocument();
//$script = implode("\n", $js) . "
$script = <<<EOT
window.opener.postMessage({$json}, '*');
(function() {window.close()}).delay(4000);
EOT;
$document->addScriptDeclaration($script);
}