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


PHP Topic::getTopicId方法代码示例

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


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

示例1: transfer_topics_3_5

function transfer_topics_3_5($p_parentId = 0)
{
    global $g_ado_db;
    $sql = 'SELECT * FROM TopicsOld';
    if (!is_null($p_parentId)) {
        $sql .= " WHERE ParentId = {$p_parentId}";
    }
    $sql .= ' ORDER BY TopicOrder DESC, LanguageId ASC';
    $rows = $g_ado_db->GetAll($sql);
    foreach ($rows as $row) {
        $topic = new Topic($row['Id']);
        if ($topic->exists()) {
            $topic->setName($row['LanguageId'], $row['Name']);
        } else {
            $topic->create(array('parent_id' => $p_parentId, 'names' => array($row['LanguageId'] => $row['Name'])));
            transfer_topics_3_5($topic->getTopicId());
        }
    }
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:19,代码来源:transfer_topics.php

示例2: has_topic

 public function has_topic($p_topicName) {
     $topic = new Topic($p_topicName);
     if (!$topic->exists()) {
         $this->trigger_invalid_value_error('has_topic', $p_topicName);
         return null;
     }
     $articleTopics = $this->getContentCache('article_topics');
     if (is_null($articleTopics)) {
         $articleTopics = ArticleTopic::GetArticleTopics($this->m_dbObject->getArticleNumber());
         $this->setContentCache('article_topics', $articleTopics);
     }
     foreach ($articleTopics as $articleTopic) {
         if ($articleTopic->getTopicId() == $topic->getTopicId()) {
             return (int)true;
         }
     }
     return (int)false;
 }
开发者ID:nistormihai,项目名称:Newscoop,代码行数:18,代码来源:MetaArticle.php

示例3: ProcessConstraints


//.........这里部分代码省略.........
	                            $operator = new Operator($p_constraints[$index+1], 'switch');
	                        }
	                        catch (InvalidOperatorException $e) {
        	                    $operator = new Operator('is', 'switch');
        	                    $comparisonOperation = new ComparisonOperation($attribute, $operator, 'on');
                	            $parameters[] = $comparisonOperation;
                	            $state = self::CONSTRAINT_ATTRIBUTE_NAME;
	                        }
	                    } else {
    	                    $operator = new Operator('is', 'switch');
                            $comparisonOperation = new ComparisonOperation($attribute, $operator, 'on');
                            $parameters[] = $comparisonOperation;
                            $state = self::CONSTRAINT_ATTRIBUTE_NAME;
	                    }
	                }
	                break;
	    		case self::CONSTRAINT_DYNAMIC_FIELD:
	    			$attribute = strtolower($word);
	    			$dynamicFields = self::GetDynamicFields($articleTypeName, $attribute);
	    			if (count($dynamicFields) > 0) {
	    				$type = $dynamicFields[0]->getGenericType();
	    				$state = self::CONSTRAINT_OPERATOR;
	    				break;
	    			}
                    CampTemplate::singleton()->trigger_error("invalid dynamic field $word in statement list_articles, constraints parameter");
                    return false;
	            case self::CONSTRAINT_OPERATOR: // reading the operator
	                try {
	                    $operator = new Operator($word, $type);
	                }
	                catch (InvalidOperatorException $e) {
    	                CampTemplate::singleton()->trigger_error("invalid operator $word of parameter constraints.$attribute in statement list_articles");
	                    return false;
	                }
	                $state = self::CONSTRAINT_VALUE;
	                break;
	            case self::CONSTRAINT_VALUE: // reading the value to compare against
	                $metaClassName = 'Meta'.ucfirst($type);
	                try {
    	                $valueObj = new $metaClassName($word);
	                } catch (InvalidValueException $e) {
                        CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_articles");
	                    return false;
	                }
       	            if ($attribute == 'type') {
                        $word = trim($word);
       	                $articleType = new ArticleType($word);
       	                if (!$articleType->exists()) {
	                        CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_articles");
	                        return false;
                        }
                        $value = $word;
                    } elseif ($attribute == 'topic') {
                        $topicObj = new Topic($word);
                        if (!$topicObj->exists()) {
                            CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_articles");
                            return false;
                        } else {
                            $value = $topicObj->getTopicId();
                        }
                    } elseif ($attribute == 'author') {
                        if (strtolower($word) == '__current') {
                        	$value = $context->article->author->name;
                        } else {
                        	$value = $word;
                        }
       	            } elseif ($type == 'switch') {
       	            	$value = (int)(strtolower($word) == 'on');
       	            } else {
       	                $value = $word;
       	            }
       	            if (!is_null($articleTypeName)) {
       	            	$attribute = "$articleTypeName.$attribute";
       	            }
       	            $comparisonOperation = new ComparisonOperation($attribute, $operator, $value);
       	            $parameters[] = $comparisonOperation;
       	            $state = self::CONSTRAINT_ATTRIBUTE_NAME;
	                $attribute = null;
	                $articleTypeName = null;
	                $type = null;
	                $value = null;
	                break;
	        }
	    }
	    if ($state != self::CONSTRAINT_ATTRIBUTE_NAME) {
            CampTemplate::singleton()->trigger_error("unexpected end of constraints parameter in list_articles");
            return false;
	    }

	    if (!$this->m_ignoreIssue && $context->issue->defined) {
            $this->m_constraints[] = new ComparisonOperation('NrIssue', new Operator('is', 'integer'),
                                                             $context->issue->number);
        }
        if (!$this->m_ignoreSection && $context->section->defined) {
            $this->m_constraints[] = new ComparisonOperation('NrSection', new Operator('is', 'integer'),
                                                             $context->section->number);
        }

	    return $parameters;
	}
开发者ID:nistormihai,项目名称:Newscoop,代码行数:101,代码来源:ArticlesList.php

示例4: camp_html_breadcrumbs

}
if ($f_confirmed == 1) {
    // get a list of subtopics
    $deleteTopics = $deleteTopic->getSubtopics();
    // detach all subtopics from all articles
    foreach ($deleteTopics as $topic) {
        ArticleTopic::RemoveTopicFromArticles($topic->getTopicId());
    }
    // delete all subtopics
    foreach ($deleteTopics as $topic) {
        $topic->delete($f_topic_language_id);
    }
    $doDelete = true;
}
if ($doDelete) {
    ArticleTopic::RemoveTopicFromArticles($deleteTopic->getTopicId());
    $deleted = $deleteTopic->delete($f_topic_language_id);
    if ($deleted) {
        camp_html_add_msg(getGS("Topic was deleted."), "ok");
        camp_html_goto_page("/{$ADMIN}/topics/index.php");
    } else {
        $errorMsgs[] = getGS('The topic $1 could not be deleted.', '<B>' . $deleteTopic->getName($f_topic_language_id) . '</B>');
    }
}
$crumbs = array();
$crumbs[] = array(getGS("Configure"), "");
$crumbs[] = array(getGS("Topics"), "/{$ADMIN}/topics/");
$crumbs[] = array(getGS("Deleting topic"), "");
echo camp_html_breadcrumbs($crumbs);
?>
开发者ID:nidzix,项目名称:Newscoop,代码行数:30,代码来源:do_del.php

示例5: testCreate

	public function testCreate()
	{
		// test create(), fetch(), getLeft(), getRight(), getName()
		$this->createAndTest(1, array('names'=>array(1=>'Sports', 2=>'Sport')), 1, 2);
		$this->createAndTest(3, array('names'=>array(1=>'Electronics', 2=>'Electronice')), 1, 2);
		$this->createAndTest(2, array('names'=>array(1=>'Education', 2=>'Educație')), 1, 2);
		$this->createAndTest(27, array('names'=>array(1=>'Health', 2=>'Sănătate')), 1, 2);

		$this->createAndTest(4, array('parent_id'=>3, 'names'=>array(1=>'Televisions', 2=>'Televizoare')), 6, 7);
		$this->createAndTest(9, array('parent_id'=>3, 'names'=>array(1=>'Portable Electronics', 2=>'Electronice portabile')), 6, 7);

		$this->createAndTest(14, array('parent_id'=>2, 'names'=>array(1=>'Culture', 2=>'Cultură')), 4, 5);
		$this->createAndTest(15, array('parent_id'=>2, 'names'=>array(1=>'Science', 2=>'Știință')), 4, 5);
		$this->createAndTest(26, array('parent_id'=>2, 'names'=>array(1=>'Religion', 2=>'Religie')), 4, 5);

		$this->createAndTest(16, array('parent_id'=>14, 'names'=>array(1=>'Music', 2=>'Muzică')), 9, 10);
		$this->createAndTest(19, array('parent_id'=>14, 'names'=>array(1=>'Film', 2=>'Film')), 9, 10);
		$this->createAndTest(22, array('parent_id'=>14, 'names'=>array(1=>'Books', 2=>'Cărți')), 9, 10);

		$this->createAndTest(17, array('parent_id'=>16, 'names'=>array(1=>'Classical', 2=>'Clasică')), 14, 15);
		$this->createAndTest(18, array('parent_id'=>16, 'names'=>array(1=>'Jazz', 2=>'Jazz')), 14, 15);

		$this->createAndTest(24, array('parent_id'=>15, 'names'=>array(1=>'Physics', 2=>'Fizică')), 7, 8);
		$this->createAndTest(25, array('parent_id'=>15, 'names'=>array(1=>'Mathematics', 2=>'Matematică')), 7, 8);

		// test constructor and GetByFullName()
		$topic = new Topic('Physics:en');

		// test other get methods
		$this->assertEquals(24, $topic->getTopicId());

		$this->assertEquals(15, $topic->getParentId());

		$this->assertEquals(2, $topic->getNumTranslations());

		$translations = array(1=>new TopicName(24, 1), 2=>new TopicName(24, 2));
		$this->assertEquals($translations, $topic->getTranslations());

		$path = array(2=>new Topic(2), 15=>new Topic(15), 24=>new Topic(24));
		$pathIds = array(2=>2, 15=>15, 24=>24);
		$this->assertEquals($path, $topic->getPath());
		$this->assertEquals($pathIds, $topic->getPath(true));

		$this->assertFalse($topic->hasSubtopics());

		$this->assertFalse($topic->isRoot());

		$this->assertEquals(1, $topic->getWidth());

		$this->assertEquals(array(), $topic->getSubtopics());

		$topic = new Topic('Educație:ro');

		$this->assertTrue($topic->isRoot());

		$this->assertTrue($topic->hasSubtopics());

		$this->assertEquals(21, $topic->getWidth());

		$this->assertEquals(null, $topic->getParentId());

		$this->assertEquals(array(2=>new Topic(2)), $topic->getPath());

		$subtopicsDepth1 = array(new Topic(26), new Topic(15), new Topic(14));
		$subtopicsDepth1Ids = array(26, 15, 14);
		$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))
//.........这里部分代码省略.........
开发者ID:nistormihai,项目名称:Newscoop,代码行数:101,代码来源:TopicTest.php

示例6: ProcessConstraints

	/**
	 * Processes list constraints passed in an array.
	 *
	 * @param array $p_constraints
	 * @return array
	 */
	protected function ProcessConstraints(array $p_constraints)
	{
	    $parameters = array();
	    $state = 1;
	    $attribute = null;
	    $operator = null;
	    $value = null;
	    foreach ($p_constraints as $index=>$word) {
	        switch ($state) {
	            case 1: // reading the parameter name
	                $attribute = strtolower($word);
	                if (!array_key_exists($attribute, self::$s_parameters)) {
	                    CampTemplate::singleton()->trigger_error("invalid attribute $word in statement list_blogentries, constraints parameter");
	                    return false;
	                }
	                if ($attribute == 'keyword') {
	                    $operator = new Operator('is', 'string');
	                    $state = 3;
	                } elseif ($attribute == 'matchalltopics' || $attribute == 'matchanytopic') {
	                    if ($attribute == 'matchalltopics') {
	                        $operator = new Operator('is', 'boolean');
	                        $comparisonOperation = new ComparisonOperation($attribute, $operator, 'true');
	                        $parameters[] = $comparisonOperation;
	                    }
	                    $state = 1;
	                } else {
                        $state = 2;
	                }
	                if ($attribute == 'onfrontpage' || $attribute == 'onsection') {
	                    if (($index + 1) < count($p_constraints)) {
	                        try {
	                            $operator = new Operator($p_constraints[$index+1], 'switch');
	                        }
	                        catch (InvalidOperatorException $e) {
        	                    $operator = new Operator('is', 'switch');
        	                    $comparisonOperation = new ComparisonOperation($attribute, $operator, 'on');
                	            $parameters[] = $comparisonOperation;
                	            $state = 1;
	                        }
	                    } else {
    	                    $operator = new Operator('is', 'switch');
                            $comparisonOperation = new ComparisonOperation($attribute, $operator, 'on');
                            $parameters[] = $comparisonOperation;
                            $state = 1;
	                    }
	                }
	                break;
	            case 2: // reading the operator
	                $type = self::$s_parameters[$attribute]['type'];
	                try {
	                    $operator = new Operator($word, $type);
	                }
	                catch (InvalidOperatorException $e) {
    	                CampTemplate::singleton()->trigger_error("invalid operator $word of parameter constraints.$attribute in statement list_blogentries");
	                    return false;
	                }
	                $state = 3;
	                break;
	            case 3: // reading the value to compare against
	                $type = self::$s_parameters[$attribute]['type'];
	                $metaClassName = 'Meta'.ucfirst($type);
	                try {
    	                $valueObj = new $metaClassName($word);
	                } catch (InvalidValueException $e) {
                        CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_blogentries");
	                    return false;
	                }
       	            if ($attribute == 'type') {
                        $word = trim($word);
       	                $blogType = new BlogType($word);
       	                if (!$blogType->exists()) {
	                        CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_blogentries");
	                        return false;
       	                }
       	                $value = $word;
       	            } elseif ($attribute == 'topic') {
       	                $topicObj = new Topic($word);
       	                if (!$topicObj->exists()) {
	                        CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_blogentries");
	                        return false;
       	                } else {
       	                    $value = $topicObj->getTopicId();
       	                }
       	            } elseif ($attribute == 'author') {
                        if (strtolower($word) == '__current') {
                        	$context = CampTemplate::singleton()->context();
                        	$value = $context->blog->author->name;
                        } else {
                        	$value = $word;
                        }
       	            } else {
       	                $value = $word;
       	            }
       	            $comparisonOperation = new ComparisonOperation($attribute, $operator, $value);
//.........这里部分代码省略.........
开发者ID:nistormihai,项目名称:Newscoop,代码行数:101,代码来源:BlogEntriesList.php


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