Esempio n. 1
0
function mogrifyDir($path, $type)
{
    echo "== mogrify {$path} to {$type}\n";
    $res = current(ar::get($path)->call('system.get.phtml'));
    if ($res && $res->type == "pdir") {
        print "Oldtype  is pdir, mogrify to new type {$type}\n";
        $res = ar::get($path)->call('system.mogrify.phtml', array('type' => $type));
    }
}
Esempio n. 2
0
 public function testObjectAllNLS()
 {
     global $AR;
     $obj = current(ar::get(TESTBASE . '/image-nls/image-nls/')->call('system.get.phtml'));
     foreach ($obj->data->nls->list as $nls => $language) {
         $content = $obj->getExif(false, true, false, $nls);
         $content = trim($content['IFD0']['ImageDescription']);
         $this->assertEquals($nls, $content);
     }
 }
Esempio n. 3
0
 public function testClosureCall()
 {
     $result = current(ar::get(TESTBASE . '/closure/')->call('closure.call.html'));
     $this->assertInternalType('array', $result);
     $this->assertCount(3, $result);
     if (is_array($result)) {
         $values = array_values($result);
         $this->assertEquals(['closure', 'closure child 1', 'closure child 2'], $values);
     }
 }
Esempio n. 4
0
 public function testParents()
 {
     global $AR;
     $obj = current(ar::get(TESTBASE . 'projects/demo/demo/images/')->call('system.get.phtml'));
     $parents = $obj->parents('', 'system.get.path.phtml');
     $this->assertTrue(in_array(TESTBASE . 'projects/demo/demo/images/', $parents));
     $parents = $obj->parents(TESTBASE . 'projects/demo/', 'system.get.path.phtml');
     // $top of the test object is TESTBASE.'/projects/demo/demo/
     // so the request path is 'above' the $top
     $this->assertEmpty($parents);
     $parents = $obj->parents(TESTBASE . 'projects/demo/', 'system.get.path.phtml', array(), TESTBASE . 'projects/demo/');
     $this->assertCount(1, $parents);
     $parents = $obj->parents('', 'system.get.path.phtml', array(), TESTBASE);
     $this->assertCount(5, $parents);
     $parents = $obj->parents(TESTBASE . 'projects/', 'system.get.path.phtml', array(), TESTBASE);
     $this->assertCount(2, $parents);
     $obj2 = current(ar::get(TESTBASE)->call('system.get.phtml'));
     $parents2 = $obj2->parents('projects/', 'system.get.path.phtml', array(), TESTBASE);
     $this->assertCount(2, $parents2);
     $this->assertEquals($parents, $parents2);
     $prep = array(TESTBASE, TESTBASE . 'projects/');
     $this->assertEquals($prep, $parents);
 }
Esempio n. 5
0
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";
    }
}
Esempio n. 6
0
function initTestData()
{
    global $AR, $ARCurrent, $store_config, $store, $ARConfig;
    $origAR = clone $AR;
    $origARCurrent = clone $ARCurrent;
    $origARConfig = clone $ARConfig;
    // become admin
    $AR->user = new object();
    $AR->user->data = new object();
    $AR->user->data->login = $ARLogin = "******";
    /* instantiate the store */
    $storetype = $store_config["dbms"] . "store";
    $store = new $storetype($root, $store_config);
    $res = ar::get('/projects/')->call('system.new.phtml', array('arNewType' => 'pproject', 'arNewFilename' => '/projects/{5:id}', 'en' => array('name' => 'Unit test dir (en)' . date(DATE_W3C)), 'nl' => array('name' => 'Unit test dir (nl)' . date(DATE_W3C)), 'de' => array('name' => 'Unit test dir (de)' . date(DATE_W3C))));
    $base = current($res);
    // set grants for testrunner user
    ar::get($res)->call('system.save.grants.phtml', array("path" => '/system/users/testrunner/', "newgrants" => 'read add edit >delete config layout'));
    define('TESTBASE', $base);
    importContent($base, getcwd() . '/www/install/packages/demo.ax');
    $AR = $origAR;
    $ARCurrent = $origARCurrent;
    $ARConfig = $origARConfig;
}
Esempio n. 7
0
function importMissingData($path)
{
    global $ARCurrent, $AR, $ax_config, $store;
    $importpath = false;
    echo "== testing for {$path}\n\n";
    $res = current(ar::get($path)->call('system.get.phtml'));
    if (!$res) {
        print "{$path} does not exists\n";
        $importpath = $path;
    }
    if ($importpath) {
        print "importing {$importpath}\n";
        $ARCurrent->nolangcheck = true;
        $ARCurrent->options["verbose"] = true;
        $ARCurrent->AXAction == "import";
        // become admin
        $AR->user = new object();
        $AR->user->data = new object();
        $AR->user->data->login = $ARLogin = "******";
        $ax_config["writeable"] = false;
        $ax_config["database"] = "../packages/base.ax";
        echo "ax file (" . $ax_config["database"] . ")\n";
        set_time_limit(0);
        $inst_store = $ax_config["dbms"] . "store";
        $axstore = new $inst_store("", $ax_config);
        if (!$axstore->error) {
            $ARCurrent->importStore =& $store;
            $args['srcpath'] = $importpath;
            $args['destpath'] = $importpath;
            $axstore->call("system.export.phtml", $args, $axstore->get("/"));
            $error = $axstore->error;
            $axstore->close();
        } else {
            $error = $axstore->error;
        }
    }
}
Esempio n. 8
0
    ?>
" class="inputline">
	</div>
	<div class="field">
		<label for="country" class="required"><?php 
    echo $ARnls["country"];
    ?>
</label>
		<select id="country" name="country">
			<option value=''><?php 
    echo $ARnls["none"];
    ?>
</option>
			<?php 
    $query = "object.parent='/system/addressbook/countries/' and name.nls='" . $nls . "' order by name.value";
    $list = ar::get('/system/addressbook/countries/')->find($query)->call('system.get.phtml');
    $country = $this->getdata("country", "none");
    foreach ($list as $entry) {
        $selected = $entry->data->value == $country ? 'selected' : '';
        printf('<option value="%s" %s>%s</option>', $entry->data->value, $selected, $entry->nlsdata->name);
    }
    ?>
		</select>
	</div>
	<div class="field">
		<label for="state" class="required"><?php 
    echo $ARnls["state"];
    ?>
</label>
		<input id="state" type="text" name="state" value="<?php 
    $this->showdata("state", "none");
Esempio n. 9
0
 /**
  * @large
  */
 public function testUpdateConflict()
 {
     $args = array('arNewType' => 'psection.library', 'arNewFilename' => '{5:id}', 'nl' => array('name' => 'test lib'), 'en' => array('name' => 'test lib'), 'de' => array('name' => 'test lib'));
     self::$testpath = current(ar::get(TESTBASE)->call('system.new.phtml', $args));
     $args = array('type' => 'pobject', 'function' => 'test.view.html', 'language' => 'any');
     $this->helperCheckout(22);
     $res = current(ar::get(self::$testpath)->call('system.get.template.php', $args));
     $this->assertEquals('template:test.view.html', $res);
     // create conflict
     $args = array("template" => 'changed', "default" => 1, "type" => 'pobject', "function" => 'test.view.html', "language" => 'any', "private" => false);
     $res = current(ar::get(self::$testpath)->call('system.save.layout.phtml', $args));
     // update outputs information, remove it for phpunit
     ob_start();
     ar::get(self::$testpath)->call('system.svn.update.php', array('revision' => 23));
     ob_end_clean();
     $res = current(ar::get(self::$testpath)->call('system.get.template.php', $args));
     $prep = "<<<<<<< .mine\nchanged=======\ntemplate:test.view.html\ntest:serverdiff\n>>>>>>> .r23\n";
     $this->assertEquals($prep, $res);
 }
Esempio n. 10
0
if ($scaffold && ar::exists($scaffold)) {
    $scaffoldOb = current(ar::get($scaffold)->call('system.get.phtml'));
    if ($scaffold) {
        // copy config from scaffold
        foreach ($scaffoldOb->data->config->pinp as $ttype => $tdata) {
            foreach ($tdata as $tfunction => $tlanguages) {
                foreach ($tlanguages as $tlanguage => $tid) {
                    if ($scaffoldOb->data->config->privatetemplates[$ttype][$tfunction]) {
                        $private = true;
                    } else {
                        $private = false;
                    }
                    if ($scaffoldOb->data->config->templates[$ttype][$tfunction][$tlanguage]) {
                        $default = true;
                    } else {
                        $default = false;
                    }
                    $template = $scaffoldOb->call('system.get.layout.phtml', array('type' => $ttype, 'function' => $tfunction, 'language' => $tlanguage));
                    $this->call('system.save.layout.phtml', array('type' => $ttype, 'function' => $tfunction, 'language' => $tlanguage, 'default' => $default, 'private' => $private, 'template' => $template));
                }
            }
        }
    }
    // copy all children from scaffold
    $objects = ar::get($scaffold)->find('')->limit(0)->order('object.path ASC')->call('system.get.name.phtml');
    foreach ($objects as $objectpath => $objectname) {
        $subpath = substr($objectpath, strlen($scaffold));
        ar::get($objectpath)->call('system.copyto.phtml', array('target' => $this->path . $subpath, 'search' => $scaffold, 'replace' => $this->path, 'defaultnls' => $this->data->nls->default));
    }
}
Esempio n. 11
0
<?php

if ($this->data->path && ar::exists($this->data->path)) {
    ar::get($this->data->path)->call("explore.browse.php", $arCallArgs);
}
Esempio n. 12
0
<?php

$arLanguage = ar::getvar('arLanguage');
if (!$arLanguage || $arLanguage != $ARConfig->nls->default) {
    return;
}
$scaffoldConfig = ar::acquire('settings.scaffolds');
if ($scaffoldConfig) {
    if (!is_array($scaffoldConfig)) {
        $scaffoldConfig = array($scaffoldConfig);
    }
    $count = 0;
    foreach ($scaffoldConfig as $scaffold) {
        $query = "object.type = '" . $this->type . "' and object.parent='" . $scaffold . $this->type . "/' and name.nls='{$arLanguage}'";
        $count += ar::get($scaffold . $this->type)->find($query)->count();
    }
    if ($count) {
        ?>
<div class="field">
	<label for="scaffold"><?php 
        echo $ARnls["ariadne:scaffold"];
        ?>
</label>
	<select id="scaffold" type="text" name="scaffold" class="selectline">
		<option value=""><?php 
        echo $ARnls["ariadne:noscaffold"];
        ?>
</option>
		<?php 
        foreach ($scaffoldConfig as $scaffold) {
            $query = "object.type = '" . $this->type . "' and object.parent='" . $scaffold . $this->type . "/' and name.nls='{$arLanguage}'";
Esempio n. 13
0
 protected function printTraceEntry($entry)
 {
     global $store_config;
     $templatesRoot = $store_config['files'] . 'templates';
     $file = substr($entry['file'], strlen($templatesRoot) + 1);
     $template = substr($file, strrpos($file, '/') + 2, -4);
     $idPath = substr($file, 0, -(strlen($template) + 6));
     $id = $this->getTemplateId($idPath);
     $language = substr($template, strrpos($template, '.') + 1);
     $subtype = substr($template, 0, strpos($template, '.', 2));
     $type = substr($template, 0, strpos($template, '.'));
     if (!isset($this->scope[$id])) {
         $this->scope[$id] = current(ar::get('/')->find('object.id=' . $id)->call('system.get.phtml'));
     }
     $object = $this->scope[$id];
     if (!isset($object->config->pinp[$subtype])) {
         $subtype = $type;
     }
     $template = substr($template, strlen($subtype) + 1, -(strlen($language) + 1));
     $path = $this->scope[$id]->path;
     $heleneTemplate = $path . $subtype . '::' . $template . '.' . $language;
     $options = [];
     if (!$object->data->config->templates[$subtype][$template][$language]) {
         $options[] = 'local';
     }
     if ($object->data->config->privatetemplates[$subtype][$template]) {
         $options[] = 'private';
     }
     if (count($options)) {
         $heleneTemplate .= '[' . join(',', $options) . ']';
     }
     $this->write("<div class=\"unity-trace-line\">");
     if (ar_pinp::exists('helene.template.html')) {
         $closeLink = true;
         $this->write("<a target=\"_blank\" href=\"helene.template.html?heleneTemplate=" . RawURLEncode($heleneTemplate) . "\">");
     }
     $this->write("<span class=\"unity-trace-path\" title=\"{$path}\">{$path}</span>:<span class=\"unity-trace-type\">{$type}</span>::<span class=\"unity-trace-template\">{$template}</span>");
     if ($language != 'any') {
         $this->write("(<span class=\"unity-trace-language\">{$language}</span>)");
     }
     if ($closeLink) {
         $this->write("</a>");
     }
     $this->write(" line <span class=\"unity-trace-line-nr\">{$entry['line']}</span>");
     $this->write("</div>");
 }
Esempio n. 14
0
 public function testApiMultiUrlList()
 {
     $testobj = current(ar::get(self::$testPath)->call('system.get.phtml'));
     // unset structure
     unset($testobj->data->url);
     unset($testobj->data->urlList);
     unset($testobj->data->en->url);
     unset($testobj->data->de->url);
     unset($testobj->data->nl->url);
     unset($testobj->data->en->urlList);
     unset($testobj->data->de->urlList);
     unset($testobj->data->nl->urlList);
     $testobj->save();
     $testobj->call('system.save.data.phtml', array('en' => array('urlList' => array('http://test.url.en')), 'nl' => array('urlList' => array('http://test.url.nl', 'http://test2.url.nl'))));
     $this->assertFalse((bool) $testobj->error);
     $refobj = current(ar::get(self::$testPath)->call('system.get.phtml'));
     $this->assertEquals($testobj->data->url, 'http://test.url.en');
     $this->assertEquals($testobj->data->en->url, 'http://test.url.en');
     $this->assertEquals($testobj->data->nl->url, 'http://test.url.nl');
     $this->assertEquals($testobj->data->url, $refobj->data->url);
     $this->assertContains('http://test.url.en', $refobj->data->en->urlList);
     $this->assertContains('http://test.url.nl', $refobj->data->nl->urlList);
     $this->assertContains('http://test2.url.nl', $refobj->data->nl->urlList);
     $this->assertEquals($testobj->data->en->url, $refobj->data->en->url);
     $this->assertEquals($testobj->data->en->urlList, $refobj->data->en->urlList);
     $this->assertEquals($testobj->data->nl->url, $refobj->data->nl->url);
     $this->assertEquals($testobj->data->nl->urlList, $refobj->data->nl->urlList);
     $this->assertEmpty($testobj->data->de->urlList);
     $this->assertEquals('', $testobj->data->de->url);
     $this->assertArrayHasKey('host', $refobj->data->config->url_list);
     $this->assertArrayHasKey('test.url.en', $refobj->data->config->url_list['host']);
     $this->assertArrayHasKey('test.url.nl', $refobj->data->config->url_list['host']);
     $this->assertArrayHasKey('test2.url.nl', $refobj->data->config->url_list['host']);
     $testobj->call('system.save.data.phtml', array('en' => array('urlList' => '')));
     $refobj = current(ar::get(self::$testPath)->call('system.get.phtml'));
     $this->assertEquals($testobj->data->url, '');
     $this->assertEquals($testobj->data->nl->url, 'http://test.url.nl');
     $this->assertEquals($testobj->data->en->url, '');
     $this->assertEquals($testobj->data->url, $refobj->data->url);
     $this->assertEmpty($refobj->data->en->urlList);
     $this->assertEquals($testobj->data->en->url, $refobj->data->en->url);
     $this->assertEquals($testobj->data->en->urlList, $refobj->data->en->urlList);
     $this->assertEmpty($testobj->data->de->urlList);
     $this->assertEquals('', $testobj->data->de->url);
     $this->assertArrayHasKey('host', $refobj->data->config->url_list);
     $this->assertArrayHasKey('test.url.nl', $refobj->data->config->url_list['host']);
     $this->assertArrayHasKey('test2.url.nl', $refobj->data->config->url_list['host']);
     $this->assertArrayNotHasKey('test.url.en', $refobj->data->config->url_list['host']);
 }
Esempio n. 15
0
 public function testAdminHasAllRights()
 {
     $obj = array_pop(ar::get('/')->call('system.get.phtml'));
     $res = $obj->CheckSilent('randomstuf' . md5(time()));
     $this->assertEquals($res, 1);
 }
Esempio n. 16
0
}
$args = array("path" => $this instanceof \pshortcut && $this->data->path && ar::exists($this->data->path) ? $this->data->path : $this->path, "query" => '', "limit" => $items_per_page, "offset" => $offset, "sanity" => true, "order" => $orderQuery, "view" => $viewtype, "total" => ar::ls()->count(), "template" => 'system.list.entry.php', "args" => array("columns" => $colDefs), "filters" => array(), "method" => "post");
$args['parent'] = $args['path'];
$eventData = ar_events::fire('ariadne:onFilterGather', $args);
$eventData = ar_events::fire('ariadne:onFilter', $eventData);
if ($eventData) {
    $query = $eventData['query'];
    if ($eventData['parent'] && $query) {
        $query = sprintf('object.parent="%s" and ( %s )', $eventData['parent'], $query);
    } else {
        if (!$query) {
            $query = sprintf('object.parent="%s"', $eventData['parent'] ? $eventData['parent'] : $eventData['path']);
        }
    }
    $object_list = ar::get($eventData['path'])->find($query)->limit($eventData['limit'])->offset($eventData['offset'])->order($eventData['order'])->call($eventData['template'], $eventData['args']);
    $object_count = ar::get($eventData['path'])->find($query)->limit($eventData['limit'])->offset($eventData['offset'])->order($eventData['order'])->count();
    $divId = "resultsDiv";
    $tableId = "resultsTable";
    $colDefs = $eventData['args']['columns'];
    foreach ($colDefs as $colKey => $colDef) {
        if ($colDef['hide']) {
            unset($colDefs[$colKey]);
        } else {
            $colDefs[$colKey] = array_merge($colDef, ['key' => $colKey]);
        }
    }
    $colDefs = array_values($colDefs);
    $viewtype = $eventData['view'];
    $items_per_page = $eventData['limit'];
    $current_page = 1 + floor($eventData['offset'] / $eventData['limit']);
    if ($viewtype == "details") {
Esempio n. 17
0
<pre>
<?php 
$importpath = false;
echo "== testing for lib folder\n\n";
$res = current(ar::get('/system/lib/muze/')->call('system.get.phtml'));
if (!$res) {
    print "No muze libs found\n";
    $importpath = '/system/lib/muze/';
    $res = current(ar::get('/system/lib/')->call('system.get.phtml'));
    if (!$res) {
        print "No lib folder found\n";
        $importpath = '/system/lib/';
    }
} else {
    print "Old muzelibs found, upgrade ?\n";
}
if ($importpath) {
    print "importing {$importpath}\n";
    $ARCurrent->nolangcheck = true;
    $ARCurrent->options["verbose"] = true;
    $ARCurrent->AXAction == "import";
    // become admin
    $AR->user = new object();
    $AR->user->data = new object();
    $AR->user->data->login = $ARLogin = "******";
    $ax_config["writeable"] = false;
    $ax_config["database"] = "../packages/base.ax";
    echo "ax file (" . $ax_config["database"] . ")\n";
    set_time_limit(0);
    $inst_store = $ax_config["dbms"] . "store";
    $axstore = new $inst_store("", $ax_config);
Esempio n. 18
0
 public static function crumbs($options = array())
 {
     $current = $options['current'];
     if (!$current) {
         $current = ar::context()->getPath();
     }
     $top = $options['top'];
     if (!$top) {
         $top = ar_store::currentSite($current);
     }
     $options += array('current' => $current, 'top' => $top, 'filter' => '');
     $current = $options['current'];
     if (!$current) {
         $current = $top;
     }
     if ($options['filter']) {
         $query .= ' and ( ' . $options['filter'] . ' )';
     }
     return ar::get($current)->parents()->top($top);
 }
Esempio n. 19
0
 public function testParseFile()
 {
     global $AR;
     $obj = current(ar::get(TESTBASE . '/file-nls/file-nls/')->call('system.get.phtml'));
     foreach ($obj->data->nls->list as $nls => $language) {
         $content = $obj->ParseFile('file', $nls);
         $content = trim($content);
         $this->assertEquals('taal ' . $nls, $content);
     }
 }
Esempio n. 20
0
        $info = parseFile($file);
        $nlsFiles[$info['file']][$info['nls']] = $info;
    }
    unset($files);
    foreach ($nlsFiles as $basefile => $nlsData) {
        if (count($nlsData)) {
            $needsUpgrade[$objectID] = '' . $objectID;
        }
    }
    unset($nlsFiles);
    foreach ($dirs as $dir) {
        recurse($dir);
    }
    unset($dirs);
}
recurse($files);
sort($needsUpgrade);
// in large instalations, the store mysql connction has timed out by now, restarting store
global $store, $store_config;
$inst_store = $store_config["dbms"] . "store";
$store = new $inst_store($root, $store_config);
foreach ($needsUpgrade as $objID) {
    print "Searching for {$objID}\n";
    $result = ar::get('/')->find("id == {$objID}")->call('system.get.phtml');
    if (count($result) == 1) {
        $obj = current($result);
        print "Upgrading " . $obj->path . "\n<br>";
        $obj->call('system.upgrade.filestore.8.4.php');
    }
}
echo "Done with converting nls filestore.<br>\n";
Esempio n. 21
0
$ax_config["database"] = "packages/base.ax";
//	echo "ax file (".$ax_config["database"].")\n";
set_time_limit(0);
$inst_store = $ax_config["dbms"] . "store";
$axstore = new $inst_store("", $ax_config);
if (!$axstore->error) {
    $ARCurrent->importStore =& $store;
    $args = "srcpath=/&destpath=/";
    $axstore->call("system.export.phtml", $args, $axstore->get("/"));
    $error = $axstore->error;
    $axstore->close();
} else {
    $error = $axstore->error;
}
$version = $ARversion['version'];
ar::get('/system/ariadne/version/')->call('system.save.data.phtml', array('value' => $version));
$ax_config["writeable"] = false;
$ax_config["database"] = "packages/lib.ax";
set_time_limit(0);
$inst_store = $ax_config["dbms"] . "store";
$axstore = new $inst_store("", $ax_config);
if (!$axstore->error) {
    $ARCurrent->importStore =& $store;
    $args = "srcpath=/&destpath=/";
    $axstore->call("system.export.phtml", $args, $axstore->get("/"));
    $error = $axstore->error;
    $axstore->close();
} else {
    $error = $axstore->error;
    echo $error;
}