本文整理汇总了PHP中Tags::Format方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::Format方法的具体用法?PHP Tags::Format怎么用?PHP Tags::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::Format方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tbxUploadStepOne
function tbxUploadStepOne()
{
global $t;
$v = Validator::Create();
$_REQUEST['tags'] = Tags::Format($_REQUEST['tags']);
$v->Register($_REQUEST['title'], Validator_Type::LENGTH_BETWEEN, _T('Validation:Invalid Length', _T('Label:Title'), Config::Get('title_min_length'), Config::Get('title_max_length')), Config::Get('title_min_length') . ',' . Config::Get('title_max_length'));
$v->Register($_REQUEST['description'], Validator_Type::LENGTH_BETWEEN, _T('Validation:Invalid Length', _T('Label:Description'), Config::Get('description_min_length'), Config::Get('description_max_length')), Config::Get('description_min_length') . ',' . Config::Get('description_max_length'));
$v->Register(Tags::Count($_REQUEST['tags']), Validator_Type::IS_BETWEEN, _T('Validation:Invalid Num Tags', Config::Get('tags_min'), Config::Get('tags_max')), Config::Get('tags_min') . ',' . Config::Get('tags_max'));
// Register user-defined field validators
$schema = GetDBSchema();
$v->RegisterFromXml($schema->el('//table[name="tbx_video_custom"]'), 'user', 'create');
// Check blacklist
$_REQUEST['ip_address'] = $_SERVER['REMOTE_ADDR'];
if (($match = Blacklist::Match($_REQUEST, Blacklist::ITEM_VIDEO)) !== false) {
$v->SetError(_T('Validation:Blacklisted', $match['match']));
}
// Validate CAPTCHA
if (Config::Get('flag_captcha_on_upload')) {
Captcha::Verify();
}
if (!$v->Validate()) {
$t->Assign('g_errors', $v->GetErrors());
$t->AssignByRef('g_form', $_REQUEST);
return tbxDisplayUpload();
}
$_REQUEST['step_one_data'] = base64_encode(serialize($_REQUEST));
$_REQUEST['step_one_sig'] = sha1($_REQUEST['step_one_data'] . Config::Get('random_value'));
$t->Assign('g_file_types', '*.' . str_replace(',', ';*.', Config::Get('upload_extensions')));
$t->Assign('g_cookie', $_COOKIE[LOGIN_COOKIE]);
$t->AssignByRef('g_form', $_REQUEST);
$t->Display('upload-step-two.tpl');
}
示例2: Import
public function Import()
{
$imported = 0;
$DB = GetDB();
$yt = new Zend_Gdata_YouTube();
$video_feed = $yt->getVideoFeed($this->feed['feed_url']);
$entry;
foreach ($video_feed as $entry) {
// Check for duplicates, and skip
if ($DB->QueryCount('SELECT COUNT(*) FROM `tbx_video_feed_history` WHERE `feed_id`=? AND `unique_id`=?', array($this->feed['feed_id'], $entry->getVideoId()))) {
continue;
}
// Video is not embeddable, skip
if (!$entry->isVideoEmbeddable()) {
continue;
}
// Setup defaults
$video = $this->defaults;
$video['title'] = $entry->getVideoTitle();
$video['description'] = $entry->getVideoDescription();
$video['tags'] = Tags::Format(implode(' ', $entry->getVideoTags()));
$video['duration'] = $entry->getVideoDuration();
// Get preview images
$times = array();
$thumbs = array();
foreach ($entry->getVideoThumbnails() as $thumb) {
if (!isset($times[$thumb['time']])) {
$times[$thumb['time']] = true;
$thumbs[] = array('thumbnail' => $thumb['url']);
}
}
$clip = array('type' => 'Embed', 'clip' => '<object width="640" height="385">' . '<param name="movie" value="http://www.youtube.com/v/' . $entry->getVideoId() . '&fs=1"></param>' . '<param name="allowFullScreen" value="true"></param>' . '<param name="allowscriptaccess" value="always"></param>' . '<embed src="http://www.youtube.com/v/' . $entry->getVideoId() . '&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="640" height="385"></embed>' . '</object>');
$best_category = GetBestCategory(join(' ', array($video['title'], $video['description'], $video['tags'])));
if (!empty($best_category)) {
$video['category_id'] = $best_category;
}
$video['video_id'] = DatabaseAdd('tbx_video', $video);
DatabaseAdd('tbx_video_custom', $video);
DatabaseAdd('tbx_video_stat', $video);
if (!$video['is_private']) {
Tags::AddToFrequency($video['tags']);
}
UpdateCategoryStats($video['category_id']);
$video_dir = new Video_Dir(Video_Dir::DirNameFromId($video['video_id']));
$clip['video_id'] = $video['video_id'];
DatabaseAdd('tbx_video_clip', $clip);
$display_thumbnail = null;
foreach ($thumbs as $thumb) {
$thttp = new HTTP();
if ($thttp->Get($thumb['thumbnail'], $thumb['thumbnail'])) {
$temp_file = $video_dir->AddTempFromVar($thttp->body, JPG_EXTENSION);
$imgsize = @getimagesize($temp_file);
if ($imgsize !== false) {
if (Video_Thumbnail::CanResize()) {
$local_filename = Video_Thumbnail::Resize($temp_file, Config::Get('thumb_size'), Config::Get('thumb_quality'), $video_dir->GetThumbsDir());
} else {
$local_filename = $video_dir->AddThumbFromFile($temp_file, JPG_EXTENSION);
}
$local_filename = str_replace(Config::Get('document_root'), '', $local_filename);
$thumb_id = DatabaseAdd('tbx_video_thumbnail', array('video_id' => $video['video_id'], 'thumbnail' => $local_filename));
if (empty($display_thumbnail)) {
$display_thumbnail = $thumb_id;
}
} else {
unlink($temp_file);
}
}
}
if (!empty($display_thumbnail)) {
$DB->Update('UPDATE `tbx_video` SET `display_thumbnail`=? WHERE `video_id`=?', array($display_thumbnail, $video['video_id']));
}
$DB->Update('INSERT INTO `tbx_video_feed_history` VALUES (?,?)', array($this->feed['feed_id'], $entry->getVideoId()));
$imported++;
}
$DB->Update('UPDATE `tbx_video_feed` SET `date_last_read`=? WHERE `feed_id`=?', array(Database_MySQL::Now(), $this->feed['feed_id']));
UpdateSponsorStats($this->feed['sponsor_id']);
return $imported;
}
示例3: tbxVideoEdit
function tbxVideoEdit()
{
global $t;
$DB = GetDB();
$username = AuthenticateUser::GetUsername();
$video = $DB->Row('SELECT * FROM `tbx_video` JOIN `tbx_video_custom` USING (`video_id`) WHERE `username`=? AND `tbx_video`.`video_id`=?', array($username, $_REQUEST['video_id']));
$_REQUEST['tags'] = Tags::Format($_REQUEST['tags']);
$v = Validator::Create();
$v->Register(empty($video), Validator_Type::IS_FALSE, _T('Validation:Not your video'));
$v->Register($_REQUEST['title'], Validator_Type::LENGTH_BETWEEN, _T('Validation:Invalid Length', _T('Label:Title'), Config::Get('title_min_length'), Config::Get('title_max_length')), Config::Get('title_min_length') . ',' . Config::Get('title_max_length'));
$v->Register($_REQUEST['description'], Validator_Type::LENGTH_BETWEEN, _T('Validation:Invalid Length', _T('Label:Description'), Config::Get('description_min_length'), Config::Get('description_max_length')), Config::Get('description_min_length') . ',' . Config::Get('description_max_length'));
$v->Register(Tags::Count($_REQUEST['tags']), Validator_Type::IS_BETWEEN, _T('Validation:Invalid Num Tags', Config::Get('tags_min'), Config::Get('tags_max')), Config::Get('tags_min') . ',' . Config::Get('tags_max'));
// Register user-defined field validators
$schema = GetDBSchema();
$v->RegisterFromXml($schema->el('//table[name="tbx_video_custom"]'), 'user', 'create');
// Check blacklist
$_REQUEST['ip_address'] = $_SERVER['REMOTE_ADDR'];
if (($match = Blacklist::Match($_REQUEST, Blacklist::ITEM_VIDEO)) !== false) {
$v->SetError(_T('Validation:Blacklisted', $match['match']));
}
if (!$v->Validate()) {
$t->Assign('g_errors', $v->GetErrors());
return tbxDisplayVideoEdit(false);
}
// Strip HTML tags
if (Config::Get('flag_video_strip_tags')) {
$_REQUEST = String::StripTags($_REQUEST);
}
// Prepare fields for database
Form_Prepare::Standard('tbx_video', 'edit');
Form_Prepare::Custom('tbx_video_custom_schema', 'on_edit');
$_REQUEST['video_id'] = $video['video_id'];
$_REQUEST['display_thumbnail'] = $DB->QuerySingleColumn('SELECT `thumbnail_id` FROM `tbx_video_thumbnail` WHERE `video_id`=? AND `thumbnail_id`=?', array($video['video_id'], $_REQUEST['display_thumbnail']));
$_REQUEST['is_private'] = Config::Get('flag_upload_allow_private') ? intval($_REQUEST['is_private']) : 0;
$_REQUEST['allow_ratings'] = intval($_REQUEST['allow_ratings']);
$_REQUEST['allow_embedding'] = intval($_REQUEST['allow_embedding']);
$_REQUEST['allow_comments'] = intval($_REQUEST['allow_comments']) ? 'Yes - Add Immediately' : 'No';
if ($_REQUEST['recorded_day'] && $_REQUEST['recorded_month'] && $_REQUEST['recorded_year']) {
$_REQUEST['date_recorded'] = $_REQUEST['recorded_year'] . '-' . $_REQUEST['recorded_month'] . '-' . $_REQUEST['recorded_day'];
}
if (empty($_REQUEST['display_thumbnail'])) {
unset($_REQUEST['display_thumbnail']);
}
DatabaseUpdate('tbx_video', $_REQUEST);
DatabaseUpdate('tbx_video_custom', $_REQUEST);
// Handle changes to privacy
if ($_REQUEST['is_private'] && !$video['is_private']) {
$private_id = sha1(uniqid(mt_rand(), true));
$DB->Update('REPLACE INTO `tbx_video_private` VALUES (?,?)', array($video['video_id'], $private_id));
} else {
if (!$_REQUEST['is_private']) {
$DB->Update('DELETE FROM `tbx_video_private` WHERE `video_id`=?', array($video['video_id']));
}
}
$t->ClearCache('video-watch.tpl', $video['video_id']);
$t->Assign('g_success', true);
tbxDisplayVideoEdit();
}
示例4: tbxBannerAdd
function tbxBannerAdd($phase)
{
switch ($phase) {
case Phase::PRE_VALIDATE:
Uploads::ProcessNew();
$upload = Uploads::Get('upload_file');
if (!empty($upload)) {
$v = Validator::Get();
$v->Register(empty($upload['error']), Validator_Type::IS_TRUE, $upload['error']);
$v->Register(stripos(Request::Get('banner_html'), '{$upload_file}'), Validator_Type::NOT_FALSE, 'The Banner HTML must contain {$upload_file} where you want the URL of the upload file placed');
}
break;
case Phase::VALIDATION_FAILED:
Uploads::RemoveCurrent();
break;
case Phase::PRE_INSERT:
$upload = Uploads::Get('upload_file');
if (!empty($upload)) {
$_REQUEST['upload_id'] = $upload['upload_id'];
$_REQUEST['banner_html'] = str_replace('{$upload_file}', $upload['uri'], $_REQUEST['banner_html']);
}
$_REQUEST['tags'] = Tags::Format(Request::Get('tags'));
$_REQUEST['sponsor_id'] = String::Nullify($_REQUEST['sponsor_id']);
if (!empty($_REQUEST['sponsor_id'])) {
$DB = GetDB();
$sponsor = $DB->Row('SELECT * FROM `tbx_sponsor` WHERE `sponsor_id`=?', array($_REQUEST['sponsor_id']));
if (!empty($sponsor)) {
$_REQUEST['banner_html'] = str_replace('{$sponsor_url}', $sponsor['url'], $_REQUEST['banner_html']);
}
}
break;
}
}
示例5: Import
public static function Import($settings)
{
$DB = GetDB();
ProgressBarShow('pb-import');
$file = TEMP_DIR . '/' . File::Sanitize($settings['import_file']);
$fp = fopen($file, 'r');
$filesize = filesize($file);
$line = $read = $imported = 0;
$expected = count($settings['fields']);
while (!feof($fp)) {
$line++;
$string = fgets($fp);
$read += strlen($string);
$data = explode($settings['delimiter'], trim($string));
ProgressBarUpdate('pb-import', $read / $filesize * 100);
// Line does not have the expected number of fields
if (count($data) != $expected) {
continue;
}
$video = array();
$defaults = array('category_id' => $settings['category_id'], 'sponsor_id' => $settings['sponsor_id'], 'username' => $settings['username'], 'duration' => Format::DurationToSeconds($settings['duration']), 'status' => $settings['status'], 'next_status' => $settings['status'], 'allow_comments' => $settings['allow_comments'], 'allow_ratings' => $settings['allow_ratings'], 'allow_embedding' => $settings['allow_embedding'], 'is_private' => $settings['is_private'], 'date_added' => Database_MySQL::Now(), 'is_featured' => 0, 'is_user_submitted' => 0, 'conversion_failed' => 0, 'tags' => null, 'title' => null, 'description' => null);
foreach ($settings['fields'] as $index => $field) {
if (!empty($field)) {
$video[$field] = trim($data[$index]);
}
}
// Setup clips
$clips = array();
$thumbs = array();
$clip_type = 'URL';
if (isset($video['embed_code'])) {
// Cannot convert or thumbnail from embed code
$settings['flag_convert'] = $settings['flag_thumb'] = false;
$clips[] = $video['embed_code'];
$clip_type = 'Embed';
} else {
if (isset($video['gallery_url'])) {
$http = new HTTP();
if (!$http->Get($video['gallery_url'])) {
// Broken gallery URL, continue
continue;
}
list($thumbs, $clips) = Video_Source_Gallery::ExtractUrls($http->url, $http->body);
} else {
if (!isset($video['video_url']) && isset($video['base_video_url'])) {
if (!preg_match('~/$~', $video['base_video_url'])) {
$video['base_video_url'] .= '/';
}
foreach (explode(',', $video['video_filename']) as $filename) {
$clips[] = $video['base_video_url'] . $filename;
}
} else {
$clips[] = $video['video_url'];
}
}
}
// Check for duplicate clips
$duplicate = false;
foreach ($clips as $clip) {
if (!Request::Get('flag_skip_imported_check') && $DB->QueryCount('SELECT COUNT(*) FROM `tbx_imported` WHERE `video_url`=?', array($clip)) > 0) {
$duplicate = true;
}
$DB->Update('REPLACE INTO `tbx_imported` VALUES (?)', array($clip));
}
// Dupe found
if ($duplicate) {
continue;
}
// Setup thumbs
if (!isset($video['gallery_url']) && !isset($video['thumbnail_url']) && isset($video['base_thumbnail_url'])) {
if (!preg_match('~/$~', $video['base_thumbnail_url'])) {
$video['base_thumbnail_url'] .= '/';
}
foreach (explode(',', String::FormatCommaSeparated($video['thumbnail_filename'])) as $filename) {
$thumbs[] = $video['base_thumbnail_url'] . $filename;
}
} else {
if (!isset($video['gallery_url']) && isset($video['thumbnail_url'])) {
$thumbs[] = $video['thumbnail_url'];
}
}
// Setup duration
if (isset($video['duration_seconds'])) {
$video['duration'] = $video['duration_seconds'];
} else {
if (isset($video['duration_formatted'])) {
$video['duration'] = Format::DurationToSeconds($video['duration_formatted']);
}
}
// Use description for title
if (empty($video['title'])) {
$video['title'] = isset($video['description']) ? $video['description'] : '';
}
// Use title for description
if (empty($video['description'])) {
$video['description'] = isset($video['title']) ? $video['title'] : '';
}
// Use title for tags
if (empty($video['tags'])) {
$video['tags'] = isset($video['title']) ? $video['title'] : '';
//.........这里部分代码省略.........
示例6: define
<?php
// Copyright 2011 JMB Software, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
if (!preg_match('~/admin$~', realpath(dirname(__FILE__)))) {
echo "This file must be located in the admin directory of your TubeX installation";
exit;
}
define('TUBEX_CONTROL_PANEL', true);
require_once 'includes/cp-global.php';
$DB = GetDB();
$DB->Update('DELETE FROM `tbx_video_tag`');
$result = $DB->Query('SELECT * FROM `tbx_video` WHERE `status`=? AND `is_private`=?', array(STATUS_ACTIVE, 0));
while ($video = $DB->NextRow($result)) {
$video['tags'] = Tags::Format($video['tags']);
Tags::AddToFrequency($video['tags']);
$DB->Update('UPDATE `tbx_video` SET `tags`=? WHERE `video_id`=?', array($video['tags'], $video['video_id']));
}
$DB->Free($result);
echo "VIDEO TAGS HAVE BEEN SUCCESSFULLY UPDATED!\n";
示例7: Import
public function Import()
{
$imported = 0;
$http = new HTTP();
if ($http->Get($this->feed['feed_url'])) {
$xml = simplexml_load_string($this->ToUTF8($http->body), 'XML_Element', LIBXML_NOERROR, LIBXML_NOWARNING, LIBXML_NOCDATA);
if ($xml !== false) {
$DB = GetDB();
foreach ($xml->xpath('//videos/video') as $xvideo) {
// Check for duplicates, and skip
if ($DB->QueryCount('SELECT COUNT(*) FROM `tbx_video_feed_history` WHERE `feed_id`=? AND `unique_id`=?', array($this->feed['feed_id'], $xvideo->id->val()))) {
continue;
}
// Setup defaults
$video = $this->defaults;
$video['title'] = $xvideo->title->val();
$video['description'] = $xvideo->description->val();
$video['tags'] = Tags::Format($xvideo->tags->val());
if (empty($video['description'])) {
$video['description'] = $video['title'];
}
// Process <clips>
$clips = array();
$screens = array();
foreach ($xvideo->xpath('./clips/clip') as $xclip) {
$video['duration'] += $xclip->duration;
$clip_url = $xvideo->clip_url->val();
$flv = $xclip->flv->val();
// Account for malformed feeds where the clip_url contains the URL to the video
// file rather than the required root URL
if (strstr($clip_url, $flv) === false) {
$clip_url = $clip_url . $flv;
}
$clips[] = array('type' => 'URL', 'clip' => $clip_url);
foreach ($xclip->xpath('./screens/screen') as $xscreen) {
$screen_url = $xvideo->screen_url->val();
$screen = $xscreen->val();
// Account for malformed feeds where the screen_url contains the URL to the image
// file rather than the required root URL
if (strstr($screen_url, $screen) === false) {
$screen_url = $screen_url . $screen;
}
$screens[] = array('thumbnail' => $screen_url);
}
}
if (count($clips) > 0) {
$best_category = GetBestCategory(join(' ', array($video['title'], $video['description'], $video['tags'])));
if (!empty($best_category)) {
$video['category_id'] = $best_category;
}
if ($this->feed['flag_convert']) {
$video['status'] = STATUS_QUEUED;
$video['next_status'] = $this->feed['status'];
}
$video['video_id'] = DatabaseAdd('tbx_video', $video);
DatabaseAdd('tbx_video_custom', $video);
DatabaseAdd('tbx_video_stat', $video);
if (!$video['is_private']) {
Tags::AddToFrequency($video['tags']);
}
$video['queued'] = time();
if ($this->feed['flag_convert']) {
DatabaseAdd('tbx_conversion_queue', $video);
}
if ($this->feed['flag_thumb']) {
DatabaseAdd('tbx_thumb_queue', $video);
}
UpdateCategoryStats($video['category_id']);
$video_dir = new Video_Dir(Video_Dir::DirNameFromId($video['video_id']));
foreach ($clips as $clip) {
$clip['video_id'] = $video['video_id'];
DatabaseAdd('tbx_video_clip', $clip);
}
$display_thumbnail = null;
foreach ($screens as $screen) {
$thttp = new HTTP();
if ($thttp->Get($screen['thumbnail'], $screen['thumbnail'])) {
$temp_file = $video_dir->AddTempFromVar($thttp->body, JPG_EXTENSION);
$imgsize = @getimagesize($temp_file);
if ($imgsize !== false) {
if (Video_Thumbnail::CanResize()) {
$local_filename = Video_Thumbnail::Resize($temp_file, Config::Get('thumb_size'), Config::Get('thumb_quality'), $video_dir->GetThumbsDir());
} else {
$local_filename = $video_dir->AddThumbFromFile($temp_file, JPG_EXTENSION);
}
$local_filename = str_replace(Config::Get('document_root'), '', $local_filename);
$thumb_id = DatabaseAdd('tbx_video_thumbnail', array('video_id' => $video['video_id'], 'thumbnail' => $local_filename));
if (empty($display_thumbnail)) {
$display_thumbnail = $thumb_id;
}
}
}
}
$video_dir->ClearTemp();
if (!empty($display_thumbnail)) {
$DB->Update('UPDATE `tbx_video` SET `display_thumbnail`=? WHERE `video_id`=?', array($display_thumbnail, $video['video_id']));
}
$DB->Update('INSERT INTO `tbx_video_feed_history` VALUES (?,?)', array($this->feed['feed_id'], $xvideo->id->val()));
$imported++;
}
//.........这里部分代码省略.........