Ejemplo n.º 1
0
 /**
  * Optional method. If exists, allows this class to decide the title for
  * all blockinstances of this type
  */
 public static function get_instance_title(BlockInstance $bi)
 {
     $configdata = $bi->get('configdata');
     if (!empty($configdata['artefactid'])) {
         safe_require('artefact', 'cpds');
         $cpd = new ArtefactTypecpd($configdata['artefactid']);
         $title = $cpd->get('title');
         return $title;
     }
     return '';
 }
Ejemplo n.º 2
0
 /**
  * Creates a cpd or activity from the given entry
  *
  * @param SimpleXMLElement $entry    The entry to create the cpd or activity from
  * @param PluginImportLeap $importer The importer
  * @return array A list of artefact IDs created, to be used with the artefact mapping.
  */
 private static function create_cpd(SimpleXMLElement $entry, PluginImportLeap $importer)
 {
     // First decide if it's going to be a cpd or a activity depending
     // on whether it has any ancestral cpds.
     if (self::get_ancestor_entryid($entry, $importer)) {
         $artefact = new ArtefactTypeactivity();
     } else {
         $artefact = new ArtefactTypecpd();
     }
     $artefact->set('title', (string) $entry->title);
     $artefact->set('description', PluginImportLeap::get_entry_content($entry, $importer));
     $artefact->set('owner', $importer->get('usr'));
     if (isset($entry->author->name) && strlen($entry->author->name)) {
         $artefact->set('authorname', $entry->author->name);
     } else {
         $artefact->set('author', $importer->get('usr'));
     }
     if ($published = strtotime((string) $entry->published)) {
         $artefact->set('ctime', $published);
     }
     if ($updated = strtotime((string) $entry->updated)) {
         $artefact->set('mtime', $updated);
     }
     $artefact->set('tags', PluginImportLeap::get_entry_tags($entry));
     // Set startdate and hours status if we can find them
     if ($artefact instanceof ArtefactTypeactivity) {
         $namespaces = $importer->get_namespaces();
         $ns = $importer->get_leap2a_namespace();
         $dates = PluginImportLeap::get_leap_dates($entry, $namespaces, $ns);
         if (!empty($dates['target']['value'])) {
             $startdate = strtotime($dates['target']['value']);
         }
         $artefact->set('startdate', empty($startdate) ? $artefact->get('mtime') : $startdate);
         if ($entry->xpath($namespaces[$ns] . ':status[@' . $namespaces[$ns] . ':stage="hours"]')) {
             $artefact->set('hours', 1);
         }
     }
     $artefact->commit();
     return array($artefact->get('id'));
 }