/**
  * Display a toolbar
  *
  * @todo dh> This seems to be a lot of Javascript. Please try exporting it in a
  *       (dynamically created) .js src file. Then we could use cache headers
  *       to let the browser cache it.
  * @param array Associative array of parameters
  * @return boolean did we display a toolbar?
  */
 function AdminDisplayToolbar(&$params)
 {
     $allow_HTML = false;
     if (!empty($params['Item'])) {
         // Item is set, get Blog from post
         $edited_Item =& $params['Item'];
         $Blog =& $edited_Item->get_Blog();
         // We editing an Item, Check if HTML is allowed for the post type:
         $allow_HTML = $edited_Item->get_type_setting('allow_html');
     }
     if (empty($Blog)) {
         // Item is not set, try global Blog
         global $Blog;
         if (empty($Blog)) {
             // We can't get a Blog, this way "apply_rendering" plugin collection setting is not available
             return false;
         }
     }
     if (!empty($params['Comment'])) {
         // We editing a Comment, Check if HTML is allowed for the comments of current Blog:
         $allow_HTML = $Blog->get_setting('allow_html_comment');
     }
     if (!$allow_HTML) {
         // Only when HTML is allowed in post/comment
         return false;
     }
     $coll_setting_name = $params['target_type'] == 'Comment' ? 'coll_apply_comment_rendering' : 'coll_apply_rendering';
     $apply_rendering = $this->get_coll_setting($coll_setting_name, $Blog);
     if (empty($apply_rendering) || $apply_rendering == 'never') {
         // Plugin is not enabled for current case, so don't display a toolbar:
         return false;
     }
     // Append css styles for tinymce editor area
     global $tinymce_content_css;
     if (empty($tinymce_content_css)) {
         // Initialize first time
         $tinymce_content_css = array();
     }
     $tinymce_content_css[] = get_require_url($this->get_plugin_url() . 'tinymce_editor.css', true, 'css');
     // Print toolbar on screen
     return $this->DisplayCodeToolbar();
 }
</div>' );
				} );
			} );
			// -->
		</script>
		<?php 
    if ($fm_highlight) {
        // we want to highlight a file (e.g. via "Locate this file!"), scroll there and do the success fade
        ?>

			<script type="text/javascript">
			jQuery( function() {
				var fm_hl = jQuery("#fm_highlighted");
				if( fm_hl.length ) {
					jQuery.getScript('<?php 
        echo get_require_url('#scrollto#');
        ?>
', function () {
						jQuery.scrollTo( fm_hl,
						{ onAfter: function()
							{
								evoFadeHighlight( fm_hl )
							}
						} );
					});
				}
			} );
			</script>

			<?php 
    }
/**
 * Memorize that a specific css that file will be required by the current page.
 * All requested files will be included in the page head only once (when headlines is called)
 *
 * Accepts absolute urls, filenames relative to the rsc/css directory.
 * Set $relative_to_base to TRUE to prevent this function from adding on the rsc_path
 *
 * @param string alias, url or filename (relative to rsc/css) for CSS file
 * @param boolean|string 'relative' or true (relative to <base>) or 'rsc_url' (relative to $rsc_url) or 'blog' (relative to current blog URL -- may be subdomain or custom domain)
 * @param string title.  The title for the link tag
 * @param string media.  ie, 'print'
 * @param string version number to append at the end of requested url to avoid getting an old version from the cache
 * @param boolean TRUE to print script tag on the page, FALSE to store in array to print then inside <head>
 */
function require_css($css_file, $relative_to = 'rsc_url', $title = NULL, $media = NULL, $version = '#', $output = false)
{
    static $required_css;
    global $dequeued_headlines;
    if (isset($dequeued_headlines[$css_file])) {
        // Don't require this file if it was dequeued before this request
        return;
    }
    // Which subfolder do we want to use in case of absolute paths? (doesn't appy to 'relative')
    $subfolder = 'css';
    if ($relative_to == 'rsc_url' || $relative_to == 'blog') {
        if (preg_match('/\\.(bundle|bmin|min)\\.css$/', $css_file)) {
            $subfolder = 'build';
        }
    }
    // Get library url of CSS file by alias name
    $css_url = get_require_url($css_file, $relative_to, $subfolder, $version);
    // Add to headlines, if not done already:
    if (empty($required_css) || !in_array(strtolower($css_url), $required_css)) {
        $required_css[] = strtolower($css_url);
        $stylesheet_tag = '<link type="text/css" rel="stylesheet"';
        $stylesheet_tag .= empty($title) ? '' : ' title="' . $title . '"';
        $stylesheet_tag .= empty($media) ? '' : ' media="' . $media . '"';
        $stylesheet_tag .= ' href="' . $css_url . '" />';
        if ($output) {
            // Print stylesheet tag right here
            echo $stylesheet_tag;
        } else {
            // Add stylesheet tag to <head>
            add_headline($stylesheet_tag, $css_file);
        }
    }
}
Beispiel #4
0
/**
 * Allow recursive category selection.
 *
 * @todo Allow to use a dropdown (select) to switch between blogs ( CSS / JS onchange - no submit.. )
 *
 * @param Form
 * @param boolean true: use form fields, false: display only
 * @param boolean true: show links for add new category & manual
 * @param array Params
 */
function cat_select($Form, $form_fields = true, $show_title_links = true, $params = array())
{
    global $blog, $current_blog_ID, $current_User, $edited_Item, $cat_select_form_fields;
    global $admin_url, $rsc_url;
    if (get_post_cat_setting($blog) < 1) {
        // No categories for $blog
        return;
    }
    $params = array_merge(array('categories_name' => T_('Categories'), 'fold' => false), $params);
    $cat = param('cat', 'integer', 0);
    if (empty($edited_Item->ID) && !empty($cat)) {
        // If the GET param 'cat' is defined we should preselect the category for new created post
        global $post_extracats;
        $post_extracats = array($cat);
        $edited_Item->main_cat_ID = $cat;
    }
    if ($show_title_links) {
        // Use in Back-office
        $fieldset_title = $params['categories_name'] . get_manual_link('post-categories-panel') . action_icon(T_('Categories'), 'edit', $admin_url . '?ctrl=chapters&amp;blog=' . $blog, T_('Categories'), 3, 4, array('class' => 'action_icon pull-right'));
    } else {
        $fieldset_title = $params['categories_name'];
    }
    $Form->begin_fieldset($fieldset_title, array('class' => 'extracats', 'id' => 'itemform_categories', 'fold' => $params['fold']));
    $r = '';
    $cat_select_form_fields = $form_fields;
    $ChapterCache =& get_ChapterCache();
    $r .= '<table cellspacing="0" class="catselect table table-striped table-hover table-condensed">';
    if (get_post_cat_setting($blog) == 3) {
        // Main + Extra cats option is set, display header
        $r .= cat_select_header($params);
    }
    $callbacks = array('before_first' => 'cat_select_before_first', 'before_each' => 'cat_select_before_each', 'after_each' => 'cat_select_after_each', 'after_last' => 'cat_select_after_last');
    // Init cat display param
    $cat_display_params = array('total_count' => 0);
    if (get_allow_cross_posting() >= 2 || isset($blog) && get_post_cat_setting($blog) > 1 && get_allow_cross_posting() == 1) {
        // If BLOG cross posting enabled, go through all blogs with cats:
        /**
         * @var BlogCache
         */
        $BlogCache =& get_BlogCache();
        $ChapterCache->reveal_children(NULL, true);
        /**
         * @var Blog
         */
        for ($l_Blog =& $BlogCache->get_first(); !is_null($l_Blog); $l_Blog =& $BlogCache->get_next()) {
            // run recursively through the cats
            if (!blog_has_cats($l_Blog->ID)) {
                continue;
            }
            if (!$current_User->check_perm('blog_post_statuses', 'edit', false, $l_Blog->ID)) {
                continue;
            }
            $r .= '<tr class="group' . ($blog == $l_Blog->ID ? ' catselect_blog__current' : '') . '" id="catselect_blog' . $l_Blog->ID . '"><td colspan="3">' . $l_Blog->dget('name') . "</td></tr>\n";
            $current_blog_ID = $l_Blog->ID;
            // Global needed in callbacks
            foreach ($ChapterCache->subset_root_cats[$current_blog_ID] as $root_Chapter) {
                $r .= cat_select_display($root_Chapter, $callbacks, $cat_display_params);
            }
            if ($blog == $current_blog_ID) {
                $r .= cat_select_new($cat_display_params);
            }
        }
    } else {
        // BLOG Cross posting is disabled. Current blog only:
        $current_blog_ID = $blog;
        $ChapterCache->reveal_children($current_blog_ID, true);
        foreach ($ChapterCache->subset_root_cats[$blog] as $root_Chapter) {
            $r .= cat_select_display($root_Chapter, $callbacks, $cat_display_params);
        }
        $r .= cat_select_new($cat_display_params);
    }
    $r .= '</table>';
    echo $r;
    $Form->end_fieldset();
    if (isset($blog) && get_allow_cross_posting()) {
        echo '<script type="text/javascript">jQuery.getScript("' . get_require_url('#scrollto#') . '", function () {
			jQuery("[id$=itemform_categories]").scrollTo( "#catselect_blog' . $blog . '" );
		});</script>';
    }
}
 /**
  * Get the URL to include TinyMCE.
  * @return string
  */
 function get_tinymce_src_url()
 {
     $relative_to = is_admin_page() ? 'rsc_url' : 'blog';
     if ($this->Settings->get('use_gzip_compressor')) {
         $url = get_require_url('#tinymce_gzip#', $relative_to);
         // dh> suffix of the file to compress. Looking at tiny_mce_gzip.php it only allows "_src". Needs investigation - maybe the tiny_mce_jquery.js would actually work when "_jquery" would be allowed.
     } else {
         $url = get_require_url('#tinymce#', $relative_to);
     }
     return $url;
 }