private function setup_links() { if (empty($this->views) || empty($this->artefacts)) { return; } $viewlist = join(',', array_keys($this->views)); $artefactlist = join(',', array_keys($this->artefacts)); // Views in collections if ($this->collections) { $collectionlist = join(',', array_keys($this->collections)); $records = get_records_select_array('collection_view', "view IN ({$viewlist}) AND collection IN ({$collectionlist})"); if ($records) { foreach ($records as &$r) { $this->links->collectionview[$r->collection][$r->view] = 1; $this->links->viewcollection[$r->view][$r->collection] = 1; } } } // Artefacts directly in views $records = get_records_select_array('view_artefact', "view IN ({$viewlist}) OR artefact IN ({$artefactlist})"); if ($records) { foreach ($records as &$r) { $this->links->viewcontents[$r->view][$r->artefact] = 1; $this->links->artefactinview[$r->artefact][$r->view] = 1; } } // Artefact parent-child relationships $records = get_records_select_array('artefact', "parent IN ({$artefactlist}) AND id IN ({$artefactlist})", array(), '', 'id,parent'); if ($records) { foreach ($records as &$r) { $this->links->children[$r->parent][$r->id] = 1; $this->links->parent[$r->id] = $r->parent; } } // Artefact-attachment relationships $records = get_records_select_array('artefact_attachment', "artefact IN ({$artefactlist}) AND attachment IN ({$artefactlist})"); if ($records) { foreach ($records as &$r) { $this->links->attachments[$r->artefact][$r->attachment] = 1; } } // Other leap2a relationships $this->links->viewartefact = array(); $this->links->artefactview = array(); $this->links->artefactartefact = array(); foreach (require_artefact_plugins() as $plugin) { safe_require('export', 'leap/' . $plugin->name, 'lib.php', 'require_once', true); } foreach (plugins_installed('artefact') as $plugin) { $classname = 'LeapExportElement' . ucfirst($plugin->name); if (is_callable($classname . '::setup_links')) { // You must explicitly pass variables by reference when calling // call_user_func, or else they get copied automatically. // Using a dummy variable here to avoid the "Call time pass by reference // is deprecated" warning that php displays on the screen. $dummyref =& $this->links; call_user_func(array($classname, 'setup_links'), $dummyref, array_keys($this->views), array_keys($this->artefacts)); } } }
function artefact_get_types_from_filter($filter) { static $contenttype_artefacttype = null; if (is_null($contenttype_artefacttype)) { $contenttype_artefacttype = array(); foreach (require_artefact_plugins() as $plugin) { $classname = generate_class_name('artefact', $plugin->name); if (!is_callable($classname . '::get_artefact_type_content_types')) { continue; } $artefacttypetypes = call_static_method($classname, 'get_artefact_type_content_types'); foreach ($artefacttypetypes as $artefacttype => $contenttypes) { if (!empty($contenttypes)) { foreach ($contenttypes as $ct) { $contenttype_artefacttype[$ct][] = $artefacttype; } } } } } if (empty($contenttype_artefacttype[$filter])) { return null; } return $contenttype_artefacttype[$filter]; }