Skip to content

Commit 9d0a350

Browse files
author
Thuong
committed
joomla-content
1 parent 503d13d commit 9d0a350

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* @package Redcore
4+
* @subpackage Api
5+
*
6+
* @copyright Copyright (C) 2008 - 2021 redWEB.dk. All rights reserved.
7+
* @license GNU General Public License version 2 or later, see LICENSE.
8+
*/
9+
10+
defined('JPATH_BASE') or die;
11+
12+
/**
13+
* Api Helper class for overriding default methods
14+
*
15+
* @package Redcore
16+
* @subpackage Api Helper
17+
* @since 1.8
18+
*/
19+
class RApiHalHelperSiteContent
20+
{
21+
/**
22+
* Service for creating content.
23+
*
24+
* @param string $data content
25+
*
26+
* @return boolean True on success. False otherwise.
27+
*/
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+
}
57+
}
58+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://local.test.aesirx.io:88/media/redcore/webservices/site.content.1.0.0.wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://local.test.aesirx.io:88/media/redcore/webservices/site.content.1.0.0.wsdl">
3+
<wsdl:types>
4+
<s:schema targetNamespace="http://local.test.aesirx.io:88/media/redcore/webservices/site.content.1.0.0.wsdl" elementFormDefault="unqualified">
5+
<s:complexType name="ArrayOfStringType">
6+
<s:sequence>
7+
<s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string"/>
8+
</s:sequence>
9+
</s:complexType>
10+
<s:element name="create">
11+
<s:complexType>
12+
<s:sequence>
13+
<s:element minOccurs="0" maxOccurs="1" name="data" type="s:string"/>
14+
</s:sequence>
15+
</s:complexType>
16+
</s:element>
17+
<s:element name="createResponse">
18+
<s:complexType>
19+
<s:sequence>
20+
<s:element minOccurs="1" maxOccurs="1" name="result" type="s:boolean"/>
21+
</s:sequence>
22+
</s:complexType>
23+
</s:element>
24+
</s:schema>
25+
</wsdl:types>
26+
<wsdl:service name="site.content.1.0.0">
27+
<wsdl:documentation/>
28+
<wsdl:port name="site.content.1.0.0_Soap" binding="tns:site.content.1.0.0">
29+
<soap:address location="http://local.test.aesirx.io:88/administrator/index.php?webserviceClient=site&amp;webserviceVersion=1.0.0&amp;option=content&amp;api=soap"/>
30+
</wsdl:port>
31+
</wsdl:service>
32+
<wsdl:message name="createRequest">
33+
<wsdl:part name="parameters" element="tns:create"/>
34+
</wsdl:message>
35+
<wsdl:message name="createResponse">
36+
<wsdl:part name="parameters" element="tns:createResponse"/>
37+
</wsdl:message>
38+
<wsdl:portType name="site.content.1.0.0">
39+
<wsdl:operation name="create">
40+
<wsdl:input message="tns:createRequest"/>
41+
<wsdl:output message="tns:createResponse"/>
42+
</wsdl:operation>
43+
</wsdl:portType>
44+
<wsdl:binding name="site.content.1.0.0" type="tns:site.content.1.0.0">
45+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
46+
<wsdl:operation name="create">
47+
<soap:operation soapAction="create" type="document"/>
48+
<wsdl:input>
49+
<soap:body use="literal"/>
50+
</wsdl:input>
51+
<wsdl:output>
52+
<soap:body use="literal"/>
53+
</wsdl:output>
54+
</wsdl:operation>
55+
</wsdl:binding>
56+
</wsdl:definitions>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<apiservice client="site">
3+
<name>content</name>
4+
<author/>
5+
<copyright/>
6+
<description/>
7+
<config>
8+
<name>content</name>
9+
<version>1.0.0</version>
10+
<authorizationAssetName>com_{webserviceName}</authorizationAssetName>
11+
</config>
12+
<operations>
13+
<documentation authorizationNeeded="false" source="auto" url=""/>
14+
<create authorizationNeeded="false" strictFields="false" authorization="" dataMode="helper" optionName="" modelClassName="" modelClassPath="" isAdminClass="false" functionName="save" functionArgs="" validateData="none" validateDataFunction="validate" tableName="">
15+
<fields>
16+
<field name="data" transform="string" defaultValue="" isRequiredField="false" isPrimaryField="false"/>
17+
</fields>
18+
<resources>
19+
<resource displayGroup="_links" displayName="documentation" fieldFormat="{webserviceUrlPath}&amp;format=doc#{rel}" linkTitle="Documentation" linkName="{webserviceName}" hrefLang="" linkTemplated="true" linkRel="curies"/>
20+
<resource displayGroup="_links" displayName="base" fieldFormat="/" linkTitle="Default page"/>
21+
<resource displayGroup="_links" displayName="{webserviceName}:list" fieldFormat="{webserviceUrlPath}"/>
22+
<resource displayGroup="_links" displayName="{webserviceName}:self" fieldFormat="{webserviceUrlPath}&amp;id={id}"/>
23+
<resource displayName="result" fieldFormat="{result}" transform="boolean"/>
24+
</resources>
25+
</create>
26+
</operations>
27+
<complexArrays/>
28+
</apiservice>

0 commit comments

Comments
 (0)