Beispiel #1
0
function PageHome(&$skeleton)
{
    $articles = Entities::retrieveGroupedEntities(ARTICLES);
    $itemlist = new ItemList($skeleton);
    $itemlist->setBorders(array('top' => '-', 'bottom' => '-', 'left' => '+', 'right' => '+'));
    $ascii_article = new Article($skeleton, current($articles));
    $skeleton->addWidget($ascii_article);
    $count = 0;
    while ($article = next($articles)) {
        ++$count;
        $text = "";
        $text .= "[url=";
        $text .= Common::urlFor('view_article', array('token' => $article->getToken())) . ']';
        $text .= "[b]" . $article->getCategory() . "[/b]";
        $text .= "/" . $article->getTitle() . '[/url]';
        $text .= " (" . $article->getDate() . ")";
        if ($count < count($articles) - 1) {
            $text .= "\n";
        }
        $itemlist->setText($text);
    }
    if ($count > 0) {
        $skeleton->addWidget($itemlist);
    }
}
Beispiel #2
0
function PageViewAsText($token)
{
    header('content-type: text/html');
    if ($article = Entities::retrieveEntity($token)) {
        echo '<pre>' . Ascii::generateHTML($article->getContent()) . '</pre>';
    } else {
        echo "No matching article found.";
    }
    exit;
}
Beispiel #3
0
function PageViewArticle($skeleton, $token)
{
    if ($article = Entities::retrieveEntity($token)) {
        $ascii_article = new Article($skeleton, $article);
        $skeleton->addWidget($ascii_article);
    } else {
        $text = new TextContent($skeleton);
        $text->addText("No matchin article found :'(");
        $skeleton->addWidget($text);
    }
}
Beispiel #4
0
function SearchArticles($pattern, $skeleton)
{
    $matches = 0;
    $articles = Entities::retrieveGroupedEntities(ARTICLES);
    $itemlist = new ItemList($skeleton);
    foreach ($articles as $article) {
        if (stristr($article->getContent(), $pattern)) {
            ++$matches;
            $link = Common::urlFor('view_article', array('token' => $article->getToken()));
            $itemlist->setText('<a href="' . $link . '">' . $article->getTitle() . '</a>');
        }
    }
    $skeleton->addWidget($itemlist);
    return $matches;
}
* A copy of the License is located at
*
* https://www.axibase.com/atsd/axibase-apache-2.0.pdf
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace axibase\atsdPHP;

require_once '../atsdPHP/models/Entities.php';
require_once '../atsdPHP/HttpClient.php';
require_once '../atsdPHP/Utils.php';
$expression = 'name like \'nurswgvmw*\'';
$tags = 'app, os';
$limit = 10;
$queryClient = new Entities();
$params = array("limit" => $limit, 'expression' => $expression, 'tags' => $tags);
$responseEntities = $queryClient->findAll($params);
$viewConfig = new ViewConfiguration('Entities for expression: ' . $expression . "; tags: " . $tags . "; limit: " . $limit, 'entities', array('lastInsertTime' => 'unixtimestamp'));
$entitiesTable = Utils::arrayAsHtmlTable($responseEntities, $viewConfig);
$entity = "awsswgvml001";
$responseEntity = $queryClient->find($entity);
$viewConfig = new ViewConfiguration('Entity: ' . $entity, "entity");
$entityTable = Utils::arrayAsHtmlTable(array($responseEntity), $viewConfig);
$params = array("limit" => $limit);
$responseMetrics = $queryClient->findMetrics($entity, $params);
$viewConfig = new ViewConfiguration('Metrics for entity: ' . $entity, "metrics");
$metricsTable = Utils::arrayAsHtmlTable($responseMetrics, $viewConfig);
Utils::render(array($entitiesTable, $entityTable, $metricsTable));
Beispiel #6
0
<?php

foreach (Entities::retrieveCategories() as $category) {
    ?>
<h2>/<?php 
    echo $category;
    ?>
</h2>
<div class="last_articles">
  <?php 
    foreach (Entities::retrieveEntities(ARTICLES . '/' . $category) as $article) {
        ?>
  <h3>
    <a href="<?php 
        echo Common::urlFor('view_article', array('token' => $article->getToken()));
        ?>
">
   <?php 
        echo Common::stripString($article->getTitle(), 19);
        ?>
    </a>
  </h3>
  <?php 
    }
    ?>
</div>
<?php 
}
<?php

/*
* Copyright 2015 Axibase Corporation or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* https://www.axibase.com/atsd/axibase-apache-2.0.pdf
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace axibase\atsdPHP;

require_once '../atsdPHP/models/Entities.php';
require_once '../atsdPHP/HttpClient.php';
$expression = 'name like \'*\'';
$limit = 1;
$queryClient = new Entities();
$params = array("limit" => $limit, 'expression' => $expression);
$responseEntities = $queryClient->findAll($params);
if (empty($responseEntities)) {
    exit("Connection failed!");
}
exit("Connection success!");
Beispiel #8
0
$p4 = '';
$p5 = '';
if (!empty($source)) {
    $p1 = $source;
    if (!isset($Encrypt) || empty($Encrypt)) {
        $Encrypt = new Encrypt();
    }
    $p1 = $Encrypt->fix_filename_str($p1);
    if (!isset($Translit) || empty($Translit)) {
        $Translit = new Translit();
    }
    $p1 = $Translit->Transliterate($p1);
    $p1 = $Encrypt->unix_filename($p1);
    $p = $source;
    if (!isset($Entities) || empty($Entities)) {
        $Entities = new Entities();
    }
    $p = $Entities->ipa_text_to_dec_ents($p);
    /* this replacement should be done before any other
    	  conversion to numeric entities */
    //$p = $Entities->text_digits_to_dec_ents($p);
    $p = $Entities->text_symbs_to_dec_ents($p);
    $p = $Entities->named_symbs_to_dec_ents($p);
    //$p = $Entities->latin_text_chars_to_dec_ents($p);
    $p = $Entities->acc_text_to_dec_ents($p);
    $p = $Entities->acc_named_to_dec_ents($p);
    $p = $Entities->cyr_text_chars_to_dec_ents($p);
    $p = $Entities->cyr_named_chars_to_dec_ents($p);
    $p = $Entities->hex_ents_to_dec_ents($p);
    $p = str_replace("&", "&amp;", $p);
    if (!empty($ent_amp)) {
Beispiel #9
0
$ent_parse = isset($_REQUEST['ent_parse']) ? $_REQUEST['ent_parse'] : '';
$ent_amp = isset($_REQUEST['ent_amp']) ? $_REQUEST['ent_amp'] : '';
$ent_single_quotes = isset($_REQUEST['ent_single_quotes']) ? $_REQUEST['ent_single_quotes'] : '';
$ent_double_quotes = isset($_REQUEST['ent_double_quotes']) ? $_REQUEST['ent_double_quotes'] : '';
$ent_lt_gt = isset($_REQUEST['ent_lt_gt']) ? $_REQUEST['ent_lt_gt'] : '';
$ent_hyphenminus = isset($_REQUEST['ent_hyphenminus']) ? $_REQUEST['ent_hyphenminus'] : '';
$p = '';
if (!empty($source)) {
    $p = $source;
    if (!empty($ent_parse)) {
        if (!isset($Typography) || empty($Typography)) {
            $Typography = new Typography();
        }
        $p = $Typography->parse($p);
        if (!isset($Entities) || empty($Entities)) {
            $Entities = new Entities();
        }
        $p = $Entities->ipa_text_to_dec_ents($p);
        //$p = $Entities->text_digits_to_dec_ents($p);
        $p = $Entities->text_symbs_to_dec_ents($p);
        $p = $Entities->named_symbs_to_dec_ents($p);
        //$p = $Entities->latin_text_chars_to_dec_ents($p);
        $p = $Entities->acc_text_to_dec_ents($p);
        $p = $Entities->acc_named_to_dec_ents($p);
        //$p = $Entities->cyr_text_chars_to_dec_ents($p);
        $p = $Entities->cyr_named_chars_to_dec_ents($p);
        $p = $Entities->hex_ents_to_dec_ents($p);
    }
    $p = str_replace("&", "&amp;", $p);
    if (!empty($ent_amp)) {
        $p = str_replace("&", "&amp;amp;", $p);
Beispiel #10
0
 protected function prepareInsert($item)
 {
     if (empty($item)) {
         return;
     }
     if (is_string($item)) {
         $item = Entities::replaceAllEntities($item);
         $frag = $this->ownerDocument->createDocumentFragment();
         try {
             $frag->appendXML($item);
         } catch (Exception $e) {
         }
         return $frag;
     }
     if ($item instanceof \DOMNode) {
         if ($item->ownerDocument !== $this->ownerDocument) {
             return $this->ownerDocument->importNode($item, true);
         }
         return $item;
     }
 }
Beispiel #11
0
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>mxs_area</title>
  <subtitle><?php 
echo TITLE;
?>
</subtitle>
  <link href="http://aimxhaisse.com/"/>
  <author>
    <name>Sebastien Rannou</name>
    <email>rannou.sebastien@gmail.com</email>
  </author>

  <?php 
foreach (Entities::retrieveGroupedEntities(ARTICLES) as $article) {
    ?>
  <entry>
    <title><?php 
    echo $article->getTitle();
    ?>
</title>
    <link href="<?php 
    echo ROOT_URI . Common::urlFor('view_article', array('token' => $article->getToken()));
    ?>
"/>
    <updated><?php 
    echo date(DATE_ATOM, $article->getTimestamp());
    ?>
</updated>
    <summary type="xhtml"><?php 
Beispiel #12
0
<?php

namespace axibase\atsdPHP;

require_once '../atsdPHP/HttpClient.php';
require_once '../atsdPHP/models/Entities.php';
$client = new Entities();
if (empty($_REQUEST['entity'])) {
    exit("Entity is not specified");
}
$metrics = $client->findMetrics($_REQUEST['entity'], array("useEntityInsertTime" => true));
if ($metrics === false) {
    $metrics = array();
}
if (!isset($_REQUEST['lag'])) {
    $_REQUEST['lag'] = "99999999";
}
if (!isset($_REQUEST['ahead'])) {
    $_REQUEST['ahead'] = "99999999";
}
if (!isset($_REQUEST['status'])) {
    $_REQUEST['status'] = 'all';
}
function prepareTimestamp($timestamp)
{
    $date = new \DateTime();
    $date->setTimestamp($timestamp / 1000);
    return $date->format('Y-m-d H:i:s');
}
?>
<!DOCTYPE html>
</form>
<?php 
if (!empty($_REQUEST['entity'])) {
    ?>

<p id="title-0" class="title"></p>
<div id="widget-0"></div>

<p class="title">Tags:</p>
<table border="1px" class="tags-table">
    <tr>
        <th>name</th>
        <th>value</th>
    </tr>
    <?php 
    $client = new Entities();
    $entityData = $client->find($_REQUEST['entity']);
    foreach ($entityData['tags'] as $key => $value) {
        echo "<tr><td>" . $key . "</td><td>" . $value . "</td></tr>";
    }
    ?>
</table>
</body>
<script>
    function onload() {
        onBodyLoad();
        loadWidgets('WidgetExample.config?cache=' + Date.now(), function (widgetConfigs) {
            var widget = widgetConfigs[0];
            widget.path = "WidgetExampleSeriesProxy.php";

            var series = widget.series[0];