本文整理汇总了PHP中makeArray函数的典型用法代码示例。如果您正苦于以下问题:PHP makeArray函数的具体用法?PHP makeArray怎么用?PHP makeArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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);
}
}
}
示例3: 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");
}
}
示例4: 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);
}
}
示例5: 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");
}
}
}
示例6: mm_hideTabs
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 (useThisRule($roles, $templates)) {
$output = " // ----------- Hide tabs -------------- \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;
}
// end switch
$e->output($output . "\n");
}
// end foreach
}
// end if
}
示例7: 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");
}
}
示例8: createrecord
function createrecord()
{
if (isset($_POST['submit'])) {
// Check for username password and avatar
if ($_POST['password'] != null && $_POST['user'] != null) {
//prepare for output processing
function makeArray()
{
$salt = "supperDupperSalt";
$epass = md5($_POST['password'] . $salt);
$euser = $_POST['user'];
return array("USER NAME" => $euser, "Hashed PASSWORD with Dash of Salt" => $epass);
}
// Output Login Details to User
echo "<h2>CONGRATULATIONS!</h2> Sign-up was successfull!";
echo "<table width=100% align=left border=0><tr><td>";
// CONVERT array into a variable for accessing
$data = makeArray();
// FOREACH for displaying Array Contents created in makeArray Function
foreach ($data as $atrribute => $data) {
// echo "<p align=left><font color=#FF4136>{$attribute}</font>{$data}";
}
// Process Avatar Photo for Upload
$tmp_file = $_FILES['avatarfile']['tmp_name'];
// Given a string containing the path to a file/directory,
// the basename function will return the trailing name component.
$targer_file = basename($_FILES['avatarfile']['name']);
$upload_dir = "uploads";
// move_uploaded_file will return false if $tmp_file is not a valid upload file
// or if it cannot be moved for any other reason
if (move_uploaded_file($tmp_file, $upload_dir . "/" . $targer_file)) {
echo "File uploaded successfully.";
} else {
echo "<br><br> AVATAR: Np photo was uploaded.";
}
echo "<br><br><a href='?action=home'>Please try logging in Now!</a>";
//close table
echo "</td></tr></table>";
//connect to database from including file
include "DBCredentials.php";
$salt = "supperDupperSalt";
$epass = md5($_POST['password'] . $salt);
$euser = $_POST['user'];
// Prepare statement for INSERT
$stmt = $dbh->prepare("insert into users101 (username, password, avatar) \n values(:username, :password, :avatar)");
$stmt->bindParam(':username', $euser);
$stmt->bindParam(':password', $epass);
$stmt->bindParam(':avatar', $targer_file);
$stmt->execute();
} else {
echo "Sorry, you must submit ALL registration fields to proceed.";
echo "<br><br></b><a href='?action=home'>Try again?</a><br><br>";
}
}
}
示例9: 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
}
示例10: mm_synch_fields
/**
* mm_synch_fields
* @version 1.1 (2012-11-13)
*
* Synch two fields in real time.
*
* @uses ManagerManager plugin 0.4.
*
* @link http://code.divandesign.biz/modx/mm_synch_fields/1.1
*
* @copyright 2012
*/
function mm_synch_fields($fields, $roles = '', $templates = '')
{
global $modx, $mm_fields;
$e =& $modx->Event;
// if we've been supplied with a string, convert it into an array
$fields = makeArray($fields);
// We need at least 2 values
if (count($fields) < 2) {
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_synch_fields :: Begin ------------- \n";
$output .= '
synch_field[mm_sync_field_count] = new Array();
';
foreach ($fields as $field) {
if (isset($mm_fields[$field])) {
$fieldtype = $mm_fields[$field]['fieldtype'];
$fieldname = $mm_fields[$field]['fieldname'];
$valid_fieldtypes = array('input', 'textarea');
// Make sure we're dealing with an input
if (!in_array($fieldtype, $valid_fieldtypes)) {
break;
}
// Add this field to the array of fields being synched
$output .= '
synch_field[mm_sync_field_count].push($j("' . $fieldtype . '[name=' . $fieldname . ']"));
';
// Or we don't recognise it
} else {
break;
}
}
// Output some javascript to sync these fields
$output .= '
$j.each(synch_field[mm_sync_field_count], function(i, n){
$j.each(synch_field[mm_sync_field_count], function(j, m){
if (i != j){
n.keyup(function(){
m.val($j(this).val());
});
}
});
});
mm_sync_field_count++;
';
$output .= "// -------------- mm_synch_fields :: End ------------- \n";
$e->output($output . "\n");
}
}
示例11: mm_hideTemplates
function mm_hideTemplates($tplIds, $roles = '', $templates = '')
{
global $modx;
$e =& $modx->Event;
$tplIds = makeArray($tplIds);
if (useThisRule($roles, $templates)) {
$output = " // ----------- Hide templates -------------- \n";
foreach ($tplIds as $tpl) {
$output .= 'if ($j("select#template").val() != ' . $tpl . ') { ' . "\n";
$output .= '$j("select#template option[value=' . $tpl . ']").hide();' . "\n";
$output .= '}' . "\n";
}
$e->output($output . "\n");
}
}
示例12: mm_hideTemplates
/**
* mm_hideTemplates
* @version 1.1 (2012-11-13)
*
* Hide a template within the dropdown list of templates.
* Based on code submitted by Metaller
*
* @uses ManagerManager plugin 0.4.
*
* @link http://code.divandesign.biz/modx/mm_hidetemplates/1.1
*
* @copyright 2012
*/
function mm_hideTemplates($tplIds, $roles = '', $templates = '')
{
global $modx;
$e =& $modx->Event;
$tplIds = makeArray($tplIds);
if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
$output = "// -------------- mm_hideTemplates :: Begin ------------- \n";
foreach ($tplIds as $tpl) {
$output .= 'if ($j("select#template").val() != ' . $tpl . '){ ' . "\n";
$output .= '$j("select#template option[value=' . $tpl . ']").remove();' . "\n";
$output .= '}' . "\n";
}
$output .= "// -------------- mm_hideTemplates :: End ------------- \n";
$e->output($output . "\n");
}
}
示例13: mm_hideTabs
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 (useThisRule($roles, $templates)) {
$output = " // ----------- Hide tabs -------------- \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;
// Version 1.0.0 only
// Version 1.0.0 only
case 'meta':
if ($modx->hasPermission('edit_doc_metatags')) {
$output .= 'if (tpSettings.getSelectedIndex() == 2) { tpSettings.setSelectedIndex(0); } ' . "\n";
$output .= '$j("div#documentPane h2:nth-child(3)").hide(); ' . "\n";
$output .= '$j("#tabMeta").hide(); ';
}
break;
// Version 1.0.1 only
// Version 1.0.1 only
case 'access':
$output .= 'if (tpSettings.getSelectedIndex() == 2) { tpSettings.setSelectedIndex(0); } ' . "\n";
$output .= '$j("div#documentPane h2:nth-child(3)").hide(); ' . "\n";
$output .= '$j("#tabPreview").hide();';
break;
}
// end switch
$e->output($output . "\n");
}
// end foreach
}
// end if
}
示例14: mm_widget_colors
/**
* mm_widget_colors
* @version 1.1 (2012-11-13)
*
* Adds a color selection widget to the specified TVs.
*
* @uses ManagerManager plugin 0.4.
*
* @link http://code.divandesign.biz/modx/mm_widget_colors/1.1
*
* @copyright 2012
*/
function mm_widget_colors($fields, $default = '#ffffff', $roles = '', $templates = '')
{
global $modx, $mm_fields, $mm_current_page;
$e =& $modx->event;
if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
$output = '';
// if we've been supplied with a string, convert it into an array
$fields = makeArray($fields);
// Which template is this page using?
if (isset($content['template'])) {
$page_template = $content['template'];
} else {
// If no content is set, it's likely we're adding a new page at top level.
// So use the site default template. This may need some work as it might interfere with a default template set by MM?
$page_template = $modx->config['default_template'];
}
// Does this page's template use any of these TVs? If not, quit.
$tv_count = tplUseTvs($mm_current_page['template'], $fields);
if ($tv_count === false) {
return;
}
// Insert some JS
$output .= includeJs($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/colors/farbtastic.js');
// Insert some CSS
$output .= includeCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/colors/farbtastic.css');
// Go through each of the fields supplied
foreach ($fields as $tv) {
$tv_id = $mm_fields[$tv]['fieldname'];
$output .= '
// ----------- Color widget for ' . $tv_id . ' --------------
$j("#' . $tv_id . '").css("background-image","none");
$j("#' . $tv_id . '").after(\'<div id="colorpicker' . $tv_id . '"></div>\');
if ($j("#' . $tv_id . '").val() == ""){
$j("#' . $tv_id . '").val("' . $default . '");
}
$j("#colorpicker' . $tv_id . '").farbtastic("#' . $tv_id . '");
$j("#colorpicker' . $tv_id . '").mouseup(function(){
// mark the document as dirty, or the value wont be saved
$j("#' . $tv_id . '").trigger("change");
});
';
}
$e->output($output . "\n");
}
}
示例15: mm_widget_colors
/**
* mm_widget_colors
* @version 1.2 (2013-12-11)
*
* A widget for ManagerManager plugin that allows text field to be turned into a color picker storing a chosen hex value in the field on the document editing page.
*
* @uses ManagerManager plugin 0.6.
*
* @param $fields {comma separated string} - The name(s) of the template variables this should apply to. @required
* @param $default {string} - Which color in hex format should be selected by default in new documents. This is only used in situations where the TV does not have a default value specified in the TV definition. Default: '#ffffff'.
* @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: ''.
*
* @event OnDocFormPrerender
* @event OnDocFormRender
*
* @link http://code.divandesign.biz/modx/mm_widget_colors/1.2
*
* @copyright 2013
*/
function mm_widget_colors($fields, $default = '#ffffff', $roles = '', $templates = '')
{
if (!useThisRule($roles, $templates)) {
return;
}
global $modx;
$e =& $modx->Event;
$output = '';
if ($e->name == 'OnDocFormPrerender') {
$output .= includeJsCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/colors/farbtastic.js', 'html', 'farbtastic', '1.2');
$output .= includeJsCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/colors/farbtastic.css', 'html');
$e->output($output);
} else {
if ($e->name == 'OnDocFormRender') {
global $mm_current_page, $mm_fields;
// if we've been supplied with a string, convert it into an array
$fields = makeArray($fields);
// Does this page's template use any of these TVs? If not, quit.
$tv_count = tplUseTvs($mm_current_page['template'], $fields);
if ($tv_count === false) {
return;
}
$output .= "//---------- mm_widget_colors :: Begin -----\n";
// Go through each of the fields supplied
foreach ($fields as $tv) {
$tv_id = $mm_fields[$tv]['fieldname'];
$output .= '
$j("#' . $tv_id . '").css("background-image","none");
$j("#' . $tv_id . '").after(\'<div id="colorpicker' . $tv_id . '"></div>\');
if ($j("#' . $tv_id . '").val() == ""){
$j("#' . $tv_id . '").val("' . $default . '");
}
$j("#colorpicker' . $tv_id . '").farbtastic("#' . $tv_id . '");
$j("#colorpicker' . $tv_id . '").mouseup(function(){
// mark the document as dirty, or the value wont be saved
$j("#' . $tv_id . '").trigger("change");
});
';
}
$output .= "//---------- mm_widget_colors :: End -----\n";
$e->output($output);
}
}
}