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


PHP tree::generate方法代码示例

本文整理汇总了PHP中tree::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP tree::generate方法的具体用法?PHP tree::generate怎么用?PHP tree::generate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tree的用法示例。


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

示例1: node_search

 /**
  * Nodesøk
  */
 protected function node_search($cid, $dest, $search)
 {
     $search = utf8_decode($search);
     // hent all informasjon
     $result = \Kofradia\DB::get()->query("SELECT node_id, node_parent_node_id, node_title, node_type, node_params, node_show_menu, node_expand_menu, node_enabled, node_priority, node_change FROM nodes");
     $nodes = array();
     while ($row = $result->fetch()) {
         $row['params'] = new params($row['node_params']);
         $row['enheter'] = array();
         $row['plain'] = "";
         $nodes[$row['node_id']] = $row;
     }
     if (count($nodes) == 0) {
         $this->msg($cid, $dest, "Ingen siden eksisterer.");
         return;
     }
     // sett opp søkekriteriene
     $search_list = search_query($search);
     $search_list = $search_list[1];
     $search_list2 = $search_list;
     // for delvise treff
     foreach ($search_list as &$q) {
         $q = '/(\\P{L}|^)' . preg_replace(array('/([\\/\\\\\\[\\]()$.+?|{}])/', '/\\*\\*+/', '/\\*/'), array('\\\\$1', '*', '\\S*'), $q) . '(\\P{L}|$)/i';
     }
     // sett opp søkeliste hvor vi søker med * på slutten av ordene
     foreach ($search_list2 as &$q) {
         $q = '/' . preg_replace(array('/([\\/\\\\\\[\\]()$.+?|{}])/', '/\\*\\*+/', '/\\*/'), array('\\\\$1', '*', '\\S*'), $q) . '/i';
     }
     // hent alle enhetene
     $result = \Kofradia\DB::get()->query("SELECT ni_id, ni_node_id, ni_type, nir_content, nir_params, nir_time FROM nodes_items LEFT JOIN nodes_items_rev ON nir_id = ni_nir_id WHERE ni_enabled != 0 AND ni_deleted = 0 ORDER BY ni_priority");
     while ($row = $result->fetch()) {
         if (!isset($nodes[$row['ni_node_id']])) {
             continue;
         }
         $data = nodes::content_build($row);
         $nodes[$row['ni_node_id']]['enheter'][] = $data;
         // bygg opp plain tekst
         $plain = preg_replace("/<br[^\\/>]*\\/?>/", "\n", $data);
         $plain = preg_replace("/(<\\/?(h[1-6]|p)[^>]*>)/", "\n\\1", $plain);
         $plain = html_entity_decode(strip_tags($plain));
         $plain = preg_replace("/(^ +| +\$|\\r)/m", "", $plain);
         #$plain = preg_replace("/(?<![!,.\\n ])\\n/", " ", $plain);
         $plain = preg_replace("/\\n/", " ", $plain);
         $plain = preg_replace("/  +/", " ", $plain);
         $plain = trim($plain);
         $nodes[$row['ni_node_id']]['plain'] .= $plain . " ";
     }
     // sett opp riktige referanser og lag tree
     $sub = array();
     foreach (nodes::$nodes as $row) {
         if ($row['node_enabled'] != 0) {
             $sub[$row['node_parent_node_id']][] = $row['node_id'];
         }
     }
     $tree = new tree($sub);
     $data = $tree->generate(0, NULL, $nodes);
     // sett opp paths
     $paths = array();
     $path = array();
     $number = 1;
     foreach ($data as $row) {
         for (; $row['number'] <= $number; $number--) {
             // fjern fra path
             array_pop($path);
         }
         if ($row['number'] >= $number) {
             // legg til i path
             $path[] = $row['data']['node_title'];
         }
         $paths[$row['data']['node_id']] = $path;
         $number = $row['number'];
     }
     // sett opp søkeresultater
     $result = array();
     $points = array();
     $points2 = array();
     foreach ($data as $row) {
         if ($row['data']['node_type'] != "container") {
             continue;
         }
         // utfør søk
         $found = true;
         $p = 0;
         $p2 = 0;
         foreach ($search_list as $key => $regex) {
             $ok = false;
             $matches = null;
             // søk i teksten
             if (preg_match_all($regex, $row['data']['plain'], $matches)) {
                 $ok = true;
                 $p += count($matches[0]);
             }
             if (preg_match_all($search_list2[$key], $row['data']['plain'], $matches)) {
                 $ok = true;
                 $p2 += count($matches[0]);
             }
             // søk i tittelen
//.........这里部分代码省略.........
开发者ID:Kuzat,项目名称:kofradia,代码行数:101,代码来源:ircbot_log.php

示例2: get_directory_tree

 /**
  * Hent tree for mappene
  * @return tree
  */
 public static function get_directory_tree()
 {
     global $_base;
     // hent alle mappene
     $result = \Kofradia\DB::get()->query("SELECT cfd_id, cfd_parent_cfd_id, cfd_title, cfd_description, cfd_time, cfd_up_id, cfd_access_level FROM crewfiles_directories ORDER BY cfd_title");
     // les inn mappene
     $dirs = array();
     $dirs_sub = array();
     while ($row = $result->fetch()) {
         $dirs[$row['cfd_id']] = $row;
         $dirs_sub[$row['cfd_parent_cfd_id']][] = $row['cfd_id'];
     }
     // hent tree
     $root = array(0 => array("number" => 0, "prefix" => "", "prefix_node" => "", "data" => crewfiles_directory::$root));
     $tree = new tree($dirs_sub);
     $tree->generate(0, $root, $dirs);
     // returner tree
     return $tree;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:23,代码来源:class.crewfiles.php

示例3: show_nodes_list

    protected static function show_nodes_list()
    {
        echo '
<h1>Innhold</h1>
<h2>Oversikt over sidene</h2>
<p class="h_right"><a href="' . ess::$s['relative_path'] . '/node/a?new_node" class="large_button">Ny side</a></p>
<table class="table tablemb" width="100%">
	<thead>
		<tr>
			<th>Tittel</th>
			<th>Informasjon</th>
			<th>Enheter</th>
			<th>Ny side</th>
			<th>Vis</th>
		</tr>
	</thead>
	<tbody class="c">';
        // hent antall items i hver node
        $result = \Kofradia\DB::get()->query("SELECT ni_node_id, COUNT(ni_id) count FROM nodes_items WHERE ni_deleted = 0 GROUP BY ni_node_id");
        $nodes_items_count = array();
        while ($row = $result->fetch()) {
            $nodes_items_count[$row['ni_node_id']] = $row['count'];
        }
        foreach (nodes::$nodes as $key => &$value) {
            $value['ni_count'] = isset($nodes_items_count[$key]) ? $nodes_items_count[$key] : 0;
        }
        // generer data
        $tree = new tree(nodes::$nodes_sub);
        $data = $tree->generate(0, NULL, nodes::$nodes);
        $parent_disabled = 0;
        $parent_hidden = 0;
        $i = 0;
        foreach ($data as $key => $row) {
            if ($parent_disabled != 0 && $row['number'] <= $parent_disabled) {
                $parent_disabled = 0;
            }
            if ($parent_hidden != 0 && $row['number'] <= $parent_hidden) {
                $parent_hidden = 0;
            }
            // adresse
            switch ($row['data']['node_type']) {
                case "url_absolute":
                    $params = new params($row['data']['node_params']);
                    $url = htmlspecialchars($params->get("url"));
                    break;
                case "url_relative":
                    $params = new params($row['data']['node_params']);
                    $url = ess::$s['relative_path'] . htmlspecialchars($params->get("url"));
                    break;
                default:
                    if ($key == nodes::$default_node) {
                        $url = ess::$s['relative_path'] . '/';
                    } else {
                        $url = ess::$s['relative_path'] . '/node/' . $row['data']['node_id'];
                    }
            }
            // verktøy
            $tools = array();
            // deaktivert?
            if ($row['data']['node_enabled'] == 0) {
                $tools[] = '[<span style="color:#FF0000">deaktivert</span>]';
                if ($parent_disabled != 0) {
                    $parent_disabled = $row['number'];
                }
            } elseif ($parent_disabled) {
                $tools[] = '[<span style="color:#FF0000">deaktivert</span> (arvet)]';
            }
            // skjult fra menyen
            if ($row['data']['node_show_menu'] == 0) {
                $tools[] = '[<span style="color:#FF0000">skjult fra meny</span> - <a href="' . ess::$s['relative_path'] . '/node/a?node_id=' . $row['data']['node_id'] . '&amp;show_menu">vis</a>]';
                if ($parent_hidden != 0) {
                    $parent_hidden = $row['number'];
                }
            } elseif ($parent_hidden) {
                $tools[] = '[<span style="color:#FF0000">skjult fra meny</span> (arvet)]';
            }
            $tools = count($tools) == 0 ? '&nbsp;' : '<span style="font-size: 10px">' . implode(" ", $tools) . '</span>';
            // farge
            $i++;
            $class = nodes::$node_id == $key ? ' class="highlight"' : ($i % 2 == 0 ? ' class="color"' : '');
            // informasjon om typen
            switch ($row['data']['node_type']) {
                case "url_absolute":
                    $typeinfo = '<span style="font-size: 9px">(absolutt adresse)</span>';
                    break;
                case "url_relative":
                    $typeinfo = '<span style="font-size: 9px">(relativ adresse)</span>';
                    break;
                default:
                    $typeinfo = '';
            }
            // enheter
            $units = array();
            if ($row['data']['ni_count'] > 0) {
                $units[] = $row['data']['ni_count'];
            }
            if ($typeinfo != "") {
                $units[] = $typeinfo;
            }
            $units = count($units) == 0 ? '&nbsp;' : implode(" ", $units);
//.........这里部分代码省略.........
开发者ID:Kuzat,项目名称:kofradia,代码行数:101,代码来源:node.php


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