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


PHP tplUseTvs函数代码示例

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


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

示例1: 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

示例2: 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");
    }
}
开发者ID:Fiberalph,项目名称:evolution-jp,代码行数:57,代码来源:colors.php

示例3: 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);
        }
    }
}
开发者ID:radist,项目名称:modx.evo.custom,代码行数:64,代码来源:colors.php

示例4: mm_ddYMap

/**
 * mm_ddYMap
 * @version 1.4.3 (2013-12-10)
 * 
 * @desc A widget for ManagerManager plugin allowing Yandex Maps integration.
 * 
 * @uses ManagerManager plugin 0.6.
 * 
 * @param $tvs {comma separated string} - TV names to which the widget is applied. @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: ''.
 * @param $w {'auto'; integer} - Width of the map container. Default: 'auto'.
 * @param $h {integer} - Height of the map container. Default: 400.
 * @param $hideField {boolean} - Original coordinates field hiding status (true — hide, false — show). Default: true.
 * 
 * @event OnDocFormPrerender
 * @event OnDocFormRender
 * 
 * @link http://code.divandesign.biz/modx/mm_ddymap/1.4.3
 * 
 * @copyright 2013, DivanDesign
 * http://www.DivanDesign.biz
 */
function mm_ddYMap($tvs, $roles = '', $templates = '', $w = 'auto', $h = '400', $hideField = true)
{
    if (!useThisRule($roles, $templates)) {
        return;
    }
    global $modx;
    $e =& $modx->Event;
    if ($e->name == 'OnDocFormPrerender') {
        //The main js file including
        $output = includeJsCss($modx->config['site_url'] . 'assets/plugins/managermanager/widgets/ddymap/jquery.ddMM.mm_ddYMap.js', 'html', 'jquery.ddMM.mm_ddYMap', '1.0.2');
        //The Yandex.Maps library including
        $output .= includeJsCss('http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU&onload=mm_ddYMap_init', 'html', 'api-maps.yandex.ru', '2.0');
        $e->output($output);
    } else {
        if ($e->name == 'OnDocFormRender') {
            global $mm_current_page;
            $output = '';
            //if we've been supplied with a string, convert it into an array
            $tvs = makeArray($tvs);
            $usedTvs = tplUseTvs($mm_current_page['template'], $tvs, '', 'id', 'name');
            if ($usedTvs == false) {
                return;
            }
            $output .= "//---------- mm_ddYMap :: Begin -----\n";
            //Iterate over supplied TVs instead of doing so to the result of tplUseTvs() to maintain rendering order.
            foreach ($tvs as $tv) {
                //If this $tv is used in a current template
                if (isset($usedTvs[$tv])) {
                    $output .= '
$j("#tv' . $usedTvs[$tv]['id'] . '").mm_ddYMap({
	hideField: ' . intval($hideField) . ',
	width: "' . $w . '",
	height: "' . $h . '"
});
';
                }
            }
            $output .= "//---------- mm_ddYMap :: End -----\n";
            $e->output($output);
        }
    }
}
开发者ID:myindexlike,项目名称:modx.evo.custom,代码行数:65,代码来源:ddymap.php

示例5: mm_ddGMap

/**
 * mm_ddGMap
 * @version 1.2b (2014-05-14)
 * 
 * @desc Widget for ManagerManager plugin allowing Google Maps integration.
 * 
 * @uses ManagerManager plugin 0.6.1.
 * 
 * @param $tvs {comma separated string} - TV names to which the widget is applied. @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: ''.
 * @param $w {'auto'; integer} - Width of the map container. Default: 'auto'.
 * @param $h {integer} - Height of the map container. Default: 400.
 * @param $hideField {0; 1} - Original coordinates field hiding status (1 — hide, 0 — show). Default: 1.
 * 
 * @link http://code.divandesign.biz/modx/mm_ddgmap/1.2b
 * 
 * @copyright 2014, DivanDesign
 * http://www.DivanDesign.biz
 */
function mm_ddGMap($tvs, $roles = '', $templates = '', $w = 'auto', $h = '400', $hideField = true)
{
    if (!useThisRule($roles, $templates)) {
        return;
    }
    global $modx;
    $e =& $modx->Event;
    if ($e->name == 'OnDocFormPrerender') {
        global $modx_lang_attribute;
        //The main js file including
        $output = includeJsCss($modx->config['site_url'] . 'assets/plugins/managermanager/widgets/ddgmap/jquery.ddMM.mm_ddGMap.js', 'html', 'jquery.ddMM.mm_ddGMap', '1.0');
        //The Google.Maps library including
        $output .= includeJsCss('http://maps.google.com/maps/api/js?sensor=false&hl=' . $modx_lang_attribute . '&callback=mm_ddGMap_init', 'html', 'maps.google.com', '0');
        $e->output($output);
    } else {
        if ($e->name == 'OnDocFormRender') {
            global $mm_current_page;
            $output = '';
            $tvs = makeArray($tvs);
            $usedTvs = tplUseTvs($mm_current_page['template'], $tvs, '', 'id', 'name');
            if ($usedTvs == false) {
                return;
            }
            $output .= "//---------- mm_ddGMap :: Begin -----\n";
            //Iterate over supplied TVs instead of doing so to the result of tplUseTvs() to maintain rendering order.
            foreach ($tvs as $tv) {
                //If this $tv is used in a current template
                if (isset($usedTvs[$tv])) {
                    $output .= '
$j("#tv' . $usedTvs[$tv]['id'] . '").mm_ddGMap({
	hideField: ' . intval($hideField) . ',
	width: "' . $w . '",
	height: "' . $h . '"
});
';
                }
            }
            $output .= "//---------- mm_ddGMap :: End -----\n";
            $e->output($output);
        }
    }
}
开发者ID:radist,项目名称:modx.evo.custom,代码行数:62,代码来源:ddgmap.php

示例6: mm_widget_template

function mm_widget_template($fields, $other_param = 'defaultValue', $roles = '', $templates = '')
{
    global $modx, $content, $mm_fields;
    $e =& $modx->Event;
    if (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
        $output = '';
        // 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
        // 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'];
        }
        $count = tplUseTvs($content['template'], $fields);
        if ($count == false) {
            return;
        }
        // We always put a JS comment, which makes debugging much easier
        $output .= "//  -------------- Widget name ------------- \n";
        // 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'];
        }
    }
    // end if
    $e->output($output . "\n");
    // Send the output to the browser
}
开发者ID:myindexlike,项目名称:MODX.plugins,代码行数:41,代码来源:!template.php

示例7: mm_widget_googlemap

function mm_widget_googlemap($fields, $googleApiKey = '', $default = '', $roles = '', $templates = '')
{
    global $modx, $mm_fields, $mm_current_page, $modx_lang_attribute;
    $e =& $modx->event;
    if (useThisRule($roles, $templates)) {
        $output = '';
        $fields = makeArray($fields);
        $count = tplUseTvs($mm_current_page['template'], $fields);
        if ($count == false) {
            return;
        }
        $output .= "//  -------------- googlemap widget ------------- \n";
        $output .= includeJs($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/googlemap/googlemap.js');
        $output .= includeJs("http://maps.google.com/maps?file=api&sensor=false&key={$googleApiKey}&async=2&hl={$modx_lang_attribute}");
        foreach ($fields as $targetTv) {
            $tv_id = $mm_fields[$targetTv]['fieldname'];
            $output .= "googlemap('{$tv_id}','{$default}');";
        }
        $e->output($output . "\n");
        // Send the output to the browser
    }
}
开发者ID:Fiberalph,项目名称:evolution-jp,代码行数:22,代码来源:googlemap.php

示例8: mm_ddNumericFields

/**
 * mm_ddNumericFields
 * @version 1.1.1 (2013-12-11)
 * 
 * A widget for ManagerManager plugin denying using any chars in TV fields but numeric.
 * 
 * @uses ManagerManager plugin 0.6.
 * 
 * @param $tvs {comma separated string} - TV names to which the widget is applied. @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. Default: ''.
 * @param $allowFloat {0; 1} - Float number availability status (1 — float numbers may be used, 0 — float numbers using is not available). Default: 1.
 * @param $decimals {integer} - Number of chars standing after comma (0 — any). Default: 0.
 * 
 * @link http://code.divandesign.biz/modx/mm_ddnumericfields/1.1.1
 * 
 * @copyright 2013, DivanDesign
 * http://www.DivanDesign.biz
 */
function mm_ddNumericFields($tvs = '', $roles = '', $templates = '', $allowFloat = 1, $decimals = 0)
{
    global $modx, $mm_current_page;
    $e =& $modx->Event;
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $tvs = tplUseTvs($mm_current_page['template'], $tvs);
        if ($tvs == false) {
            return;
        }
        $output = '';
        $output .= "//---------- mm_ddNumericFields :: Begin -----\n";
        foreach ($tvs as $tv) {
            $output .= '
$j("#tv' . $tv['id'] . '").ddNumeric({
	allowFloat: ' . intval($allowFloat) . ',
	decimals: ' . intval($decimals) . '
});
';
        }
        $output .= "//---------- mm_ddNumericFields :: End -----\n";
        $e->output($output);
    }
}
开发者ID:radist,项目名称:modx.evo.custom,代码行数:42,代码来源:ddnumericfields.php

示例9: mm_widget_showimagetvs

/**
 * mm_widget_showimagetvs
 * @version 1.2.1 (2014-05-07)
 * 
 * @desc A widget for ManagerManager plugin that allows the preview of images chosen in image TVs to be shown on the document editing page.
 * Emulates showimagestv plugin, which is not compatible with ManagerManager.
 * 
 * @uses ManagerManager plugin 0.6.1.
 * 
 * @param $tvs {comma separated string} - The name(s) of the template variables this should apply to. Default: ''.
 * @param $maxWidth {integer} - Preferred maximum width of the preview. Default: 300.
 * @param $maxHeight {integer} - Preferred maximum height of the preview. Default: 100.
 * @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_widget_showimagetvs/1.2.1
 * 
 * @copyright 2014
 */
function mm_widget_showimagetvs($tvs = '', $maxWidth = 300, $maxHeight = 100, $thumbnailerUrl = '', $roles = '', $templates = '')
{
    if (!useThisRule($roles, $templates)) {
        return;
    }
    global $modx;
    $e =& $modx->Event;
    if ($e->name == 'OnDocFormPrerender') {
        //The main js file including
        $output = includeJsCss($modx->config['site_url'] . 'assets/plugins/managermanager/widgets/showimagetvs/jquery.ddMM.mm_widget_showimagetvs.js', 'html', 'jquery.ddMM.mm_widget_showimagetvs', '1.0.1');
        $e->output($output);
    } else {
        if ($e->name == 'OnDocFormRender') {
            global $mm_current_page;
            $output = '';
            // Does this page's template use any image TVs? If not, quit now!
            $tvs = tplUseTvs($mm_current_page['template'], $tvs, 'image');
            if ($tvs == false) {
                return;
            }
            $output .= "//---------- mm_widget_showimagetvs :: Begin -----\n";
            // Go through each TV
            foreach ($tvs as $tv) {
                $output .= '
$j("#tv' . $tv['id'] . '").mm_widget_showimagetvs({
	thumbnailerUrl: "' . trim($thumbnailerUrl) . '",
	width: ' . intval($maxWidth) . ',
	height: ' . intval($maxHeight) . ',
});
';
            }
            $output .= "//---------- mm_widget_showimagetvs :: End -----\n";
            $e->output($output);
        }
    }
}
开发者ID:radist,项目名称:modx.evo.custom,代码行数:55,代码来源:showimagetvs.php

示例10: mm_ddGMap

/**
 * mm_ddGMap
 * @version 1.1.1 (2012-11-13)
 * 
 * Позволяет интегрировать карту Google Maps для получения координат.
 * 
 * @uses ManagerManager plugin 0.4.
 * 
 * @param $tvs {string; comma separated string} - Имя TV, для которой необходимо применить виджет.
 * @param $roles {string; comma separated string} - Роли, для которых необходимо применить виждет, пустое значение — все роли. По умолчанию: ''.
 * @param $templates {string; comma separated string} - Шаблоны, для которых необходимо применить виджет, пустое значение — все шаблоны. По умолчанию: ''.
 * @param $w {string; integer} - Ширина контейнера с картой. По умолчанию: 'auto'.
 * @param $h {integer} - Высота контейнера с картой. По умолчанию: 400.
 * @param $hideField {boolean} - Необходимо ли скрывать оригинальное текстовое поле с координатами. По умолчанию: true.
 * 
 * @link http://code.divandesign.biz/modx/mm_ddgmap/1.1.1
 * 
 * @copyright 2012, DivanDesign
 * http://www.DivanDesign.biz
 */
function mm_ddGMap($tvs, $roles = '', $templates = '', $w = 'auto', $h = '400', $hideField = true)
{
    global $modx, $content, $mm_fields, $modx_lang_attribute;
    $e =& $modx->Event;
    if ($e->name == 'OnDocFormRender' && useThisRule($roles, $templates)) {
        $output = '';
        // if we've been supplied with a string, convert it into an array
        $tvs = makeArray($tvs);
        // 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'];
        }
        $tvs = tplUseTvs($page_template, $tvs);
        if ($tvs == false) {
            return;
        }
        $style = 'width: ' . $w . 'px; height: ' . $h . 'px; position: relative; border: 1px solid #c3c3c3;';
        // We always put a JS comment, which makes debugging much easier
        $output .= "//  -------------- mm_ddGMap :: Begin ------------- \n";
        // Do something for each of the fields supplied
        foreach ($tvs as $tv) {
            // 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 = 'tv' . $tv['id'];
            $output .= '
//TV с координатами
var coordFieldId = "' . $tv_id . '", $coordinatesField = $j("#" + coordFieldId);
//Координаты
var ddLatLng = $coordinatesField.val();

//Родитель
var $coordFieldParent = $coordinatesField.parents("tr:first");
//Запоминаем название поля
var sectionName = $coordFieldParent.find(".warning").text();

//Скрываем родителя и разделитель
$coordFieldParent.hide().prev("tr").hide();

//Контейнер для карты
var $sectionConteiner = $j("<div class=\\"sectionHeader\\">" + sectionName + "</div><div class=\\"sectionBody tmplvars\\"><div class=\\"ddGMap" + coordFieldId + "\\" style=\\"' . $style . '\\"></div></div>");
//Добавляем контейнер
$coordinatesField.parents(".tab-page:first").append($sectionConteiner);

//Если скрывать не надо, засовываем перед картой
if (!' . intval($hideField) . '){
	$coordinatesField.insertBefore(".ddGMap" + coordFieldId);
}

//Если координаты не заданны, то задаём дефолт
if(ddLatLng == "") ddLatLng = "55.19396010947335,61.3670539855957";
ddLatLng = ddLatLng.split(",");

//Callback функция для GM
window.ddgminitialize = function(){
	var GM = google.maps;
	var myOptions = {
		zoom: 15,
		center: new GM.LatLng(ddLatLng[0],ddLatLng[1]),
		mapTypeId: GM.MapTypeId.ROADMAP,
		streetViewControl: false,
		scrollwheel: false
	};
	var map = new GM.Map($sectionConteiner.find(".ddGMap" + coordFieldId).get(0), myOptions);
	//Добавляем маркер на карту
	var GMMarker = new GM.Marker({
		position: new GM.LatLng(ddLatLng[0],ddLatLng[1]),
		map: map,
		draggable: true
	});
	//При перетаскивании маркера
	GM.event.addListener(GMMarker, "drag", function(event){
		var position = event.latLng;//Координаты
		$coordinatesField.val(position.lat() + "," + position.lng());//Сохраняем значение в поле
	});
	//При клике на карте
	GM.event.addListener(map, "click", function(event){
//.........这里部分代码省略.........
开发者ID:Fiberalph,项目名称:evolution-jp,代码行数:101,代码来源:ddgmap.php

示例11: mm_ddSelectDocuments

/**
 * mm_ddSelectDocuments
 * @version 1.2.2 (2014-02-14)
 * 
 * @desc A widget for ManagerManager that makes selection of documents ids easier.
 * 
 * @uses ManagerManager 0.6.
 * @uses ddTools 0.10.
 * 
 * @param $tvs {comma separated string} - TVs names that the widget is applied to. @required
 * @param $roles {comma separated string} - 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} - Templates IDs for which the widget is applying (empty value means the widget is applying to all templates). Default: ''.
 * @param $parentIds {comma separated string} - Parent documents IDs. @required
 * @param $depth {integer} - Depth of search. Default: 1.
 * @param $filter {separated string} - Filter clauses, separated by '&' between pairs and by '=' between keys and values. For example, 'template=15&published=1' means to choose the published documents with template id=15. Default: ''.
 * @param $max {integer} - The largest number of elements that can be selected by user (“0” means selection without a limit). Default: 0.
 * @param $labelMask {string} - Template to be used while rendering elements of the document selection list. It is set as a string containing placeholders for document fields and TVs. Also, there is the additional placeholder “[+title+]” that is substituted with either “menutitle” (if defined) or “pagetitle”. Default: '[+title+] ([+id+])'.
 * 
 * @event OnDocFormPrerender
 * @event OnDocFormRender
 * 
 * @link http://code.divandesign.biz/modx/mm_ddselectdocuments/1.2.2
 * 
 * @copyright 2014, DivanDesign
 * http://www.DivanDesign.biz
 */
function mm_ddSelectDocuments($tvs = '', $roles = '', $templates = '', $parentIds, $depth = 1, $filter = '', $max = 0, $labelMask = '[+title+] ([+id+])')
{
    if (empty($parentIds) || !useThisRule($roles, $templates)) {
        return;
    }
    global $modx;
    $e =& $modx->Event;
    $output = '';
    if ($e->name == 'OnDocFormPrerender') {
        $pluginDir = $modx->config['site_url'] . 'assets/plugins/managermanager/';
        $widgetDir = $pluginDir . 'widgets/ddselectdocuments/';
        $output .= includeJsCss($widgetDir . 'ddselectdocuments.css', 'html');
        $output .= includeJsCss($pluginDir . 'js/jquery-ui-1.10.3.min.js', 'html', 'jquery-ui', '1.10.3');
        $output .= includeJsCss($widgetDir . 'jquery.ddMultipleInput-1.2.1.min.js', 'html', 'jquery.ddMultipleInput', '1.2.1');
        $e->output($output);
    } else {
        if ($e->name == 'OnDocFormRender') {
            global $mm_current_page;
            $tvs = tplUseTvs($mm_current_page['template'], $tvs);
            if ($tvs == false) {
                return;
            }
            $filter = ddTools::explodeAssoc($filter, '&', '=');
            //Необходимые поля
            preg_match_all('~\\[\\+([^\\+\\]]*?)\\+\\]~', $labelMask, $matchField);
            $fields = array_unique(array_merge(array_keys($filter), array('pagetitle', 'id'), $matchField[1]));
            if (($title_pos = array_search('title', $fields)) !== false) {
                unset($fields[$title_pos]);
                $fields = array_unique(array_merge($fields, array('menutitle')));
            }
            //Рекурсивно получает все необходимые документы
            if (!function_exists('ddGetDocs')) {
                function ddGetDocs($parentIds = array(0), $filter = array(), $depth = 1, $labelMask = '[+pagetitle+] ([+id+])', $fields = array('pagetitle', 'id'))
                {
                    //Получаем дочерние документы текущего уровня
                    $docs = array();
                    //Перебираем всех родителей
                    foreach ($parentIds as $parent) {
                        //Получаем документы текущего родителя
                        $tekDocs = ddTools::getDocumentChildrenTVarOutput($parent, $fields, false);
                        //Если что-то получили
                        if (is_array($tekDocs)) {
                            //Запомним
                            $docs = array_merge($docs, $tekDocs);
                        }
                    }
                    $result = array();
                    //Если что-то есть
                    if (count($docs) > 0) {
                        //Перебираем полученные документы
                        foreach ($docs as $val) {
                            //Если фильтр пустой, либо не пустой и документ удовлетворяет всем условиям
                            if (empty($filter) || count(array_intersect_assoc($filter, $val)) == count($filter)) {
                                $val['title'] = empty($val['menutitle']) ? $val['pagetitle'] : $val['menutitle'];
                                //Записываем результат
                                $tmp = ddTools::parseText($labelMask, $val, '[+', '+]', false);
                                if (strlen(trim($tmp)) == 0) {
                                    $tmp = ddTools::parseText('[+pagetitle+] ([+id+])', $val, '[+', '+]', false);
                                }
                                $result[] = array('label' => $tmp, 'value' => $val['id']);
                            }
                            //Если ещё надо двигаться глубже
                            if ($depth > 1) {
                                //Сливаем результат с дочерними документами
                                $result = array_merge($result, ddGetDocs(array($val['id']), $filter, $depth - 1, $labelMask, $fields));
                            }
                        }
                    }
                    return $result;
                }
            }
            //Получаем все дочерние документы
            $docs = ddGetDocs(explode(',', $parentIds), $filter, $depth, $labelMask, $fields);
            if (count($docs) == 0) {
//.........这里部分代码省略.........
开发者ID:myindexlike,项目名称:modx.evo.custom,代码行数:101,代码来源:ddselectdocuments.php

示例12: mm_ddReadonly

/**
 * mm_ddReadonly
 * @version 1.0.1 (2013-07-13)
 *
 * @desc Makes fields only readable.
 *
 * @uses ManagerManager plugin 0.5.1.
 * 
 * @param $fields {comma separated string} - The name(s) of the document fields (or TVs) for which the widget is applying. @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} - Templates IDs for which the widget is applying (empty value means the widget is applying to all templates). Default: ''.
 *
 * @link http://code.divandesign.biz/modx/mm_ddreadonly/1.0.1
 *
 * @copyright 2013, DivanDesign
 * http://www.DivanDesign.biz
 */
function mm_ddReadonly($fields = '', $roles = '', $templates = '')
{
    global $modx, $mm_fields, $mm_current_page;
    $e =& $modx->Event;
    if (!useThisRule($roles, $templates)) {
        return;
    }
    //Перед сохранением документа
    if ($e->name == 'OnBeforeDocFormSave') {
        //Если создаётся новый документ, у него нет никакого id ещё, да и нам пофиг, т.к. никто ничего с ним всё равно не мог сделать до сохранения
        if ($e->params['mode'] == 'new') {
            return;
        }
        //ID документа
        $docId = $e->params['id'];
        //Если нужная переменная в сессии не определена, определим
        if (!is_array($_SESSION['mm_ddReadonly'])) {
            $_SESSION['mm_ddReadonly'] = array();
        }
        //Разбиваем переданные поля в массивчик
        $fields = makeArray($fields);
        //Получаем id TV. TODO: Оптимизировать, чтобы всё было в один запрос
        $tvs = tplUseTvs($mm_current_page['template'], $fields, '', 'id,name');
        //Результат
        $resultFields = array();
        //Если что-то оплучили
        if (is_array($tvs) && count($tvs) > 0) {
            $tvsNames = array();
            //Пробежимся, переделаем под удобный нам формат
            foreach ($tvs as $val) {
                $tvsNames[$val['id']] = $val['name'];
            }
            //Получаем значения TV
            $tvs = $modx->db->makeArray($modx->db->select('value,tmplvarid AS id', ddTools::$tables['site_tmplvar_contentvalues'], 'contentid=' . $docId . ' AND tmplvarid IN ' . makeSqlList(array_keys($tvsNames))));
            //Если что-то нашлось
            if (count($tvs) > 0) {
                //Пробежимся
                foreach ($tvs as $val) {
                    //Если значение не пустое
                    if ($val['value'] != '') {
                        //Запишем значения
                        $resultFields[$tvsNames[$val['id']]] = $val['value'];
                    }
                }
            }
        }
        //Перебираем поля
        foreach ($fields as $key => $val) {
            //Если такого поля нет или это TV
            if (!isset($mm_fields[$val]) || $mm_fields[$val]['tv'] == 1) {
                //Снесём
                unset($fields[$key]);
            }
        }
        if (count($fields) > 0) {
            //Получаем значения необходимых полей
            $fields = $modx->db->getRow($modx->db->select(implode(',', $fields), ddTools::$tables['site_content'], 'id=' . $docId));
            //Переберём
            foreach ($fields as $key => $val) {
                if ($val != '') {
                    $resultFields[$key] = $val;
                }
            }
        }
        //Если хоть что-то осталось
        if (count($resultFields) > 0) {
            //Сохраним значения в сессию, они нам ещё понадобятся
            $_SESSION['mm_ddReadonly'][$docId] = $resultFields;
        }
        //После сохранения документа
    } else {
        if ($e->name == 'OnDocFormSave') {
            //Если создаётся новый документ, у него нет никакого id ещё, да и нам пофиг, т.к. никто ничего с ним всё равно не мог сделать до сохранения
            if ($e->params['mode'] == 'new') {
                return;
            }
            //ID документа
            $docId = $e->params['id'];
            //Если данные о текущем документе есть
            if (is_array($_SESSION['mm_ddReadonly']) && is_array($_SESSION['mm_ddReadonly'][$docId]) && count($_SESSION['mm_ddReadonly'][$docId]) > 0) {
                //Обновляем данные документа в соответствии с тем, что было раньше
                ddTools::updateDocument($docId, $_SESSION['mm_ddReadonly'][$docId]);
                //Сносим за ненадобностью
//.........这里部分代码省略.........
开发者ID:radist,项目名称:modx.evo.custom,代码行数:101,代码来源:ddreadonly.php

示例13: getTplMatchedFields

/**
 * getTplMatchedFields
 * @version 1.0.1 (2013-11-11)
 * 
 * @desc Returns the array that contains only those of passed fields/TVs which are used in the template.
 * 
 * @param $fields {comma separated string; array} - Document fields or TVs names. @required
 * @param $tvTypes {comma separated string; array} - TVs types, e.g. image, text. Default: ''.
 * @param $tempaleId {integer} - Template ID. Default: $mm_current_page['template'].
 * 
 * @return {array; false}
 */
function getTplMatchedFields($fields, $tvTypes = '', $tempaleId = '')
{
    $fields = makeArray($fields);
    //$fields is required
    if (empty($fields)) {
        return false;
    }
    //Template of current document by default
    if (empty($tempaleId)) {
        global $mm_current_page;
        $tempaleId = $mm_current_page['template'];
    }
    //Only document fields
    $docFields = array_intersect($fields, ddTools::$documentFields);
    //If $fields contains no TVs
    if (count($docFields) == count($fields)) {
        $fields = $docFields;
    } else {
        //Get specified TVs for this template
        $fields = tplUseTvs($tempaleId, $fields, $tvTypes, 'name', 'name');
        //If there are no appropriate TVs
        if ($fields == false) {
            if (!empty($docFields)) {
                $fields = $docFields;
            }
        } else {
            $fields = array_merge(array_keys($fields), $docFields);
        }
    }
    return $fields;
}
开发者ID:AlexJS7,项目名称:church.local,代码行数:43,代码来源:utilities.inc.php

示例14: mm_ddAutoFolders

/**
 * mm_ddAutoFolders
 * @version 1.2 (2014-04-18)
 * 
 * @desc Automatically move documents (OnBeforeDocFormSave event) based on their date (publication date; any date in tv) into folders of year and month (like 2012/02/). If folders (documents) of year and month doesn`t exist they are created automatically OnBeforeDocFormSave event.
 * 
 * @uses ManagerManager plugin 0.5
 * 
 * @param $roles {comma separated string} - List of role IDs this should be applied to. Leave empty (or omit) for all roles. Default: ''.
 * @param $templates {comma separated string} - List of template IDs this should be applied to. Leave empty (or omit) for all templates. Default: ''.
 * @param $yearsParents {comma separated string} - IDs of ultimate parents (parents of the years). @required
 * @param $dateSource {string} - Name of template variable which contains the date. Default: 'pub_date'.
 * @param $yearFields {string: JSON} - Document fields and/or TVs that are required to be assigned to year documents. An associative array in JSON where the keys and values correspond field names and values respectively. Default: '{"template":0,"published":0}'.
 * @param $monthFields {string: JSON} - Document fields and/or TVs that are required to be assigned to month documents. An associative array in JSON where the keys and values correspond field names and values respectively. Default: '{"template":0,"published":0}'.
 * @param $yearPublished {0; 1} - Note this is a deprecated parameter, please, use “$yearFields”. Whether the year documents should be published? Default: —.
 * @param $monthPublished {0; 1} - Note this is a deprecated parameter, please, use “$monthFields”. Whether the month documents should be published? Default: —.
 * @param $numericMonth {boolean} - Numeric aliases for month documents. Default: false.
 * 
 * @link http://code.divandesign.biz/modx/mm_ddautofolders/1.2
 * 
 * @copyright 2014, DivanDesign
 * http://www.DivanDesign.biz
 */
function mm_ddAutoFolders($roles = '', $templates = '', $yearsParents = '', $dateSource = 'pub_date', $yearFields = '{"template":0,"published":0}', $monthFields = '{"template":0,"published":0}', $yearPublished = NULL, $monthPublished = NULL, $numericMonth = false)
{
    global $modx, $pub_date, $parent, $mm_current_page, $tmplvars, $modx_lang_attribute;
    $e =& $modx->Event;
    //$yearsParents is required
    if ($yearsParents != '' && $e->name == 'OnBeforeDocFormSave' && useThisRule($roles, $templates)) {
        $defaultFields = array('template' => 0, 'published' => 0);
        //Функция аналогична методу «$modx->getParentIds» за исключением того, что родитель = 0 тоже выставляется
        function getParentIds($id)
        {
            global $modx;
            $parents = $modx->getParentIds($id);
            //Если текущего id нет в массиве, значит его родитель = 0
            if (!isset($parents[$id])) {
                $parents[$id] = 0;
                //Если текущий документ есть, а его родителя нет, значит родитель родителя = 0
            } else {
                if (!isset($parents[$parents[$id]])) {
                    $parents[$parents[$id]] = 0;
                }
            }
            return $parents;
        }
        //Получаем всех родителей текущего документа (или его родителя, если это новый документ)
        $allParents = getParentIds(is_numeric($e->params['id']) ? $e->params['id'] : $parent);
        $yearsParents = makeArray($yearsParents);
        //Перебираем переданных родителей
        foreach ($yearsParents as $key => $val) {
            //Если текущий документ не принадлежит к переданному родителю, значит этот родитель лишний
            if (!isset($allParents[$val])) {
                unset($yearsParents[$key]);
            }
        }
        //Если остался хоть один родитель (а остаться должен только один)
        if (count($yearsParents) > 0) {
            //Сбрасываем ключи
            $yearsParents = array_values($yearsParents);
            //Если документ не относится ни к одному переданному родителю, то ничего делать не нужно
        } else {
            return;
        }
        //Текущее правило
        $rule = array();
        //Дата
        $ddDate = array();
        //Если задано, откуда брать дату и это не дата публикации, пытаемся найти в tv`шках
        if ($dateSource && $dateSource != 'pub_date') {
            //Получаем tv с датой для данного шаблона
            $dateTv = tplUseTvs($mm_current_page['template'], $dateSource);
            //Если tv удалось получить, такая tv есть и есть её значение
            if ($dateTv && $dateTv[0]['id'] && $tmplvars[$dateTv[0]['id']] && $tmplvars[$dateTv[0]['id']][1]) {
                //Если дата в юникс-времени
                if (is_numeric($tmplvars[$dateTv[0]['id']][1])) {
                    $ddDate['date'] = $tmplvars[$dateTv[0]['id']][1];
                } else {
                    //Пытаемся преобразовать в unix-время
                    $ddDate['date'] = strtotime($tmplvars[$dateTv[0]['id']][1]);
                }
            }
        } else {
            $ddDate['date'] = $pub_date;
        }
        //Если не задана дата, выбрасываем
        if (!$ddDate['date']) {
            return;
        }
        //Псевдонимы родителей (какие должны быть)
        //Год в формате 4 цифры
        $ddDate['y'] = date('Y', $ddDate['date']);
        //Псевдоним месяца (порядковый номер номер с ведущим нолём или название на английском)
        $ddDate['m'] = $numericMonth ? date('m', $ddDate['date']) : strtolower(date('F', $ddDate['date']));
        //Порядковый номер месяца
        $ddDate['n'] = date('n', $ddDate['date']);
        //Если язык админки — русский
        if (strtolower($modx_lang_attribute) == 'ru') {
            //Все месяцы на русском
            $ruMonthes = array('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь');
//.........这里部分代码省略.........
开发者ID:stoler,项目名称:offset-print,代码行数:101,代码来源:ddautofolders.php

示例15: mm_widget_tags

function mm_widget_tags($fields, $delimiter = ',', $source = '', $display_count = false, $roles = '', $templates = '')
{
    global $modx, $content, $mm_fields;
    $e =& $modx->Event;
    if (useThisRule($roles, $templates)) {
        $output = '';
        // if we've been supplied with a string, convert it into an array
        $fields = makeArray($fields);
        // And likewise for the data source (if supplied)
        $source = empty($source) ? $fields : makeArray($source);
        // 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.
        $field_tvs = tplUseTvs($page_template, $fields);
        if ($field_tvs == false) {
            return;
        }
        $source_tvs = tplUseTvs($page_template, $source);
        if ($source_tvs == false) {
            return;
        }
        // Insert some JS  and a style sheet into the head
        $output .= "//  -------------- Tag widget include ------------- \n";
        $output .= includeJs($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/tags/tags.js');
        $output .= includeCss($modx->config['base_url'] . 'assets/plugins/managermanager/widgets/tags/tags.css');
        // Go through each of the fields supplied
        foreach ($fields as $targetTv) {
            $tv_id = $mm_fields[$targetTv]['fieldname'];
            // Make an SQL friendly list of fields to look at:
            //$escaped_sources = array();
            //foreach ($source as $s) {
            //$s=substr($s,2,1);
            //	$escaped_sources[] = "'".$s."'";
            //}
            $sql_sources = implode(',', $source_tvs[0]);
            // Get the list of current values for this TV
            $sql = "SELECT `value` FROM " . $modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE tmplvarid IN (" . $sql_sources . ")";
            $result = $modx->dbQuery($sql);
            $all_docs = $modx->db->makeArray($result);
            $foundTags = array();
            foreach ($all_docs as $theDoc) {
                $theTags = explode($delimiter, $theDoc['value']);
                foreach ($theTags as $t) {
                    $foundTags[trim($t)]++;
                }
            }
            // Sort the TV values (case insensitively)
            uksort($foundTags, 'strcasecmp');
            $lis = '';
            foreach ($foundTags as $t => $c) {
                $lis .= '<li title="Used ' . $c . ' times">' . jsSafe($t) . ($display_count ? ' (' . $c . ')' : '') . '</li>';
            }
            $html_list = '<ul class="mmTagList" id="' . $tv_id . '_tagList">' . $lis . '</ul>';
            // Insert the list of tags after the field
            $output .= '
				//  -------------- Tag widget for ' . $targetTv . ' (' . $tv_id . ') --------------
				$j("#' . $tv_id . '").after(\'' . $html_list . '\');
				';
            // Initiate the tagCompleter class for this field
            $output .= 'var ' . $tv_id . '_tags = new TagCompleter("' . $tv_id . '", "' . $tv_id . '_tagList", "' . $delimiter . '"); ';
        }
    }
    $e->output($output . "\n");
}
开发者ID:myindexlike,项目名称:MODX.plugins,代码行数:70,代码来源:tags.php


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