예제 #1
0
/**
 * Implementation of hook_add_js_call.
 */
function ft_fckeditor_add_js_call()
{
    global $ft;
    $return = '';
    // Only add JS when we're on an edit page.
    if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'edit' && file_exists($ft['plugins']['fckeditor']['settings']['path'])) {
        $list = explode(" ", $ft['plugins']['fckeditor']['settings']['list']);
        if (in_array(ft_get_ext(strtolower($_REQUEST['file'])), $list)) {
            $return .= 'var oFCKeditor = new FCKeditor("filecontent") ;
      oFCKeditor.BasePath = "' . $ft['plugins']['fckeditor']['settings']['BasePath'] . '" ;
      oFCKeditor.ReplaceTextarea() ;';
            // Unbind save action and rebind with a fckeditor specific version.
            $return .= '$("#save").unbind();$("#save").click(function(){
       $("#savestatus").empty().append("<p class=\\"ok\\">' . t('Saving file&hellip;') . '</p>");
       // Get file content from fckeditor.
       oEditor = FCKeditorAPI.GetInstance("filecontent");
       filecontent = oEditor.GetHTML();
       $.post("' . ft_get_self() . '", {method:\'ajax\', act:\'saveedit\', file: $(\'#file\').val(), dir: $(\'#dir\').val(), filecontent: filecontent, convertspaces: $(\'#convertspaces\').val()}, function(data){
         $("#savestatus").empty().append(data);
       });
      });';
        }
    }
    return $return;
}
예제 #2
0
/**
 * Implementation of hook_add_js_call_footer.
 */
function ft_tinymce_add_js_call_footer()
{
    global $ft;
    $return = '';
    // Only add JS when we're on an edit page.
    if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'edit') {
        if (file_exists($ft['plugins']['tinymce']['settings']['path'])) {
            $list = explode(" ", $ft['plugins']['tinymce']['settings']['list']);
            if (in_array(ft_get_ext(strtolower($_REQUEST['file'])), $list)) {
                $return = 'tinyMCE.init({
          mode : "exact",
          elements : "filecontent",
          theme : "advanced",
          theme_advanced_toolbar_location : "top",
          theme_advanced_toolbar_align : "left"
        });';
            } else {
                $return = '// File not in TinyMCE edit list.';
            }
        } else {
            $return = '// TinyMCE file not found: ' . $ft['plugins']['tinymce']['settings']['path'];
        }
    }
    return $return;
}
예제 #3
0
/**
 * Implementation of hook_add_js_call_footer.
 */
function ft_editorck_add_js_call_footer()
{
    global $ft;
    $return = '';
    // Only add JS when we're on an edit page.
    if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'edit') {
        if (file_exists($ft['plugins']['editorck']['settings']['path'])) {
            $list = explode(" ", $ft['plugins']['editorck']['settings']['list']);
            if (in_array(ft_get_ext(strtolower($_REQUEST['file'])), $list)) {
                $return = 'CKEDITOR.replace("filecontent");';
            } else {
                $return = '// File not in ckeditor edit list.';
            }
        } else {
            $return = '// ckeditor file not found: ' . $ft['plugins']['editorck']['settings']['path'];
        }
    }
    return $return;
}
예제 #4
0
파일: ft2.php 프로젝트: rekysda/filemanager
/**
 * Shorten a file name to a given length maintaining the file extension.
 *
 * @param $name
 *   File name.
 * @param $limit
 *   The maximum length of the file name.
 * @return The shortened file name.
 */
function ft_get_nice_filename($name, $limit = -1)
{
    if ($limit > 0) {
        $noext = $name;
        if (strstr($name, '.')) {
            $noext = substr($name, 0, strrpos($name, '.'));
        }
        $ext = ft_get_ext($name);
        if (strlen($noext) - 3 > $limit) {
            $name = substr($noext, 0, $limit) . '...';
            if ($ext != '') {
                $name = $name . '.' . $ext;
            }
        }
    }
    return $name;
}
예제 #5
0
/**
 * Check if file is on the edit list.
 *
 * @param $file
 *   File name.
 * @return TRUE if file is on the edit list.
 */
function ft_check_edit($file)
{
    global $ft;
    // Check against file blacklist.
    if ($ft['plugins']['edit']['settings']['editlist'] != "") {
        $list = explode(" ", $ft['plugins']['edit']['settings']['editlist']);
        if (in_array(ft_get_ext(strtolower($file)), $list)) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}