Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce2b2ba
commit 34334d9
Showing
52 changed files
with
4,396 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
unset($_SESSION["user_id"]); | ||
session_destroy(); | ||
|
||
Core::redir("./"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
if(isset($_GET["opt"])){ | ||
if($_GET["opt"]=="add"){ | ||
$cat = new WidgetData(); | ||
$cat->title = $_POST["title"]; | ||
$cat->func = $_POST["func"]; | ||
$cat->params = $_POST["params"]; | ||
$cat->ord = $_POST["ord"]; | ||
$cat->add(); | ||
Core::redir("./?view=widgets"); | ||
} | ||
else if($_GET["opt"]=="update"){ | ||
$cat = WidgetData::getById($_POST["id"]); | ||
$cat->title = $_POST["title"]; | ||
$cat->func = $_POST["func"]; | ||
$cat->params = $_POST["params"]; | ||
$cat->status = $_POST["status"]; | ||
$cat->ord = $_POST["ord"]; | ||
$cat->update(); | ||
Core::redir("./?view=widgets"); | ||
} | ||
else if($_GET["opt"]=="del"){ | ||
$cat = WidgetData::getById($_GET["id"]); | ||
$cat->del(); | ||
Core::redir("./?view=widgets"); | ||
} | ||
} | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
class WidgetData { | ||
public static $tablename = "widget"; | ||
|
||
|
||
public function WidgetData(){ | ||
$this->title = ""; | ||
$this->content = ""; | ||
$this->image = ""; | ||
$this->user_id = ""; | ||
$this->is_public = "0"; | ||
$this->created_at = "NOW()"; | ||
} | ||
|
||
public function add(){ | ||
$sql = "insert into ".self::$tablename." (title,func,params,ord) "; | ||
$sql .= "value (\"$this->title\",\"$this->func\",\"$this->params\",$this->ord)"; | ||
Executor::doit($sql); | ||
} | ||
|
||
public static function delById($id){ | ||
$sql = "delete from ".self::$tablename." where id=$id"; | ||
Executor::doit($sql); | ||
} | ||
public function del(){ | ||
$sql = "delete from ".self::$tablename." where id=$this->id"; | ||
Executor::doit($sql); | ||
} | ||
|
||
// partiendo de que ya tenemos creado un objecto WidgetData previamente utilizamos el contexto | ||
public function update(){ | ||
$sql = "update ".self::$tablename." set title=\"$this->title\",func=\"$this->func\",params=\"$this->params\",status=\"$this->status\",ord=\"$this->ord\" where id=$this->id"; | ||
Executor::doit($sql); | ||
} | ||
|
||
public static function getById($id){ | ||
$sql = "select * from ".self::$tablename." where id=$id"; | ||
$query = Executor::doit($sql); | ||
return Model::one($query[0],new WidgetData()); | ||
} | ||
|
||
|
||
|
||
public static function getAll(){ | ||
$sql = "select * from ".self::$tablename; | ||
$query = Executor::doit($sql); | ||
return Model::many($query[0],new WidgetData()); | ||
} | ||
|
||
public static function getPublics(){ | ||
$sql = "select * from ".self::$tablename." where status=1 order by ord"; | ||
$query = Executor::doit($sql); | ||
return Model::many($query[0],new WidgetData()); | ||
} | ||
|
||
public static function getLike($q){ | ||
$sql = "select * from ".self::$tablename." where title like '%$q%' or content like '%$q%'"; | ||
$query = Executor::doit($sql); | ||
return Model::many($query[0],new WidgetData()); | ||
} | ||
|
||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.