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


PHP Topic::GetTree方法代码示例

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


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

示例1: putGS

	</TD>
</TR>
<tr style="display: none;" id="topic_list">
	<td align="right"><?php 
    putGS("Top element");
    ?>
:</td>
	<td>
		<select name="f_root_topic_id" class="input_select">
<?php 
    $TOL_Language = camp_session_get('LoginLanguageId', 1);
    $lang = new Language($TOL_Language);
    $currentLanguageId = $lang->getLanguageId();
    //$currentLanguages = Language::GetLanguages(null, $TOL_Language);
    //$currentLanguageId = $currentLanguages[0]->getLanguageId();
    $topics = Topic::GetTree();
    foreach ($topics as $topicPath) {
        $printTopic = array();
        foreach ($topicPath as $topicId => $topic) {
            $translations = $topic->getTranslations();
            if (array_key_exists($currentLanguageId, $translations)) {
                $currentTopic = $translations[$currentLanguageId];
            } elseif ($currentLanguageId != 1 && array_key_exists(1, $translations)) {
                $currentTopic = $translations[1];
            } else {
                $currentTopic = end($translations);
            }
            $printTopic[] = $currentTopic;
        }
        echo '<option value="' . $topic->getTopicId() . '">' . htmlspecialchars(implode(" / ", $printTopic)) . "</option>\n";
    }
开发者ID:nidzix,项目名称:Newscoop,代码行数:31,代码来源:retype.php

示例2: is_array

$issues = Issue::GetIssues($this->publication, NULL);
$issuesNo = is_array($issues) ? sizeof($issues) : 0;
$menuIssueTitle = $issuesNo > 0 ? getGS('All Issues') : getGS('No issues found');
$articleTypes = ArticleType::GetArticleTypes(true);
// get sections
$sections = array();
$section_objects = Section::GetSections($this->publication, $this->issue, $this->language);
foreach ($section_objects as $section) {
    if (!isset($sections[$section->getSectionNumber()])) {
        $sections[$section->getSectionNumber()] = $section;
    }
}
$sectionsNo = is_array($sections) ? sizeof($sections) : 0;
$menuSectionTitle = $sectionsNo > 0 ? getGS('All Sections') : getGS('No sections found');
$topics = array();
foreach (Topic::GetTree() as $topic) {
    $topic = array_pop($topic);
    $topics[$topic->getTopicId()] = $topic->getName($this->language);
}
?>
<script type="text/javascript">
//for use in table for default filters
contextListFilters = {}
</script>

<div class="filters">

  <dl class="zend_form">
                  <dd>

<fieldset class="toggle filters" style="display:block">
开发者ID:nidzix,项目名称:Newscoop,代码行数:31,代码来源:filters.php

示例3: p

            <?php 
        } else {
            ?>
              <?php 
            p($text);
            ?>
            <?php 
        }
        ?>
          </li>
        <?php 
    } elseif ($dbColumn->getType() == ArticleTypeField::TYPE_TOPIC) {
        $articleTypeField = new ArticleTypeField($articleObj->getType(), substr($dbColumn->getName(), 1));
        $rootTopicId = $articleTypeField->getTopicTypeRootElement();
        $rootTopic = new Topic($rootTopicId);
        $subtopics = Topic::GetTree($rootTopicId);
        $articleTopicId = $articleData->getProperty($dbColumn->getName());
        ?>
          <li>
            <label><?php 
        echo htmlspecialchars($dbColumn->getDisplayName($articleObj->getLanguageId()));
        ?>
</label>
                <?php 
        if (count($subtopics) == 0) {
            ?>
                <?php 
            putGS('No subtopics available');
            ?>
                <?php 
        } else {
开发者ID:nidzix,项目名称:Newscoop,代码行数:31,代码来源:edit_html.php

示例4: testCreate


//.........这里部分代码省略.........
		$this->assertEquals($subtopicsDepth1, $topic->getSubtopics());
		$this->assertEquals($subtopicsDepth1Ids, $topic->getSubtopics(true));
		$subtopicsDepth2 = array(new Topic(26), new Topic(15), new Topic(25), new Topic(24),
		new Topic(14), new Topic(22), new Topic(19), new Topic(16));
		$this->assertEquals($subtopicsDepth2, $topic->getSubtopics(false, 2));
		$subtopicsAll = array(new Topic(26), new Topic(15), new Topic(25), new Topic(24),
		new Topic(14), new Topic(22), new Topic(19), new Topic(16), new Topic(18), new Topic(17));
		$this->assertEquals($subtopicsAll, $topic->getSubtopics(false, 0));

		$topics = array(new Topic(2));
		$this->assertEquals($topics, Topic::GetTopics(2));
		$this->assertEquals($topics, Topic::GetTopics(null, 1, 'Education'));
		$this->assertEquals($subtopicsDepth1, Topic::GetTopics(null, null, null, 2));
		$this->assertEquals($subtopicsAll, Topic::GetTopics(null, null, null, 2, 0));
		$subtopicsDepth1Name = array(new Topic(14), new Topic(26), new Topic(15));
		$this->assertEquals($subtopicsDepth1Name, Topic::GetTopics(null, 1, null, 2, 1,
		null, array(array('field'=>'byname', 'dir'=>'asc'))));

		$tree = array(
		array(27=>new Topic(27)),
		array(2=>new Topic(2)),
		array(2=>new Topic(2), 26=>new Topic(26)),
		array(2=>new Topic(2), 15=>new Topic(15)),
		array(2=>new Topic(2), 15=>new Topic(15), 25=>new Topic(25)),
		array(2=>new Topic(2), 15=>new Topic(15), 24=>new Topic(24)),
		array(2=>new Topic(2), 14=>new Topic(14)),
		array(2=>new Topic(2), 14=>new Topic(14), 22=>new Topic(22)),
		array(2=>new Topic(2), 14=>new Topic(14), 19=>new Topic(19)),
		array(2=>new Topic(2), 14=>new Topic(14), 16=>new Topic(16)),
		array(2=>new Topic(2), 14=>new Topic(14), 16=>new Topic(16), 18=>new Topic(18)),
		array(2=>new Topic(2), 14=>new Topic(14), 16=>new Topic(16), 17=>new Topic(17)),
		array(3=>new Topic(3)),
		array(3=>new Topic(3), 9=>new Topic(9)),
		array(3=>new Topic(3), 4=>new Topic(4)),
		array(1=>new Topic(1))
		);
		$this->assertEquals($tree, Topic::GetTree());
		$subtree = array(
		array(26=>new Topic(26)),
		array(15=>new Topic(15)),
		array(15=>new Topic(15), 25=>new Topic(25)),
		array(15=>new Topic(15), 24=>new Topic(24)),
		array(14=>new Topic(14)),
		array(14=>new Topic(14), 22=>new Topic(22)),
		array(14=>new Topic(14), 19=>new Topic(19)),
		array(14=>new Topic(14), 16=>new Topic(16)),
		array(14=>new Topic(14), 16=>new Topic(16), 18=>new Topic(18)),
		array(14=>new Topic(14), 16=>new Topic(16), 17=>new Topic(17))
		);
		$this->assertEquals($subtree, Topic::GetTree(2));
		$subtree = array(
		array(22=>new Topic(22)),
		array(19=>new Topic(19)),
		array(16=>new Topic(16)),
		array(16=>new Topic(16), 18=>new Topic(18)),
		array(16=>new Topic(16), 17=>new Topic(17))
		);
		$this->assertEquals($subtree, Topic::GetTree(14));

		Topic::UpdateOrder(array('topic_2'=>array('topic_26', 'topic_14', 'topic_15')));
		$topic = new Topic(14);
		$this->assertEquals(6, $topic->getLeft());
		$this->assertEquals(17, $topic->getRight());
		$topic = new Topic(15);
		$this->assertEquals(18, $topic->getLeft());
		$this->assertEquals(23, $topic->getRight());
		$topic = new Topic(16);
		$this->assertEquals(11, $topic->getLeft());
		$this->assertEquals(16, $topic->getRight());
		Topic::UpdateOrder(array('topic_0'=>array('topic_27', 'topic_3', 'topic_2', 'topic_1')));
		$topic = new Topic(3);
		$this->assertEquals(3, $topic->getLeft());
		$this->assertEquals(8, $topic->getRight());
		$topic = new Topic(2);
		$this->assertEquals(9, $topic->getLeft());
		$this->assertEquals(30, $topic->getRight());
		$topic = new Topic(16);
		$this->assertEquals(17, $topic->getLeft());
		$this->assertEquals(22, $topic->getRight());

		// test setName()
		$topic->setName(1, 'My Music');
		$topic = new Topic(16);
		$this->assertEquals('My Music', $topic->getName(1));

		// test delete()
		$topic->delete(2);
		$this->assertEquals('My Music', $topic->getName(1));
		$this->assertEquals(1, $topic->getNumTranslations());
		$topic->delete();
		$topic = new Topic(15);
		$this->assertEquals(18, $topic->getLeft());
		$this->assertEquals(23, $topic->getRight());
		$topic = new Topic(1);
		$this->assertEquals(25, $topic->getLeft());
		$this->assertEquals(26, $topic->getRight());
		$topic = new Topic(14);
		$subtopics = array(22, 19);
		$this->assertEquals($subtopics, $topic->getSubtopics(true));
	} // fn testCreate
开发者ID:nistormihai,项目名称:Newscoop,代码行数:101,代码来源:TopicTest.php

示例5: p

                        $option .= " / ".htmlspecialchars($name);
                    }
                    $selected = $currentTopic->getTopicId() == SystemPref::Get('PLUGIN_BLOG_ROOT_TOPIC_ID') ? 'selected' : '';
                    p("<option value=\"{$currentTopic->getTopicId()}\" $selected>$option</option>");
                }
                ?>
            </select>
       </td>
    </tr>
        <tr>
        <td align="left"><?php putGS("Blog mood root"); ?></td>
        <td>
            <select name="f_blog_root_mood_id" />
                <option value="0">--root--</option>
                <?php
                foreach (Topic::GetTree() as $path) {
                    $option='';
                    $currentTopic = camp_array_peek($path, false, -1);
                    $name = $currentTopic->getName($language_id);

                    if (empty($name)) {
                        // Backwards compatibility
                        $name = $currentTopic->getName(1);
                        if (empty($name)) {
                            continue;
                        }
                    }
                    foreach ($path as $topicObj) {
                        $name = $topicObj->getName($language_id);
                        if (empty($name)) {
                            $name = $topicObj->getName(1);
开发者ID:nistormihai,项目名称:Newscoop,代码行数:31,代码来源:blog_prefs.php

示例6: GetMoodList

    public static function GetMoodList($p_language_id)
    {
        $options = array(0 => '------');

        foreach (Topic::GetTree((int)SystemPref::Get('PLUGIN_BLOG_ROOT_MOOD_ID')) as $path) {
            $currentTopic = camp_array_peek($path, false, -1);
            $name = $currentTopic->getName($p_language_id);

            if (empty($name)) {
                // Backwards compatibility
                $name = $currentTopic->getName(1);
                if (empty($name)) {
                    continue;
                }
            }
            foreach ($path as $topicObj) {
                $name = $topicObj->getName($p_language_id);
                if (empty($name)) {
                    $name = $topicObj->getName(1);
                    if (empty($name)) {
                        $name = "-----";
                    }
                }
                $value = htmlspecialchars($name);
            }
            $selected = $currentTopic->getTopicId() == SystemPref::Get('PLUGIN_BLOG_ROOT_MOOD_ID') ? 'selected' : '';
            $options[$currentTopic->getTopicId()] = $value;
        }

        return (array)$options;
    }
开发者ID:nistormihai,项目名称:Newscoop,代码行数:31,代码来源:Blog.php


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