本文整理汇总了PHP中Plugin::Trigger方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::Trigger方法的具体用法?PHP Plugin::Trigger怎么用?PHP Plugin::Trigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::Trigger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveAvatar
/**
* Save an uploaded image to a new location
* @param string $original_file Path to the temporary image
* @param string $original_extension Original file extension of temporary image
* @param string $save_as Filename to save the new image as
* @return void Temporary image is resampled, resized, and saved in its final location
*/
static function SaveAvatar($original_file, $original_extension, $save_as)
{
$avatar_size = 100;
$save_as = UPLOAD_PATH . '/avatars/' . $save_as;
list($width_src, $height_src) = getimagesize($original_file);
// Determine new image dimensions
$ratio = $width_src / $height_src;
// Check for dimension overage
if ($width_src > $height_src && $width_src > $avatar_size) {
$width_dst = $avatar_size;
// Resize width
$height_dst = floor($width_dst / $ratio);
// Resize height based on ratio
} else {
if ($width_src < $height_src && $height_src > $avatar_size) {
$height_dst = $avatar_size;
// Resize height
$width_dst = floor($height_dst * $ratio);
// Resize width based on ratio
} else {
if ($width_src == $height_src && $width_src > $avatar_size) {
$width_dst = $avatar_size;
// Resize width
$height_dst = $avatar_size;
// Resize height
} else {
$width_dst = $width_src;
$height_dst = $height_src;
}
}
}
Plugin::Trigger('avatar.before_save');
// Determin which type of image object to create (and how to process it) based on file extension
if (in_array($original_extension, array('jpg', 'jpeg'))) {
// Create image object from original image
$image = imagecreatefromjpeg($original_file);
// Resize image & Resample (To corrupt any possible injections)
$image_dst = imagecreatetruecolor($width_dst, $height_dst);
imagecopyresampled($image_dst, $image, 0, 0, 0, 0, $width_dst, $height_dst, $width_src, $height_src);
// Save image to HDD as JPG
imagejpeg($image_dst, $save_as, 100);
} else {
// Create image object from original image
if ($original_extension == 'gif') {
// GIFs are converted to PNGs
$image = imagecreatefromgif($original_file);
} else {
$image = imagecreatefrompng($original_file);
}
// Create empty resized image & turn off transparency
$image_dst = imagecreatetruecolor($width_dst, $height_dst);
imagealphablending($image_dst, false);
imagesavealpha($image_dst, true);
// Resize image & Resample (To corrupt any possible injections)
imagecopyresampled($image_dst, $image, 0, 0, 0, 0, $width_dst, $height_dst, $width_src, $height_src);
// Save image to HDD as PNG
imagepng($image_dst, $save_as);
}
Plugin::Trigger('avatar.save');
}
示例2: Paginate
/**
* Output paginated links
* @return mixed Returns the pagination block with links
*/
public function Paginate()
{
Plugin::Trigger('pagination.paginate');
if ($this->total <= $this->records_per_page) {
return '';
}
$links = $this->GetLinks();
$previous = $this->GetPrevious();
$first = $this->GetFirst();
$last = $this->GetLast();
$next = $this->GetNext();
return '<ul id="pagination">' . $previous . $first . $links . $last . $next . '</ul>';
}
示例3: dirname
<?php
// Include required files
include_once dirname(dirname(__FILE__)) . '/cc-core/config/admin.bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
Plugin::Trigger('admin.plugin_settings.start');
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$admin = new User($logged_in);
Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
$enabled_plugins = Plugin::GetEnabledPlugins();
// Validate plugin
if (!empty($_GET['plugin']) && Plugin::ValidPlugin($_GET['plugin'], true)) {
$plugin = trim($_GET['plugin']);
} else {
App::Throw404();
}
// Verify plugin is enabled and has 'Settings'
if (array_search($plugin, $enabled_plugins) !== false && method_exists($plugin, 'Settings')) {
$plugin_info = Plugin::GetPluginInfo($plugin);
$page_title = $plugin_info->name . ' Settings';
} else {
App::Throw404();
}
// Output Page
Plugin::Trigger("admin.{$plugin}.before_render");
include 'header.php';
call_user_func(array($plugin, 'Settings'));
Plugin::Trigger("admin.{$plugin}.settings");
include 'footer.php';
示例4: trim
$string = '/^[a-z0-9][a-z0-9_\\.\\-]+@[a-z0-9][a-z0-9\\.-]+\\.[a-z0-9]{2,4}$/i';
if (!empty($_POST['email']) && !ctype_space($_POST['email']) && preg_match($string, $_POST['email'])) {
View::$vars->email = trim($_POST['email']);
} else {
View::$vars->Errors['email'] = Language::GetText('error_email');
}
// Validate feedback
if (!empty($_POST['feedback']) && !ctype_space($_POST['feedback'])) {
View::$vars->feedback = trim($_POST['feedback']);
} else {
View::$vars->Errors['feedback'] = Language::GetText('error_message');
}
// Send email if no errors
if (empty(View::$vars->Errors)) {
$subject = 'Message received From ' . $config->sitename;
$Msg = "Name: " . View::$vars->name . "\n";
$Msg .= "E-mail: " . View::$vars->email . "\n";
$Msg .= "Message:\n" . View::$vars->feedback;
App::Alert($subject, $Msg);
Plugin::Trigger('contact.send');
View::$vars->message_type = 'success';
View::$vars->message = Language::GetText('success_contact_sent');
} else {
View::$vars->message_type = 'error';
View::$vars->message = Language::GetText('errors_below');
View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->Errors);
}
}
// Output Page
Plugin::Trigger('contact.before_render');
View::Render('contact.tpl');
示例5: Exception
throw new Exception(Language::GetText('error_flag_own'));
}
// Verify Flag doesn't exist
$data = array('type' => $_POST['type'], 'id' => $_POST['id'], 'user_id' => $user->user_id);
if (Flag::Exist($data)) {
throw new Exception(Language::GetText('error_flag_duplicate'));
}
Plugin::Trigger('flag.ajax.before_flag');
// Send admin alert
if (Settings::Get('alerts_flags') == '1') {
$subject = 'Content Flagged As Inappropriate';
$body = "One of your members flagged content as inappropriate. ";
$body .= "Please review the content to verify it is valid. ";
$body .= "You can login to the Admin Panel to dismiss the flag, or uphold it and ban the content.";
$body .= "\n\n=======================================================\n";
$body .= "Content Type: {$type}\n";
$body .= "URL: {$url}\n";
$body .= "{$name}\n";
$body .= "=======================================================";
Plugin::Trigger('flag.ajax.alert');
App::Alert($subject, $body);
}
// Create flag and output message
Flag::Create($data);
Plugin::Trigger('flag.ajax.flag');
echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_flag')));
exit;
} catch (Exception $e) {
echo json_encode(array('result' => 0, 'msg' => $e->getMessage()));
exit;
}
示例6: User
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
$records_per_page = 9;
$url = HOST . '/myaccount/myfavorites';
View::$vars->message = null;
/***********************
Handle Form if submitted
***********************/
if (isset($_GET['vid']) && is_numeric($_GET['vid']) && $_GET['vid'] != 0) {
$data = array('user_id' => View::$vars->user->user_id, 'video_id' => $_GET['vid']);
$id = Favorite::Exist($data);
if ($id) {
Favorite::Delete($id);
View::$vars->message = Language::GetText('success_favorite_removed');
View::$vars->message_type = 'success';
Plugin::Trigger('myfavorites.remove_favorite');
}
}
// Retrieve total count
$query = "SELECT " . DB_PREFIX . "favorites.video_id FROM " . DB_PREFIX . "favorites INNER JOIN " . DB_PREFIX . "videos ON " . DB_PREFIX . "favorites.video_id = " . DB_PREFIX . "videos.video_id WHERE status = 'approved' AND private = '0' AND " . DB_PREFIX . "favorites.user_id = " . View::$vars->user->user_id;
$result_count = $db->Query($query);
$total = $db->Count($result_count);
// Initialize pagination
View::$vars->pagination = new Pagination($url, $total, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
View::$vars->result = $db->Query($query);
// Output page
Plugin::Trigger('myfavorites.before_render');
View::Render('myaccount/myfavorites.tpl');
示例7: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('Video');
// Establish page variables, objects, arrays, etc
View::InitView('mobile_videos');
Plugin::Trigger('mobile_videos.start');
// Retrieve video count
$query = "SELECT COUNT(video_id) FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND gated = '0'";
$result = $db->Query($query);
View::$vars->count = $db->FetchRow($result);
View::$vars->count = View::$vars->count[0];
// Retrieve video list
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND gated = '0' ORDER BY video_id DESC LIMIT 20";
View::$vars->videos = array();
$result = $db->Query($query);
while ($video = $db->FetchObj($result)) {
View::$vars->videos[] = $video->video_id;
}
// Output Page
Plugin::Trigger('mobile_videos.before_render');
View::Render('videos.tpl');
示例8: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('Video');
// Establish page variables, objects, arrays, etc
View::InitView('mobile_play');
Plugin::Trigger('mobile_play.start');
// Verify a video was selected
if (!isset($_GET['vid']) || !is_numeric($_GET['vid'])) {
App::Throw404();
}
// Verify video exists
$data = array('video_id' => $_GET['vid'], 'status' => 'approved', 'private' => '0', 'gated' => '0');
$id = Video::Exist($data);
if (!$id) {
App::Throw404();
}
// Retrieve video
View::$vars->video = $video = new Video($id);
View::$vars->meta->title = $video->title;
// Output Page
Plugin::Trigger('mobile_play.before_render');
View::Render('play.tpl');
示例9: SimpleXMLElement
$namespace .= ' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"';
$xml_root = '<urlset' . $namespace . '></urlset>';
$xml_frame = $xml_header . $xml_root;
$xml = new SimpleXMLElement($xml_frame);
// Add video entries
while ($row = $db->FetchObj($result)) {
$video = new Video($row->video_id);
$url = $xml->addChild('url');
$url->addChild('loc', $video->url . '/');
$block = $url->addChild('video:video', '', 'video');
$block->addChild('content_loc', $config->flv_url . '/' . $video->filename . '.flv');
$block->addChild('thumbnail_loc', $config->thumb_url . '/' . $video->filename . '.jpg');
$block->addChild('title', $video->title);
$block->addChild('description', $video->description);
$block->addChild('rating', Rating::GetFiveScaleRating($row->video_id));
$block->addChild('view_count', $video->views);
$block->addChild('publication_date', Functions::DateFormat('Y-m-d', $video->date_created));
foreach ($video->tags as $_value) {
$block->addChild('tag', $_value);
}
$block->addChild('category', $row->cat_name);
$block->addChild('family_friendly', 'yes');
$block->addChild('duration', Functions::DurationInSeconds($video->duration));
}
} else {
App::Throw404();
}
// Output XML
Plugin::Trigger('video_sitemap.output');
header("Content-type: text/xml");
echo $xml->asXML();
示例10: MATCH
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE MATCH(title, tags, description) AGAINST ('{$search_terms}') AND status = 'approved' AND private = '0' AND video_id != " . View::$vars->video->video_id . " LIMIT 9";
View::$vars->result_related = $db->Query($query);
} else {
// Use LIKE query
$tags = View::$vars->video->tags;
foreach ($tags as $key => $tag) {
$tag = $db->Escape($tag);
$sub_queries[] = "video_id IN (SELECT video_id FROM " . DB_PREFIX . "videos WHERE title LIKE '%{$tag}%' OR description LIKE '%{$tag}%' OR tags LIKE '%{$tag}%')";
}
$sub_queries = implode(' OR ', $sub_queries);
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE ({$sub_queries}) AND status = 'approved' AND private = '0' AND video_id != " . View::$vars->video->video_id . " LIMIT 9";
View::$vars->result_related = $db->Query($query);
}
Plugin::Trigger('play.load_suggestions');
### Retrieve comment count
$query = "SELECT COUNT(comment_id) FROM " . DB_PREFIX . "comments WHERE video_id = " . View::$vars->video->video_id . " AND status = 'approved'";
Plugin::Trigger('play.comment_count');
$result_comment_count = $db->Query($query);
$comment_count = $db->FetchRow($result_comment_count);
View::$vars->comment_count = $comment_count[0];
### Retrieve comments
$query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE video_id = " . View::$vars->video->video_id . " AND status = 'approved' ORDER BY comment_id DESC LIMIT 0, 5";
Plugin::Trigger('play.load_comments');
$result_comments = $db->Query($query);
View::$vars->comment_list = array();
while ($row = $db->FetchObj($result_comments)) {
View::$vars->comment_list[] = $row->comment_id;
}
// Output Page
Plugin::Trigger('play.before_render');
View::Render('play.tpl');
示例11: htmlspecialchars
View::$vars->data['email'] = htmlspecialchars(trim($_POST['email']));
} else {
View::$vars->errors['email'] = Language::GetText('error_email_unavailable');
}
} else {
View::$vars->errors['email'] = Language::GetText('error_email');
}
### Create user if no errors were found
if (empty(View::$vars->errors)) {
View::$vars->data['confirm_code'] = User::CreateToken();
View::$vars->data['status'] = 'new';
View::$vars->data['password'] = md5(View::$vars->data['password']);
Plugin::Trigger('register.before_create');
User::Create(View::$vars->data);
View::$vars->message = Language::GetText('success_registered');
View::$vars->message_type = 'success';
$replacements = array('confirm_code' => View::$vars->data['confirm_code'], 'host' => HOST, 'sitename' => $config->sitename);
$mail = new Mail();
$mail->LoadTemplate('welcome', $replacements);
$mail->Send(View::$vars->data['email']);
Plugin::Trigger('register.create');
unset(View::$vars->data);
} else {
View::$vars->message = Language::GetText('errors_below');
View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
View::$vars->message_type = 'error';
}
}
// Output Page
Plugin::Trigger('register.before_render');
View::Render('register.tpl');
示例12: dirname
<?php
// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
View::InitView('upload_complete');
Plugin::Trigger('upload_complete.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
App::EnableUploadsCheck();
View::$vars->user = new User(View::$vars->logged_in);
### Verify user completed upload process
if (isset($_SESSION['upload'])) {
unset($_SESSION['upload']);
} else {
header('Location: ' . HOST . '/myaccount/upload/video/');
exit;
}
// Output page
Plugin::Trigger('upload_complete.before_render');
View::Render('myaccount/upload_complete.tpl');
示例13: htmlspecialchars
View::$vars->data['private_url'] = htmlspecialchars(trim($_POST['private_url']));
View::$vars->private_url = View::$vars->data['private_url'];
} catch (Exception $e) {
View::$vars->errors['private_url'] = Language::GetText('error_private_url');
}
} else {
View::$vars->data['private'] = '0';
View::$vars->data['private_url'] = '';
View::$vars->private_url = Video::GeneratePrivate();
}
// Update video if no errors were made
if (empty(View::$vars->errors)) {
View::$vars->video->Update(View::$vars->data);
View::$vars->message = Language::GetText('success_video_updated');
if (View::$vars->video->private == '1') {
View::$vars->private_url = View::$vars->video->private_url;
}
View::$vars->message_type = 'success';
Plugin::Trigger('edit_video.edit');
} else {
View::$vars->message = Language::GetText('errors_below');
View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
View::$vars->message_type = 'error';
}
}
### Populate categories dropdown
$query = "SELECT cat_id, cat_name FROM " . DB_PREFIX . "categories";
View::$vars->result_cat = $db->Query($query);
// Output page
Plugin::Trigger('edit_video.before_render');
View::Render('myaccount/edit_video.tpl');
示例14: Video
View::$vars->video_url = View::$vars->video->url;
$url = HOST . '/videos/' . View::$vars->video->video_id . '/comments';
} else {
if (!empty($_GET['private']) && ($video_id = Video::Exist(array('status' => 'approved', 'private_url' => $_GET['private'])))) {
View::$vars->video = new Video($video_id);
View::$vars->private = true;
View::$vars->video_url = HOST . '/private/videos/' . View::$vars->video->private_url;
$url = HOST . '/private/comments/' . View::$vars->video->private_url;
} else {
App::Throw404();
}
}
// Retrieve Video
View::$vars->meta->title = Functions::Replace(View::$vars->meta->title, array('video' => View::$vars->video->title));
// Retrieve comments count
$query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE video_id = " . View::$vars->video->video_id . " ORDER BY comment_id DESC";
$result_count = $db->Query($query);
View::$vars->total_comments = $db->Count($result_count);
// Initialize pagination
View::$vars->pagination = new Pagination($url, View::$vars->total_comments, $records_per_page);
$start_record = View::$vars->pagination->GetStartRecord();
// Retrieve limited results
$query .= " LIMIT {$start_record}, {$records_per_page}";
$result = $db->Query($query);
View::$vars->comment_list = array();
while ($row = $db->FetchObj($result)) {
View::$vars->comment_list[] = $row->comment_id;
}
// Output page
Plugin::Trigger('comments.before_render');
View::Render('comments.tpl');
示例15: User
if (!$logged_in) {
App::Throw404();
}
$user = new User($logged_in);
$data = array();
/***********************
Handle page if submitted
***********************/
if (isset($_POST['submitted'])) {
// Save update if no errors were found
if (!empty($_POST['post']) && !ctype_space($_POST['post'])) {
$data['post'] = htmlspecialchars(trim($_POST['post']));
$data['user_id'] = $user->user_id;
Plugin::Trigger('post.ajax.before_post_update');
$post_id = Post::Create($data);
$post = new Post($post_id);
// Retrieve new formatted status updated
View::InitView();
ob_start();
View::RepeatingBlock('post.tpl', array($post->post_id));
$status_update = ob_get_contents();
ob_end_clean();
Plugin::Trigger('post.ajax.post_update');
echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_status_updated'), 'other' => $status_update));
exit;
} else {
echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_status_update')));
exit;
}
}
// END verify if page was submitted