示例#1
0
文件: lib.php 项目: Br3nda/mahara
 /**
  * Returns a list of artefact IDs that are in this blockinstance.
  *
  * People may embed artefacts as images etc. They show up as links to the 
  * download script, which isn't much to go on, but should be enough for us 
  * to detect that the artefacts are therefore 'in' this blocktype.
  */
 public static function get_artefacts(BlockInstance $instance)
 {
     $artefacts = array();
     $configdata = $instance->get('configdata');
     if (isset($configdata['text'])) {
         require_once get_config('docroot') . 'artefact/lib.php';
         $artefacts = artefact_get_references_in_html($configdata['text']);
     }
     return $artefacts;
 }
示例#2
0
文件: lib.php 项目: banterweb/mahara
 /**
  * Returns a list of artefact IDs that are in this blockinstance.
  *
  * People may embed artefacts as images etc. They show up as links to the
  * download script, which isn't much to go on, but should be enough for us
  * to detect that the artefacts are therefore 'in' this blocktype.
  */
 public static function get_artefacts(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     $artefacts = array();
     if (isset($configdata['artefactid'])) {
         $artefacts[] = $configdata['artefactid'];
         // Add all artefacts found in the text
         $text = $instance->get_artefact_instance($configdata['artefactid'])->get('description');
         $artefacts = array_unique(array_merge($artefacts, artefact_get_references_in_html($text)));
     }
     return $artefacts;
 }
示例#3
0
文件: lib.php 项目: rboyatt/mahara
 public static function get_artefacts(BlockInstance $instance)
 {
     safe_require('artefact', 'file');
     $configdata = $instance->get('configdata');
     // Add all artefacts found in the text
     if (empty($configdata['text'])) {
         $artefacts = array();
     } else {
         $artefacts = array_unique(artefact_get_references_in_html($configdata['text']));
     }
     return $artefacts;
 }
示例#4
0
 /**
  * Copy the description of the view template
  * and its embedded image artefacts
  *
  * @param View $template the view template
  * @param array &$artefactcopies the artefact mapping
  * @return string updated description
  */
 private function copy_description(View $template, array &$artefactcopies)
 {
     $new_description = $template->get('description');
     if (!empty($new_description) && strpos($new_description, 'artefact/file/download.php?file=') !== false) {
         // Get all possible embedded artefacts
         $artefactids = array_unique(artefact_get_references_in_html($new_description));
         // Copy these image artefacts
         foreach ($artefactids as $aid) {
             try {
                 $a = artefact_instance_from_id($aid);
             } catch (Exception $e) {
                 continue;
             }
             if ($a instanceof ArtefactTypeImage) {
                 $artefactcopies[$aid] = (object) array('oldid' => $aid, 'oldparent' => $a->get('parent'));
                 $artefactcopies[$aid]->newid = $a->copy_for_new_owner($this->get('owner'), $this->get('group'), $this->get('institution'));
             }
         }
         // Update the image urls in the description
         if (!empty($artefactcopies)) {
             $regexp = array();
             $replacetext = array();
             foreach ($artefactcopies as $oldaid => $newobj) {
                 // Change the old image id to the new one
                 $regexp[] = '#<img([^>]+)src=("|\\")' . preg_quote(get_config('wwwroot') . 'artefact/file/download.php?file=' . $oldaid) . '(&|&amp;)embedded=1([^"]*)"#';
                 $replacetext[] = '<img$1src="' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $newobj->newid . '&embedded=1"';
             }
             $new_description = preg_replace($regexp, $replacetext, $new_description);
         }
     }
     return $new_description;
 }
示例#5
0
 /**
  * Looks through the blog post text for links to download artefacts, and
  * returns the IDs of those artefacts.
  */
 public function get_referenced_artefacts_from_postbody()
 {
     return artefact_get_references_in_html($this->get('description'));
 }
示例#6
0
文件: lib.php 项目: vohung96/mahara
 /**
  * Returns a list of artefact IDs that are in this blockinstance.
  *
  * People may embed artefacts as images etc. They show up as links to the
  * download script, which isn't much to go on, but should be enough for us
  * to detect that the artefacts are therefore 'in' this blocktype.
  */
 public static function get_artefacts(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     $artefacts = array();
     if (isset($configdata['artefactid'])) {
         $artefacts[] = $configdata['artefactid'];
         // Add all artefacts found in the text
         $text = $instance->get_artefact_instance($configdata['artefactid'])->get('description');
         $artefacts = array_unique(array_merge($artefacts, artefact_get_references_in_html($text)));
         // Get all the feedback on this annotation
         // to retrieve all the artefacts found in their text
         // and to include the feedback as part of the view_artefact.
         // Please note that images owned by other users that are place on feedback
         // will not be part of the view_artefact because the owner of the
         // annotation does not own the image being placed on the feedback.
         // Therefore, when exported as Leap2A, these images will not come through.
         $sql = "SELECT a.id, a.description\n                    FROM {artefact} a\n                    INNER JOIN {artefact_annotation_feedback} af ON a.id = af.artefact\n                    WHERE af.onannotation = ?";
         // Keep a list of the feedback ids.
         $artefactfeedback = array();
         if ($feedback = get_records_sql_array($sql, array($configdata['artefactid']))) {
             foreach ($feedback as $f) {
                 // Include the feedback artefact.
                 $artefactfeedback[] = $f->id;
                 // Include any artefacts found in its text.
                 // The BlockInstance::rebuild_artefact_list() will sort out the ownership.
                 $artefacts = array_unique(array_merge($artefacts, artefact_get_references_in_html($f->description)));
             }
             // Now merge the feedback artefacts as well.
             $artefacts = array_unique(array_merge($artefacts, $artefactfeedback));
         }
     }
     return $artefacts;
 }