Ejemplo n.º 1
0
 public function indexAction()
 {
     $params = ['user_id' => 1];
     $treeModel = new TreeModel();
     $treeList = $treeModel->GetTreeList($params);
     $userModel = new UserModel();
     $user_setting = $userModel->GetUserSetting($params);
     //data handle
     foreach ($treeList as $key => $val) {
         $treeList[$key]['added_time'] = date('Y年m月d日 H:i:s', $val['added_time']);
     }
     $this->getView()->assign("timeline", $treeList);
     $this->getView()->assign("title", Lang::goLang('TITLE'));
     $this->getView()->assign("intro", $user_setting['intro']);
 }
Ejemplo n.º 2
0
 /**
  * Retorna se o model e filho do informado via parametro.
  *
  * @param TreeModel $parent
  *
  * @return bool
  */
 public function isChild(TreeModel $parent)
 {
     return $this->left > $parent->getLeft() && $this->right < $parent->getRight();
 }
Ejemplo n.º 3
0
 public function Save($PostValues, $PreviousValues = False)
 {
     ReplaceEmpty($PostValues, Null);
     $RowID = GetValue($this->PrimaryKey, $PostValues);
     $Insert = $RowID === False;
     $URI = GetValue('URI', $PostValues, Null);
     if ($URI !== Null) {
         $this->Validation->ApplyRule('URI', 'UrlPath');
     }
     if ($Insert && !$this->CheckUniqueURI($URI)) {
         $this->Validation->AddValidationResult('URI', '%s: Already exists.');
     }
     if (GetValue('ParentID', $PostValues) === Null) {
         SetValue('ParentID', $PostValues, 1);
     }
     if (array_key_exists('Mask', $PostValues)) {
         $PostValues['Mask'] = self::CalculateMask($PostValues['Mask']);
     }
     $this->DefineSchema();
     $this->AddUpdateFields($PostValues);
     if ($Insert) {
         $this->AddInsertFields($PostValues);
     }
     if ($this->Validate($PostValues, $Insert) === True) {
         $Fields = $this->Validation->SchemaValidationFields();
         if ($Insert) {
             $ParentID = GetValue('ParentID', $PostValues);
             $RowID = parent::InsertNode($ParentID, $Fields);
             if (!$RowID) {
                 $this->Validation->AddValidationResult('RowID', '%s: InsertNode operation failed.');
             }
         } else {
             $this->Update($Fields, array('SectionID' => $RowID));
         }
         if (count($this->Validation->Results()) == 0) {
             CandyModel::SaveRoute($PostValues);
         }
     } else {
         $RowID = False;
     }
     return $RowID;
 }