/** * Set PHx variables recursive with keypath. * * @access private * @param mixed $value The current value to set in the PHx variable. * @param string $key The key for the current value. * @param string $path The keypath for the current value. */ private function setPHxVariables($value = '', $key = '', $path = '') { $keypath = !empty($path) ? $path . "." . $key : $key; if (is_array($value)) { foreach ($value as $subkey => $subval) { $this->setPHxVariables($subval, $subkey, $keypath); } } else { $this->phx->setPHxVariable($keypath, $value); } }
/** * Generate a listing of a single thumbnail/image for gallery/slideshow display */ function renderSingle() { global $modx; // Retrieve chunks/default templates from disk $tpl = $this->config['tpl'] == '' ? file_get_contents($this->config['snippetPath'] . $this->config['type'] . '/tpl.default.txt') : $modx->getChunk($this->config['tpl']); $item_tpl = $this->config['itemTpl'] == '' ? file_get_contents($this->config['snippetPath'] . $this->config['type'] . '/tpl.item.default.txt') : $modx->getChunk($this->config['itemTpl']); $picSelect = ''; if ($this->config['picId'] != '*' && !empty($this->config['picId'])) { $picSelect = "id = '" . $this->config['picId'] . "'"; } $phx = new PHxParser(); // Instantiate PHx $items = ''; // Retrieve photos from the database table $result = $modx->db->select("*", $modx->getFullTableName($this->galleriesTable), $picSelect); if ($modx->db->getRecordCount($result) > 0) { while ($row = $modx->fetchRow($result)) { $item_phx = new PHxParser(); foreach ($row as $name => $value) { if ($name == 'filename') { $item_phx->setPHxVariable($name, rawurlencode(trim($value))); } else { $item_phx->setPHxVariable($name, trim($value)); } } $item_phx->setPHxVariable('images_dir', $this->config['galleriesUrl'] . $row['content_id'] . '/'); $item_phx->setPHxVariable('thumbs_dir', $this->config['galleriesUrl'] . $row['content_id'] . '/thumbs/'); $item_phx->setPHxVariable('original_dir', $this->config['galleriesUrl'] . $row['content_id'] . '/original/'); $item_phx->setPHxVariable('plugin_dir', $this->config['snippetUrl'] . $this->config['type'] . '/'); $items .= $item_phx->Parse($item_tpl); } } $phx->setPHxVariable('items', $items); $phx->setPHxVariable('plugin_dir', $this->config['snippetUrl'] . $this->config['type'] . '/'); return $phx->Parse($tpl); // Pass through PHx; }