本文整理汇总了PHP中helpers\Hooks::addHook方法的典型用法代码示例。如果您正苦于以下问题:PHP Hooks::addHook方法的具体用法?PHP Hooks::addHook怎么用?PHP Hooks::addHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers\Hooks
的用法示例。
在下文中一共展示了Hooks::addHook方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
Hooks::addHook('js', 'Controllers\\auth@js');
Hooks::addHook('css', 'Controllers\\auth@css');
$error = 'hi';
$success = 'hi';
if (Session::get('loggedin')) {
Url::redirect();
}
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
//validation
if (Password::verify($password, $this->_model->getHash($username)) == false) {
$error[] = 'Wrong username or password';
}
//if validation has passed carry on
if (!$error) {
Session::set('loggedin', true);
Session::set('username', $username);
Session::set('memberID', $this->_model->getID($username));
$data = array('lastLogin' => date('Y-m-d G:i:s'));
$where = array('memberID' => $this->_model->getID($username));
$this->_model->update($data, $where);
$error = 'hi';
Url::redirect();
}
}
$data['title'] = 'Login';
View::rendertemplate('header', $data);
View::render('auth/login', $data, $error, $success);
View::rendertemplate('footer', $data);
}
示例2: index
public function index()
{
if (!Session::get('loggedin')) {
Url::redirect('login');
}
if (isset($_POST['submit']) && $_FILES['fileToUpload']['size'] > 0) {
$name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
$price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']);
$description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription'];
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if (isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if ($check !== false) {
//echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
//echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
$error = "Sorry, file already exists." . $error;
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
$error = "Sorry, your file is too large." . $error;
$uploadOk = 0;
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
$error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
$error = "Sorry, your file was not uploaded." . $error;
// if everything is ok, try to upload file
} else {
//if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], str_replace(' ','-',strtolower($target_file)))) {
//echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
$product['product'] = array('name' => $name, 'price' => $price, 'description' => $description, 'lastUpdate' => date('Y-m-d G:i:s'));
$product['image'] = array('image' => file_get_contents($_FILES['fileToUpload']['tmp_name']), 'size' => $_FILES["fileToUpload"]["size"], 'type' => $imageFileType);
$this->_model->insertProduct($product);
//unlink(str_replace(' ','-',strtolower($target_file)));
}
}
Hooks::addHook('js', 'Controllers\\menu@indexJS');
Hooks::addHook('css', 'Controllers\\menu@indexCss');
$data['title'] = 'index';
$data['username'] = Session::get('username');
View::rendertemplate('header', $data);
View::render('menu/index', $data, $error);
View::rendertemplate('footer', $data);
}
示例3: GetUser
public function GetUser($id_contato, $messages = [])
{
$data['name'] = $this->contatos->getOneName($id_contato);
$data['mail'] = $this->contatos->getOneMail($id_contato);
$data['mail_type'] = $this->contatos->getMailType();
$data['phone'] = $this->contatos->getOnePhone($id_contato);
$data['phone_type'] = $this->contatos->getPhoneType();
$data['messages'] = $messages;
Hooks::addHook('js', '\\Controllers\\PainelContatoUsuario@scripts');
// var_dump($data['mail_type']);
// var_dump('aaa');
// die();
View::renderTemplate('header', $data);
View::render('painel_contato_usuario/edit_contato_usuario', $data);
View::renderTemplate('footer', $data);
}
示例4: login
public function login()
{
Hooks::addHook('js', 'Controllers\\auth@js');
Hooks::addHook('css', 'Controllers\\auth@css');
// if(Session::get('loggedin')){
// Url::redirect();
// }
$currentUser = ParseUser::getCurrentUser();
if ($currentUser) {
// do stuff with the user
Url::redirect();
} else {
// show the signup or login page
}
//==============Sign Up Manually==========================
// $user = new ParseUser();
// $user->set("username", "yoak");
// $user->set("password", "yoakyoak");
// $user->set("email", "pacosarin@gmail.com");
// // other fields can be set just like with ParseObject
// $user->set("phone", "0909814465");
// try {
// $user->signUp();
// // Hooray! Let them use the app now.
// $error = 'Hooray! Let them use the app now.';
// } catch (ParseException $ex) {
// // Show the error message somewhere and let the user try again.
// echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
// }
//==============Sign Up Manually==========================
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
try {
$user = ParseUser::logIn($username, $password);
Url::redirect();
// Do stuff after successful login.
} catch (ParseException $ex) {
// The login failed. Check error to see why.
$error = "ParseException: " . $ex->getCode() . " " . $ex->getMessage();
}
}
$data['title'] = 'Login';
View::rendertemplate('header', $data);
View::render('auth/login', $data, $error);
View::rendertemplate('footer', $data);
}
示例5:
<?php
use Helpers\Hooks;
Hooks::addHook('routes', 'Modules\\Blog\\Controllers\\Blog@routes');
示例6:
<?php
use Helpers\Hooks;
Hooks::addHook('sidebar', 'Modules\\Members\\Controllers\\Members@index');
Hooks::addHook('routes', 'Modules\\Members\\Controllers\\Members@routes');
示例7:
<?php
use Helpers\Hooks;
Hooks::addHook('sidebar', 'Modules\\Members\\Controllers\\Members@index');
Hooks::addHook('routes', 'Modules\\Members\\Controllers\\Members@routes');
Hooks::addHook('navbar', 'Modules\\Members\\Controllers\\Members@navbar');
示例8: order
//.........这里部分代码省略.........
} else {
$query = new ParseQuery('Order');
$query->equalTo('objectId', $objectId);
$order = $query->first();
$order->set('productId', $productId);
$order->set('productName', $productName);
$order->set('customerName', $customerName);
$order->set('customerId', $customerId);
$order->setAssociativeArray('contact', $contact);
$order->set('transportDate', $transportDate);
$order->set('address', $address);
$order->set('transportStatus', $transportStatus);
$order->set('transferStatus', $transferStatus);
$order->set('trackingNumber', $trackingNumber);
$order->save();
}
} else {
if (isset($_POST['submit'])) {
$productId = !isset($_POST['productId']) || trim($_POST['productId']) == '' ? '' : $_POST['productId'];
$productName = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
$customerId = !isset($_POST['customerId']) || trim($_POST['customerId']) == '' ? '' : $_POST['customerId'];
$customerName = !isset($_POST['customerName']) || trim($_POST['customerName']) == '' ? '' : $_POST['customerName'];
$lineId = !isset($_POST['lineId']) || trim($_POST['lineId']) == '' ? '' : $_POST['lineId'];
$facebook = !isset($_POST['facebook']) || trim($_POST['facebook']) == '' ? '' : $_POST['facebook'];
$telephone = !isset($_POST['telephone']) || trim($_POST['telephone']) == '' ? '' : $_POST['telephone'];
$transportDate = !isset($_POST['transportDate']) || trim($_POST['transportDate']) == '' ? null : DateTime::createFromFormat('d/m/Y', $_POST['transportDate']);
$transportStatus = !isset($_POST['transportStatus']) || trim($_POST['transportStatus']) == '' ? '' : $_POST['transportStatus'];
$transferStatus = !isset($_POST['transferStatus']) || trim($_POST['transferStatus']) == '' ? '' : $_POST['transferStatus'];
$trackingNumber = !isset($_POST['trackingNumber']) || trim($_POST['trackingNumber']) == '' ? '' : $_POST['trackingNumber'];
$contact = ['telephone' => $telephone, 'lineId' => $lineId, 'facebook' => $facebook];
if ($_FILES['fileToUpload']['size'] > 0) {
$target_file = basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if ($check !== false) {
//echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
//echo "File is not an image.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
$error = "Sorry, your file is too large." . $error;
$uploadOk = 0;
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
$error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
$error = "Sorry, your file was not uploaded." . $error;
// if everything is ok, try to upload file
} else {
$imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
$order = new ParseObject('Order');
$order->set('productId', $productId);
$order->set('productName', $productName);
$order->set('customerName', $customerName);
$order->set('customerId', $customerId);
$order->setAssociativeArray('contact', $contact);
$order->set('slipPayin', $imageFile);
$order->set('transportDate', $transportDate);
$order->set('address', $address);
$order->set('transportStatus', $transportStatus);
$order->set('transferStatus', $transferStatus);
$order->set('trackingNumber', $trackingNumber);
$order->save();
}
} else {
$order = new ParseObject('Order');
$order->set('productId', $productId);
$order->set('productName', $productName);
$order->set('customerName', $customerName);
$order->set('customerId', $customerId);
$order->setAssociativeArray('contact', $contact);
$order->set('transportDate', $transportDate);
$order->set('address', $address);
$order->set('transportStatus', $transportStatus);
$order->set('transferStatus', $transferStatus);
$order->set('trackingNumber', $trackingNumber);
$order->save();
}
Url::redirect('order');
}
$sidemenu = new ParseQuery('SideMenu');
$result = $sidemenu->find();
Hooks::addHook('js', 'Controllers\\inventory\\Order@JS');
Hooks::addHook('css', 'Controllers\\inventory\\Order@CSS');
$data['title'] = 'รายการสั่งซื้อสินค้า';
$data['username'] = $currentUser->get('username');
$data['sidemenu'] = $result;
View::rendertemplate('header', $data);
View::render('inventory/order', $data, $error);
View::rendertemplate('footer', $data);
}
}
示例9:
<?php
use Helpers\Hooks;
//use Modules\Search\Controllers\Config as config;
Hooks::addHook('routes', 'Modules\\Search\\Controllers\\Main@routes');
示例10: product
//.........这里部分代码省略.........
$uploadOk = 1;
} else {
//echo "File is not an image.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
$error = "Sorry, your file is too large." . $error;
$uploadOk = 0;
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
$error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
$error = "Sorry, your file was not uploaded." . $error;
// if everything is ok, try to upload file
} else {
$imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
$query = new ParseQuery('Product');
$query->equalTo('objectId', $objectId);
$product = $query->first();
$product->set('name', $_POST['productName']);
$product->set('price', $price);
$product->set('description', $description);
$product->set('picture', $imageFile);
$product->save();
}
} else {
$query = new ParseQuery('Product');
$query->equalTo('objectId', $objectId);
$product = $query->first();
$product->set('name', $name);
$product->set('price', $price);
$product->set('description', $description);
$product->save();
}
} else {
if (isset($_POST['submit'])) {
$name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName'];
$price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']);
$description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription'];
if ($_FILES['fileToUpload']['size'] > 0) {
$target_file = basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if ($check !== false) {
//echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
//echo "File is not an image.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
$error = "Sorry, your file is too large." . $error;
$uploadOk = 0;
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
$error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error;
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
$error = "Sorry, your file was not uploaded." . $error;
// if everything is ok, try to upload file
} else {
$imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file);
$product = new ParseObject('Product');
$product->set('name', $name);
$product->set('price', $price);
$product->set('description', $description);
$product->set('picture', $imageFile);
$product->save();
}
} else {
$product = new ParseObject('Product');
$product->set('name', $name);
$product->set('price', $price);
$product->set('description', $description);
$product->save();
}
Url::redirect('product');
}
$sidemenu = new ParseQuery('SideMenu');
$result = $sidemenu->find();
Hooks::addHook('js', 'Controllers\\inventory\\Product@JS');
Hooks::addHook('css', 'Controllers\\inventory\\Product@CSS');
$data['title'] = 'สินค้า';
$data['username'] = $currentUser->get('username');
$data['sidemenu'] = $result;
View::rendertemplate('header', $data);
View::render('inventory/product', $data, $error);
View::rendertemplate('footer', $data);
}
}