1: <?php
2: /**
3: * ClipIt - JuxtaLearn Web Space
4: * PHP version: >= 5.2
5: * Creation date: 2013-10-10
6: * Last update: $Date$
7: * @author Pablo LlinĂ¡s Arnaiz <pebs74@gmail.com>, URJC JuxtaLearn Team
8: * @version $Version$
9: * @link http://www.juxtalearn.eu
10: * @license GNU Affero General Public License v3
11: * @package ClipIt
12: * @subpackage clipit_api
13: */
14:
15: /**
16: * A key term (Label) which can be linked from any Resource as metadata for richer linkage, searching and context.
17: */
18: class ClipitLabel extends UBItem {
19: /**
20: * @const string Elgg entity SUBTYPE for this class
21: */
22: const SUBTYPE = "ClipitLabel";
23:
24: /**
25: * Create a new instance of this class, and assign values to its properties.
26: *
27: * @param array $prop_value_array Array of [property]=>value pairs to set into the new instance
28: *
29: * @return int|bool Returns instance Id if correct, or false if error
30: */
31: static function create($prop_value_array) {
32: if(!isset($prop_value_array["name"])){
33: return null;
34: }
35: $id_array = static::get_from_search($prop_value_array["name"], true, true);
36: if(!empty($id_array)){
37: return array_pop($id_array)->id;
38: }
39: return static::set_properties(null, $prop_value_array);
40: }
41: }