drj58429 2015-01-23 21:36
浏览 63

在php仪表板的文章中链接url不起作用

I have a dashboard designed in php for the client from where he is able to add new stories/articles on the main site using the tiny mce editor, just similar to a joomla article. The problem is that when a url is linked then it appends to the main site for some reason. e.g

http://example.com/"http://careers.virginmedia.com//"

I have tried every format for the url, but doesn't work. Please can someone help me with this.

The following code adds the content

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');
    }
}

The code below displays it

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;
    }

The tinymce page code:

<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>
  • 写回答

1条回答 默认 最新

  • dongyi1748 2015-01-24 14:35
    关注

    You are using TinyMCE with the relative_urls = false option. From looking at the TinyMCE docs on URL conversion I think you should instead drop that option and add convert_urls: false.

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧