public function get($url, $request = null, $options = array()) { $xml = $this->httpClient->get($url, $request, $options); if ($xml && !ar_error::isError($xml)) { return $this->parse($xml); } else { return $xml; } }
public function readFromArray($csvArray, $settings = array()) { $context = pobject::getContext(); $me = $context["arCurrentObject"]; $csv = new csvFeed($me, $settings); $result = $csv->readFromArray($csvArray, $settings); if ($result && ar_error::isError($result)) { return $result; } else { return $csv; } }
public function testSaveAndGet() { global $AR; $me = $this; ar::context()->callAtPath(TESTBASE . 'file-nls/', function () use($me) { $content = "file contents"; $result = ar_store_files::save('test', $content, 'nl'); $me->assertEquals($result, strlen($content)); $result = ar_store_files::get('test', 'nl'); if (!ar_error::isError($result)) { $result = $result->getContents(); } $me->assertEquals($content, $result); }); }
public static function put($url, $contents, $options = array()) { $path = parse_url($url, PHP_URL_PATH); if ($path !== false) { $fileName = basename($path); $client = new ar_connect_ftpClient($url, $options); if (!ar_error::isError($client)) { return $client->put($contents, $fileName); } else { return $client; } } else { return ar::error("Could not parse url " . (string) $url, 11); } }
function importTemplate($cpath, $args) { global $store, $axstore; $templatesrc = current($axstore->call('system.get.template.php', $args, $axstore->get($cpath))); $templatedst = current($store->call('system.get.template.php', $args, $store->get($cpath))); if (!$store->exists($cpath)) { // cannot install config on non-existing path print "{$cpath} doesn't exists, skipping\n"; } if (!ar_error::isError($templatesrc)) { if (ar_error::isError($templatedst)) { // error means no template found // save template $args['template'] = $templatesrc; ar::get($cpath)->call('system.save.layout.phtml', $args); } else { print "Already a configfile defined on {$cpath}, please merge the following in your configfile " . $args['function'] . "\n"; print $templatesrc . "\n"; } } else { print "Error src template not found on {$cpath} \n"; } }
public static function _isError($ob) { return ar_error::isError($ob); }
public function post($path, $options = array()) { $url = ar::url($this->rootURL . $path . '.json'); $json = $this->client->post($url, $options); if ($json && !ar_error::isError($json)) { return json_decode($json); } else { return $json; } }
<?php if ($this->CheckLogin("layout") && $this->CheckConfig()) { $args = array("type" => $this->getvar("newtype"), "function" => $this->getvar("newfunction"), "language" => $this->getvar("newlanguage"), "default" => $this->getvar("default"), "template" => $this->getvar("template"), "private" => $this->getvar("private")); if ($args['function'] == 'config.ini' && $this instanceof $args['type']) { $result = $this->call('system.template.test.phtml', $args); if (!$result) { $this->error = 'Unknown error in template ' . $args['function']; } else { if (ar_error::isError($result)) { $this->error = $result->getMessage(); } } } if (!$this->error) { $this->call("system.save.layout.phtml", $args); } if (!$this->error) { $this->call("window.opener.objectadded.js"); $formArgs = array(); } else { $formArgs = array('error' => $this->error); } $this->call("dialog.templates.edit.form.php", $formArgs); }
$deleted_templates[] = $item['name']; break; case "E": // existing template, no need for recompile break; case "Skipped": case "C": break; // Don't try to recompile conflicted templates // Don't try to recompile conflicted templates default: $updated_templates[] = $item['name']; break; } $props = $fstore->svn_get_ariadne_props($svn, $item['name']); if (ar_error::isError($props)) { echo "<span>" . $props->getMessage() . "</span>"; } else { if ($item["filestate"] == "A") { echo "<span class='svn_addtemplateline'>Added " . $this->path . $props["ar:function"] . " (" . $props["ar:type"] . ") [" . $props["ar:language"] . "] " . ($props["ar:default"] == '1' ? $ARnls["default"] : "") . "</span>\n"; } elseif ($item["filestate"] == "U") { // substr to work around bugs in SVN.php echo "<span class='svn_revisionline'>Updated " . $this->path . $props["ar:function"] . " (" . $props["ar:type"] . ") [" . $props["ar:language"] . "] " . ($props["ar:default"] == '1' ? $ARnls["default"] : "") . "</span>\n"; } elseif ($item["filestate"] == "M" || $item["filestate"] == "G") { echo "<span class='svn_revisionline'>Merged " . $this->path . $props["ar:function"] . " (" . $props["ar:type"] . ") [" . $props["ar:language"] . "] " . ($props["ar:default"] == '1' ? $ARnls["default"] : "") . "</span>\n"; } elseif ($item["filestate"] == "E") { echo "<span class='svn_revisionline'>Existing " . $this->path . $props["ar:function"] . " (" . $props["ar:type"] . ") [" . $props["ar:language"] . "] " . ($props["ar:default"] == '1' ? $ARnls["default"] : "") . "</span>\n"; } elseif ($item["filestate"] == "C") { echo "<span class='svn_revisionline'>Conflict " . $this->path . $props["ar:function"] . " (" . $props["ar:type"] . ") [" . $props["ar:language"] . "] " . ($props["ar:default"] == '1' ? $ARnls["default"] : "") . "</span>\n"; } elseif ($item["filestate"] == "D") { // system.svn.delete.templates.php will report that this template has been deleted
public static function tryToParse($xml) { $result = $xml; if (!$xml instanceof ar_xmlNodeInterface) { if ($xml && strpos($xml, '<') !== false) { try { $result = self::parse('<root>' . $xml . '</root>'); if (ar_error::isError($result)) { $result = new ar_xmlNode((string) $xml); } else { $result = $result->firstChild->childNodes; } } catch (Exception $e) { $result = new ar_xmlNode((string) $xml); } } else { $result = new ar_xmlNode((string) $xml); } } return $result; }
$status .= "<span class='svndiff_headline'>" . htmlspecialchars($line) . "</span>\n"; $line = $linebased[++$i]; $firstspace = strpos($line, " ") + 1; $nextspace = strpos($line, "\t", $firstspace); $template = substr($line, $firstspace, $nextspace - $firstspace); $props = $fstore->svn_get_ariadne_props($svn, $template); if (!ar_error::isError($props) && count($props)) { $line = str_replace($template, $this->path . $props["ar:function"] . " (" . $props["ar:type"] . ") [" . $props["ar:language"] . "] " . ($props["ar:default"] == '1' ? $ARnls["default"] : ""), $line); } $status .= "<span class='svndiff_headline'>" . htmlspecialchars($line) . "</span>\n"; $line = $linebased[++$i]; $firstspace = strpos($line, " ") + 1; $nextspace = strpos($line, "\t", $firstspace); $template = substr($line, $firstspace, $nextspace - $firstspace); $props = $fstore->svn_get_ariadne_props($svn, $template); if (!ar_error::isError($props) && count($props)) { $line = str_replace($template, $this->path . $props["ar:function"] . " (" . $props["ar:type"] . ") [" . $props["ar:language"] . "] " . ($props["ar:default"] == '1' ? $ARnls["default"] : ""), $line); } $status .= "<span class='svndiff_headline'>" . htmlspecialchars($line) . "</span>\n"; break; case "@": // @@ $status .= "<span class='svndiff_offsetline'>" . htmlspecialchars($line) . "</span>\n"; break; case "-": // --- file -diff $status .= "<span class='svndiff_removeline'>" . htmlspecialchars($line) . "</span>\n"; break; case "+": // +++ file +diff $status .= "<span class='svndiff_addline'>" . htmlspecialchars($line) . "</span>\n";
public static function tryToParse($html) { $result = $html; if (!$html instanceof ar_xmlNodeInterface) { // ar_xmlNodeInterface is correct, there is no ar_htmlNodeInterface if ($html && strpos($html, '<') !== false) { try { $result = self::parse($html, 'UTF-8'); if (ar_error::isError($result)) { $result = new ar_htmlNode((string) $html); } else { $check = trim($html); /* DOMDocument::loadHTML always generates a full html document so the next bit of magic tries to remove the added elements */ if (stripos($check, '<p') === 0) { $result = $result->html->body[0]->childNodes; } else { $result = $result->html->body[0]; if ($result->firstChild->tagName == 'p') { $result = $result->firstChild; } $result = $result->childNodes; } } } catch (Exception $e) { $result = new ar_htmlNode((string) $html); } } else { $result = new ar_htmlNode((string) $html); } } return $result; }
public function _init($config) { $geo = new pinp_geo(); $result = $geo->init($config); if (!ar_error::isError($result)) { return $geo; } else { return $result; } }