/** * Check validity and compatibility of options * * @access static * @param string $page name to get contents * @param string $current showing page name * @param array $options * @param array $unknowns * @return $options */ function check_options($page, $current, $options, $unknowns = array()) { if (count($unknowns) > 0) { $line = PluginSonotsOption::glue_option_line($unknowns); sonots::mythrow('Argument(s) "' . htmlspecialchars($line) . '" are invalid.'); return; } if ($page !== $current) { $options['fromhere'] = false; } // link=on is flexible. Set to true value. if ($options['link'] === 'on') { if ($page === $current) { $options['link'] = 'anchor'; } else { $options['link'] = 'page'; } } return $options; }
/** * Check option validities and compatibilities * * @param array $options * @param array $unknown unknown options * @param array $conf_options * @return array */ function check_options($options, $unknowns, $conf_options) { global $vars; // first arg if (!isset($options['tag']) && count($unknowns) > 0) { $unknown_keys = array_diff_key($unknowns, $conf_options); $options['tag'] = $key = key($unknown_keys); unset($unknowns[$key]); } if (count($unknowns) > 0) { $line = PluginSonotsOption::glue_option_line($unknowns); sonots::mythrow('Argument(s) "' . htmlspecialchars($line) . '" are invalid'); return; } if (isset($options['include'])) { $options['include'] = PluginIncludex::check_options($options['include']); $options['date'] = false; // include does not use definitely $options['new'] = false; // include does not use definitely $options['info'] = null; $options['contents'] = null; // include does not use definitely } //// Compat if ($options['date'] || $options['new']) { $options['info'] = array(); } if ($options['date']) { if (!in_array('date', $options['info'])) { $options['info'][] = 'date'; } } if ($options['new']) { if (!in_array('new', $options['info'])) { $options['info'][] = 'new'; } } return $options; }
/** * Check option validities and compatibilities * * @param array $options * @param array $unknown unknown options * @param array $conf_options * @return array */ function check_options($options, $unknowns, $conf_options) { global $vars; // first arg if (!isset($options['home']) && count($unknowns) > 0) { $unknown_keys = array_diff_key($unknowns, $conf_options); $options['home'] = $key = key($unknown_keys); // compat with ls, ls2 unset($unknowns[$key]); } if (count($unknowns) > 0) { $line = PluginSonotsOption::glue_option_line($unknowns); sonots::mythrow('Argument(s) "' . htmlspecialchars($line) . '" are invalid'); return; } if (!isset($options['home'])) { if (!isset($options['tag'])) { $options['home'] = $vars['page'] != '' ? sonots::get_dirname($vars['page']) : ''; } } elseif ($options['home'] === '/') { $options['home'] = ''; } else { $options['home'] = sonots::get_fullname($options['home'], $vars['page']); } $options['prefix'] = $options['home'] . '/'; //// Compat if ($options['basename']) { $options['linkstr'] = 'basename'; } return $options; }
/** * Check option validities and compatibilities * * @param array $options * @param array $unknown unknown options * @param array $conf_options * @return array */ function check_options($options, $unknowns, $conf_options) { global $vars; // first arg if (count($unknowns) > 0) { $unknown_keys = array_diff_key($unknowns, $conf_options); $key = key($unknown_keys); if (in_array($key, $conf_options['popular'][2])) { $options['popular'] = $key; unset($unknowns[$key]); } } if (count($unknowns) > 0) { $line = PluginSonotsOption::glue_option_line($unknowns); sonots::mythrow('Argument(s) "' . htmlspecialchars($line) . '" are invalid'); return; } return $options; }
/** * Check option validities and compatibilities * * @param array $options * @param array $unknown unknown options * @param array $conf_options * @return array */ function check_options($options, $unknowns, $conf_options) { global $vars; // first arg if (!isset($options['prefix']) && count($unknowns) > 0) { $unknown_keys = array_diff_key($unknowns, $conf_options); $options['prefix'] = $key = key($unknown_keys); // compat with ls, ls2 unset($unknowns[$key]); } if (count($unknowns) > 0) { $line = PluginSonotsOption::glue_option_line($unknowns); sonots::mythrow('Argument(s) "' . htmlspecialchars($line) . '" are invalid'); return; } if (!isset($options['prefix'])) { if (!isset($options['tag'])) { $options['prefix'] = $vars['page'] != '' ? $vars['page'] . '/' : ''; } } elseif ($options['prefix'] === '/') { $options['prefix'] = ''; } else { $options['prefix'] = sonots::get_fullname($options['prefix'], $vars['page']); } //// hierarchy off if (isset($options['tag'])) { $options['hierarchy'] = false; } if ($options['sort'] == 'date') { $options['hierarchy'] = false; } if ($options['sort'] == 'title') { $options['hierarchy'] = false; } if (isset($options['include'])) { $options['include'] = PluginIncludex::check_options($options['include']); $options['hierarchy'] = false; // hierarchy + include => XHTML invalid $options['date'] = false; // include does not use definitely $options['new'] = false; // include does not use definitely $options['info'] = null; $options['contents'] = null; // include does not use definitely } if ($options['linkstr'] === 'relative' && $options['hierarchy']) { $options['linkstr'] = 'basename'; // equivalent to basename } //// Compat if ($options['basename']) { $options['linkstr'] = 'basename'; } if ($options['date'] || $options['new']) { $options['info'] = array(); } if ($options['date']) { if (!in_array('date', $options['info'])) { $options['info'][] = 'date'; } } if ($options['new']) { if (!in_array('new', $options['info'])) { $options['info'][] = 'new'; } } return $options; }
/** * Check Page Validity * * @access static * @param string $page * @param string $current * @param array $visited * @return string evaluated page */ function check_page($page, $current, $visited = array()) { if (empty($page)) { sonots::mythrow("No page is specified."); return; } $page = get_fullname($page, $current); if (!is_page($page)) { sonots::mythrow('Page ' . sonots::make_pagelink_nopg($page) . ' does not exist.'); return; } if (!check_readable($page, false, false)) { sonots::mythrow('Page ' . sonots::make_pagelink_nopg($page) . ' is not readable.'); return; } if (isset($visited[$page])) { sonots::mythrow('Page ' . sonots::make_pagelink_nopg($page) . ' is already included.'); return; } return $page; }