當前位置: 首頁>>代碼示例>>PHP>>正文


PHP modResource類代碼示例

本文整理匯總了PHP中modResource的典型用法代碼示例。如果您正苦於以下問題:PHP modResource類的具體用法?PHP modResource怎麽用?PHP modResource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了modResource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkRules

 public function checkRules()
 {
     $DocID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
     $rules = $this->getOptions("rules", array());
     $flag = empty($rules);
     if (!$flag && $DocID && $this->loadModClass("modResource")) {
         $DOC = new modResource($this->_modx);
         $data = $DOC->edit($DocID)->toArray();
         $flag = true;
         foreach ($rules as $item => $value) {
             switch ($item) {
                 case 'id':
                     if ($DOC->getID() != $value) {
                         $flag = false;
                     }
                     break;
                 default:
                     if (!isset($data[$item]) || $data[$item] != $value) {
                         $flag = false;
                     }
                     break;
             }
         }
     }
     return $flag;
 }
開發者ID:dukeRD,項目名稱:customTables,代碼行數:26,代碼來源:CRGrid.class.php

示例2: handleOriginalParent

 /**
  * @param \modResource $originalParent
  */
 protected function handleOriginalParent($originalParent)
 {
     $originalGreatParent = $originalParent->Parent;
     if ($originalGreatParent && $originalGreatParent->class_key == 'CollectionContainer' && $originalParent->hasChildren() == 0) {
         $originalParent->set('show_in_tree', 0);
         $originalParent->save();
     }
 }
開發者ID:Burick,項目名稱:Collections,代碼行數:11,代碼來源:collectionsonresourcebeforesort.class.php

示例3: beforeSave

 public function beforeSave()
 {
     /** @var modResource $parent */
     $parent = $this->modx->getObject('modResource', $this->object->parent);
     if ($parent && $parent->class_key == 'CollectionContainer') {
         $this->object->set('show_in_tree', 0);
     } else {
         $this->object->set('show_in_tree', 1);
     }
     return parent::beforeSave();
 }
開發者ID:lokamaya,項目名稱:Collections,代碼行數:11,代碼來源:changeparent.class.php

示例4: process

 public function process()
 {
     /* @var modResourceGroupResource $resourceGroupResource */
     $resourceGroupResource = $this->modx->getObject('modResourceGroupResource', array('document_group' => $this->resourceGroup->get('id'), 'document' => $this->resource->get('id')));
     if (empty($resourceGroupResource)) {
         return $this->failure($this->modx->lexicon('resource_group_resource_err_nf'));
     }
     if ($resourceGroupResource->remove() == false) {
         return $this->failure($this->modx->lexicon('resource_group_resource_err_remove'));
     } else {
         $this->fireAfterRemove();
     }
     return $this->success('', $resourceGroupResource);
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:14,代碼來源:removeresource.class.php

示例5: process

 /**
  * Process this page, load the resource, and present its values
  * @return void
  */
 public function process()
 {
     $data = $this->processInput($this->config['gpc']);
     /* @var modProcessorResponse $response */
     $response = $this->modx->runProcessor('resource/update', $data);
     if (!$response->isError()) {
         $tempRes = $response->getObject();
         $this->resource = $this->modx->getObject('modResource', $tempRes['id']);
         $this->setPlaceholders(array('message' => $this->modx->lexicon('updated'), 'resid' => $this->resource->get('id'), 'ctx' => $this->resource->get('context_key')));
     } else {
         $error = $response->getAllErrors();
         $this->setPlaceholder('message', 'Something went wrong updating the Resource: ' . implode(', ', $error));
     }
 }
開發者ID:rossng,項目名稱:HandyMan,代碼行數:18,代碼來源:update.save.class.php

示例6: handleOriginalParent

 /**
  * @param \modResource $parent
  * @param \modResource $resource
  * @param \modResource $originalParent
  */
 protected function handleOriginalParent($parent, $resource, $originalParent)
 {
     if ($originalParent->class_key == 'CollectionContainer') {
         if ($parent->class_key != 'CollectionContainer') {
             $resource->set('show_in_tree', 1);
         }
     } else {
         /** @var \modResource $originalGreatParent */
         $originalGreatParent = $originalParent->Parent;
         if ($originalGreatParent && $originalGreatParent->class_key == 'CollectionContainer') {
             $resource->set('show_in_tree', 1);
         }
     }
 }
開發者ID:Burick,項目名稱:Collections,代碼行數:19,代碼來源:collectionsonbeforedocformsave.class.php

示例7: getResourceGroups

 public function getResourceGroups()
 {
     $parentGroups = array();
     if ($this->resource->get('id') == 0) {
         $parent = $this->modx->getObject('modResource', $this->resource->get('parent'));
         /** @var modResource $parent */
         if ($parent) {
             $parentResourceGroups = $parent->getMany('ResourceGroupResources');
             /** @var modResourceGroupResource $parentResourceGroup */
             foreach ($parentResourceGroups as $parentResourceGroup) {
                 $parentGroups[] = $parentResourceGroup->get('document_group');
             }
             $parentGroups = array_unique($parentGroups);
         }
     }
     $this->resourceArray['resourceGroups'] = array();
     $resourceGroups = $this->resource->getGroupsList(array('name' => 'ASC'), 0, 0);
     /** @var modResourceGroup $resourceGroup */
     foreach ($resourceGroups['collection'] as $resourceGroup) {
         $access = (bool) $resourceGroup->get('access');
         if (!empty($parent) && $this->resource->get('id') == 0) {
             $access = in_array($resourceGroup->get('id'), $parentGroups) ? true : false;
         }
         $resourceGroupArray = array($resourceGroup->get('id'), $resourceGroup->get('name'), $access);
         $this->resourceArray['resourceGroups'][] = $resourceGroupArray;
     }
     return $this->resourceArray['resourceGroups'];
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:28,代碼來源:resource.class.php

示例8: modresource_populate_children

function modresource_populate_children(\Teleport\Action\Extract &$extract, modResource &$object, $criteria, $graph, $graphCriteria, $vehicle, &$vehicleCount)
{
    unset($criteria['parent']);
    $children = $object->getMany('Children', null, false);
    if ($children) {
        foreach ($children as &$child) {
            /** @var modResource $child */
            if ($graph !== null) {
                $child->getGraph($graph, $graphCriteria);
            }
            if ($extract->package->put($child, $vehicle['attributes'])) {
                $vehicleCount++;
            }
            modresource_populate_children($extract, $child, $criteria, $graph, $graphCriteria, $vehicle, $vehicleCount);
        }
    }
}
開發者ID:exside,項目名稱:teleport,代碼行數:17,代碼來源:modresourcechildren.php

示例9: prepareResourceNode

 /** {@inheritDoc} */
 public function prepareResourceNode(modResource $resource)
 {
     $qtipField = $this->getProperty('qtipField');
     $nodeField = $this->getProperty('nodeField');
     $hasChildren = (int) $resource->get('childrenCount') > 0 && $resource->get('hide_children_in_tree') == 0 ? true : false;
     // Assign an icon class based on the class_key
     $class = $iconCls = array();
     $classKey = strtolower($resource->get('class_key'));
     if (substr($classKey, 0, 3) == 'mod') {
         $classKey = substr($classKey, 3);
     }
     $classKeyIcon = $this->modx->getOption('mgr_tree_icon_' . $classKey, null, 'tree-resource');
     $iconCls[] = $classKeyIcon;
     $class[] = 'icon-' . strtolower(str_replace('mod', '', $resource->get('class_key')));
     if (!$resource->isfolder) {
         $class[] = 'x-tree-node-leaf icon-resource';
     }
     if (!$resource->get('published')) {
         $class[] = 'unpublished';
     }
     if ($resource->get('deleted')) {
         $class[] = 'deleted';
     }
     if ($resource->get('hidemenu')) {
         $class[] = 'hidemenu';
     }
     if ($hasChildren) {
         $class[] = 'haschildren';
         $iconCls[] = $this->modx->getOption('mgr_tree_icon_folder', null, 'tree-folder');
         $iconCls[] = 'parent-resource';
     }
     $qtip = '';
     if (!empty($qtipField)) {
         $qtip = '<b>' . strip_tags($resource->{$qtipField}) . '</b>';
     } else {
         if ($resource->longtitle != '') {
             $qtip = '<b>' . strip_tags($resource->longtitle) . '</b><br />';
         }
         if ($resource->description != '') {
             $qtip = '<i>' . strip_tags($resource->description) . '</i>';
         }
     }
     $idNote = $this->modx->hasPermission('tree_show_resource_ids') ? ' <span dir="ltr">(' . $resource->id . ')</span>' : '';
     $itemArray = array('text' => strip_tags($resource->{$nodeField}) . $idNote, 'id' => $resource->context_key . '_' . $resource->id, 'pk' => $resource->id, 'cls' => implode(' ', $class), 'iconCls' => implode(' ', $iconCls), 'type' => 'modResource', 'classKey' => $resource->class_key, 'ctx' => $resource->context_key, 'hide_children_in_tree' => $resource->hide_children_in_tree, 'qtip' => $qtip, 'checked' => !empty($resource->member) || $resource->id == $this->parent_id ? true : false, 'disabled' => $resource->id == $this->parent_id ? true : false);
     if (!$hasChildren) {
         $itemArray['hasChildren'] = false;
         $itemArray['children'] = array();
         $itemArray['expanded'] = true;
     } else {
         $itemArray['hasChildren'] = true;
     }
     if ($itemArray['classKey'] != 'msCategory') {
         unset($itemArray['checked']);
     }
     return $itemArray;
 }
開發者ID:volkovnd,項目名稱:miniShop2,代碼行數:57,代碼來源:getnodes.class.php

示例10: getResource

 /**
  * Get the Resource associated
  * 
  * @return modResource|string
  */
 public function getResource()
 {
     $resourceId = $this->getProperty('resource', 0);
     if (empty($resourceId)) {
         $this->resource = $this->modx->newObject('modResource');
         $this->resource->set('id', 0);
     } else {
         $this->resource = $this->modx->getObject('modResource', $resourceId);
         if (empty($this->resource)) {
             return $this->modx->lexicon('resource_err_nfs', array('id' => $resourceId));
         }
         /* check access */
         if (!$this->resource->checkPolicy('view')) {
             return $this->modx->lexicon('permission_denied');
         }
     }
     return $this->resource;
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:23,代碼來源:getlist.class.php

示例11: process

 public function process()
 {
     if (!$this->validate()) {
         return $this->failure();
     }
     $this->resource->fromArray($this->getProperties());
     if ($this->resource->save() === false) {
         return $this->failure($this->modx->lexicon('resource_err_save'));
     }
     return $this->success();
 }
開發者ID:e-gob,項目名稱:apps.gob.cl,代碼行數:11,代碼來源:updatefromgrid.class.php

示例12: process

 /**
  * @return array|string
  */
 public function process()
 {
     if (!($data = $this->handleFile())) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_ns'));
     }
     $properties = $this->mediaSource->getProperties();
     $tmp = explode('.', $data['name']);
     $extension = strtolower(end($tmp));
     $image_extensions = $allowed_extensions = array();
     if (!empty($properties['imageExtensions']['value'])) {
         $image_extensions = array_map('trim', explode(',', strtolower($properties['imageExtensions']['value'])));
     }
     if (!empty($properties['allowedFileTypes']['value'])) {
         $allowed_extensions = array_map('trim', explode(',', strtolower($properties['allowedFileTypes']['value'])));
     }
     if (!empty($allowed_extensions) && !in_array($extension, $allowed_extensions)) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_ext'));
     } else {
         if (in_array($extension, $image_extensions)) {
             $type = 'image';
         } else {
             $type = $extension;
         }
     }
     $hash = sha1($data['stream']);
     if ($this->modx->getCount('msResourceFile', array('resource_id' => $this->resource->id, 'hash' => $hash, 'parent' => 0))) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_exists'));
     }
     $filename = !empty($properties['imageNameType']) && $properties['imageNameType']['value'] == 'friendly' ? $this->resource->cleanAlias($data['name']) : $hash . '.' . $extension;
     $rank = isset($properties['imageUploadDir']) && empty($properties['imageUploadDir']['value']) ? 0 : $this->modx->getCount('msResourceFile', array('parent' => 0, 'resource_id' => $this->resource->id));
     /* @var msResourceFile $product_file */
     $product_file = $this->modx->newObject('msResourceFile', array('resource_id' => $this->resource->id, 'parent' => 0, 'name' => $data['name'], 'file' => $filename, 'path' => $this->resource->id . '/', 'source' => $this->mediaSource->get('id'), 'type' => $type, 'rank' => $rank, 'createdon' => date('Y-m-d H:i:s'), 'createdby' => $this->modx->user->id, 'active' => 1, 'hash' => $hash, 'properties' => $data['properties']));
     $this->mediaSource->createContainer($product_file->path, '/');
     $file = $this->mediaSource->createObject($product_file->get('path'), $product_file->get('file'), $data['stream']);
     if ($file) {
         $url = $this->mediaSource->getObjectUrl($product_file->get('path') . $product_file->get('file'));
         $product_file->set('url', $url);
         $product_file->save();
         if (empty($rank)) {
             $imagesTable = $this->modx->getTableName('msResourceFile');
             $sql = "UPDATE {$imagesTable} SET rank = rank + 1 WHERE resource_id ='" . $this->resource->id . "' AND id !='" . $product_file->get('id') . "'";
             $this->modx->exec($sql);
         }
         $generate = $product_file->generateThumbnails($this->mediaSource);
         if ($generate !== true) {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not generate thumbnails for image with id = ' . $product_file->get('id') . '. ' . $generate);
             return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_thumb'));
         } else {
             return $this->success();
         }
     } else {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_save') . ': ' . print_r($this->mediaSource->getErrors(), 1));
     }
 }
開發者ID:sin4end,項目名稱:ms2Gallery,代碼行數:57,代碼來源:upload.class.php

示例13: process

 public function process()
 {
     $action = $this->resource->get('deleted') ? 'undelete' : 'delete';
     $return = $this->hm->runProcessor(array('action' => 'resource/' . $action, 'id' => $this->resource->get('id')));
     if ($return['success'] == 1) {
         if ($action == 'undelete') {
             $message = 'Successfully undeleted resource ' . $this->resource->get('pagetitle') . '.';
         } else {
             $message = 'Successfully deleted resource ' . $this->resource->get('pagetitle') . '.';
         }
     } else {
         $message = 'Something went wrong. ' . $return['message'];
     }
     $this->setPlaceholder('message', $message);
 }
開發者ID:rossng,項目名稱:HandyMan,代碼行數:15,代碼來源:delete.class.php

示例14: clearCache

 /**
  * Empty site cache if specified to do so
  * @return void
  */
 public function clearCache()
 {
     $syncSite = $this->getProperty('syncsite', false);
     $clearCache = $this->getProperty('clearCache', false);
     if (!empty($syncSite) || !empty($clearCache)) {
         $this->modx->cacheManager->refresh(array('db' => array(), 'auto_publish' => array('contexts' => array($this->object->get('context_key'))), 'context_settings' => array('contexts' => array($this->object->get('context_key'))), 'resource' => array('contexts' => array($this->object->get('context_key')))));
     }
 }
開發者ID:rosstimson,項目名稱:revolution,代碼行數:12,代碼來源:update.class.php

示例15: loadCollection

 /**
  * {@inheritDoc}
  * @return array
  */
 public static function loadCollection(xPDO &$xpdo, $className, $criteria = null, $cacheFlag = true)
 {
     if (!is_object($criteria)) {
         $criteria = $xpdo->getCriteria($className, $criteria, $cacheFlag);
     }
     $xpdo->addDerivativeCriteria($className, $criteria);
     return parent::loadCollection($xpdo, $className, $criteria, $cacheFlag);
 }
開發者ID:rafull6,項目名稱:texno-service,代碼行數:12,代碼來源:mscategory.class.php


注:本文中的modResource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。