示例#1
1
use tests\models\Tree;
use Yii;
?>

<!-- Sidebar user panel -->
<?php 
if (!\Yii::$app->user->isGuest) {
    ?>
    <div class="user-panel">
        <div class="pull-left image">
            <?php 
    echo \cebe\gravatar\Gravatar::widget(['email' => \Yii::$app->user->identity->profile->gravatar_email === null ? \Yii::$app->user->identity->email : \Yii::$app->user->identity->profile->gravatar_email, 'options' => ['alt' => \Yii::$app->user->identity->username], 'size' => 64]);
    ?>
        </div>
        <div class="pull-left info">
            <p><?php 
    echo \Yii::$app->user->identity->username;
    ?>
</p>

            <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
        </div>
    </div>
<?php 
}
?>


<?php 
echo \dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'encodeLabels' => false, 'items' => \yii\helpers\ArrayHelper::merge(['items' => ['label' => 'Backend navigation', 'options' => ['class' => 'header']]], \dmstr\modules\pages\models\Tree::getMenuItems('backend', true, \dmstr\modules\pages\models\Tree::GLOBAL_ACCESS_DOMAIN))]);
示例#2
0
    public static function dropdown()
    {
        return function () {
            $input = TreeViewInput::className();
            $tree = Tree::className();
            return <<<CODE
\$form->field(\$model, 'request_param')->widget(
    {$input}::className(),
    [
        // single query fetch to render the tree
        'query'          => {$tree}::find()->addOrderBy('root, lft'),
        'headingOptions' => ['label' => 'Pages'],
        'model'          => \$model,         // input model
        'attribute'      => 'request_param', // input attribute
        'value'          => \$model->route,
        'asDropdown'     => true,           // will render the tree input widget as a dropdown.
        'multiple'       => false,          // set to false if you do not need multiple selection
        'fontAwesome'    => true,           // render font awesome icons
        'rootOptions'    => [
            'label' => '<i class="fa fa-tree"></i>',
            'class' => 'text-success',
        ],
        'options'        => [
            #'data-route' => (\$treeNode !== null) ? \$treeNode->route : null,
        ],
    ]
);
CODE;
        };
    }
示例#3
0
 /**
  * @return mixed|object dmstr\modules\pages\models\Tree
  */
 public function getLocalizedRootNode()
 {
     $localizedRoot = Tree::ROOT_NODE_PREFIX . '_' . \Yii::$app->language;
     \Yii::trace('localizedRoot: ' . $localizedRoot, __METHOD__);
     $page = Tree::findOne([Tree::ATTR_DOMAIN_ID => Tree::ROOT_NODE_PREFIX, Tree::ATTR_ACCESS_DOMAIN => mb_strtolower(\Yii::$app->language), Tree::ATTR_ACTIVE => Tree::ACTIVE, Tree::ATTR_VISIBLE => Tree::VISIBLE]);
     return $page;
 }
示例#4
0
 public function getLocalizedRootNode()
 {
     $localizedRoot = 'root_' . \Yii::$app->language;
     \Yii::trace('localizedRoot: ' . $localizedRoot, __METHOD__);
     $page = Tree::findOne([Tree::ATTR_NAME_ID => $localizedRoot, Tree::ATTR_ACTIVE => Tree::ACTIVE, Tree::ATTR_VISIBLE => Tree::VISIBLE]);
     return $page;
 }
 /**
  * renders a page view from the database
  *
  * @param $id
  * @param null $pageName
  * @param null $parentLeave
  *
  * @return string
  * @throws HttpException
  */
 public function actionPage($id, $pageName = null, $parentLeave = null)
 {
     Url::remember();
     \Yii::$app->session['__crudReturnUrl'] = null;
     // Set layout
     $this->layout = '@app/views/layouts/main';
     // Get active Tree object, allow access to invisible pages
     // @todo: improve handling, using also roles
     $pageQuery = Tree::find()->where([Tree::ATTR_ID => $id, Tree::ATTR_ACTIVE => Tree::ACTIVE, Tree::ATTR_ACCESS_DOMAIN => \Yii::$app->language]);
     // Show disabled pages for admins
     if (!\Yii::$app->user->can('pages')) {
         $pageQuery->andWhere([Tree::ATTR_DISABLED => Tree::NOT_DISABLED]);
     }
     // get page
     $page = $pageQuery->one();
     if ($page !== null) {
         // Set page title
         $this->view->title = $page->page_title;
         // Register default SEO meta tags
         $this->view->registerMetaTag(['name' => 'keywords', 'content' => $page->default_meta_keywords]);
         $this->view->registerMetaTag(['name' => 'description', 'content' => $page->default_meta_description]);
         if (\Yii::$app->user->isGuest) {
             Yii::$app->response->headers->set('Expires', gmdate('D, d M Y H:i:s \\G\\M\\T', time() + (getenv("HTTP_EXPIRES") !== null ? getenv("HTTP_EXPIRES") : 0)));
         }
         // Render view
         return $this->render($page->view, ['page' => $page]);
     } else {
         throw new HttpException(404, \Yii::t('app', 'Page not found.') . ' [ID: ' . $id . ']');
     }
 }
示例#6
0
 public function testRemoveRootNode()
 {
     $root = Tree::findOne(['domain_id' => 'root-' . md5($_SERVER['REQUEST_TIME'])]);
     $root->removeNode(false);
     $this->assertSame($root->errors, [], 'Root node has errors');
     $root = Tree::findOne(['domain_id' => 'root-' . md5($_SERVER['REQUEST_TIME'])]);
     $this->assertNull($root);
 }
 public function actionPage($id, $pageName = null, $parentLeave = null)
 {
     Url::remember();
     \Yii::$app->session['__crudReturnUrl'] = null;
     // Set layout
     $this->layout = '@app/views/layouts/main';
     // Get Tree object
     $page = Tree::findOne([Tree::ATTR_ID => $id, Tree::ATTR_ACTIVE => Tree::ACTIVE, Tree::ATTR_VISIBLE => Tree::VISIBLE]);
     if ($page !== null) {
         // Set page title
         $this->view->title = $page->page_title;
         // Register default SEO meta tags
         $this->view->registerMetaTag(['name' => 'keywords', 'content' => $page->default_meta_keywords]);
         $this->view->registerMetaTag(['name' => 'description', 'content' => $page->default_meta_description]);
         // Render view
         return $this->render($page->view, ['page' => $page]);
     } else {
         throw new HttpException(404, \Yii::t('app', 'Page not found.') . ' [ID: ' . $id . ']');
     }
 }
示例#8
0
文件: main.php 项目: Quexer69/app
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>
<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => getenv('APP_NAME'), 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar navbar-fixed-top navbar-bold']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav'], 'encodeLabels' => false, 'items' => \dmstr\modules\pages\models\Tree::getMenuItems('root_' . Yii::$app->language)]);
$menuItems = [];
if (Yii::$app->hasModule('user')) {
    if (Yii::$app->user->isGuest) {
        $menuItems[] = ['label' => 'Signup', 'url' => ['/user/registration/register']];
        $menuItems[] = ['label' => 'Login', 'url' => ['/user/security/login']];
    } else {
        $menuItems[] = ['label' => '<i class="glyphicon glyphicon-user"></i> ' . Yii::$app->user->identity->username, 'options' => ['id' => 'link-user-menu'], 'items' => [['label' => '<i class="glyphicon glyphicon-user"></i> Profile', 'url' => ['/user/profile/show', 'id' => \Yii::$app->user->id]], '<li class="divider"></li>', ['label' => '<i class="glyphicon glyphicon-log-out"></i> Logout', 'url' => ['/user/security/logout'], 'linkOptions' => ['data-method' => 'post', 'id' => 'link-logout']]]];
        $menuItems[] = ['label' => '<i class="glyphicon glyphicon-cog"></i>', 'url' => ['/backend'], 'visible' => Yii::$app->user->can('backend_default') || isset(Yii::$app->user->identity) && Yii::$app->user->identity->isAdmin];
    }
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'encodeLabels' => false, 'items' => $menuItems]);
NavBar::end();
?>

    <div class="container">
示例#9
0
 /**
  * @param array $additionalParams
  *
  * @return null|string
  */
 public function createUrl($additionalParams = [])
 {
     $leave = Tree::find()->where(['id' => $this->id])->one();
     if ($leave === null) {
         Yii::error("Tree node with id=" . $this->id . " not found.");
         return null;
     }
     // TODO merged request and additional params, URL rule has therefore to be updated/extended
     if ($leave->route !== null) {
         if ($additionalParams) {
             // merge with $params
         }
         return self::getSluggedUrl($leave);
     } elseif ($leave->route !== null) {
         return \Yii::$app->urlManager->createUrl([$leave->route]);
     }
 }
示例#10
0
/**
 * Wrapper templates
 */
$headerTemplate = <<<HTML
<div class="row">
    <div class="col-sm-6" id="pages-detail-heading">
        {heading}
    </div>
    <div class="col-sm-6" id="pages-detail-search">
        {search}
    </div>
</div>
HTML;
$mainTemplate = <<<HTML
<div class="row">
    <div class="col-md-4" id="pages-detail-wrapper">
        <div class="box boy-body">
        {wrapper}
        </div>
    </div>
    <div class="col-md-8" id="pages-detail-panel">
        {detail}
    </div>
</div>
HTML;
/** @var Tree $queryTree */
$queryTree = Tree::find()->where([Tree::ATTR_ACCESS_DOMAIN => [\Yii::$app->language, Yii::$app->user->can(Tree::GLOBAL_ACCESS_PERMISSION) ? Tree::GLOBAL_ACCESS_DOMAIN : '']])->orderBy('root, lft');
/**
 * Render tree view
 */
echo TreeView::widget(['query' => $queryTree, 'isAdmin' => true, 'softDelete' => false, 'displayValue' => 1, 'wrapperTemplate' => '{header}{footer}{tree}', 'headingOptions' => ['label' => 'Nodes'], 'treeOptions' => ['style' => 'height:auto; min-height:400px'], 'headerTemplate' => $headerTemplate, 'mainTemplate' => $mainTemplate]);
示例#11
0
    ?>
</h4>
    <div class="row">
        <div class="col-xs-12">
            <?php 
    echo $form->field($node, 'page_title', ['addon' => ['prepend' => ['content' => Inflector::titleize('page_title')]]])->textInput($inputOpts)->label(false);
    ?>
        </div>
    </div>
    <?php 
    if ($node->createUrl() != null) {
        ?>
        <div class="row">
            <div class="col-xs-12 col-lg-12">
                <?php 
        echo $form->field($node, 'slug', ['addon' => ['prepend' => ['content' => \Yii::t('crud', 'Page URL')]]])->textInput(['value' => Tree::getSluggedUrl($node), 'disabled' => true])->label(false)->hint(FA::icon('info-circle') . ' ' . \Yii::t('crud', 'Automatically generated from page title.') . ' ' . \Yii::t('crud', 'To change URL change page title above.'), ['class' => 'hints']);
        ?>
            </div>
        </div>
    <?php 
    }
    ?>
    <div class="row">
        <div class="col-xs-12 col-lg-12">
            <?php 
    echo $form->field($node, 'default_meta_keywords', ['addon' => ['prepend' => ['content' => 'Keywords']]])->textInput()->label(false);
    ?>
        </div>
        <div class="col-xs-12 col-lg-12">
            <?php 
    echo $form->field($node, 'default_meta_description', ['addon' => ['prepend' => ['content' => 'Description']]])->textarea(['rows' => 5])->label(false);
示例#12
0
$title = Inflector::titleize($this->context->module->id);
\dmstr\modules\pages\assets\PagesAsset::register($this);
?>

<?php 
/**
 * Output TreeView widget
 */
// Wrapper templates
$headerTemplate = <<<HTML
<div class="row">
    <div class="col-sm-6" id="pages-detail-heading">
        {heading}
    </div>
    <div class="col-sm-6" id="pages-detail-search">
        {search}
    </div>
</div>
HTML;
$mainTemplate = <<<HTML
<div class="row">
    <div class="col-md-4" id="pages-detail-wrapper">
        {wrapper}
    </div>
    <div class="col-md-8" id="pages-detail-panel">
        {detail}
    </div>
</div>
HTML;
echo TreeView::widget(['query' => Tree::find()->addOrderBy('root, lft')->andWhere([Tree::ATTR_ACCESS_DOMAIN => \Yii::$app->language]), 'isAdmin' => true, 'softDelete' => false, 'displayValue' => 1, 'wrapperTemplate' => "{header}{footer}{tree}", 'headingOptions' => ['label' => $title . '-Module'], 'treeOptions' => ['style' => 'height:600px'], 'headerTemplate' => $headerTemplate, 'mainTemplate' => $mainTemplate]);
示例#13
0
    ?>
        </div>
        <div class="pull-left info">
            <p><?php 
    echo \Yii::$app->user->identity->username;
    ?>
</p>

            <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
        </div>
    </div>
<?php 
}
?>


<?php 
// prepare menu items, get all modules
$adminMenuItems = [];
$developerMenuItems = [];
foreach (\dmstr\helpers\Metadata::getModules() as $name => $module) {
    $role = $name;
    $defaultItem = ['icon' => 'fa fa-cube', 'label' => $name, 'url' => ['/' . $name], 'visible' => Yii::$app->user->can($role) || Yii::$app->user->identity && Yii::$app->user->identity->isAdmin, 'items' => []];
    $developerMenuItems[] = $defaultItem;
}
// create developer menu, when user is admin
if (Yii::$app->user->identity && Yii::$app->user->identity->isAdmin) {
    $adminMenuItems[] = ['url' => '#', 'icon' => 'fa fa-cogs', 'label' => 'Modules', 'items' => $developerMenuItems, 'options' => ['class' => 'treeview'], 'visible' => Yii::$app->user->identity->isAdmin];
}
echo \dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => \yii\helpers\ArrayHelper::merge(['items' => ['label' => 'Backend navigation', 'options' => ['class' => 'header']]], \dmstr\modules\pages\models\Tree::getMenuItems('backend', true), $adminMenuItems)]);
示例#14
0
            <div class="row">
                <div class="col-xs-12 col-sm-6">
                    <?php 
        echo $form->field($node, Tree::ATTR_ACCESS_DOMAIN, ['addon' => ['prepend' => ['content' => 'Access Domain']]])->dropDownList(Tree::optsAccessDomain())->label(false);
        ?>
                </div>
                <div class="col-xs-12 col-sm-6">
                    <?php 
        echo $form->field($node, Tree::ATTR_ROUTE)->widget(\kartik\select2\Select2::classname(), ['name' => Html::getInputName($node, Tree::ATTR_ROUTE), 'model' => $node, 'attribute' => Tree::ATTR_ROUTE, 'addon' => ['prepend' => ['content' => 'Route']], 'data' => Tree::optsRoute(), 'options' => ['placeholder' => Yii::t('pages', 'Select route'), 'multiple' => false], 'pluginOptions' => ['allowClear' => true]])->label(false);
        ?>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12 col-sm-12">
                    <?php 
        echo $form->field($node, Tree::ATTR_VIEW)->widget(\kartik\select2\Select2::classname(), ['name' => Html::getInputName($node, Tree::ATTR_VIEW), 'model' => $node, 'attribute' => Tree::ATTR_VIEW, 'addon' => ['prepend' => ['content' => 'Available Views']], 'data' => Tree::optsView(), 'options' => ['id' => 'tree-views', 'placeholder' => Yii::t('pages', 'Type to autocomplete'), 'multiple' => false], 'pluginOptions' => ['allowClear' => true]])->label(false);
        ?>
                </div>

            </div>
            <?php 
        Box::end();
        ?>

            <?php 
        Box::begin(['title' => Yii::t('kvtree', Yii::t('kvtree', 'SEO')), 'collapse' => true, 'collapse_remember' => false, 'collapseDefault' => false]);
        ?>
            <div class="row">
                <div class="col-xs-12">
                    <?php 
        echo $form->field($node, 'page_title', ['addon' => ['prepend' => ['content' => Inflector::titleize('page_title')]]])->textInput($inputOpts)->label(false);
 /**
  * @return array
  */
 private function resolveFallbackPage($pageId)
 {
     $original = Tree::find()->where(['id' => $pageId])->one();
     $fallback = Tree::find()->where(['domain_id' => $original->domain_id, 'access_domain' => \Yii::$app->language])->one();
     return $fallback;
 }
示例#16
0
    ?>
" class="small-box-footer">
                        Audit <i class="fa fa-arrow-circle-right"></i>
                    </a>
                </div>
            </div>
            <!-- ./col -->
        <?php 
}
?>

    </div>

    <div class="row">
        <?php 
$items = \dmstr\modules\pages\models\Tree::getMenuItems('backend', true, \dmstr\modules\pages\models\Tree::GLOBAL_ACCESS_DOMAIN);
foreach ($items as $item) {
    if ($item['visible']) {
        echo '<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2">';
        echo \insolita\wgadminlte\SmallBox::widget(['head' => substr(trim(strip_tags($item['label'])), 0, 2), 'icon' => isset($item['icon']) ? $item['icon'] : '', 'footer' => $item['label'], 'footer_link' => $item['url']]);
        echo '</div>';
    }
}
?>
    </div>


<?php 
if (\Yii::$app->user->identity->isAdmin) {
    ?>
    <div class="row">