当前位置: 首页>>代码示例>>PHP>>正文


PHP xPDO::newObject方法代码示例

本文整理汇总了PHP中xPDO::newObject方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::newObject方法的具体用法?PHP xPDO::newObject怎么用?PHP xPDO::newObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xPDO的用法示例。


在下文中一共展示了xPDO::newObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: transfer

 public function transfer($signature, $target = null, array $args = array())
 {
     $result = false;
     $metadata = $this->info($signature);
     if (!empty($metadata)) {
         /** @var modTransportPackage $package */
         $package = $this->xpdo->newObject('transport.modTransportPackage');
         $package->set('signature', $signature);
         $package->set('state', 1);
         $package->set('workspace', 1);
         $package->set('created', date('Y-m-d h:i:s'));
         $package->set('provider', $this->get('id'));
         $package->set('metadata', $metadata);
         $package->set('package_name', $metadata['name']);
         $package->parseSignature();
         $package->setPackageVersionData();
         $locationArgs = isset($metadata['file']) ? array_merge($metadata['file'], $args) : $args;
         $url = $this->downloadUrl($signature, $this->arg('location', $locationArgs), $args);
         if (!empty($url)) {
             if (empty($target)) {
                 $target = $this->xpdo->getOption('core_path', $args, MODX_CORE_PATH) . 'packages/';
             }
             if ($package->transferPackage($url, $target)) {
                 if ($package->save()) {
                     $package->getTransport();
                     $result = $package;
                 }
             }
         }
     }
     return $result;
 }
开发者ID:modxcustomize,项目名称:Clickatell,代码行数:32,代码来源:modtransportprovider.class.php

示例2: save

 /**
  * Overrides xPDOObject::save to handle closure table edits.
  *
  * @param boolean $cacheFlag
  * @return boolean
  */
 public function save($cacheFlag = null)
 {
     $new = $this->isNew();
     if ($new) {
         if (!$this->get('createdon')) {
             $this->set('createdon', strftime('%Y-%m-%d %H:%M:%S'));
         }
         $ip = $this->get('ip');
         if (empty($ip) && !empty($_SERVER['REMOTE_ADDR'])) {
             $this->set('ip', $_SERVER['REMOTE_ADDR']);
         }
     }
     $saved = parent::save($cacheFlag);
     if ($saved && $new) {
         $id = $this->get('id');
         $parent = $this->get('parent');
         /* create self closure */
         $cl = $this->xpdo->newObject('quipCommentClosure');
         $cl->set('ancestor', $id);
         $cl->set('descendant', $id);
         if ($cl->save() === false) {
             $this->remove();
             return false;
         }
         /* create closures and calculate rank */
         $c = $this->xpdo->newQuery('quipCommentClosure');
         $c->where(array('descendant' => $parent, 'ancestor:!=' => 0));
         $c->sortby('depth', 'DESC');
         $gparents = $this->xpdo->getCollection('quipCommentClosure', $c);
         $cgps = count($gparents);
         $gps = array();
         $i = $cgps;
         /** @var quipCommentClosure $gparent */
         foreach ($gparents as $gparent) {
             $gps[] = str_pad($gparent->get('ancestor'), 10, '0', STR_PAD_LEFT);
             /** @var quipCommentClosure $obj */
             $obj = $this->xpdo->newObject('quipCommentClosure');
             $obj->set('ancestor', $gparent->get('ancestor'));
             $obj->set('descendant', $id);
             $obj->set('depth', $i);
             $obj->save();
             $i--;
         }
         $gps[] = str_pad($id, 10, '0', STR_PAD_LEFT);
         /* add self closure too */
         /* add root closure */
         /** @var quipCommentClosure $cl */
         $cl = $this->xpdo->newObject('quipCommentClosure');
         $cl->set('ancestor', 0);
         $cl->set('descendant', $id);
         $cl->set('depth', $cgps);
         $cl->save();
         /* set rank */
         $rank = implode('-', $gps);
         $this->set('rank', $rank);
         $this->save();
     }
     return $saved;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:65,代码来源:quipcomment.class.php

示例3: joinGroup

 /**
  * Join a User Group, and optionally assign a Role.
  *
  * @access public
  * @param mixed $groupId Either the name or ID of the User Group to join.
  * @param mixed $roleId Optional. Either the name or ID of the Role to
  * @param integer $rank Optional.
  * assign to for the group.
  * @return boolean True if successful.
  */
 public function joinGroup($groupId, $roleId = null, $rank = null)
 {
     $joined = false;
     $groupPk = is_string($groupId) ? array('name' => $groupId) : $groupId;
     /** @var modUserGroup $userGroup */
     $userGroup = $this->xpdo->getObject('modUserGroup', $groupPk);
     if (empty($userGroup)) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'User Group not found with key: ' . $groupId);
         return $joined;
     }
     /** @var modUserGroupRole $role */
     if (!empty($roleId)) {
         $rolePk = is_string($roleId) ? array('name' => $roleId) : $roleId;
         $role = $this->xpdo->getObject('modUserGroupRole', $rolePk);
         if (empty($role)) {
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Role not found with key: ' . $role);
             return $joined;
         }
     }
     /** @var modUserGroupMember $member */
     $member = $this->xpdo->getObject('modUserGroupMember', array('member' => $this->get('id'), 'user_group' => $userGroup->get('id')));
     if (empty($member)) {
         if ($rank == null) {
             $rank = count($this->getMany('UserGroupMembers'));
         }
         $member = $this->xpdo->newObject('modUserGroupMember');
         $member->set('member', $this->get('id'));
         $member->set('user_group', $userGroup->get('id'));
         $member->set('rank', $rank);
         if (!empty($role)) {
             $member->set('role', $role->get('id'));
         }
         $joined = $member->save();
         if (!$joined) {
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'An unknown error occurred preventing adding the User to the User Group.');
         } else {
             unset($_SESSION["modx.user.{$this->get('id')}.userGroupNames"], $_SESSION["modx.user.{$this->get('id')}.userGroups"]);
         }
     } else {
         $joined = true;
     }
     return $joined;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:53,代码来源:moduser.class.php

示例4: flush

} else {
    $xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not remove core/ and core.transport.zip before starting build.');
    flush();
}
/* create core transport package */
$package = new xPDOTransport($xpdo, 'core', $packageDirectory);
unset($packageDirectory);
$xpdo->setPackage('modx', MODX_CORE_PATH . 'model/');
$xpdo->loadClass('modAccess');
$xpdo->loadClass('modAccessibleObject');
$xpdo->loadClass('modAccessibleSimpleObject');
$xpdo->loadClass('modPrincipal');
$xpdo->log(xPDO::LOG_LEVEL_INFO, 'Core transport package created.');
flush();
/* core namespace */
$namespace = $xpdo->newObject('modNamespace');
$namespace->set('name', 'core');
$namespace->set('path', '{core_path}');
$namespace->set('assets_path', '{assets_path}');
$package->put($namespace, array(xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => true));
unset($namespace);
$xpdo->log(xPDO::LOG_LEVEL_INFO, 'Core Namespace packaged.');
flush();
/* modWorkspace */
$collection = array();
$collection['1'] = $xpdo->newObject('modWorkspace');
$collection['1']->fromArray(array('id' => 1, 'name' => 'Default MODX workspace', 'path' => '{core_path}', 'active' => 1), '', true, true);
$attributes = array(xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false);
foreach ($collection as $c) {
    $package->put($c, $attributes);
}
开发者ID:OptimusCrime,项目名称:revolution,代码行数:31,代码来源:transport.core.php

示例5: getFileChunk

 /**
  * @param string $tpl
  * @param array $placeholders
  * @return string
  */
 public function getFileChunk($tpl, array $placeholders = array())
 {
     $output = '';
     $file = $tpl;
     if (!file_exists($file)) {
         $file = $this->modx->getOption('manager_path') . 'templates/' . $this->modx->getOption('manager_theme', null, 'default') . '/' . $tpl;
     }
     if (!file_exists($file)) {
         $file = $this->modx->getOption('manager_path') . 'templates/default/' . $tpl;
     }
     if (file_exists($file)) {
         /** @var modChunk $chunk */
         $chunk = $this->modx->newObject('modChunk');
         $chunk->setCacheable(false);
         $tplContent = file_get_contents($file);
         $chunk->setContent($tplContent);
         $output = $chunk->process($placeholders);
     }
     return $output;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:25,代码来源:moddashboardwidget.class.php

示例6: readAll

 /**
  * Mark all posts in this thread as read
  * @static
  * @param xPDO $modx
  * @param string $type
  * @return bool
  */
 public static function readAll(xPDO &$modx, $type = 'message')
 {
     $userId = $modx->discuss->user->get('id');
     $sql = 'SELECT `disThread`.`id`
     FROM ' . $modx->getTableName('disThread') . ' `disThread`
         INNER JOIN ' . $modx->getTableName('disThreadUser') . ' `ThreadUser`
         ON `ThreadUser`.`thread` = `disThread`.`id`
         LEFT JOIN ' . $modx->getTableName('disThreadRead') . ' `ThreadRead`
         ON `ThreadRead`.`thread` = `disThread`.`id`
     WHERE
         `ThreadUser`.`user` = ' . $userId . '
     AND `ThreadRead`.`id` IS NULL
     AND `private` = 1
     ORDER BY `disThread`.`id` DESC';
     $stmt = $modx->query($sql);
     if (!$stmt) {
         return false;
     }
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $read = $modx->getCount('disThreadRead', array('thread' => $row['id'], 'user' => $userId));
         if ($read == 0) {
             $read = $modx->newObject('disThreadRead');
             $read->fromArray(array('thread' => $row['id'], 'board' => 0, 'user' => $userId));
             $read->save();
         }
     }
     $stmt->closeCursor();
     return true;
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:36,代码来源:disthread.class.php


注:本文中的xPDO::newObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。