Esempio n. 1
0
 public function AddAttach($result, $destination, $type = REALTION_ATTACH)
 {
     $data = array('attach_filename' => $result['value']['name'], 'attach_size' => $result['value']['size'], 'attach_ext' => $result['value']['ext'], 'attach_location' => $result['value']['path'], 'attach_time' => time(), 'attach_label' => $_POST['label'], 'attach_url' => str_replace('../upload/', UR_UPLOAD, $result['value']['path']));
     $id = $this->Create($data);
     $rel = TRelation::GetInstance();
     return $rel->Add($id, $destination, $type);
 }
Esempio n. 2
0
 public static function GetInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 3
0
 public function GetAttached($destination, $type = REALTION_ATTACH)
 {
     $rel = TRelation::GetInstance();
     $result = $rel->GetByDestination($destination, $type);
     if (count($result) > 0) {
         $sql = "SELECT attach_label,attach_id FROM %table% WHERE attach_id IN(" . implode(',', $result) . ') ;';
         $result = $this->db->select($sql, array('attach'));
     }
     return $result;
 }
Esempio n. 4
0
 /** Gets TRelation object by meaning_id
  * @return TRelation or NULL in case of error
  */
 public static function getByMeaning($meaning_id, $meaning_obj)
 {
     return TRelation::getRelation("meaning_id", $meaning_id, $meaning_obj);
 }
Esempio n. 5
0
 /**
  * Get categories of a destination
  * @param int $destination destination id
  * @param int $type
  */
 public function GetCategories($destination, $type = RELATION_CATEGORY)
 {
     // Pre hook
     _hk('P' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $destination, $type);
     $rel = TRelation::GetInstance();
     $sources = $rel->GetByDestination($destination, $type);
     $result = $this->GetCheckedCategories($sources);
     // result hook
     _hk('R' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $result);
     return $result;
 }
Esempio n. 6
0
include "../../../config.php";
include LIB_DIR . "header.php";
$php_self = "view_related_words.php";
?>
<h1>Example for searching of a list of related words</h1>

<form action="<?php 
echo $php_self;
?>
" method="GET">
    <input type="text" size="30" name="page_title" value="<?php 
if (isset($page_title)) {
    print $page_title;
}
?>
">
    <input type="submit" value="search">
</form>
<?php 
if (isset($page_title)) {
    $related_words_arr = TRelation::getPageRelations($page_title);
    if (sizeof($related_words_arr)) {
        print "<table border='1'>\n";
        foreach ($related_words_arr as $rword => $relation_names) {
            print "<tr><td>{$rword}</td><td>" . join(", ", $relation_names) . "</td></tr>\n";
        }
        print "</table>\n";
    }
}
include LIB_DIR . "footer.php";
Esempio n. 7
0
<?php

$topix = GetTopicByLiker($url[1], 10);
$smarty->assign('topix', $topix);
$r = TRelation::GetInstance();
$member['likes'] = $r->GetSourceCount($url[1], REALTION_LIKE);
$member['frinds'] = $r->GetSourceCount($url[1], REALTION_FRIEND);
$member['comz'] = GetCount('comment', ' comment_member_id = ' . (int) $_COOKIE['mid']);
$smarty->assign('member', $member);
$smarty->assign('frindz', GetFrienz($url[1]));
$idd = isset($_COOKIE['mid']) ? $_COOKIE['mid'] : 0;
$smarty->assign('is_f', $r->Has($idd, $url[1], REALTION_FRIEND));
Esempio n. 8
0
 public function CatSync($id)
 {
     $rel = TRelation::GetInstance();
     $rel->Sync($_POST['category'], $id, RELATION_CATEGORY);
     unset($_POST['category']);
 }
Esempio n. 9
0
 /** Gets TMeaning object by property $property_name with value $property_value.
  * @return TMeaning or NULL in case of error
  */
 public static function getMeaning($property_name, $property_value, $lang_pos_obj = NULL)
 {
     global $LINK_DB;
     $query = "SELECT * FROM meaning WHERE `{$property_name}`='{$property_value}' order by id";
     $result = $LINK_DB->query_e($query, "Query failed in " . __METHOD__ . " in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     if ($LINK_DB->query_count($result) == 0) {
         return NULL;
     }
     $meaning_arr = array();
     while ($row = $result->fetch_object()) {
         /*
                 if ($lang_pos_obj == NULL)
                 $lang_pos_obj = TLangPOS::getByID($row->lang_pos_id);
         */
         $meaning = new TMeaning($row->id, $lang_pos_obj, $row->lang_pos_id, $row->meaning_n, TWikiText::getByID($row->wiki_text_id), $row->wiki_text_id);
         $meaning->relation = TRelation::getByMeaning($row->id, $meaning);
         $meaning->translation = TTranslation::getByMeaning($row->id, $meaning);
         $meaning->label_meaning = TLabelMeaning::getByMeaning($row->id, $meaning);
         $meaning_arr[] = $meaning;
     }
     return $meaning_arr;
 }
Esempio n. 10
0
function GetAttached($destination, $type = REALTION_ATTACH)
{
    global $database_handle;
    $rel = TRelation::GetInstance();
    $result = $rel->GetByDestination($destination, $type);
    if (count($result) > 0) {
        $sql = "SELECT attach_filename,attach_url FROM %table% WHERE attach_id IN(" . implode(',', $result) . ') ;';
        $result = $database_handle->select($sql, array('attach'));
    }
    return $result;
}
Esempio n. 11
0
<?php

$rel_cls = TRelation::GetInstance();
function GetRelDst($typ, $table, $arg = array())
{
    // get global array
    global $ID, $database_handle;
    $fields = isset($arg['fields']) ? $arg['fields'] : '*';
    $prefix = isset($arg['prefix']) ? $arg['prefix'] : $table . '_';
    $order = isset($arg['order']) ? $arg['order'] : $prefix . 'id DESC';
    $filter = isset($arg['rule']) ? ' AND ' . $arg['rule'] : null;
    $rule = isset($arg['rule']) ? ' AND ' . $arg['rule'] : null;
    $sql = "SELECT  o.{$fields} FROM " . DB_PREFIX . "relation AS r " . "JOIN %table% AS o ON  r.src = o.{$prefix}id WHERE " . "r.dst = {$ID} AND r.typ = {$typ} {$rule} {$filter} ORDER BY {$order} ;";
    //    die($sql);
    return $database_handle->Select($sql, array($table));
}
function GetRelSrc($typ, $table, $arg = array())
{
    // get global array
    global $ID, $database_handle;
    $fields = isset($arg['fields']) ? $arg['fields'] : '*';
    $prefix = isset($arg['prefix']) ? $arg['prefix'] : $table . '_';
    $order = isset($arg['order']) ? $arg['order'] : $prefix . 'id DESC';
    $filter = isset($arg['filter']) ? ' AND ' . $arg['filter'] : null;
    $rule = isset($arg['rule']) ? ' AND ' . $arg['rule'] : null;
    $sql = "SELECT  o.{$fields} FROM " . DB_PREFIX . "relation AS r " . "JOIN %table% AS o ON  r.dst = o.{$prefix}id WHERE " . "r.src = {$ID} AND r.typ = {$typ} {$rule} {$filter} ORDER BY {$order} ;";
    //    die($sql);
    return $database_handle->Select($sql, array($table));
}
function GetTag($suffix = null, $arg = array())
{
Esempio n. 12
0
 public function RemoveAttach($attach_id, $destination, $type = REALTION_ATTACH)
 {
     $rel = TRelation::GetInstance();
     $rel->Remove($attach_id, $destination, $type);
     GoBack();
 }