Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions extensions/webservices/joomla/site.content.1.0.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* @package Redcore
* @subpackage Api
*
* @copyright Copyright (C) 2008 - 2021 redWEB.dk. All rights reserved.
* @license GNU General Public License version 2 or later, see LICENSE.
*/

defined('JPATH_BASE') or die;

/**
* Api Helper class for overriding default methods
*
* @package Redcore
* @subpackage Api Helper
* @since 1.8
*/
class RApiHalHelperSiteContent
{
/**
* Service for creating content.
*
* @param string $data content
*
* @return boolean True on success. False otherwise.
*/
public function save($data)
{
if (version_compare(JVERSION, '3.0', 'lt')) {
JTable::addIncludePath(JPATH_PLATFORM . 'joomla/database/table');
}

$data = (object) $data;
$article = JTable::getInstance('content');
$article->title = $data->title;
$article->alias = JFilterOutput::stringURLSafe($data->title);
$article->introtext = '<p>'.$data->description.'</p>';
$article->created = JFactory::getDate()->toSQL();;
$article->created_by_alias = $data->user;
$article->state = 1;
$article->access = 1;
$article->metadata = '{"page_title":"'.$data->title.'","author":"'.$data->user.'","robots":""}';
$article->language = '*';

if (!$article->check()) {
throw new Exception($article->getError());
return FALSE;
}

if (!$article->store(TRUE)) {
throw new Exception($article->getError());
return FALSE;
}
}
}
28 changes: 28 additions & 0 deletions extensions/webservices/joomla/site.content.1.0.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<apiservice client="site">
<name>content</name>
<author/>
<copyright/>
<description/>
<config>
<name>content</name>
<version>1.0.0</version>
<authorizationAssetName>com_{webserviceName}</authorizationAssetName>
</config>
<operations>
<documentation authorizationNeeded="false" source="auto" url=""/>
<create authorizationNeeded="false" strictFields="false" authorization="" dataMode="helper" optionName="" modelClassName="" modelClassPath="" isAdminClass="false" functionName="save" functionArgs="" validateData="none" validateDataFunction="validate" tableName="">
<fields>
<field name="data" transform="string" defaultValue="" isRequiredField="false" isPrimaryField="false"/>
</fields>
<resources>
<resource displayGroup="_links" displayName="documentation" fieldFormat="{webserviceUrlPath}&amp;format=doc#{rel}" linkTitle="Documentation" linkName="{webserviceName}" hrefLang="" linkTemplated="true" linkRel="curies"/>
<resource displayGroup="_links" displayName="base" fieldFormat="/" linkTitle="Default page"/>
<resource displayGroup="_links" displayName="{webserviceName}:list" fieldFormat="{webserviceUrlPath}"/>
<resource displayGroup="_links" displayName="{webserviceName}:self" fieldFormat="{webserviceUrlPath}&amp;id={id}"/>
<resource displayName="result" fieldFormat="{result}" transform="boolean"/>
</resources>
</create>
</operations>
<complexArrays/>
</apiservice>