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


PHP Gdn_Model::validationResults方法代码示例

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


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

示例1: save


//.........这里部分代码省略.........
         } else {
             $Addon = $Stub;
             if (isset($Path)) {
                 $Addon['MD5'] = md5_file($Path);
                 $Addon['FileSize'] = filesize($Path);
             }
         }
     }
     // Get an existing addon.
     if (isset($Addon['AddonID'])) {
         $CurrentAddon = $this->getID($Addon['AddonID'], false, ['GetVersions' => true]);
     } elseif (isset($Addon['AddonKey']) && isset($Addon['AddonTypeID'])) {
         $CurrentAddon = $this->getID(array($Addon['AddonKey'], $Addon['AddonTypeID']), false, ['GetVersions' => true]);
     } else {
         $CurrentAddon = false;
     }
     trace($CurrentAddon, 'CurrentAddon');
     $Insert = !$CurrentAddon;
     if ($Insert) {
         $this->addInsertFields($Addon);
     }
     $this->addUpdateFields($Addon);
     // always add update fields
     if (!$this->validate($Addon, $Insert)) {
         trace('Addon did not validate');
         return false;
     }
     // Search for the current version.
     $MaxVersion = false;
     $CurrentVersion = false;
     if ($CurrentAddon && isset($Addon['Version'])) {
         // Search for a current version.
         foreach ($CurrentAddon['Versions'] as $Index => $Version) {
             if (isset($Addon['AddonVersionID'])) {
                 if ($Addon['AddonVersionID'] == $Version['AddonVersionID']) {
                     $CurrentVersion = $Version;
                 }
             } elseif (version_compare($Addon['Version'], $Version['Version']) == 0) {
                 $CurrentVersion = $Version;
             }
             // Only check for a current version if the version has been checked.
             if (!$Version['Checked']) {
                 continue;
             }
             if (!$MaxVersion || version_compare($MaxVersion['Version'], $Version['Version'], '<')) {
                 $MaxVersion = $Version;
             }
         }
     }
     // Save the addon.
     $Fields = $this->filterSchema($Addon);
     if ($Insert) {
         $AddonID = $this->SQL->insert($this->Name, $Fields);
         // Add the activity.
         $ActivityModel = new ActivityModel();
         $Activity = array('ActivityType' => 'Addon', 'ActivityUserID' => $Fields['InsertUserID'], 'NotifyUserID' => ActivityModel::NOTIFY_PUBLIC, 'HeadlineFormat' => '{ActivityUserID,user} added the <a href="{Url,html}">{Data.Name}</a> addon.', 'Story' => Gdn_Format::html($Fields['Description']), 'Route' => '/addon/' . rawurlencode(self::slug($Fields, false)), 'Data' => array('Name' => $Fields['Name']));
         $ActivityModel->save($Activity);
     } else {
         $AddonID = val('AddonID', $CurrentAddon);
         // Only save the addon if it is the current version.
         if (!$MaxVersion || version_compare($Addon['Version'], $MaxVersion['Version'], '>=')) {
             trace('Uploaded version is the most recent version.');
             $this->SQL->put($this->Name, $Fields, array('AddonID' => $AddonID));
         } else {
             $this->SQL->reset();
         }
     }
     // Save the version.
     if ($AddonID && isset($Path) || isset($Addon['File'])) {
         trace('Saving addon version');
         $Addon['AddonID'] = $AddonID;
         if (isset($Path)) {
             if (!stringBeginsWith($Path, PATH_UPLOADS . '/addons/')) {
                 // The addon must be copied into the uploads folder.
                 $NewPath = PATH_UPLOADS . '/addons/' . basename($Path);
                 //rename($Path, $NewPath);
                 $Path = $NewPath;
                 $this->_AddonCache = array();
             }
             $File = substr($Path, strlen(PATH_UPLOADS . '/'));
             $Addon['File'] = $File;
         }
         if ($CurrentVersion) {
             $Addon['AddonVersionID'] = val('AddonVersionID', $CurrentVersion);
         }
         // Insert or update the version.
         $VersionModel = new Gdn_Model('AddonVersion');
         $AddonVersionID = $VersionModel->save($Addon);
         $this->Validation->addValidationResult($VersionModel->validationResults());
         if (!$AddonVersionID) {
             return false;
         }
         // Update the current version in the addon.
         if (!$MaxVersion || version_compare($CurrentAddon['Version'], $Addon['Version'], '<')) {
             $this->SQL->put($this->Name, array('CurrentAddonVersionID' => $AddonVersionID), array('AddonID' => $AddonID));
         }
     }
     $this->_AddonCache = array();
     return $AddonID;
 }
开发者ID:vanilla,项目名称:community,代码行数:101,代码来源:class.addonmodel.php


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