Пример #1
0
include_once 'common.inc.php';
require_once ROOT . '/class/relation.class.php';
//check_user
check_user();
if ($url->get('source_class') && $url->get('source_type') && $url->get('source_id')) {
    $source = $url->getObject('source_');
    debug($source, 'Source');
    $session->set('relation_source', $source->getUid());
} elseif ($url->get('action')) {
    $source = $thinkedit->newObject($session->get('relation_source'));
} else {
    echo translate('save_before_relating');
    die;
    // todo more gracefull : do not display relation iframe iframe in edit when editing new record
}
$relation = new relation();
/*********** handle actions **********/
if ($url->get('action') == 'relate') {
    //echo 'I must relate';
    $target = $url->getObject('target_');
    $relation->relate($source, $target);
}
if ($url->get('action') == 'unrelate') {
    //echo 'I must relate';
    $target = $url->getObject('target_');
    $relation->unrelate($source, $target);
}
$relations = $relation->getRelations($source);
if ($relations) {
    foreach ($relations as $relation_object) {
        $relation_object->load();
<?php

require_once '../thinkedit.init.php';
require_once ROOT . '/class/relation.class.php';
$articles = $thinkedit->newRecord('article');
$authors = $thinkedit->newRecord('author');
// get first article
$article = $articles->findFirst();
// get first author
$author = $authors->findFirst();
$relation = new relation();
debug($article);
debug($author);
$relation->relate($article, $author);
//$relation->unRelate($article, $author);
$relations = $relation->getRelations($article);
foreach ($relations as $related_item) {
    $related_item->load();
    echo $related_item->getTitle();
}
echo $total_queries;
Пример #3
0
check_user();
if ($url->get('action') == 'init') {
    if (isset($_SERVER['HTTP_REFERER'])) {
        $session->set('action', 'relate');
        $session->set('referrer', $_SERVER['HTTP_REFERER']);
    } else {
        trigger_error('no referrer found, cannot relate currently');
    }
}
if ($url->get('action') == 'relate') {
    $session->delete('action');
    echo 'I need to do a relation';
}
if ($url->get('action') == 'cancel') {
}
$source = $url->getObject();
debug($source, 'Source');
require_once ROOT . '/class/relation.class.php';
$out['title'] = 'Relations';
$relation = new relation();
$relations = $relation->getRelations($source);
if ($relations) {
    foreach ($relations as $relation_object) {
        $item['title'] = te_short(20, $relation_object->getTitle());
        $item['icon'] = $relation_object->getIcon();
        $out['relation']['data'][] = $item;
    }
}
debug($out, 'OUT');
debug($relations);
die;
Пример #4
0
        // add a picture to each article
        $child->addChild($thinkedit->newModule('image'));
    }
}
// what is under node id 0 ?
$mynode = $thinkedit->newModuleByNode(0);
debug($mynode->id);
debug($mynode->type);
$mynode->load();
// post a message to mynode (arbitrary defined)
$post = $thinkedit->newModule('post');
$post->setTitle('Do you agree?');
$post->set('message', 'here we go gentlemens');
$post->save();
$mynode->addChild($post);
// or
$post->addParent($mynode);
// will this work ???
// relate this post to the news category
$relation = new relation();
$relation->makeRelation($post, $news);
// or
$post->makeRelation($news);
// Append an image file to the post :
$image = $thinkedit->newModule('image');
// load image data here
$image->setContent($imagedata);
$image->save();
$post->makeRelation($image);
//or
$image->makeRelation($post);