4 require_once
'Services/Contact/BuddySystem/classes/states/class.ilAbstractBuddySystemRelationState.php';
39 $this->lng = $DIC[
'lng'];
47 if(null === self::$instance)
49 self::$instance =
new self;
52 return self::$instance;
59 public function getValidStates()
61 if(null !== self::$valid_states)
63 return self::$valid_states;
67 $iter =
new DirectoryIterator(dirname(__FILE__));
68 foreach($iter as
$file)
78 require_once $file->getFilename();
79 $class = str_replace(
array(
'class.',
'.php'),
'', $file->getBasename());
80 $reflection =
new ReflectionClass($class);
82 !$reflection->isAbstract() &&
83 $reflection->isSubclassOf(
'ilBuddySystemRelationState')
86 $states[] =
new $class();
90 return (self::$valid_states = $states);
99 foreach($this->getValidStates() as $state)
101 if($state->isInitial())
116 if(null !== self::$state_option_array[$with_initial_state])
118 return self::$state_option_array[$with_initial_state];
123 foreach($this->getValidStates() as $state)
125 if($with_initial_state || !$state->isInitial())
127 $options[get_class($state)] = $this->lng->txt(
'buddy_bs_state_' . strtolower($state->getName()));
131 return (self::$state_option_array[$with_initial_state] =
$options);
142 $state_class = get_class($relation->
getState());
143 $renderer_class = $state_class .
'ButtonRenderer';
144 $renderer_path =
"Services/Contact/BuddySystem/classes/states/renderer/class.{$renderer_class}.php";
146 if(!file_exists($renderer_path))
151 require_once $renderer_path;
152 if(!class_exists($renderer_class))
154 throw new ilBuddySystemException(sprintf(
"Could not find a renderer class for state: %s in file: %s", $state_class, $renderer_path));
157 return new $renderer_class($owner_id, $relation);
Class ilBuddySystemRelationStateFactory.
static $state_option_array
getStatesAsOptionArray($with_initial_state=false)
getRendererByOwnerAndRelation($owner_id, ilBuddySystemRelation $relation)
if(!is_array($argv)) $options
Create styles array
The data for the language used.
Class ilBuddySystemRelation.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file