本文整理汇总了PHP中xPDOObject::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDOObject::toArray方法的具体用法?PHP xPDOObject::toArray怎么用?PHP xPDOObject::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDOObject
的用法示例。
在下文中一共展示了xPDOObject::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareRow
/**
* Prepare the row for iteration
* @param xPDOObject $object
* @return array
*/
public function prepareRow(xPDOObject $object)
{
$objectArray = $object->toArray();
$objectArray['catid'] = $objectArray['id'];
$objectArray['text'] = $objectArray['name'];
$hasChildren = $this->_hasChildren($objectArray['catid']);
$objectArray['leaf'] = $hasChildren ? FALSE : TRUE;
$usergroups = $object->getMany('vnewsCategoriesHasUsergroups');
$usergroupsArray = array();
if ($usergroups) {
foreach ($usergroups as $usergroup) {
$usergroupId = $usergroup->get('usergroup_id');
$c = $this->modx->newQuery('modUserGroup');
$c->where(array('id' => $usergroupId));
$modUserGroup = $this->modx->getObject('modUserGroup', $c);
if ($modUserGroup) {
$usergroupsArray[] = array('usergroup_id' => $usergroupId, 'usergroup' => $modUserGroup->get('name'));
}
}
}
$objectArray['usergroups'] = $usergroupsArray;
unset($objectArray['id']);
// avoid Ext component's ID
return $objectArray;
}
示例2: prepareRow
public function prepareRow(xPDOObject $object)
{
$objectArray = $object->toArray();
$objectArray['sender_name'] = $object->get('sender_username');
$objectArray['read'] = $object->get('read') ? true : false;
return $objectArray;
}
示例3: prepareRow
/**
* @param xPDOObject|quipCommentNotify $object
* @return boolean
*/
public function prepareRow(xPDOObject $object)
{
$notifyArray = $object->toArray();
$notifyArray['cls'] = '';
$notifyArray['createdon'] = !empty($notifyArray['createdon']) ? strftime('%b %d, %Y %H:%M %p', strtotime($notifyArray['createdon'])) : '';
return $notifyArray;
}
示例4: prepareRow
/**
* @param xPDOObject $object
* @return array
*/
public function prepareRow(xPDOObject $object)
{
$array = $object->toArray();
$array['actions'] = array();
if (!($user = $this->modx->getObject('modUser', $array['user_id']))) {
return $this->failure($this->modx->lexicon('identifyx_user_err_nf') . ' №' . $id);
}
$blocked = $user->Profile->get('blocked');
if ($blocked) {
$array['actions'][] = array('cls' => '', 'icon' => 'icon icon-power-off action-green', 'title' => $this->modx->lexicon('identifyx_user_enable'), 'multiple' => $this->modx->lexicon('identifyx_users_enable'), 'action' => 'unblockUser', 'button' => true, 'menu' => true);
} else {
$array['actions'][] = array('cls' => '', 'icon' => 'icon icon-power-off action-gray', 'title' => $this->modx->lexicon('identifyx_user_disable'), 'multiple' => $this->modx->lexicon('identifyx_users_disable'), 'action' => 'blockUser', 'button' => true, 'menu' => true);
}
// // Edit
// $array['actions'][] = array(
// 'cls' => '',
// 'icon' => 'icon icon-edit',
// 'title' => $this->modx->lexicon('identifyx_item_update'),
// 'multiple' => $this->modx->lexicon('identifyx_items_update'),
// 'action' => 'updateData',
// 'button' => true,
// 'menu' => true,
// );
// // Remove
// $array['actions'][] = array(
// 'cls' => '',
// 'icon' => 'icon icon-trash-o action-red',
// 'title' => $this->modx->lexicon('identifyx_item_remove'),
// 'multiple' => $this->modx->lexicon('identifyx_items_remove'),
// 'action' => 'removeData',
// 'button' => true,
// 'menu' => true,
// );
return $array;
}
示例5: prepareRow
public function prepareRow(xPDOObject $object)
{
$ff = $object->toArray();
$ff['encrypted'] = $this->modx->getCount($this->classKey, array('form' => $ff['form'], 'encrypted' => 1));
$ff['total'] = $this->modx->getCount($this->classKey, array('form' => $ff['form']));
return $ff;
}
示例6: delete
/**
* Handle DELETE requests
* @return array
*/
public function delete()
{
$id = $this->getProperty($this->primaryKeyField, false);
if (empty($id)) {
return $this->failure($this->modx->lexicon('rest.err_field_ns', array('field' => $this->primaryKeyField)));
}
$c = $this->getPrimaryKeyCriteria($id);
$this->object = $this->modx->getObject($this->classKey, $c);
if (empty($this->object)) {
return $this->failure($this->modx->lexicon('rest.err_obj_nf', array('class_key' => $this->classKey)));
}
if (!empty($this->deleteRequiredFields)) {
if (!$this->checkRequiredFields($this->deleteRequiredFields)) {
return $this->failure();
}
}
$this->object->fromArray($this->getProperties());
$beforeDelete = $this->beforeDelete();
if ($beforeDelete !== true) {
return $this->failure($beforeDelete === false ? $this->errorMessage : $beforeDelete);
}
if (!$this->object->{$this->deleteMethod}()) {
$this->setObjectErrors();
return $this->failure($this->modx->lexicon('rest.err_class_remove', array('class_key' => $this->classKey)));
}
$objectArray = $this->object->toArray();
$this->afterDelete($objectArray);
return $this->success('', $objectArray);
}
示例7: prepareRow
public function prepareRow(xPDOObject $object)
{
$objectArray = $object->toArray();
$objectArray['category_name'] = $object->get('category_name');
unset($objectArray['content']);
return $objectArray;
}
示例8: prepareRow
/**
* Prepare the row for iteration
* @param xPDOObject $object
* @return array
*/
public function prepareRow(xPDOObject $object)
{
$objectArray = $object->toArray();
unset($objectArray['password'], $objectArray['cachepwd'], $objectArray['salt'], $objectArray['class_key'], $objectArray['active'], $objectArray['remote_key'], $objectArray['remote_data'], $objectArray['hash_class'], $objectArray['primary_group'], $objectArray['session_stale'], $objectArray['sudo'], $objectArray['blocked']);
$objectArray['uid'] = $objectArray['id'];
$objectArray['text'] = $objectArray['username'] . ' (' . $objectArray['id'] . ')';
$basePath = $this->modx->getOption('uploadtousers.base_path', null, $this->modx->getOption('assets_path') . 'userfiles/');
if (!is_dir($basePath)) {
$this->modx->log(modX::LOG_LEVEL_ERROR, $basePath . ' for Upload to Users package does not exist.');
return $objectArray;
}
$folderName = $this->modx->getOption('uploadtousers.foldername');
if (!empty($folderName)) {
switch ($folderName) {
case 'id':
$dirPath = $basePath . $objectArray['uid'] . '/';
break;
case 'username':
$dirPath = $basePath . $objectArray['username'] . '/';
break;
default:
break;
}
$objectArray['leaf'] = $this->_leaf($dirPath);
}
if (!is_dir($dirPath)) {
@mkdir($dirPath);
}
$objectArray['dirPath'] = $dirPath;
$objectArray['type'] = 'user';
unset($objectArray['id']);
// avoid Ext component's ID
return $objectArray;
}
示例9: prepareRow
public function prepareRow(xPDOObject $object)
{
$core = array('Resource', 'Object', 'Administrator', 'Load Only', 'Load, List and View');
$policyArray = $object->toArray();
$permissions = array();
$cls = 'pedit';
if (!in_array($object->get('name'), $core)) {
$cls .= ' premove';
}
$policyArray['cls'] = $cls;
if (!empty($policyArray['total_permissions'])) {
$data = $object->get('data');
$ct = 0;
if (!empty($data)) {
foreach ($data as $k => $v) {
if (!empty($v)) {
$permissions[] = $k;
$ct++;
}
}
}
$policyArray['active_permissions'] = $ct;
$policyArray['active_of'] = $this->modx->lexicon('active_of', array('active' => $policyArray['active_permissions'], 'total' => $policyArray['total_permissions']));
$policyArray['permissions'] = $permissions;
}
unset($policyArray['data']);
return $policyArray;
}
示例10: prepareRow
/**
* @param xPDOObject $object
*
* @return array
*/
public function prepareRow(xPDOObject $object)
{
$array = $object->toArray();
$array['key'] = $array['classKey'] . '-' . $array['item'];
switch ($array['classKey']) {
case 'modTemplate':
$array['name'] = '<a href="index.php?a=element/template/update&id=' . $array['item'] . '">' . $array['templatename'] . '</a>';
break;
case 'modChunk':
$array['name'] = '<a href="index.php?a=element/chunk/update&id=' . $array['item'] . '">' . $array['chunkname'] . '</a>';
break;
case 'modSnippet':
$array['name'] = '<a href="index.php?a=element/snippet/update&id=' . $array['item'] . '">' . $array['snippetname'] . '</a>';
break;
case 'modPlugin':
$array['name'] = '<a href="index.php?a=element/plugin/update&id=' . $array['item'] . '">' . $array['pluginname'] . '</a>';
break;
case 'modTemplateVar':
$array['name'] = '<a href="index.php?a=element/tv/update&id=' . $array['item'] . '">' . $array['tvname'] . '</a>';
break;
}
if (!isset($array['name'])) {
$array['name'] = '(' . $this->modx->lexicon('deleted') . ')';
}
unset($array['templatename'], $array['chunkname'], $array['snippetname'], $array['pluginname'], $array['id']);
$array['actions'][] = array('cls' => '', 'icon' => 'icon icon-pencil-square-o ', 'title' => $this->modx->lexicon('admintools_open'), 'action' => 'openElement', 'button' => true, 'menu' => true);
return $array;
}
示例11: prepareRow
public function prepareRow(xPDOObject $object)
{
$itemArray = $object->toArray();
$itemArray['album'] = $this->getProperty('album');
$itemArray['filename'] = basename($object->get('filename'));
$imagePath = $object->get('image_path');
$size = @getimagesize($imagePath);
if (is_array($size)) {
$itemArray['image_width'] = $size[0];
$itemArray['image_height'] = $size[1];
$itemArray['image_type'] = $size[2];
}
$c = array();
$c['h'] = $this->modx->getOption('gallery.backend_thumb_height', null, 60);
$c['w'] = $this->modx->getOption('gallery.backend_thumb_width', null, 80);
$c['zc'] = $this->modx->getOption('gallery.backend_thumb_zoomcrop', null, 1);
$c['far'] = $this->modx->getOption('gallery.backend_thumb_far', null, 'C');
$itemArray['thumbnail'] = $object->get('thumbnail', $c);
$itemArray['image'] = $object->get('image');
$itemArray['relativeImage'] = $object->get('relativeImage');
$itemArray['absoluteImage'] = $object->get('absoluteImage');
$itemArray['filesize'] = $object->get('filesize');
$itemArray['menu'] = array();
$itemArray['menu'][] = array('text' => $this->modx->lexicon('gallery.item_update'), 'handler' => 'this.updateItem');
$itemArray['menu'][] = '-';
$itemArray['menu'][] = array('text' => $this->modx->lexicon('gallery.item_delete'), 'handler' => 'this.deleteItem');
return $itemArray;
}
示例12: prepareRow
/**
* Prepare the row for iteration
* @param xPDOObject $object
* @return array
*/
public function prepareRow(xPDOObject $object)
{
$objectArray = $object->toArray();
$objectArray['usergroups'] = '';
if (!empty($objectArray['user_id'])) {
$userObj = $this->modx->getObject('modUser', $objectArray['user_id']);
if ($userObj) {
$usergroups = $userObj->getUserGroupNames();
if ($usergroups) {
$objectArray['usergroups'] = @implode(',', $usergroups);
}
}
}
$subscribersHasCategories = $object->getMany('vnewsSubscribersHasCategories');
$objectArray['categories'] = '';
if ($subscribersHasCategories) {
$categories = array();
foreach ($subscribersHasCategories as $subsHasCats) {
$category = $subsHasCats->getOne('vnewsCategories');
$categories[] = $category->get('name');
}
$objectArray['categories'] = @implode(',', $categories);
}
return $objectArray;
}
示例13: prepareRow
/** {@inheritDoc} */
public function prepareRow(xPDOObject $object)
{
$icon = 'fa';
$array = $object->toArray();
$array['actions'] = array();
// Menu
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-cog actions-menu", 'menu' => false, 'button' => true, 'action' => 'showMenu', 'type' => 'menu');
// Edit
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-edit green", 'title' => $this->modx->lexicon('mlmsystem_action_edit'), 'action' => 'update', 'button' => true, 'menu' => true);
// sep
$array['actions'][] = array('cls' => '', 'icon' => '', 'title' => '', 'action' => 'sep', 'button' => false, 'menu' => true);
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-street-view", 'title' => $this->modx->lexicon('mlmsystem_action_change_parent'), 'action' => 'changeParent', 'button' => false, 'menu' => true);
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-money ", 'title' => $this->modx->lexicon('mlmsystem_action_change_balance'), 'action' => 'changeBalance', 'button' => true, 'menu' => true);
// sep
$array['actions'][] = array('cls' => '', 'icon' => '', 'title' => '', 'action' => 'sep', 'button' => false, 'menu' => true);
//Blocked status
if ($array['status'] != $this->statusBlocked) {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-unlock-alt red", 'title' => $this->modx->lexicon('mlmsystem_action_active_blocked'), 'action' => 'activeBlocked', 'button' => false, 'menu' => true);
} else {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-unlock green", 'title' => $this->modx->lexicon('mlmsystem_action_inactive_blocked'), 'action' => 'inactiveBlocked', 'button' => false, 'menu' => true);
}
if (!$array['leader']) {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-shield green", 'title' => $this->modx->lexicon('mlmsystem_action_active_leader'), 'action' => 'activeLeader', 'button' => false, 'menu' => true);
} else {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-shield red", 'title' => $this->modx->lexicon('mlmsystem_action_inactive_leader'), 'action' => 'inactiveLeader', 'button' => false, 'menu' => true);
}
// Remove
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-trash-o red", 'title' => $this->modx->lexicon('mlmsystem_action_remove'), 'action' => 'remove', 'button' => false, 'menu' => true);
return $array;
}
示例14: prepareRow
/**
* @param xPDOObject $object
*
* @return array
*/
public function prepareRow(xPDOObject $object)
{
$icon = 'fa';
$array = $object->toArray();
$array['actions'] = array();
// Edit
/*$array['actions'][] = array(
'cls' => '',
'icon' => "$icon $icon-eye green",
'title' => $this->modx->lexicon('gl_action_view'),
'action' => 'update',
'button' => true,
'menu' => true,
);*/
if (!$array['active']) {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-toggle-off red", 'title' => $this->modx->lexicon('gl_action_active'), 'action' => 'active', 'button' => true, 'menu' => true);
} else {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-toggle-on green", 'title' => $this->modx->lexicon('gl_action_inactive'), 'action' => 'inactive', 'button' => true, 'menu' => true);
}
// sep
$array['actions'][] = array('cls' => '', 'icon' => '', 'title' => '', 'action' => 'sep', 'button' => false, 'menu' => true);
// Remove
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-trash-o red", 'title' => $this->modx->lexicon('gl_action_remove'), 'action' => 'remove', 'button' => true, 'menu' => true);
return $array;
}
示例15: prepareRow
/**
* @param xPDOObject $object
*
* @return array
*/
public function prepareRow(xPDOObject $object)
{
$icon = 'icon';
$array = $object->toArray();
$array['actions'] = array();
// Edit
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-edit green", 'title' => $this->modx->lexicon('gl_action_update'), 'action' => 'update', 'button' => true, 'menu' => true);
if ($array['default']) {
return $array;
}
switch (true) {
case $array['active']:
break;
case $array['active1']:
$array['active'] = 1;
break;
case $array['active2']:
$array['active'] = 1;
break;
default:
$array['active'] = 0;
}
if (!$array['active']) {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-toggle-off red", 'title' => $this->modx->lexicon('gl_action_active'), 'action' => 'active', 'button' => true, 'menu' => true);
} else {
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-toggle-on green", 'title' => $this->modx->lexicon('gl_action_inactive'), 'action' => 'inactive', 'button' => true, 'menu' => true);
}
// sep
$array['actions'][] = array('cls' => '', 'icon' => '', 'title' => '', 'action' => 'sep', 'button' => false, 'menu' => true);
// Remove
$array['actions'][] = array('cls' => '', 'icon' => "{$icon} {$icon}-trash-o red", 'title' => $this->modx->lexicon('gl_action_remove'), 'action' => 'remove', 'button' => true, 'menu' => true);
return $array;
}