当前位置: 首页>>代码示例>>PHP>>正文


PHP useThisRule函数代码示例

本文整理汇总了PHP中useThisRule函数的典型用法代码示例。如果您正苦于以下问题:PHP useThisRule函数的具体用法?PHP useThisRule怎么用?PHP useThisRule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了useThisRule函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mm_minimizablesections

function mm_minimizablesections($sections, $roles = '', $templates = '', $minimized = '')
{
    if (!useThisRule($roles, $templates)) {
        return;
    }
    global $modx;
    $e =& $modx->Event;
    $site = $modx->config['site_url'];
    $widgetDir = $site . 'assets/plugins/managermanager/widgets/mm_minimizablesections/';
    $output = '';
    if ($e->name == 'OnDocFormPrerender') {
        $output .= includeJsCss($widgetDir . 'minimizablesections.css', 'html');
        $e->output($output);
    } else {
        if ($e->name == 'OnDocFormRender') {
            $sections = makeArray($sections);
            $minimized = makeArray($minimized);
            $sections = array_map("prepareSection", $sections);
            $minimized = array_map("prepareSection", $minimized);
            $output .= "//---------- mm_minimizablesections :: Begin -----\n";
            $output .= '$j("' . implode(",", $sections) . '","#documentPane").addClass("minimizable").on("click",function(){
     var _t = $j(this);
     _t.next().slideToggle(400,function(){_t.toggleClass("minimized");})
    });
    $j(".minimizable").filter("' . implode(",", $minimized) . '").addClass("minimized").next().hide();
  ';
            $output .= "//---------- mm_minimizablesections :: End -----\n";
            $e->output($output);
        }
    }
}
开发者ID:foxcoonn,项目名称:modx.evo.custom,代码行数:31,代码来源:mm_minimizablesections.php

示例2: mm_renameTab

/**
 * mm_renameTab
 * @version 1.1 (2012-11-13)
 * 
 * Rename a tab.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @link http://code.divandesign.biz/modx/mm_renametab/1.1
 * 
 * @copyright 2012
 */
function mm_renameTab($tab, $newname, $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->event;
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $output = "//  -------------- mm_renameTab :: Begin ------------- \n";
        switch ($tab) {
            case 'general':
                $output .= '$j("div#documentPane h2:nth-child(1) span").empty().prepend("' . jsSafe($newname) . '");' . "\n";
                break;
            case 'settings':
                $output .= '$j("div#documentPane h2:nth-child(2) span").empty().prepend("' . jsSafe($newname) . '");' . "\n";
                break;
                // This is =<1.0.0 only
            // This is =<1.0.0 only
            case 'meta':
                if ($modx->hasPermission('edit_doc_metatags') && $modx->config['show_meta'] != "0") {
                    $output .= '$j("div#documentPane h2:nth-child(3) span").empty().prepend("' . jsSafe($newname) . '");' . "\n";
                }
                break;
                // This is 1.0.1 specific
            // This is 1.0.1 specific
            case 'access':
                $access_index = $modx->config['show_meta'] == "0" ? 3 : 4;
                $output .= '$j("div#documentPane h2:nth-child(' . $access_index . ') span").empty().prepend("' . jsSafe($newname) . '");' . "\n";
                break;
        }
        $output .= "//  -------------- mm_renameTab :: End ------------- \n";
        $e->output($output . "\n");
    }
}
开发者ID:Fiberalph,项目名称:evolution-jp,代码行数:44,代码来源:mm_renametab.php

示例3: mm_hideSections

/**
 * mm_hideSections
 * @version 1.2.1 (2014-05-25)
 * 
 * @desc A widget for ManagerManager plugin that allows one or a few sections to be hidden on the document edit page.
 * 
 * @uses ManagerManager plugin 0.6.2.
 * 
 * @param $sections {comma separated string} - The id(s) of the sections this should apply to. @required
 * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''.
 * @param $templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). Default: ''.
 * 
 * @link http://code.divandesign.biz/modx/mm_hidesections/1.2.1
 * 
 * @copyright 2014
 */
function mm_hideSections($sections, $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->Event;
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        // if we've been supplied with a string, convert it into an array
        $sections = makeArray($sections);
        $output = "//---------- mm_hideSections :: Begin -----\n";
        foreach ($sections as $section) {
            switch ($section) {
                case 'access':
                    // These have moved to tabs in 1.0.1
                    $output .= '$j("#sectionAccessHeader, #sectionAccessBody").hide();' . "\n";
                    break;
                default:
                    $section = prepareSectionId($section);
                    $output .= '$j("#' . $section . '_header, #' . $section . '_body").hide();' . "\n";
                    break;
            }
        }
        $output .= "//---------- mm_hideSections :: End -----\n";
        $e->output($output);
    }
}
开发者ID:myindexlike,项目名称:modx.evo.custom,代码行数:41,代码来源:mm_hidesections.php

示例4: mm_widget_template

/**
 * mm_widget_template
 * @version 1.0 (2013-01-01)
 *
 * A template for creating new widgets
 *
 * @uses ManagerManager plugin 0.4.
 *
 * @link http://
 *
 * @copyright 2013
 */
function mm_widget_template($fields, $other_param = 'defaultValue', $roles = '', $templates = '')
{
    global $modx, $mm_fields, $mm_current_page;
    $e =& $modx->event;
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        // Your output should be stored in a string, which is outputted at the end
        // It will be inserted as a Javascript block (with jQuery), which is executed on document ready
        // We always put a JS comment, which makes debugging much easier
        $output = "//  -------------- mm_widget_template :: Begin ------------- \n";
        // if we've been supplied with a string, convert it into an array
        $fields = makeArray($fields);
        // You might want to check whether the current page's template uses the TVs that have been
        // supplied, to save processing page which don't contain them
        $count = tplUseTvs($mm_current_page['template'], $fields);
        if ($count == false) {
            return;
        }
        // We have functions to include JS or CSS external files you might need
        // The standard ModX API methods don't work here
        $output .= includeJs('assets/plugins/managermanager/widgets/template/javascript.js');
        $output .= includeCss('assets/plugins/managermanager/widgets/template/styles.css');
        // Do something for each of the fields supplied
        foreach ($fields as $targetTv) {
            // If it's a TV, we may need to map the field name, to what it's ID is.
            // This can be obtained from the mm_fields array
            $tv_id = $mm_fields[$targetTv]['fieldname'];
        }
        //JS comment for end of widget
        $output .= "//  -------------- mm_widget_template :: End ------------- \n";
        // Send the output to the browser
        $e->output($output . "\n");
    }
}
开发者ID:Fiberalph,项目名称:evolution-jp,代码行数:45,代码来源:!template.php

示例5: mm_changeFieldHelp

/**
 * mm_changeFieldHelp
 * @version 1.1.1 (2013-05-20)
 *
 * Change the help text of a field.
 * 
 * @uses ManagerManager plugin 0.5.
 * 
 * @param $field {string} - The name of the document field (or TV) this should apply to. @required
 * @param $helptext {string} - The new help text. @required
 * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''.
 * @param $templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). Default: ''.
 * 
 * @link http://code.divandesign.biz/modx/mm_changefieldhelp/1.1.1
 * 
 * @copyright 2013
 */
function mm_changeFieldHelp($field, $helptext = '', $roles = '', $templates = '')
{
    global $mm_fields, $modx;
    $e =& $modx->Event;
    if ($helptext == '') {
        return;
    }
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $output = "//  -------------- mm_changeFieldHelp :: Begin ------------- \n";
        // What type is this field?
        if (isset($mm_fields[$field])) {
            $fieldtype = $mm_fields[$field]['fieldtype'];
            $fieldname = $mm_fields[$field]['fieldname'];
            //Is this TV?
            if ($mm_fields[$field]['tv']) {
                $output .= '$j("' . $fieldtype . '[name=' . $fieldname . ']").parents("td:first").prev("td").children("span.comment").html("' . jsSafe($helptext) . '");';
                //Or document field
            } else {
                // Give the help button an ID, and modify the alt/title text
                $output .= '$j("' . $fieldtype . '[name=' . $fieldname . ']").siblings("img[style*=\'cursor:help\']").attr("id", "' . $fieldname . '-help").attr("alt", "' . jsSafe($helptext) . '").attr("title", "' . jsSafe($helptext) . '"); ';
            }
        }
        $output .= "//  -------------- mm_changeFieldHelp :: End ------------- \n";
        $e->output($output . "\n");
    }
}
开发者ID:AlexJS7,项目名称:church.local,代码行数:44,代码来源:mm_changefieldhelp.php

示例6: mm_hideFields

/**
 * mm_hideFields
 * @version 1.1.2 (2014-05-07)
 * 
 * @desc A widget for ManagerManager plugin that allows one or more of the default document fields or template variables to be hidden within the manager.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @param $fields {comma separated string} - The name(s) of the document fields (or TVs) this should apply to. @required
 * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''.
 * @param $templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). Default: ''.
 * 
 * @link http://code.divandesign.biz/modx/mm_hidefields/1.1.2
 * 
 * @copyright 2014
 */
function mm_hideFields($fields, $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->Event;
    // if we've been supplied with a string, convert it into an array
    $fields = makeArray($fields);
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        global $mm_fields;
        $output = "//---------- mm_hideFields :: Begin -----\n";
        foreach ($fields as $field) {
            switch ($field) {
                // Exceptions
                case 'keywords':
                    $output .= '$j("select[name*=\'keywords\']").parent("td").hide();' . "\n";
                    break;
                case 'metatags':
                    $output .= '$j("select[name*\'=metatags\']").parent("td").hide()' . "\n";
                    break;
                case 'hidemenu':
                case 'hide_menu':
                case 'show_in_menu':
                    $output .= '$j("input[name=\'hidemenucheck\']").parent("td").hide();' . "\n";
                    break;
                case 'menuindex':
                    $output .= '$j("input[name=\'menuindex\']").parents("table").parent("td").prev("td").children("span.warning").hide();' . "\n";
                    $output .= '$j("input[name=\'menuindex\']").parent("td").hide();' . "\n";
                    break;
                case 'which_editor':
                    $output .= '$j("select#which_editor").prev("span.warning").hide();' . "\n";
                    $output .= '$j("select#which_editor").hide();' . "\n";
                    break;
                case 'content':
                    $output .= '$j("#sectionContentHeader, #sectionContentBody").hide();' . "\n";
                    // For 1.0.0
                    $output .= '$j("#ta").parent("div").parent("div").hide().prev("div").hide();' . "\n";
                    // For 1.0.1
                    break;
                case 'pub_date':
                    $output .= '$j("input[name=\'pub_date\']").parents("tr").next("tr").hide();' . "\n";
                    $output .= '$j("input[name=\'pub_date\']").parents("tr").hide();' . "\n";
                    break;
                case 'unpub_date':
                    $output .= '$j("input[name=\'unpub_date\']").parents("tr").next("tr").hide();' . "\n";
                    $output .= '$j("input[name=\'unpub_date\']").parents("tr").hide();' . "\n";
                    break;
                    // Ones that follow the regular pattern
                // Ones that follow the regular pattern
                default:
                    if (isset($mm_fields[$field])) {
                        // Check the fields exist,  so we're not writing JS for elements that don't exist
                        $output .= '$j("' . $mm_fields[$field]['fieldtype'] . '[name=\'' . $mm_fields[$field]['fieldname'] . '\']").parents("tr").hide().next("tr").find("td[colspan=2]").parent("tr").hide();' . "\n";
                    }
                    break;
            }
            $output .= "//---------- mm_hideFields :: End -----\n";
            $e->output($output);
        }
    }
}
开发者ID:radist,项目名称:modx.evo.custom,代码行数:76,代码来源:mm_hidefields.php

示例7: mm_ddCreateSection

/** 
 * mm_ddCreateSection
 * @version 1.0 (2013-05-22)
 * 
 * @description 
 * 
 * @uses ManagerManager 0.5.
 *
 * @param $title {string} - The display name of the new section. @required
 * @param $id {string} - A unique ID for this section. @required
 * @param $tabId {string} - The ID of the tab which the section should be inserted to. Can be one of the default tab IDs or a new custom tab created with mm_createTab. Default: 'general'.
 * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''.
 * @param $templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). Default: ''.
 * 
 * @link http://code.divandesign.biz/modx/mm_ddcreatesection/1.0
 * 
 * @copyright 2013, DivanDesign
 * http://www.DivanDesign.ru
 */
function mm_ddCreateSection($title, $id, $tabId = 'general', $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->Event;
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates) && !empty($id)) {
        // We always put a JS comment, which makes debugging much easier
        $output = "\n//  -------------- mm_ddCreateSection :: Begin ------------- \n";
        if ($title == '') {
            $title = $id;
        }
        $id = prepareSectionId($id);
        $tabId = prepareTabId($tabId);
        $section = '
<div class="sectionHeader" id="' . $id . '_header">' . $title . '</div>
<div class="sectionBody" id="' . $id . '_body"><table style="position:relative;" border="0" cellspacing="0" cellpadding="3" width="100%"></table></div>
		';
        //tabGeneral
        // Clean up for js output
        $section = str_replace(array("\n", "\t", "\r"), '', $section);
        $output .= '$j("#' . $tabId . '").append(\'' . $section . '\');';
        //JS comment for end of widget
        $output .= "\n//  -------------- mm_ddCreateSection :: End ------------- \n";
        // Send the output to the browser
        $e->output($output . "\n");
    }
}
开发者ID:stoler,项目名称:offset-print,代码行数:45,代码来源:ddcreatesection.php

示例8: mm_widget_evogallery

function mm_widget_evogallery($moduleid, $title = '', $roles = '', $templates = '')
{
    global $modx, $content, $mm_fields;
    $e =& $modx->Event;
    if (useThisRule($roles, $templates)) {
        //Include language file
        $langpath = $modx->config['base_path'] . "assets/modules/evogallery/lang/";
        //First include english
        if (file_exists($langpath . 'english.inc.php')) {
            include $langpath . 'english.inc.php';
        }
        //Include current manager language
        if (file_exists($langpath . $modx->config['manager_language'] . '.inc.php')) {
            include $langpath . $modx->config['manager_language'] . '.inc.php';
        }
        $title = empty($title) ? $_lang['mm_tab_name'] : $title;
        //TODO: Add iframe autoheight
        if (isset($content['id'])) {
            $iframecontent = '<iframe id="mm_evogallery" src="' . $modx->config['site_url'] . 'manager/index.php?a=112&id=' . $moduleid . '&onlygallery=1&action=view&content_id=' . $content['id'] . '" style="width:100%;height:600px;" scrolling="auto" frameborder="0"></iframe>';
        } else {
            $iframecontent = '<p class="warning">' . $_lang['mm_save_required'] . '</p>';
        }
        mm_createTab($title, 'evogallery', '', '', '<strong>' . $_lang['mm_manage_images'] . '</strong>', '100%');
        $output = "\$j('#table-evogallery').append('<tr><td>{$iframecontent}</td></tr>');";
    }
    // end if
    $e->output($output . "\n");
    // Send the output to the browser
}
开发者ID:KiPa187,项目名称:EvoGallery,代码行数:29,代码来源:evogallery.php

示例9: mm_hideSections

/**
 * mm_hideSections
 * @version 1.1 (2012-11-13)
 * 
 * Hides sections.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @link http://code.divandesign.biz/modx/mm_hidesections/1.1
 * 
 * @copyright 2012
 */
function mm_hideSections($sections, $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->event;
    // if we've been supplied with a string, convert it into an array
    $sections = makeArray($sections);
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if (useThisRule($roles, $templates)) {
        $output = "//  -------------- mm_hideSections :: Begin ------------- \n";
        foreach ($sections as $section) {
            switch ($section) {
                case 'content':
                    $output .= '
					$j("#content_header").hide();
					$j("#content_body").hide();
					';
                    break;
                case 'tvs':
                    $output .= '
					$j("#tv_header").hide();
					$j("#tv_body").hide();
					';
                    break;
                case 'access':
                    // These have moved to tabs in 1.0.1
                    $output .= '
					$j("#sectionAccessHeader").hide();
					$j("#sectionAccessBody").hide();';
                    break;
            }
            $output .= "//  -------------- mm_hideSections :: End ------------- \n";
            $e->output($output . "\n");
        }
    }
}
开发者ID:Fiberalph,项目名称:evolution-jp,代码行数:47,代码来源:mm_hidesections.php

示例10: mm_renameSection

/**
 * mm_renameSection
 * @version 1.1 (2012-11-13)
 * 
 * Rename a section.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @link http://code.divandesign.biz/modx/mm_renamesection/1.1
 * 
 * @copyright 2012
 */
function mm_renameSection($section, $newname, $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->event;
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $output = "//  -------------- mm_renameSection :: Begin ------------- \n";
        switch ($section) {
            case 'content':
                $output .= '$j("div#content_header").empty().prepend("' . jsSafe($newname) . '");' . "\n";
                break;
            case 'tvs':
                $output .= '
				$j("div#tv_header").empty().prepend("' . jsSafe($newname) . '");
				';
                break;
            case 'access':
                // These have moved to tabs in 1.0.1
                $output .= '$j("div#sectionAccessHeader").empty().prepend("' . jsSafe($newname) . '");' . "\n";
                break;
        }
        $output .= "//  -------------- mm_renameSection :: End ------------- \n";
        $e->output($output . "\n");
    }
}
开发者ID:Fiberalph,项目名称:evolution-jp,代码行数:37,代码来源:mm_renamesection.php

示例11: mm_createTab

/**
 * mm_createTab
 * @version 1.1 (2012-11-13)
 * 
 * Create a new tab.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @link http://code.divandesign.biz/modx/mm_createtab/1.1
 * 
 * @copyright 2012
 */
function mm_createTab($name, $id, $roles = '', $templates = '', $intro = '', $width = '680')
{
    global $modx;
    $e =& $modx->Event;
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if (($e->name == 'OnDocFormRender' || $e->name == 'OnPluginFormRender') && useThisRule($roles, $templates)) {
        // Plugin page tabs use a differen name for the tab object
        $js_tab_object = $e->name == 'OnPluginFormRender' ? 'tpSnippet' : 'tpSettings';
        $output = "//  -------------- mm_createTab :: Begin ------------- \n";
        $empty_tab = '
<div class="tab-page" id="tab' . $id . '">
	<h2 class="tab">' . $name . '</h2>
	<div class="tabIntro" id="tab-intro-' . $id . '">' . $intro . '</div>
	<table width="' . $width . '" border="0" cellspacing="0" cellpadding="0" id="table-' . $id . '">
	</table>
</div>
		';
        // Clean up for js output
        $empty_tab = str_replace(array("\n", "\t", "\r"), '', $empty_tab);
        $output .= '$j';
        $output .= "('div#'+mm_lastTab).after('" . $empty_tab . "'); \n";
        $output .= "mm_lastTab = 'tab" . $id . "'; \n";
        $output .= $js_tab_object . '.addTabPage( document.getElementById( "tab' . $id . '" ) ); ';
        $output .= "//  -------------- mm_createTab :: End ------------- \n";
        $e->output($output . "\n");
    }
}
开发者ID:stoler,项目名称:offset-print,代码行数:39,代码来源:mm_createtab.php

示例12: mm_renameField

/**
 * mm_renameField
 * @version 1.2 (2013-05-16)
 *
 * Change the label for an element.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @param fields {comma separated string} - The name(s) of the document fields (or TVs) this should apply to. @required
 * @param newlabel {string} - The new text for the label. @required
 * @param roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles).
 * @param templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates).
 * @param newhelp {string} - New text for the help icon with this field or for comment with TV. The same restriction apply as when using mm_changeFieldHelp directly.
 * 
 * @link http://code.divandesign.biz/modx/mm_renamefield/1.2
 * 
 * @copyright 2013
 */
function mm_renameField($fields, $newlabel, $roles = '', $templates = '', $newhelp = '')
{
    global $mm_fields, $modx;
    $e =& $modx->Event;
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $fields = makeArray($fields);
        if (count($fields) == 0) {
            return;
        }
        $output = "//  -------------- mm_renameField :: Begin ------------- \n";
        foreach ($fields as $field) {
            $element = '';
            switch ($field) {
                // Exceptions
                case 'keywords':
                    $element = '$j("select[name*=keywords]").siblings("span.warning")';
                    break;
                case 'metatags':
                    $element = '$j("select[name*=metatags]").siblings("span.warning")';
                    break;
                case 'hidemenu':
                case 'show_in_menu':
                    $element = '$j("input[name=\'hidemenucheck\']").siblings("span.warning")';
                    break;
                case 'which_editor':
                    $element = '$j("#which_editor").prev("span.warning")';
                    break;
                case 'content':
                    $element = '$j("#content_header")';
                    break;
                case 'menuindex':
                    $element = '$j("input[name=\'menuindex\']").parents("table:first").parents("td:first").prev("td").find("span.warning")';
                    break;
                    // Ones that follow the regular pattern
                // Ones that follow the regular pattern
                default:
                    if (isset($mm_fields[$field])) {
                        $fieldtype = $mm_fields[$field]['fieldtype'];
                        $fieldname = $mm_fields[$field]['fieldname'];
                        $element = '$j("' . $fieldtype . '[name=\'' . $fieldname . '\']").parents("td:first").prev("td").children("span.warning")';
                    }
                    break;
            }
            if ($element != '') {
                $output .= $element . '.contents().filter(function(){return this.nodeType === 3;}).replaceWith("' . jsSafe($newlabel) . '");';
            }
            // If new help has been supplied, do that too
            if ($newhelp != '') {
                mm_changeFieldHelp($field, $newhelp, $roles, $templates);
            }
        }
        $output .= "//  -------------- mm_renameField :: End ------------- \n";
        $e->output($output . "\n");
    }
}
开发者ID:AlexJS7,项目名称:church.local,代码行数:74,代码来源:mm_renamefield.php

示例13: mm_hideTabs

/**
 * mm_hideTabs
 * @version 1.1 (2012-11-13)
 * 
 * Hide a tab.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @link http://code.divandesign.biz/modx/mm_hidetabs/1.1
 * 
 * @copyright 2012
 */
function mm_hideTabs($tabs, $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->Event;
    // if we've been supplied with a string, convert it into an array
    $tabs = makeArray($tabs);
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $output = "//  -------------- mm_hideTabs :: Begin ------------- \n";
        foreach ($tabs as $tab) {
            switch ($tab) {
                case 'general':
                    $output .= 'if (tpSettings.getSelectedIndex() == 0) { tpSettings.setSelectedIndex(1); } ' . "\n";
                    // if we are hiding the currently active tab, make another visible
                    $output .= '$j("div#documentPane h2:nth-child(1)").hide(); ' . "\n";
                    $output .= '$j("#tabGeneral").hide();';
                    break;
                case 'settings':
                    $output .= 'if (tpSettings.getSelectedIndex() == 1) { tpSettings.setSelectedIndex(0); } ' . "\n";
                    $output .= '$j("div#documentPane h2:nth-child(2)").hide(); ' . "\n";
                    $output .= '$j("#tabSettings").hide();';
                    break;
                    // =< v1.0.0 only
                // =< v1.0.0 only
                case 'meta':
                    if ($modx->hasPermission('edit_doc_metatags') && $modx->config['show_meta'] != "0") {
                        $output .= 'if (tpSettings.getSelectedIndex() == 2) { tpSettings.setSelectedIndex(0); } ' . "\n";
                        $output .= '$j("div#documentPane h2:nth-child(3)").hide(); ' . "\n";
                        $output .= '$j("#tabMeta").hide(); ';
                    }
                    break;
                    // Meta tags tab is removed by default in version 1.0.1+ but can still be enabled via a preference.
                    // Access tab was only added in 1.0.1
                    // Since counting the tabs is the only way of determining this, we need to know if this has been activated
                    // If meta tabs are active, the "access" tab is index 4 in the HTML; otherwise index 3.
                    // If config['show_meta'] is NULL, this is a version before this option existed, e.g. < 1.0.1
                    // For versions => 1.0.1, 0 is the default value to not show them, 1 is the option to show them.
                // Meta tags tab is removed by default in version 1.0.1+ but can still be enabled via a preference.
                // Access tab was only added in 1.0.1
                // Since counting the tabs is the only way of determining this, we need to know if this has been activated
                // If meta tabs are active, the "access" tab is index 4 in the HTML; otherwise index 3.
                // If config['show_meta'] is NULL, this is a version before this option existed, e.g. < 1.0.1
                // For versions => 1.0.1, 0 is the default value to not show them, 1 is the option to show them.
                case 'access':
                    $access_index = $modx->config['show_meta'] == "0" ? 3 : 4;
                    $output .= 'if (tpSettings.getSelectedIndex() == ' . ($access_index - 1) . ') { tpSettings.setSelectedIndex(0); } ' . "\n";
                    $output .= '$j("div#documentPane h2:nth-child(' . $access_index . ')").hide(); ' . "\n";
                    $output .= '$j("#tabAccess").hide();';
                    break;
            }
            $output .= "//  -------------- mm_hideTabs :: End ------------- \n";
            $e->output($output . "\n");
        }
    }
}
开发者ID:myindexlike,项目名称:modx.evo.custom,代码行数:67,代码来源:mm_hidetabs.php

示例14: mm_ddMoveFieldsToSection

/** 
 * mm_ddMoveFieldsToSection
 * @version 1.0.2 (2013-12-10)
 * 
 * @description Widget allows document fields & TVs to be moved in an another section. However you can’t move the following fields: keywords, metatags, which_editor, show_in_menu, menuindex.
 * 
 * @uses ManagerManager 0.6.
 * 
 * @param $fields {string} - The name(s) of the document fields (or TVs) this should apply to. @required
 * @param $sectionId {string} - The ID of the section which the fields should be moved to. @required
 * @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''.
 * @param $templates {comma separated string} - Id of the templates to which this widget is applied (when this parameter is empty then widget is applied to the all templates). Default: ''.
 * 
 * @link http://code.divandesign.biz/modx/mm_movefieldstosection/1.0.2
 * 
 * @copyright 2013, DivanDesign
 * http://www.DivanDesign.ru
 */
function mm_ddMoveFieldsToSection($fields, $sectionId, $roles = '', $templates = '')
{
    global $modx;
    $e =& $modx->Event;
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $output = "//---------- mm_ddMoveFieldsToSection :: Begin -----\n";
        $output .= '$j.ddMM.moveFields("' . $fields . '", "' . prepareSectionId($sectionId) . '_body");' . "\n";
        $output .= "//---------- mm_ddMoveFieldsToSection :: End -----\n";
        $e->output($output);
    }
}
开发者ID:radist,项目名称:modx.evo.custom,代码行数:29,代码来源:ddmovefieldstosection.php

示例15: mm_galleryLink

function mm_galleryLink($fields, $roles = '', $templates = '', $moduleid = '')
{
    global $mm_fields, $modx, $content;
    $e =& $modx->Event;
    // if we've been supplied with a string, convert it into an array
    $fields = makeArray($fields);
    // if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
    if (useThisRule($roles, $templates)) {
        $output = " // ----------- Gallery Link -------------- \n";
        foreach ($fields as $field) {
            //ignore for now
            switch ($field) {
                // ignore fields that can't be converted
                case 'keywords':
                case 'metatags':
                case 'hidemenu':
                case 'which_editor':
                case 'template':
                case 'menuindex':
                case 'show_in_menu':
                case 'parent':
                case 'is_folder':
                case 'is_richtext':
                case 'log':
                case 'searchable':
                case 'cacheable':
                case 'clear_cache':
                case 'content_type':
                case 'content_dispo':
                case 'which_editor':
                    $output .= '';
                    break;
                    // default if not ignored
                // default if not ignored
                default:
                    if (isset($mm_fields[$field])) {
                        // Check the fields exist,  so we're not writing JS for elements that don't exist
                        $output .= 'var pid' . $mm_fields[$field]['fieldname'] . ' = "' . (!empty($content['id']) ? $content['id'] : 'false') . '";' . "\n";
                        $output .= 'var gl' . $mm_fields[$field]['fieldname'] . ' = $j("' . $mm_fields[$field]['fieldtype'] . '[name=' . $mm_fields[$field]['fieldname'] . ']");' . "\n";
                        $output .= 'if(pid' . $mm_fields[$field]['fieldname'] . ' != \'false\'){' . "\n";
                        $output .= '    var galleryLink = $j(\'<a href="' . $modx->config['base_url'] . MGR_DIR . '/index.php?a=112&id=' . $moduleid . '&action=view&content_id=\'+pid' . $mm_fields[$field]['fieldname'] . '+\'">Manage Photos</a>\').insertAfter(gl' . $mm_fields[$field]['fieldname'] . ');' . "\n";
                        $output .= '} else {' . "\n";
                        $output .= '    var galleryLink = $j(\'<p class="warning">You must save this page before you can manage the photos associated with it.</p>\').insertAfter(gl' . $mm_fields[$field]['fieldname'] . ');' . "\n";
                        $output .= '}' . "\n";
                        $output .= 'gl' . $mm_fields[$field]['fieldname'] . '.hide();' . "\n";
                    }
                    break;
            }
        }
        $e->output($output . "\n");
    }
    // end if
}
开发者ID:russelgal,项目名称:EvoGallery,代码行数:53,代码来源:gallerylink.inc.php


注:本文中的useThisRule函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。