示例#1
0
 public function Save($PostValues, $PreviousValues = False)
 {
     ReplaceEmpty($PostValues, Null);
     $URI = GetValue('URI', $PostValues, Null);
     $bCreateSection = GetValue('CreateSection', $PostValues);
     $RowID = GetValue('PageID', $PostValues);
     $Insert = $RowID === False;
     if ($bCreateSection) {
         $SectionModel = Gdn::Factory('SectionModel');
         $this->Validation->ApplyRule('URI', 'UrlPath');
         $this->Validation->ApplyRule('SectionID', 'Required');
         if ($Insert && $URI && CandyModel::GetRoute($URI)) {
             $this->Validation->AddValidationResult('URI', '%s: Already exists.');
         }
     }
     $this->EventArguments['PostValues'] =& $PostValues;
     $this->FireEvent('BeforeSave');
     $RowID = parent::Save($PostValues);
     if ($RowID) {
         if ($URI) {
             CandyModel::SaveRoute($URI, 'candy/content/page/' . $RowID);
         }
         if ($bCreateSection) {
             $this->CreateSection($RowID, $PostValues);
         }
     }
     return $RowID;
 }
示例#2
0
 public static function GetRequestUri($Code)
 {
     $Result = CandyModel::GetRoute($Code);
     if (!$Result) {
         return False;
     }
     return $Result->RequestUri;
 }