|
:
[2] 1
|
web-service c - 1C Bitrix |
|
: - SharePoint , .
ws , spdoc -.
, #WORK_AREA#.
index.php
<?php
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php");
if (CModule::IncludeModule("webservice")) {
require($_SERVER["DOCUMENT_ROOT"] . "/ws/spdoc/spdoc.php");
$webservice = new CWebService();
if (!$webservice->RegisterWebService('CGenericWSDLSpdoc')) {
throw new Exception('Couldn't register webservice');
}
$result = $webservice->SOAPServerProcessRequest('spdoc.ws');
if (!$result) {
throw new Exception('Couldn't process request');
}
$response = $webservice->GetSOAPServerResponse('spdoc.ws');
echo $response;
} else {
throw new Exception('Couldn't initialize webservice');
}
wsdl.php web-service
<?php
ini_set('display_errors', 1);
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php");
if (CModule::IncludeModule("webservice") ) {
require($_SERVER["DOCUMENT_ROOT"] . "/ws/spdoc/spdoc.php");
$webservice = new CWebService();
if (!$webservice->RegisterWebService('CGenericWSDLSpdoc')) {
throw new Exception('Couldn't register webservice');
}
$wsdl = $webservice->GetWSDL('spdoc.ws');
if (!$wsdl) {
throw new Exception('Couldn't create WSDL');
}
echo $wsdl;
} else {
throw new Exception('Couldn't initialize webservice');
}
spdoc.php - .
<?php
class createFile
{
var $mimeType;
var $fileName;
var $fileSize;
var $fileContent;
}
class cInputSp
{
var $group; //
var $subject; //
var $method; //.
var $file_a; //
}
class CGenericWSDLSpdoc extends IWebService
{
var $paramInfoBlock = array(
'IBLOCK_ID' => 18, // ID
'IBLOCK_GROUP' => 19 // ID
);
function _trim(&$obInput){
$a_class = get_class($obInput);
$attribs = get_class_vars($a_class);
foreach ($attribs as $key=>$val){
if (is_string($obInput->$key)){
$obInput->$key = trim($obInput->$key);
}
}
}
function loadAttachFile ($file, $nameFile, &$errString) {
//
$this ->_trim($file);
if (empty($file->fileName) or $file->fileName == '?') return false; // file
if (empty($file->fileContent)) {$errString .= 'No file content: '.$file->fileName.'. '; return false;}
if (empty($file->mimeType)) {$errString .= 'No mime-type: '.$file->fileName.'. '; return false;}
$fileArray = array();
$tmpFile = $_SERVER["DOCUMENT_ROOT"]."/ws/spdoc/".$nameFile;
($f = fopen($tmpFile,'w+b')) or die('Error create temp file.' );
if (!$fileArray['size'] = fwrite($f,base64_decode($file->fileContent))) {$errString .= 'Error write temp file. '; return false;}
fclose($f);
$fileArray['name'] = $file->fileName;
$fileArray['tmp_name'] = $tmpFile;
$fileArray['type'] = $file->mimeType;
return $fileArray;
}
function publication($data)
{
global $USER;
$this ->_trim($data);
$errString = '';
if ( CModule::IncludeModule("iblock") ) {
// NUMBER . , SP.
//
// last number of publication
$arSelect = Array("ID", "PROPERTY_NUMBER");
$arFilter = Array("IBLOCK_ID" => $this->paramInfoBlock ['IBLOCK_ID'],"INCLUDE_SUBSECTIONS" => "Y");
global $DB;
$strSql = '
SELECT MAX(CAST(VALUE AS UNSIGNED)) AS max_num
FROM b_iblock_element_property AS a
INNER JOIN b_iblock_property AS b ON b.ID = a.IBLOCK_PROPERTY_ID
WHERE b.CODE = "NUMBER"
';
$NumberPubl = $DB->Query($strSql)->getNext();
$NumberPubl = $NumberPubl['max_num'] + 1;
// ,
$arSelect = Array("ID", "NAME");
$arFilter = Array("IBLOCK_ID" => $this->paramInfoBlock['IBLOCK_GROUP'],"INCLUDE_SUBSECTIONS" => "Y","NAME"=>$data->group);
$items = CIBlockElement::GetList(false, $arFilter, false, false, $arSelect);
$idGroup = 0;
if ($lastEl = $items->GetNextElement()){
$idGroup = $lastEl->fields['ID'];
}
else {
$el = new CIBlockElement;
$arLoadProductArray = Array(
"MODIFIED_BY" => $USER->GetID(), //
"IBLOCK_ID" => intval($this->paramInfoBlock ['IBLOCK_GROUP']),
"NAME" => $data->group,
"ACTIVE" => "Y", //
"PREVIEW_TEXT" => '',
"DETAIL_TEXT" => '',
);
$idGroup = $el->Add($arLoadProductArray);
}
//
$el = new CIBlockElement;
$PROP = array();
$PROP['NUMBER'] = $NumberPubl;
$PROP['METHOD'] = $data->method;
$PROP['GROUP'] = $idGroup;
if ($fileArray = $this->loadAttachFile($data->file_a, 'file_a', $errString) )
$PROP['FILE'] = $fileArray; //
$arLoadProductArray = Array(
"MODIFIED_BY" => $USER->GetID(), //
"IBLOCK_ID" => intval($this->paramInfoBlock ['IBLOCK_ID']),
"PROPERTY_VALUES" => $PROP,
"NAME" => $data->subject,
"ACTIVE" => "Y", //
"PREVIEW_TEXT" => '',
"DETAIL_TEXT" => '',
);
$product_id = 0;
if ($product_id = $el->Add($arLoadProductArray))
{return array('id' => intval($product_id),'errString'=> $errString);}
else
{return array('id' => intval($product_id),'errString'=> $errString.'Can not add record to DB');}
}
}
function delete($id)
{
if (CModule::IncludeModule("iblock")) {
if (!CIBlockElement::Delete($id)) {
return false;
}
else
return true;
}
}
function GetWebServiceDesc()
{
// web-service
$wsdesc = new CWebServiceDesc();
$wsdesc->wsname = "spdoc.ws";
$wsdesc->wsclassname = "CGenericWSDLSpdoc";
$wsdesc->wsdlauto = true;
$wsdesc->wsendpoint = 'http://'.$_SERVER['HTTP_HOST'].'/ws/spdoc/index.php';
$wsdesc->wstargetns = CWebService::GetDefaultTargetNS();
$wsdesc->classTypes = array();
$wsdesc->structTypes = array();
/* this tryed to be loaded into a class */
$wsdesc->classTypes["createFile"] =
array(
"mimeType" => array("varType" => "string", "strict" => "no"),// "strict" => "no" ,
"fileName" => array("varType" => "string", "strict" => "no"),
"fileSize" => array("varType" => "string", "strict" => "no"),
"fileContent" => array("varType" => "string", "strict" => "no"),
);
$wsdesc->classTypes["cInputSp"] =
array(
"group" => array("varType" => "string"),
"subject" => array("varType" => "string"),
"method" => array("varType" => "string"),
"file_a" => array("varType" => "createFile")
);
$wsdesc->classes = array(
"CGenericWSDLSpdoc" => array(
"delete" => array(
"type" => "public",
"name" => "delete",
"description" => "",
"input" => array(
"id" => array("varType" => "integer"),
),
"output" => array(
"result" => array("varType" => "boolean")
)
),
"publication" => array(
"type" => "public",
"name" => "publication",
"description" => "Adds item with data, [out] array(integer id, string errString if attached file have name and haven't content or mime type)
([in] class (
group - ,
subject - ,
method - ,
file_a - )",
"input" => array(
"data" => array("varType" => "cInputSp")
),
"output" => array(
"id" => array("varType" => "integer"),
"errString" => array("varType" => "string"),
)
)
));
return $wsdesc;
}
}
- Initial WSDL /ws/spdoc/wsdl.php
- , soapUI.
.
|
|
|
|

Gibrat Jean Pierre , 14 1954 . , , , . . . . 70- , , 1975 1977 . , . .
|
|
|
|
, , Lookatme. , , . , , . .



, - .

, .

. , .


, .


. .


, , . , .

, .

. .

, , , .

, , . , , .

, . .

.




, .

.


.





. - , .
|
1C Bitrix |
|
bitrix/components klient .
filter.
:
.description.php
<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
$arComponentDescription = array(
"CACHE_PATH" => "Y",
);
?>
.parameters.php
<?
if(!defined("B_PROLOG_INCLUDED")||B_PROLOG_INCLUDED!==true)die();
$arComponentParameters = array(
'PARAMETERS' => array(
'CACHE_TIME' => array('DEFAULT'=>3600),
),
);
?>
component.php
<?
if(CModule::IncludeModule("iblock"))
{
// IBLOCK_ID=22 ,
// .
// GetList , .
$arFilter = Array("IBLOCK_ID"=>22, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "INCLUDE_SUBSECTIONS"=>"Y");
$items = CIBlockElement::GetList(Array(), $arFilter, false, false,array("ID","NAME"));
while ($enum_fields = $items->GetNext())
$arResult['BREND'][] = array(
"ID" => $enum_fields["ID"],
"NAME" => $enum_fields["NAME"],
);
}
$arResult["FORM_ACTION"] = isset($_SERVER['REQUEST_URI'])? htmlspecialchars($_SERVER['REQUEST_URI']): "";
$this->IncludeComponentTemplate();
?>
<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
$arComponentDescription = array(
"CACHE_PATH" => "Y",
);
?>
images - .
templates -
.default
style.css
.filter_name {margin: 10px;font-weight: bold;background-color: #F1F5FA;}
.filter_submit {margin: 20px 10px;}
template.php
<form action="<?$APPLICATION->GetCurDir();?>" method="GET">
<p class="filter_name">:</p>
<p class="filter_check">
<?foreach ($arResult['BREND'] as $key =>$brend):?>
<input type="checkbox" name="brend[]" value=<?=$brend['ID']?> <?if(@( in_array($brend['ID'], $_SESSION["brend"]))):?> checked <?endif?>><?=$brend['NAME']?><br>
<?endforeach;?>
</p>
<p class="filter_submit">
<input type="submit" value="" name="set_f">
<input type="submit" value="" name="del_f">
</p>
</form>
footer.php .
<?
$ttt = explode("/",$APPLICATION->GetCurDir());
$razdel = $ttt[1];
if ($razdel == "product_catalogue" || $razdel == "ready_catalogue"){
//
$APPLICATION->IncludeComponent("klient:filter", ".default", array(
"CACHE_TIME" => "3600"
),
false
);
}
?>
bitrix:catalog.
, .
.
arrFilterCat.
, arrFilterCat.
, $GLOBALS['arrFilterCat'] .
, section.php bitrix:catalog.section
if(!$GLOBALS['arrFilterCat']) GLOBAL $arrFilterCat;
if (isset($_GET["set_f"]))
{ $_SESSION["brend"] = $_GET['brend'];
}
if (isset($_SESSION["brend"])) $arrFilterCat['PROPERTY_BREND'] = $_SESSION['brend'];
if (isset($_GET["del_f"]))
{ unset($_SESSION["brend"]);
unset($arrFilterCat['PROPERTY_BREND']);
}
|
|
:
[2] 1
|