* @version $Id: _skin_list.view.php 3328 2013-03-26 11:44:11Z yura $
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
// Create result set:
$SQL = new SQL();
$SQL->SELECT('T_skins__skin.*, COUNT( DISTINCT( cset_coll_ID ) ) AS nb_blogs');
$SQL->FROM('T_skins__skin LEFT JOIN T_coll_settings ON skin_ID = cset_value AND
			( cset_name = "normal_skin_ID" OR cset_name = "mobile_skin_ID" OR cset_name = "tablet_skin_ID" )');
$SQL->GROUP_BY('skin_ID');
$CountSQL = new SQL();
$CountSQL->SELECT('COUNT( * )');
$CountSQL->FROM('T_skins__skin');
$Results = new Results($SQL->get(), 'skin_', '', NULL, $CountSQL->get());
$Results->Cache =& get_SkinCache();
$Results->title = T_('Installed skins') . get_manual_link('installed_skins');
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $Results->cols[] = array('th' => T_('Name'), 'order' => 'skin_name', 'td' => '<strong><a href="' . regenerate_url('', 'skin_ID=$skin_ID$&amp;action=edit') . '" title="' . TS_('Edit skin properties...') . '">$skin_name$</a></strong>');
} else {
    // We have NO permission to modify:
    $Results->cols[] = array('th' => T_('Name'), 'order' => 'skin_name', 'td' => '<strong>$skin_name$</strong>');
}
$Results->cols[] = array('th' => T_('Skin type'), 'order' => 'skin_type', 'td_class' => 'center', 'td' => '$skin_type$');
$Results->cols[] = array('th' => T_('Blogs'), 'order' => 'nb_blogs', 'th_class' => 'shrinkwrap', 'td_class' => 'center', 'td' => '~conditional( (#nb_blogs# > 0), #nb_blogs#, \'&nbsp;\' )~');
$Results->cols[] = array('th' => T_('Skin Folder'), 'order' => 'skin_folder', 'td' => '$skin_folder$');
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $Results->cols[] = array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'td' => action_icon(TS_('Edit skin properties...'), 'properties', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=edit\')%') . action_icon(TS_('Reload containers!'), 'reload', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=reload&amp;' . url_crumb('skin') . '\')%') . '~conditional( #nb_blogs# < 1, \'' . action_icon(TS_('Uninstall this skin!'), 'delete', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=delete&amp;' . url_crumb('skin') . '\')%') . '\', \'' . get_icon('delete', 'noimg') . '\' )~');
    $Results->global_icon(T_('Install new skin...'), 'new', regenerate_url('action,blog', 'action=new'), T_('Install new'), 3, 4);
Exemple #2
0
/**
 * Display a blog skin setting fieldset which can be normal, mobile or tablet ( used on _coll_skin_settings.form.php )
 *
 * @param object Form
 * @param integer skin ID
 * @param array display params
 */
function display_skin_fieldset(&$Form, $skin_ID, $display_params)
{
    $Form->begin_fieldset($display_params['fieldset_title'] . get_manual_link('blog_skin_settings') . ' ' . $display_params['fieldset_links']);
    if (!$skin_ID) {
        // The skin ID is empty use the same as normal skin ID
        echo '<div style="font-weight:bold;padding:0.5ex;">' . T_('Same as normal skin.') . '</div>';
    } else {
        $SkinCache =& get_SkinCache();
        $edited_Skin = $SkinCache->get_by_ID($skin_ID);
        echo '<div class="skin_settings well">';
        $disp_params = array('skinshot_class' => 'coll_settings_skinshot');
        Skin::disp_skinshot($edited_Skin->folder, $edited_Skin->name, $disp_params);
        // Skin name
        echo '<div class="skin_setting_row">';
        echo '<label>' . T_('Skin name') . ':</label>';
        echo '<span>' . $edited_Skin->name . '</span>';
        echo '</div>';
        if (isset($edited_Skin->version)) {
            // Skin version
            echo '<div class="skin_setting_row">';
            echo '<label>' . T_('Skin version') . ':</label>';
            echo '<span>' . $edited_Skin->version . '</span>';
            echo '</div>';
        }
        // Skin type
        echo '<div class="skin_setting_row">';
        echo '<label>' . T_('Skin type') . ':</label>';
        echo '<span>' . $edited_Skin->type . '</span>';
        echo '</div>';
        // Containers
        if ($skin_containers = $edited_Skin->get_containers()) {
            $container_ul = '<ul><li>' . implode('</li><li>', $skin_containers) . '</li></ul>';
        } else {
            $container_ul = '-';
        }
        echo '<div class="skin_setting_row">';
        echo '<label>' . T_('Containers') . ':</label>';
        echo '<span>' . $container_ul . '</span>';
        echo '</div>';
        echo '</div>';
        echo '<div class="skin_settings_form">';
        $skin_params = $edited_Skin->get_param_definitions($tmp_params = array('for_editing' => true));
        if (empty($skin_params)) {
            // Advertise this feature!!
            echo '<p>' . T_('This skin does not provide any configurable settings.') . '</p>';
        } else {
            load_funcs('plugins/_plugin.funcs.php');
            // Check if skin settings contain at least one fieldset
            $skin_fieldsets_exist = false;
            foreach ($skin_params as $l_name => $l_meta) {
                if (isset($l_meta['layout']) && $l_meta['layout'] == 'begin_fieldset') {
                    $skin_fieldsets_exist = true;
                    break;
                }
            }
            if (!$skin_fieldsets_exist) {
                // Enclose all skin settings in single group if no group on the skin
                array_unshift($skin_params, array('layout' => 'begin_fieldset', 'label' => T_('Skin settings')));
                array_push($skin_params, array('layout' => 'end_fieldset'));
            }
            // Loop through all widget params:
            foreach ($skin_params as $l_name => $l_meta) {
                // Display field:
                autoform_display_field($l_name, $l_meta, $Form, 'Skin', $edited_Skin);
            }
        }
        echo '</div>';
    }
    $Form->end_fieldset();
}
    case 'tablet':
        $block_item_Widget->title = T_('Choose a Tablet skin');
        $display_same_as_normal = true;
        break;
    default:
        debug_die('Invalid skin type!');
}
// Get what is the current skin ID from this kind of skin type
$current_skin_ID = $edited_Blog->get_setting($skin_type . '_skin_ID', true);
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $block_item_Widget->global_icon(T_('Install new skin...'), 'new', $dispatcher . '?ctrl=skins&amp;action=new&amp;redirect_to=' . rawurlencode(url_rel_to_same_host(regenerate_url('', 'skinpage=selection', '', '&'), $admin_url)), T_('Install new'), 3, 4);
    $block_item_Widget->global_icon(T_('Keep current skin!'), 'close', regenerate_url('skinpage'), ' ' . T_('Don\'t change'), 3, 4);
}
$block_item_Widget->disp_template_replaced('block_start');
$SkinCache =& get_SkinCache();
$SkinCache->load_all();
if ($display_same_as_normal) {
    $skinshot_title = T_('Same as normal skin');
    $select_url = '?ctrl=coll_settings&tab=skin&blog=' . $edited_Blog->ID . '&amp;action=update&amp;skinpage=selection&amp;' . $skin_type . '_skin_ID=0&amp;' . url_crumb('collection');
    $disp_params = array('function' => 'select', 'selected' => $current_skin_ID == '0', 'select_url' => $select_url);
    Skin::disp_skinshot($skinshot_title, $skinshot_title, $disp_params);
}
$SkinCache->rewind();
while (($iterator_Skin =& $SkinCache->get_next()) != NULL) {
    if ($iterator_Skin->type != $skin_type) {
        // This skin cannot be used here...
        continue;
    }
    $selected = $current_skin_ID == $iterator_Skin->ID;
    $blog_skin_param = $skin_type . '_skin_ID=';
 /**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     global $Blog;
     $this->init_display($params);
     // Available XML feeds:
     echo $this->disp_params['block_start'];
     $this->disp_title($this->get_title());
     echo $this->disp_params['block_body_start'];
     echo $this->disp_params['list_start'];
     $SkinCache =& get_SkinCache();
     $SkinCache->load_by_type('feed');
     // TODO: this is like touching private parts :>
     foreach ($SkinCache->cache as $Skin) {
         if ($Skin->type != 'feed') {
             // This skin cannot be used here...
             continue;
         }
         echo $this->disp_params['item_start'];
         echo $Skin->name . ': ';
         echo '<a href="' . $Blog->get_item_feed_url($Skin->folder) . '">' . T_('Posts') . '</a>';
         if ($Blog->get_setting('allow_comments') != 'never' && $Blog->get_setting('comment_feed_content') != 'none' && $Blog->get_setting('comments_latest')) {
             echo ', <a href="' . $Blog->get_comment_feed_url($Skin->folder) . '">' . T_('Comments') . '</a>';
         }
         echo $this->disp_params['item_end'];
     }
     echo $this->disp_params['list_end'];
     // Display "info" link, if activated.
     if ($this->disp_params['disp_info_link']) {
         /**
          * @var AbstractSettings
          */
         global $global_Cache;
         $feedhlp = $global_Cache->get('feedhlp');
         if (empty($feedhlp)) {
             // Use basic default: (fp> needs serious update) -- Note: no localization because destination is in English anyway.
             $feedhlp = array(array('http://www.webreference.fr/defintions/rss-atom-xml', 'What is RSS?'));
         }
         if ($this->disp_params['info_link']) {
             $link_params = array('target' => '_blank');
         } else {
             $link_params = array('target' => '');
         }
         display_list($feedhlp, $this->disp_params['notes_start'], $this->disp_params['notes_end'], ' ', '', '', NULL, 1, $link_params);
     }
     echo $this->disp_params['block_body_end'];
     echo $this->disp_params['block_end'];
     return true;
 }
Exemple #5
0
/**
 * Display a blog skin setting fieldset which can be normal, mobile or tablet ( used on _coll_skin_settings.form.php )
 *
 * @param object Form
 * @param integer skin ID
 * @param array display params
 */
function display_skin_fieldset(&$Form, $skin_ID, $display_params)
{
    $Form->begin_fieldset($display_params['fieldset_title'] . get_manual_link('blog_skin_settings') . ' ' . $display_params['fieldset_links']);
    if (!$skin_ID) {
        // The skin ID is empty use the same as normal skin ID
        echo '<div style="font-weight:bold;padding:0.5ex;">' . T_('Same as normal skin.') . '</div>';
    } else {
        $SkinCache =& get_SkinCache();
        $edited_Skin = $SkinCache->get_by_ID($skin_ID);
        echo '<div style="float:left;width:30%">';
        $disp_params = array('skinshot_class' => 'coll_settings_skinshot');
        Skin::disp_skinshot($edited_Skin->folder, $edited_Skin->name, $disp_params);
        $Form->info(T_('Skin name'), $edited_Skin->name);
        if (isset($edited_Skin->version)) {
            $Form->info(T_('Skin version'), $edited_Skin->version);
        }
        $Form->info(T_('Skin type'), $edited_Skin->type);
        if ($skin_containers = $edited_Skin->get_containers()) {
            $container_ul = '<ul><li>' . implode('</li><li>', $skin_containers) . '</li></ul>';
        } else {
            $container_ul = '-';
        }
        $Form->info(T_('Containers'), $container_ul);
        echo '</div>';
        echo '<div style="margin-left:30%">';
        $skin_params = $edited_Skin->get_param_definitions($tmp_params = array('for_editing' => true));
        if (empty($skin_params)) {
            // Advertise this feature!!
            echo '<p>' . T_('This skin does not provide any configurable settings.') . '</p>';
        } else {
            load_funcs('plugins/_plugin.funcs.php');
            // Loop through all widget params:
            foreach ($skin_params as $l_name => $l_meta) {
                // Display field:
                autoform_display_field($l_name, $l_meta, $Form, 'Skin', $edited_Skin);
            }
        }
        echo '</div>';
    }
    $Form->end_fieldset();
}
Exemple #6
0
/**
 * Make an $url absolute according to $host, if it is not absolute yet.
 *
 * @param string URL
 * @param string Base (including protocol, e.g. 'http://example.com'); autodedected
 * @return string
 */
function url_absolute($url, $base = NULL)
{
    load_funcs('_ext/_url_rel2abs.php');
    if (is_absolute_url($url)) {
        // URL is already absolute
        return $url;
    }
    if (empty($base)) {
        // Detect current page base
        global $Blog, $ReqHost, $base_tag_set, $baseurl;
        if ($base_tag_set) {
            // <base> tag is set
            $base = $base_tag_set;
        } else {
            if (!empty($Blog)) {
                // Get original blog skin, not passed with 'tempskin' param
                $SkinCache =& get_SkinCache();
                if (($Skin = $SkinCache->get_by_ID($Blog->get_skin_ID(), false)) !== false) {
                    $base = $Blog->get_local_skins_url() . $Skin->folder . '/';
                } else {
                    // Skin not set:
                    $base = $Blog->gen_baseurl();
                }
            } else {
                // We are displaying a general page that is not specific to a blog:
                $base = $ReqHost;
            }
        }
    }
    if (($absurl = url_to_absolute($url, $base)) === false) {
        // Return relative URL in case of error
        $absurl = $url;
    }
    return $absurl;
}
Exemple #7
0
 /**
  * Get URL to display the blog with a temporary skin.
  *
  * This is used to construct the various RSS/Atom feeds
  *
  * @param string
  * @param string
  * @param boolean
  */
 function get_tempskin_url($skin_folder_name, $additional_params = '', $halt_on_error = false)
 {
     /**
      * @var SkinCache
      */
     $SkinCache =& get_SkinCache();
     if (!($Skin =& $SkinCache->get_by_folder($skin_folder_name, $halt_on_error))) {
         return NULL;
     }
     return url_add_param($this->gen_blogurl('default'), 'tempskin=' . $skin_folder_name);
 }
Exemple #8
0
/**
 * Initialize JavaScript to build and open window
 */
function echo_modalwindow_js()
{
    global $AdminUI, $Blog, $modal_window_js_initialized;
    if (!empty($modal_window_js_initialized)) {
        // Don't print out these functions twice
        return;
    }
    // TODO: asimo> Should not use AdminUI templates for the openModalWindow function. The style part should be handled by css.
    if (is_admin_page() && isset($AdminUI) && $AdminUI->get_template('modal_window_js_func') !== false) {
        // Use the modal functions from back-office skin
        $skin_modal_window_js_func = $AdminUI->get_template('modal_window_js_func');
    } elseif (!is_admin_page() && !empty($Blog)) {
        // Use the modal functions from front-office skin
        $blog_skin_ID = $Blog->get_skin_ID();
        $SkinCache =& get_SkinCache();
        $Skin =& $SkinCache->get_by_ID($blog_skin_ID, false, false);
        if ($Skin && $Skin->get_template('modal_window_js_func') !== false) {
            $skin_modal_window_js_func = $Skin->get_template('modal_window_js_func');
        }
    }
    if (!empty($skin_modal_window_js_func) && is_string($skin_modal_window_js_func) && function_exists($skin_modal_window_js_func)) {
        // Call skin function only if it exists
        call_user_func($skin_modal_window_js_func);
        $modal_window_js_initialized = true;
        return;
    }
    echo <<<JS_CODE
/*
 * Build and open modal window
 *
 * @param string HTML content
 * @param string Width value in css format
 * @param boolean TRUE - to use transparent template
 * @param string Title of modal window (Used in bootstrap)
 * @param string|boolean Button to submit a form (Used in bootstrap), FALSE - to hide bottom panel with buttons
 */
function openModalWindow( body_html, width, height, transparent, title, button )
{
\tvar overlay_class = 'overlay_page_active';
\tif( typeof transparent != 'undefined' && transparent == true )
\t{
\t\toverlay_class = 'overlay_page_active_transparent';
\t}

\tif( typeof width == 'undefined' )
\t{
\t\twidth = '560px';
\t}
\tvar style_height = '';
\tif( typeof height != 'undefined' && ( height > 0 || height != '' ) )
\t{
\t\tstyle_height = ' style="height:' + height + '"';
\t}
\tif( jQuery( '#overlay_page' ).length > 0 )
\t{ // placeholder already exist
\t\tjQuery( '#overlay_page' ).html( body_html );
\t\treturn;
\t}
\t// add placeholder for form:
\tjQuery( 'body' ).append( '<div id="screen_mask"></div><div id="overlay_wrap" style="width:' + width + '"><div id="overlay_layout"><div id="overlay_page"' + style_height + '></div></div></div>' );
\tjQuery( '#screen_mask' ).fadeTo(1,0.5).fadeIn(200);
\tjQuery( '#overlay_page' ).html( body_html ).addClass( overlay_class );
\tjQuery( document ).on( 'click', '#close_button, #screen_mask, #overlay_page', function( e )
\t{
\t\tif( jQuery( this ).attr( 'id' ) == 'overlay_page' )
\t\t{
\t\t\tvar form_obj = jQuery( '#overlay_page form' );
\t\t\tif( form_obj.length )
\t\t\t{
\t\t\t\tvar top = form_obj.position().top + jQuery( '#overlay_wrap' ).position().top;
\t\t\t\tvar bottom = top + form_obj.height();
\t\t\t\tif( ! ( e.clientY > top && e.clientY < bottom ) )
\t\t\t\t{
\t\t\t\t\tcloseModalWindow();
\t\t\t\t}
\t\t\t}
\t\t\treturn true;
\t\t}
\t\tcloseModalWindow();
\t\treturn false;
\t} );
}

/**
 * Close modal window
 */
function closeModalWindow( document_obj )
{
\tif( typeof( document_obj ) == 'undefined' )
\t{
\t\tdocument_obj = window.document;
\t}

\tjQuery( '#overlay_page', document_obj ).hide();
\tjQuery( '.action_messages', document_obj).remove();
\tjQuery( '#server_messages', document_obj ).insertBefore( '.first_payload_block' );
\tjQuery( '#overlay_wrap', document_obj ).remove();
\tjQuery( '#screen_mask', document_obj ).remove();
\treturn false;
}

// Close ajax popup if Escape key is pressed:
jQuery(document).keyup(function(e)
{
\tif( e.keyCode == 27 )
\t{
\t\tcloseModalWindow();
\t}
} );
JS_CODE;
    $modal_window_js_initialized = true;
}
Exemple #9
0
/**
 * Check a settings from user for Back office and from skin for Front office
 *
 * @param string Setting name ( gender_colored OR bubbletip)
 * @return bool Use colored gender
 */
function check_setting($setting_name)
{
    global $Settings, $Blog, $SkinCache;
    if (!isset($Blog) && !is_admin_page()) {
        // If we use some page without blog data
        return false;
    }
    if (is_admin_page()) {
        // Check setting in the Back office
        if ($Settings->get($setting_name)) {
            // Set TRUE if the setting is ON
            return true;
        }
    } else {
        // Check setting in the Front office for current blog & skin
        global $Blog, $SkinCache;
        if (!isset($SkinCache)) {
            // Init $SkinCache if it doesn't still exist
            $SkinCache =& get_SkinCache();
        }
        $skin =& $SkinCache->get_by_ID($Blog->get('skin_ID'));
        if ($skin->get_setting($setting_name)) {
            // If setting is ON for current Blog & Skin
            if ($setting_name == 'bubbletip') {
                // Check separate case for setting 'bubbletip'
                if (is_logged_in() || $Settings->get($setting_name . '_anonymous')) {
                    // If user is logged in OR Anonymous user can see bubbletips
                    return true;
                }
            } else {
                // Setting 'gender_colored' doesn't depend on user's logged status
                return true;
            }
        }
    }
    return false;
}
Exemple #10
0
 /**
  * Check if current user has access to this blog depending on settings
  *
  * @return boolean TRUE on success
  */
 function check_access()
 {
     global $Messages, $skins_path, $ads_current_skin_path, $ReqURL, $disp;
     $allow_access = $this->get_setting('allow_access');
     if ($allow_access == 'public') {
         // Everyone has an access to this blog
         return true;
     }
     if (in_array($disp, array('login', 'lostpassword', 'register', 'help', 'msgform', 'access_requires_login'))) {
         // Don't restrict these pages
         return true;
     }
     /**
      * $allow_access == 'users' || 'members'
      */
     if (!is_logged_in()) {
         // Only logged in users have an access to this blog
         $Messages->add(T_('You need to log in before you can access this section.'), 'error');
         $login_Blog =& get_setting_Blog('login_blog_ID');
         if ($login_Blog && $login_Blog->ID != $this->ID) {
             // If this collection is not used for login actions,
             // Redirect to login form on "access_requires_login.main.php":
             header_redirect(get_login_url('no access to blog', NULL, false, NULL, 'access_requires_loginurl'), 302);
             // will have exited
         } else {
             // This collection is used for login actions
             // Don't redirect, just display a login form of this collection:
             $disp = 'access_requires_login';
             // Set redirect_to param to current url in order to display a requested page after login action:
             global $ReqURI;
             param('redirect_to', 'url', $ReqURI);
         }
     } elseif ($allow_access == 'members') {
         // Check if current user is member of this blog
         global $current_User;
         if (!$current_User->check_perm('blog_ismember', 'view', false, $this->ID)) {
             // Force disp to restrict access for current user
             $disp = 'access_denied';
             $Messages->add(T_('You are not a member of this section, therefore you are not allowed to access it.'), 'error');
             $blog_skin_ID = $this->get_skin_ID();
             if (!empty($blog_skin_ID)) {
                 // Use 'access_denied.main.php' instead of real template when current User is not a member of this blog
                 $template = 'access_denied.main.php';
                 $SkinCache =& get_SkinCache();
                 $Skin =& $SkinCache->get_by_ID($blog_skin_ID);
                 $ads_current_skin_path = $skins_path . $Skin->folder . '/';
                 $skin_template_name = $ads_current_skin_path . $template;
                 if (file_exists($skin_template_name)) {
                     // Display a special template of this skin
                     require $skin_template_name;
                     exit;
                 } else {
                     // Display a template from site skins
                     siteskin_include($template);
                     exit;
                 }
             }
         }
     }
     return true;
 }
    /**
     * Create Options for TinyMCE.init() (non-compressor) - not TinyMCE_GZ.init (compressor)!!
     *
     * @todo fp> valid_elements to try to generate less validation errors
     *
     * @param string simple|expert
     * @return string|false
     */
    function get_tmce_init($edit_layout)
    {
        global $Blog;
        global $Plugins;
        global $localtimenow, $debug, $rsc_url, $skins_url;
        global $UserSettings;
        global $ReqHost;
        $tmce_plugins_array = array('more', 'pagebreak', 'searchreplace', 'inlinepopups', 'table', 'media', 'visualchars', 'nonbreaking', 'safari', 'fullscreen');
        // Requires cURL extension since fsockopen + ssl produce fatal error
        // if PHP configured without openSSL
        if (extension_loaded('curl')) {
            $tmce_plugins_array[] = 'spellchecker';
        }
        $tmce_theme_advanced_buttons1_array = array();
        $tmce_theme_advanced_buttons2_array = array();
        $tmce_theme_advanced_buttons3_array = array();
        $tmce_theme_advanced_buttons4_array = array();
        if ($UserSettings->get('control_form_abortions')) {
            // Activate bozo validator: autosave plugin in TinyMCE
            $tmce_plugins_array[] = 'autosave';
        }
        if ($this->UserSettings->get('tmce_options_contextmenu') == 1) {
            $tmce_plugins_array[] = 'contextmenu';
        }
        if ($edit_layout == 'inskin') {
            // In-skin editing mode
            /* ----------- button row 1 ------------ */
            $tmce_theme_advanced_buttons1_array = array('bold,italic,strikethrough,forecolor,backcolor', 'fontselect,fontsizeselect', 'removeformat', 'nonbreaking,charmap', 'image,media');
            /* ----------- button row 2 ------------ */
            $tmce_theme_advanced_buttons2_array = array('formatselect,styleselect', 'bullist,numlist', 'outdent,indent', 'justifyleft,justifycenter,justifyright,justifyfull', 'morebtn,pagebreak', 'fullscreen');
            /* ----------- button row 3 ------------ */
            $tmce_theme_advanced_buttons3_array = array('link,unlink', 'undo,redo', 'search,replace');
        } else {
            // Simple & Expert modes
            /* ----------- button row 1 ------------ */
            $tmce_theme_advanced_buttons1_array = array('bold,italic,strikethrough,forecolor,backcolor', 'fontselect,fontsizeselect', 'removeformat', 'nonbreaking,charmap', 'image,media', 'link,unlink', 'fullscreen');
            /* ----------- button row 2 ------------ */
            $tmce_theme_advanced_buttons2_array = array('formatselect,styleselect', 'bullist,numlist', 'outdent,indent', 'justifyleft,justifycenter,justifyright,justifyfull', 'morebtn,pagebreak', 'undo,redo', 'search,replace');
        }
        if ($edit_layout == 'expert') {
            // Simple needs to be simpler than expert
            /* ----------- button row 3 ------------ */
            $tmce_theme_advanced_buttons3_array = array('visualchars,visualaid', 'table,row_props,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,row_after,row_before,split_cells,merge_cells', 'sub,sup');
            if ($this->UserSettings->get('tmce_options_directionality') == 1) {
                $tmce_plugins_array[] = 'directionality';
                array_push($tmce_theme_advanced_buttons3_array, 'ltr,rtl');
            }
            if ($this->UserSettings->get('tmce_options_paste') == 1) {
                $tmce_plugins_array[] = 'paste';
                $tmce_theme_advanced_buttons3_array[] = 'pastetext,pasteword';
            }
            // Requires cURL extension since fsockopen + ssl produce fatal error
            // if PHP configured without openSSL
            if (extension_loaded('curl')) {
                $tmce_theme_advanced_buttons3_array[] = 'spellchecker';
            }
            $tmce_theme_advanced_buttons3_array[] = 'code,cleanup,|,help';
            /* ----------- button row 4 ------------ */
            $tmce_theme_advanced_buttons4_array = array();
            if ($this->UserSettings->get('tmce_options_xhtmlxtras') == 1) {
                array_push($tmce_plugins_array, 'xhtmlxtras');
                array_push($tmce_theme_advanced_buttons4_array, 'cite,abbr,acronym,del,ins');
            }
            $tmce_theme_advanced_buttons4_array = $Plugins->get_trigger_event("tinymce_extend_buttons", array("tinymce_buttons" => $tmce_theme_advanced_buttons4_array), "tinymce_buttons");
        }
        $tmce_theme_advanced_buttons1 = implode(',|,', $tmce_theme_advanced_buttons1_array);
        $tmce_theme_advanced_buttons2 = implode(',|,', $tmce_theme_advanced_buttons2_array);
        $tmce_theme_advanced_buttons3 = implode(',|,', $tmce_theme_advanced_buttons3_array);
        $tmce_theme_advanced_buttons4 = implode(',|,', $tmce_theme_advanced_buttons4_array);
        // PLUGIN EXTENSIONS:
        $tmce_plugins_array = $Plugins->get_trigger_event("tinymce_extend_plugins", array("tinymce_plugins" => $tmce_plugins_array), "tinymce_plugins");
        $tmce_plugins = implode(',', $tmce_plugins_array);
        global $current_locale, $plugins_path;
        $tmce_language = substr($current_locale, 0, 2);
        // waltercruz> Fallback to english if there's no tinymce equivalent to the user locale
        // to avoid some strange screens like http://www.flickr.com/photos/waltercruz/3390729964/
        $lang_path = $plugins_path . $this->classname . '/tiny_mce/langs/' . $tmce_language . '.js';
        if (!file_exists($lang_path)) {
            $tmce_language = 'en';
        }
        // Configuration: -- http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
        $init_options = array();
        // Convert one specifc textarea to use TinyMCE:
        $init_options[] = 'mode : "exact"';
        $init_options[] = 'elements : "' . $this->tmce_editor_id . '"';
        // TinyMCE Theme+Skin+Variant to use:
        $init_options[] = 'theme : "advanced"';
        $init_options[] = 'skin : "o2k7"';
        $init_options[] = 'skin_variant : "silver"';
        // comma separated list of plugins: -- http://wiki.moxiecode.com/index.php/TinyMCE:Plugins
        $init_options[] = 'plugins : "' . $tmce_plugins . '"';
        $init_options[] = 'more_separator : "<!--more-->"';
        $init_options[] = 'pagebreak_separator : "<!--nextpage-->"';
        // Toolbars:
        $init_options[] = 'theme_advanced_toolbar_location : "top"';
        $init_options[] = 'theme_advanced_toolbar_align : "center"';
        // just to be consistent with current toolbars for now
        $init_options[] = 'theme_advanced_buttons1 : "' . $tmce_theme_advanced_buttons1 . '"';
        $init_options[] = 'theme_advanced_buttons2 : "' . $tmce_theme_advanced_buttons2 . '"';
        $init_options[] = 'theme_advanced_buttons3 : "' . $tmce_theme_advanced_buttons3 . '"';
        $init_options[] = 'theme_advanced_buttons4 : "' . $tmce_theme_advanced_buttons4 . '"';
        // UI options:
        $init_options[] = 'theme_advanced_blockformats : "p,pre,blockquote,h2,h3,h4,h5,h6,address,dt,dd,div"';
        $init_options[] = 'theme_advanced_path_location : "bottom"';
        $init_options[] = 'theme_advanced_resizing : true';
        $init_options[] = 'theme_advanced_resize_horizontal : false';
        $init_options[] = 'language : "' . $tmce_language . '"';
        // body_class : "my_class"
        // CSS used in the iframe/editable area: -- http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/content_css
        // note: $version may not be needed below because of automatic suffix? not sure..
        // TODO: we don't want all of basic.css here
        // Load the appropriate ITEM/POST styles depending on the blog's skin:
        // dh>This has to be the skins whole CSS to get real WYSIWYG handling.
        // fp> we are not aiming for perfect wysiwyg (too heavy), just for a relevant look & feel.
        // dh>We can/should use class_filter to only keep useful classes.
        // fp> how???
        $content_css = '';
        $blog_skin_ID = $Blog->get_skin_ID();
        if (!empty($blog_skin_ID)) {
            $SkinCache =& get_SkinCache();
            /**
             * @var Skin
             */
            $Skin = $SkinCache->get_by_ID($blog_skin_ID);
            $item_css_url = $skins_url . $Skin->folder . '/item.css';
            // else: $item_css_url = $rsc_url.'css/item_base.css';
            $content_css .= ',' . $item_css_url;
            // fp> TODO: this needs to be a param... "of course" -- if none: else item_default.css ?
        }
        // else item_default.css -- is it still possible to have no skin ?
        $init_options[] = 'content_css : "' . $this->get_plugin_url() . 'editor.css?v=' . ($debug ? $localtimenow : $this->version) . $content_css . '"';
        /* fp> the following seems like something that filters classes but the way it's done doesn't make sense to me.
           fp> the skin should provide a list of classes to include (with a default setting in the default skin class)
        		// Add callback which filters classes from content_css by classname and/or rule
        		// Another option would be to use theme_advanced_styles (http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/theme_advanced_styles)
        		$init_options[] = 'class_filter : function(cls, rule) {
        			var m = rule.match(/^\.bPost (.*)/);
        			if( m ) {
        				return cls;
        			}
        
        			if( cls == "center" || cls == "right" || cls == "left" ) { // TODO: dh> could get translated
        				return cls;
        			}
        
        			// console.log(cls, rule);
        			return false;
        		}';
        */
        // Generated HTML code options:
        // do not make the path relative to "document_base_url":
        $init_options[] = 'relative_urls : false';
        $init_options[] = 'entity_encoding : "raw"';
        // remove_linebreaks : false,
        // not documented:	auto_cleanup_word : true,
        $init = implode(",\n", $init_options) . ',
			plugin_insertdate_dateFormat : "%Y-%m-%d",
			plugin_insertdate_timeFormat : "%H:%M:%S",

			paste_create_paragraphs : true,
			paste_create_linebreaks : true,
			paste_use_dialog : true,
			paste_convert_headers_to_strong : false,
			paste_convert_middot_lists : true

		';
        // custom conf:
        if ($tmce_custom_conf = $this->Settings->get('tmce_custom_conf')) {
            $init .= ",\n// tmce_custom_conf (from PluginSettings):\n" . $tmce_custom_conf;
        }
        return $init;
    }
Exemple #12
0
/**
 * Check a settings from user for Back office and from skin for Front office
 *
 * @param string Setting name ( gender_colored OR bubbletip)
 * @return bool Use colored gender
 */
function check_setting($setting_name)
{
    global $Settings, $Blog;
    if (is_admin_page() || empty($Blog)) {
        // Check setting in the Back office or when Blog is not defined
        if ($Settings->get($setting_name)) {
            // Set TRUE if the setting is ON
            return true;
        }
    } else {
        // Check setting in the Front office for current blog & skin
        $SkinCache =& get_SkinCache();
        $skin =& $SkinCache->get_by_ID($Blog->get('skin_ID'));
        if ($skin->get_setting($setting_name)) {
            // If setting is ON for current Blog & Skin
            if ($setting_name == 'bubbletip') {
                // Check separate case for setting 'bubbletip'
                if (is_logged_in() || $Settings->get($setting_name . '_anonymous')) {
                    // If user is logged in OR Anonymous user can see bubbletips
                    return true;
                }
            } else {
                // Setting 'gender_colored' doesn't depend on user's logged status
                return true;
            }
        }
    }
    return false;
}
Exemple #13
0
 /**
  * Load template params from current skin
  */
 function load_template()
 {
     $params = array('toolbar_before' => '<div class="edit_toolbar $toolbar_class$">', 'toolbar_after' => '</div>', 'toolbar_title_before' => '', 'toolbar_title_after' => '', 'toolbar_group_before' => '', 'toolbar_group_after' => ' ', 'toolbar_button_class' => 'quicktags');
     if (is_admin_page()) {
         // Get plugin template from backoffice skin
         if (is_logged_in()) {
             global $current_User, $UserSettings, $adminskins_path;
             $admin_skin = $UserSettings->get('admin_skin', $current_User->ID);
             require_once $adminskins_path . $admin_skin . '/_adminUI.class.php';
             $AdminUI = new AdminUI();
             $skin_template = $AdminUI->get_template('plugin_template');
         }
     } else {
         // Get plugin template from frontoffice skin
         global $Blog;
         if (!empty($Blog)) {
             $skin_ID = $Blog->get_skin_ID();
             $SkinCache =& get_SkinCache();
             if ($Skin =& $SkinCache->get_by_ID($skin_ID, false, false)) {
                 $skin_template = $Skin->get_template('plugin_template');
             }
         }
     }
     if (empty($skin_template)) {
         // Use default template params when they are not set by skin
         $this->template = $params;
     } else {
         // Merge default params with current skin params
         $this->template = array_merge($params, $skin_template);
     }
 }
    /**
     * Create Options for TinyMCE.init() (non-compressor) - not TinyMCE_GZ.init (compressor)!!
     *
     * @todo fp> valid_elements to try to generate less validation errors
     *
     * @param string simple|expert
     * @return string|false
     */
    function get_tmce_init($edit_layout)
    {
        global $Blog;
        global $Plugins;
        global $localtimenow, $debug, $rsc_url, $rsc_path, $skins_url;
        global $UserSettings;
        global $ReqHost;
        $tmce_plugins_array = array('image', 'importcss', 'link', 'pagebreak', 'morebreak', 'textcolor', 'media', 'nonbreaking', 'charmap', 'fullscreen', 'table', 'searchreplace', 'autocomplete');
        if (function_exists('enchant_broker_init')) {
            // Requires Enchant spelling library
            $tmce_plugins_array[] = 'spellchecker';
        }
        $tmce_theme_advanced_buttons1_array = array();
        $tmce_theme_advanced_buttons2_array = array();
        $tmce_theme_advanced_buttons3_array = array();
        $tmce_theme_advanced_buttons4_array = array();
        if ($UserSettings->get('control_form_abortions')) {
            // Activate bozo validator: autosave plugin in TinyMCE
            $tmce_plugins_array[] = 'autosave';
        }
        if ($this->UserSettings->get('tmce_options_contextmenu') == 1) {
            $tmce_plugins_array[] = 'contextmenu';
        }
        if ($edit_layout == 'inskin') {
            // In-skin editing mode
            /* ----------- button row 1 ------------ */
            $tmce_theme_advanced_buttons1_array = array('bold italic strikethrough forecolor backcolor', 'removeformat', 'nonbreaking charmap', 'image media', 'fontselect fontsizeselect', 'bullist numlist', 'outdent indent');
            /* ----------- button row 2 ------------ */
            $tmce_theme_advanced_buttons2_array = array('formatselect styleselect', 'alignleft aligncenter alignright alignjustify', 'pagebreak');
            /* ----------- button row 3 ------------ */
            $tmce_theme_advanced_buttons3_array = array('link unlink', 'undo redo', 'searchreplace', 'fullscreen');
        } else {
            // Simple & Expert modes
            /* ----------- button row 1 ------------ */
            $tmce_theme_advanced_buttons1_array = array('bold italic strikethrough forecolor backcolor', 'fontselect fontsizeselect', 'removeformat', 'nonbreaking charmap', 'image media', 'link unlink', 'fullscreen');
            /* ----------- button row 2 ------------ */
            $tmce_theme_advanced_buttons2_array = array('formatselect styleselect', 'bullist numlist', 'outdent indent', 'alignleft aligncenter alignright alignjustify', 'morebreak pagebreak', 'undo redo', 'searchreplace');
        }
        if ($edit_layout == 'expert') {
            // Simple needs to be simpler than expert
            $tmce_plugins_array[] = 'visualchars code';
            /* ----------- button row 3 ------------ */
            $tmce_theme_advanced_buttons3_array = array('visualchars', 'table', 'subscript superscript');
            if ($this->UserSettings->get('tmce_options_directionality') == 1) {
                $tmce_plugins_array[] = 'directionality';
                array_push($tmce_theme_advanced_buttons3_array, 'ltr rtl');
            }
            if ($this->UserSettings->get('tmce_options_paste') == 1) {
                $tmce_plugins_array[] = 'paste';
                $tmce_theme_advanced_buttons3_array[] = 'pastetext';
            }
            if (function_exists('enchant_broker_init')) {
                // Requires Enchant spelling library
                $tmce_theme_advanced_buttons3_array[] = 'spellchecker';
            }
            $tmce_theme_advanced_buttons3_array[] = 'code';
            /* ----------- button row 4 ------------ */
            $tmce_theme_advanced_buttons4_array = array();
            $tmce_theme_advanced_buttons4_array = $Plugins->get_trigger_event("tinymce_extend_buttons", array("tinymce_buttons" => $tmce_theme_advanced_buttons4_array), "tinymce_buttons");
        }
        $tmce_theme_advanced_buttons1 = implode(' | ', $tmce_theme_advanced_buttons1_array);
        $tmce_theme_advanced_buttons2 = implode(' | ', $tmce_theme_advanced_buttons2_array);
        $tmce_theme_advanced_buttons3 = implode(' | ', $tmce_theme_advanced_buttons3_array);
        $tmce_theme_advanced_buttons4 = implode(' | ', $tmce_theme_advanced_buttons4_array);
        // PLUGIN EXTENSIONS:
        $tmce_plugins_array = $Plugins->get_trigger_event("tinymce_extend_plugins", array("tinymce_plugins" => $tmce_plugins_array), "tinymce_plugins");
        $tmce_plugins = implode(',', $tmce_plugins_array);
        global $current_locale, $plugins_path;
        $tmce_language = substr($current_locale, 0, 2);
        // waltercruz> Fallback to english if there's no tinymce equivalent to the user locale
        // to avoid some strange screens like http://www.flickr.com/photos/waltercruz/3390729964/
        $lang_path = $rsc_path . 'js/tiny_mce/langs/' . $tmce_language . '.js';
        if (!file_exists($lang_path)) {
            $tmce_language = 'en';
        }
        // Configuration: -- http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
        $init_options = array();
        // Convert one specifc textarea to use TinyMCE:
        $init_options[] = 'selector : "textarea#' . $this->tmce_editor_id . '"';
        // TinyMCE Theme+Skin+Variant to use:
        $init_options[] = 'theme : "modern"';
        $init_options[] = 'menubar : false';
        // comma separated list of plugins: -- http://wiki.moxiecode.com/index.php/TinyMCE:Plugins
        $init_options[] = 'plugins : "' . $tmce_plugins . '"';
        $init_options[] = 'external_plugins: {
				"morebreak"    : "' . $rsc_url . 'js/tiny_mce/plugins/morebreak/plugin.min.js"
			}';
        $init_options[] = 'morebreak_separator : "[teaserbreak]"';
        $init_options[] = 'pagebreak_separator : "[pagebreak]"';
        // Toolbars:
        $init_options[] = 'toolbar1: "' . $tmce_theme_advanced_buttons1 . '"';
        $init_options[] = 'toolbar2: "' . $tmce_theme_advanced_buttons2 . '"';
        $init_options[] = 'toolbar3: "' . $tmce_theme_advanced_buttons3 . '"';
        $init_options[] = 'toolbar4: "' . $tmce_theme_advanced_buttons4 . '"';
        // Context menu:
        $init_options[] = 'contextmenu: "cut copy paste | link image | inserttable"';
        // UI options:
        $init_options[] = 'block_formats : "Paragraph=p;Preformatted=pre;Block Quote=blockquote;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Definition Term=dt;Definition Description=dd;DIV=div"';
        $init_options[] = 'resize : true';
        $init_options[] = 'language : "' . $tmce_language . '"';
        $init_options[] = 'language_url : "' . $rsc_url . 'js/tiny_mce/langs/' . $tmce_language . '.js"';
        if (function_exists('enchant_broker_init')) {
            // Requires Enchant spelling library
            $init_options[] = 'spellchecker_rpc_url: \'spellchecker.php\'';
        }
        // body_class : "my_class"
        // CSS used in the iframe/editable area: -- http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/content_css
        // note: $version may not be needed below because of automatic suffix? not sure..
        // TODO: we don't want all of basic.css here
        // Load the appropriate ITEM/POST styles depending on the blog's skin:
        // Note: we are not aiming for perfect wysiwyg (too heavy), just for a relevant look & feel.
        $content_css = '';
        $blog_skin_ID = $Blog->get_skin_ID();
        if (!empty($blog_skin_ID)) {
            $SkinCache =& get_SkinCache();
            /**
             * @var Skin
             */
            $Skin = $SkinCache->get_by_ID($blog_skin_ID);
            $item_css_url = $skins_url . $Skin->folder . '/item.css';
            // else: $item_css_url = $rsc_url.'css/item_base.css';
            $content_css .= ',' . $item_css_url;
            // fp> TODO: this needs to be a param... "of course" -- if none: else item_default.css ?
        }
        // else item_default.css -- is it still possible to have no skin ?
        // Load the content css files from 3rd party code, e.g. other plugins:
        global $tinymce_content_css;
        if (is_array($tinymce_content_css) && count($tinymce_content_css)) {
            $content_css .= ',' . implode(',', $tinymce_content_css);
        }
        $init_options[] = 'content_css : "' . $this->get_plugin_url() . 'editor.css?v=' . ($debug ? $localtimenow : $this->version) . $content_css . '"';
        // Generated HTML code options:
        // do not make the path relative to "document_base_url":
        $init_options[] = 'relative_urls : false';
        $init_options[] = 'entity_encoding : "raw"';
        // Autocomplete options
        $init_options[] = 'autocomplete_options: autocomplete_static_options';
        // Must be initialize before as string with usernames that are separated by comma
        $init_options[] = 'autocomplete_options_url: htsrv_url + "anon_async.php?action=autocomplete_usernames"';
        // remove_linebreaks : false,
        // not documented:	auto_cleanup_word : true,
        $init = implode(",\n", $init_options);
        // custom conf:
        if ($tmce_custom_conf = $this->Settings->get('tmce_custom_conf')) {
            $init .= ",\n// tmce_custom_conf (from PluginSettings):\n" . $tmce_custom_conf;
        }
        return $init;
    }