Exemple #1
0
 /**
  * @param $url
  * @param $text
  * @return string
  */
 public static function a($url, $text, $classes_str = '', $target = '')
 {
     $target_str = '';
     if ($target != '') {
         $target_str = ' target="' . Sanitize::sanitizeAttrValue($target) . '" ';
     }
     return '<a class="' . Sanitize::sanitizeAttrValue($classes_str) . '" href="' . Sanitize::sanitizeUrl($url) . '"' . $target_str . '>' . Sanitize::sanitizeTagContent($text) . '</a>';
 }
 public static function renderTabs(array $tabs_arr)
 {
     echo '<ul class="nav nav-tabs">';
     foreach ($tabs_arr as $tab_arr) {
         $classes = '';
         // TODO: код взят из Router::match3() - использовать общую реализацию?
         $url_regexp = '@^' . $tab_arr['MATCH_URL'] . '$@';
         $matches_arr = array();
         $current_url = \OLOG\Router::uri_no_getform();
         if (preg_match($url_regexp, $current_url, $matches_arr)) {
             $classes .= ' active ';
         }
         echo '<li role="presentation" class="' . Sanitize::sanitizeAttrValue($classes) . '"><a href="' . Sanitize::sanitizeUrl($tab_arr['LINK_URL']) . '">' . Sanitize::sanitizeTagContent($tab_arr['TITLE']) . '</a></li>';
     }
     echo '</ul>';
 }
Exemple #3
0
 public function action()
 {
     Auth::logout();
     // remove extra cookies
     if (!empty(AuthConfig::getExtraCookiesArr())) {
         $extra_cookies_arr = AuthConfig::getExtraCookiesArr();
         foreach ($extra_cookies_arr as $cookie_name => $cookie_value) {
             //setcookie($cookie_name, $cookie_value, time() + Auth::SESSION_LIFETIME_SECONDS, '/', Auth::sessionCookieDomain());
             setcookie($cookie_name, "", 1000, '/', Auth::sessionCookieDomain(), false, true);
         }
     }
     $redirect = '/';
     if (isset($_GET['destination'])) {
         $redirect = Sanitize::sanitizeUrl($_GET['destination']);
     }
     \OLOG\Redirects::redirect($redirect);
 }
Exemple #4
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 
    }
Exemple #5
0
 /**
  * ид объекта может быть пустым - тогда при сохранении формы создаст новый объект
  * @param $obj
  * @param $element_obj_arr
  * @param string $url_to_redirect_after_save
  * @param array $redirect_get_params_arr
  * @return string html-код формы редактирования
  * @throws \Exception
  */
 public static function html($obj, $element_obj_arr, $url_to_redirect_after_save = '', $redirect_get_params_arr = [], $form_id = '', $operation_code = self::OPERATION_SAVE_EDITOR_FORM, $hide_submit_button = false)
 {
     self::executeOperations($url_to_redirect_after_save, $redirect_get_params_arr);
     $form_element_id = 'formElem_' . uniqid();
     if ($form_id) {
         $form_element_id = $form_id;
     }
     $html = '';
     $html .= '<form id="' . $form_element_id . '" class="form-horizontal" role="form" method="post" action="' . Sanitize::sanitizeUrl(\OLOG\Url::getCurrentUrl()) . '">';
     $html .= Operations::operationCodeHiddenField($operation_code);
     $html .= '<input type="hidden" name="' . self::FIELD_CLASS_NAME . '" value="' . Sanitize::sanitizeAttrValue(get_class($obj)) . '">';
     $html .= '<input type="hidden" name="' . self::FIELD_OBJECT_ID . '" value="' . Sanitize::sanitizeAttrValue(CRUDFieldsAccess::getObjId($obj)) . '">';
     /** @var InterfaceCRUDFormRow $element_obj */
     foreach ($element_obj_arr as $element_obj) {
         Assert::assert($element_obj instanceof InterfaceCRUDFormRow);
         $html .= $element_obj->html($obj);
     }
     $html .= '<div class="row">';
     $html .= '<div class="col-sm-8 col-sm-offset-4">';
     if (!$hide_submit_button) {
         $html .= '<button style="width: 100%" type="submit" class="btn btn-primary">Сохранить</button>';
     }
     $html .= '</div>';
     $html .= '</div>';
     $html .= '</form>';
     // Загрузка скриптов
     $html .= CRUDFormScript::getHtml($form_element_id);
     return $html;
 }