コード例 #1
0
 public function assetsFolderUrlToBeWritten()
 {
     $url = null;
     //the default rules only require the object to have an ID
     //but more sophisticated rules might require more - e.g. a title to be set
     //thus we check if the object is ready for folder creation - if custom rules
     //(UploadDirRulesInterface) have been set
     if (method_exists($this->owner, 'getReadyForFolderCreation')) {
         if (!$this->owner->getReadyForFolderCreation()) {
             return false;
         }
     }
     //check if the page we're having is implementing the UploadDirRulesInterface
     //for rule customization
     if ($this->owner instanceof UploadDirRulesInterface) {
         $url = $this->owner->getCalcAssetsFolderDirectory();
     } else {
         //else use the default settings
         $class = UploadDirRules::get_rules_class();
         $url = $class::calc_full_directory_for_object($this->owner);
     }
     return $url;
 }
 /**
  * Creation and association of assets folder,
  * once a data object has been created (and is ready for it)
  */
 function onAfterWrite()
 {
     parent::onAfterWrite();
     //creation will only be considered if the object has no folder relation
     if ($this->owner->AssetsFolderID == 0) {
         //the default rules only require the object to have an ID
         //but more sophisticated rules might require more - e.g. a title to be set
         //thus we check if the object is ready for folder creation - if custom rules
         //(UploadDirRulesInterface) have been set
         if ($this->owner instanceof UploadDirRulesInterface) {
             if (!$this->owner->getReadyForFolderCreation()) {
                 return false;
             }
         }
         $url = null;
         //check if the page we're having is implementing the UploadDirRulesInterface
         //for rule customization
         if ($this->owner instanceof UploadDirRulesInterface) {
             $url = $this->owner->getCalcAssetsFolderDirectory();
         } else {
             //else use the default settings
             $class = UploadDirRules::get_rules_class();
             $url = $class::calc_full_directory_for_object($this->owner);
         }
         if ($url) {
             //this creates the directory, and attaches it to the page,
             //as well as saving the object one more time - with the attached folder
             $this->findOrMakeAssetsFolder($url, true);
         }
     }
 }