| Conditions | 4 |
| Paths | 6 |
| Total Lines | 28 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public function save($data) |
||
| 29 | { |
||
| 30 | if (version_compare(JVERSION, '3.0', 'lt')) { |
||
| 31 | JTable::addIncludePath(JPATH_PLATFORM . 'joomla/database/table'); |
||
| 32 | } |
||
| 33 | |||
| 34 | $data = (object) $data; |
||
| 35 | $article = JTable::getInstance('content'); |
||
| 36 | $article->title = $data->title; |
||
|
|
|||
| 37 | // $article->alias = JFilterOutput::stringURLSafe(time()); |
||
| 38 | $article->alias = JFilterOutput::stringURLSafe($data->title); |
||
| 39 | $article->introtext = '<p>'.$data->description.'</p>'; |
||
| 40 | $article->created = JFactory::getDate()->toSQL();; |
||
| 41 | $article->created_by_alias = $data->user; |
||
| 42 | $article->state = 1; |
||
| 43 | $article->access = 1; |
||
| 44 | $article->metadata = '{"page_title":"'.$data->title.'","author":"'.$data->user.'","robots":""}'; |
||
| 45 | $article->language = '*'; |
||
| 46 | // $article->catid = 1; |
||
| 47 | |||
| 48 | if (!$article->check()) { |
||
| 49 | throw new Exception($article->getError()); |
||
| 50 | return FALSE; |
||
| 51 | } |
||
| 52 | |||
| 53 | if (!$article->store(TRUE)) { |
||
| 54 | throw new Exception($article->getError()); |
||
| 55 | return FALSE; |
||
| 56 | } |
||
| 59 |