Example #1
0
 /**
  * 
  * @return array
  */
 public function getTerms()
 {
     $termRows = $this->dbcon->fetch($this->dbcon->select($this->table), true);
     $terms = array();
     foreach ($termRows as $termRow) {
         $term = new term();
         $term->createFromDbObject($termRow);
         $terms[] = $term;
     }
     return $terms;
 }
Example #2
0
 public static function get_terms_of_scope($scope_UID, $lang = '')
 {
     $terms = array();
     // extract scope terms relations
     $dbObj = new dbAPI();
     $query = "SELECT * FROM TERMS where ENABLED = 1 AND ( ID_SCOPE = " . $scope_UID . ")";
     $terms_related = $dbObj->db_select_query($dbObj->db_get_contentDB(), $query);
     if ($terms_related == null) {
         return null;
     }
     // get terms details
     for ($i = 0; $i < count($terms_related); $i++) {
         $curr_term = term::get_term_by_UID_with_relations($terms_related[$i]["ID_TERM_STRING"], $lang);
         if ($curr_term != null) {
             array_push($terms, $curr_term);
         }
     }
     return $terms;
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $insert = $request->all();
     $safeName = false;
     //upload image
     if ($file = Input::file('image')) {
         $fileName = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension() ?: 'png';
         $folderName = '/uploads/';
         $destinationPath = Config::get('app.path') . $folderName;
         $safeName = time() . "_" . str_random(10) . '.' . $extension;
         $file->move($destinationPath, $safeName);
         $insert['image'] = $safeName ? $folderName . $safeName : '';
     }
     if (isset(Term::$boolean)) {
         foreach (term::$boolean as $field) {
             if (isset($insert[$field]) && $insert[$field] == "on") {
                 $insert[$field] = 1;
             }
         }
     }
     term::create($insert);
     return redirect('admin/terms')->with('success', Lang::get('message.success.create'));
 }
Example #4
0
 /**
  * returns list of terms that are related to object
  * @param {array} $object_UID    array of type array("column_name"=>'DELIVERY_BASE_ID', "value"=>5)
  * @param {string} $database_name database name e.g. 'content', 'user'
  * @param {string} $tableName     Table name of the relation which depends on object type, e.g. R_LD2T, R_LK2T.
  * @param  {string} $lang          The required language, if no language is selected all languages will be returned
  * @return {array:terms}                array of terms
  */
 public static function get_terms_of_object($object_UID, $database_name, $tableName, $lang = '')
 {
     // get database name
     $database_name = dbAPI::get_db_name($database_name);
     $dbObj = new dbAPI();
     // get column name of object and its value (UID) to look for in table
     $object_column_name = $object_UID["column_name"];
     $object_UID_value = $object_UID["value"];
     if ($object_column_name == null || $object_column_name == '') {
         debugLog::log("<i>[relations.php:get_terms_of_object]</i> Column name was not specified.");
         return null;
     }
     // get all related terms to object
     $query = "SELECT * FROM " . $tableName . " where ENABLED = 1 AND (" . $object_column_name . " = " . $object_UID_value . ")";
     $results = $dbObj->db_select_query($database_name, $query);
     // retrieve term's details from terms class into array
     $terms = array();
     for ($i = 0; $i < count($results); $i++) {
         $curr_term = term::get_term_by_UID($results[$i]["TERM_ID"], $lang);
         // copy LINK_TYPE to term object
         $curr_term["LINK_TYPE"] = $results[$i]["LINK_TYPE"];
         array_push($terms, $curr_term);
     }
     return $terms;
 }
Example #5
0
 public static function get_scopes_of_term($term_UID, $lang = '')
 {
     $scopes = array();
     // extract scope terms relations
     $dbObj = new dbAPI();
     $query = "SELECT * FROM TERMS where ENABLED = 1 AND ( ID_TERM_STRING = " . $term_UID . ")";
     $scopes_related = $dbObj->db_select_query($dbObj->db_get_contentDB(), $query);
     if ($scopes_related == null) {
         return null;
     }
     // get scopes and meanings details
     for ($i = 0; $i < count($scopes_related); $i++) {
         $curr_scope = scope::get_scope_by_UID($scopes_related[$i]["ID_SCOPE"], $lang);
         $curr_meaning = term::get_term_meaning_by_UID($scopes_related[$i]["ID_TERM_MEAN"], $lang);
         if ($curr_scope != null) {
             array_push($scopes, array('scope' => $curr_scope, 'meaning' => $curr_meaning));
         }
     }
     return $scopes;
 }