/** * Generate macro output based on passed arguments * * @return string */ public function render() { $content = $this->args; // args will be null if the macro is called without parenthesis. if (!$content) { return ''; } // Parse arguments // We expect the 1st argument to be a filename $args = explode(',', $content); $file = array_shift($args); $this->attr = array(); $this->attr['href'] = ''; $this->attr['style'] = array(); $this->attr['details'] = true; // Get single attributes // EX: [[Image(myimage.png, nolink, right)]] $argues = preg_replace_callback('/[, ](left|right|top|center|bottom|nodetails|[0-9]+(px|%|em)?)(?:[, ]|$)/i', array(&$this, 'parseSingleAttribute'), $content); // Get quoted attribute/value pairs // EX: [[Image(myimage.png, desc="My description, contains, commas")]] $argues = preg_replace_callback('/[, ](alt|altimage|althref|desc|title|width|height|align|border|longdesc|class|id|usemap|link|rel|details)=(?:["\'])([^"\']*)(?:["\'])/i', array(&$this, 'parseAttributeValuePair'), $content); // Get non-quoted attribute/value pairs // EX: [[Image(myimage.png, width=100)]] $argues = preg_replace_callback('/[, ](alt|altimage|althref|desc|title|width|height|align|border|longdesc|class|id|usemap|link|rel|details)=([^"\',]*)(?:[, ]|$)/i', array(&$this, 'parseAttributeValuePair'), $content); $attr = $this->attr; // Get wiki config $this->config = Component::params('com_wiki'); if ($this->filepath != '') { $this->config->set('filepath', $this->filepath); } $imgs = explode(',', $this->config->get('img_ext', 'jpg, jpeg, jpe, gif, png')); $imgs = array_map('trim', $imgs); $imgs = array_map('strtolower', $imgs); $this->imgs = $imgs; $ret = false; // Is it numeric? if (is_numeric($file)) { include_once PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'tables' . DS . 'attachment.php'; // Get resource by ID $attach = new \Components\Wiki\Tables\Attachment($this->_db); $attach->load(intval($file)); // Check for file existence if ($attach->filename && file_exists($this->_path($attach->filename)) || file_exists($this->_path($attach->filename, true))) { $attr['desc'] = isset($attr['desc']) ? $attr['desc'] : ''; if (!$attr['desc']) { $attr['desc'] = $attach->description ? stripslashes($attach->description) : ''; //$attach->filename; } $attr['created'] = $attach->created; $attr['created_by'] = $attach->created_by; $ret = true; } } else { if (file_exists($this->_path($file)) || file_exists($this->_path($file, true))) { include_once PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'tables' . DS . 'attachment.php'; // Get resource by ID $attach = new \Components\Wiki\Tables\Attachment($this->_db); $attach->load($file, $this->pageid); if ($attach->filename) { $attr['created'] = $attach->created; $attr['created_by'] = $attach->created_by; } $attr['desc'] = isset($attr['desc']) ? $attr['desc'] : $file; $ret = true; } } // Does the file exist? if ($ret) { //$attr['desc'] = htmlentities($attr['desc'], ENT_COMPAT, 'UTF-8'); // Return HTML return $this->_embed($file, $attr); } else { // Return error message return '(file:' . $file . ' not found)'; } }
if ($sort == 'description') { echo $dir == 'ASC' ? '↑' : '↓'; } ?> <?php echo Lang::txt('COM_WIKI_COL_DESCRIPTION'); ?> </a> </th> </tr> </thead> <tbody> <?php if ($rows) { $database = \App::get('db'); $asset = new \Components\Wiki\Tables\Attachment($database); foreach ($rows as $row) { $fsize = Lang::txt('COM_WIKI_UNKNOWN'); if (is_file($asset->filespace() . DS . $row->pageid . DS . $row->filename)) { $fsize = \Hubzero\Utility\Number::formatBytes(filesize($asset->filespace() . DS . $row->pageid . DS . $row->filename)); } $name = Lang::txt('COM_WIKI_UNKNOWN'); $xprofile = \Hubzero\User\Profile::getInstance($row->created_by); if (is_object($xprofile)) { $name = $this->escape(stripslashes($xprofile->get('name'))); $name = $xprofile->get('public') ? '<a href="' . Route::url($xprofile->getLink()) . '">' . $name . '</a>' : $name; } ?> <tr> <td> <time datetime="<?php