我在php中为客户端设计了一个仪表板,他可以使用微小的mce编辑器在主站点上添加新的故事/文章,类似于joomla文章。问题是,当链接网址时,它会出于某种原因附加到主网站。 e.g
http://example.com/ “http://careers.virginmedia.com//”
我已尝试过该网址的所有格式,但无效。请有人帮我这个。
以下代码添加了内容
function addSponsoredAd()
{
if(isset($_POST['submit']))
{
$db = new Connection(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$userID = $_SESSION['user']['userID'];
$ID = getNextID('sponsoredAds');
$imgTmp = $_FILES['image']['tmp_name'];
$image = basename(strtolower(str_replace(' ', '-', $_FILES['image']['name'])));
$info = pathinfo($_FILES['image']['name']);
$filename = $image;
$imageFolder = '../mediaLibrary/sponsoredAds/';
$imageDestination = $imageFolder.$filename;
move_uploaded_file($imgTmp, $imageDestination);
$title = $_POST['title'];
$description = $_POST['description'];
$position = $_POST['position'];
$status = $_POST['status'];
$content = $_POST['content'];
$parameters = array(
'table' => 'sponsoredAds',
'fieldsAndValues' => array(
'userID' => $userID,
'title' => $title,
'description' => $description,
'status' => $status,
'position' => $position,
'content'=> $content,
'dateAdded' => datetime()
)
);
$db->insert($parameters);
if($imgTmp != '')
{
$parameters = array(
'table' => 'sponsoredAds',
'fieldsAndValues' => array(
'logo' => $imageDestination
),
'conditions' => 'WHERE ID = "'.$ID.'"'
);
$db->update($parameters);
}
setMessage('Added a new sponsored ad: '.$title, 1);
header('Location: '.BASE_URL.'dashboard/sponsoredAds');
}
}
以下代码显示
function getSponsoredListings()
{
$db = new Connection(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$result = $db->query('
SELECT *
FROM sponsoredAds
ORDER BY position
');
$items='';
while($row = mysql_fetch_assoc($result))
{
$items .= '
<div id="search-results">
<div class="search-result '.$class.'" id="searchResult'.$row['ID'].'">
<a href="sponsored-posts/'.$row['ID'].'">
<div class="img-container">
<img src="'.BASE_URL.str_replace('../', '', $row['logo']).'" alt="'.$row['title'].'" />
</div><!-- End img container -->
<h3>'.$row['title'].'</h3>
<p>'.$row['content'].'</p>
<div class="cont">'.$row['description']
.'</div><!-- End cont -->
</a>
</div><!-- End search result -->
</div><!-- End search results -->
';
$count++;
}
return $items;
}
tinymce页面代码:
<head>
<title>Dashboard</title>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>_style/main.css" />
<link rel="stylesheet" href="<?php echo BASE_URL; ?>_style/dashboard.css" />
<link href="<?php echo BASE_URL; ?>favicon.ico" type="image/x-icon" rel="shortcut icon" />
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>-->
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/functions.js"></script>
<script src="<?php echo BASE_URL; ?>dashboard/_scripts/functions.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/notify.1.0.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/jquery.validate.min.js"></script>
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/jquery.cookie.js"></script>
<script src="http://cdn.jquerytools.org/1.2.7/all/jquery.tools.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector:'textarea',
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
var BASE_URL = '<?php echo BASE_URL; ?>';
$(document).ready(function() {
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : '<?php echo BASE_URL; ?>_scripts/tinymce/jscripts/tiny_mce/tiny_mce.js',
mode : 'textareas',
plugins : 'jbimages,paste,fullscreen,media,table',
paste_auto_cleanup_on_paste : true,
theme : 'advanced',
theme_advanced_buttons1 : 'bold,italic,underline,|,bullist,numlist,|,link,unlink,image,jbimages,|,formatselect,removeformat,code, fullscreen, media,|,tablecontrols',
theme_advanced_buttons3_add : "tablecontrols",
table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
table_cell_limit : 100,
table_row_limit : 5,
table_col_limit : 5,
theme_advanced_buttons2 : '',
theme_advanced_buttons3 : '',
theme_advanced_buttons4 : '',
theme_advanced_toolbar_location : 'top',
theme_advanced_toolbar_align : 'left',
theme_advanced_resizing : true,
theme_advanced_blockformats : 'Paragraph=p,Heading=h4,Leading=h3',
relative_urls : false,
valid_elements : '*[*]',
valid_styles : {'span' : 'text-decoration', 'img' : 'vertical-align,border,margin-top,margin-bottom,margin-left,margin-right,float'},
width: '100%',
height: '400',
extended_valid_elements: "embed[width|height|name|flashvars|src|bgcolor|align|play|loop|quality|allowscriptaccess|type|pluginspage]",
media_strict: false
});
$('#name').keyup(function(){
$('#permalink').val($('#name').val().replace(/[^a-zA-Z 0-9-]+/g, '').toLowerCase().replace(/\s/g, '-').replace('--', '-'));
});
});
</script>
<h1>Add a New Sponsored Ad</h1>
<form action="<?php addSponsoredAd(); ?>" method="post" enctype="multipart/form-data">
<label for="image">Logo</label>
<input type="file" name="image" id="image" />
<label for="title">Title</label>
<input type="text" name="title" id="title" />
<label for="description">Description</label>
<textarea name="description" id="description"><?php echo $info['description']; ?></textarea>
<label for="content">Content</label>
<textarea class="tinymce" name="content" id="content"><?php echo $info['content']; ?></textarea>
<!-- <label for="position">Position</label>
<input type="text" name="position" id="position" /> -->
<label for="status"><input type="checkbox" name="status" id="status" value="1" /> Active?</label>
<input type="submit" name="submit" id="submit" value="Add Sponsored Ad" />
</form>
答案 0 :(得分:0)
您正在使用带有relative_urls = false
选项的TinyMCE。通过查看TinyMCE docs on URL conversion,我认为您应该删除该选项并添加convert_urls: false
。