public function html($obj)
 {
     $url = CRUDCompiler::compile($this->getLink(), ['this' => $obj]);
     $text = CRUDCompiler::compile($this->getText(), ['this' => $obj]);
     if (trim($text) == '') {
         $text = '#EMPTY#';
     }
     $o = BT::a($url, $text, $this->getClassesStr());
     return $o;
 }
示例#2
0
    public static function render($content_html, $h1_str = '', $breadcrumbs_arr = [])
    {
        ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
	<!-- Latest compiled and minified JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
    <?php 
        echo BT::breadcrumbs($breadcrumbs_arr);
        ?>
    <div class="page-header">
    <h1><?php 
        echo $h1_str;
        ?>
</h1>
    </div>
    <?php 
        echo $content_html;
        ?>
</div>

</body>
</html>
<?php 
    }
示例#3
0
 public static function breadcrumbsArr()
 {
     return array_merge(DemoMainPageAction::breadcrumbsArr(), [BT::a(self::getUrl(), 'Terms')]);
 }
示例#4
0
文件: BT.php 项目: o-log/php-bt
 public static function tabHtml($text, $match_url, $link_url, $target = '')
 {
     $classes = '';
     // TODO: код взят из Router::match3() - использовать общую реализацию?
     $url_regexp = '@^' . $match_url . '$@';
     $matches_arr = array();
     $current_url = self::uri_no_getform();
     // TODO: use common request reader
     if (preg_match($url_regexp, $current_url, $matches_arr)) {
         $classes .= ' active ';
     }
     if ($link_url == '') {
         $classes .= ' disabled ';
     }
     $html = '';
     $html .= '<li role="presentation" class="' . Sanitize::sanitizeAttrValue($classes) . '">';
     $html .= BT::a($link_url, $text, '', $target);
     $html .= '</li>';
     return $html;
 }
示例#5
0
 public static function breadcrumbsArr()
 {
     return [BT::a(self::getUrl(), 'Main')];
 }
示例#6
0
 public static function breadcrumbsArr($term_id)
 {
     return array_merge(DemoTermsListAction::breadcrumbsArr(), [BT::a(self::getUrl($term_id), 'Term ' . $term_id)]);
 }
示例#7
0
 public static function breadcrumbsArr($node_id)
 {
     return array_merge(DemoNodesListAction::getBreadcrumbsArr(), [BT::a(self::getUrl($node_id), 'Node ' . $node_id)]);
 }
示例#8
0
    public static function render($content_html, $action_obj = null)
    {
        $page_toolbar_html = '';
        // запрашиваем до начала вывода на страницу, потому что там может редирект или какая-то еще работа с хидерами
        if ($action_obj) {
            if ($action_obj instanceof \OLOG\Layouts\InterfacePageToolbarHtml) {
                $page_toolbar_html = $action_obj->pageToolbarHtml();
            }
        }
        ?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
	      integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
	        integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
	        crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
	<?php 
        //$application_title = BTConfig::getApplicationTitle();
        $application_title = 'Home';
        $menu_items_arr = [];
        if ($action_obj instanceof InterfaceMenu) {
            $menu_items_arr = $action_obj::menuArr();
        }
        ?>
	<nav class="navbar navbar-inverse">
		<div class="container-fluid">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
				        data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="/"><?php 
        echo $application_title;
        ?>
</a>
			</div>

			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav">
					<?php 
        foreach ($menu_items_arr as $menu_item_obj) {
            \OLOG\Assert::assert($menu_item_obj instanceof \OLOG\Layouts\MenuItem);
            $children_arr = $menu_item_obj->getChildrenArr();
            $href = 'href="#"';
            if ($menu_item_obj->getUrl()) {
                $href = 'href="' . Sanitize::sanitizeUrl($menu_item_obj->getUrl()) . '"';
            }
            $icon = '';
            if ($menu_item_obj->getIconClassesStr()) {
                $icon = '<i class="' . $menu_item_obj->getIconClassesStr() . '"></i> ';
            }
            if (count($children_arr)) {
                ?>
							<li class="dropdown">
								<a <?php 
                echo $href;
                ?>
 class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
									<?php 
                echo $icon . Sanitize::sanitizeTagContent($menu_item_obj->getText());
                ?>
 <span class="caret"></span>
								</a>
								<ul class="dropdown-menu">
									<?php 
                /** @var  $child_menu_item_obj \OLOG\Layouts\MenuItem */
                foreach ($children_arr as $child_menu_item_obj) {
                    \OLOG\Assert::assert($child_menu_item_obj instanceof \OLOG\Layouts\MenuItem);
                    $children_href = '';
                    if ($child_menu_item_obj->getUrl()) {
                        $children_href = 'href="' . Sanitize::sanitizeUrl($child_menu_item_obj->getUrl()) . '"';
                    }
                    $children_icon = '';
                    if ($child_menu_item_obj->getIconClassesStr()) {
                        $children_icon = '<i class="' . $child_menu_item_obj->getIconClassesStr() . '"></i> ';
                    }
                    ?>
										<li>
											<a <?php 
                    echo $children_href;
                    ?>
><?php 
                    echo $children_icon . Sanitize::sanitizeTagContent($child_menu_item_obj->getText());
                    ?>
</a>
										</li>
										<?php 
                }
                ?>
								</ul>
							</li>
							<?php 
            } else {
                ?>
							<li>
								<a <?php 
                echo $href;
                ?>
><?php 
                echo $icon . Sanitize::sanitizeTagContent($menu_item_obj->getText());
                ?>
</a>
							</li>
							<?php 
            }
        }
        ?>
				</ul>
			</div><!-- /.navbar-collapse -->
		</div><!-- /.container-fluid -->
	</nav>
	<?php 
        $h1_str = '';
        //$breadcrumbs_arr = ConfWrapper::getOptionalValue(\OLOG\BT\BTConstants::MODULE_NAME . '.' . \OLOG\BT\BTConstants::BREADCRUMBS_PREFIX_ARR, []);
        //$breadcrumbs_arr = BTConfig::getBreadcrumbsPrefixArr();
        $breadcrumbs_arr = [];
        if ($action_obj) {
            /*
            if ($action_obj instanceof InterfaceBreadcrumbs) {
            	$breadcrumbs_arr = array_merge($breadcrumbs_arr, $action_obj->currentBreadcrumbsArr());
            }
            */
            if ($action_obj instanceof \OLOG\Layouts\InterfaceTopActionObj) {
                $top_action_obj = $action_obj->topActionObj();
                $extra_breadcrumbs_arr = [];
                while ($top_action_obj) {
                    $top_action_title = '#NO_TITLE#';
                    if ($top_action_obj instanceof \OLOG\Layouts\InterfacePageTitle) {
                        $top_action_title = $top_action_obj->pageTitle();
                    }
                    $top_action_url = '#NO_URL#';
                    if ($top_action_obj instanceof InterfaceAction) {
                        $top_action_url = $top_action_obj->url();
                    }
                    array_unshift($extra_breadcrumbs_arr, HTML::a($top_action_url, $top_action_title));
                    $top_action_obj = null;
                    if ($top_action_obj instanceof \OLOG\Layouts\InterfaceTopActionObj) {
                        $top_action_obj = $top_action_obj->topActionObj();
                    }
                }
                $breadcrumbs_arr = array_merge($breadcrumbs_arr, $extra_breadcrumbs_arr);
            }
            if ($action_obj instanceof \OLOG\Layouts\InterfacePageTitle) {
                $h1_str = $action_obj->pageTitle();
            }
        }
        if (!empty($breadcrumbs_arr)) {
            echo BT::breadcrumbs($breadcrumbs_arr);
        }
        ?>
	<div class="page-header">
		<h1>
			<?php 
        echo $h1_str;
        ?>
			<?php 
        if ($page_toolbar_html != '') {
            echo '<span>' . $page_toolbar_html . '</span>';
        }
        ?>
		</h1>
	</div>
	<?php 
        echo $content_html;
        ?>
</div>
</body>
</html>
<?php 
    }
    public function htmlForValue($field_value, $input_name = null)
    {
        $field_name = $this->getFieldName();
        if (is_null($input_name)) {
            $input_name = $field_name;
        }
        $referenced_class_name = $this->getReferencedClassName();
        $referenced_class_title_field = $this->getReferencedClassTitleField();
        $referenced_obj_title = '';
        $disabled_btn_link = 'disabled';
        $is_null_value = '';
        if (is_null($field_value)) {
            $is_null_value = "1";
        }
        if (!is_null($field_value)) {
            $referenced_obj = CRUDObjectLoader::createAndLoadObject($referenced_class_name, $field_value);
            $referenced_obj_title = CRUDFieldsAccess::getObjectFieldValue($referenced_obj, $referenced_class_title_field);
            $disabled_btn_link = '';
        }
        $is_required_str = '';
        if ($this->is_required) {
            $is_required_str = ' required ';
        }
        $html = '';
        $html .= Preloader::preloaderJsHtml();
        $select_element_id = 'js_select_' . rand(1, 999999);
        $choose_form_element_id = 'collapse_' . rand(1, 999999);
        $html .= '<input type="hidden" id="' . Sanitize::sanitizeAttrValue($select_element_id) . '" name="' . Sanitize::sanitizeAttrValue($input_name) . '" value="' . $field_value . '" data-field="' . Sanitize::sanitizeAttrValue($select_element_id) . '_text" ' . $is_required_str . '/>';
        $html .= '<input type="hidden" id="' . Sanitize::sanitizeAttrValue($select_element_id) . '_is_null" name="' . Sanitize::sanitizeAttrValue($input_name) . '___is_null" value="' . $is_null_value . '"/>';
        $html .= '<div class="input-group">';
        if ($this->getAjaxActionUrl()) {
            $html .= '<span class="input-group-btn">';
            $html .= '<button type="button" class="btn btn-default" data-toggle="modal" data-target="#' . $choose_form_element_id . '"><span class="glyphicon glyphicon-folder-open"></span></button>';
            $html .= '<button type="button" id="' . Sanitize::sanitizeAttrValue($select_element_id) . '_btn_is_null" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span></button>';
            $html .= '</span>';
        }
        $html .= '<div class="form-control" id="' . Sanitize::sanitizeAttrValue($select_element_id) . '_text">' . $referenced_obj_title . '</div>';
        if ($this->getEditorUrl()) {
            $html .= '<span class="input-group-btn">';
            $html .= '<button ' . $disabled_btn_link . ' type="button" id="' . Sanitize::sanitizeAttrValue($select_element_id) . '_btn_link" class="btn btn-default">Перейти</button>';
            $html .= '</span>';
        }
        $html .= '</div>';
        $html .= BT::modal($choose_form_element_id, 'Выбрать');
        ob_start();
        ?>

        <script>
            $('#<?php 
        echo $choose_form_element_id;
        ?>
').on('hidden.bs.modal', function () {
	            $('#<?php 
        echo $choose_form_element_id;
        ?>
 .modal-body').html('');
            });

            $('#<?php 
        echo $choose_form_element_id;
        ?>
').on('shown.bs.modal', function (e) {
	            OLOG.preloader.show();
                $.ajax({
                    url: "<?php 
        echo $this->getAjaxActionUrl();
        ?>
"
                }).success(function(received_html) {
                    $('#<?php 
        echo $choose_form_element_id;
        ?>
 .modal-body').html(received_html);
	                OLOG.preloader.hide();
                });
            });

            $('#<?php 
        echo $choose_form_element_id;
        ?>
').on('click', '.js-ajax-form-select', function (e) {
            	e.preventDefault();
                var select_id = $(this).data('id');
                var select_title = $(this).data('title');
				$('#<?php 
        echo $choose_form_element_id;
        ?>
').modal('hide');
				$('#<?php 
        echo $select_element_id;
        ?>
_text').text(select_title);
                $('#<?php 
        echo $select_element_id;
        ?>
_btn_link').attr('disabled', false);
				$('#<?php 
        echo $select_element_id;
        ?>
').val(select_id).trigger('change');
				$('#<?php 
        echo $select_element_id;
        ?>
_is_null').val('');
			});

			$('#<?php 
        echo $select_element_id;
        ?>
_btn_is_null').on('click', function (e) {
				e.preventDefault();
				$('#<?php 
        echo $select_element_id;
        ?>
_text').text('');
                $('#<?php 
        echo $select_element_id;
        ?>
_btn_link').attr('disabled', true);
				$('#<?php 
        echo $select_element_id;
        ?>
').val('').trigger('change');
				$('#<?php 
        echo $select_element_id;
        ?>
_is_null').val(1);
			});

            $('#<?php 
        echo $select_element_id;
        ?>
_btn_link').on('click', function (e) {
                var url = '<?php 
        echo $this->getEditorUrl();
        ?>
';
                var id = $('#<?php 
        echo $select_element_id;
        ?>
').val();
                url = url.replace('REFERENCED_ID', id);

                window.location = url;
            });
        </script>

        <?php 
        $html .= ob_get_clean();
        return $html;
    }