Browse Source

Is404 template method, make some fields private

Vova Tkach 6 years ago
parent
commit
b12d6c5be8
5 changed files with 50 additions and 46 deletions
  1. 17 17
      engine/fetdata/content.go
  2. 14 10
      engine/fetdata/fetdata.go
  3. 3 3
      engine/fetdata/http.go
  4. 12 12
      engine/fetdata/meta_data.go
  5. 4 4
      engine/fetdata/user.go

+ 17 - 17
engine/fetdata/content.go

@@ -8,11 +8,11 @@ import (
 )
 
 func (this *FERData) Name() string {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return this.DataRow.(*utils.MySql_page).A_name
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return this.dataRow.(*utils.MySql_page).A_name
 		}
-	} else if this.Is404 {
+	} else if this.is404 {
 		// Return it from settings
 		return "404"
 	}
@@ -20,20 +20,20 @@ func (this *FERData) Name() string {
 }
 
 func (this *FERData) Alias() string {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return this.DataRow.(*utils.MySql_page).A_alias
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return this.dataRow.(*utils.MySql_page).A_alias
 		}
 	}
 	return ""
 }
 
 func (this *FERData) Content() template.HTML {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return template.HTML(this.DataRow.(*utils.MySql_page).A_content)
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return template.HTML(this.dataRow.(*utils.MySql_page).A_content)
 		}
-	} else if this.Is404 {
+	} else if this.is404 {
 		// Return it from settings
 		return template.HTML("The page what you looking for is not found")
 	}
@@ -41,18 +41,18 @@ func (this *FERData) Content() template.HTML {
 }
 
 func (this *FERData) DateTime() int {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return this.DataRow.(*utils.MySql_page).A_datetime
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return this.dataRow.(*utils.MySql_page).A_datetime
 		}
 	}
 	return 0
 }
 
 func (this *FERData) DateTimeFormat(format string) string {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return time.Unix(int64(this.DataRow.(*utils.MySql_page).A_datetime), 0).Format(format)
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return time.Unix(int64(this.dataRow.(*utils.MySql_page).A_datetime), 0).Format(format)
 		}
 	}
 	return ""

+ 14 - 10
engine/fetdata/fetdata.go

@@ -6,29 +6,33 @@ import (
 )
 
 type FERData struct {
-	Wrap    *wrapper.Wrapper
-	DataRow interface{}
-	Is404   bool
+	wrap    *wrapper.Wrapper
+	dataRow interface{}
+	is404   bool
 
 	bufferUser *utils.MySql_user
 }
 
 func New(wrap *wrapper.Wrapper, drow interface{}, is404 bool) *FERData {
 	fer := &FERData{
-		Wrap:    wrap,
-		DataRow: drow,
-		Is404:   is404,
+		wrap:    wrap,
+		dataRow: drow,
+		is404:   is404,
 	}
 	return fer.init()
 }
 
 func (this *FERData) init() *FERData {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			if this.DataRow.(*utils.MySql_page).A_meta_title == "" {
-				this.DataRow.(*utils.MySql_page).A_meta_title = this.DataRow.(*utils.MySql_page).A_name
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			if this.dataRow.(*utils.MySql_page).A_meta_title == "" {
+				this.dataRow.(*utils.MySql_page).A_meta_title = this.dataRow.(*utils.MySql_page).A_name
 			}
 		}
 	}
 	return this
 }
+
+func (this *FERData) Is404() bool {
+	return this.is404
+}

+ 3 - 3
engine/fetdata/http.go

@@ -5,13 +5,13 @@ import (
 )
 
 func (this *FERData) RequestURI() string {
-	return this.Wrap.R.RequestURI
+	return this.wrap.R.RequestURI
 }
 
 func (this *FERData) RequestURL() string {
-	return this.Wrap.R.URL.Path
+	return this.wrap.R.URL.Path
 }
 
 func (this *FERData) RequestGET() string {
-	return utils.ExtractGetParams(this.Wrap.R.RequestURI)
+	return utils.ExtractGetParams(this.wrap.R.RequestURI)
 }

+ 12 - 12
engine/fetdata/meta_data.go

@@ -5,11 +5,11 @@ import (
 )
 
 func (this *FERData) MetaTitle() string {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return this.DataRow.(*utils.MySql_page).A_meta_title
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return this.dataRow.(*utils.MySql_page).A_meta_title
 		}
-	} else if this.Is404 {
+	} else if this.is404 {
 		// Return it from settings
 		return "Page not found"
 	}
@@ -17,11 +17,11 @@ func (this *FERData) MetaTitle() string {
 }
 
 func (this *FERData) MetaKeywords() string {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return this.DataRow.(*utils.MySql_page).A_meta_keywords
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return this.dataRow.(*utils.MySql_page).A_meta_keywords
 		}
-	} else if this.Is404 {
+	} else if this.is404 {
 		// Return it from settings
 		return ""
 	}
@@ -29,11 +29,11 @@ func (this *FERData) MetaKeywords() string {
 }
 
 func (this *FERData) MetaDescription() string {
-	if this.DataRow != nil {
-		if this.Wrap.CurrModule == "index" {
-			return this.DataRow.(*utils.MySql_page).A_meta_description
+	if this.dataRow != nil {
+		if this.wrap.CurrModule == "index" {
+			return this.dataRow.(*utils.MySql_page).A_meta_description
 		}
-	} else if this.Is404 {
+	} else if this.is404 {
 		// Return it from settings
 		return ""
 	}

+ 4 - 4
engine/fetdata/user.go

@@ -7,8 +7,8 @@ import (
 func (this *FERData) userToBuffer() {
 	if this.bufferUser == nil {
 		user := utils.MySql_user{}
-		if this.Wrap.S.GetInt("UserId", 0) > 0 {
-			err := this.Wrap.DB.QueryRow(`
+		if this.wrap.S.GetInt("UserId", 0) > 0 {
+			err := this.wrap.DB.QueryRow(`
 				SELECT
 					id,
 					first_name,
@@ -21,7 +21,7 @@ func (this *FERData) userToBuffer() {
 				WHERE
 					id = ?
 				LIMIT 1;`,
-				this.Wrap.S.GetInt("UserId", 0),
+				this.wrap.S.GetInt("UserId", 0),
 			).Scan(
 				&user.A_id,
 				&user.A_first_name,
@@ -31,7 +31,7 @@ func (this *FERData) userToBuffer() {
 				&user.A_active,
 			)
 			if err != nil {
-				this.Wrap.LogError(err.Error())
+				this.wrap.LogError(err.Error())
 			}
 		}
 		this.bufferUser = &user