/** * Handle the match */ function handle($match, $state, $pos, Doku_Handler $handler) { // prepare default data $return = array('data' => $data, 'width' => 425, 'height' => 350, 'align' => 'center'); // prepare input $lines = explode("\n", $match); $conf = array_shift($lines); $conf = substr($conf, 6, -1); array_pop($lines); // parse adhoc configs if (preg_match('/\\b(left|center|right)\\b/i', $conf, $match)) { $return['align'] = $match[1]; } if (preg_match('/\\b(\\d+)x(\\d+)\\b/', $conf, $match)) { $return['width'] = $match[1]; $return['height'] = $match[2]; } // strip configs to find swf $conf = preg_replace('/\\b(left|center|right|(\\d+)x(\\d+))\\b/i', '', $conf); $conf = trim($conf); $return['swf'] = ml($conf, '', true, '&'); // parse parameters $return['data'] = linesToHash($lines); foreach ($return['data'] as $key => $val) { if ($key[0] == '!') { $return['data'][substr($key, 1)] = ml($val, '', true, '&'); unset($return['data'][$key]); } } return $return; }
/** * Parse the type and configuration data from the syntax */ function handle($match, $state, $pos, &$handler) { $match = substr(trim($match), 5, -7); // strip '<blog' and '</blog>' list($type, $conf) = explode('>', $match, 2); $type = trim($type); $conf = trim($conf); $conf = linesToHash(explode("\n", $conf)); if (!$type) { $type = 'list'; } // check type if (!in_array($type, $this->type_whitelist)) { msg('Unknown blog syntax type "' . hsc($type) . '" using "list" instead', -1); $type = 'list'; } // handle multi keys $conf['blog'] = array_filter(array_map('trim', explode(',', $conf['blog']))); $conf['tags'] = array_filter(array_map('trim', explode(',', $conf['tags']))); $conf['type'] = array_filter(array_map('trim', explode(',', $conf['type']))); if (!count($conf['blog'])) { $conf['blog'] = array('default'); } // higher default limit for tag cloud if ($type == 'tagcloud' && !$conf['limit']) { $conf['limit'] = 25; } // default to listwrap for recent comments if ($type == 'recentcomments' && !isset($conf['listwrap'])) { $conf['listwrap'] = 1; } // reversed listwrap syntax if ($conf['nolistwrap']) { $conf['listwrap'] = 0; unset($conf['nolistwrap']); } // merge with default config $conf = array_merge($this->config, $conf); return array('type' => $type, 'conf' => $conf); }
/** * Check various versions * * @return bool */ private function _step_version() { $ok = true; // check if PHP is up to date if (version_compare(phpversion(), '5.2.0', '<')) { $this->_warn($this->getLang('vs_php')); $ok = false; } // we need SSL - only newer HTTPClients check that themselves if (!in_array('ssl', stream_get_transports())) { $this->_warn($this->getLang('vs_ssl')); $ok = false; } // get the available version $http = new DokuHTTPClient(); $tgzversion = $http->get($this->tgzversion); if (!$tgzversion) { $this->_warn($this->getLang('vs_tgzno') . ' ' . hsc($http->error)); $ok = false; } if (!preg_match('/(^| )(\\d\\d\\d\\d-\\d\\d-\\d\\d[a-z]*)( |$)/i', $tgzversion, $m)) { $this->_warn($this->getLang('vs_tgzno')); $ok = false; $tgzversionnum = 0; } else { $tgzversionnum = $m[2]; $this->_say($this->getLang('vs_tgz'), $tgzversion); } // get the current version $version = getVersion(); if (!preg_match('/(^| )(\\d\\d\\d\\d-\\d\\d-\\d\\d[a-z]*)( |$)/i', $version, $m)) { $versionnum = 0; } else { $versionnum = $m[2]; } $this->_say($this->getLang('vs_local'), $version); // compare versions if (!$versionnum) { $this->_warn($this->getLang('vs_localno')); $ok = false; } else { if ($tgzversionnum) { if ($tgzversionnum < $versionnum) { $this->_warn($this->getLang('vs_newer')); $ok = false; } elseif ($tgzversionnum == $versionnum) { $this->_warn($this->getLang('vs_same')); $ok = false; } } } // check plugin version $pluginversion = $http->get($this->pluginversion); if ($pluginversion) { $plugininfo = linesToHash(explode("\n", $pluginversion)); $myinfo = $this->getInfo(); if ($plugininfo['date'] > $myinfo['date']) { $this->_warn($this->getLang('vs_plugin')); $ok = false; } } return $ok; }
/** * Builds a hash from a configfile * * If $lower is set to true all hash keys are converted to * lower case. * * @author Harry Fuecks <*****@*****.**> * @author Andreas Gohr <*****@*****.**> * @author Gina Haeussge <*****@*****.**> */ function confToHash($file, $lower = false) { $conf = array(); $lines = @file($file); if (!$lines) { return $conf; } return linesToHash($lines, $lower); }