root/trunk/lib/model/SnippetSnippet.php

Revision 2, 1.4 kB (checked in by fabien, 6 years ago)

initial import

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 require_once 'model/om/BaseSnippetSnippet.php';
4
5
6 /**
7  * Skeleton subclass for representing a row from the 'sn_snippet' table.
8  *
9  *
10  *
11  * You should add additional methods to this class to meet the
12  * application requirements.  This class will only be generated as
13  * long as it does not already exist in the output directory.
14  *
15  * @package model
16  */   
17 class SnippetSnippet extends BaseSnippetSnippet
18 {
19   public function getTags()
20   {
21     return $this->getAllTags();
22   }
23
24   public function setTags($phrase)
25   {
26     $con = Propel::getConnection();
27     try
28     {
29       $con->begin();
30
31       // remove old tags
32       $c = new Criteria();
33       $c->add(SnippetTagPeer::USER_ID, $this->getUserId());
34       $c->add(SnippetTagPeer::SNIPPET_ID, $this->getId());
35       SnippetTagPeer::doDelete($c);
36
37       // add new tags
38       $tags = TagTools::splitPhrase($phrase);
39       foreach($tags as $word)
40       {
41         $tag = new SnippetTag();
42         $tag->setUserId($this->getUserId());
43         $tag->setSnippetSnippet($this);
44         $tag->setName(TagTools::normalize($word));
45         $tag->save($con);
46       }
47
48       $con->commit();
49
50     }
51     catch (Exception $e)
52     {
53       $con->rollback();
54       throw $e;
55     }
56   }
57
58   public function getItemFeedDescription()
59   {
60     return $this->getHtmlBody();
61   }
62
63   public function setBody($body)
64   {
65     parent::setBody($body);
66
67     $this->setHtmlBody(myToolkit::transformToHtml($body));
68   }
69 }
70
Note: See TracBrowser for help on using the browser.