function getSchema($name)
{
    $schema = new stdClass();
    $schema->name = $name;
    $schema->url = "http://schema.org/" . $name;
    $schema->properties = array();
    $yql_base_url = "http://query.yahooapis.com/v1/public/yql";
    $yql_query = "select * from html where url=\"http://schema.org/" . $name . "\" AND xpath=\"//div[@id='mainContent']\"";
    $yql_query_url = $yql_base_url . "?q=" . urlencode($yql_query);
    $yql_query_url .= "&format=json";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $yql_query_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $content = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    $jsonObject = json_decode($content);
    $result = $jsonObject->query->results;
    if ($jsonObject->query->count > 0) {
        if (is_array($result->div->table)) {
            $result->div->table = $result->div->table[0];
        }
        if (is_array($result->div->table->tbody)) {
            $result->div->table->tbody = $result->div->table->tbody[0];
        }
        $trs = $result->div->table->tbody->tr;
        if (!is_array($trs)) {
            $trs = array($trs);
        }
        if ($result->div->table->thead[1]->tr->th->p->a->content == $name) {
            foreach ($trs as $index => $tr) {
                $object = new stdClass();
                if (isset($tr->th)) {
                    $object->name = getPropName($tr->th);
                    $object->type = getPropType($tr->td);
                } else {
                    $object->name = getPropName($tr);
                    $object->type = getPropType($tr);
                }
                $schema->properties[] = $object;
            }
        }
        $schema->parent = getParrentClass($result->div->h1);
    }
    var_dump($schema);
    return $schema;
}
Example #2
0
echo $arResult["NAV_STRING"];
?>
<br />
<?endif;?>

<table class="format_table">
	<tr>
		<?foreach(	$arParams["FIELD_CODE"] as $i=>$code):?>
			<th><?php 
echo GetMessage("IBLOCK_FIELD_" . $code);
?>
</th>
		<?endforeach;?>
		<?foreach($arParams["PROPERTY_CODE"] as $i => $code):?>
			<th><?php 
echo getPropName($code, $arParams["IBLOCK_ID"]);
?>
</th>
		<?endforeach;?>
		<? foreach( $arParams["ACTIONS"] as $key => $link ){ ?>
			<th></th>
		<?}?>
		
	</tr>
<?foreach($arResult["ITEMS"] as $arItem):?>
	<?
	$this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT"));
	$this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
	?>
	<tr class="news-item" id="<?php 
echo $this->GetEditAreaId($arItem['ID']);