to
- foreach ($definition->info[$token->name]->attr_transform_pre as $transform) { - $attr = $transform->transform($o = $attr, $config, $context); - if ($e) { - if ($attr != $o) { - $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); - } - } - } - - // create alias to this element's attribute definition array, see - // also $d_defs (global attribute definition array) - // DEFINITION CALL - $defs = $definition->info[$token->name]->attr; - - $attr_key = false; - $context->register('CurrentAttr', $attr_key); - - // iterate through all the attribute keypairs - // Watch out for name collisions: $key has previously been used - foreach ($attr as $attr_key => $value) { - - // call the definition - if (isset($defs[$attr_key])) { - // there is a local definition defined - if ($defs[$attr_key] === false) { - // We've explicitly been told not to allow this element. - // This is usually when there's a global definition - // that must be overridden. - // Theoretically speaking, we could have a - // AttrDef_DenyAll, but this is faster! - $result = false; - } else { - // validate according to the element's definition - $result = $defs[$attr_key]->validate( - $value, - $config, - $context - ); - } - } elseif (isset($d_defs[$attr_key])) { - // there is a global definition defined, validate according - // to the global definition - $result = $d_defs[$attr_key]->validate( - $value, - $config, - $context - ); - } else { - // system never heard of the attribute? DELETE! - $result = false; - } - - // put the results into effect - if ($result === false || $result === null) { - // this is a generic error message that should replaced - // with more specific ones when possible - if ($e) { - $e->send(E_ERROR, 'AttrValidator: Attribute removed'); - } - - // remove the attribute - unset($attr[$attr_key]); - } elseif (is_string($result)) { - // generally, if a substitution is happening, there - // was some sort of implicit correction going on. We'll - // delegate it to the attribute classes to say exactly what. - - // simple substitution - $attr[$attr_key] = $result; - } else { - // nothing happens - } - - // we'd also want slightly more complicated substitution - // involving an array as the return value, - // although we're not sure how colliding attributes would - // resolve (certain ones would be completely overriden, - // others would prepend themselves). - } - - $context->destroy('CurrentAttr'); - - // post transforms - - // global (error reporting untested) - foreach ($definition->info_attr_transform_post as $transform) { - $attr = $transform->transform($o = $attr, $config, $context); - if ($e) { - if ($attr != $o) { - $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); - } - } - } - - // local (error reporting untested) - foreach ($definition->info[$token->name]->attr_transform_post as $transform) { - $attr = $transform->transform($o = $attr, $config, $context); - if ($e) { - if ($attr != $o) { - $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); - } - } - } - - $token->attr = $attr; - - // destroy CurrentToken if we made it ourselves - if (!$current_token) { - $context->destroy('CurrentToken'); - } - - } - - -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/Bootstrap.php b/library/vendor/HTMLPurifier/Bootstrap.php deleted file mode 100644 index 707122bb2..000000000 --- a/library/vendor/HTMLPurifier/Bootstrap.php +++ /dev/null @@ -1,124 +0,0 @@ - -if (!defined('PHP_EOL')) { - switch (strtoupper(substr(PHP_OS, 0, 3))) { - case 'WIN': - define('PHP_EOL', "\r\n"); - break; - case 'DAR': - define('PHP_EOL', "\r"); - break; - default: - define('PHP_EOL', "\n"); - } -} - -/** - * Bootstrap class that contains meta-functionality for HTML Purifier such as - * the autoload function. - * - * @note - * This class may be used without any other files from HTML Purifier. - */ -class HTMLPurifier_Bootstrap -{ - - /** - * Autoload function for HTML Purifier - * @param string $class Class to load - * @return bool - */ - public static function autoload($class) - { - $file = HTMLPurifier_Bootstrap::getPath($class); - if (!$file) { - return false; - } - // Technically speaking, it should be ok and more efficient to - // just do 'require', but Antonio Parraga reports that with - // Zend extensions such as Zend debugger and APC, this invariant - // may be broken. Since we have efficient alternatives, pay - // the cost here and avoid the bug. - require_once HTMLPURIFIER_PREFIX . '/' . $file; - return true; - } - - /** - * Returns the path for a specific class. - * @param string $class Class path to get - * @return string - */ - public static function getPath($class) - { - if (strncmp('HTMLPurifier', $class, 12) !== 0) { - return false; - } - // Custom implementations - if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) { - $code = str_replace('_', '-', substr($class, 22)); - $file = 'HTMLPurifier/Language/classes/' . $code . '.php'; - } else { - $file = str_replace('_', '/', $class) . '.php'; - } - if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) { - return false; - } - return $file; - } - - /** - * "Pre-registers" our autoloader on the SPL stack. - */ - public static function registerAutoload() - { - $autoload = array('HTMLPurifier_Bootstrap', 'autoload'); - if (($funcs = spl_autoload_functions()) === false) { - spl_autoload_register($autoload); - } elseif (function_exists('spl_autoload_unregister')) { - if (version_compare(PHP_VERSION, '5.3.0', '>=')) { - // prepend flag exists, no need for shenanigans - spl_autoload_register($autoload, true, true); - } else { - $buggy = version_compare(PHP_VERSION, '5.2.11', '<'); - $compat = version_compare(PHP_VERSION, '5.1.2', '<=') && - version_compare(PHP_VERSION, '5.1.0', '>='); - foreach ($funcs as $func) { - if ($buggy && is_array($func)) { - // :TRICKY: There are some compatibility issues and some - // places where we need to error out - $reflector = new ReflectionMethod($func[0], $func[1]); - if (!$reflector->isStatic()) { - throw new Exception( - 'HTML Purifier autoloader registrar is not compatible - with non-static object methods due to PHP Bug #44144; - Please do not use HTMLPurifier.autoload.php (or any - file that includes this file); instead, place the code: - spl_autoload_register(array(\'HTMLPurifier_Bootstrap\', \'autoload\')) - after your own autoloaders.' - ); - } - // Suprisingly, spl_autoload_register supports the - // Class::staticMethod callback format, although call_user_func doesn't - if ($compat) { - $func = implode('::', $func); - } - } - spl_autoload_unregister($func); - } - spl_autoload_register($autoload); - foreach ($funcs as $func) { - spl_autoload_register($func); - } - } - } - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/CSSDefinition.php b/library/vendor/HTMLPurifier/CSSDefinition.php deleted file mode 100644 index 3f08b81c5..000000000 --- a/library/vendor/HTMLPurifier/CSSDefinition.php +++ /dev/null @@ -1,549 +0,0 @@ -info['text-align'] = new HTMLPurifier_AttrDef_Enum( - array('left', 'right', 'center', 'justify'), - false - ); - - $border_style = - $this->info['border-bottom-style'] = - $this->info['border-right-style'] = - $this->info['border-left-style'] = - $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum( - array( - 'none', - 'hidden', - 'dotted', - 'dashed', - 'solid', - 'double', - 'groove', - 'ridge', - 'inset', - 'outset' - ), - false - ); - - $this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style); - - $this->info['clear'] = new HTMLPurifier_AttrDef_Enum( - array('none', 'left', 'right', 'both'), - false - ); - $this->info['float'] = new HTMLPurifier_AttrDef_Enum( - array('none', 'left', 'right'), - false - ); - $this->info['font-style'] = new HTMLPurifier_AttrDef_Enum( - array('normal', 'italic', 'oblique'), - false - ); - $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum( - array('normal', 'small-caps'), - false - ); - - $uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum(array('none')), - new HTMLPurifier_AttrDef_CSS_URI() - ) - ); - - $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum( - array('inside', 'outside'), - false - ); - $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum( - array( - 'disc', - 'circle', - 'square', - 'decimal', - 'lower-roman', - 'upper-roman', - 'lower-alpha', - 'upper-alpha', - 'none' - ), - false - ); - $this->info['list-style-image'] = $uri_or_none; - - $this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config); - - $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum( - array('capitalize', 'uppercase', 'lowercase', 'none'), - false - ); - $this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color(); - - $this->info['background-image'] = $uri_or_none; - $this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum( - array('repeat', 'repeat-x', 'repeat-y', 'no-repeat') - ); - $this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum( - array('scroll', 'fixed') - ); - $this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition(); - - $this->info['background-size'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum( - array( - 'auto', - 'cover', - 'contain', - 'initial', - 'inherit', - ) - ), - new HTMLPurifier_AttrDef_CSS_Percentage(), - new HTMLPurifier_AttrDef_CSS_Length() - ) - ); - - $border_color = - $this->info['border-top-color'] = - $this->info['border-bottom-color'] = - $this->info['border-left-color'] = - $this->info['border-right-color'] = - $this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum(array('transparent')), - new HTMLPurifier_AttrDef_CSS_Color() - ) - ); - - $this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config); - - $this->info['border-color'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_color); - - $border_width = - $this->info['border-top-width'] = - $this->info['border-bottom-width'] = - $this->info['border-left-width'] = - $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')), - new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative - ) - ); - - $this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width); - - $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum(array('normal')), - new HTMLPurifier_AttrDef_CSS_Length() - ) - ); - - $this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum(array('normal')), - new HTMLPurifier_AttrDef_CSS_Length() - ) - ); - - $this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum( - array( - 'xx-small', - 'x-small', - 'small', - 'medium', - 'large', - 'x-large', - 'xx-large', - 'larger', - 'smaller' - ) - ), - new HTMLPurifier_AttrDef_CSS_Percentage(), - new HTMLPurifier_AttrDef_CSS_Length() - ) - ); - - $this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum(array('normal')), - new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives - new HTMLPurifier_AttrDef_CSS_Length('0'), - new HTMLPurifier_AttrDef_CSS_Percentage(true) - ) - ); - - $margin = - $this->info['margin-top'] = - $this->info['margin-bottom'] = - $this->info['margin-left'] = - $this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length(), - new HTMLPurifier_AttrDef_CSS_Percentage(), - new HTMLPurifier_AttrDef_Enum(array('auto')) - ) - ); - - $this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin); - - // non-negative - $padding = - $this->info['padding-top'] = - $this->info['padding-bottom'] = - $this->info['padding-left'] = - $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length('0'), - new HTMLPurifier_AttrDef_CSS_Percentage(true) - ) - ); - - $this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding); - - $this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length(), - new HTMLPurifier_AttrDef_CSS_Percentage() - ) - ); - - $trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length('0'), - new HTMLPurifier_AttrDef_CSS_Percentage(true), - new HTMLPurifier_AttrDef_Enum(array('auto', 'initial', 'inherit')) - ) - ); - $trusted_min_wh = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length('0'), - new HTMLPurifier_AttrDef_CSS_Percentage(true), - new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit')) - ) - ); - $trusted_max_wh = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length('0'), - new HTMLPurifier_AttrDef_CSS_Percentage(true), - new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit')) - ) - ); - $max = $config->get('CSS.MaxImgLength'); - - $this->info['width'] = - $this->info['height'] = - $max === null ? - $trusted_wh : - new HTMLPurifier_AttrDef_Switch( - 'img', - // For img tags: - new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length('0', $max), - new HTMLPurifier_AttrDef_Enum(array('auto')) - ) - ), - // For everyone else: - $trusted_wh - ); - $this->info['min-width'] = - $this->info['min-height'] = - $max === null ? - $trusted_min_wh : - new HTMLPurifier_AttrDef_Switch( - 'img', - // For img tags: - new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length('0', $max), - new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit')) - ) - ), - // For everyone else: - $trusted_min_wh - ); - $this->info['max-width'] = - $this->info['max-height'] = - $max === null ? - $trusted_max_wh : - new HTMLPurifier_AttrDef_Switch( - 'img', - // For img tags: - new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length('0', $max), - new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit')) - ) - ), - // For everyone else: - $trusted_max_wh - ); - - $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration(); - - $this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily(); - - // this could use specialized code - $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum( - array( - 'normal', - 'bold', - 'bolder', - 'lighter', - '100', - '200', - '300', - '400', - '500', - '600', - '700', - '800', - '900' - ), - false - ); - - // MUST be called after other font properties, as it references - // a CSSDefinition object - $this->info['font'] = new HTMLPurifier_AttrDef_CSS_Font($config); - - // same here - $this->info['border'] = - $this->info['border-bottom'] = - $this->info['border-top'] = - $this->info['border-left'] = - $this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config); - - $this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum( - array('collapse', 'separate') - ); - - $this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum( - array('top', 'bottom') - ); - - $this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum( - array('auto', 'fixed') - ); - - $this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Enum( - array( - 'baseline', - 'sub', - 'super', - 'top', - 'text-top', - 'middle', - 'bottom', - 'text-bottom' - ) - ), - new HTMLPurifier_AttrDef_CSS_Length(), - new HTMLPurifier_AttrDef_CSS_Percentage() - ) - ); - - $this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2); - - // These CSS properties don't work on many browsers, but we live - // in THE FUTURE! - $this->info['white-space'] = new HTMLPurifier_AttrDef_Enum( - array('nowrap', 'normal', 'pre', 'pre-wrap', 'pre-line') - ); - - if ($config->get('CSS.Proprietary')) { - $this->doSetupProprietary($config); - } - - if ($config->get('CSS.AllowTricky')) { - $this->doSetupTricky($config); - } - - if ($config->get('CSS.Trusted')) { - $this->doSetupTrusted($config); - } - - $allow_important = $config->get('CSS.AllowImportant'); - // wrap all attr-defs with decorator that handles !important - foreach ($this->info as $k => $v) { - $this->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important); - } - - $this->setupConfigStuff($config); - } - - /** - * @param HTMLPurifier_Config $config - */ - protected function doSetupProprietary($config) - { - // Internet Explorer only scrollbar colors - $this->info['scrollbar-arrow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - $this->info['scrollbar-base-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - $this->info['scrollbar-darkshadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - $this->info['scrollbar-face-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - $this->info['scrollbar-highlight-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - $this->info['scrollbar-shadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - - // vendor specific prefixes of opacity - $this->info['-moz-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); - $this->info['-khtml-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); - - // only opacity, for now - $this->info['filter'] = new HTMLPurifier_AttrDef_CSS_Filter(); - - // more CSS3 - $this->info['page-break-after'] = - $this->info['page-break-before'] = new HTMLPurifier_AttrDef_Enum( - array( - 'auto', - 'always', - 'avoid', - 'left', - 'right' - ) - ); - $this->info['page-break-inside'] = new HTMLPurifier_AttrDef_Enum(array('auto', 'avoid')); - - $border_radius = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Percentage(true), // disallow negative - new HTMLPurifier_AttrDef_CSS_Length('0') // disallow negative - )); - - $this->info['border-top-left-radius'] = - $this->info['border-top-right-radius'] = - $this->info['border-bottom-right-radius'] = - $this->info['border-bottom-left-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 2); - // TODO: support SLASH syntax - $this->info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 4); - - } - - /** - * @param HTMLPurifier_Config $config - */ - protected function doSetupTricky($config) - { - $this->info['display'] = new HTMLPurifier_AttrDef_Enum( - array( - 'inline', - 'block', - 'list-item', - 'run-in', - 'compact', - 'marker', - 'table', - 'inline-block', - 'inline-table', - 'table-row-group', - 'table-header-group', - 'table-footer-group', - 'table-row', - 'table-column-group', - 'table-column', - 'table-cell', - 'table-caption', - 'none' - ) - ); - $this->info['visibility'] = new HTMLPurifier_AttrDef_Enum( - array('visible', 'hidden', 'collapse') - ); - $this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(array('visible', 'hidden', 'auto', 'scroll')); - $this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); - } - - /** - * @param HTMLPurifier_Config $config - */ - protected function doSetupTrusted($config) - { - $this->info['position'] = new HTMLPurifier_AttrDef_Enum( - array('static', 'relative', 'absolute', 'fixed') - ); - $this->info['top'] = - $this->info['left'] = - $this->info['right'] = - $this->info['bottom'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_CSS_Length(), - new HTMLPurifier_AttrDef_CSS_Percentage(), - new HTMLPurifier_AttrDef_Enum(array('auto')), - ) - ); - $this->info['z-index'] = new HTMLPurifier_AttrDef_CSS_Composite( - array( - new HTMLPurifier_AttrDef_Integer(), - new HTMLPurifier_AttrDef_Enum(array('auto')), - ) - ); - } - - /** - * Performs extra config-based processing. Based off of - * HTMLPurifier_HTMLDefinition. - * @param HTMLPurifier_Config $config - * @todo Refactor duplicate elements into common class (probably using - * composition, not inheritance). - */ - protected function setupConfigStuff($config) - { - // setup allowed elements - $support = "(for information on implementing this, see the " . - "support forums) "; - $allowed_properties = $config->get('CSS.AllowedProperties'); - if ($allowed_properties !== null) { - foreach ($this->info as $name => $d) { - if (!isset($allowed_properties[$name])) { - unset($this->info[$name]); - } - unset($allowed_properties[$name]); - } - // emit errors - foreach ($allowed_properties as $name => $d) { - // :TODO: Is this htmlspecialchars() call really necessary? - $name = htmlspecialchars($name); - trigger_error("Style attribute '$name' is not supported $support", E_USER_WARNING); - } - } - - $forbidden_properties = $config->get('CSS.ForbiddenProperties'); - if ($forbidden_properties !== null) { - foreach ($this->info as $name => $d) { - if (isset($forbidden_properties[$name])) { - unset($this->info[$name]); - } - } - } - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef.php b/library/vendor/HTMLPurifier/ChildDef.php deleted file mode 100644 index 8eb17b82e..000000000 --- a/library/vendor/HTMLPurifier/ChildDef.php +++ /dev/null @@ -1,52 +0,0 @@ -elements; - } - - /** - * Validates nodes according to definition and returns modification. - * - * @param HTMLPurifier_Node[] $children Array of HTMLPurifier_Node - * @param HTMLPurifier_Config $config HTMLPurifier_Config object - * @param HTMLPurifier_Context $context HTMLPurifier_Context object - * @return bool|array true to leave nodes as is, false to remove parent node, array of replacement children - */ - abstract public function validateChildren($children, $config, $context); -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef/Chameleon.php b/library/vendor/HTMLPurifier/ChildDef/Chameleon.php deleted file mode 100644 index 7439be26b..000000000 --- a/library/vendor/HTMLPurifier/ChildDef/Chameleon.php +++ /dev/null @@ -1,67 +0,0 @@ -inline = new HTMLPurifier_ChildDef_Optional($inline); - $this->block = new HTMLPurifier_ChildDef_Optional($block); - $this->elements = $this->block->elements; - } - - /** - * @param HTMLPurifier_Node[] $children - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return bool - */ - public function validateChildren($children, $config, $context) - { - if ($context->get('IsInline') === false) { - return $this->block->validateChildren( - $children, - $config, - $context - ); - } else { - return $this->inline->validateChildren( - $children, - $config, - $context - ); - } - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef/Custom.php b/library/vendor/HTMLPurifier/ChildDef/Custom.php deleted file mode 100644 index f515888a1..000000000 --- a/library/vendor/HTMLPurifier/ChildDef/Custom.php +++ /dev/null @@ -1,102 +0,0 @@ -dtd_regex = $dtd_regex; - $this->_compileRegex(); - } - - /** - * Compiles the PCRE regex from a DTD regex ($dtd_regex to $_pcre_regex) - */ - protected function _compileRegex() - { - $raw = str_replace(' ', '', $this->dtd_regex); - if ($raw[0] != '(') { - $raw = "($raw)"; - } - $el = '[#a-zA-Z0-9_.-]+'; - $reg = $raw; - - // COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M - // DOING! Seriously: if there's problems, please report them. - - // collect all elements into the $elements array - preg_match_all("/$el/", $reg, $matches); - foreach ($matches[0] as $match) { - $this->elements[$match] = true; - } - - // setup all elements as parentheticals with leading commas - $reg = preg_replace("/$el/", '(,\\0)', $reg); - - // remove commas when they were not solicited - $reg = preg_replace("/([^,(|]\(+),/", '\\1', $reg); - - // remove all non-paranthetical commas: they are handled by first regex - $reg = preg_replace("/,\(/", '(', $reg); - - $this->_pcre_regex = $reg; - } - - /** - * @param HTMLPurifier_Node[] $children - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return bool - */ - public function validateChildren($children, $config, $context) - { - $list_of_children = ''; - $nesting = 0; // depth into the nest - foreach ($children as $node) { - if (!empty($node->is_whitespace)) { - continue; - } - $list_of_children .= $node->name . ','; - } - // add leading comma to deal with stray comma declarations - $list_of_children = ',' . rtrim($list_of_children, ','); - $okay = - preg_match( - '/^,?' . $this->_pcre_regex . '$/', - $list_of_children - ); - return (bool)$okay; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef/Empty.php b/library/vendor/HTMLPurifier/ChildDef/Empty.php deleted file mode 100644 index a8a6cbdd2..000000000 --- a/library/vendor/HTMLPurifier/ChildDef/Empty.php +++ /dev/null @@ -1,38 +0,0 @@ - true, 'ul' => true, 'ol' => true); - - public $whitespace; - - /** - * @param array $children - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return array - */ - public function validateChildren($children, $config, $context) - { - // Flag for subclasses - $this->whitespace = false; - - // if there are no tokens, delete parent node - if (empty($children)) { - return false; - } - - // if li is not allowed, delete parent node - if (!isset($config->getHTMLDefinition()->info['li'])) { - trigger_error("Cannot allow ul/ol without allowing li", E_USER_WARNING); - return false; - } - - // the new set of children - $result = array(); - - // a little sanity check to make sure it's not ALL whitespace - $all_whitespace = true; - - $current_li = null; - - foreach ($children as $node) { - if (!empty($node->is_whitespace)) { - $result[] = $node; - continue; - } - $all_whitespace = false; // phew, we're not talking about whitespace - - if ($node->name === 'li') { - // good - $current_li = $node; - $result[] = $node; - } else { - // we want to tuck this into the previous li - // Invariant: we expect the node to be ol/ul - // ToDo: Make this more robust in the case of not ol/ul - // by distinguishing between existing li and li created - // to handle non-list elements; non-list elements should - // not be appended to an existing li; only li created - // for non-list. This distinction is not currently made. - if ($current_li === null) { - $current_li = new HTMLPurifier_Node_Element('li'); - $result[] = $current_li; - } - $current_li->children[] = $node; - $current_li->empty = false; // XXX fascinating! Check for this error elsewhere ToDo - } - } - if (empty($result)) { - return false; - } - if ($all_whitespace) { - return false; - } - return $result; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef/Optional.php b/library/vendor/HTMLPurifier/ChildDef/Optional.php deleted file mode 100644 index b9468063b..000000000 --- a/library/vendor/HTMLPurifier/ChildDef/Optional.php +++ /dev/null @@ -1,45 +0,0 @@ -whitespace) { - return $children; - } else { - return array(); - } - } - return $result; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef/Required.php b/library/vendor/HTMLPurifier/ChildDef/Required.php deleted file mode 100644 index 0d1c8f5f3..000000000 --- a/library/vendor/HTMLPurifier/ChildDef/Required.php +++ /dev/null @@ -1,118 +0,0 @@ - $x) { - $elements[$i] = true; - if (empty($i)) { - unset($elements[$i]); - } // remove blank - } - } - $this->elements = $elements; - } - - /** - * @type bool - */ - public $allow_empty = false; - - /** - * @type string - */ - public $type = 'required'; - - /** - * @param array $children - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return array - */ - public function validateChildren($children, $config, $context) - { - // Flag for subclasses - $this->whitespace = false; - - // if there are no tokens, delete parent node - if (empty($children)) { - return false; - } - - // the new set of children - $result = array(); - - // whether or not parsed character data is allowed - // this controls whether or not we silently drop a tag - // or generate escaped HTML from it - $pcdata_allowed = isset($this->elements['#PCDATA']); - - // a little sanity check to make sure it's not ALL whitespace - $all_whitespace = true; - - $stack = array_reverse($children); - while (!empty($stack)) { - $node = array_pop($stack); - if (!empty($node->is_whitespace)) { - $result[] = $node; - continue; - } - $all_whitespace = false; // phew, we're not talking about whitespace - - if (!isset($this->elements[$node->name])) { - // special case text - // XXX One of these ought to be redundant or something - if ($pcdata_allowed && $node instanceof HTMLPurifier_Node_Text) { - $result[] = $node; - continue; - } - // spill the child contents in - // ToDo: Make configurable - if ($node instanceof HTMLPurifier_Node_Element) { - for ($i = count($node->children) - 1; $i >= 0; $i--) { - $stack[] = $node->children[$i]; - } - continue; - } - continue; - } - $result[] = $node; - } - if (empty($result)) { - return false; - } - if ($all_whitespace) { - $this->whitespace = true; - return false; - } - return $result; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef/StrictBlockquote.php b/library/vendor/HTMLPurifier/ChildDef/StrictBlockquote.php deleted file mode 100644 index 3270a46e1..000000000 --- a/library/vendor/HTMLPurifier/ChildDef/StrictBlockquote.php +++ /dev/null @@ -1,110 +0,0 @@ -init($config); - return $this->fake_elements; - } - - /** - * @param array $children - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return array - */ - public function validateChildren($children, $config, $context) - { - $this->init($config); - - // trick the parent class into thinking it allows more - $this->elements = $this->fake_elements; - $result = parent::validateChildren($children, $config, $context); - $this->elements = $this->real_elements; - - if ($result === false) { - return array(); - } - if ($result === true) { - $result = $children; - } - - $def = $config->getHTMLDefinition(); - $block_wrap_name = $def->info_block_wrapper; - $block_wrap = false; - $ret = array(); - - foreach ($result as $node) { - if ($block_wrap === false) { - if (($node instanceof HTMLPurifier_Node_Text && !$node->is_whitespace) || - ($node instanceof HTMLPurifier_Node_Element && !isset($this->elements[$node->name]))) { - $block_wrap = new HTMLPurifier_Node_Element($def->info_block_wrapper); - $ret[] = $block_wrap; - } - } else { - if ($node instanceof HTMLPurifier_Node_Element && isset($this->elements[$node->name])) { - $block_wrap = false; - - } - } - if ($block_wrap) { - $block_wrap->children[] = $node; - } else { - $ret[] = $node; - } - } - return $ret; - } - - /** - * @param HTMLPurifier_Config $config - */ - private function init($config) - { - if (!$this->init) { - $def = $config->getHTMLDefinition(); - // allow all inline elements - $this->real_elements = $this->elements; - $this->fake_elements = $def->info_content_sets['Flow']; - $this->fake_elements['#PCDATA'] = true; - $this->init = true; - } - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ChildDef/Table.php b/library/vendor/HTMLPurifier/ChildDef/Table.php deleted file mode 100644 index 67c7e9535..000000000 --- a/library/vendor/HTMLPurifier/ChildDef/Table.php +++ /dev/null @@ -1,224 +0,0 @@ - true, - 'tbody' => true, - 'thead' => true, - 'tfoot' => true, - 'caption' => true, - 'colgroup' => true, - 'col' => true - ); - - public function __construct() - { - } - - /** - * @param array $children - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return array - */ - public function validateChildren($children, $config, $context) - { - if (empty($children)) { - return false; - } - - // only one of these elements is allowed in a table - $caption = false; - $thead = false; - $tfoot = false; - - // whitespace - $initial_ws = array(); - $after_caption_ws = array(); - $after_thead_ws = array(); - $after_tfoot_ws = array(); - - // as many of these as you want - $cols = array(); - $content = array(); - - $tbody_mode = false; // if true, then we need to wrap any stray - //
- This directive turns on auto-paragraphing, where double newlines are - converted in to paragraphs whenever possible. Auto-paragraphing: -
-
- p
tags must be allowed for this directive to take effect.
- We do not use br
tags for paragraphing, as that is
- semantically incorrect.
-
- To prevent auto-paragraphing as a content-producer, refrain from using
- double-newlines except to specify a new paragraph or in contexts where
- it has special meaning (whitespace usually has no meaning except in
- tags like pre
, so this should not be difficult.) To prevent
- the paragraphing of inline text adjacent to block elements, wrap them
- in div
tags (the behavior is slightly different outside of
- the root node.)
-
- This directive can be used to add custom auto-format injectors. - Specify an array of injector names (class name minus the prefix) - or concrete implementations. Injector class must exist. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt deleted file mode 100644 index 663064a34..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt +++ /dev/null @@ -1,11 +0,0 @@ -AutoFormat.DisplayLinkURI -TYPE: bool -VERSION: 3.2.0 -DEFAULT: false ---DESCRIPTION-- -- This directive turns on the in-text display of URIs in <a> tags, and disables - those links. For example, example becomes - example (http://example.com). -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt deleted file mode 100644 index 3a48ba960..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt +++ /dev/null @@ -1,12 +0,0 @@ -AutoFormat.Linkify -TYPE: bool -VERSION: 2.0.1 -DEFAULT: false ---DESCRIPTION-- - -
- This directive turns on linkification, auto-linking http, ftp and
- https URLs. a
tags with the href
attribute
- must be allowed.
-
- Location of configuration documentation to link to, let %s substitute - into the configuration's namespace and directive names sans the percent - sign. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt deleted file mode 100644 index 7996488be..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt +++ /dev/null @@ -1,12 +0,0 @@ -AutoFormat.PurifierLinkify -TYPE: bool -VERSION: 2.0.1 -DEFAULT: false ---DESCRIPTION-- - -
- Internal auto-formatter that converts configuration directives in
- syntax %Namespace.Directive to links. a
tags
- with the href
attribute must be allowed.
-
- Given that an element has no contents, it will be removed by default, unless
- this predicate dictates otherwise. The predicate can either be an associative
- map from tag name to list of attributes that must be present for the element
- to be considered preserved: thus, the default always preserves colgroup
,
- th
and td
, and also iframe
if it
- has a src
.
-
- When %AutoFormat.RemoveEmpty and %AutoFormat.RemoveEmpty.RemoveNbsp - are enabled, this directive defines what HTML elements should not be - removede if they have only a non-breaking space in them. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt deleted file mode 100644 index 9228dee22..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt +++ /dev/null @@ -1,15 +0,0 @@ -AutoFormat.RemoveEmpty.RemoveNbsp -TYPE: bool -VERSION: 4.0.0 -DEFAULT: false ---DESCRIPTION-- -- When enabled, HTML Purifier will treat any elements that contain only - non-breaking spaces as well as regular whitespace as empty, and remove - them when %AutoFormat.RemoveEmpty is enabled. -
-- See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements - that don't have this behavior applied to them. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt deleted file mode 100644 index 34657ba47..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt +++ /dev/null @@ -1,46 +0,0 @@ -AutoFormat.RemoveEmpty -TYPE: bool -VERSION: 3.2.0 -DEFAULT: false ---DESCRIPTION-- -- When enabled, HTML Purifier will attempt to remove empty elements that - contribute no semantic information to the document. The following types - of nodes will be removed: -
-<a></a>
but not
- <br />
), and
- colgroup
element, orid
or name
attribute,
- when those attributes are permitted on those elements.
- - Please be very careful when using this functionality; while it may not - seem that empty elements contain useful information, they can alter the - layout of a document given appropriate styling. This directive is most - useful when you are processing machine-generated HTML, please avoid using - it on regular user HTML. -
-- Elements that contain only whitespace will be treated as empty. Non-breaking - spaces, however, do not count as whitespace. See - %AutoFormat.RemoveEmpty.RemoveNbsp for alternate behavior. -
-- This algorithm is not perfect; you may still notice some empty tags, - particularly if a node had elements, but those elements were later removed - because they were not permitted in that context, or tags that, after - being auto-closed by another tag, where empty. This is for safety reasons - to prevent clever code from breaking validation. The general rule of thumb: - if a tag looked empty on the way in, it will get removed; if HTML Purifier - made it empty, it will stay. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt deleted file mode 100644 index dde990ab2..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt +++ /dev/null @@ -1,11 +0,0 @@ -AutoFormat.RemoveSpansWithoutAttributes -TYPE: bool -VERSION: 4.0.1 -DEFAULT: false ---DESCRIPTION-- -
- This directive causes span
tags without any attributes
- to be removed. It will also remove spans that had all attributes
- removed during processing.
-
- By default, HTML Purifier removes duplicate CSS properties,
- like color:red; color:blue
. If this is set to
- true, duplicate properties are allowed.
-
display:none;
is considered a tricky property that
-will only be allowed if this directive is set to true.
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt
deleted file mode 100644
index 3fd465406..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-CSS.AllowedFonts
-TYPE: lookup/null
-VERSION: 4.3.0
-DEFAULT: NULL
---DESCRIPTION--
-
- Allows you to manually specify a set of allowed fonts. If
- NULL
, all fonts are allowed. This directive
- affects generic names (serif, sans-serif, monospace, cursive,
- fantasy) as well as specific font families.
-
- If HTML Purifier's style attributes set is unsatisfactory for your needs, - you can overload it with your own list of tags to allow. Note that this - method is subtractive: it does its job by taking away from HTML Purifier - usual feature set, so you cannot add an attribute that HTML Purifier never - supported in the first place. -
-- Warning: If another directive conflicts with the - elements here, that directive will win and override. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt deleted file mode 100644 index 5cb7dda3b..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt +++ /dev/null @@ -1,11 +0,0 @@ -CSS.DefinitionRev -TYPE: int -VERSION: 2.0.0 -DEFAULT: 1 ---DESCRIPTION-- - -- Revision identifier for your custom definition. See - %HTML.DefinitionRev for details. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt deleted file mode 100644 index f1f5c5f12..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt +++ /dev/null @@ -1,13 +0,0 @@ -CSS.ForbiddenProperties -TYPE: lookup -VERSION: 4.2.0 -DEFAULT: array() ---DESCRIPTION-- -- This is the logical inverse of %CSS.AllowedProperties, and it will - override that directive or any other directive. If possible, - %CSS.AllowedProperties is recommended over this directive, - because it can sometimes be difficult to tell whether or not you've - forbidden all of the CSS properties you truly would like to disallow. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt deleted file mode 100644 index 7a3291470..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt +++ /dev/null @@ -1,16 +0,0 @@ -CSS.MaxImgLength -TYPE: string/null -DEFAULT: '1200px' -VERSION: 3.1.1 ---DESCRIPTION-- -
- This parameter sets the maximum allowed length on img
tags,
- effectively the width
and height
properties.
- Only absolute units of measurement (in, pt, pc, mm, cm) and pixels (px) are allowed. This is
- in place to prevent imagecrash attacks, disable with null at your own risk.
- This directive is similar to %HTML.MaxImgLength, and both should be
- concurrently edited, although there are
- subtle differences in the input format (the CSS max is a number with
- a unit).
-
- Whether or not to allow safe, proprietary CSS values. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt deleted file mode 100644 index e733a61e8..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt +++ /dev/null @@ -1,9 +0,0 @@ -CSS.Trusted -TYPE: bool -VERSION: 4.2.1 -DEFAULT: false ---DESCRIPTION-- -Indicates whether or not the user's CSS input is trusted or not. If the -input is trusted, a more expansive set of allowed properties. See -also %HTML.Trusted. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt deleted file mode 100644 index c486724c8..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt +++ /dev/null @@ -1,14 +0,0 @@ -Cache.DefinitionImpl -TYPE: string/null -VERSION: 2.0.0 -DEFAULT: 'Serializer' ---DESCRIPTION-- - -This directive defines which method to use when caching definitions, -the complex data-type that makes HTML Purifier tick. Set to null -to disable caching (not recommended, as you will see a definite -performance degradation). - ---ALIASES-- -Core.DefinitionCache ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt deleted file mode 100644 index 54036507d..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt +++ /dev/null @@ -1,13 +0,0 @@ -Cache.SerializerPath -TYPE: string/null -VERSION: 2.0.0 -DEFAULT: NULL ---DESCRIPTION-- - -- Absolute path with no trailing slash to store serialized definitions in. - Default is within the - HTML Purifier library inside DefinitionCache/Serializer. This - path must be writable by the webserver. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt deleted file mode 100644 index 2e0cc8104..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt +++ /dev/null @@ -1,16 +0,0 @@ -Cache.SerializerPermissions -TYPE: int/null -VERSION: 4.3.0 -DEFAULT: 0755 ---DESCRIPTION-- - -- Directory permissions of the files and directories created inside - the DefinitionCache/Serializer or other custom serializer path. -
-
- In HTML Purifier 4.8.0, this also supports NULL
,
- which means that no chmod'ing or directory creation shall
- occur.
-
- This directive enables aggressive pre-filter fixes HTML Purifier can - perform in order to ensure that open angled-brackets do not get killed - during parsing stage. Enabling this will result in two preg_replace_callback - calls and at least two preg_replace calls for every HTML document parsed; - if your users make very well-formed HTML, you can set this directive false. - This has no effect when DirectLex is used. -
-- Notice: This directive's default turned from false to true - in HTML Purifier 3.2.0. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt deleted file mode 100644 index b2b6ab149..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt +++ /dev/null @@ -1,16 +0,0 @@ -Core.AggressivelyRemoveScript -TYPE: bool -VERSION: 4.9.0 -DEFAULT: true ---DESCRIPTION-- -- This directive enables aggressive pre-filter removal of - script tags. This is not necessary for security, - but it can help work around a bug in libxml where embedded - HTML elements inside script sections cause the parser to - choke. To revert to pre-4.9.0 behavior, set this to false. - This directive has no effect if %Core.Trusted is true, - %Core.RemoveScriptContents is false, or %Core.HiddenElements - does not contain script. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt deleted file mode 100644 index 2c910cc7d..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt +++ /dev/null @@ -1,16 +0,0 @@ -Core.AllowHostnameUnderscore -TYPE: bool -VERSION: 4.6.0 -DEFAULT: false ---DESCRIPTION-- -- By RFC 1123, underscores are not permitted in host names. - (This is in contrast to the specification for DNS, RFC - 2181, which allows underscores.) - However, most browsers do the right thing when faced with - an underscore in the host name, and so some poorly written - websites are written with the expectation this should work. - Setting this parameter to true relaxes our allowed character - check so that underscores are permitted. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt deleted file mode 100644 index 06278f82a..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt +++ /dev/null @@ -1,12 +0,0 @@ -Core.AllowParseManyTags -TYPE: bool -DEFAULT: false -VERSION: 4.10.1 ---DESCRIPTION-- -- This directive allows parsing of many nested tags. - If you set true, relaxes any hardcoded limit from the parser. - However, in that case it may cause a Dos attack. - Be careful when enabling it. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt deleted file mode 100644 index d7317911f..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt +++ /dev/null @@ -1,12 +0,0 @@ -Core.CollectErrors -TYPE: bool -VERSION: 2.0.0 -DEFAULT: false ---DESCRIPTION-- - -Whether or not to collect errors found while filtering the document. This -is a useful way to give feedback to your users. Warning: -Currently this feature is very patchy and experimental, with lots of -possible error messages not yet implemented. It will not cause any -problems, but it may not help your users either. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt deleted file mode 100644 index a75844cd5..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt +++ /dev/null @@ -1,160 +0,0 @@ -Core.ColorKeywords -TYPE: hash -VERSION: 2.0.0 ---DEFAULT-- -array ( - 'aliceblue' => '#F0F8FF', - 'antiquewhite' => '#FAEBD7', - 'aqua' => '#00FFFF', - 'aquamarine' => '#7FFFD4', - 'azure' => '#F0FFFF', - 'beige' => '#F5F5DC', - 'bisque' => '#FFE4C4', - 'black' => '#000000', - 'blanchedalmond' => '#FFEBCD', - 'blue' => '#0000FF', - 'blueviolet' => '#8A2BE2', - 'brown' => '#A52A2A', - 'burlywood' => '#DEB887', - 'cadetblue' => '#5F9EA0', - 'chartreuse' => '#7FFF00', - 'chocolate' => '#D2691E', - 'coral' => '#FF7F50', - 'cornflowerblue' => '#6495ED', - 'cornsilk' => '#FFF8DC', - 'crimson' => '#DC143C', - 'cyan' => '#00FFFF', - 'darkblue' => '#00008B', - 'darkcyan' => '#008B8B', - 'darkgoldenrod' => '#B8860B', - 'darkgray' => '#A9A9A9', - 'darkgrey' => '#A9A9A9', - 'darkgreen' => '#006400', - 'darkkhaki' => '#BDB76B', - 'darkmagenta' => '#8B008B', - 'darkolivegreen' => '#556B2F', - 'darkorange' => '#FF8C00', - 'darkorchid' => '#9932CC', - 'darkred' => '#8B0000', - 'darksalmon' => '#E9967A', - 'darkseagreen' => '#8FBC8F', - 'darkslateblue' => '#483D8B', - 'darkslategray' => '#2F4F4F', - 'darkslategrey' => '#2F4F4F', - 'darkturquoise' => '#00CED1', - 'darkviolet' => '#9400D3', - 'deeppink' => '#FF1493', - 'deepskyblue' => '#00BFFF', - 'dimgray' => '#696969', - 'dimgrey' => '#696969', - 'dodgerblue' => '#1E90FF', - 'firebrick' => '#B22222', - 'floralwhite' => '#FFFAF0', - 'forestgreen' => '#228B22', - 'fuchsia' => '#FF00FF', - 'gainsboro' => '#DCDCDC', - 'ghostwhite' => '#F8F8FF', - 'gold' => '#FFD700', - 'goldenrod' => '#DAA520', - 'gray' => '#808080', - 'grey' => '#808080', - 'green' => '#008000', - 'greenyellow' => '#ADFF2F', - 'honeydew' => '#F0FFF0', - 'hotpink' => '#FF69B4', - 'indianred' => '#CD5C5C', - 'indigo' => '#4B0082', - 'ivory' => '#FFFFF0', - 'khaki' => '#F0E68C', - 'lavender' => '#E6E6FA', - 'lavenderblush' => '#FFF0F5', - 'lawngreen' => '#7CFC00', - 'lemonchiffon' => '#FFFACD', - 'lightblue' => '#ADD8E6', - 'lightcoral' => '#F08080', - 'lightcyan' => '#E0FFFF', - 'lightgoldenrodyellow' => '#FAFAD2', - 'lightgray' => '#D3D3D3', - 'lightgrey' => '#D3D3D3', - 'lightgreen' => '#90EE90', - 'lightpink' => '#FFB6C1', - 'lightsalmon' => '#FFA07A', - 'lightseagreen' => '#20B2AA', - 'lightskyblue' => '#87CEFA', - 'lightslategray' => '#778899', - 'lightslategrey' => '#778899', - 'lightsteelblue' => '#B0C4DE', - 'lightyellow' => '#FFFFE0', - 'lime' => '#00FF00', - 'limegreen' => '#32CD32', - 'linen' => '#FAF0E6', - 'magenta' => '#FF00FF', - 'maroon' => '#800000', - 'mediumaquamarine' => '#66CDAA', - 'mediumblue' => '#0000CD', - 'mediumorchid' => '#BA55D3', - 'mediumpurple' => '#9370DB', - 'mediumseagreen' => '#3CB371', - 'mediumslateblue' => '#7B68EE', - 'mediumspringgreen' => '#00FA9A', - 'mediumturquoise' => '#48D1CC', - 'mediumvioletred' => '#C71585', - 'midnightblue' => '#191970', - 'mintcream' => '#F5FFFA', - 'mistyrose' => '#FFE4E1', - 'moccasin' => '#FFE4B5', - 'navajowhite' => '#FFDEAD', - 'navy' => '#000080', - 'oldlace' => '#FDF5E6', - 'olive' => '#808000', - 'olivedrab' => '#6B8E23', - 'orange' => '#FFA500', - 'orangered' => '#FF4500', - 'orchid' => '#DA70D6', - 'palegoldenrod' => '#EEE8AA', - 'palegreen' => '#98FB98', - 'paleturquoise' => '#AFEEEE', - 'palevioletred' => '#DB7093', - 'papayawhip' => '#FFEFD5', - 'peachpuff' => '#FFDAB9', - 'peru' => '#CD853F', - 'pink' => '#FFC0CB', - 'plum' => '#DDA0DD', - 'powderblue' => '#B0E0E6', - 'purple' => '#800080', - 'rebeccapurple' => '#663399', - 'red' => '#FF0000', - 'rosybrown' => '#BC8F8F', - 'royalblue' => '#4169E1', - 'saddlebrown' => '#8B4513', - 'salmon' => '#FA8072', - 'sandybrown' => '#F4A460', - 'seagreen' => '#2E8B57', - 'seashell' => '#FFF5EE', - 'sienna' => '#A0522D', - 'silver' => '#C0C0C0', - 'skyblue' => '#87CEEB', - 'slateblue' => '#6A5ACD', - 'slategray' => '#708090', - 'slategrey' => '#708090', - 'snow' => '#FFFAFA', - 'springgreen' => '#00FF7F', - 'steelblue' => '#4682B4', - 'tan' => '#D2B48C', - 'teal' => '#008080', - 'thistle' => '#D8BFD8', - 'tomato' => '#FF6347', - 'turquoise' => '#40E0D0', - 'violet' => '#EE82EE', - 'wheat' => '#F5DEB3', - 'white' => '#FFFFFF', - 'whitesmoke' => '#F5F5F5', - 'yellow' => '#FFFF00', - 'yellowgreen' => '#9ACD32' -) ---DESCRIPTION-- - -Lookup array of color names to six digit hexadecimal number corresponding -to color, with preceding hash mark. Used when parsing colors. The lookup -is done in a case-insensitive manner. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt deleted file mode 100644 index 64b114fce..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt +++ /dev/null @@ -1,14 +0,0 @@ -Core.ConvertDocumentToFragment -TYPE: bool -DEFAULT: true ---DESCRIPTION-- - -This parameter determines whether or not the filter should convert -input that is a full document with html and body tags to a fragment -of just the contents of a body tag. This parameter is simply something -HTML Purifier can do during an edge-case: for most inputs, this -processing is not necessary. - ---ALIASES-- -Core.AcceptFullDocuments ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt deleted file mode 100644 index 36f16e07e..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt +++ /dev/null @@ -1,17 +0,0 @@ -Core.DirectLexLineNumberSyncInterval -TYPE: int -VERSION: 2.0.0 -DEFAULT: 0 ---DESCRIPTION-- - -- Specifies the number of tokens the DirectLex line number tracking - implementations should process before attempting to resyncronize the - current line count by manually counting all previous new-lines. When - at 0, this functionality is disabled. Lower values will decrease - performance, and this is only strictly necessary if the counting - algorithm is buggy (in which case you should report it as a bug). - This has no effect when %Core.MaintainLineNumbers is disabled or DirectLex is - not being used. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt deleted file mode 100644 index 1cd4c2c96..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt +++ /dev/null @@ -1,14 +0,0 @@ -Core.DisableExcludes -TYPE: bool -DEFAULT: false -VERSION: 4.5.0 ---DESCRIPTION-- -
- This directive disables SGML-style exclusions, e.g. the exclusion of
- <object>
in any descendant of a
- <pre>
tag. Disabling excludes will allow some
- invalid documents to pass through HTML Purifier, but HTML Purifier
- will also be less likely to accidentally remove large documents during
- processing.
-
Warning: this configuration option is no longer does anything as of 4.6.0.
- -When true, a child is found that is not allowed in the context of the -parent element will be transformed into text as if it were ASCII. When -false, that element and all internal tags will be dropped, though text will -be preserved. There is no option for dropping the element but preserving -child nodes.
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt deleted file mode 100644 index a7a5b249b..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt +++ /dev/null @@ -1,7 +0,0 @@ -Core.EscapeInvalidTags -TYPE: bool -DEFAULT: false ---DESCRIPTION-- -When true, invalid tags will be written back to the document as plain text. -Otherwise, they are silently dropped. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt deleted file mode 100644 index abb499948..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt +++ /dev/null @@ -1,13 +0,0 @@ -Core.EscapeNonASCIICharacters -TYPE: bool -VERSION: 1.4.0 -DEFAULT: false ---DESCRIPTION-- -This directive overcomes a deficiency in %Core.Encoding by blindly -converting all non-ASCII characters into decimal numeric entities before -converting it to its native encoding. This means that even characters that -can be expressed in the non-UTF-8 encoding will be entity-ized, which can -be a real downer for encodings like Big5. It also assumes that the ASCII -repetoire is available, although this is the case for almost all encodings. -Anyway, use UTF-8! ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt deleted file mode 100644 index 915391edb..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt +++ /dev/null @@ -1,19 +0,0 @@ -Core.HiddenElements -TYPE: lookup ---DEFAULT-- -array ( - 'script' => true, - 'style' => true, -) ---DESCRIPTION-- - -
- This directive is a lookup array of elements which should have their
- contents removed when they are not allowed by the HTML definition.
- For example, the contents of a script
tag are not
- normally shown in a document, so if script tags are to be removed,
- their contents should be removed to. This is opposed to a b
- tag, which defines some presentational changes but does not hide its
- contents.
-
- Prior to HTML Purifier 4.9.0, entities were decoded by performing - a global search replace for all entities whose decoded versions - did not have special meanings under HTML, and replaced them with - their decoded versions. We would match all entities, even if they did - not have a trailing semicolon, but only if there weren't any trailing - alphanumeric characters. -
-Original | Text | Attribute |
---|---|---|
¥ | ¥ | ¥ |
¥ | ¥ | ¥ |
¥a | ¥a | ¥a |
¥= | ¥= | ¥= |
- In HTML Purifier 4.9.0, we changed the behavior of entity parsing - to match entities that had missing trailing semicolons in less - cases, to more closely match HTML5 parsing behavior: -
-Original | Text | Attribute |
---|---|---|
¥ | ¥ | ¥ |
¥ | ¥ | ¥ |
¥a | ¥a | ¥a |
¥= | ¥= | ¥= |
- This flag reverts back to pre-HTML Purifier 4.9.0 behavior. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt deleted file mode 100644 index 8983e2cca..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt +++ /dev/null @@ -1,34 +0,0 @@ -Core.LexerImpl -TYPE: mixed/null -VERSION: 2.0.0 -DEFAULT: NULL ---DESCRIPTION-- - -- This parameter determines what lexer implementation can be used. The - valid values are: -
-HTMLPurifier_Lexer
.
- I may remove this option simply because I don't expect anyone
- to use it.
- - If true, HTML Purifier will add line number information to all tokens. - This is useful when error reporting is turned on, but can result in - significant performance degradation and should not be used when - unnecessary. This directive must be used with the DirectLex lexer, - as the DOMLex lexer does not (yet) support this functionality. - If the value is null, an appropriate value will be selected based - on other configuration. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt deleted file mode 100644 index d77f5360d..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt +++ /dev/null @@ -1,11 +0,0 @@ -Core.NormalizeNewlines -TYPE: bool -VERSION: 4.2.0 -DEFAULT: true ---DESCRIPTION-- -
- Whether or not to normalize newlines to the operating
- system default. When false
, HTML Purifier
- will attempt to preserve mixed newline files.
-
- This directive enables pre-emptive URI checking in img
- tags, as the attribute validation strategy is not authorized to
- remove elements from the document. Revert to pre-1.3.0 behavior by setting to false.
-
<? ...
-?>
, remove it out-right. This may be useful if the HTML
-you are validating contains XML processing instruction gunk, however,
-it can also be user-unfriendly for people attempting to post PHP
-snippets.
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt
deleted file mode 100644
index a4cd966df..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Core.RemoveScriptContents
-TYPE: bool/null
-DEFAULT: NULL
-VERSION: 2.0.0
-DEPRECATED-VERSION: 2.1.0
-DEPRECATED-USE: Core.HiddenElements
---DESCRIPTION--
-- This directive enables HTML Purifier to remove not only script tags - but all of their contents. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt deleted file mode 100644 index 3db50ef20..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt +++ /dev/null @@ -1,11 +0,0 @@ -Filter.Custom -TYPE: list -VERSION: 3.1.0 -DEFAULT: array() ---DESCRIPTION-- -
- This directive can be used to add custom filters; it is nearly the
- equivalent of the now deprecated HTMLPurifier->addFilter()
- method. Specify an array of concrete implementations.
-
- Whether or not to escape the dangerous characters <, > and & - as \3C, \3E and \26, respectively. This is can be safely set to false - if the contents of StyleBlocks will be placed in an external stylesheet, - where there is no risk of it being interpreted as HTML. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt deleted file mode 100644 index 7f95f54d1..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt +++ /dev/null @@ -1,29 +0,0 @@ -Filter.ExtractStyleBlocks.Scope -TYPE: string/null -VERSION: 3.0.0 -DEFAULT: NULL -ALIASES: Filter.ExtractStyleBlocksScope, FilterParam.ExtractStyleBlocksScope ---DESCRIPTION-- - -
- If you would like users to be able to define external stylesheets, but
- only allow them to specify CSS declarations for a specific node and
- prevent them from fiddling with other elements, use this directive.
- It accepts any valid CSS selector, and will prepend this to any
- CSS declaration extracted from the document. For example, if this
- directive is set to #user-content
and a user uses the
- selector a:hover
, the final selector will be
- #user-content a:hover
.
-
- The comma shorthand may be used; consider the above example, with
- #user-content, #user-content2
, the final selector will
- be #user-content a:hover, #user-content2 a:hover
.
-
- Warning: It is possible for users to bypass this measure - using a naughty + selector. This is a bug in CSS Tidy 1.3, not HTML - Purifier, and I am working to get it fixed. Until then, HTML Purifier - performs a basic check to prevent this. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt deleted file mode 100644 index 6c231b2d7..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt +++ /dev/null @@ -1,16 +0,0 @@ -Filter.ExtractStyleBlocks.TidyImpl -TYPE: mixed/null -VERSION: 3.1.0 -DEFAULT: NULL -ALIASES: FilterParam.ExtractStyleBlocksTidyImpl ---DESCRIPTION-- -
- If left NULL, HTML Purifier will attempt to instantiate a csstidy
- class to use for internal cleaning. This will usually be good enough.
-
- However, for trusted user input, you can set this to false
to
- disable cleaning. In addition, you can supply your own concrete implementation
- of Tidy's interface to use, although I don't know why you'd want to do that.
-
- This directive turns on the style block extraction filter, which removes
- style
blocks from input HTML, cleans them up with CSSTidy,
- and places them in the StyleBlocks
context variable, for further
- use by you, usually to be placed in an external stylesheet, or a
- style
block in the head
of your document.
-
- Sample usage: -
-'; -?> - - - --Filter.ExtractStyleBlocks -body {color:#F00;} Some text'; - - $config = HTMLPurifier_Config::createDefault(); - $config->set('Filter', 'ExtractStyleBlocks', true); - $purifier = new HTMLPurifier($config); - - $html = $purifier->purify($dirty); - - // This implementation writes the stylesheets to the styles/ directory. - // You can also echo the styles inside the document, but it's a bit - // more difficult to make sure they get interpreted properly by - // browsers; try the usual CSS armoring techniques. - $styles = $purifier->context->get('StyleBlocks'); - $dir = 'styles/'; - if (!is_dir($dir)) mkdir($dir); - $hash = sha1($_GET['html']); - foreach ($styles as $i => $style) { - file_put_contents($name = $dir . $hash . "_$i"); - echo ''; - } -?> - - -- -- - -]]>
- Warning: It is possible for a user to mount an - imagecrash attack using this CSS. Counter-measures are difficult; - it is not simply enough to limit the range of CSS lengths (using - relative lengths with many nesting levels allows for large values - to be attained without actually specifying them in the stylesheet), - and the flexible nature of selectors makes it difficult to selectively - disable lengths on image tags (HTML Purifier, however, does disable - CSS width and height in inline styling). There are probably two effective - counter measures: an explicit width and height set to auto in all - images in your document (unlikely) or the disabling of width and - height (somewhat reasonable). Whether or not these measures should be - used is left to the reader. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt deleted file mode 100644 index 321eaa2d8..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt +++ /dev/null @@ -1,16 +0,0 @@ -Filter.YouTube -TYPE: bool -VERSION: 3.1.0 -DEFAULT: false ---DESCRIPTION-- -- Warning: Deprecated in favor of %HTML.SafeObject and - %Output.FlashCompat (turn both on to allow YouTube videos and other - Flash content). -
-- This directive enables YouTube video embedding in HTML Purifier. Check - this document - on embedding videos for more information on what this filter does. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt deleted file mode 100644 index 0b2c106da..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt +++ /dev/null @@ -1,25 +0,0 @@ -HTML.Allowed -TYPE: itext/null -VERSION: 2.0.0 -DEFAULT: NULL ---DESCRIPTION-- - -
- This is a preferred convenience directive that combines
- %HTML.AllowedElements and %HTML.AllowedAttributes.
- Specify elements and attributes that are allowed using:
- element1[attr1|attr2],element2...
. For example,
- if you would like to only allow paragraphs and links, specify
- a[href],p
. You can specify attributes that apply
- to all elements using an asterisk, e.g. *[lang]
.
- You can also use newlines instead of commas to separate elements.
-
- Warning:
- All of the constraints on the component directives are still enforced.
- The syntax is a subset of TinyMCE's valid_elements
- whitelist: directly copy-pasting it here will probably result in
- broken whitelists. If %HTML.AllowedElements or %HTML.AllowedAttributes
- are set, this directive has no effect.
-
- If HTML Purifier's attribute set is unsatisfactory, overload it! - The syntax is "tag.attr" or "*.attr" for the global attributes - (style, id, class, dir, lang, xml:lang). -
-- Warning: If another directive conflicts with the - elements here, that directive will win and override. For - example, %HTML.EnableAttrID will take precedence over *.id in this - directive. You must set that directive to true before you can use - IDs at all. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt deleted file mode 100644 index 140e21423..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt +++ /dev/null @@ -1,10 +0,0 @@ -HTML.AllowedComments -TYPE: lookup -VERSION: 4.4.0 -DEFAULT: array() ---DESCRIPTION-- -A whitelist which indicates what explicit comment bodies should be -allowed, modulo leading and trailing whitespace. See also %HTML.AllowedCommentsRegexp -(these directives are union'ed together, so a comment is considered -valid if any directive deems it valid.) ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt deleted file mode 100644 index f22e977d4..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt +++ /dev/null @@ -1,15 +0,0 @@ -HTML.AllowedCommentsRegexp -TYPE: string/null -VERSION: 4.4.0 -DEFAULT: NULL ---DESCRIPTION-- -A regexp, which if it matches the body of a comment, indicates that -it should be allowed. Trailing and leading spaces are removed prior -to running this regular expression. -Warning: Make sure you specify -correct anchor metacharacters^regex$
, otherwise you may accept
-comments that you did not mean to! In particular, the regex /foo|bar/
-is probably not sufficiently strict, since it also allows foobar
.
-See also %HTML.AllowedComments (these directives are union'ed together,
-so a comment is considered valid if any directive deems it valid.)
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt
deleted file mode 100644
index 1d3fa7907..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-HTML.AllowedElements
-TYPE: lookup/null
-VERSION: 1.3.0
-DEFAULT: NULL
---DESCRIPTION--
-- If HTML Purifier's tag set is unsatisfactory for your needs, you can - overload it with your own list of tags to allow. If you change - this, you probably also want to change %HTML.AllowedAttributes; see - also %HTML.Allowed which lets you set allowed elements and - attributes at the same time. -
-- If you attempt to allow an element that HTML Purifier does not know - about, HTML Purifier will raise an error. You will need to manually - tell HTML Purifier about this element by using the - advanced customization features. -
-- Warning: If another directive conflicts with the - elements here, that directive will win and override. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt deleted file mode 100644 index 5a59a55c0..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt +++ /dev/null @@ -1,20 +0,0 @@ -HTML.AllowedModules -TYPE: lookup/null -VERSION: 2.0.0 -DEFAULT: NULL ---DESCRIPTION-- - -- A doctype comes with a set of usual modules to use. Without having - to mucking about with the doctypes, you can quickly activate or - disable these modules by specifying which modules you wish to allow - with this directive. This is most useful for unit testing specific - modules, although end users may find it useful for their own ends. -
-- If you specify a module that does not exist, the manager will silently - fail to use it, so be careful! User-defined modules are not affected - by this directive. Modules defined in %HTML.CoreModules are not - affected by this directive. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt deleted file mode 100644 index 151fb7b82..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt +++ /dev/null @@ -1,11 +0,0 @@ -HTML.Attr.Name.UseCDATA -TYPE: bool -DEFAULT: false -VERSION: 4.0.0 ---DESCRIPTION-- -The W3C specification DTD defines the name attribute to be CDATA, not ID, due -to limitations of DTD. In certain documents, this relaxed behavior is desired, -whether it is to specify duplicate names, or to specify names that would be -illegal IDs (for example, names that begin with a digit.) Set this configuration -directive to true to use the relaxed parsing rules. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt deleted file mode 100644 index 45ae469ec..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt +++ /dev/null @@ -1,18 +0,0 @@ -HTML.BlockWrapper -TYPE: string -VERSION: 1.3.0 -DEFAULT: 'p' ---DESCRIPTION-- - -- String name of element to wrap inline elements that are inside a block - context. This only occurs in the children of blockquote in strict mode. -
-
- Example: by default value,
- <blockquote>Foo</blockquote>
would become
- <blockquote><p>Foo</p></blockquote>
.
- The <p>
tags can be replaced with whatever you desire,
- as long as it is a block level element.
-
- Certain modularized doctypes (XHTML, namely), have certain modules - that must be included for the doctype to be an conforming document - type: put those modules here. By default, XHTML's core modules - are used. You can set this to a blank array to disable core module - protection, but this is not recommended. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt deleted file mode 100644 index 6ed70b599..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt +++ /dev/null @@ -1,9 +0,0 @@ -HTML.CustomDoctype -TYPE: string/null -VERSION: 2.0.1 -DEFAULT: NULL ---DESCRIPTION-- - -A custom doctype for power-users who defined their own document -type. This directive only applies when %HTML.Doctype is blank. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt deleted file mode 100644 index 103db754a..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt +++ /dev/null @@ -1,33 +0,0 @@ -HTML.DefinitionID -TYPE: string/null -DEFAULT: NULL -VERSION: 2.0.0 ---DESCRIPTION-- - -- Unique identifier for a custom-built HTML definition. If you edit - the raw version of the HTMLDefinition, introducing changes that the - configuration object does not reflect, you must specify this variable. - If you change your custom edits, you should change this directive, or - clear your cache. Example: -
--$config = HTMLPurifier_Config::createDefault(); -$config->set('HTML', 'DefinitionID', '1'); -$def = $config->getHTMLDefinition(); -$def->addAttribute('a', 'tabindex', 'Number'); --
- In the above example, the configuration is still at the defaults, but - using the advanced API, an extra attribute has been added. The - configuration object normally has no way of knowing that this change - has taken place, so it needs an extra directive: %HTML.DefinitionID. - If someone else attempts to use the default configuration, these two - pieces of code will not clobber each other in the cache, since one has - an extra directive attached to it. -
-- You must specify a value to this directive to use the - advanced API features. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt deleted file mode 100644 index 229ae0267..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt +++ /dev/null @@ -1,16 +0,0 @@ -HTML.DefinitionRev -TYPE: int -VERSION: 2.0.0 -DEFAULT: 1 ---DESCRIPTION-- - -- Revision identifier for your custom definition specified in - %HTML.DefinitionID. This serves the same purpose: uniquely identifying - your custom definition, but this one does so in a chronological - context: revision 3 is more up-to-date then revision 2. Thus, when - this gets incremented, the cache handling is smart enough to clean - up any older revisions of your definition as well as flush the - cache. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt deleted file mode 100644 index 9dab497f2..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt +++ /dev/null @@ -1,11 +0,0 @@ -HTML.Doctype -TYPE: string/null -DEFAULT: NULL ---DESCRIPTION-- -Doctype to use during filtering. Technically speaking this is not actually -a doctype (as it does not identify a corresponding DTD), but we are using -this name for sake of simplicity. When non-blank, this will override any -older directives like %HTML.XHTML or %HTML.Strict. ---ALLOWED-- -'HTML 4.01 Transitional', 'HTML 4.01 Strict', 'XHTML 1.0 Transitional', 'XHTML 1.0 Strict', 'XHTML 1.1' ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt deleted file mode 100644 index 7878dc0bf..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt +++ /dev/null @@ -1,11 +0,0 @@ -HTML.FlashAllowFullScreen -TYPE: bool -VERSION: 4.2.0 -DEFAULT: false ---DESCRIPTION-- -
- Whether or not to permit embedded Flash content from
- %HTML.SafeObject to expand to the full screen. Corresponds to
- the allowFullScreen
parameter.
-
- While this directive is similar to %HTML.AllowedAttributes, for
- forwards-compatibility with XML, this attribute has a different syntax. Instead of
- tag.attr
, use tag@attr
. To disallow href
- attributes in a
tags, set this directive to
- a@href
. You can also disallow an attribute globally with
- attr
or *@attr
(either syntax is fine; the latter
- is provided for consistency with %HTML.AllowedAttributes).
-
- Warning: This directive complements %HTML.ForbiddenElements, - accordingly, check - out that directive for a discussion of why you - should think twice before using this directive. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt deleted file mode 100644 index 93a53e14f..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt +++ /dev/null @@ -1,20 +0,0 @@ -HTML.ForbiddenElements -TYPE: lookup -VERSION: 3.1.0 -DEFAULT: array() ---DESCRIPTION-- -- This was, perhaps, the most requested feature ever in HTML - Purifier. Please don't abuse it! This is the logical inverse of - %HTML.AllowedElements, and it will override that directive, or any - other directive. -
-
- If possible, %HTML.Allowed is recommended over this directive, because it
- can sometimes be difficult to tell whether or not you've forbidden all of
- the behavior you would like to disallow. If you forbid img
- with the expectation of preventing images on your site, you'll be in for
- a nasty surprise when people start using the background-image
- CSS property.
-
- Whether or not to permit form elements in the user input, regardless of - %HTML.Trusted value. Please be very careful when using this functionality, as - enabling forms in untrusted documents may allow for phishing attacks. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt deleted file mode 100644 index e424c386e..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt +++ /dev/null @@ -1,14 +0,0 @@ -HTML.MaxImgLength -TYPE: int/null -DEFAULT: 1200 -VERSION: 3.1.1 ---DESCRIPTION-- -
- This directive controls the maximum number of pixels in the width and
- height attributes in img
tags. This is
- in place to prevent imagecrash attacks, disable with null at your own risk.
- This directive is similar to %CSS.MaxImgLength, and both should be
- concurrently edited, although there are
- subtle differences in the input format (the HTML max is an integer).
-
- String name of element that HTML fragment passed to library will be - inserted in. An interesting variation would be using span as the - parent element, meaning that only inline tags would be allowed. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt deleted file mode 100644 index dfb720496..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt +++ /dev/null @@ -1,12 +0,0 @@ -HTML.Proprietary -TYPE: bool -VERSION: 3.1.0 -DEFAULT: false ---DESCRIPTION-- -
- Whether or not to allow proprietary elements and attributes in your
- documents, as per HTMLPurifier_HTMLModule_Proprietary
.
- Warning: This can cause your documents to stop
- validating!
-
- Whether or not to permit embed tags in documents, with a number of extra - security features added to prevent script execution. This is similar to - what websites like MySpace do to embed tags. Embed is a proprietary - element and will cause your website to stop validating; you should - see if you can use %Output.FlashCompat with %HTML.SafeObject instead - first.
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt deleted file mode 100644 index 5eb6ec2b5..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt +++ /dev/null @@ -1,13 +0,0 @@ -HTML.SafeIframe -TYPE: bool -VERSION: 4.4.0 -DEFAULT: false ---DESCRIPTION-- -- Whether or not to permit iframe tags in untrusted documents. This - directive must be accompanied by a whitelist of permitted iframes, - such as %URI.SafeIframeRegexp, otherwise it will fatally error. - This directive has no effect on strict doctypes, as iframes are not - valid. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt deleted file mode 100644 index ceb342e22..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt +++ /dev/null @@ -1,13 +0,0 @@ -HTML.SafeObject -TYPE: bool -VERSION: 3.1.1 -DEFAULT: false ---DESCRIPTION-- -- Whether or not to permit object tags in documents, with a number of extra - security features added to prevent script execution. This is similar to - what websites like MySpace do to object tags. You should also enable - %Output.FlashCompat in order to generate Internet Explorer - compatibility code for your object tags. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt deleted file mode 100644 index 5ebc7a19d..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt +++ /dev/null @@ -1,10 +0,0 @@ -HTML.SafeScripting -TYPE: lookup -VERSION: 4.5.0 -DEFAULT: array() ---DESCRIPTION-- -- Whether or not to permit script tags to external scripts in documents. - Inline scripting is not allowed, and the script must match an explicit whitelist. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt deleted file mode 100644 index a8b1de56b..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt +++ /dev/null @@ -1,9 +0,0 @@ -HTML.Strict -TYPE: bool -VERSION: 1.3.0 -DEFAULT: false -DEPRECATED-VERSION: 1.7.0 -DEPRECATED-USE: HTML.Doctype ---DESCRIPTION-- -Determines whether or not to use Transitional (loose) or Strict rulesets. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt deleted file mode 100644 index 587a16778..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt +++ /dev/null @@ -1,8 +0,0 @@ -HTML.TargetBlank -TYPE: bool -VERSION: 4.4.0 -DEFAULT: FALSE ---DESCRIPTION-- -If enabled,target=blank
attributes are added to all outgoing links.
-(This includes links from an HTTPS version of a page to an HTTP version.)
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt
deleted file mode 100644
index dd514c0de..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt
+++ /dev/null
@@ -1,10 +0,0 @@
---# vim: et sw=4 sts=4
-HTML.TargetNoopener
-TYPE: bool
-VERSION: 4.8.0
-DEFAULT: TRUE
---DESCRIPTION--
-If enabled, noopener rel attributes are added to links which have
-a target attribute associated with them. This prevents malicious
-destinations from overwriting the original window.
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt
deleted file mode 100644
index cb5a0b0e5..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-HTML.TargetNoreferrer
-TYPE: bool
-VERSION: 4.8.0
-DEFAULT: TRUE
---DESCRIPTION--
-If enabled, noreferrer rel attributes are added to links which have
-a target attribute associated with them. This prevents malicious
-destinations from overwriting the original window.
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt
deleted file mode 100644
index b4c271b7f..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-HTML.TidyAdd
-TYPE: lookup
-VERSION: 2.0.0
-DEFAULT: array()
---DESCRIPTION--
-
-Fixes to add to the default set of Tidy fixes as per your level.
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt
deleted file mode 100644
index 4186ccd0d..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-HTML.TidyLevel
-TYPE: string
-VERSION: 2.0.0
-DEFAULT: 'medium'
---DESCRIPTION--
-
-General level of cleanliness the Tidy module should enforce. -There are four allowed values:
-
- If true, HTML Purifier will protect against Internet Explorer's
- mishandling of the innerHTML
attribute by appending
- a space to any attribute that does not contain angled brackets, spaces
- or quotes, but contains a backtick. This slightly changes the
- semantics of any given attribute, so if this is unacceptable and
- you do not use innerHTML
on any of your pages, you can
- turn this directive off.
-
- If true, HTML Purifier will generate Internet Explorer compatibility - code for all object code. This is highly recommended if you enable - %HTML.SafeObject. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt deleted file mode 100644 index 79f8ad82c..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt +++ /dev/null @@ -1,13 +0,0 @@ -Output.Newline -TYPE: string/null -VERSION: 2.0.1 -DEFAULT: NULL ---DESCRIPTION-- - -- Newline string to format final output with. If left null, HTML Purifier - will auto-detect the default newline type of the system and use that; - you can manually override it here. Remember, \r\n is Windows, \r - is Mac, and \n is Unix. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt deleted file mode 100644 index 232b02362..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt +++ /dev/null @@ -1,14 +0,0 @@ -Output.SortAttr -TYPE: bool -VERSION: 3.2.0 -DEFAULT: false ---DESCRIPTION-- -
- If true, HTML Purifier will sort attributes by name before writing them back
- to the document, converting a tag like: <el b="" a="" c="" />
- to <el a="" b="" c="" />
. This is a workaround for
- a bug in FCKeditor which causes it to swap attributes order, adding noise
- to text diffs. If you're not seeing this bug, chances are, you don't need
- this directive.
-
- Determines whether or not to run Tidy on the final output for pretty - formatting reasons, such as indentation and wrap. -
-- This can greatly improve readability for editors who are hand-editing - the HTML, but is by no means necessary as HTML Purifier has already - fixed all major errors the HTML may have had. Tidy is a non-default - extension, and this directive will silently fail if Tidy is not - available. -
-- If you are looking to make the overall look of your page's source - better, I recommend running Tidy on the entire page rather than just - user-content (after all, the indentation relative to the containing - blocks will be incorrect). -
---ALIASES-- -Core.TidyFormat ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt deleted file mode 100644 index 071bc0295..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt +++ /dev/null @@ -1,7 +0,0 @@ -Test.ForceNoIconv -TYPE: bool -DEFAULT: false ---DESCRIPTION-- -When set to true, HTMLPurifier_Encoder will act as if iconv does not exist -and use only pure PHP implementations. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt deleted file mode 100644 index eb97307e2..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt +++ /dev/null @@ -1,18 +0,0 @@ -URI.AllowedSchemes -TYPE: lookup ---DEFAULT-- -array ( - 'http' => true, - 'https' => true, - 'mailto' => true, - 'ftp' => true, - 'nntp' => true, - 'news' => true, - 'tel' => true, -) ---DESCRIPTION-- -Whitelist that defines the schemes that a URI is allowed to have. This -prevents XSS attacks from using pseudo-schemes like javascript or mocha. -There is also support for thedata
and file
-URI schemes, but they are not enabled by default.
---# vim: et sw=4 sts=4
diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Base.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Base.txt
deleted file mode 100644
index 876f0680c..000000000
--- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Base.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-URI.Base
-TYPE: string/null
-VERSION: 2.1.0
-DEFAULT: NULL
---DESCRIPTION--
-
-- The base URI is the URI of the document this purified HTML will be - inserted into. This information is important if HTML Purifier needs - to calculate absolute URIs from relative URIs, such as when %URI.MakeAbsolute - is on. You may use a non-absolute URI for this value, but behavior - may vary (%URI.MakeAbsolute deals nicely with both absolute and - relative paths, but forwards-compatibility is not guaranteed). - Warning: If set, the scheme on this URI - overrides the one specified by %URI.DefaultScheme. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt deleted file mode 100644 index 834bc08c0..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt +++ /dev/null @@ -1,15 +0,0 @@ -URI.DefaultScheme -TYPE: string/null -DEFAULT: 'http' ---DESCRIPTION-- - -- Defines through what scheme the output will be served, in order to - select the proper object validator when no scheme information is present. -
- -- Starting with HTML Purifier 4.9.0, the default scheme can be null, in - which case we reject all URIs which do not have explicit schemes. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt deleted file mode 100644 index f05312ba8..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt +++ /dev/null @@ -1,11 +0,0 @@ -URI.DefinitionID -TYPE: string/null -VERSION: 2.1.0 -DEFAULT: NULL ---DESCRIPTION-- - -- Unique identifier for a custom-built URI definition. If you want - to add custom URIFilters, you must specify this value. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt deleted file mode 100644 index 80cfea93f..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt +++ /dev/null @@ -1,11 +0,0 @@ -URI.DefinitionRev -TYPE: int -VERSION: 2.1.0 -DEFAULT: 1 ---DESCRIPTION-- - -- Revision identifier for your custom definition. See - %HTML.DefinitionRev for details. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt deleted file mode 100644 index 71ce025a2..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt +++ /dev/null @@ -1,14 +0,0 @@ -URI.Disable -TYPE: bool -VERSION: 1.3.0 -DEFAULT: false ---DESCRIPTION-- - -- Disables all URIs in all forms. Not sure why you'd want to do that - (after all, the Internet's founded on the notion of a hyperlink). -
- ---ALIASES-- -Attr.DisableURI ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt deleted file mode 100644 index 13c122c8c..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt +++ /dev/null @@ -1,11 +0,0 @@ -URI.DisableExternal -TYPE: bool -VERSION: 1.2.0 -DEFAULT: false ---DESCRIPTION-- -Disables links to external websites. This is a highly effective anti-spam -and anti-pagerank-leech measure, but comes at a hefty price: nolinks or -images outside of your domain will be allowed. Non-linkified URIs will -still be preserved. If you want to be able to link to subdomains or use -absolute URIs, specify %URI.Host for your website. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt deleted file mode 100644 index abcc1efd6..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt +++ /dev/null @@ -1,13 +0,0 @@ -URI.DisableExternalResources -TYPE: bool -VERSION: 1.3.0 -DEFAULT: false ---DESCRIPTION-- -Disables the embedding of external resources, preventing users from -embedding things like images from other hosts. This prevents access -tracking (good for email viewers), bandwidth leeching, cross-site request -forging, goatse.cx posting, and other nasties, but also results in a loss -of end-user functionality (they can't directly post a pic they posted from -Flickr anymore). Use it if you don't have a robust user-content moderation -team. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt deleted file mode 100644 index f891de499..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt +++ /dev/null @@ -1,15 +0,0 @@ -URI.DisableResources -TYPE: bool -VERSION: 4.2.0 -DEFAULT: false ---DESCRIPTION-- -- Disables embedding resources, essentially meaning no pictures. You can - still link to them though. See %URI.DisableExternalResources for why - this might be a good idea. -
-- Note: While this directive has been available since 1.3.0, - it didn't actually start doing anything until 4.2.0. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Host.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Host.txt deleted file mode 100644 index ee83b121d..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Host.txt +++ /dev/null @@ -1,19 +0,0 @@ -URI.Host -TYPE: string/null -VERSION: 1.2.0 -DEFAULT: NULL ---DESCRIPTION-- - -- Defines the domain name of the server, so we can determine whether or - an absolute URI is from your website or not. Not strictly necessary, - as users should be using relative URIs to reference resources on your - website. It will, however, let you use absolute URIs to link to - subdomains of the domain you post here: i.e. example.com will allow - sub.example.com. However, higher up domains will still be excluded: - if you set %URI.Host to sub.example.com, example.com will be blocked. - Note: This directive overrides %URI.Base because - a given page may be on a sub-domain, but you wish HTML Purifier to be - more relaxed and allow some of the parent domains too. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt deleted file mode 100644 index 0b6df7625..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt +++ /dev/null @@ -1,9 +0,0 @@ -URI.HostBlacklist -TYPE: list -VERSION: 1.3.0 -DEFAULT: array() ---DESCRIPTION-- -List of strings that are forbidden in the host of any URI. Use it to kill -domain names of spam, etc. Note that it will catch anything in the domain, -so moo.com will catch moo.com.example.com. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt deleted file mode 100644 index 4214900a5..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt +++ /dev/null @@ -1,13 +0,0 @@ -URI.MakeAbsolute -TYPE: bool -VERSION: 2.1.0 -DEFAULT: false ---DESCRIPTION-- - -- Converts all URIs into absolute forms. This is useful when the HTML - being filtered assumes a specific base path, but will actually be - viewed in a different context (and setting an alternate base URI is - not possible). %URI.Base must be set for this directive to work. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt deleted file mode 100644 index 58c81dcc4..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt +++ /dev/null @@ -1,83 +0,0 @@ -URI.Munge -TYPE: string/null -VERSION: 1.3.0 -DEFAULT: NULL ---DESCRIPTION-- - -
- Munges all browsable (usually http, https and ftp)
- absolute URIs into another URI, usually a URI redirection service.
- This directive accepts a URI, formatted with a %s
where
- the url-encoded original URI should be inserted (sample:
- http://www.google.com/url?q=%s
).
-
- Uses for this directive: -
-
- Prior to HTML Purifier 3.1.1, this directive also enabled the munging
- of browsable external resources, which could break things if your redirection
- script was a splash page or used meta
tags. To revert to
- previous behavior, please use %URI.MungeResources.
-
- You may want to also use %URI.MungeSecretKey along with this directive - in order to enforce what URIs your redirector script allows. Open - redirector scripts can be a security risk and negatively affect the - reputation of your domain name. -
-- Starting with HTML Purifier 3.1.1, there is also these substitutions: -
-Key | -Description | -Example <a href=""> |
-
---|---|---|
%r | -1 - The URI embeds a resource (blank) - The URI is merely a link |
- - |
%n | -The name of the tag this URI came from | -a | -
%m | -The name of the attribute this URI came from | -href | -
%p | -The name of the CSS property this URI came from, or blank if irrelevant | -- |
- Admittedly, these letters are somewhat arbitrary; the only stipulation - was that they couldn't be a through f. r is for resource (I would have preferred - e, but you take what you can get), n is for name, m - was picked because it came after n (and I couldn't use a), p is for - property. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt deleted file mode 100644 index 6fce0fdc3..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt +++ /dev/null @@ -1,17 +0,0 @@ -URI.MungeResources -TYPE: bool -VERSION: 3.1.1 -DEFAULT: false ---DESCRIPTION-- -
- If true, any URI munging directives like %URI.Munge
- will also apply to embedded resources, such as <img src="">
.
- Be careful enabling this directive if you have a redirector script
- that does not use the Location
HTTP header; all of your images
- and other embedded resources will break.
-
- Warning: It is strongly advised you use this in conjunction - %URI.MungeSecretKey to mitigate the security risk of an open redirector. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt deleted file mode 100644 index 1e17c1d46..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt +++ /dev/null @@ -1,30 +0,0 @@ -URI.MungeSecretKey -TYPE: string/null -VERSION: 3.1.1 -DEFAULT: NULL ---DESCRIPTION-- -- This directive enables secure checksum generation along with %URI.Munge. - It should be set to a secure key that is not shared with anyone else. - The checksum can be placed in the URI using %t. Use of this checksum - affords an additional level of protection by allowing a redirector - to check if a URI has passed through HTML Purifier with this line: -
- -$checksum === hash_hmac("sha256", $url, $secret_key)- -
- If the output is TRUE, the redirector script should accept the URI. -
- -- Please note that it would still be possible for an attacker to procure - secure hashes en-mass by abusing your website's Preview feature or the - like, but this service affords an additional level of protection - that should be combined with website blacklisting. -
- -- Remember this has no effect if %URI.Munge is not on. -
---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt deleted file mode 100644 index 23331a4e7..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt +++ /dev/null @@ -1,9 +0,0 @@ -URI.OverrideAllowedSchemes -TYPE: bool -DEFAULT: true ---DESCRIPTION-- -If this is set to true (which it is by default), you can override -%URI.AllowedSchemes by simply registering a HTMLPurifier_URIScheme to the -registry. If false, you will also have to update that directive in order -to add more schemes. ---# vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt b/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt deleted file mode 100644 index 79084832b..000000000 --- a/library/vendor/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt +++ /dev/null @@ -1,22 +0,0 @@ -URI.SafeIframeRegexp -TYPE: string/null -VERSION: 4.4.0 -DEFAULT: NULL ---DESCRIPTION-- -- A PCRE regular expression that will be matched against an iframe URI. This is - a relatively inflexible scheme, but works well enough for the most common - use-case of iframes: embedded video. This directive only has an effect if - %HTML.SafeIframe is enabled. Here are some example values: -
-%^http://www.youtube.com/embed/%
- Allow YouTube videos%^http://player.vimeo.com/video/%
- Allow Vimeo videos%^http://(www.youtube.com/embed/|player.vimeo.com/video/)%
- Allow both
- Note that this directive does not give you enough granularity to, say, disable
- all autoplay
videos. Pipe up on the HTML Purifier forums if this
- is a capability you want.
-
' . $this->locale->getMessage('ErrorCollector: No errors') . '
'; - } else { - return ''; - //$string .= ''; - //$string .= ''; - $ret[] = $string; - } - foreach ($current->children as $array) { - $context[] = $current; - $stack = array_merge($stack, array_reverse($array, true)); - for ($i = count($array); $i > 0; $i--) { - $context_stack[] = $context; - } - } - } - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/ErrorStruct.php b/library/vendor/HTMLPurifier/ErrorStruct.php deleted file mode 100644 index cf869d321..000000000 --- a/library/vendor/HTMLPurifier/ErrorStruct.php +++ /dev/null @@ -1,74 +0,0 @@ -children[$type][$id])) { - $this->children[$type][$id] = new HTMLPurifier_ErrorStruct(); - $this->children[$type][$id]->type = $type; - } - return $this->children[$type][$id]; - } - - /** - * @param int $severity - * @param string $message - */ - public function addError($severity, $message) - { - $this->errors[] = array($severity, $message); - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/Exception.php b/library/vendor/HTMLPurifier/Exception.php deleted file mode 100644 index be85b4c56..000000000 --- a/library/vendor/HTMLPurifier/Exception.php +++ /dev/null @@ -1,12 +0,0 @@ -preFilter, - * 2->preFilter, 3->preFilter, purify, 3->postFilter, 2->postFilter, - * 1->postFilter. - * - * @note Methods are not declared abstract as it is perfectly legitimate - * for an implementation not to want anything to happen on a step - */ - -class HTMLPurifier_Filter -{ - - /** - * Name of the filter for identification purposes. - * @type string - */ - public $name; - - /** - * Pre-processor function, handles HTML before HTML Purifier - * @param string $html - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return string - */ - public function preFilter($html, $config, $context) - { - return $html; - } - - /** - * Post-processor function, handles HTML after HTML Purifier - * @param string $html - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return string - */ - public function postFilter($html, $config, $context) - { - return $html; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/Filter/ExtractStyleBlocks.php b/library/vendor/HTMLPurifier/Filter/ExtractStyleBlocks.php deleted file mode 100644 index 66f70b0fc..000000000 --- a/library/vendor/HTMLPurifier/Filter/ExtractStyleBlocks.php +++ /dev/null @@ -1,341 +0,0 @@ - blocks from input HTML, cleans them up - * using CSSTidy, and then places them in $purifier->context->get('StyleBlocks') - * so they can be used elsewhere in the document. - * - * @note - * See tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php for - * sample usage. - * - * @note - * This filter can also be used on stylesheets not included in the - * document--something purists would probably prefer. Just directly - * call HTMLPurifier_Filter_ExtractStyleBlocks->cleanCSS() - */ -class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter -{ - /** - * @type string - */ - public $name = 'ExtractStyleBlocks'; - - /** - * @type array - */ - private $_styleMatches = array(); - - /** - * @type csstidy - */ - private $_tidy; - - /** - * @type HTMLPurifier_AttrDef_HTML_ID - */ - private $_id_attrdef; - - /** - * @type HTMLPurifier_AttrDef_CSS_Ident - */ - private $_class_attrdef; - - /** - * @type HTMLPurifier_AttrDef_Enum - */ - private $_enum_attrdef; - - public function __construct() - { - $this->_tidy = new csstidy(); - $this->_tidy->set_cfg('lowercase_s', false); - $this->_id_attrdef = new HTMLPurifier_AttrDef_HTML_ID(true); - $this->_class_attrdef = new HTMLPurifier_AttrDef_CSS_Ident(); - $this->_enum_attrdef = new HTMLPurifier_AttrDef_Enum( - array( - 'first-child', - 'link', - 'visited', - 'active', - 'hover', - 'focus' - ) - ); - } - - /** - * Save the contents of CSS blocks to style matches - * @param array $matches preg_replace style $matches array - */ - protected function styleCallback($matches) - { - $this->_styleMatches[] = $matches[1]; - } - - /** - * Removes inline - // we must not grab foo in a font-family prop). - if ($config->get('Filter.ExtractStyleBlocks.Escaping')) { - $css = str_replace( - array('<', '>', '&'), - array('\3C ', '\3E ', '\26 '), - $css - ); - } - return $css; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/Filter/YouTube.php b/library/vendor/HTMLPurifier/Filter/YouTube.php deleted file mode 100644 index 276d8362f..000000000 --- a/library/vendor/HTMLPurifier/Filter/YouTube.php +++ /dev/null @@ -1,65 +0,0 @@ -]+>.+?' . - '(?:http:)?//www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s'; - $pre_replace = ' '; - return preg_replace($pre_regex, $pre_replace, $html); - } - - /** - * @param string $html - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - * @return string - */ - public function postFilter($html, $config, $context) - { - $post_regex = '# #'; - return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html); - } - - /** - * @param $url - * @return string - */ - protected function armorUrl($url) - { - return str_replace('--', '--', $url); - } - - /** - * @param array $matches - * @return string - */ - protected function postFilterCallback($matches) - { - $url = $this->armorUrl($matches[1]); - return ''; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/Generator.php b/library/vendor/HTMLPurifier/Generator.php deleted file mode 100644 index eb56e2dfa..000000000 --- a/library/vendor/HTMLPurifier/Generator.php +++ /dev/null @@ -1,286 +0,0 @@ - tags. - * @type bool - */ - private $_scriptFix = false; - - /** - * Cache of HTMLDefinition during HTML output to determine whether or - * not attributes should be minimized. - * @type HTMLPurifier_HTMLDefinition - */ - private $_def; - - /** - * Cache of %Output.SortAttr. - * @type bool - */ - private $_sortAttr; - - /** - * Cache of %Output.FlashCompat. - * @type bool - */ - private $_flashCompat; - - /** - * Cache of %Output.FixInnerHTML. - * @type bool - */ - private $_innerHTMLFix; - - /** - * Stack for keeping track of object information when outputting IE - * compatibility code. - * @type array - */ - private $_flashStack = array(); - - /** - * Configuration for the generator - * @type HTMLPurifier_Config - */ - protected $config; - - /** - * @param HTMLPurifier_Config $config - * @param HTMLPurifier_Context $context - */ - public function __construct($config, $context) - { - $this->config = $config; - $this->_scriptFix = $config->get('Output.CommentScriptContents'); - $this->_innerHTMLFix = $config->get('Output.FixInnerHTML'); - $this->_sortAttr = $config->get('Output.SortAttr'); - $this->_flashCompat = $config->get('Output.FlashCompat'); - $this->_def = $config->getHTMLDefinition(); - $this->_xhtml = $this->_def->doctype->xml; - } - - /** - * Generates HTML from an array of tokens. - * @param HTMLPurifier_Token[] $tokens Array of HTMLPurifier_Token - * @return string Generated HTML - */ - public function generateFromTokens($tokens) - { - if (!$tokens) { - return ''; - } - - // Basic algorithm - $html = ''; - for ($i = 0, $size = count($tokens); $i < $size; $i++) { - if ($this->_scriptFix && $tokens[$i]->name === 'script' - && $i + 2 < $size && $tokens[$i+2] instanceof HTMLPurifier_Token_End) { - // script special case - // the contents of the script block must be ONE token - // for this to work. - $html .= $this->generateFromToken($tokens[$i++]); - $html .= $this->generateScriptFromToken($tokens[$i++]); - } - $html .= $this->generateFromToken($tokens[$i]); - } - - // Tidy cleanup - if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) { - $tidy = new Tidy; - $tidy->parseString( - $html, - array( - 'indent'=> true, - 'output-xhtml' => $this->_xhtml, - 'show-body-only' => true, - 'indent-spaces' => 2, - 'wrap' => 68, - ), - 'utf8' - ); - $tidy->cleanRepair(); - $html = (string) $tidy; // explicit cast necessary - } - - // Normalize newlines to system defined value - if ($this->config->get('Core.NormalizeNewlines')) { - $nl = $this->config->get('Output.Newline'); - if ($nl === null) { - $nl = PHP_EOL; - } - if ($nl !== "\n") { - $html = str_replace("\n", $nl, $html); - } - } - return $html; - } - - /** - * Generates HTML from a single token. - * @param HTMLPurifier_Token $token HTMLPurifier_Token object. - * @return string Generated HTML - */ - public function generateFromToken($token) - { - if (!$token instanceof HTMLPurifier_Token) { - trigger_error('Cannot generate HTML from non-HTMLPurifier_Token object', E_USER_WARNING); - return ''; - - } elseif ($token instanceof HTMLPurifier_Token_Start) { - $attr = $this->generateAttributes($token->attr, $token->name); - if ($this->_flashCompat) { - if ($token->name == "object") { - $flash = new stdClass(); - $flash->attr = $token->attr; - $flash->param = array(); - $this->_flashStack[] = $flash; - } - } - return '<' . $token->name . ($attr ? ' ' : '') . $attr . '>'; - - } elseif ($token instanceof HTMLPurifier_Token_End) { - $_extra = ''; - if ($this->_flashCompat) { - if ($token->name == "object" && !empty($this->_flashStack)) { - // doesn't do anything for now - } - } - return $_extra . '' . $token->name . '>'; - - } elseif ($token instanceof HTMLPurifier_Token_Empty) { - if ($this->_flashCompat && $token->name == "param" && !empty($this->_flashStack)) { - $this->_flashStack[count($this->_flashStack)-1]->param[$token->attr['name']] = $token->attr['value']; - } - $attr = $this->generateAttributes($token->attr, $token->name); - return '<' . $token->name . ($attr ? ' ' : '') . $attr . - ( $this->_xhtml ? ' /': '' ) //
tags? - if ($this->allowsElement('p')) { - if (empty($this->currentNesting) || strpos($text, "\n\n") !== false) { - // Note that we have differing behavior when dealing with text - // in the anonymous root node, or a node inside the document. - // If the text as a double-newline, the treatment is the same; - // if it doesn't, see the next if-block if you're in the document. - - $i = $nesting = null; - if (!$this->forwardUntilEndToken($i, $current, $nesting) && $token->is_whitespace) { - // State 1.1: ... ^ (whitespace, then document end) - // ---- - // This is a degenerate case - } else { - if (!$token->is_whitespace || $this->_isInline($current)) { - // State 1.2: PAR1 - // ---- - - // State 1.3: PAR1\n\nPAR2 - // ------------ - - // State 1.4:
tag? - } elseif (!empty($this->currentNesting) && - $this->currentNesting[count($this->currentNesting) - 1]->name == 'p') { - // State 3.1: ...
PAR1 - // ---- - - // State 3.2: ...
PAR1\n\nPAR2 - // ------------ - $token = array(); - $this->_splitText($text, $token); - // Abort! - } else { - // State 4.1: ...PAR1 - // ---- - - // State 4.2: ...PAR1\n\nPAR2 - // ------------ - } - } - - /** - * @param HTMLPurifier_Token $token - */ - public function handleElement(&$token) - { - // We don't have to check if we're already in a
tag for block - // tokens, because the tag would have been autoclosed by MakeWellFormed. - if ($this->allowsElement('p')) { - if (!empty($this->currentNesting)) { - if ($this->_isInline($token)) { - // State 1:
PAR1
\n\n - // --- - // Quite frankly, this should be handled by splitText - $token = array($this->_pStart(), $token); - } else { - // State 1.1.1:PAR1
- // --- - // State 1.1.2:is needed. - if ($this->_pLookAhead()) { - // State 1.3.1:
tags. - } - } - } - } else { - // State 2.2:
- // --- - } - } - - /** - * Splits up a text in paragraph tokens and appends them - * to the result stream that will replace the original - * @param string $data String text data that will be processed - * into paragraphs - * @param HTMLPurifier_Token[] $result Reference to array of tokens that the - * tags will be appended onto - */ - private function _splitText($data, &$result) - { - $raw_paragraphs = explode("\n\n", $data); - $paragraphs = array(); // without empty paragraphs - $needs_start = false; - $needs_end = false; - - $c = count($raw_paragraphs); - if ($c == 1) { - // There were no double-newlines, abort quickly. In theory this - // should never happen. - $result[] = new HTMLPurifier_Token_Text($data); - return; - } - for ($i = 0; $i < $c; $i++) { - $par = $raw_paragraphs[$i]; - if (trim($par) !== '') { - $paragraphs[] = $par; - } else { - if ($i == 0) { - // Double newline at the front - if (empty($result)) { - // The empty result indicates that the AutoParagraph - // injector did not add any start paragraph tokens. - // This means that we have been in a paragraph for - // a while, and the newline means we should start a new one. - $result[] = new HTMLPurifier_Token_End('p'); - $result[] = new HTMLPurifier_Token_Text("\n\n"); - // However, the start token should only be added if - // there is more processing to be done (i.e. there are - // real paragraphs in here). If there are none, the - // next start paragraph tag will be handled by the - // next call to the injector - $needs_start = true; - } else { - // We just started a new paragraph! - // Reinstate a double-newline for presentation's sake, since - // it was in the source code. - array_unshift($result, new HTMLPurifier_Token_Text("\n\n")); - } - } elseif ($i + 1 == $c) { - // Double newline at the end - // There should be a trailing
when we're finally done. - $needs_end = true; - } - } - } - - // Check if this was just a giant blob of whitespace. Move this earlier, - // perhaps? - if (empty($paragraphs)) { - return; - } - - // Add the start tag indicated by \n\n at the beginning of $data - if ($needs_start) { - $result[] = $this->_pStart(); - } - - // Append the paragraphs onto the result - foreach ($paragraphs as $par) { - $result[] = new HTMLPurifier_Token_Text($par); - $result[] = new HTMLPurifier_Token_End('p'); - $result[] = new HTMLPurifier_Token_Text("\n\n"); - $result[] = $this->_pStart(); - } - - // Remove trailing start token; Injector will handle this later if - // it was indeed needed. This prevents from needing to do a lookahead, - // at the cost of a lookbehind later. - array_pop($result); - - // If there is no need for an end tag, remove all of it and let - // MakeWellFormed close it later. - if (!$needs_end) { - array_pop($result); // removes \n\n - array_pop($result); // removes - } - } - - /** - * Returns true if passed token is inline (and, ergo, allowed in - * paragraph tags) - * @param HTMLPurifier_Token $token - * @return bool - */ - private function _isInline($token) - { - return isset($this->htmlDefinition->info['p']->child->elements[$token->name]); - } - - /** - * Looks ahead in the token list and determines whether or not we need - * to insert atag. - * @return bool - */ - private function _pLookAhead() - { - if ($this->currentToken instanceof HTMLPurifier_Token_Start) { - $nesting = 1; - } else { - $nesting = 0; - } - $ok = false; - $i = null; - while ($this->forwardUntilEndToken($i, $current, $nesting)) { - $result = $this->_checkNeedsP($current); - if ($result !== null) { - $ok = $result; - break; - } - } - return $ok; - } - - /** - * Determines if a particular token requires an earlier inline token - * to get a paragraph. This should be used with _forwardUntilEndToken - * @param HTMLPurifier_Token $current - * @return bool - */ - private function _checkNeedsP($current) - { - if ($current instanceof HTMLPurifier_Token_Start) { - if (!$this->_isInline($current)) { - //
n"; - //echo "$n\nsigfigs = $sigfigs\nnew_log = $new_log\nlog = $log\nrp = $rp\n\n"; - - $n = $this->round($n, $sigfigs); - if (strpos($n, '.') !== false) { - $n = rtrim($n, '0'); - } - $n = rtrim($n, '.'); - - return new HTMLPurifier_Length($n, $unit); - } - - /** - * Returns the number of significant figures in a string number. - * @param string $n Decimal number - * @return int number of sigfigs - */ - public function getSigFigs($n) - { - $n = ltrim($n, '0+-'); - $dp = strpos($n, '.'); // decimal position - if ($dp === false) { - $sigfigs = strlen(rtrim($n, '0')); - } else { - $sigfigs = strlen(ltrim($n, '0.')); // eliminate extra decimal character - if ($dp !== 0) { - $sigfigs--; - } - } - return $sigfigs; - } - - /** - * Adds two numbers, using arbitrary precision when available. - * @param string $s1 - * @param string $s2 - * @param int $scale - * @return string - */ - private function add($s1, $s2, $scale) - { - if ($this->bcmath) { - return bcadd($s1, $s2, $scale); - } else { - return $this->scale((float)$s1 + (float)$s2, $scale); - } - } - - /** - * Multiples two numbers, using arbitrary precision when available. - * @param string $s1 - * @param string $s2 - * @param int $scale - * @return string - */ - private function mul($s1, $s2, $scale) - { - if ($this->bcmath) { - return bcmul($s1, $s2, $scale); - } else { - return $this->scale((float)$s1 * (float)$s2, $scale); - } - } - - /** - * Divides two numbers, using arbitrary precision when available. - * @param string $s1 - * @param string $s2 - * @param int $scale - * @return string - */ - private function div($s1, $s2, $scale) - { - if ($this->bcmath) { - return bcdiv($s1, $s2, $scale); - } else { - return $this->scale((float)$s1 / (float)$s2, $scale); - } - } - - /** - * Rounds a number according to the number of sigfigs it should have, - * using arbitrary precision when available. - * @param float $n - * @param int $sigfigs - * @return string - */ - private function round($n, $sigfigs) - { - $new_log = (int)floor(log(abs($n), 10)); // Number of digits left of decimal - 1 - $rp = $sigfigs - $new_log - 1; // Number of decimal places needed - $neg = $n < 0 ? '-' : ''; // Negative sign - if ($this->bcmath) { - if ($rp >= 0) { - $n = bcadd($n, $neg . '0.' . str_repeat('0', $rp) . '5', $rp + 1); - $n = bcdiv($n, '1', $rp); - } else { - // This algorithm partially depends on the standardized - // form of numbers that comes out of bcmath. - $n = bcadd($n, $neg . '5' . str_repeat('0', $new_log - $sigfigs), 0); - $n = substr($n, 0, $sigfigs + strlen($neg)) . str_repeat('0', $new_log - $sigfigs + 1); - } - return $n; - } else { - return $this->scale(round($n, $sigfigs - $new_log - 1), $rp + 1); - } - } - - /** - * Scales a float to $scale digits right of decimal point, like BCMath. - * @param float $r - * @param int $scale - * @return string - */ - private function scale($r, $scale) - { - if ($scale < 0) { - // The f sprintf type doesn't support negative numbers, so we - // need to cludge things manually. First get the string. - $r = sprintf('%.0f', (float)$r); - // Due to floating point precision loss, $r will more than likely - // look something like 4652999999999.9234. We grab one more digit - // than we need to precise from $r and then use that to round - // appropriately. - $precise = (string)round(substr($r, 0, strlen($r) + $scale), -1); - // Now we return it, truncating the zero that was rounded off. - return substr($precise, 0, -1) . str_repeat('0', -$scale + 1); - } - return sprintf('%.' . $scale . 'f', (float)$r); - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/VERSION b/library/vendor/HTMLPurifier/VERSION deleted file mode 100644 index f029ee574..000000000 --- a/library/vendor/HTMLPurifier/VERSION +++ /dev/null @@ -1 +0,0 @@ -4.15.0 \ No newline at end of file diff --git a/library/vendor/HTMLPurifier/VarParser.php b/library/vendor/HTMLPurifier/VarParser.php deleted file mode 100644 index 0c97c8289..000000000 --- a/library/vendor/HTMLPurifier/VarParser.php +++ /dev/null @@ -1,198 +0,0 @@ - self::C_STRING, - 'istring' => self::ISTRING, - 'text' => self::TEXT, - 'itext' => self::ITEXT, - 'int' => self::C_INT, - 'float' => self::C_FLOAT, - 'bool' => self::C_BOOL, - 'lookup' => self::LOOKUP, - 'list' => self::ALIST, - 'hash' => self::HASH, - 'mixed' => self::C_MIXED - ); - - /** - * Lookup table of types that are string, and can have aliases or - * allowed value lists. - */ - public static $stringTypes = array( - self::C_STRING => true, - self::ISTRING => true, - self::TEXT => true, - self::ITEXT => true, - ); - - /** - * Validate a variable according to type. - * It may return NULL as a valid type if $allow_null is true. - * - * @param mixed $var Variable to validate - * @param int $type Type of variable, see HTMLPurifier_VarParser->types - * @param bool $allow_null Whether or not to permit null as a value - * @return string Validated and type-coerced variable - * @throws HTMLPurifier_VarParserException - */ - final public function parse($var, $type, $allow_null = false) - { - if (is_string($type)) { - if (!isset(HTMLPurifier_VarParser::$types[$type])) { - throw new HTMLPurifier_VarParserException("Invalid type '$type'"); - } else { - $type = HTMLPurifier_VarParser::$types[$type]; - } - } - $var = $this->parseImplementation($var, $type, $allow_null); - if ($allow_null && $var === null) { - return null; - } - // These are basic checks, to make sure nothing horribly wrong - // happened in our implementations. - switch ($type) { - case (self::C_STRING): - case (self::ISTRING): - case (self::TEXT): - case (self::ITEXT): - if (!is_string($var)) { - break; - } - if ($type == self::ISTRING || $type == self::ITEXT) { - $var = strtolower($var); - } - return $var; - case (self::C_INT): - if (!is_int($var)) { - break; - } - return $var; - case (self::C_FLOAT): - if (!is_float($var)) { - break; - } - return $var; - case (self::C_BOOL): - if (!is_bool($var)) { - break; - } - return $var; - case (self::LOOKUP): - case (self::ALIST): - case (self::HASH): - if (!is_array($var)) { - break; - } - if ($type === self::LOOKUP) { - foreach ($var as $k) { - if ($k !== true) { - $this->error('Lookup table contains value other than true'); - } - } - } elseif ($type === self::ALIST) { - $keys = array_keys($var); - if (array_keys($keys) !== $keys) { - $this->error('Indices for list are not uniform'); - } - } - return $var; - case (self::C_MIXED): - return $var; - default: - $this->errorInconsistent(get_class($this), $type); - } - $this->errorGeneric($var, $type); - } - - /** - * Actually implements the parsing. Base implementation does not - * do anything to $var. Subclasses should overload this! - * @param mixed $var - * @param int $type - * @param bool $allow_null - * @return string - */ - protected function parseImplementation($var, $type, $allow_null) - { - return $var; - } - - /** - * Throws an exception. - * @throws HTMLPurifier_VarParserException - */ - protected function error($msg) - { - throw new HTMLPurifier_VarParserException($msg); - } - - /** - * Throws an inconsistency exception. - * @note This should not ever be called. It would be called if we - * extend the allowed values of HTMLPurifier_VarParser without - * updating subclasses. - * @param string $class - * @param int $type - * @throws HTMLPurifier_Exception - */ - protected function errorInconsistent($class, $type) - { - throw new HTMLPurifier_Exception( - "Inconsistency in $class: " . HTMLPurifier_VarParser::getTypeName($type) . - " not implemented" - ); - } - - /** - * Generic error for if a type didn't work. - * @param mixed $var - * @param int $type - */ - protected function errorGeneric($var, $type) - { - $vtype = gettype($var); - $this->error("Expected type " . HTMLPurifier_VarParser::getTypeName($type) . ", got $vtype"); - } - - /** - * @param int $type - * @return string - */ - public static function getTypeName($type) - { - static $lookup; - if (!$lookup) { - // Lazy load the alternative lookup table - $lookup = array_flip(HTMLPurifier_VarParser::$types); - } - if (!isset($lookup[$type])) { - return 'unknown'; - } - return $lookup[$type]; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/VarParser/Flexible.php b/library/vendor/HTMLPurifier/VarParser/Flexible.php deleted file mode 100644 index 3bfbe8386..000000000 --- a/library/vendor/HTMLPurifier/VarParser/Flexible.php +++ /dev/null @@ -1,130 +0,0 @@ - $j) { - $var[$i] = trim($j); - } - if ($type === self::HASH) { - // key:value,key2:value2 - $nvar = array(); - foreach ($var as $keypair) { - $c = explode(':', $keypair, 2); - if (!isset($c[1])) { - continue; - } - $nvar[trim($c[0])] = trim($c[1]); - } - $var = $nvar; - } - } - if (!is_array($var)) { - break; - } - $keys = array_keys($var); - if ($keys === array_keys($keys)) { - if ($type == self::ALIST) { - return $var; - } elseif ($type == self::LOOKUP) { - $new = array(); - foreach ($var as $key) { - $new[$key] = true; - } - return $new; - } else { - break; - } - } - if ($type === self::ALIST) { - trigger_error("Array list did not have consecutive integer indexes", E_USER_WARNING); - return array_values($var); - } - if ($type === self::LOOKUP) { - foreach ($var as $key => $value) { - if ($value !== true) { - trigger_error( - "Lookup array has non-true value at key '$key'; " . - "maybe your input array was not indexed numerically", - E_USER_WARNING - ); - } - $var[$key] = true; - } - } - return $var; - default: - $this->errorInconsistent(__CLASS__, $type); - } - $this->errorGeneric($var, $type); - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/VarParser/Native.php b/library/vendor/HTMLPurifier/VarParser/Native.php deleted file mode 100644 index f11c318ef..000000000 --- a/library/vendor/HTMLPurifier/VarParser/Native.php +++ /dev/null @@ -1,38 +0,0 @@ -evalExpression($var); - } - - /** - * @param string $expr - * @return mixed - * @throws HTMLPurifier_VarParserException - */ - protected function evalExpression($expr) - { - $var = null; - $result = eval("\$var = $expr;"); - if ($result === false) { - throw new HTMLPurifier_VarParserException("Fatal error in evaluated code"); - } - return $var; - } -} - -// vim: et sw=4 sts=4 diff --git a/library/vendor/HTMLPurifier/VarParserException.php b/library/vendor/HTMLPurifier/VarParserException.php deleted file mode 100644 index 5df341495..000000000 --- a/library/vendor/HTMLPurifier/VarParserException.php +++ /dev/null @@ -1,11 +0,0 @@ -front = $front; - $this->back = $back; - } - - /** - * Creates a zipper from an array, with a hole in the - * 0-index position. - * @param Array to zipper-ify. - * @return Tuple of zipper and element of first position. - */ - static public function fromArray($array) { - $z = new self(array(), array_reverse($array)); - $t = $z->delete(); // delete the "dummy hole" - return array($z, $t); - } - - /** - * Convert zipper back into a normal array, optionally filling in - * the hole with a value. (Usually you should supply a $t, unless you - * are at the end of the array.) - */ - public function toArray($t = NULL) { - $a = $this->front; - if ($t !== NULL) $a[] = $t; - for ($i = count($this->back)-1; $i >= 0; $i--) { - $a[] = $this->back[$i]; - } - return $a; - } - - /** - * Move hole to the next element. - * @param $t Element to fill hole with - * @return Original contents of new hole. - */ - public function next($t) { - if ($t !== NULL) array_push($this->front, $t); - return empty($this->back) ? NULL : array_pop($this->back); - } - - /** - * Iterated hole advancement. - * @param $t Element to fill hole with - * @param $i How many forward to advance hole - * @return Original contents of new hole, i away - */ - public function advance($t, $n) { - for ($i = 0; $i < $n; $i++) { - $t = $this->next($t); - } - return $t; - } - - /** - * Move hole to the previous element - * @param $t Element to fill hole with - * @return Original contents of new hole. - */ - public function prev($t) { - if ($t !== NULL) array_push($this->back, $t); - return empty($this->front) ? NULL : array_pop($this->front); - } - - /** - * Delete contents of current hole, shifting hole to - * next element. - * @return Original contents of new hole. - */ - public function delete() { - return empty($this->back) ? NULL : array_pop($this->back); - } - - /** - * Returns true if we are at the end of the list. - * @return bool - */ - public function done() { - return empty($this->back); - } - - /** - * Insert element before hole. - * @param Element to insert - */ - public function insertBefore($t) { - if ($t !== NULL) array_push($this->front, $t); - } - - /** - * Insert element after hole. - * @param Element to insert - */ - public function insertAfter($t) { - if ($t !== NULL) array_push($this->back, $t); - } - - /** - * Splice in multiple elements at hole. Functional specification - * in terms of array_splice: - * - * $arr1 = $arr; - * $old1 = array_splice($arr1, $i, $delete, $replacement); - * - * list($z, $t) = HTMLPurifier_Zipper::fromArray($arr); - * $t = $z->advance($t, $i); - * list($old2, $t) = $z->splice($t, $delete, $replacement); - * $arr2 = $z->toArray($t); - * - * assert($old1 === $old2); - * assert($arr1 === $arr2); - * - * NB: the absolute index location after this operation is - * *unchanged!* - * - * @param Current contents of hole. - */ - public function splice($t, $delete, $replacement) { - // delete - $old = array(); - $r = $t; - for ($i = $delete; $i > 0; $i--) { - $old[] = $r; - $r = $this->delete(); - } - // insert - for ($i = count($replacement)-1; $i >= 0; $i--) { - $this->insertAfter($r); - $r = $replacement[$i]; - } - return array($old, $r); - } -} diff --git a/library/vendor/JShrink/LICENSE b/library/vendor/JShrink/LICENSE deleted file mode 100644 index c6597d85c..000000000 --- a/library/vendor/JShrink/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2009, Robert Hafner -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/library/vendor/JShrink/Minifier.php b/library/vendor/JShrink/Minifier.php deleted file mode 100644 index fad43d212..000000000 --- a/library/vendor/JShrink/Minifier.php +++ /dev/null @@ -1,613 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * JShrink - * - * - * @package JShrink - * @author Robert Hafner
"asd" + ++x;
*/
- $lock = '"LOCK---' . crc32(time()) . '"';
-
- $matches = [];
- preg_match('/([+-])(\s+)([+-])/S', $js, $matches);
- if (empty($matches)) {
- return $js;
- }
-
- $this->locks[$lock] = $matches[2];
-
- $js = preg_replace('/([+-])\s+([+-])/S', "$1{$lock}$2", $js);
- /* -- */
-
- return $js;
- }
-
- /**
- * Replace "locks" with the original characters
- *
- * @param string $js The string to unlock
- * @return bool
- */
- protected function unlock($js)
- {
- if (empty($this->locks)) {
- return $js;
- }
-
- foreach ($this->locks as $lock => $replacement) {
- $js = str_replace($lock, $replacement, $js);
- }
-
- return $js;
- }
-}
diff --git a/library/vendor/JShrink/SOURCE b/library/vendor/JShrink/SOURCE
deleted file mode 100644
index 00ccc58ce..000000000
--- a/library/vendor/JShrink/SOURCE
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-set -eux
-VERSION=1.4.0
-curl -LsS https://github.com/tedious/JShrink/archive/v"$VERSION".tar.gz -o /tmp/JShrink.tar.gz
-tar xzf /tmp/JShrink.tar.gz --strip-components 1 JShrink-"$VERSION"/LICENSE
-tar xzf /tmp/JShrink.tar.gz --strip-components 3 JShrink-"$VERSION"/src/JShrink/Minifier.php
-rm /tmp/JShrink.tar.gz
diff --git a/library/vendor/Parsedown/LICENSE b/library/vendor/Parsedown/LICENSE
deleted file mode 100644
index 8e7c764d1..000000000
--- a/library/vendor/Parsedown/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2013-2018 Emanuil Rusev, erusev.com
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/library/vendor/Parsedown/Parsedown.php b/library/vendor/Parsedown/Parsedown.php
deleted file mode 100644
index a34b44f0f..000000000
--- a/library/vendor/Parsedown/Parsedown.php
+++ /dev/null
@@ -1,1693 +0,0 @@
-DefinitionData = array();
-
- # standardize line breaks
- $text = str_replace(array("\r\n", "\r"), "\n", $text);
-
- # remove surrounding line breaks
- $text = trim($text, "\n");
-
- # split text into lines
- $lines = explode("\n", $text);
-
- # iterate through lines to identify blocks
- $markup = $this->lines($lines);
-
- # trim line breaks
- $markup = trim($markup, "\n");
-
- return $markup;
- }
-
- #
- # Setters
- #
-
- function setBreaksEnabled($breaksEnabled)
- {
- $this->breaksEnabled = $breaksEnabled;
-
- return $this;
- }
-
- protected $breaksEnabled;
-
- function setMarkupEscaped($markupEscaped)
- {
- $this->markupEscaped = $markupEscaped;
-
- return $this;
- }
-
- protected $markupEscaped;
-
- function setUrlsLinked($urlsLinked)
- {
- $this->urlsLinked = $urlsLinked;
-
- return $this;
- }
-
- protected $urlsLinked = true;
-
- function setSafeMode($safeMode)
- {
- $this->safeMode = (bool) $safeMode;
-
- return $this;
- }
-
- protected $safeMode;
-
- protected $safeLinksWhitelist = array(
- 'http://',
- 'https://',
- 'ftp://',
- 'ftps://',
- 'mailto:',
- 'data:image/png;base64,',
- 'data:image/gif;base64,',
- 'data:image/jpeg;base64,',
- 'irc:',
- 'ircs:',
- 'git:',
- 'ssh:',
- 'news:',
- 'steam:',
- );
-
- #
- # Lines
- #
-
- protected $BlockTypes = array(
- '#' => array('Header'),
- '*' => array('Rule', 'List'),
- '+' => array('List'),
- '-' => array('SetextHeader', 'Table', 'Rule', 'List'),
- '0' => array('List'),
- '1' => array('List'),
- '2' => array('List'),
- '3' => array('List'),
- '4' => array('List'),
- '5' => array('List'),
- '6' => array('List'),
- '7' => array('List'),
- '8' => array('List'),
- '9' => array('List'),
- ':' => array('Table'),
- '<' => array('Comment', 'Markup'),
- '=' => array('SetextHeader'),
- '>' => array('Quote'),
- '[' => array('Reference'),
- '_' => array('Rule'),
- '`' => array('FencedCode'),
- '|' => array('Table'),
- '~' => array('FencedCode'),
- );
-
- # ~
-
- protected $unmarkedBlockTypes = array(
- 'Code',
- );
-
- #
- # Blocks
- #
-
- protected function lines(array $lines)
- {
- $CurrentBlock = null;
-
- foreach ($lines as $line)
- {
- if (chop($line) === '')
- {
- if (isset($CurrentBlock))
- {
- $CurrentBlock['interrupted'] = true;
- }
-
- continue;
- }
-
- if (strpos($line, "\t") !== false)
- {
- $parts = explode("\t", $line);
-
- $line = $parts[0];
-
- unset($parts[0]);
-
- foreach ($parts as $part)
- {
- $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
-
- $line .= str_repeat(' ', $shortage);
- $line .= $part;
- }
- }
-
- $indent = 0;
-
- while (isset($line[$indent]) and $line[$indent] === ' ')
- {
- $indent ++;
- }
-
- $text = $indent > 0 ? substr($line, $indent) : $line;
-
- # ~
-
- $Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
-
- # ~
-
- if (isset($CurrentBlock['continuable']))
- {
- $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
-
- if (isset($Block))
- {
- $CurrentBlock = $Block;
-
- continue;
- }
- else
- {
- if ($this->isBlockCompletable($CurrentBlock['type']))
- {
- $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
- }
- }
- }
-
- # ~
-
- $marker = $text[0];
-
- # ~
-
- $blockTypes = $this->unmarkedBlockTypes;
-
- if (isset($this->BlockTypes[$marker]))
- {
- foreach ($this->BlockTypes[$marker] as $blockType)
- {
- $blockTypes []= $blockType;
- }
- }
-
- #
- # ~
-
- foreach ($blockTypes as $blockType)
- {
- $Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
-
- if (isset($Block))
- {
- $Block['type'] = $blockType;
-
- if ( ! isset($Block['identified']))
- {
- $Blocks []= $CurrentBlock;
-
- $Block['identified'] = true;
- }
-
- if ($this->isBlockContinuable($blockType))
- {
- $Block['continuable'] = true;
- }
-
- $CurrentBlock = $Block;
-
- continue 2;
- }
- }
-
- # ~
-
- if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
- {
- $CurrentBlock['element']['text'] .= "\n".$text;
- }
- else
- {
- $Blocks []= $CurrentBlock;
-
- $CurrentBlock = $this->paragraph($Line);
-
- $CurrentBlock['identified'] = true;
- }
- }
-
- # ~
-
- if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
- {
- $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
- }
-
- # ~
-
- $Blocks []= $CurrentBlock;
-
- unset($Blocks[0]);
-
- # ~
-
- $markup = '';
-
- foreach ($Blocks as $Block)
- {
- if (isset($Block['hidden']))
- {
- continue;
- }
-
- $markup .= "\n";
- $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
- }
-
- $markup .= "\n";
-
- # ~
-
- return $markup;
- }
-
- protected function isBlockContinuable($Type)
- {
- return method_exists($this, 'block'.$Type.'Continue');
- }
-
- protected function isBlockCompletable($Type)
- {
- return method_exists($this, 'block'.$Type.'Complete');
- }
-
- #
- # Code
-
- protected function blockCode($Line, $Block = null)
- {
- if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
- {
- return;
- }
-
- if ($Line['indent'] >= 4)
- {
- $text = substr($Line['body'], 4);
-
- $Block = array(
- 'element' => array(
- 'name' => 'pre',
- 'handler' => 'element',
- 'text' => array(
- 'name' => 'code',
- 'text' => $text,
- ),
- ),
- );
-
- return $Block;
- }
- }
-
- protected function blockCodeContinue($Line, $Block)
- {
- if ($Line['indent'] >= 4)
- {
- if (isset($Block['interrupted']))
- {
- $Block['element']['text']['text'] .= "\n";
-
- unset($Block['interrupted']);
- }
-
- $Block['element']['text']['text'] .= "\n";
-
- $text = substr($Line['body'], 4);
-
- $Block['element']['text']['text'] .= $text;
-
- return $Block;
- }
- }
-
- protected function blockCodeComplete($Block)
- {
- $text = $Block['element']['text']['text'];
-
- $Block['element']['text']['text'] = $text;
-
- return $Block;
- }
-
- #
- # Comment
-
- protected function blockComment($Line)
- {
- if ($this->markupEscaped or $this->safeMode)
- {
- return;
- }
-
- if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
- {
- $Block = array(
- 'markup' => $Line['body'],
- );
-
- if (preg_match('/-->$/', $Line['text']))
- {
- $Block['closed'] = true;
- }
-
- return $Block;
- }
- }
-
- protected function blockCommentContinue($Line, array $Block)
- {
- if (isset($Block['closed']))
- {
- return;
- }
-
- $Block['markup'] .= "\n" . $Line['body'];
-
- if (preg_match('/-->$/', $Line['text']))
- {
- $Block['closed'] = true;
- }
-
- return $Block;
- }
-
- #
- # Fenced Code
-
- protected function blockFencedCode($Line)
- {
- if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([^`]+)?[ ]*$/', $Line['text'], $matches))
- {
- $Element = array(
- 'name' => 'code',
- 'text' => '',
- );
-
- if (isset($matches[1]))
- {
- /**
- * https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes
- * Every HTML element may have a class attribute specified.
- * The attribute, if specified, must have a value that is a set
- * of space-separated tokens representing the various classes
- * that the element belongs to.
- * [...]
- * The space characters, for the purposes of this specification,
- * are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab),
- * U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
- * U+000D CARRIAGE RETURN (CR).
- */
- $language = substr($matches[1], 0, strcspn($matches[1], " \t\n\f\r"));
-
- $class = 'language-'.$language;
-
- $Element['attributes'] = array(
- 'class' => $class,
- );
- }
-
- $Block = array(
- 'char' => $Line['text'][0],
- 'element' => array(
- 'name' => 'pre',
- 'handler' => 'element',
- 'text' => $Element,
- ),
- );
-
- return $Block;
- }
- }
-
- protected function blockFencedCodeContinue($Line, $Block)
- {
- if (isset($Block['complete']))
- {
- return;
- }
-
- if (isset($Block['interrupted']))
- {
- $Block['element']['text']['text'] .= "\n";
-
- unset($Block['interrupted']);
- }
-
- if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
- {
- $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
-
- $Block['complete'] = true;
-
- return $Block;
- }
-
- $Block['element']['text']['text'] .= "\n".$Line['body'];
-
- return $Block;
- }
-
- protected function blockFencedCodeComplete($Block)
- {
- $text = $Block['element']['text']['text'];
-
- $Block['element']['text']['text'] = $text;
-
- return $Block;
- }
-
- #
- # Header
-
- protected function blockHeader($Line)
- {
- if (isset($Line['text'][1]))
- {
- $level = 1;
-
- while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
- {
- $level ++;
- }
-
- if ($level > 6)
- {
- return;
- }
-
- $text = trim($Line['text'], '# ');
-
- $Block = array(
- 'element' => array(
- 'name' => 'h' . min(6, $level),
- 'text' => $text,
- 'handler' => 'line',
- ),
- );
-
- return $Block;
- }
- }
-
- #
- # List
-
- protected function blockList($Line)
- {
- list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
-
- if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
- {
- $Block = array(
- 'indent' => $Line['indent'],
- 'pattern' => $pattern,
- 'element' => array(
- 'name' => $name,
- 'handler' => 'elements',
- ),
- );
-
- if($name === 'ol')
- {
- $listStart = stristr($matches[0], '.', true);
-
- if($listStart !== '1')
- {
- $Block['element']['attributes'] = array('start' => $listStart);
- }
- }
-
- $Block['li'] = array(
- 'name' => 'li',
- 'handler' => 'li',
- 'text' => array(
- $matches[2],
- ),
- );
-
- $Block['element']['text'] []= & $Block['li'];
-
- return $Block;
- }
- }
-
- protected function blockListContinue($Line, array $Block)
- {
- if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
- {
- if (isset($Block['interrupted']))
- {
- $Block['li']['text'] []= '';
-
- $Block['loose'] = true;
-
- unset($Block['interrupted']);
- }
-
- unset($Block['li']);
-
- $text = isset($matches[1]) ? $matches[1] : '';
-
- $Block['li'] = array(
- 'name' => 'li',
- 'handler' => 'li',
- 'text' => array(
- $text,
- ),
- );
-
- $Block['element']['text'] []= & $Block['li'];
-
- return $Block;
- }
-
- if ($Line['text'][0] === '[' and $this->blockReference($Line))
- {
- return $Block;
- }
-
- if ( ! isset($Block['interrupted']))
- {
- $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
-
- $Block['li']['text'] []= $text;
-
- return $Block;
- }
-
- if ($Line['indent'] > 0)
- {
- $Block['li']['text'] []= '';
-
- $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
-
- $Block['li']['text'] []= $text;
-
- unset($Block['interrupted']);
-
- return $Block;
- }
- }
-
- protected function blockListComplete(array $Block)
- {
- if (isset($Block['loose']))
- {
- foreach ($Block['element']['text'] as &$li)
- {
- if (end($li['text']) !== '')
- {
- $li['text'] []= '';
- }
- }
- }
-
- return $Block;
- }
-
- #
- # Quote
-
- protected function blockQuote($Line)
- {
- if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
- {
- $Block = array(
- 'element' => array(
- 'name' => 'blockquote',
- 'handler' => 'lines',
- 'text' => (array) $matches[1],
- ),
- );
-
- return $Block;
- }
- }
-
- protected function blockQuoteContinue($Line, array $Block)
- {
- if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
- {
- if (isset($Block['interrupted']))
- {
- $Block['element']['text'] []= '';
-
- unset($Block['interrupted']);
- }
-
- $Block['element']['text'] []= $matches[1];
-
- return $Block;
- }
-
- if ( ! isset($Block['interrupted']))
- {
- $Block['element']['text'] []= $Line['text'];
-
- return $Block;
- }
- }
-
- #
- # Rule
-
- protected function blockRule($Line)
- {
- if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
- {
- $Block = array(
- 'element' => array(
- 'name' => 'hr'
- ),
- );
-
- return $Block;
- }
- }
-
- #
- # Setext
-
- protected function blockSetextHeader($Line, array $Block = null)
- {
- if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
- {
- return;
- }
-
- if (chop($Line['text'], $Line['text'][0]) === '')
- {
- $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
-
- return $Block;
- }
- }
-
- #
- # Markup
-
- protected function blockMarkup($Line)
- {
- if ($this->markupEscaped or $this->safeMode)
- {
- return;
- }
-
- if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
- {
- $element = strtolower($matches[1]);
-
- if (in_array($element, $this->textLevelElements))
- {
- return;
- }
-
- $Block = array(
- 'name' => $matches[1],
- 'depth' => 0,
- 'markup' => $Line['text'],
- );
-
- $length = strlen($matches[0]);
-
- $remainder = substr($Line['text'], $length);
-
- if (trim($remainder) === '')
- {
- if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
- {
- $Block['closed'] = true;
-
- $Block['void'] = true;
- }
- }
- else
- {
- if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
- {
- return;
- }
-
- if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
- {
- $Block['closed'] = true;
- }
- }
-
- return $Block;
- }
- }
-
- protected function blockMarkupContinue($Line, array $Block)
- {
- if (isset($Block['closed']))
- {
- return;
- }
-
- if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
- {
- $Block['depth'] ++;
- }
-
- if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
- {
- if ($Block['depth'] > 0)
- {
- $Block['depth'] --;
- }
- else
- {
- $Block['closed'] = true;
- }
- }
-
- if (isset($Block['interrupted']))
- {
- $Block['markup'] .= "\n";
-
- unset($Block['interrupted']);
- }
-
- $Block['markup'] .= "\n".$Line['body'];
-
- return $Block;
- }
-
- #
- # Reference
-
- protected function blockReference($Line)
- {
- if (preg_match('/^\[(.+?)\]:[ ]*(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
- {
- $id = strtolower($matches[1]);
-
- $Data = array(
- 'url' => $matches[2],
- 'title' => null,
- );
-
- if (isset($matches[3]))
- {
- $Data['title'] = $matches[3];
- }
-
- $this->DefinitionData['Reference'][$id] = $Data;
-
- $Block = array(
- 'hidden' => true,
- );
-
- return $Block;
- }
- }
-
- #
- # Table
-
- protected function blockTable($Line, array $Block = null)
- {
- if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
- {
- return;
- }
-
- if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '')
- {
- $alignments = array();
-
- $divider = $Line['text'];
-
- $divider = trim($divider);
- $divider = trim($divider, '|');
-
- $dividerCells = explode('|', $divider);
-
- foreach ($dividerCells as $dividerCell)
- {
- $dividerCell = trim($dividerCell);
-
- if ($dividerCell === '')
- {
- continue;
- }
-
- $alignment = null;
-
- if ($dividerCell[0] === ':')
- {
- $alignment = 'left';
- }
-
- if (substr($dividerCell, - 1) === ':')
- {
- $alignment = $alignment === 'left' ? 'center' : 'right';
- }
-
- $alignments []= $alignment;
- }
-
- # ~
-
- $HeaderElements = array();
-
- $header = $Block['element']['text'];
-
- $header = trim($header);
- $header = trim($header, '|');
-
- $headerCells = explode('|', $header);
-
- foreach ($headerCells as $index => $headerCell)
- {
- $headerCell = trim($headerCell);
-
- $HeaderElement = array(
- 'name' => 'th',
- 'text' => $headerCell,
- 'handler' => 'line',
- );
-
- if (isset($alignments[$index]))
- {
- $alignment = $alignments[$index];
-
- $HeaderElement['attributes'] = array(
- 'style' => 'text-align: '.$alignment.';',
- );
- }
-
- $HeaderElements []= $HeaderElement;
- }
-
- # ~
-
- $Block = array(
- 'alignments' => $alignments,
- 'identified' => true,
- 'element' => array(
- 'name' => 'table',
- 'handler' => 'elements',
- ),
- );
-
- $Block['element']['text'] []= array(
- 'name' => 'thead',
- 'handler' => 'elements',
- );
-
- $Block['element']['text'] []= array(
- 'name' => 'tbody',
- 'handler' => 'elements',
- 'text' => array(),
- );
-
- $Block['element']['text'][0]['text'] []= array(
- 'name' => 'tr',
- 'handler' => 'elements',
- 'text' => $HeaderElements,
- );
-
- return $Block;
- }
- }
-
- protected function blockTableContinue($Line, array $Block)
- {
- if (isset($Block['interrupted']))
- {
- return;
- }
-
- if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
- {
- $Elements = array();
-
- $row = $Line['text'];
-
- $row = trim($row);
- $row = trim($row, '|');
-
- preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
-
- foreach ($matches[0] as $index => $cell)
- {
- $cell = trim($cell);
-
- $Element = array(
- 'name' => 'td',
- 'handler' => 'line',
- 'text' => $cell,
- );
-
- if (isset($Block['alignments'][$index]))
- {
- $Element['attributes'] = array(
- 'style' => 'text-align: '.$Block['alignments'][$index].';',
- );
- }
-
- $Elements []= $Element;
- }
-
- $Element = array(
- 'name' => 'tr',
- 'handler' => 'elements',
- 'text' => $Elements,
- );
-
- $Block['element']['text'][1]['text'] []= $Element;
-
- return $Block;
- }
- }
-
- #
- # ~
- #
-
- protected function paragraph($Line)
- {
- $Block = array(
- 'element' => array(
- 'name' => 'p',
- 'text' => $Line['text'],
- 'handler' => 'line',
- ),
- );
-
- return $Block;
- }
-
- #
- # Inline Elements
- #
-
- protected $InlineTypes = array(
- '"' => array('SpecialCharacter'),
- '!' => array('Image'),
- '&' => array('SpecialCharacter'),
- '*' => array('Emphasis'),
- ':' => array('Url'),
- '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'),
- '>' => array('SpecialCharacter'),
- '[' => array('Link'),
- '_' => array('Emphasis'),
- '`' => array('Code'),
- '~' => array('Strikethrough'),
- '\\' => array('EscapeSequence'),
- );
-
- # ~
-
- protected $inlineMarkerList = '!"*_&[:<>`~\\';
-
- #
- # ~
- #
-
- public function line($text, $nonNestables=array())
- {
- $markup = '';
-
- # $excerpt is based on the first occurrence of a marker
-
- while ($excerpt = strpbrk($text, $this->inlineMarkerList))
- {
- $marker = $excerpt[0];
-
- $markerPosition = strpos($text, $marker);
-
- $Excerpt = array('text' => $excerpt, 'context' => $text);
-
- foreach ($this->InlineTypes[$marker] as $inlineType)
- {
- # check to see if the current inline type is nestable in the current context
-
- if ( ! empty($nonNestables) and in_array($inlineType, $nonNestables))
- {
- continue;
- }
-
- $Inline = $this->{'inline'.$inlineType}($Excerpt);
-
- if ( ! isset($Inline))
- {
- continue;
- }
-
- # makes sure that the inline belongs to "our" marker
-
- if (isset($Inline['position']) and $Inline['position'] > $markerPosition)
- {
- continue;
- }
-
- # sets a default inline position
-
- if ( ! isset($Inline['position']))
- {
- $Inline['position'] = $markerPosition;
- }
-
- # cause the new element to 'inherit' our non nestables
-
- foreach ($nonNestables as $non_nestable)
- {
- $Inline['element']['nonNestables'][] = $non_nestable;
- }
-
- # the text that comes before the inline
- $unmarkedText = substr($text, 0, $Inline['position']);
-
- # compile the unmarked text
- $markup .= $this->unmarkedText($unmarkedText);
-
- # compile the inline
- $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
-
- # remove the examined text
- $text = substr($text, $Inline['position'] + $Inline['extent']);
-
- continue 2;
- }
-
- # the marker does not belong to an inline
-
- $unmarkedText = substr($text, 0, $markerPosition + 1);
-
- $markup .= $this->unmarkedText($unmarkedText);
-
- $text = substr($text, $markerPosition + 1);
- }
-
- $markup .= $this->unmarkedText($text);
-
- return $markup;
- }
-
- #
- # ~
- #
-
- protected function inlineCode($Excerpt)
- {
- $marker = $Excerpt['text'][0];
-
- if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(? strlen($matches[0]),
- 'element' => array(
- 'name' => 'code',
- 'text' => $text,
- ),
- );
- }
- }
-
- protected function inlineEmailTag($Excerpt)
- {
- if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
- {
- $url = $matches[1];
-
- if ( ! isset($matches[2]))
- {
- $url = 'mailto:' . $url;
- }
-
- return array(
- 'extent' => strlen($matches[0]),
- 'element' => array(
- 'name' => 'a',
- 'text' => $matches[1],
- 'attributes' => array(
- 'href' => $url,
- ),
- ),
- );
- }
- }
-
- protected function inlineEmphasis($Excerpt)
- {
- if ( ! isset($Excerpt['text'][1]))
- {
- return;
- }
-
- $marker = $Excerpt['text'][0];
-
- if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
- {
- $emphasis = 'strong';
- }
- elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
- {
- $emphasis = 'em';
- }
- else
- {
- return;
- }
-
- return array(
- 'extent' => strlen($matches[0]),
- 'element' => array(
- 'name' => $emphasis,
- 'handler' => 'line',
- 'text' => $matches[1],
- ),
- );
- }
-
- protected function inlineEscapeSequence($Excerpt)
- {
- if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
- {
- return array(
- 'markup' => $Excerpt['text'][1],
- 'extent' => 2,
- );
- }
- }
-
- protected function inlineImage($Excerpt)
- {
- if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
- {
- return;
- }
-
- $Excerpt['text']= substr($Excerpt['text'], 1);
-
- $Link = $this->inlineLink($Excerpt);
-
- if ($Link === null)
- {
- return;
- }
-
- $Inline = array(
- 'extent' => $Link['extent'] + 1,
- 'element' => array(
- 'name' => 'img',
- 'attributes' => array(
- 'src' => $Link['element']['attributes']['href'],
- 'alt' => $Link['element']['text'],
- ),
- ),
- );
-
- $Inline['element']['attributes'] += $Link['element']['attributes'];
-
- unset($Inline['element']['attributes']['href']);
-
- return $Inline;
- }
-
- protected function inlineLink($Excerpt)
- {
- $Element = array(
- 'name' => 'a',
- 'handler' => 'line',
- 'nonNestables' => array('Url', 'Link'),
- 'text' => null,
- 'attributes' => array(
- 'href' => null,
- 'title' => null,
- ),
- );
-
- $extent = 0;
-
- $remainder = $Excerpt['text'];
-
- if (preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches))
- {
- $Element['text'] = $matches[1];
-
- $extent += strlen($matches[0]);
-
- $remainder = substr($remainder, $extent);
- }
- else
- {
- return;
- }
-
- if (preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*"|\'[^\']*\'))?\s*[)]/', $remainder, $matches))
- {
- $Element['attributes']['href'] = $matches[1];
-
- if (isset($matches[2]))
- {
- $Element['attributes']['title'] = substr($matches[2], 1, - 1);
- }
-
- $extent += strlen($matches[0]);
- }
- else
- {
- if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
- {
- $definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
- $definition = strtolower($definition);
-
- $extent += strlen($matches[0]);
- }
- else
- {
- $definition = strtolower($Element['text']);
- }
-
- if ( ! isset($this->DefinitionData['Reference'][$definition]))
- {
- return;
- }
-
- $Definition = $this->DefinitionData['Reference'][$definition];
-
- $Element['attributes']['href'] = $Definition['url'];
- $Element['attributes']['title'] = $Definition['title'];
- }
-
- return array(
- 'extent' => $extent,
- 'element' => $Element,
- );
- }
-
- protected function inlineMarkup($Excerpt)
- {
- if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false)
- {
- return;
- }
-
- if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches))
- {
- return array(
- 'markup' => $matches[0],
- 'extent' => strlen($matches[0]),
- );
- }
-
- if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches))
- {
- return array(
- 'markup' => $matches[0],
- 'extent' => strlen($matches[0]),
- );
- }
-
- if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
- {
- return array(
- 'markup' => $matches[0],
- 'extent' => strlen($matches[0]),
- );
- }
- }
-
- protected function inlineSpecialCharacter($Excerpt)
- {
- if ($Excerpt['text'][0] === '&' and ! preg_match('/^?\w+;/', $Excerpt['text']))
- {
- return array(
- 'markup' => '&',
- 'extent' => 1,
- );
- }
-
- $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
-
- if (isset($SpecialCharacter[$Excerpt['text'][0]]))
- {
- return array(
- 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
- 'extent' => 1,
- );
- }
- }
-
- protected function inlineStrikethrough($Excerpt)
- {
- if ( ! isset($Excerpt['text'][1]))
- {
- return;
- }
-
- if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
- {
- return array(
- 'extent' => strlen($matches[0]),
- 'element' => array(
- 'name' => 'del',
- 'text' => $matches[1],
- 'handler' => 'line',
- ),
- );
- }
- }
-
- protected function inlineUrl($Excerpt)
- {
- if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
- {
- return;
- }
-
- if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
- {
- $url = $matches[0][0];
-
- $Inline = array(
- 'extent' => strlen($matches[0][0]),
- 'position' => $matches[0][1],
- 'element' => array(
- 'name' => 'a',
- 'text' => $url,
- 'attributes' => array(
- 'href' => $url,
- ),
- ),
- );
-
- return $Inline;
- }
- }
-
- protected function inlineUrlTag($Excerpt)
- {
- if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
- {
- $url = $matches[1];
-
- return array(
- 'extent' => strlen($matches[0]),
- 'element' => array(
- 'name' => 'a',
- 'text' => $url,
- 'attributes' => array(
- 'href' => $url,
- ),
- ),
- );
- }
- }
-
- # ~
-
- protected function unmarkedText($text)
- {
- if ($this->breaksEnabled)
- {
- $text = preg_replace('/[ ]*\n/', "') - { - $markup = $trimmedMarkup; - $markup = substr($markup, 3); - - $position = strpos($markup, "
"); - - $markup = substr_replace($markup, '', $position, 4); - } - - return $markup; - } - - # - # Deprecated Methods - # - - function parse($text) - { - $markup = $this->text($text); - - return $markup; - } - - protected function sanitiseElement(array $Element) - { - static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; - static $safeUrlNameToAtt = array( - 'a' => 'href', - 'img' => 'src', - ); - - if (isset($safeUrlNameToAtt[$Element['name']])) - { - $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); - } - - if ( ! empty($Element['attributes'])) - { - foreach ($Element['attributes'] as $att => $val) - { - # filter out badly parsed attribute - if ( ! preg_match($goodAttribute, $att)) - { - unset($Element['attributes'][$att]); - } - # dump onevent attribute - elseif (self::striAtStart($att, 'on')) - { - unset($Element['attributes'][$att]); - } - } - } - - return $Element; - } - - protected function filterUnsafeUrlInAttribute(array $Element, $attribute) - { - foreach ($this->safeLinksWhitelist as $scheme) - { - if (self::striAtStart($Element['attributes'][$attribute], $scheme)) - { - return $Element; - } - } - - $Element['attributes'][$attribute] = str_replace(':', '%3A', $Element['attributes'][$attribute]); - - return $Element; - } - - # - # Static Methods - # - - protected static function escape($text, $allowQuotes = false) - { - return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8'); - } - - protected static function striAtStart($string, $needle) - { - $len = strlen($needle); - - if ($len > strlen($string)) - { - return false; - } - else - { - return strtolower(substr($string, 0, $len)) === strtolower($needle); - } - } - - static function instance($name = 'default') - { - if (isset(self::$instances[$name])) - { - return self::$instances[$name]; - } - - $instance = new static(); - - self::$instances[$name] = $instance; - - return $instance; - } - - private static $instances = array(); - - # - # Fields - # - - protected $DefinitionData; - - # - # Read-Only - - protected $specialCharacters = array( - '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', - ); - - protected $StrongRegex = array( - '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', - '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', - ); - - protected $EmRegex = array( - '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', - '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', - ); - - protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; - - protected $voidElements = array( - 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', - ); - - protected $textLevelElements = array( - 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', - 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', - 'i', 'rp', 'del', 'code', 'strike', 'marquee', - 'q', 'rt', 'ins', 'font', 'strong', - 's', 'tt', 'kbd', 'mark', - 'u', 'xm', 'sub', 'nobr', - 'sup', 'ruby', - 'var', 'span', - 'wbr', 'time', - ); -} diff --git a/library/vendor/Parsedown/SOURCE b/library/vendor/Parsedown/SOURCE deleted file mode 100644 index 4570e917c..000000000 --- a/library/vendor/Parsedown/SOURCE +++ /dev/null @@ -1,7 +0,0 @@ -RELEASE=1.7.3 -PARSEDOWN=parsedown-$RELEASE -curl https://codeload.github.com/erusev/parsedown/tar.gz/${RELEASE} -o ${PARSEDOWN}.tar.gz -tar xfz ${PARSEDOWN}.tar.gz --strip-components 1 ${PARSEDOWN}/Parsedown.php ${PARSEDOWN}/LICENSE.txt -chmod 0644 Parsedown.php -mv LICENSE.txt LICENSE -rm ${PARSEDOWN}.tar.gz diff --git a/library/vendor/Zend/Cache.php b/library/vendor/Zend/Cache.php deleted file mode 100644 index 272cd0b9d..000000000 --- a/library/vendor/Zend/Cache.php +++ /dev/null @@ -1,245 +0,0 @@ -setBackend($backendObject); - return $frontendObject; - } - - /** - * Backend Constructor - * - * @param string $backend - * @param array $backendOptions - * @param boolean $customBackendNaming - * @param boolean $autoload - * @return Zend_Cache_Backend - */ - public static function _makeBackend($backend, $backendOptions, $customBackendNaming = false, $autoload = false) - { - if (!$customBackendNaming) { - $backend = self::_normalizeName($backend); - } - if (in_array($backend, Zend_Cache::$standardBackends)) { - // we use a standard backend - $backendClass = 'Zend_Cache_Backend_' . $backend; - // security controls are explicit - } else { - // we use a custom backend - if (!preg_match('~^[\w\\\\]+$~D', $backend)) { - Zend_Cache::throwException("Invalid backend name [$backend]"); - } - if (!$customBackendNaming) { - // we use this boolean to avoid an API break - $backendClass = 'Zend_Cache_Backend_' . $backend; - } else { - $backendClass = $backend; - } - if (!$autoload) { - $file = str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php'; - if (!(self::_isReadable($file))) { - self::throwException("file $file not found in include_path"); - } - } - } - return new $backendClass($backendOptions); - } - - /** - * Frontend Constructor - * - * @param string $frontend - * @param array $frontendOptions - * @param boolean $customFrontendNaming - * @param boolean $autoload - * @return Zend_Cache_Core|Zend_Cache_Frontend - */ - public static function _makeFrontend($frontend, $frontendOptions = array(), $customFrontendNaming = false, $autoload = false) - { - if (!$customFrontendNaming) { - $frontend = self::_normalizeName($frontend); - } - if (in_array($frontend, self::$standardFrontends)) { - // we use a standard frontend - // For perfs reasons, with frontend == 'Core', we can interact with the Core itself - $frontendClass = 'Zend_Cache_' . ($frontend != 'Core' ? 'Frontend_' : '') . $frontend; - // security controls are explicit - } else { - // we use a custom frontend - if (!preg_match('~^[\w\\\\]+$~D', $frontend)) { - Zend_Cache::throwException("Invalid frontend name [$frontend]"); - } - if (!$customFrontendNaming) { - // we use this boolean to avoid an API break - $frontendClass = 'Zend_Cache_Frontend_' . $frontend; - } else { - $frontendClass = $frontend; - } - if (!$autoload) { - $file = str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php'; - if (!(self::_isReadable($file))) { - self::throwException("file $file not found in include_path"); - } - } - } - return new $frontendClass($frontendOptions); - } - - /** - * Throw an exception - * - * Note : for perf reasons, the "load" of Zend/Cache/Exception is dynamic - * @param string $msg Message for the exception - * @throws Zend_Cache_Exception - */ - public static function throwException($msg, Exception $e = null) - { - // For perfs reasons, we use this dynamic inclusion - throw new Zend_Cache_Exception($msg, 0, $e); - } - - /** - * Normalize frontend and backend names to allow multiple words TitleCased - * - * @param string $name Name to normalize - * @return string - */ - protected static function _normalizeName($name) - { - $name = ucfirst(strtolower($name)); - $name = str_replace(array('-', '_', '.'), ' ', $name); - $name = ucwords($name); - $name = str_replace(' ', '', $name); - if (stripos($name, 'ZendServer') === 0) { - $name = 'ZendServer_' . substr($name, strlen('ZendServer')); - } - - return $name; - } - - /** - * Returns TRUE if the $filename is readable, or FALSE otherwise. - * This function uses the PHP include_path, where PHP's is_readable() - * does not. - * - * Note : this method comes from Zend_Loader (see #ZF-2891 for details) - * - * @param string $filename - * @return boolean - */ - private static function _isReadable($filename) - { - if (!$fh = @fopen($filename, 'r', true)) { - return false; - } - @fclose($fh); - return true; - } - -} diff --git a/library/vendor/Zend/Cache/Backend.php b/library/vendor/Zend/Cache/Backend.php deleted file mode 100644 index 6e1efdeed..000000000 --- a/library/vendor/Zend/Cache/Backend.php +++ /dev/null @@ -1,285 +0,0 @@ - (int) lifetime : - * - Cache lifetime (in seconds) - * - If null, the cache is valid forever - * - * =====> (int) logging : - * - if set to true, a logging is activated throw Zend_Log - * - * @var array directives - */ - protected $_directives = array( - 'lifetime' => 3600, - 'logging' => false, - 'logger' => null - ); - - /** - * Available options - * - * @var array available options - */ - protected $_options = array(); - - /** - * Constructor - * - * @param array $options Associative array of options - */ - public function __construct(array $options = array()) - { - foreach ($options as $name => $value) { - $this->setOption($name, $value); - } - } - - /** - * Set the frontend directives - * - * @param array $directives Assoc of directives - * @throws Zend_Cache_Exception - * @return void - */ - public function setDirectives($directives) - { - if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array'); - while (list($name, $value) = each($directives)) { - if (!is_string($name)) { - Zend_Cache::throwException("Incorrect option name : $name"); - } - $name = strtolower($name); - if (array_key_exists($name, $this->_directives)) { - $this->_directives[$name] = $value; - } - - } - - $this->_loggerSanity(); - } - - /** - * Set an option - * - * @param string $name - * @param mixed $value - * @throws Zend_Cache_Exception - * @return void - */ - public function setOption($name, $value) - { - if (!is_string($name)) { - Zend_Cache::throwException("Incorrect option name : $name"); - } - $name = strtolower($name); - if (array_key_exists($name, $this->_options)) { - $this->_options[$name] = $value; - } - } - - /** - * Returns an option - * - * @param string $name Optional, the options name to return - * @throws Zend_Cache_Exceptions - * @return mixed - */ - public function getOption($name) - { - $name = strtolower($name); - - if (array_key_exists($name, $this->_options)) { - return $this->_options[$name]; - } - - if (array_key_exists($name, $this->_directives)) { - return $this->_directives[$name]; - } - - Zend_Cache::throwException("Incorrect option name : {$name}"); - } - - /** - * Get the life time - * - * if $specificLifetime is not false, the given specific life time is used - * else, the global lifetime is used - * - * @param int $specificLifetime - * @return int Cache life time - */ - public function getLifetime($specificLifetime) - { - if ($specificLifetime === false) { - return $this->_directives['lifetime']; - } - return $specificLifetime; - } - - /** - * Return true if the automatic cleaning is available for the backend - * - * DEPRECATED : use getCapabilities() instead - * - * @deprecated - * @return boolean - */ - public function isAutomaticCleaningAvailable() - { - return true; - } - - /** - * Determine system TMP directory and detect if we have read access - * - * inspired from Zend_File_Transfer_Adapter_Abstract - * - * @return string - * @throws Zend_Cache_Exception if unable to determine directory - */ - public function getTmpDir() - { - $tmpdir = array(); - foreach (array($_ENV, $_SERVER) as $tab) { - foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) { - if (isset($tab[$key]) && is_string($tab[$key])) { - if (($key == 'windir') or ($key == 'SystemRoot')) { - $dir = realpath($tab[$key] . '\\temp'); - } else { - $dir = realpath($tab[$key]); - } - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } - } - } - } - $upload = ini_get('upload_tmp_dir'); - if ($upload) { - $dir = realpath($upload); - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } - } - if (function_exists('sys_get_temp_dir')) { - $dir = sys_get_temp_dir(); - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } - } - // Attemp to detect by creating a temporary file - $tempFile = tempnam(md5(uniqid(rand(), TRUE)), ''); - if ($tempFile) { - $dir = realpath(dirname($tempFile)); - unlink($tempFile); - if ($this->_isGoodTmpDir($dir)) { - return $dir; - } - } - if ($this->_isGoodTmpDir('/tmp')) { - return '/tmp'; - } - if ($this->_isGoodTmpDir('\\temp')) { - return '\\temp'; - } - Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually'); - } - - /** - * Verify if the given temporary directory is readable and writable - * - * @param string $dir temporary directory - * @return boolean true if the directory is ok - */ - protected function _isGoodTmpDir($dir) - { - if (is_readable($dir)) { - if (is_writable($dir)) { - return true; - } - } - return false; - } - - /** - * Make sure if we enable logging that the Zend_Log class - * is available. - * Create a default log object if none is set. - * - * @throws Zend_Cache_Exception - * @return void - */ - protected function _loggerSanity() - { - if (!isset($this->_directives['logging']) || !$this->_directives['logging']) { - return; - } - - if (isset($this->_directives['logger'])) { - if ($this->_directives['logger'] instanceof Zend_Log) { - return; - } - Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.'); - } - - // Create a default logger to the standard output stream - $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output')); - $logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<=')); - $this->_directives['logger'] = $logger; - } - - /** - * Log a message at the WARN (4) priority. - * - * @param string $message - * @param int $priority - * @return void - */ - protected function _log($message, $priority = 4) - { - if (!$this->_directives['logging']) { - return; - } - - if (!isset($this->_directives['logger'])) { - Zend_Cache::throwException('Logging is enabled but logger is not set.'); - } - $logger = $this->_directives['logger']; - if (!$logger instanceof Zend_Log) { - Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.'); - } - $logger->log($message, $priority); - } -} diff --git a/library/vendor/Zend/Cache/Backend/Apc.php b/library/vendor/Zend/Cache/Backend/Apc.php deleted file mode 100644 index 960532314..000000000 --- a/library/vendor/Zend/Cache/Backend/Apc.php +++ /dev/null @@ -1,353 +0,0 @@ - infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $lifetime = $this->getLifetime($specificLifetime); - $result = apc_store($id, array($data, time(), $lifetime), $lifetime); - if (count($tags) > 0) { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - } - return $result; - } - - /** - * Remove a cache record - * - * @param string $id cache id - * @return boolean true if no problem - */ - public function remove($id) - { - return apc_delete($id); - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => unsupported - * 'matchingTag' => unsupported - * 'notMatchingTag' => unsupported - * 'matchingAnyTag' => unsupported - * - * @param string $mode clean mode - * @param array $tags array of tags - * @throws Zend_Cache_Exception - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - return apc_clear_cache('user'); - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend"); - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_APC_BACKEND); - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - - /** - * Return true if the automatic cleaning is available for the backend - * - * DEPRECATED : use getCapabilities() instead - * - * @deprecated - * @return boolean - */ - public function isAutomaticCleaningAvailable() - { - return false; - } - - /** - * Return the filling percentage of the backend storage - * - * @throws Zend_Cache_Exception - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - $mem = apc_sma_info(true); - $memSize = $mem['num_seg'] * $mem['seg_size']; - $memAvailable= $mem['avail_mem']; - $memUsed = $memSize - $memAvailable; - if ($memSize == 0) { - Zend_Cache::throwException('can\'t get apc memory size'); - } - if ($memUsed > $memSize) { - return 100; - } - return ((int) (100. * ($memUsed / $memSize))); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - $ids = array(); - $iterator = new APCIterator('user', null, APC_ITER_KEY); - foreach ($iterator as $item) { - $ids[] = $item['key']; - } - - return $ids; - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - $tmp = apc_fetch($id); - if (is_array($tmp)) { - $data = $tmp[0]; - $mtime = $tmp[1]; - if (!isset($tmp[2])) { - // because this record is only with 1.7 release - // if old cache records are still there... - return false; - } - $lifetime = $tmp[2]; - return array( - 'expire' => $mtime + $lifetime, - 'tags' => array(), - 'mtime' => $mtime - ); - } - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - $tmp = apc_fetch($id); - if (is_array($tmp)) { - $data = $tmp[0]; - $mtime = $tmp[1]; - if (!isset($tmp[2])) { - // because this record is only with 1.7 release - // if old cache records are still there... - return false; - } - $lifetime = $tmp[2]; - $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime; - if ($newLifetime <=0) { - return false; - } - apc_store($id, array($data, time(), $newLifetime), $newLifetime); - return true; - } - return false; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => false, - 'tags' => false, - 'expired_read' => false, - 'priority' => false, - 'infinite_lifetime' => false, - 'get_list' => true - ); - } - -} diff --git a/library/vendor/Zend/Cache/Backend/BlackHole.php b/library/vendor/Zend/Cache/Backend/BlackHole.php deleted file mode 100644 index 8732c1968..000000000 --- a/library/vendor/Zend/Cache/Backend/BlackHole.php +++ /dev/null @@ -1,248 +0,0 @@ - infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - return true; - } - - /** - * Remove a cache record - * - * @param string $id cache id - * @return boolean true if no problem - */ - public function remove($id) - { - return true; - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => remove too old cache entries ($tags is not used) - * 'matchingTag' => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * 'notMatchingTag' => remove cache entries not matching one of the given tags - * ($tags can be an array of strings or a single string) - * 'matchingAnyTag' => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode clean mode - * @param tags array $tags array of tags - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - return true; - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - return array(); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - return array(); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - return array(); - } - - /** - * Return the filling percentage of the backend storage - * - * @return int integer between 0 and 100 - * @throws Zend_Cache_Exception - */ - public function getFillingPercentage() - { - return 0; - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - return false; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => true, - 'tags' => true, - 'expired_read' => true, - 'priority' => true, - 'infinite_lifetime' => true, - 'get_list' => true, - ); - } - - /** - * PUBLIC METHOD FOR UNIT TESTING ONLY ! - * - * Force a cache record to expire - * - * @param string $id cache id - */ - public function ___expire($id) - { - } -} diff --git a/library/vendor/Zend/Cache/Backend/ExtendedInterface.php b/library/vendor/Zend/Cache/Backend/ExtendedInterface.php deleted file mode 100644 index 2f0f526b7..000000000 --- a/library/vendor/Zend/Cache/Backend/ExtendedInterface.php +++ /dev/null @@ -1,125 +0,0 @@ - (string) cache_dir : - * - Directory where to put the cache files - * - * =====> (boolean) file_locking : - * - Enable / disable file_locking - * - Can avoid cache corruption under bad circumstances but it doesn't work on multithread - * webservers and on NFS filesystems for example - * - * =====> (boolean) read_control : - * - Enable / disable read control - * - If enabled, a control key is embeded in cache file and this key is compared with the one - * calculated after the reading. - * - * =====> (string) read_control_type : - * - Type of read control (only if read control is enabled). Available values are : - * 'md5' for a md5 hash control (best but slowest) - * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice) - * 'adler32' for an adler32 hash control (excellent choice too, faster than crc32) - * 'strlen' for a length only test (fastest) - * - * =====> (int) hashed_directory_level : - * - Hashed directory level - * - Set the hashed directory structure level. 0 means "no hashed directory - * structure", 1 means "one level of directory", 2 means "two levels"... - * This option can speed up the cache only when you have many thousands of - * cache file. Only specific benchs can help you to choose the perfect value - * for you. Maybe, 1 or 2 is a good start. - * - * =====> (int) hashed_directory_umask : - * - deprecated - * - Permissions for hashed directory structure - * - * =====> (int) hashed_directory_perm : - * - Permissions for hashed directory structure - * - * =====> (string) file_name_prefix : - * - prefix for cache files - * - be really carefull with this option because a too generic value in a system cache dir - * (like /tmp) can cause disasters when cleaning the cache - * - * =====> (int) cache_file_umask : - * - deprecated - * - Permissions for cache files - * - * =====> (int) cache_file_perm : - * - Permissions for cache files - * - * =====> (int) metatadatas_array_max_size : - * - max size for the metadatas array (don't change this value unless you - * know what you are doing) - * - * @var array available options - */ - protected $_options = array( - 'cache_dir' => null, - 'file_locking' => true, - 'read_control' => true, - 'read_control_type' => 'crc32', - 'hashed_directory_level' => 0, - 'hashed_directory_perm' => 0700, - 'file_name_prefix' => 'zend_cache', - 'cache_file_perm' => 0600, - 'metadatas_array_max_size' => 100 - ); - - /** - * Array of metadatas (each item is an associative array) - * - * @var array - */ - protected $_metadatasArray = array(); - - - /** - * Constructor - * - * @param array $options associative array of options - * @throws Zend_Cache_Exception - */ - public function __construct(array $options = array()) - { - parent::__construct($options); - if ($this->_options['cache_dir'] !== null) { // particular case for this option - $this->setCacheDir($this->_options['cache_dir']); - } else { - $this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false); - } - if (isset($this->_options['file_name_prefix'])) { // particular case for this option - if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) { - Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]'); - } - } - if ($this->_options['metadatas_array_max_size'] < 10) { - Zend_Cache::throwException('Invalid metadatas_array_max_size, must be > 10'); - } - - if (isset($options['hashed_directory_umask'])) { - // See #ZF-12047 - trigger_error("'hashed_directory_umask' is deprecated -> please use 'hashed_directory_perm' instead", E_USER_NOTICE); - if (!isset($options['hashed_directory_perm'])) { - $options['hashed_directory_perm'] = $options['hashed_directory_umask']; - } - } - if (isset($options['hashed_directory_perm']) && is_string($options['hashed_directory_perm'])) { - // See #ZF-4422 - $this->_options['hashed_directory_perm'] = octdec($this->_options['hashed_directory_perm']); - } - - if (isset($options['cache_file_umask'])) { - // See #ZF-12047 - trigger_error("'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", E_USER_NOTICE); - if (!isset($options['cache_file_perm'])) { - $options['cache_file_perm'] = $options['cache_file_umask']; - } - } - if (isset($options['cache_file_perm']) && is_string($options['cache_file_perm'])) { - // See #ZF-4422 - $this->_options['cache_file_perm'] = octdec($this->_options['cache_file_perm']); - } - } - - /** - * Set the cache_dir (particular case of setOption() method) - * - * @param string $value - * @param boolean $trailingSeparator If true, add a trailing separator is necessary - * @throws Zend_Cache_Exception - * @return void - */ - public function setCacheDir($value, $trailingSeparator = true) - { - if (!is_dir($value)) { - Zend_Cache::throwException(sprintf('cache_dir "%s" must be a directory', $value)); - } - if (!is_writable($value)) { - Zend_Cache::throwException(sprintf('cache_dir "%s" is not writable', $value)); - } - if ($trailingSeparator) { - // add a trailing DIRECTORY_SEPARATOR if necessary - $value = rtrim(realpath($value), '\\/') . DIRECTORY_SEPARATOR; - } - $this->_options['cache_dir'] = $value; - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id cache id - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - if (!($this->_test($id, $doNotTestCacheValidity))) { - // The cache is not hit ! - return false; - } - $metadatas = $this->_getMetadatas($id); - $file = $this->_file($id); - $data = $this->_fileGetContents($file); - if ($this->_options['read_control']) { - $hashData = $this->_hash($data, $this->_options['read_control_type']); - $hashControl = $metadatas['hash']; - if ($hashData != $hashControl) { - // Problem detected by the read control ! - $this->_log('Zend_Cache_Backend_File::load() / read_control : stored hash and computed hash do not match'); - $this->remove($id); - return false; - } - } - return $data; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - clearstatcache(); - return $this->_test($id, false); - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param boolean|int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - clearstatcache(); - $file = $this->_file($id); - $path = $this->_path($id); - if ($this->_options['hashed_directory_level'] > 0) { - if (!is_writable($path)) { - // maybe, we just have to build the directory structure - $this->_recursiveMkdirAndChmod($id); - } - if (!is_writable($path)) { - return false; - } - } - if ($this->_options['read_control']) { - $hash = $this->_hash($data, $this->_options['read_control_type']); - } else { - $hash = ''; - } - $metadatas = array( - 'hash' => $hash, - 'mtime' => time(), - 'expire' => $this->_expireTime($this->getLifetime($specificLifetime)), - 'tags' => $tags - ); - $res = $this->_setMetadatas($id, $metadatas); - if (!$res) { - $this->_log('Zend_Cache_Backend_File::save() / error on saving metadata'); - return false; - } - $res = $this->_filePutContents($file, $data); - return $res; - } - - /** - * Remove a cache record - * - * @param string $id cache id - * @return boolean true if no problem - */ - public function remove($id) - { - $file = $this->_file($id); - $boolRemove = $this->_remove($file); - $boolMetadata = $this->_delMetadatas($id); - return $boolMetadata && $boolRemove; - } - - /** - * Clean some cache records - * - * Available modes are : - * - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode clean mode - * @param array $tags array of tags - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - // We use this protected method to hide the recursive stuff - clearstatcache(); - return $this->_clean($this->_options['cache_dir'], $mode, $tags); - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - return $this->_get($this->_options['cache_dir'], 'ids', array()); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - return $this->_get($this->_options['cache_dir'], 'tags', array()); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - return $this->_get($this->_options['cache_dir'], 'matching', $tags); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - return $this->_get($this->_options['cache_dir'], 'notMatching', $tags); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - return $this->_get($this->_options['cache_dir'], 'matchingAny', $tags); - } - - /** - * Return the filling percentage of the backend storage - * - * @throws Zend_Cache_Exception - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - $free = disk_free_space($this->_options['cache_dir']); - $total = disk_total_space($this->_options['cache_dir']); - if ($total == 0) { - Zend_Cache::throwException('can\'t get disk_total_space'); - } else { - if ($free >= $total) { - return 100; - } - return ((int) (100. * ($total - $free) / $total)); - } - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - $metadatas = $this->_getMetadatas($id); - if (!$metadatas) { - return false; - } - if (time() > $metadatas['expire']) { - return false; - } - return array( - 'expire' => $metadatas['expire'], - 'tags' => $metadatas['tags'], - 'mtime' => $metadatas['mtime'] - ); - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - $metadatas = $this->_getMetadatas($id); - if (!$metadatas) { - return false; - } - if (time() > $metadatas['expire']) { - return false; - } - $newMetadatas = array( - 'hash' => $metadatas['hash'], - 'mtime' => time(), - 'expire' => $metadatas['expire'] + $extraLifetime, - 'tags' => $metadatas['tags'] - ); - $res = $this->_setMetadatas($id, $newMetadatas); - if (!$res) { - return false; - } - return true; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => true, - 'tags' => true, - 'expired_read' => true, - 'priority' => false, - 'infinite_lifetime' => true, - 'get_list' => true - ); - } - - /** - * PUBLIC METHOD FOR UNIT TESTING ONLY ! - * - * Force a cache record to expire - * - * @param string $id cache id - */ - public function ___expire($id) - { - $metadatas = $this->_getMetadatas($id); - if ($metadatas) { - $metadatas['expire'] = 1; - $this->_setMetadatas($id, $metadatas); - } - } - - /** - * Get a metadatas record - * - * @param string $id Cache id - * @return array|false Associative array of metadatas - */ - protected function _getMetadatas($id) - { - if (isset($this->_metadatasArray[$id])) { - return $this->_metadatasArray[$id]; - } else { - $metadatas = $this->_loadMetadatas($id); - if (!$metadatas) { - return false; - } - $this->_setMetadatas($id, $metadatas, false); - return $metadatas; - } - } - - /** - * Set a metadatas record - * - * @param string $id Cache id - * @param array $metadatas Associative array of metadatas - * @param boolean $save optional pass false to disable saving to file - * @return boolean True if no problem - */ - protected function _setMetadatas($id, $metadatas, $save = true) - { - if (count($this->_metadatasArray) >= $this->_options['metadatas_array_max_size']) { - $n = (int) ($this->_options['metadatas_array_max_size'] / 10); - $this->_metadatasArray = array_slice($this->_metadatasArray, $n); - } - if ($save) { - $result = $this->_saveMetadatas($id, $metadatas); - if (!$result) { - return false; - } - } - $this->_metadatasArray[$id] = $metadatas; - return true; - } - - /** - * Drop a metadata record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - protected function _delMetadatas($id) - { - if (isset($this->_metadatasArray[$id])) { - unset($this->_metadatasArray[$id]); - } - $file = $this->_metadatasFile($id); - return $this->_remove($file); - } - - /** - * Clear the metadatas array - * - * @return void - */ - protected function _cleanMetadatas() - { - $this->_metadatasArray = array(); - } - - /** - * Load metadatas from disk - * - * @param string $id Cache id - * @return array|false Metadatas associative array - */ - protected function _loadMetadatas($id) - { - $file = $this->_metadatasFile($id); - $result = $this->_fileGetContents($file); - if (!$result) { - return false; - } - $tmp = @unserialize($result); - return $tmp; - } - - /** - * Save metadatas to disk - * - * @param string $id Cache id - * @param array $metadatas Associative array - * @return boolean True if no problem - */ - protected function _saveMetadatas($id, $metadatas) - { - $file = $this->_metadatasFile($id); - $result = $this->_filePutContents($file, serialize($metadatas)); - if (!$result) { - return false; - } - return true; - } - - /** - * Make and return a file name (with path) for metadatas - * - * @param string $id Cache id - * @return string Metadatas file name (with path) - */ - protected function _metadatasFile($id) - { - $path = $this->_path($id); - $fileName = $this->_idToFileName('internal-metadatas---' . $id); - return $path . $fileName; - } - - /** - * Check if the given filename is a metadatas one - * - * @param string $fileName File name - * @return boolean True if it's a metadatas one - */ - protected function _isMetadatasFile($fileName) - { - $id = $this->_fileNameToId($fileName); - if (substr($id, 0, 21) == 'internal-metadatas---') { - return true; - } else { - return false; - } - } - - /** - * Remove a file - * - * If we can't remove the file (because of locks or any problem), we will touch - * the file to invalidate it - * - * @param string $file Complete file path - * @return boolean True if ok - */ - protected function _remove($file) - { - if (!is_file($file)) { - return false; - } - if (!@unlink($file)) { - # we can't remove the file (because of locks or any problem) - $this->_log("Zend_Cache_Backend_File::_remove() : we can't remove $file"); - return false; - } - return true; - } - - /** - * Clean some cache records (protected method used for recursive stuff) - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $dir Directory to clean - * @param string $mode Clean mode - * @param array $tags Array of tags - * @throws Zend_Cache_Exception - * @return boolean True if no problem - */ - protected function _clean($dir, $mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - if (!is_dir($dir)) { - return false; - } - $result = true; - $prefix = $this->_options['file_name_prefix']; - $glob = @glob($dir . $prefix . '--*'); - if ($glob === false) { - // On some systems it is impossible to distinguish between empty match and an error. - return true; - } - $metadataFiles = array(); - foreach ($glob as $file) { - if (is_file($file)) { - $fileName = basename($file); - if ($this->_isMetadatasFile($fileName)) { - // In CLEANING_MODE_ALL, we drop anything, even remainings old metadatas files. - // To do that, we need to save the list of the metadata files first. - if ($mode == Zend_Cache::CLEANING_MODE_ALL) { - $metadataFiles[] = $file; - } - continue; - } - $id = $this->_fileNameToId($fileName); - $metadatas = $this->_getMetadatas($id); - if ($metadatas === FALSE) { - $metadatas = array('expire' => 1, 'tags' => array()); - } - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - $result = $result && $this->remove($id); - break; - case Zend_Cache::CLEANING_MODE_OLD: - if (time() > $metadatas['expire']) { - $result = $this->remove($id) && $result; - } - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - $matching = true; - foreach ($tags as $tag) { - if (!in_array($tag, $metadatas['tags'])) { - $matching = false; - break; - } - } - if ($matching) { - $result = $this->remove($id) && $result; - } - break; - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - $matching = false; - foreach ($tags as $tag) { - if (in_array($tag, $metadatas['tags'])) { - $matching = true; - break; - } - } - if (!$matching) { - $result = $this->remove($id) && $result; - } - break; - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $matching = false; - foreach ($tags as $tag) { - if (in_array($tag, $metadatas['tags'])) { - $matching = true; - break; - } - } - if ($matching) { - $result = $this->remove($id) && $result; - } - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) { - // Recursive call - $result = $this->_clean($file . DIRECTORY_SEPARATOR, $mode, $tags) && $result; - if ($mode == Zend_Cache::CLEANING_MODE_ALL) { - // we try to drop the structure too - @rmdir($file); - } - } - } - - // cycle through metadataFiles and delete orphaned ones - foreach ($metadataFiles as $file) { - if (file_exists($file)) { - $result = $this->_remove($file) && $result; - } - } - - return $result; - } - - protected function _get($dir, $mode, $tags = array()) - { - if (!is_dir($dir)) { - return false; - } - $result = array(); - $prefix = $this->_options['file_name_prefix']; - $glob = @glob($dir . $prefix . '--*'); - if ($glob === false) { - // On some systems it is impossible to distinguish between empty match and an error. - return array(); - } - foreach ($glob as $file) { - if (is_file($file)) { - $fileName = basename($file); - $id = $this->_fileNameToId($fileName); - $metadatas = $this->_getMetadatas($id); - if ($metadatas === FALSE) { - continue; - } - if (time() > $metadatas['expire']) { - continue; - } - switch ($mode) { - case 'ids': - $result[] = $id; - break; - case 'tags': - $result = array_unique(array_merge($result, $metadatas['tags'])); - break; - case 'matching': - $matching = true; - foreach ($tags as $tag) { - if (!in_array($tag, $metadatas['tags'])) { - $matching = false; - break; - } - } - if ($matching) { - $result[] = $id; - } - break; - case 'notMatching': - $matching = false; - foreach ($tags as $tag) { - if (in_array($tag, $metadatas['tags'])) { - $matching = true; - break; - } - } - if (!$matching) { - $result[] = $id; - } - break; - case 'matchingAny': - $matching = false; - foreach ($tags as $tag) { - if (in_array($tag, $metadatas['tags'])) { - $matching = true; - break; - } - } - if ($matching) { - $result[] = $id; - } - break; - default: - Zend_Cache::throwException('Invalid mode for _get() method'); - break; - } - } - if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) { - // Recursive call - $recursiveRs = $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags); - if ($recursiveRs === false) { - $this->_log('Zend_Cache_Backend_File::_get() / recursive call : can\'t list entries of "'.$file.'"'); - } else { - $result = array_unique(array_merge($result, $recursiveRs)); - } - } - } - return array_unique($result); - } - - /** - * Compute & return the expire time - * - * @param int $lifetime - * @return int expire time (unix timestamp) - */ - protected function _expireTime($lifetime) - { - if ($lifetime === null) { - return 9999999999; - } - return time() + $lifetime; - } - - /** - * Make a control key with the string containing datas - * - * @param string $data Data - * @param string $controlType Type of control 'md5', 'crc32' or 'strlen' - * @throws Zend_Cache_Exception - * @return string Control key - */ - protected function _hash($data, $controlType) - { - switch ($controlType) { - case 'md5': - return md5($data); - case 'crc32': - return crc32($data); - case 'strlen': - return strlen($data); - case 'adler32': - return hash('adler32', $data); - default: - Zend_Cache::throwException("Incorrect hash function : $controlType"); - } - } - - /** - * Transform a cache id into a file name and return it - * - * @param string $id Cache id - * @return string File name - */ - protected function _idToFileName($id) - { - $prefix = $this->_options['file_name_prefix']; - $result = $prefix . '---' . $id; - return $result; - } - - /** - * Make and return a file name (with path) - * - * @param string $id Cache id - * @return string File name (with path) - */ - protected function _file($id) - { - $path = $this->_path($id); - $fileName = $this->_idToFileName($id); - return $path . $fileName; - } - - /** - * Return the complete directory path of a filename (including hashedDirectoryStructure) - * - * @param string $id Cache id - * @param boolean $parts if true, returns array of directory parts instead of single string - * @return string Complete directory path - */ - protected function _path($id, $parts = false) - { - $partsArray = array(); - $root = $this->_options['cache_dir']; - $prefix = $this->_options['file_name_prefix']; - if ($this->_options['hashed_directory_level']>0) { - $hash = hash('adler32', $id); - for ($i=0 ; $i < $this->_options['hashed_directory_level'] ; $i++) { - $root = $root . $prefix . '--' . substr($hash, 0, $i + 1) . DIRECTORY_SEPARATOR; - $partsArray[] = $root; - } - } - if ($parts) { - return $partsArray; - } else { - return $root; - } - } - - /** - * Make the directory strucuture for the given id - * - * @param string $id cache id - * @return boolean true - */ - protected function _recursiveMkdirAndChmod($id) - { - if ($this->_options['hashed_directory_level'] <=0) { - return true; - } - $partsArray = $this->_path($id, true); - foreach ($partsArray as $part) { - if (!is_dir($part)) { - @mkdir($part, $this->_options['hashed_directory_perm']); - @chmod($part, $this->_options['hashed_directory_perm']); // see #ZF-320 (this line is required in some configurations) - } - } - return true; - } - - /** - * Test if the given cache id is available (and still valid as a cache record) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return boolean|mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - protected function _test($id, $doNotTestCacheValidity) - { - $metadatas = $this->_getMetadatas($id); - if (!$metadatas) { - return false; - } - if ($doNotTestCacheValidity || (time() <= $metadatas['expire'])) { - return $metadatas['mtime']; - } - return false; - } - - /** - * Return the file content of the given file - * - * @param string $file File complete path - * @return string File content (or false if problem) - */ - protected function _fileGetContents($file) - { - $result = false; - if (!is_file($file)) { - return false; - } - $f = @fopen($file, 'rb'); - if ($f) { - if ($this->_options['file_locking']) @flock($f, LOCK_SH); - $result = stream_get_contents($f); - if ($this->_options['file_locking']) @flock($f, LOCK_UN); - @fclose($f); - } - return $result; - } - - /** - * Put the given string into the given file - * - * @param string $file File complete path - * @param string $string String to put in file - * @return boolean true if no problem - */ - protected function _filePutContents($file, $string) - { - $result = false; - $f = @fopen($file, 'ab+'); - if ($f) { - if ($this->_options['file_locking']) @flock($f, LOCK_EX); - fseek($f, 0); - ftruncate($f, 0); - $tmp = @fwrite($f, $string); - if (!($tmp === FALSE)) { - $result = true; - } - @fclose($f); - } - @chmod($file, $this->_options['cache_file_perm']); - return $result; - } - - /** - * Transform a file name into cache id and return it - * - * @param string $fileName File name - * @return string Cache id - */ - protected function _fileNameToId($fileName) - { - $prefix = $this->_options['file_name_prefix']; - return preg_replace('~^' . $prefix . '---(.*)$~', '$1', $fileName); - } - -} diff --git a/library/vendor/Zend/Cache/Backend/Interface.php b/library/vendor/Zend/Cache/Backend/Interface.php deleted file mode 100644 index 1bd72d8c1..000000000 --- a/library/vendor/Zend/Cache/Backend/Interface.php +++ /dev/null @@ -1,99 +0,0 @@ - infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false); - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id); - - /** - * Clean some cache records - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()); - -} diff --git a/library/vendor/Zend/Cache/Backend/Libmemcached.php b/library/vendor/Zend/Cache/Backend/Libmemcached.php deleted file mode 100644 index ca1f695e6..000000000 --- a/library/vendor/Zend/Cache/Backend/Libmemcached.php +++ /dev/null @@ -1,482 +0,0 @@ - (array) servers : - * an array of memcached server ; each memcached server is described by an associative array : - * 'host' => (string) : the name of the memcached server - * 'port' => (int) : the port of the memcached server - * 'weight' => (int) : number of buckets to create for this server which in turn control its - * probability of it being selected. The probability is relative to the total - * weight of all servers. - * =====> (array) client : - * an array of memcached client options ; the memcached client is described by an associative array : - * @see http://php.net/manual/memcached.constants.php - * - The option name can be the name of the constant without the prefix 'OPT_' - * or the integer value of this option constant - * - * @var array available options - */ - protected $_options = array( - 'servers' => array(array( - 'host' => self::DEFAULT_HOST, - 'port' => self::DEFAULT_PORT, - 'weight' => self::DEFAULT_WEIGHT, - )), - 'client' => array() - ); - - /** - * Memcached object - * - * @var mixed memcached object - */ - protected $_memcache = null; - - /** - * Constructor - * - * @param array $options associative array of options - * @throws Zend_Cache_Exception - * @return void - */ - public function __construct(array $options = array()) - { - if (!extension_loaded('memcached')) { - Zend_Cache::throwException('The memcached extension must be loaded for using this backend !'); - } - - // override default client options - $this->_options['client'] = array( - Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT, - Memcached::OPT_HASH => Memcached::HASH_MD5, - Memcached::OPT_LIBKETAMA_COMPATIBLE => true, - ); - - parent::__construct($options); - - if (isset($this->_options['servers'])) { - $value = $this->_options['servers']; - if (isset($value['host'])) { - // in this case, $value seems to be a simple associative array (one server only) - $value = array(0 => $value); // let's transform it into a classical array of associative arrays - } - $this->setOption('servers', $value); - } - $this->_memcache = new Memcached; - - // setup memcached client options - foreach ($this->_options['client'] as $name => $value) { - $optId = null; - if (is_int($name)) { - $optId = $name; - } else { - $optConst = 'Memcached::OPT_' . strtoupper($name); - if (defined($optConst)) { - $optId = constant($optConst); - } else { - $this->_log("Unknown memcached client option '{$name}' ({$optConst})"); - } - } - if (null !== $optId) { - if (!$this->_memcache->setOption($optId, $value)) { - $this->_log("Setting memcached client option '{$optId}' failed"); - } - } - } - - // setup memcached servers - $servers = array(); - foreach ($this->_options['servers'] as $server) { - if (!array_key_exists('port', $server)) { - $server['port'] = self::DEFAULT_PORT; - } - if (!array_key_exists('weight', $server)) { - $server['weight'] = self::DEFAULT_WEIGHT; - } - - $servers[] = array($server['host'], $server['port'], $server['weight']); - } - $this->_memcache->addServers($servers); - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - $tmp = $this->_memcache->get($id); - if (isset($tmp[0])) { - return $tmp[0]; - } - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id Cache id - * @return int|false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - $tmp = $this->_memcache->get($id); - if (isset($tmp[0], $tmp[1])) { - return (int)$tmp[1]; - } - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean True if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $lifetime = $this->getLifetime($specificLifetime); - - // ZF-8856: using set because add needs a second request if item already exists - $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $lifetime); - if ($result === false) { - $rsCode = $this->_memcache->getResultCode(); - $rsMsg = $this->_memcache->getResultMessage(); - $this->_log("Memcached::set() failed: [{$rsCode}] {$rsMsg}"); - } - - if (count($tags) > 0) { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND); - } - - return $result; - } - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - return $this->_memcache->delete($id); - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => unsupported - * 'matchingTag' => unsupported - * 'notMatchingTag' => unsupported - * 'matchingAnyTag' => unsupported - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @throws Zend_Cache_Exception - * @return boolean True if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - return $this->_memcache->flush(); - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_Libmemcached::clean() : CLEANING_MODE_OLD is unsupported by the Libmemcached backend"); - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_LIBMEMCACHED_BACKEND); - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - - /** - * Return true if the automatic cleaning is available for the backend - * - * @return boolean - */ - public function isAutomaticCleaningAvailable() - { - return false; - } - - /** - * Set the frontend directives - * - * @param array $directives Assoc of directives - * @throws Zend_Cache_Exception - * @return void - */ - public function setDirectives($directives) - { - parent::setDirectives($directives); - $lifetime = $this->getLifetime(false); - if ($lifetime > 2592000) { - // #ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds) - $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime'); - } - if ($lifetime === null) { - // #ZF-4614 : we tranform null to zero to get the maximal lifetime - parent::setDirectives(array('lifetime' => 0)); - } - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - $this->_log("Zend_Cache_Backend_Libmemcached::save() : getting the list of cache ids is unsupported by the Libmemcached backend"); - return array(); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND); - return array(); - } - - /** - * Return the filling percentage of the backend storage - * - * @throws Zend_Cache_Exception - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - $mems = $this->_memcache->getStats(); - if ($mems === false) { - return 0; - } - - $memSize = null; - $memUsed = null; - foreach ($mems as $key => $mem) { - if ($mem === false) { - $this->_log('can\'t get stat from ' . $key); - continue; - } - - $eachSize = $mem['limit_maxbytes']; - $eachUsed = $mem['bytes']; - if ($eachUsed > $eachSize) { - $eachUsed = $eachSize; - } - - $memSize += $eachSize; - $memUsed += $eachUsed; - } - - if ($memSize === null || $memUsed === null) { - Zend_Cache::throwException('Can\'t get filling percentage'); - } - - return ((int) (100. * ($memUsed / $memSize))); - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - $tmp = $this->_memcache->get($id); - if (isset($tmp[0], $tmp[1], $tmp[2])) { - $data = $tmp[0]; - $mtime = $tmp[1]; - $lifetime = $tmp[2]; - return array( - 'expire' => $mtime + $lifetime, - 'tags' => array(), - 'mtime' => $mtime - ); - } - - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - $tmp = $this->_memcache->get($id); - if (isset($tmp[0], $tmp[1], $tmp[2])) { - $data = $tmp[0]; - $mtime = $tmp[1]; - $lifetime = $tmp[2]; - $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime; - if ($newLifetime <=0) { - return false; - } - // #ZF-5702 : we try replace() first becase set() seems to be slower - if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $newLifetime))) { - $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $newLifetime); - if ($result === false) { - $rsCode = $this->_memcache->getResultCode(); - $rsMsg = $this->_memcache->getResultMessage(); - $this->_log("Memcached::set() failed: [{$rsCode}] {$rsMsg}"); - } - } - return $result; - } - return false; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => false, - 'tags' => false, - 'expired_read' => false, - 'priority' => false, - 'infinite_lifetime' => false, - 'get_list' => false - ); - } - -} diff --git a/library/vendor/Zend/Cache/Backend/Memcached.php b/library/vendor/Zend/Cache/Backend/Memcached.php deleted file mode 100644 index 61ddfdc43..000000000 --- a/library/vendor/Zend/Cache/Backend/Memcached.php +++ /dev/null @@ -1,507 +0,0 @@ - (array) servers : - * an array of memcached server ; each memcached server is described by an associative array : - * 'host' => (string) : the name of the memcached server - * 'port' => (int) : the port of the memcached server - * 'persistent' => (bool) : use or not persistent connections to this memcached server - * 'weight' => (int) : number of buckets to create for this server which in turn control its - * probability of it being selected. The probability is relative to the total - * weight of all servers. - * 'timeout' => (int) : value in seconds which will be used for connecting to the daemon. Think twice - * before changing the default value of 1 second - you can lose all the - * advantages of caching if your connection is too slow. - * 'retry_interval' => (int) : controls how often a failed server will be retried, the default value - * is 15 seconds. Setting this parameter to -1 disables automatic retry. - * 'status' => (bool) : controls if the server should be flagged as online. - * 'failure_callback' => (callback) : Allows the user to specify a callback function to run upon - * encountering an error. The callback is run before failover - * is attempted. The function takes two parameters, the hostname - * and port of the failed server. - * - * =====> (boolean) compression : - * true if you want to use on-the-fly compression - * - * =====> (boolean) compatibility : - * true if you use old memcache server or extension - * - * @var array available options - */ - protected $_options = array( - 'servers' => array(array( - 'host' => self::DEFAULT_HOST, - 'port' => self::DEFAULT_PORT, - 'persistent' => self::DEFAULT_PERSISTENT, - 'weight' => self::DEFAULT_WEIGHT, - 'timeout' => self::DEFAULT_TIMEOUT, - 'retry_interval' => self::DEFAULT_RETRY_INTERVAL, - 'status' => self::DEFAULT_STATUS, - 'failure_callback' => self::DEFAULT_FAILURE_CALLBACK - )), - 'compression' => false, - 'compatibility' => false, - ); - - /** - * Memcache object - * - * @var mixed memcache object - */ - protected $_memcache = null; - - /** - * Constructor - * - * @param array $options associative array of options - * @throws Zend_Cache_Exception - * @return void - */ - public function __construct(array $options = array()) - { - if (!extension_loaded('memcache')) { - Zend_Cache::throwException('The memcache extension must be loaded for using this backend !'); - } - parent::__construct($options); - if (isset($this->_options['servers'])) { - $value= $this->_options['servers']; - if (isset($value['host'])) { - // in this case, $value seems to be a simple associative array (one server only) - $value = array(0 => $value); // let's transform it into a classical array of associative arrays - } - $this->setOption('servers', $value); - } - $this->_memcache = new Memcache; - foreach ($this->_options['servers'] as $server) { - if (!array_key_exists('port', $server)) { - $server['port'] = self::DEFAULT_PORT; - } - if (!array_key_exists('persistent', $server)) { - $server['persistent'] = self::DEFAULT_PERSISTENT; - } - if (!array_key_exists('weight', $server)) { - $server['weight'] = self::DEFAULT_WEIGHT; - } - if (!array_key_exists('timeout', $server)) { - $server['timeout'] = self::DEFAULT_TIMEOUT; - } - if (!array_key_exists('retry_interval', $server)) { - $server['retry_interval'] = self::DEFAULT_RETRY_INTERVAL; - } - if (!array_key_exists('status', $server)) { - $server['status'] = self::DEFAULT_STATUS; - } - if (!array_key_exists('failure_callback', $server)) { - $server['failure_callback'] = self::DEFAULT_FAILURE_CALLBACK; - } - if ($this->_options['compatibility']) { - // No status for compatibility mode (#ZF-5887) - $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], - $server['weight'], $server['timeout'], - $server['retry_interval']); - } else { - $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], - $server['weight'], $server['timeout'], - $server['retry_interval'], - $server['status'], $server['failure_callback']); - } - } - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - $tmp = $this->_memcache->get($id); - if (is_array($tmp) && isset($tmp[0])) { - return $tmp[0]; - } - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id Cache id - * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - $tmp = $this->_memcache->get($id); - if (is_array($tmp)) { - return $tmp[1]; - } - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean True if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $lifetime = $this->getLifetime($specificLifetime); - if ($this->_options['compression']) { - $flag = MEMCACHE_COMPRESSED; - } else { - $flag = 0; - } - - // ZF-8856: using set because add needs a second request if item already exists - $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime); - - if (count($tags) > 0) { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND); - } - - return $result; - } - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - return $this->_memcache->delete($id, 0); - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => unsupported - * 'matchingTag' => unsupported - * 'notMatchingTag' => unsupported - * 'matchingAnyTag' => unsupported - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @throws Zend_Cache_Exception - * @return boolean True if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - return $this->_memcache->flush(); - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_Memcached::clean() : CLEANING_MODE_OLD is unsupported by the Memcached backend"); - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_MEMCACHED_BACKEND); - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - - /** - * Return true if the automatic cleaning is available for the backend - * - * @return boolean - */ - public function isAutomaticCleaningAvailable() - { - return false; - } - - /** - * Set the frontend directives - * - * @param array $directives Assoc of directives - * @throws Zend_Cache_Exception - * @return void - */ - public function setDirectives($directives) - { - parent::setDirectives($directives); - $lifetime = $this->getLifetime(false); - if ($lifetime > 2592000) { - // #ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds) - $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime'); - } - if ($lifetime === null) { - // #ZF-4614 : we tranform null to zero to get the maximal lifetime - parent::setDirectives(array('lifetime' => 0)); - } - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - $this->_log("Zend_Cache_Backend_Memcached::save() : getting the list of cache ids is unsupported by the Memcache backend"); - return array(); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND); - return array(); - } - - /** - * Return the filling percentage of the backend storage - * - * @throws Zend_Cache_Exception - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - $mems = $this->_memcache->getExtendedStats(); - - $memSize = null; - $memUsed = null; - foreach ($mems as $key => $mem) { - if ($mem === false) { - $this->_log('can\'t get stat from ' . $key); - continue; - } - - $eachSize = $mem['limit_maxbytes']; - - /** - * Couchbase 1.x uses 'mem_used' instead of 'bytes' - * @see https://www.couchbase.com/issues/browse/MB-3466 - */ - $eachUsed = isset($mem['bytes']) ? $mem['bytes'] : $mem['mem_used']; - if ($eachUsed > $eachSize) { - $eachUsed = $eachSize; - } - - $memSize += $eachSize; - $memUsed += $eachUsed; - } - - if ($memSize === null || $memUsed === null) { - Zend_Cache::throwException('Can\'t get filling percentage'); - } - - return ((int) (100. * ($memUsed / $memSize))); - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - $tmp = $this->_memcache->get($id); - if (is_array($tmp)) { - $data = $tmp[0]; - $mtime = $tmp[1]; - if (!isset($tmp[2])) { - // because this record is only with 1.7 release - // if old cache records are still there... - return false; - } - $lifetime = $tmp[2]; - return array( - 'expire' => $mtime + $lifetime, - 'tags' => array(), - 'mtime' => $mtime - ); - } - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - if ($this->_options['compression']) { - $flag = MEMCACHE_COMPRESSED; - } else { - $flag = 0; - } - $tmp = $this->_memcache->get($id); - if (is_array($tmp)) { - $data = $tmp[0]; - $mtime = $tmp[1]; - if (!isset($tmp[2])) { - // because this record is only with 1.7 release - // if old cache records are still there... - return false; - } - $lifetime = $tmp[2]; - $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime; - if ($newLifetime <=0) { - return false; - } - // #ZF-5702 : we try replace() first becase set() seems to be slower - if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $flag, $newLifetime))) { - $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime); - } - return $result; - } - return false; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => false, - 'tags' => false, - 'expired_read' => false, - 'priority' => false, - 'infinite_lifetime' => false, - 'get_list' => false - ); - } - -} diff --git a/library/vendor/Zend/Cache/Backend/Sqlite.php b/library/vendor/Zend/Cache/Backend/Sqlite.php deleted file mode 100644 index fa6be7db5..000000000 --- a/library/vendor/Zend/Cache/Backend/Sqlite.php +++ /dev/null @@ -1,676 +0,0 @@ - (string) cache_db_complete_path : - * - the complete path (filename included) of the SQLITE database - * - * ====> (int) automatic_vacuum_factor : - * - Disable / Tune the automatic vacuum process - * - The automatic vacuum process defragment the database file (and make it smaller) - * when a clean() or delete() is called - * 0 => no automatic vacuum - * 1 => systematic vacuum (when delete() or clean() methods are called) - * x (integer) > 1 => automatic vacuum randomly 1 times on x clean() or delete() - * - * @var array Available options - */ - protected $_options = array( - 'cache_db_complete_path' => null, - 'automatic_vacuum_factor' => 10 - ); - - /** - * DB ressource - * - * @var mixed $_db - */ - private $_db = null; - - /** - * Boolean to store if the structure has benn checked or not - * - * @var boolean $_structureChecked - */ - private $_structureChecked = false; - - /** - * Constructor - * - * @param array $options Associative array of options - * @throws Zend_cache_Exception - * @return void - */ - public function __construct(array $options = array()) - { - parent::__construct($options); - if ($this->_options['cache_db_complete_path'] === null) { - Zend_Cache::throwException('cache_db_complete_path option has to set'); - } - if (!extension_loaded('sqlite')) { - Zend_Cache::throwException("Cannot use SQLite storage because the 'sqlite' extension is not loaded in the current PHP environment"); - } - $this->_getConnection(); - } - - /** - * Destructor - * - * @return void - */ - public function __destruct() - { - @sqlite_close($this->_getConnection()); - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string|false Cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - $this->_checkAndBuildStructure(); - $sql = "SELECT content FROM cache WHERE id='$id'"; - if (!$doNotTestCacheValidity) { - $sql = $sql . " AND (expire=0 OR expire>" . time() . ')'; - } - $result = $this->_query($sql); - $row = @sqlite_fetch_array($result); - if ($row) { - return $row['content']; - } - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id Cache id - * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - $this->_checkAndBuildStructure(); - $sql = "SELECT lastModified FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')'; - $result = $this->_query($sql); - $row = @sqlite_fetch_array($result); - if ($row) { - return ((int) $row['lastModified']); - } - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @throws Zend_Cache_Exception - * @return boolean True if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $this->_checkAndBuildStructure(); - $lifetime = $this->getLifetime($specificLifetime); - $data = @sqlite_escape_string($data); - $mktime = time(); - if ($lifetime === null) { - $expire = 0; - } else { - $expire = $mktime + $lifetime; - } - $this->_query("DELETE FROM cache WHERE id='$id'"); - $sql = "INSERT INTO cache (id, content, lastModified, expire) VALUES ('$id', '$data', $mktime, $expire)"; - $res = $this->_query($sql); - if (!$res) { - $this->_log("Zend_Cache_Backend_Sqlite::save() : impossible to store the cache id=$id"); - return false; - } - $res = true; - foreach ($tags as $tag) { - $res = $this->_registerTag($id, $tag) && $res; - } - return $res; - } - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - $this->_checkAndBuildStructure(); - $res = $this->_query("SELECT COUNT(*) AS nbr FROM cache WHERE id='$id'"); - $result1 = @sqlite_fetch_single($res); - $result2 = $this->_query("DELETE FROM cache WHERE id='$id'"); - $result3 = $this->_query("DELETE FROM tag WHERE id='$id'"); - $this->_automaticVacuum(); - return ($result1 && $result2 && $result3); - } - - /** - * Clean some cache records - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean True if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - $this->_checkAndBuildStructure(); - $return = $this->_clean($mode, $tags); - $this->_automaticVacuum(); - return $return; - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - $this->_checkAndBuildStructure(); - $res = $this->_query("SELECT id FROM cache WHERE (expire=0 OR expire>" . time() . ")"); - $result = array(); - while ($id = @sqlite_fetch_single($res)) { - $result[] = $id; - } - return $result; - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - $this->_checkAndBuildStructure(); - $res = $this->_query("SELECT DISTINCT(name) AS name FROM tag"); - $result = array(); - while ($id = @sqlite_fetch_single($res)) { - $result[] = $id; - } - return $result; - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - $first = true; - $ids = array(); - foreach ($tags as $tag) { - $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'"); - if (!$res) { - return array(); - } - $rows = @sqlite_fetch_all($res, SQLITE_ASSOC); - $ids2 = array(); - foreach ($rows as $row) { - $ids2[] = $row['id']; - } - if ($first) { - $ids = $ids2; - $first = false; - } else { - $ids = array_intersect($ids, $ids2); - } - } - $result = array(); - foreach ($ids as $id) { - $result[] = $id; - } - return $result; - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - $res = $this->_query("SELECT id FROM cache"); - $rows = @sqlite_fetch_all($res, SQLITE_ASSOC); - $result = array(); - foreach ($rows as $row) { - $id = $row['id']; - $matching = false; - foreach ($tags as $tag) { - $res = $this->_query("SELECT COUNT(*) AS nbr FROM tag WHERE name='$tag' AND id='$id'"); - if (!$res) { - return array(); - } - $nbr = (int) @sqlite_fetch_single($res); - if ($nbr > 0) { - $matching = true; - } - } - if (!$matching) { - $result[] = $id; - } - } - return $result; - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - $first = true; - $ids = array(); - foreach ($tags as $tag) { - $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'"); - if (!$res) { - return array(); - } - $rows = @sqlite_fetch_all($res, SQLITE_ASSOC); - $ids2 = array(); - foreach ($rows as $row) { - $ids2[] = $row['id']; - } - if ($first) { - $ids = $ids2; - $first = false; - } else { - $ids = array_merge($ids, $ids2); - } - } - $result = array(); - foreach ($ids as $id) { - $result[] = $id; - } - return $result; - } - - /** - * Return the filling percentage of the backend storage - * - * @throws Zend_Cache_Exception - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - $dir = dirname($this->_options['cache_db_complete_path']); - $free = disk_free_space($dir); - $total = disk_total_space($dir); - if ($total == 0) { - Zend_Cache::throwException('can\'t get disk_total_space'); - } else { - if ($free >= $total) { - return 100; - } - return ((int) (100. * ($total - $free) / $total)); - } - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - $tags = array(); - $res = $this->_query("SELECT name FROM tag WHERE id='$id'"); - if ($res) { - $rows = @sqlite_fetch_all($res, SQLITE_ASSOC); - foreach ($rows as $row) { - $tags[] = $row['name']; - } - } - $this->_query('CREATE TABLE cache (id TEXT PRIMARY KEY, content BLOB, lastModified INTEGER, expire INTEGER)'); - $res = $this->_query("SELECT lastModified,expire FROM cache WHERE id='$id'"); - if (!$res) { - return false; - } - $row = @sqlite_fetch_array($res, SQLITE_ASSOC); - return array( - 'tags' => $tags, - 'mtime' => $row['lastModified'], - 'expire' => $row['expire'] - ); - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - $sql = "SELECT expire FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')'; - $res = $this->_query($sql); - if (!$res) { - return false; - } - $expire = @sqlite_fetch_single($res); - $newExpire = $expire + $extraLifetime; - $res = $this->_query("UPDATE cache SET lastModified=" . time() . ", expire=$newExpire WHERE id='$id'"); - if ($res) { - return true; - } else { - return false; - } - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => true, - 'tags' => true, - 'expired_read' => true, - 'priority' => false, - 'infinite_lifetime' => true, - 'get_list' => true - ); - } - - /** - * PUBLIC METHOD FOR UNIT TESTING ONLY ! - * - * Force a cache record to expire - * - * @param string $id Cache id - */ - public function ___expire($id) - { - $time = time() - 1; - $this->_query("UPDATE cache SET lastModified=$time, expire=$time WHERE id='$id'"); - } - - /** - * Return the connection resource - * - * If we are not connected, the connection is made - * - * @throws Zend_Cache_Exception - * @return resource Connection resource - */ - private function _getConnection() - { - if (is_resource($this->_db)) { - return $this->_db; - } else { - $this->_db = @sqlite_open($this->_options['cache_db_complete_path']); - if (!(is_resource($this->_db))) { - Zend_Cache::throwException("Impossible to open " . $this->_options['cache_db_complete_path'] . " cache DB file"); - } - return $this->_db; - } - } - - /** - * Execute an SQL query silently - * - * @param string $query SQL query - * @return mixed|false query results - */ - private function _query($query) - { - $db = $this->_getConnection(); - if (is_resource($db)) { - $res = @sqlite_query($db, $query); - if ($res === false) { - return false; - } else { - return $res; - } - } - return false; - } - - /** - * Deal with the automatic vacuum process - * - * @return void - */ - private function _automaticVacuum() - { - if ($this->_options['automatic_vacuum_factor'] > 0) { - $rand = rand(1, $this->_options['automatic_vacuum_factor']); - if ($rand == 1) { - $this->_query('VACUUM'); - } - } - } - - /** - * Register a cache id with the given tag - * - * @param string $id Cache id - * @param string $tag Tag - * @return boolean True if no problem - */ - private function _registerTag($id, $tag) { - $res = $this->_query("DELETE FROM TAG WHERE name='$tag' AND id='$id'"); - $res = $this->_query("INSERT INTO tag (name, id) VALUES ('$tag', '$id')"); - if (!$res) { - $this->_log("Zend_Cache_Backend_Sqlite::_registerTag() : impossible to register tag=$tag on id=$id"); - return false; - } - return true; - } - - /** - * Build the database structure - * - * @return false - */ - private function _buildStructure() - { - $this->_query('DROP INDEX tag_id_index'); - $this->_query('DROP INDEX tag_name_index'); - $this->_query('DROP INDEX cache_id_expire_index'); - $this->_query('DROP TABLE version'); - $this->_query('DROP TABLE cache'); - $this->_query('DROP TABLE tag'); - $this->_query('CREATE TABLE version (num INTEGER PRIMARY KEY)'); - $this->_query('CREATE TABLE cache (id TEXT PRIMARY KEY, content BLOB, lastModified INTEGER, expire INTEGER)'); - $this->_query('CREATE TABLE tag (name TEXT, id TEXT)'); - $this->_query('CREATE INDEX tag_id_index ON tag(id)'); - $this->_query('CREATE INDEX tag_name_index ON tag(name)'); - $this->_query('CREATE INDEX cache_id_expire_index ON cache(id, expire)'); - $this->_query('INSERT INTO version (num) VALUES (1)'); - } - - /** - * Check if the database structure is ok (with the good version) - * - * @return boolean True if ok - */ - private function _checkStructureVersion() - { - $result = $this->_query("SELECT num FROM version"); - if (!$result) return false; - $row = @sqlite_fetch_array($result); - if (!$row) { - return false; - } - if (((int) $row['num']) != 1) { - // old cache structure - $this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped'); - return false; - } - return true; - } - - /** - * Clean some cache records - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean True if no problem - */ - private function _clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - $res1 = $this->_query('DELETE FROM cache'); - $res2 = $this->_query('DELETE FROM tag'); - return $res1 && $res2; - break; - case Zend_Cache::CLEANING_MODE_OLD: - $mktime = time(); - $res1 = $this->_query("DELETE FROM tag WHERE id IN (SELECT id FROM cache WHERE expire>0 AND expire<=$mktime)"); - $res2 = $this->_query("DELETE FROM cache WHERE expire>0 AND expire<=$mktime"); - return $res1 && $res2; - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - $ids = $this->getIdsMatchingTags($tags); - $result = true; - foreach ($ids as $id) { - $result = $this->remove($id) && $result; - } - return $result; - break; - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - $ids = $this->getIdsNotMatchingTags($tags); - $result = true; - foreach ($ids as $id) { - $result = $this->remove($id) && $result; - } - return $result; - break; - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $ids = $this->getIdsMatchingAnyTags($tags); - $result = true; - foreach ($ids as $id) { - $result = $this->remove($id) && $result; - } - return $result; - break; - default: - break; - } - return false; - } - - /** - * Check if the database structure is ok (with the good version), if no : build it - * - * @throws Zend_Cache_Exception - * @return boolean True if ok - */ - private function _checkAndBuildStructure() - { - if (!($this->_structureChecked)) { - if (!$this->_checkStructureVersion()) { - $this->_buildStructure(); - if (!$this->_checkStructureVersion()) { - Zend_Cache::throwException("Impossible to build cache structure in " . $this->_options['cache_db_complete_path']); - } - } - $this->_structureChecked = true; - } - return true; - } - -} diff --git a/library/vendor/Zend/Cache/Backend/Static.php b/library/vendor/Zend/Cache/Backend/Static.php deleted file mode 100644 index 920302089..000000000 --- a/library/vendor/Zend/Cache/Backend/Static.php +++ /dev/null @@ -1,577 +0,0 @@ - null, - 'sub_dir' => 'html', - 'file_extension' => '.html', - 'index_filename' => 'index', - 'file_locking' => true, - 'cache_file_perm' => 0600, - 'cache_directory_perm' => 0700, - 'debug_header' => false, - 'tag_cache' => null, - 'disable_caching' => false - ); - - /** - * Cache for handling tags - * @var Zend_Cache_Core - */ - protected $_tagCache = null; - - /** - * Tagged items - * @var array - */ - protected $_tagged = null; - - /** - * Interceptor child method to handle the case where an Inner - * Cache object is being set since it's not supported by the - * standard backend interface - * - * @param string $name - * @param mixed $value - * @return Zend_Cache_Backend_Static - */ - public function setOption($name, $value) - { - if ($name == 'tag_cache') { - $this->setInnerCache($value); - } else { - // See #ZF-12047 and #GH-91 - if ($name == 'cache_file_umask') { - trigger_error( - "'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", - E_USER_NOTICE - ); - - $name = 'cache_file_perm'; - } - if ($name == 'cache_directory_umask') { - trigger_error( - "'cache_directory_umask' is deprecated -> please use 'cache_directory_perm' instead", - E_USER_NOTICE - ); - - $name = 'cache_directory_perm'; - } - - parent::setOption($name, $value); - } - return $this; - } - - /** - * Retrieve any option via interception of the parent's statically held - * options including the local option for a tag cache. - * - * @param string $name - * @return mixed - */ - public function getOption($name) - { - $name = strtolower($name); - - if ($name == 'tag_cache') { - return $this->getInnerCache(); - } - - return parent::getOption($name); - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * Note : return value is always "string" (unserialization is done by the core not by the backend) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - if (($id = (string)$id) === '') { - $id = $this->_detectId(); - } else { - $id = $this->_decodeId($id); - } - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - if ($doNotTestCacheValidity) { - $this->_log("Zend_Cache_Backend_Static::load() : \$doNotTestCacheValidity=true is unsupported by the Static backend"); - } - - $fileName = basename($id); - if ($fileName === '') { - $fileName = $this->_options['index_filename']; - } - $pathName = $this->_options['public_dir'] . dirname($id); - $file = rtrim($pathName, '/') . '/' . $fileName . $this->_options['file_extension']; - if (file_exists($file)) { - $content = file_get_contents($file); - return $content; - } - - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return bool - */ - public function test($id) - { - $id = $this->_decodeId($id); - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - - $fileName = basename($id); - if ($fileName === '') { - $fileName = $this->_options['index_filename']; - } - if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif (!$this->_tagged) { - return false; - } - $pathName = $this->_options['public_dir'] . dirname($id); - - // Switch extension if needed - if (isset($this->_tagged[$id])) { - $extension = $this->_tagged[$id]['extension']; - } else { - $extension = $this->_options['file_extension']; - } - $file = $pathName . '/' . $fileName . $extension; - if (file_exists($file)) { - return true; - } - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - if ($this->_options['disable_caching']) { - return true; - } - $extension = null; - if ($this->_isSerialized($data)) { - $data = unserialize($data); - $extension = '.' . ltrim($data[1], '.'); - $data = $data[0]; - } - - clearstatcache(); - if (($id = (string)$id) === '') { - $id = $this->_detectId(); - } else { - $id = $this->_decodeId($id); - } - - $fileName = basename($id); - if ($fileName === '') { - $fileName = $this->_options['index_filename']; - } - - $pathName = realpath($this->_options['public_dir']) . dirname($id); - $this->_createDirectoriesFor($pathName); - - if ($id === null || strlen($id) == 0) { - $dataUnserialized = unserialize($data); - $data = $dataUnserialized['data']; - } - $ext = $this->_options['file_extension']; - if ($extension) $ext = $extension; - $file = rtrim($pathName, '/') . '/' . $fileName . $ext; - if ($this->_options['file_locking']) { - $result = file_put_contents($file, $data, LOCK_EX); - } else { - $result = file_put_contents($file, $data); - } - @chmod($file, $this->_octdec($this->_options['cache_file_perm'])); - - if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif ($this->_tagged === null) { - $this->_tagged = array(); - } - if (!isset($this->_tagged[$id])) { - $this->_tagged[$id] = array(); - } - if (!isset($this->_tagged[$id]['tags'])) { - $this->_tagged[$id]['tags'] = array(); - } - $this->_tagged[$id]['tags'] = array_unique(array_merge($this->_tagged[$id]['tags'], $tags)); - $this->_tagged[$id]['extension'] = $ext; - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - return (bool) $result; - } - - /** - * Recursively create the directories needed to write the static file - */ - protected function _createDirectoriesFor($path) - { - if (!is_dir($path)) { - $oldUmask = umask(0); - if ( !@mkdir($path, $this->_octdec($this->_options['cache_directory_perm']), true)) { - $lastErr = error_get_last(); - umask($oldUmask); - Zend_Cache::throwException("Can't create directory: {$lastErr['message']}"); - } - umask($oldUmask); - } - } - - /** - * Detect serialization of data (cannot predict since this is the only way - * to obey the interface yet pass in another parameter). - * - * In future, ZF 2.0, check if we can just avoid the interface restraints. - * - * This format is the only valid one possible for the class, so it's simple - * to just run a regular expression for the starting serialized format. - */ - protected function _isSerialized($data) - { - return preg_match("/a:2:\{i:0;s:\d+:\"/", $data); - } - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - $fileName = basename($id); - if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif (!$this->_tagged) { - return false; - } - if (isset($this->_tagged[$id])) { - $extension = $this->_tagged[$id]['extension']; - } else { - $extension = $this->_options['file_extension']; - } - if ($fileName === '') { - $fileName = $this->_options['index_filename']; - } - $pathName = $this->_options['public_dir'] . dirname($id); - $file = realpath($pathName) . '/' . $fileName . $extension; - if (!file_exists($file)) { - return false; - } - return unlink($file); - } - - /** - * Remove a cache record recursively for the given directory matching a - * REQUEST_URI based relative path (deletes the actual file matching this - * in addition to the matching directory) - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function removeRecursively($id) - { - if (!$this->_verifyPath($id)) { - Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path'); - } - $fileName = basename($id); - if ($fileName === '') { - $fileName = $this->_options['index_filename']; - } - $pathName = $this->_options['public_dir'] . dirname($id); - $file = $pathName . '/' . $fileName . $this->_options['file_extension']; - $directory = $pathName . '/' . $fileName; - if (file_exists($directory)) { - if (!is_writable($directory)) { - return false; - } - if (is_dir($directory)) { - foreach (new DirectoryIterator($directory) as $file) { - if (true === $file->isFile()) { - if (false === unlink($file->getPathName())) { - return false; - } - } - } - } - rmdir($directory); - } - if (file_exists($file)) { - if (!is_writable($file)) { - return false; - } - return unlink($file); - } - return true; - } - - /** - * Clean some cache records - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean true if no problem - * @throws Zend_Exception - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - $result = false; - switch ($mode) { - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - if (empty($tags)) { - throw new Zend_Exception('Cannot use tag matching modes as no tags were defined'); - } - if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) { - $this->_tagged = $tagged; - } elseif (!$this->_tagged) { - return true; - } - foreach ($tags as $tag) { - $urls = array_keys($this->_tagged); - foreach ($urls as $url) { - if (isset($this->_tagged[$url]['tags']) && in_array($tag, $this->_tagged[$url]['tags'])) { - $this->remove($url); - unset($this->_tagged[$url]); - } - } - } - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - $result = true; - break; - case Zend_Cache::CLEANING_MODE_ALL: - if ($this->_tagged === null) { - $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME); - $this->_tagged = $tagged; - } - if ($this->_tagged === null || empty($this->_tagged)) { - return true; - } - $urls = array_keys($this->_tagged); - foreach ($urls as $url) { - $this->remove($url); - unset($this->_tagged[$url]); - } - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - $result = true; - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_Static : Selected Cleaning Mode Currently Unsupported By This Backend"); - break; - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - if (empty($tags)) { - throw new Zend_Exception('Cannot use tag matching modes as no tags were defined'); - } - if ($this->_tagged === null) { - $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME); - $this->_tagged = $tagged; - } - if ($this->_tagged === null || empty($this->_tagged)) { - return true; - } - $urls = array_keys($this->_tagged); - foreach ($urls as $url) { - $difference = array_diff($tags, $this->_tagged[$url]['tags']); - if (count($tags) == count($difference)) { - $this->remove($url); - unset($this->_tagged[$url]); - } - } - $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME); - $result = true; - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - return $result; - } - - /** - * Set an Inner Cache, used here primarily to store Tags associated - * with caches created by this backend. Note: If Tags are lost, the cache - * should be completely cleaned as the mapping of tags to caches will - * have been irrevocably lost. - * - * @param Zend_Cache_Core - * @return void - */ - public function setInnerCache(Zend_Cache_Core $cache) - { - $this->_tagCache = $cache; - $this->_options['tag_cache'] = $cache; - } - - /** - * Get the Inner Cache if set - * - * @return Zend_Cache_Core - */ - public function getInnerCache() - { - if ($this->_tagCache === null) { - Zend_Cache::throwException('An Inner Cache has not been set; use setInnerCache()'); - } - return $this->_tagCache; - } - - /** - * Verify path exists and is non-empty - * - * @param string $path - * @return bool - */ - protected function _verifyPath($path) - { - $path = realpath($path); - $base = realpath($this->_options['public_dir']); - return strncmp($path, $base, strlen($base)) !== 0; - } - - /** - * Determine the page to save from the request - * - * @return string - */ - protected function _detectId() - { - return $_SERVER['REQUEST_URI']; - } - - /** - * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...) - * - * Throw an exception if a problem is found - * - * @param string $string Cache id or tag - * @throws Zend_Cache_Exception - * @return void - * @deprecated Not usable until perhaps ZF 2.0 - */ - protected static function _validateIdOrTag($string) - { - if (!is_string($string)) { - Zend_Cache::throwException('Invalid id or tag : must be a string'); - } - - // Internal only checked in Frontend - not here! - if (substr($string, 0, 9) == 'internal-') { - return; - } - - // Validation assumes no query string, fragments or scheme included - only the path - if (!preg_match( - '/^(?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*\'()\[\]:@&=+$,;])*)?)+$/', - $string - ) - ) { - Zend_Cache::throwException("Invalid id or tag '$string' : must be a valid URL path"); - } - } - - /** - * Detect an octal string and return its octal value for file permission ops - * otherwise return the non-string (assumed octal or decimal int already) - * - * @param string $val The potential octal in need of conversion - * @return int - */ - protected function _octdec($val) - { - if (is_string($val) && decoct(octdec($val)) == $val) { - return octdec($val); - } - return $val; - } - - /** - * Decode a request URI from the provided ID - * - * @param string $id - * @return string - */ - protected function _decodeId($id) - { - return pack('H*', $id); - } -} diff --git a/library/vendor/Zend/Cache/Backend/Test.php b/library/vendor/Zend/Cache/Backend/Test.php deleted file mode 100644 index c06f95954..000000000 --- a/library/vendor/Zend/Cache/Backend/Test.php +++ /dev/null @@ -1,414 +0,0 @@ -_addLog('construct', array($options)); - } - - /** - * Set the frontend directives - * - * @param array $directives assoc of directives - * @return void - */ - public function setDirectives($directives) - { - $this->_addLog('setDirectives', array($directives)); - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * For this test backend only, if $id == 'false', then the method will return false - * if $id == 'serialized', the method will return a serialized array - * ('foo' else) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string Cached datas (or false) - */ - public function load($id, $doNotTestCacheValidity = false) - { - $this->_addLog('get', array($id, $doNotTestCacheValidity)); - - if ( $id == 'false' - || $id == 'd8523b3ee441006261eeffa5c3d3a0a7' - || $id == 'e83249ea22178277d5befc2c5e2e9ace' - || $id == '40f649b94977c0a6e76902e2a0b43587' - || $id == '88161989b73a4cbfd0b701c446115a99' - || $id == '205fc79cba24f0f0018eb92c7c8b3ba4' - || $id == '170720e35f38150b811f68a937fb042d') - { - return false; - } - if ($id=='serialized') { - return serialize(array('foo')); - } - if ($id=='serialized2') { - return serialize(array('headers' => array(), 'data' => 'foo')); - } - if ( $id == '71769f39054f75894288e397df04e445' || $id == '615d222619fb20b527168340cebd0578' - || $id == '8a02d218a5165c467e7a5747cc6bd4b6' || $id == '648aca1366211d17cbf48e65dc570bee' - || $id == '4a923ef02d7f997ca14d56dfeae25ea7') { - return serialize(array('foo', 'bar')); - } - if ( $id == 'f53c7d912cc523d9a65834c8286eceb9') { - return serialize(array('foobar')); - } - return 'foo'; - } - - /** - * Test if a cache is available or not (for the given id) - * - * For this test backend only, if $id == 'false', then the method will return false - * (123456 else) - * - * @param string $id Cache id - * @return mixed|false false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - $this->_addLog('test', array($id)); - if ($id=='false') { - return false; - } - if (($id=='3c439c922209e2cb0b54d6deffccd75a')) { - return false; - } - return 123456; - } - - /** - * Save some string datas into a cache record - * - * For this test backend only, if $id == 'false', then the method will return false - * (true else) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean True if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $this->_addLog('save', array($data, $id, $tags)); - if (substr($id,-5)=='false') { - return false; - } - return true; - } - - /** - * Remove a cache record - * - * For this test backend only, if $id == 'false', then the method will return false - * (true else) - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - $this->_addLog('remove', array($id)); - if (substr($id,-5)=='false') { - return false; - } - return true; - } - - /** - * Clean some cache records - * - * For this test backend only, if $mode == 'false', then the method will return false - * (true else) - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean True if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - $this->_addLog('clean', array($mode, $tags)); - if ($mode=='false') { - return false; - } - return true; - } - - /** - * Get the last log - * - * @return string The last log - */ - public function getLastLog() - { - return $this->_log[$this->_index - 1]; - } - - /** - * Get the log index - * - * @return int Log index - */ - public function getLogIndex() - { - return $this->_index; - } - - /** - * Get the complete log array - * - * @return array Complete log array - */ - public function getAllLogs() - { - return $this->_log; - } - - /** - * Return true if the automatic cleaning is available for the backend - * - * @return boolean - */ - public function isAutomaticCleaningAvailable() - { - return true; - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - return array( - 'prefix_id1', 'prefix_id2' - ); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - return array( - 'tag1', 'tag2' - ); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - if ($tags == array('tag1', 'tag2')) { - return array('prefix_id1', 'prefix_id2'); - } - - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - if ($tags == array('tag3', 'tag4')) { - return array('prefix_id3', 'prefix_id4'); - } - - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - if ($tags == array('tag5', 'tag6')) { - return array('prefix_id5', 'prefix_id6'); - } - - return array(); - } - - /** - * Return the filling percentage of the backend storage - * - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - return 50; - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - return true; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => true, - 'tags' => true, - 'expired_read' => false, - 'priority' => true, - 'infinite_lifetime' => true, - 'get_list' => true - ); - } - - /** - * Add an event to the log array - * - * @param string $methodName MethodName - * @param array $args Arguments - * @return void - */ - private function _addLog($methodName, $args) - { - $this->_log[$this->_index] = array( - 'methodName' => $methodName, - 'args' => $args - ); - $this->_index = $this->_index + 1; - } - -} diff --git a/library/vendor/Zend/Cache/Backend/TwoLevels.php b/library/vendor/Zend/Cache/Backend/TwoLevels.php deleted file mode 100644 index 1e6792b31..000000000 --- a/library/vendor/Zend/Cache/Backend/TwoLevels.php +++ /dev/null @@ -1,546 +0,0 @@ - (string) slow_backend : - * - Slow backend name - * - Must implement the Zend_Cache_Backend_ExtendedInterface - * - Should provide a big storage - * - * =====> (string) fast_backend : - * - Flow backend name - * - Must implement the Zend_Cache_Backend_ExtendedInterface - * - Must be much faster than slow_backend - * - * =====> (array) slow_backend_options : - * - Slow backend options (see corresponding backend) - * - * =====> (array) fast_backend_options : - * - Fast backend options (see corresponding backend) - * - * =====> (int) stats_update_factor : - * - Disable / Tune the computation of the fast backend filling percentage - * - When saving a record into cache : - * 1 => systematic computation of the fast backend filling percentage - * x (integer) > 1 => computation of the fast backend filling percentage randomly 1 times on x cache write - * - * =====> (boolean) slow_backend_custom_naming : - * =====> (boolean) fast_backend_custom_naming : - * =====> (boolean) slow_backend_autoload : - * =====> (boolean) fast_backend_autoload : - * - See Zend_Cache::factory() method - * - * =====> (boolean) auto_fill_fast_cache - * - If true, automatically fill the fast cache when a cache record was not found in fast cache, but did - * exist in slow cache. This can be usefull when a non-persistent cache like APC or Memcached got - * purged for whatever reason. - * - * =====> (boolean) auto_refresh_fast_cache - * - If true, auto refresh the fast cache when a cache record is hit - * - * @var array available options - */ - protected $_options = array( - 'slow_backend' => 'File', - 'fast_backend' => 'Apc', - 'slow_backend_options' => array(), - 'fast_backend_options' => array(), - 'stats_update_factor' => 10, - 'slow_backend_custom_naming' => false, - 'fast_backend_custom_naming' => false, - 'slow_backend_autoload' => false, - 'fast_backend_autoload' => false, - 'auto_fill_fast_cache' => true, - 'auto_refresh_fast_cache' => true - ); - - /** - * Slow Backend - * - * @var Zend_Cache_Backend_ExtendedInterface - */ - protected $_slowBackend; - - /** - * Fast Backend - * - * @var Zend_Cache_Backend_ExtendedInterface - */ - protected $_fastBackend; - - /** - * Cache for the fast backend filling percentage - * - * @var int - */ - protected $_fastBackendFillingPercentage = null; - - /** - * Constructor - * - * @param array $options Associative array of options - * @throws Zend_Cache_Exception - * @return void - */ - public function __construct(array $options = array()) - { - parent::__construct($options); - - if ($this->_options['slow_backend'] === null) { - Zend_Cache::throwException('slow_backend option has to set'); - } elseif ($this->_options['slow_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) { - $this->_slowBackend = $this->_options['slow_backend']; - } else { - $this->_slowBackend = Zend_Cache::_makeBackend( - $this->_options['slow_backend'], - $this->_options['slow_backend_options'], - $this->_options['slow_backend_custom_naming'], - $this->_options['slow_backend_autoload'] - ); - if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) { - Zend_Cache::throwException('slow_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); - } - } - - if ($this->_options['fast_backend'] === null) { - Zend_Cache::throwException('fast_backend option has to set'); - } elseif ($this->_options['fast_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) { - $this->_fastBackend = $this->_options['fast_backend']; - } else { - $this->_fastBackend = Zend_Cache::_makeBackend( - $this->_options['fast_backend'], - $this->_options['fast_backend_options'], - $this->_options['fast_backend_custom_naming'], - $this->_options['fast_backend_autoload'] - ); - if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) { - Zend_Cache::throwException('fast_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); - } - } - - $this->_slowBackend->setDirectives($this->_directives); - $this->_fastBackend->setDirectives($this->_directives); - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - $fastTest = $this->_fastBackend->test($id); - if ($fastTest) { - return $fastTest; - } else { - return $this->_slowBackend->test($id); - } - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false, $priority = 8) - { - $usage = $this->_getFastFillingPercentage('saving'); - $boolFast = true; - $lifetime = $this->getLifetime($specificLifetime); - $preparedData = $this->_prepareData($data, $lifetime, $priority); - if (($priority > 0) && (10 * $priority >= $usage)) { - $fastLifetime = $this->_getFastLifetime($lifetime, $priority); - $boolFast = $this->_fastBackend->save($preparedData, $id, array(), $fastLifetime); - $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime); - } else { - $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime); - if ($boolSlow === true) { - $boolFast = $this->_fastBackend->remove($id); - if (!$boolFast && !$this->_fastBackend->test($id)) { - // some backends return false on remove() even if the key never existed. (and it won't if fast is full) - // all we care about is that the key doesn't exist now - $boolFast = true; - } - } - } - - return ($boolFast && $boolSlow); - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * Note : return value is always "string" (unserialization is done by the core not by the backend) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @return string|false cached datas - */ - public function load($id, $doNotTestCacheValidity = false) - { - $resultFast = $this->_fastBackend->load($id, $doNotTestCacheValidity); - if ($resultFast === false) { - $resultSlow = $this->_slowBackend->load($id, $doNotTestCacheValidity); - if ($resultSlow === false) { - // there is no cache at all for this id - return false; - } - } - $array = $resultFast !== false ? unserialize($resultFast) : unserialize($resultSlow); - - //In case no cache entry was found in the FastCache and auto-filling is enabled, copy data to FastCache - if ($resultFast === false && $this->_options['auto_fill_fast_cache']) { - $preparedData = $this->_prepareData($array['data'], $array['lifetime'], $array['priority']); - $this->_fastBackend->save($preparedData, $id, array(), $array['lifetime']); - } - // maybe, we have to refresh the fast cache ? - elseif ($this->_options['auto_refresh_fast_cache']) { - if ($array['priority'] == 10) { - // no need to refresh the fast cache with priority = 10 - return $array['data']; - } - $newFastLifetime = $this->_getFastLifetime($array['lifetime'], $array['priority'], time() - $array['expire']); - // we have the time to refresh the fast cache - $usage = $this->_getFastFillingPercentage('loading'); - if (($array['priority'] > 0) && (10 * $array['priority'] >= $usage)) { - // we can refresh the fast cache - $preparedData = $this->_prepareData($array['data'], $array['lifetime'], $array['priority']); - $this->_fastBackend->save($preparedData, $id, array(), $newFastLifetime); - } - } - return $array['data']; - } - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - $boolFast = $this->_fastBackend->remove($id); - $boolSlow = $this->_slowBackend->remove($id); - return $boolFast && $boolSlow; - } - - /** - * Clean some cache records - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @throws Zend_Cache_Exception - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - $boolFast = $this->_fastBackend->clean(Zend_Cache::CLEANING_MODE_ALL); - $boolSlow = $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_ALL); - return $boolFast && $boolSlow; - break; - case Zend_Cache::CLEANING_MODE_OLD: - return $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_OLD); - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - $ids = $this->_slowBackend->getIdsMatchingTags($tags); - $res = true; - foreach ($ids as $id) { - $bool = $this->remove($id); - $res = $res && $bool; - } - return $res; - break; - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - $ids = $this->_slowBackend->getIdsNotMatchingTags($tags); - $res = true; - foreach ($ids as $id) { - $bool = $this->remove($id); - $res = $res && $bool; - } - return $res; - break; - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $ids = $this->_slowBackend->getIdsMatchingAnyTags($tags); - $res = true; - foreach ($ids as $id) { - $bool = $this->remove($id); - $res = $res && $bool; - } - return $res; - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - return $this->_slowBackend->getIds(); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - return $this->_slowBackend->getTags(); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - return $this->_slowBackend->getIdsMatchingTags($tags); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - return $this->_slowBackend->getIdsNotMatchingTags($tags); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - return $this->_slowBackend->getIdsMatchingAnyTags($tags); - } - - /** - * Return the filling percentage of the backend storage - * - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - return $this->_slowBackend->getFillingPercentage(); - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - return $this->_slowBackend->getMetadatas($id); - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - return $this->_slowBackend->touch($id, $extraLifetime); - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - $slowBackendCapabilities = $this->_slowBackend->getCapabilities(); - return array( - 'automatic_cleaning' => $slowBackendCapabilities['automatic_cleaning'], - 'tags' => $slowBackendCapabilities['tags'], - 'expired_read' => $slowBackendCapabilities['expired_read'], - 'priority' => $slowBackendCapabilities['priority'], - 'infinite_lifetime' => $slowBackendCapabilities['infinite_lifetime'], - 'get_list' => $slowBackendCapabilities['get_list'] - ); - } - - /** - * Prepare a serialized array to store datas and metadatas informations - * - * @param string $data data to store - * @param int $lifetime original lifetime - * @param int $priority priority - * @return string serialize array to store into cache - */ - private function _prepareData($data, $lifetime, $priority) - { - $lt = $lifetime; - if ($lt === null) { - $lt = 9999999999; - } - return serialize(array( - 'data' => $data, - 'lifetime' => $lifetime, - 'expire' => time() + $lt, - 'priority' => $priority - )); - } - - /** - * Compute and return the lifetime for the fast backend - * - * @param int $lifetime original lifetime - * @param int $priority priority - * @param int $maxLifetime maximum lifetime - * @return int lifetime for the fast backend - */ - private function _getFastLifetime($lifetime, $priority, $maxLifetime = null) - { - if ($lifetime <= 0) { - // if no lifetime, we have an infinite lifetime - // we need to use arbitrary lifetimes - $fastLifetime = (int) (2592000 / (11 - $priority)); - } else { - // prevent computed infinite lifetime (0) by ceil - $fastLifetime = (int) ceil($lifetime / (11 - $priority)); - } - - if ($maxLifetime >= 0 && $fastLifetime > $maxLifetime) { - return $maxLifetime; - } - - return $fastLifetime; - } - - /** - * PUBLIC METHOD FOR UNIT TESTING ONLY ! - * - * Force a cache record to expire - * - * @param string $id cache id - */ - public function ___expire($id) - { - $this->_fastBackend->remove($id); - $this->_slowBackend->___expire($id); - } - - private function _getFastFillingPercentage($mode) - { - - if ($mode == 'saving') { - // mode saving - if ($this->_fastBackendFillingPercentage === null) { - $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage(); - } else { - $rand = rand(1, $this->_options['stats_update_factor']); - if ($rand == 1) { - // we force a refresh - $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage(); - } - } - } else { - // mode loading - // we compute the percentage only if it's not available in cache - if ($this->_fastBackendFillingPercentage === null) { - $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage(); - } - } - return $this->_fastBackendFillingPercentage; - } - -} diff --git a/library/vendor/Zend/Cache/Backend/WinCache.php b/library/vendor/Zend/Cache/Backend/WinCache.php deleted file mode 100644 index c922280bb..000000000 --- a/library/vendor/Zend/Cache/Backend/WinCache.php +++ /dev/null @@ -1,347 +0,0 @@ - infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $lifetime = $this->getLifetime($specificLifetime); - $result = wincache_ucache_set($id, array($data, time(), $lifetime), $lifetime); - if (count($tags) > 0) { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND); - } - return $result; - } - - /** - * Remove a cache record - * - * @param string $id cache id - * @return boolean true if no problem - */ - public function remove($id) - { - return wincache_ucache_delete($id); - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => unsupported - * 'matchingTag' => unsupported - * 'notMatchingTag' => unsupported - * 'matchingAnyTag' => unsupported - * - * @param string $mode clean mode - * @param array $tags array of tags - * @throws Zend_Cache_Exception - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - return wincache_ucache_clear(); - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_WinCache::clean() : CLEANING_MODE_OLD is unsupported by the WinCache backend"); - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND); - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - - /** - * Return true if the automatic cleaning is available for the backend - * - * DEPRECATED : use getCapabilities() instead - * - * @deprecated - * @return boolean - */ - public function isAutomaticCleaningAvailable() - { - return false; - } - - /** - * Return the filling percentage of the backend storage - * - * @throws Zend_Cache_Exception - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - $mem = wincache_ucache_meminfo(); - $memSize = $mem['memory_total']; - $memUsed = $memSize - $mem['memory_free']; - if ($memSize == 0) { - Zend_Cache::throwException('can\'t get WinCache memory size'); - } - if ($memUsed > $memSize) { - return 100; - } - return ((int) (100. * ($memUsed / $memSize))); - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND); - return array(); - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - $res = array(); - $array = wincache_ucache_info(); - $records = $array['ucache_entries']; - foreach ($records as $record) { - $res[] = $record['key_name']; - } - return $res; - } - - /** - * Return an array of metadatas for the given cache id - * - * The array must include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - $tmp = wincache_ucache_get($id); - if (is_array($tmp)) { - $data = $tmp[0]; - $mtime = $tmp[1]; - if (!isset($tmp[2])) { - return false; - } - $lifetime = $tmp[2]; - return array( - 'expire' => $mtime + $lifetime, - 'tags' => array(), - 'mtime' => $mtime - ); - } - return false; - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - $tmp = wincache_ucache_get($id); - if (is_array($tmp)) { - $data = $tmp[0]; - $mtime = $tmp[1]; - if (!isset($tmp[2])) { - return false; - } - $lifetime = $tmp[2]; - $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime; - if ($newLifetime <=0) { - return false; - } - return wincache_ucache_set($id, array($data, time(), $newLifetime), $newLifetime); - } - return false; - } - - /** - * Return an associative array of capabilities (booleans) of the backend - * - * The array must include these keys : - * - automatic_cleaning (is automating cleaning necessary) - * - tags (are tags supported) - * - expired_read (is it possible to read expired cache records - * (for doNotTestCacheValidity option for example)) - * - priority does the backend deal with priority when saving - * - infinite_lifetime (is infinite lifetime can work with this backend) - * - get_list (is it possible to get the list of cache ids and the complete list of tags) - * - * @return array associative of with capabilities - */ - public function getCapabilities() - { - return array( - 'automatic_cleaning' => false, - 'tags' => false, - 'expired_read' => false, - 'priority' => false, - 'infinite_lifetime' => false, - 'get_list' => true - ); - } - -} diff --git a/library/vendor/Zend/Cache/Backend/Xcache.php b/library/vendor/Zend/Cache/Backend/Xcache.php deleted file mode 100644 index d78d52d8c..000000000 --- a/library/vendor/Zend/Cache/Backend/Xcache.php +++ /dev/null @@ -1,219 +0,0 @@ - (string) user : - * xcache.admin.user (necessary for the clean() method) - * - * =====> (string) password : - * xcache.admin.pass (clear, not MD5) (necessary for the clean() method) - * - * @var array available options - */ - protected $_options = array( - 'user' => null, - 'password' => null - ); - - /** - * Constructor - * - * @param array $options associative array of options - * @throws Zend_Cache_Exception - * @return void - */ - public function __construct(array $options = array()) - { - if (!extension_loaded('xcache')) { - Zend_Cache::throwException('The xcache extension must be loaded for using this backend !'); - } - parent::__construct($options); - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * WARNING $doNotTestCacheValidity=true is unsupported by the Xcache backend - * - * @param string $id cache id - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return string cached datas (or false) - */ - public function load($id, $doNotTestCacheValidity = false) - { - if ($doNotTestCacheValidity) { - $this->_log("Zend_Cache_Backend_Xcache::load() : \$doNotTestCacheValidity=true is unsupported by the Xcache backend"); - } - $tmp = xcache_get($id); - if (is_array($tmp)) { - return $tmp[0]; - } - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - if (xcache_isset($id)) { - $tmp = xcache_get($id); - if (is_array($tmp)) { - return $tmp[1]; - } - } - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data datas to cache - * @param string $id cache id - * @param array $tags array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $lifetime = $this->getLifetime($specificLifetime); - $result = xcache_set($id, array($data, time()), $lifetime); - if (count($tags) > 0) { - $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_XCACHE_BACKEND); - } - return $result; - } - - /** - * Remove a cache record - * - * @param string $id cache id - * @return boolean true if no problem - */ - public function remove($id) - { - return xcache_unset($id); - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => unsupported - * 'matchingTag' => unsupported - * 'notMatchingTag' => unsupported - * 'matchingAnyTag' => unsupported - * - * @param string $mode clean mode - * @param array $tags array of tags - * @throws Zend_Cache_Exception - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - // Necessary because xcache_clear_cache() need basic authentification - $backup = array(); - if (isset($_SERVER['PHP_AUTH_USER'])) { - $backup['PHP_AUTH_USER'] = $_SERVER['PHP_AUTH_USER']; - } - if (isset($_SERVER['PHP_AUTH_PW'])) { - $backup['PHP_AUTH_PW'] = $_SERVER['PHP_AUTH_PW']; - } - if ($this->_options['user']) { - $_SERVER['PHP_AUTH_USER'] = $this->_options['user']; - } - if ($this->_options['password']) { - $_SERVER['PHP_AUTH_PW'] = $this->_options['password']; - } - - $cnt = xcache_count(XC_TYPE_VAR); - for ($i=0; $i < $cnt; $i++) { - xcache_clear_cache(XC_TYPE_VAR, $i); - } - - if (isset($backup['PHP_AUTH_USER'])) { - $_SERVER['PHP_AUTH_USER'] = $backup['PHP_AUTH_USER']; - $_SERVER['PHP_AUTH_PW'] = $backup['PHP_AUTH_PW']; - } - return true; - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_Xcache::clean() : CLEANING_MODE_OLD is unsupported by the Xcache backend"); - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_XCACHE_BACKEND); - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - - /** - * Return true if the automatic cleaning is available for the backend - * - * @return boolean - */ - public function isAutomaticCleaningAvailable() - { - return false; - } - -} diff --git a/library/vendor/Zend/Cache/Backend/ZendPlatform.php b/library/vendor/Zend/Cache/Backend/ZendPlatform.php deleted file mode 100644 index 8e6f460de..000000000 --- a/library/vendor/Zend/Cache/Backend/ZendPlatform.php +++ /dev/null @@ -1,315 +0,0 @@ -_directives['lifetime']; - } - $res = output_cache_get($id, $lifetime); - if($res) { - return $res[0]; - } else { - return false; - } - } - - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id Cache id - * @return mixed|false false (a cache is not available) or "last modified" timestamp (int) of the available cache record - */ - public function test($id) - { - $result = output_cache_get($id, $this->_directives['lifetime']); - if ($result) { - return $result[1]; - } - return false; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data Data to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - if (!($specificLifetime === false)) { - $this->_log("Zend_Cache_Backend_ZendPlatform::save() : non false specifc lifetime is unsuported for this backend"); - } - - $lifetime = $this->_directives['lifetime']; - $result1 = output_cache_put($id, array($data, time())); - $result2 = (count($tags) == 0); - - foreach ($tags as $tag) { - $tagid = self::TAGS_PREFIX.$tag; - $old_tags = output_cache_get($tagid, $lifetime); - if ($old_tags === false) { - $old_tags = array(); - } - $old_tags[$id] = $id; - output_cache_remove_key($tagid); - $result2 = output_cache_put($tagid, $old_tags); - } - - return $result1 && $result2; - } - - - /** - * Remove a cache record - * - * @param string $id Cache id - * @return boolean True if no problem - */ - public function remove($id) - { - return output_cache_remove_key($id); - } - - - /** - * Clean some cache records - * - * Available modes are : - * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) - * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) - * This mode is not supported in this backend - * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => unsupported - * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode Clean mode - * @param array $tags Array of tags - * @throws Zend_Cache_Exception - * @return boolean True if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - case Zend_Cache::CLEANING_MODE_OLD: - $cache_dir = ini_get('zend_accelerator.output_cache_dir'); - if (!$cache_dir) { - return false; - } - $cache_dir .= '/.php_cache_api/'; - return $this->_clean($cache_dir, $mode); - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - $idlist = null; - foreach ($tags as $tag) { - $next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']); - if ($idlist) { - $idlist = array_intersect_assoc($idlist, $next_idlist); - } else { - $idlist = $next_idlist; - } - if (count($idlist) == 0) { - // if ID list is already empty - we may skip checking other IDs - $idlist = null; - break; - } - } - if ($idlist) { - foreach ($idlist as $id) { - output_cache_remove_key($id); - } - } - return true; - break; - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - $this->_log("Zend_Cache_Backend_ZendPlatform::clean() : CLEANING_MODE_NOT_MATCHING_TAG is not supported by the Zend Platform backend"); - return false; - break; - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $idlist = null; - foreach ($tags as $tag) { - $next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']); - if ($idlist) { - $idlist = array_merge_recursive($idlist, $next_idlist); - } else { - $idlist = $next_idlist; - } - if (count($idlist) == 0) { - // if ID list is already empty - we may skip checking other IDs - $idlist = null; - break; - } - } - if ($idlist) { - foreach ($idlist as $id) { - output_cache_remove_key($id); - } - } - return true; - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } - - /** - * Clean a directory and recursivly go over it's subdirectories - * - * Remove all the cached files that need to be cleaned (according to mode and files mtime) - * - * @param string $dir Path of directory ot clean - * @param string $mode The same parameter as in Zend_Cache_Backend_ZendPlatform::clean() - * @return boolean True if ok - */ - private function _clean($dir, $mode) - { - $d = @dir($dir); - if (!$d) { - return false; - } - $result = true; - while (false !== ($file = $d->read())) { - if ($file == '.' || $file == '..') { - continue; - } - $file = $d->path . $file; - if (is_dir($file)) { - $result = ($this->_clean($file .'/', $mode)) && ($result); - } else { - if ($mode == Zend_Cache::CLEANING_MODE_ALL) { - $result = ($this->_remove($file)) && ($result); - } else if ($mode == Zend_Cache::CLEANING_MODE_OLD) { - // Files older than lifetime get deleted from cache - if ($this->_directives['lifetime'] !== null) { - if ((time() - @filemtime($file)) > $this->_directives['lifetime']) { - $result = ($this->_remove($file)) && ($result); - } - } - } - } - } - $d->close(); - return $result; - } - - /** - * Remove a file - * - * If we can't remove the file (because of locks or any problem), we will touch - * the file to invalidate it - * - * @param string $file Complete file path - * @return boolean True if ok - */ - private function _remove($file) - { - if (!@unlink($file)) { - # If we can't remove the file (because of locks or any problem), we will touch - # the file to invalidate it - $this->_log("Zend_Cache_Backend_ZendPlatform::_remove() : we can't remove $file => we are going to try to invalidate it"); - if ($this->_directives['lifetime'] === null) { - return false; - } - if (!file_exists($file)) { - return false; - } - return @touch($file, time() - 2*abs($this->_directives['lifetime'])); - } - return true; - } - -} diff --git a/library/vendor/Zend/Cache/Backend/ZendServer.php b/library/vendor/Zend/Cache/Backend/ZendServer.php deleted file mode 100644 index 6243d869d..000000000 --- a/library/vendor/Zend/Cache/Backend/ZendServer.php +++ /dev/null @@ -1,205 +0,0 @@ - (string) namespace : - * Namespace to be used for chaching operations - * - * @var array available options - */ - protected $_options = array( - 'namespace' => 'zendframework' - ); - - /** - * Store data - * - * @param mixed $data Object to store - * @param string $id Cache id - * @param int $timeToLive Time to live in seconds - * @throws Zend_Cache_Exception - */ - abstract protected function _store($data, $id, $timeToLive); - - /** - * Fetch data - * - * @param string $id Cache id - * @throws Zend_Cache_Exception - */ - abstract protected function _fetch($id); - - /** - * Unset data - * - * @param string $id Cache id - */ - abstract protected function _unset($id); - - /** - * Clear cache - */ - abstract protected function _clear(); - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id cache id - * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested - * @return string cached datas (or false) - */ - public function load($id, $doNotTestCacheValidity = false) - { - $tmp = $this->_fetch($id); - if ($tmp !== null) { - return $tmp; - } - return false; - } - - /** - * Test if a cache is available or not (for the given id) - * - * @param string $id cache id - * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record - * @throws Zend_Cache_Exception - */ - public function test($id) - { - $tmp = $this->_fetch('internal-metadatas---' . $id); - if ($tmp !== false) { - if (!is_array($tmp) || !isset($tmp['mtime'])) { - Zend_Cache::throwException('Cache metadata for \'' . $id . '\' id is corrupted' ); - } - return $tmp['mtime']; - } - return false; - } - - /** - * Compute & return the expire time - * - * @return int expire time (unix timestamp) - */ - private function _expireTime($lifetime) - { - if ($lifetime === null) { - return 9999999999; - } - return time() + $lifetime; - } - - /** - * Save some string datas into a cache record - * - * Note : $data is always "string" (serialization is done by the - * core not by the backend) - * - * @param string $data datas to cache - * @param string $id cache id - * @param array $tags array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem - */ - public function save($data, $id, $tags = array(), $specificLifetime = false) - { - $lifetime = $this->getLifetime($specificLifetime); - $metadatas = array( - 'mtime' => time(), - 'expire' => $this->_expireTime($lifetime), - ); - - if (count($tags) > 0) { - $this->_log('Zend_Cache_Backend_ZendServer::save() : tags are unsupported by the ZendServer backends'); - } - - return $this->_store($data, $id, $lifetime) && - $this->_store($metadatas, 'internal-metadatas---' . $id, $lifetime); - } - - /** - * Remove a cache record - * - * @param string $id cache id - * @return boolean true if no problem - */ - public function remove($id) - { - $result1 = $this->_unset($id); - $result2 = $this->_unset('internal-metadatas---' . $id); - - return $result1 && $result2; - } - - /** - * Clean some cache records - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => unsupported - * 'matchingTag' => unsupported - * 'notMatchingTag' => unsupported - * 'matchingAnyTag' => unsupported - * - * @param string $mode clean mode - * @param array $tags array of tags - * @throws Zend_Cache_Exception - * @return boolean true if no problem - */ - public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) - { - switch ($mode) { - case Zend_Cache::CLEANING_MODE_ALL: - $this->_clear(); - return true; - break; - case Zend_Cache::CLEANING_MODE_OLD: - $this->_log("Zend_Cache_Backend_ZendServer::clean() : CLEANING_MODE_OLD is unsupported by the Zend Server backends."); - break; - case Zend_Cache::CLEANING_MODE_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: - case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: - $this->_clear(); - $this->_log('Zend_Cache_Backend_ZendServer::clean() : tags are unsupported by the Zend Server backends.'); - break; - default: - Zend_Cache::throwException('Invalid mode for clean() method'); - break; - } - } -} diff --git a/library/vendor/Zend/Cache/Backend/ZendServer/Disk.php b/library/vendor/Zend/Cache/Backend/ZendServer/Disk.php deleted file mode 100644 index 09cd126c1..000000000 --- a/library/vendor/Zend/Cache/Backend/ZendServer/Disk.php +++ /dev/null @@ -1,99 +0,0 @@ -_options['namespace'] . '::' . $id, - $data, - $timeToLive) === false) { - $this->_log('Store operation failed.'); - return false; - } - return true; - } - - /** - * Fetch data - * - * @param string $id Cache id - * @return mixed|null - */ - protected function _fetch($id) - { - return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id); - } - - /** - * Unset data - * - * @param string $id Cache id - * @return boolean true if no problem - */ - protected function _unset($id) - { - return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id); - } - - /** - * Clear cache - */ - protected function _clear() - { - zend_disk_cache_clear($this->_options['namespace']); - } -} diff --git a/library/vendor/Zend/Cache/Backend/ZendServer/ShMem.php b/library/vendor/Zend/Cache/Backend/ZendServer/ShMem.php deleted file mode 100644 index 5fe1894df..000000000 --- a/library/vendor/Zend/Cache/Backend/ZendServer/ShMem.php +++ /dev/null @@ -1,99 +0,0 @@ -_options['namespace'] . '::' . $id, - $data, - $timeToLive) === false) { - $this->_log('Store operation failed.'); - return false; - } - return true; - } - - /** - * Fetch data - * - * @param string $id Cache id - * @return mixed|null - */ - protected function _fetch($id) - { - return zend_shm_cache_fetch($this->_options['namespace'] . '::' . $id); - } - - /** - * Unset data - * - * @param string $id Cache id - * @return boolean true if no problem - */ - protected function _unset($id) - { - return zend_shm_cache_delete($this->_options['namespace'] . '::' . $id); - } - - /** - * Clear cache - */ - protected function _clear() - { - zend_shm_cache_clear($this->_options['namespace']); - } -} diff --git a/library/vendor/Zend/Cache/Core.php b/library/vendor/Zend/Cache/Core.php deleted file mode 100644 index 833f24720..000000000 --- a/library/vendor/Zend/Cache/Core.php +++ /dev/null @@ -1,762 +0,0 @@ - (boolean) write_control : - * - Enable / disable write control (the cache is read just after writing to detect corrupt entries) - * - Enable write control will lightly slow the cache writing but not the cache reading - * Write control can detect some corrupt cache files but maybe it's not a perfect control - * - * ====> (boolean) caching : - * - Enable / disable caching - * (can be very useful for the debug of cached scripts) - * - * =====> (string) cache_id_prefix : - * - prefix for cache ids (namespace) - * - * ====> (boolean) automatic_serialization : - * - Enable / disable automatic serialization - * - It can be used to save directly datas which aren't strings (but it's slower) - * - * ====> (int) automatic_cleaning_factor : - * - Disable / Tune the automatic cleaning process - * - The automatic cleaning process destroy too old (for the given life time) - * cache files when a new cache file is written : - * 0 => no automatic cache cleaning - * 1 => systematic cache cleaning - * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write - * - * ====> (int) lifetime : - * - Cache lifetime (in seconds) - * - If null, the cache is valid forever. - * - * ====> (boolean) logging : - * - If set to true, logging is activated (but the system is slower) - * - * ====> (boolean) ignore_user_abort - * - If set to true, the core will set the ignore_user_abort PHP flag inside the - * save() method to avoid cache corruptions in some cases (default false) - * - * @var array $_options available options - */ - protected $_options = array( - 'write_control' => true, - 'caching' => true, - 'cache_id_prefix' => null, - 'automatic_serialization' => false, - 'automatic_cleaning_factor' => 10, - 'lifetime' => 3600, - 'logging' => false, - 'logger' => null, - 'ignore_user_abort' => false - ); - - /** - * Array of options which have to be transfered to backend - * - * @var array $_directivesList - */ - protected static $_directivesList = array('lifetime', 'logging', 'logger'); - - /** - * Not used for the core, just a sort a hint to get a common setOption() method (for the core and for frontends) - * - * @var array $_specificOptions - */ - protected $_specificOptions = array(); - - /** - * Last used cache id - * - * @var string $_lastId - */ - private $_lastId = null; - - /** - * True if the backend implements Zend_Cache_Backend_ExtendedInterface - * - * @var boolean $_extendedBackend - */ - protected $_extendedBackend = false; - - /** - * Array of capabilities of the backend (only if it implements Zend_Cache_Backend_ExtendedInterface) - * - * @var array - */ - protected $_backendCapabilities = array(); - - /** - * Constructor - * - * @param array|Zend_Config $options Associative array of options or Zend_Config instance - * @throws Zend_Cache_Exception - * @return void - */ - public function __construct($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - if (!is_array($options)) { - Zend_Cache::throwException("Options passed were not an array" - . " or Zend_Config instance."); - } - foreach ($options as $name => $value) { - $this->setOption($name, $value); - } - $this->_loggerSanity(); - } - - /** - * Set options using an instance of type Zend_Config - * - * @param Zend_Config $config - * @return Zend_Cache_Core - */ - public function setConfig(Zend_Config $config) - { - $options = $config->toArray(); - foreach ($options as $name => $value) { - $this->setOption($name, $value); - } - return $this; - } - - /** - * Set the backend - * - * @param Zend_Cache_Backend $backendObject - * @throws Zend_Cache_Exception - * @return void - */ - public function setBackend(Zend_Cache_Backend $backendObject) - { - $this->_backend= $backendObject; - // some options (listed in $_directivesList) have to be given - // to the backend too (even if they are not "backend specific") - $directives = array(); - foreach (Zend_Cache_Core::$_directivesList as $directive) { - $directives[$directive] = $this->_options[$directive]; - } - $this->_backend->setDirectives($directives); - if (in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_backend))) { - $this->_extendedBackend = true; - $this->_backendCapabilities = $this->_backend->getCapabilities(); - } - - } - - /** - * Returns the backend - * - * @return Zend_Cache_Backend backend object - */ - public function getBackend() - { - return $this->_backend; - } - - /** - * Public frontend to set an option - * - * There is an additional validation (relatively to the protected _setOption method) - * - * @param string $name Name of the option - * @param mixed $value Value of the option - * @throws Zend_Cache_Exception - * @return void - */ - public function setOption($name, $value) - { - if (!is_string($name)) { - Zend_Cache::throwException("Incorrect option name!"); - } - $name = strtolower($name); - if (array_key_exists($name, $this->_options)) { - // This is a Core option - $this->_setOption($name, $value); - return; - } - if (array_key_exists($name, $this->_specificOptions)) { - // This a specic option of this frontend - $this->_specificOptions[$name] = $value; - return; - } - } - - /** - * Public frontend to get an option value - * - * @param string $name Name of the option - * @throws Zend_Cache_Exception - * @return mixed option value - */ - public function getOption($name) - { - $name = strtolower($name); - - if (array_key_exists($name, $this->_options)) { - // This is a Core option - return $this->_options[$name]; - } - - if (array_key_exists($name, $this->_specificOptions)) { - // This a specic option of this frontend - return $this->_specificOptions[$name]; - } - - Zend_Cache::throwException("Incorrect option name : $name"); - } - - /** - * Set an option - * - * @param string $name Name of the option - * @param mixed $value Value of the option - * @throws Zend_Cache_Exception - * @return void - */ - private function _setOption($name, $value) - { - if (!is_string($name) || !array_key_exists($name, $this->_options)) { - Zend_Cache::throwException("Incorrect option name : $name"); - } - if ($name == 'lifetime' && empty($value)) { - $value = null; - } - $this->_options[$name] = $value; - } - - /** - * Force a new lifetime - * - * The new value is set for the core/frontend but for the backend too (directive) - * - * @param int $newLifetime New lifetime (in seconds) - * @return void - */ - public function setLifetime($newLifetime) - { - $this->_options['lifetime'] = $newLifetime; - $this->_backend->setDirectives(array( - 'lifetime' => $newLifetime - )); - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @param boolean $doNotUnserialize Do not serialize (even if automatic_serialization is true) => for internal use - * @return mixed|false Cached datas - */ - public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false) - { - if (!$this->_options['caching']) { - return false; - } - $id = $this->_id($id); // cache id may need prefix - $this->_lastId = $id; - $this->_validateIdOrTag($id); - - $this->_log("Zend_Cache_Core: load item '{$id}'", 7); - $data = $this->_backend->load($id, $doNotTestCacheValidity); - if ($data===false) { - // no cache available - return false; - } - if ((!$doNotUnserialize) && $this->_options['automatic_serialization']) { - // we need to unserialize before sending the result - return unserialize($data); - } - return $data; - } - - /** - * Test if a cache is available for the given id - * - * @param string $id Cache id - * @return int|false Last modified time of cache entry if it is available, false otherwise - */ - public function test($id) - { - if (!$this->_options['caching']) { - return false; - } - $id = $this->_id($id); // cache id may need prefix - $this->_validateIdOrTag($id); - $this->_lastId = $id; - - $this->_log("Zend_Cache_Core: test item '{$id}'", 7); - return $this->_backend->test($id); - } - - /** - * Save some data in a cache - * - * @param mixed $data Data to put in cache (can be another type than string if automatic_serialization is on) - * @param string $id Cache id (if not set, the last cache id will be used) - * @param array $tags Cache tags - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends - * @throws Zend_Cache_Exception - * @return boolean True if no problem - */ - public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8) - { - if (!$this->_options['caching']) { - return true; - } - if ($id === null) { - $id = $this->_lastId; - } else { - $id = $this->_id($id); - } - $this->_validateIdOrTag($id); - $this->_validateTagsArray($tags); - if ($this->_options['automatic_serialization']) { - // we need to serialize datas before storing them - $data = serialize($data); - } else { - if (!is_string($data)) { - Zend_Cache::throwException("Datas must be string or set automatic_serialization = true"); - } - } - - // automatic cleaning - if ($this->_options['automatic_cleaning_factor'] > 0) { - $rand = rand(1, $this->_options['automatic_cleaning_factor']); - if ($rand==1) { - // new way || deprecated way - if ($this->_extendedBackend || method_exists($this->_backend, 'isAutomaticCleaningAvailable')) { - $this->_log("Zend_Cache_Core::save(): automatic cleaning running", 7); - $this->clean(Zend_Cache::CLEANING_MODE_OLD); - } else { - $this->_log("Zend_Cache_Core::save(): automatic cleaning is not available/necessary with current backend", 4); - } - } - } - - $this->_log("Zend_Cache_Core: save item '{$id}'", 7); - if ($this->_options['ignore_user_abort']) { - $abort = ignore_user_abort(true); - } - if (($this->_extendedBackend) && ($this->_backendCapabilities['priority'])) { - $result = $this->_backend->save($data, $id, $tags, $specificLifetime, $priority); - } else { - $result = $this->_backend->save($data, $id, $tags, $specificLifetime); - } - if ($this->_options['ignore_user_abort']) { - ignore_user_abort($abort); - } - - if (!$result) { - // maybe the cache is corrupted, so we remove it ! - $this->_log("Zend_Cache_Core::save(): failed to save item '{$id}' -> removing it", 4); - $this->_backend->remove($id); - return false; - } - - if ($this->_options['write_control']) { - $data2 = $this->_backend->load($id, true); - if ($data!=$data2) { - $this->_log("Zend_Cache_Core::save(): write control of item '{$id}' failed -> removing it", 4); - $this->_backend->remove($id); - return false; - } - } - - return true; - } - - /** - * Remove a cache - * - * @param string $id Cache id to remove - * @return boolean True if ok - */ - public function remove($id) - { - if (!$this->_options['caching']) { - return true; - } - $id = $this->_id($id); // cache id may need prefix - $this->_validateIdOrTag($id); - - $this->_log("Zend_Cache_Core: remove item '{$id}'", 7); - return $this->_backend->remove($id); - } - - /** - * Clean cache entries - * - * Available modes are : - * 'all' (default) => remove all cache entries ($tags is not used) - * 'old' => remove too old cache entries ($tags is not used) - * 'matchingTag' => remove cache entries matching all given tags - * ($tags can be an array of strings or a single string) - * 'notMatchingTag' => remove cache entries not matching one of the given tags - * ($tags can be an array of strings or a single string) - * 'matchingAnyTag' => remove cache entries matching any given tags - * ($tags can be an array of strings or a single string) - * - * @param string $mode - * @param array|string $tags - * @throws Zend_Cache_Exception - * @return boolean True if ok - */ - public function clean($mode = 'all', $tags = array()) - { - if (!$this->_options['caching']) { - return true; - } - if (!in_array($mode, array(Zend_Cache::CLEANING_MODE_ALL, - Zend_Cache::CLEANING_MODE_OLD, - Zend_Cache::CLEANING_MODE_MATCHING_TAG, - Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG, - Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG))) { - Zend_Cache::throwException('Invalid cleaning mode'); - } - $this->_validateTagsArray($tags); - - return $this->_backend->clean($mode, $tags); - } - - /** - * Return an array of stored cache ids which match given tags - * - * In case of multiple tags, a logical AND is made between tags - * - * @param array $tags array of tags - * @return array array of matching cache ids (string) - */ - public function getIdsMatchingTags($tags = array()) - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG); - } - - $ids = $this->_backend->getIdsMatchingTags($tags); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } - } - - return $ids; - } - - /** - * Return an array of stored cache ids which don't match given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) - */ - public function getIdsNotMatchingTags($tags = array()) - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG); - } - - $ids = $this->_backend->getIdsNotMatchingTags($tags); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } - } - - return $ids; - } - - /** - * Return an array of stored cache ids which match any given tags - * - * In case of multiple tags, a logical OR is made between tags - * - * @param array $tags array of tags - * @return array array of matching any cache ids (string) - */ - public function getIdsMatchingAnyTags($tags = array()) - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG); - } - - $ids = $this->_backend->getIdsMatchingAnyTags($tags); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } - } - - return $ids; - } - - /** - * Return an array of stored cache ids - * - * @return array array of stored cache ids (string) - */ - public function getIds() - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - - $ids = $this->_backend->getIds(); - - // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600) - if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') { - $prefix = & $this->_options['cache_id_prefix']; - $prefixLen = strlen($prefix); - foreach ($ids as &$id) { - if (strpos($id, $prefix) === 0) { - $id = substr($id, $prefixLen); - } - } - } - - return $ids; - } - - /** - * Return an array of stored tags - * - * @return array array of stored tags (string) - */ - public function getTags() - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - if (!($this->_backendCapabilities['tags'])) { - Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG); - } - return $this->_backend->getTags(); - } - - /** - * Return the filling percentage of the backend storage - * - * @return int integer between 0 and 100 - */ - public function getFillingPercentage() - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - return $this->_backend->getFillingPercentage(); - } - - /** - * Return an array of metadatas for the given cache id - * - * The array will include these keys : - * - expire : the expire timestamp - * - tags : a string array of tags - * - mtime : timestamp of last modification time - * - * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) - */ - public function getMetadatas($id) - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - $id = $this->_id($id); // cache id may need prefix - return $this->_backend->getMetadatas($id); - } - - /** - * Give (if possible) an extra lifetime to the given cache id - * - * @param string $id cache id - * @param int $extraLifetime - * @return boolean true if ok - */ - public function touch($id, $extraLifetime) - { - if (!$this->_extendedBackend) { - Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF); - } - $id = $this->_id($id); // cache id may need prefix - - $this->_log("Zend_Cache_Core: touch item '{$id}'", 7); - return $this->_backend->touch($id, $extraLifetime); - } - - /** - * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...) - * - * Throw an exception if a problem is found - * - * @param string $string Cache id or tag - * @throws Zend_Cache_Exception - * @return void - */ - protected function _validateIdOrTag($string) - { - if (!is_string($string)) { - Zend_Cache::throwException('Invalid id or tag : must be a string'); - } - if (substr($string, 0, 9) == 'internal-') { - Zend_Cache::throwException('"internal-*" ids or tags are reserved'); - } - if (!preg_match('~^[a-zA-Z0-9_]+$~D', $string)) { - Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_]"); - } - } - - /** - * Validate a tags array (security, reliable filenames, reserved prefixes...) - * - * Throw an exception if a problem is found - * - * @param array $tags Array of tags - * @throws Zend_Cache_Exception - * @return void - */ - protected function _validateTagsArray($tags) - { - if (!is_array($tags)) { - Zend_Cache::throwException('Invalid tags array : must be an array'); - } - foreach($tags as $tag) { - $this->_validateIdOrTag($tag); - } - reset($tags); - } - - /** - * Make sure if we enable logging that the Zend_Log class - * is available. - * Create a default log object if none is set. - * - * @throws Zend_Cache_Exception - * @return void - */ - protected function _loggerSanity() - { - if (!isset($this->_options['logging']) || !$this->_options['logging']) { - return; - } - - if (isset($this->_options['logger']) && $this->_options['logger'] instanceof Zend_Log) { - return; - } - - // Create a default logger to the standard output stream - $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output')); - $logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<=')); - $this->_options['logger'] = $logger; - } - - /** - * Log a message at the WARN (4) priority. - * - * @param string $message - * @throws Zend_Cache_Exception - * @return void - */ - protected function _log($message, $priority = 4) - { - if (!$this->_options['logging']) { - return; - } - if (!(isset($this->_options['logger']) || $this->_options['logger'] instanceof Zend_Log)) { - Zend_Cache::throwException('Logging is enabled but logger is not set'); - } - $logger = $this->_options['logger']; - $logger->log($message, $priority); - } - - /** - * Make and return a cache id - * - * Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null - * - * @param string $id Cache id - * @return string Cache id (with or without prefix) - */ - protected function _id($id) - { - if (($id !== null) && isset($this->_options['cache_id_prefix'])) { - return $this->_options['cache_id_prefix'] . $id; // return with prefix - } - return $id; // no prefix, just return the $id passed - } - -} diff --git a/library/vendor/Zend/Cache/Exception.php b/library/vendor/Zend/Cache/Exception.php deleted file mode 100644 index bc3c81518..000000000 --- a/library/vendor/Zend/Cache/Exception.php +++ /dev/null @@ -1,31 +0,0 @@ -_tags = $tags; - $this->_extension = $extension; - ob_start(array($this, '_flush')); - ob_implicit_flush(false); - $this->_idStack[] = $id; - return false; - } - - /** - * callback for output buffering - * (shouldn't really be called manually) - * - * @param string $data Buffered output - * @return string Data to send to browser - */ - public function _flush($data) - { - $id = array_pop($this->_idStack); - if ($id === null) { - Zend_Cache::throwException('use of _flush() without a start()'); - } - if ($this->_extension) { - $this->save(serialize(array($data, $this->_extension)), $id, $this->_tags); - } else { - $this->save($data, $id, $this->_tags); - } - return $data; - } -} diff --git a/library/vendor/Zend/Cache/Frontend/Class.php b/library/vendor/Zend/Cache/Frontend/Class.php deleted file mode 100644 index c7208a19e..000000000 --- a/library/vendor/Zend/Cache/Frontend/Class.php +++ /dev/null @@ -1,274 +0,0 @@ - (mixed) cached_entity : - * - if set to a class name, we will cache an abstract class and will use only static calls - * - if set to an object, we will cache this object methods - * - * ====> (boolean) cache_by_default : - * - if true, method calls will be cached by default - * - * ====> (array) cached_methods : - * - an array of method names which will be cached (even if cache_by_default = false) - * - * ====> (array) non_cached_methods : - * - an array of method names which won't be cached (even if cache_by_default = true) - * - * @var array available options - */ - protected $_specificOptions = array( - 'cached_entity' => null, - 'cache_by_default' => true, - 'cached_methods' => array(), - 'non_cached_methods' => array() - ); - - /** - * Tags array - * - * @var array - */ - protected $_tags = array(); - - /** - * SpecificLifetime value - * - * false => no specific life time - * - * @var bool|int - */ - protected $_specificLifetime = false; - - /** - * The cached object or the name of the cached abstract class - * - * @var mixed - */ - protected $_cachedEntity = null; - - /** - * The class name of the cached object or cached abstract class - * - * Used to differentiate between different classes with the same method calls. - * - * @var string - */ - protected $_cachedEntityLabel = ''; - - /** - * Priority (used by some particular backends) - * - * @var int - */ - protected $_priority = 8; - - /** - * Constructor - * - * @param array $options Associative array of options - * @throws Zend_Cache_Exception - */ - public function __construct(array $options = array()) - { - foreach ($options as $name => $value) { - $this->setOption($name, $value); - } - if ($this->_specificOptions['cached_entity'] === null) { - Zend_Cache::throwException('cached_entity must be set !'); - } - $this->setCachedEntity($this->_specificOptions['cached_entity']); - $this->setOption('automatic_serialization', true); - } - - /** - * Set a specific life time - * - * @param bool|int $specificLifetime - * @return void - */ - public function setSpecificLifetime($specificLifetime = false) - { - $this->_specificLifetime = $specificLifetime; - } - - /** - * Set the priority (used by some particular backends) - * - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) - */ - public function setPriority($priority) - { - $this->_priority = $priority; - } - - /** - * Public frontend to set an option - * - * Just a wrapper to get a specific behaviour for cached_entity - * - * @param string $name Name of the option - * @param mixed $value Value of the option - * @throws Zend_Cache_Exception - * @return void - */ - public function setOption($name, $value) - { - if ($name == 'cached_entity') { - $this->setCachedEntity($value); - } else { - parent::setOption($name, $value); - } - } - - /** - * Specific method to set the cachedEntity - * - * if set to a class name, we will cache an abstract class and will use only static calls - * if set to an object, we will cache this object methods - * - * @param mixed $cachedEntity - */ - public function setCachedEntity($cachedEntity) - { - if (!is_string($cachedEntity) && !is_object($cachedEntity)) { - Zend_Cache::throwException( - 'cached_entity must be an object or a class name' - ); - } - - $this->_cachedEntity = $cachedEntity; - $this->_specificOptions['cached_entity'] = $cachedEntity; - - if (is_string($this->_cachedEntity)) { - $this->_cachedEntityLabel = $this->_cachedEntity; - } else { - $ro = new ReflectionObject($this->_cachedEntity); - $this->_cachedEntityLabel = $ro->getName(); - } - } - - /** - * Set the cache array - * - * @param array $tags - * @return void - */ - public function setTagsArray($tags = array()) - { - $this->_tags = $tags; - } - - /** - * Main method : call the specified method or get the result from cache - * - * @param string $name Method name - * @param array $parameters Method parameters - * @return mixed Result - * @throws Exception - */ - public function __call($name, $parameters) - { - $callback = array($this->_cachedEntity, $name); - - if (!is_callable($callback, false)) { - Zend_Cache::throwException('Invalid callback'); - } - - $cacheBool1 = $this->_specificOptions['cache_by_default']; - $cacheBool2 = in_array($name, $this->_specificOptions['cached_methods']); - $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_methods']); - $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3)); - - if (!$cache) { - // We do not have not cache - return call_user_func_array($callback, $parameters); - } - - $id = $this->makeId($name, $parameters); - if (($rs = $this->load($id)) && (array_key_exists(0, $rs)) - && (array_key_exists(1, $rs)) - ) { - // A cache is available - $output = $rs[0]; - $return = $rs[1]; - } else { - // A cache is not available (or not valid for this frontend) - ob_start(); - ob_implicit_flush(false); - - try { - $return = call_user_func_array($callback, $parameters); - $output = ob_get_clean(); - $data = array($output, $return); - - $this->save( - $data, $id, $this->_tags, $this->_specificLifetime, - $this->_priority - ); - } catch (Exception $e) { - ob_end_clean(); - throw $e; - } - } - - echo $output; - return $return; - } - - /** - * ZF-9970 - * - * @deprecated - */ - private function _makeId($name, $args) - { - return $this->makeId($name, $args); - } - - /** - * Make a cache id from the method name and parameters - * - * @param string $name Method name - * @param array $args Method parameters - * @return string Cache id - */ - public function makeId($name, array $args = array()) - { - return md5($this->_cachedEntityLabel . '__' . $name . '__' . serialize($args)); - } -} diff --git a/library/vendor/Zend/Cache/Frontend/File.php b/library/vendor/Zend/Cache/Frontend/File.php deleted file mode 100644 index 98cd5a3b6..000000000 --- a/library/vendor/Zend/Cache/Frontend/File.php +++ /dev/null @@ -1,221 +0,0 @@ - (string) master_file : - * - a complete path of the master file - * - deprecated (see master_files) - * - * ====> (array) master_files : - * - an array of complete path of master files - * - this option has to be set ! - * - * ====> (string) master_files_mode : - * - Zend_Cache_Frontend_File::MODE_AND or Zend_Cache_Frontend_File::MODE_OR - * - if MODE_AND, then all master files have to be touched to get a cache invalidation - * - if MODE_OR (default), then a single touched master file is enough to get a cache invalidation - * - * ====> (boolean) ignore_missing_master_files - * - if set to true, missing master files are ignored silently - * - if set to false (default), an exception is thrown if there is a missing master file - * @var array available options - */ - protected $_specificOptions = array( - 'master_file' => null, - 'master_files' => null, - 'master_files_mode' => 'OR', - 'ignore_missing_master_files' => false - ); - - /** - * Master file mtimes - * - * Array of int - * - * @var array - */ - private $_masterFile_mtimes = null; - - /** - * Constructor - * - * @param array $options Associative array of options - * @throws Zend_Cache_Exception - * @return void - */ - public function __construct(array $options = array()) - { - foreach ($options as $name => $value) { - $this->setOption($name, $value); - } - if (!isset($this->_specificOptions['master_files'])) { - Zend_Cache::throwException('master_files option must be set'); - } - } - - /** - * Change the master_files option - * - * @param array $masterFiles the complete paths and name of the master files - */ - public function setMasterFiles(array $masterFiles) - { - $this->_specificOptions['master_file'] = null; // to keep a compatibility - $this->_specificOptions['master_files'] = null; - $this->_masterFile_mtimes = array(); - - clearstatcache(); - $i = 0; - foreach ($masterFiles as $masterFile) { - if (file_exists($masterFile)) { - $mtime = filemtime($masterFile); - } else { - $mtime = false; - } - - if (!$this->_specificOptions['ignore_missing_master_files'] && !$mtime) { - Zend_Cache::throwException('Unable to read master_file : ' . $masterFile); - } - - $this->_masterFile_mtimes[$i] = $mtime; - $this->_specificOptions['master_files'][$i] = $masterFile; - if ($i === 0) { // to keep a compatibility - $this->_specificOptions['master_file'] = $masterFile; - } - - $i++; - } - } - - /** - * Change the master_file option - * - * To keep the compatibility - * - * @deprecated - * @param string $masterFile the complete path and name of the master file - */ - public function setMasterFile($masterFile) - { - $this->setMasterFiles(array($masterFile)); - } - - /** - * Public frontend to set an option - * - * Just a wrapper to get a specific behaviour for master_file - * - * @param string $name Name of the option - * @param mixed $value Value of the option - * @throws Zend_Cache_Exception - * @return void - */ - public function setOption($name, $value) - { - if ($name == 'master_file') { - $this->setMasterFile($value); - } else if ($name == 'master_files') { - $this->setMasterFiles($value); - } else { - parent::setOption($name, $value); - } - } - - /** - * Test if a cache is available for the given id and (if yes) return it (false else) - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @param boolean $doNotUnserialize Do not serialize (even if automatic_serialization is true) => for internal use - * @return mixed|false Cached datas - */ - public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false) - { - if (!$doNotTestCacheValidity) { - if ($this->test($id)) { - return parent::load($id, true, $doNotUnserialize); - } - return false; - } - return parent::load($id, true, $doNotUnserialize); - } - - /** - * Test if a cache is available for the given id - * - * @param string $id Cache id - * @return int|false Last modified time of cache entry if it is available, false otherwise - */ - public function test($id) - { - $lastModified = parent::test($id); - if ($lastModified) { - if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) { - // MODE_AND - foreach($this->_masterFile_mtimes as $masterFileMTime) { - if ($masterFileMTime) { - if ($lastModified > $masterFileMTime) { - return $lastModified; - } - } - } - } else { - // MODE_OR - $res = true; - foreach($this->_masterFile_mtimes as $masterFileMTime) { - if ($masterFileMTime) { - if ($lastModified <= $masterFileMTime) { - return false; - } - } - } - return $lastModified; - } - } - return false; - } - -} - diff --git a/library/vendor/Zend/Cache/Frontend/Function.php b/library/vendor/Zend/Cache/Frontend/Function.php deleted file mode 100644 index 3dc7fd82a..000000000 --- a/library/vendor/Zend/Cache/Frontend/Function.php +++ /dev/null @@ -1,178 +0,0 @@ - (boolean) cache_by_default : - * - if true, function calls will be cached by default - * - * ====> (array) cached_functions : - * - an array of function names which will be cached (even if cache_by_default = false) - * - * ====> (array) non_cached_functions : - * - an array of function names which won't be cached (even if cache_by_default = true) - * - * @var array options - */ - protected $_specificOptions = array( - 'cache_by_default' => true, - 'cached_functions' => array(), - 'non_cached_functions' => array() - ); - - /** - * Constructor - * - * @param array $options Associative array of options - * @return void - */ - public function __construct(array $options = array()) - { - foreach ($options as $name => $value) { - $this->setOption($name, $value); - } - $this->setOption('automatic_serialization', true); - } - - /** - * Main method : call the specified function or get the result from cache - * - * @param callback $callback A valid callback - * @param array $parameters Function parameters - * @param array $tags Cache tags - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends - * @return mixed Result - */ - public function call($callback, array $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8) - { - if (!is_callable($callback, true, $name)) { - Zend_Cache::throwException('Invalid callback'); - } - - $cacheBool1 = $this->_specificOptions['cache_by_default']; - $cacheBool2 = in_array($name, $this->_specificOptions['cached_functions']); - $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_functions']); - $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3)); - if (!$cache) { - // Caching of this callback is disabled - return call_user_func_array($callback, $parameters); - } - - $id = $this->_makeId($callback, $parameters); - if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1])) { - // A cache is available - $output = $rs[0]; - $return = $rs[1]; - } else { - // A cache is not available (or not valid for this frontend) - ob_start(); - ob_implicit_flush(false); - $return = call_user_func_array($callback, $parameters); - $output = ob_get_clean(); - $data = array($output, $return); - $this->save($data, $id, $tags, $specificLifetime, $priority); - } - - echo $output; - return $return; - } - - /** - * ZF-9970 - * - * @deprecated - */ - private function _makeId($callback, array $args) - { - return $this->makeId($callback, $args); - } - - /** - * Make a cache id from the function name and parameters - * - * @param callback $callback A valid callback - * @param array $args Function parameters - * @throws Zend_Cache_Exception - * @return string Cache id - */ - public function makeId($callback, array $args = array()) - { - if (!is_callable($callback, true, $name)) { - Zend_Cache::throwException('Invalid callback'); - } - - // functions, methods and classnames are case-insensitive - $name = strtolower($name); - - // generate a unique id for object callbacks - if (is_object($callback)) { // Closures & __invoke - $object = $callback; - } elseif (isset($callback[0])) { // array($object, 'method') - $object = $callback[0]; - } - if (isset($object)) { - try { - $tmp = @serialize($callback); - } catch (Exception $e) { - Zend_Cache::throwException($e->getMessage()); - } - if (!$tmp) { - $lastErr = error_get_last(); - Zend_Cache::throwException("Can't serialize callback object to generate id: {$lastErr['message']}"); - } - $name.= '__' . $tmp; - } - - // generate a unique id for arguments - $argsStr = ''; - if ($args) { - try { - $argsStr = @serialize(array_values($args)); - } catch (Exception $e) { - Zend_Cache::throwException($e->getMessage()); - } - if (!$argsStr) { - $lastErr = error_get_last(); - throw Zend_Cache::throwException("Can't serialize arguments to generate id: {$lastErr['message']}"); - } - } - - return md5($name . $argsStr); - } - -} diff --git a/library/vendor/Zend/Cache/Frontend/Output.php b/library/vendor/Zend/Cache/Frontend/Output.php deleted file mode 100644 index dd8fe8d70..000000000 --- a/library/vendor/Zend/Cache/Frontend/Output.php +++ /dev/null @@ -1,104 +0,0 @@ -_idStack = array(); - } - - /** - * Start the cache - * - * @param string $id Cache id - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @param boolean $echoData If set to true, datas are sent to the browser if the cache is hit (simply returned else) - * @return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas) - */ - public function start($id, $doNotTestCacheValidity = false, $echoData = true) - { - $data = $this->load($id, $doNotTestCacheValidity); - if ($data !== false) { - if ( $echoData ) { - echo($data); - return true; - } else { - return $data; - } - } - ob_start(); - ob_implicit_flush(false); - $this->_idStack[] = $id; - return false; - } - - /** - * Stop the cache - * - * @param array $tags Tags array - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @param string $forcedDatas If not null, force written datas with this - * @param boolean $echoData If set to true, datas are sent to the browser - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends - * @return void - */ - public function end($tags = array(), $specificLifetime = false, $forcedDatas = null, $echoData = true, $priority = 8) - { - if ($forcedDatas === null) { - $data = ob_get_clean(); - } else { - $data =& $forcedDatas; - } - $id = array_pop($this->_idStack); - if ($id === null) { - Zend_Cache::throwException('use of end() without a start()'); - } - $this->save($data, $id, $tags, $specificLifetime, $priority); - if ($echoData) { - echo($data); - } - } - -} diff --git a/library/vendor/Zend/Cache/Frontend/Page.php b/library/vendor/Zend/Cache/Frontend/Page.php deleted file mode 100644 index 832628125..000000000 --- a/library/vendor/Zend/Cache/Frontend/Page.php +++ /dev/null @@ -1,403 +0,0 @@ - (boolean) http_conditional : - * - if true, http conditional mode is on - * WARNING : http_conditional OPTION IS NOT IMPLEMENTED FOR THE MOMENT (TODO) - * - * ====> (boolean) debug_header : - * - if true, a debug text is added before each cached pages - * - * ====> (boolean) content_type_memorization : - * - deprecated => use memorize_headers instead - * - if the Content-Type header is sent after the cache was started, the - * corresponding value can be memorized and replayed when the cache is hit - * (if false (default), the frontend doesn't take care of Content-Type header) - * - * ====> (array) memorize_headers : - * - an array of strings corresponding to some HTTP headers name. Listed headers - * will be stored with cache datas and "replayed" when the cache is hit - * - * ====> (array) default_options : - * - an associative array of default options : - * - (boolean) cache : cache is on by default if true - * - (boolean) cacheWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') : - * if true, cache is still on even if there are some variables in this superglobal array - * if false, cache is off if there are some variables in this superglobal array - * - (boolean) makeIdWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') : - * if true, we have to use the content of this superglobal array to make a cache id - * if false, the cache id won't be dependent of the content of this superglobal array - * - (int) specific_lifetime : cache specific lifetime - * (false => global lifetime is used, null => infinite lifetime, - * integer => this lifetime is used), this "lifetime" is probably only - * usefull when used with "regexps" array - * - (array) tags : array of tags (strings) - * - (int) priority : integer between 0 (very low priority) and 10 (maximum priority) used by - * some particular backends - * - * ====> (array) regexps : - * - an associative array to set options only for some REQUEST_URI - * - keys are (pcre) regexps - * - values are associative array with specific options to set if the regexp matchs on $_SERVER['REQUEST_URI'] - * (see default_options for the list of available options) - * - if several regexps match the $_SERVER['REQUEST_URI'], only the last one will be used - * - * @var array options - */ - protected $_specificOptions = array( - 'http_conditional' => false, - 'debug_header' => false, - 'content_type_memorization' => false, - 'memorize_headers' => array(), - 'default_options' => array( - 'cache_with_get_variables' => false, - 'cache_with_post_variables' => false, - 'cache_with_session_variables' => false, - 'cache_with_files_variables' => false, - 'cache_with_cookie_variables' => false, - 'make_id_with_get_variables' => true, - 'make_id_with_post_variables' => true, - 'make_id_with_session_variables' => true, - 'make_id_with_files_variables' => true, - 'make_id_with_cookie_variables' => true, - 'cache' => true, - 'specific_lifetime' => false, - 'tags' => array(), - 'priority' => null - ), - 'regexps' => array() - ); - - /** - * Internal array to store some options - * - * @var array associative array of options - */ - protected $_activeOptions = array(); - - /** - * If true, the page won't be cached - * - * @var boolean - */ - protected $_cancel = false; - - /** - * Constructor - * - * @param array $options Associative array of options - * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested - * @throws Zend_Cache_Exception - * @return void - */ - public function __construct(array $options = array()) - { - foreach ($options as $name => $value) { - $name = strtolower($name); - switch ($name) { - case 'regexps': - $this->_setRegexps($value); - break; - case 'default_options': - $this->_setDefaultOptions($value); - break; - case 'content_type_memorization': - $this->_setContentTypeMemorization($value); - break; - default: - $this->setOption($name, $value); - } - } - if (isset($this->_specificOptions['http_conditional'])) { - if ($this->_specificOptions['http_conditional']) { - Zend_Cache::throwException('http_conditional is not implemented for the moment !'); - } - } - $this->setOption('automatic_serialization', true); - } - - /** - * Specific setter for the 'default_options' option (with some additional tests) - * - * @param array $options Associative array - * @throws Zend_Cache_Exception - * @return void - */ - protected function _setDefaultOptions($options) - { - if (!is_array($options)) { - Zend_Cache::throwException('default_options must be an array !'); - } - foreach ($options as $key=>$value) { - if (!is_string($key)) { - Zend_Cache::throwException("invalid option [$key] !"); - } - $key = strtolower($key); - if (isset($this->_specificOptions['default_options'][$key])) { - $this->_specificOptions['default_options'][$key] = $value; - } - } - } - - /** - * Set the deprecated contentTypeMemorization option - * - * @param boolean $value value - * @return void - * @deprecated - */ - protected function _setContentTypeMemorization($value) - { - $found = null; - foreach ($this->_specificOptions['memorize_headers'] as $key => $value) { - if (strtolower($value) == 'content-type') { - $found = $key; - } - } - if ($value) { - if (!$found) { - $this->_specificOptions['memorize_headers'][] = 'Content-Type'; - } - } else { - if ($found) { - unset($this->_specificOptions['memorize_headers'][$found]); - } - } - } - - /** - * Specific setter for the 'regexps' option (with some additional tests) - * - * @param array $options Associative array - * @throws Zend_Cache_Exception - * @return void - */ - protected function _setRegexps($regexps) - { - if (!is_array($regexps)) { - Zend_Cache::throwException('regexps option must be an array !'); - } - foreach ($regexps as $regexp=>$conf) { - if (!is_array($conf)) { - Zend_Cache::throwException('regexps option must be an array of arrays !'); - } - $validKeys = array_keys($this->_specificOptions['default_options']); - foreach ($conf as $key=>$value) { - if (!is_string($key)) { - Zend_Cache::throwException("unknown option [$key] !"); - } - $key = strtolower($key); - if (!in_array($key, $validKeys)) { - unset($regexps[$regexp][$key]); - } - } - } - $this->setOption('regexps', $regexps); - } - - /** - * Start the cache - * - * @param string $id (optional) A cache id (if you set a value here, maybe you have to use Output frontend instead) - * @param boolean $doNotDie For unit testing only ! - * @return boolean True if the cache is hit (false else) - */ - public function start($id = false, $doNotDie = false) - { - $this->_cancel = false; - $lastMatchingRegexp = null; - if (isset($_SERVER['REQUEST_URI'])) { - foreach ($this->_specificOptions['regexps'] as $regexp => $conf) { - if (preg_match("`$regexp`", $_SERVER['REQUEST_URI'])) { - $lastMatchingRegexp = $regexp; - } - } - } - $this->_activeOptions = $this->_specificOptions['default_options']; - if ($lastMatchingRegexp !== null) { - $conf = $this->_specificOptions['regexps'][$lastMatchingRegexp]; - foreach ($conf as $key=>$value) { - $this->_activeOptions[$key] = $value; - } - } - if (!($this->_activeOptions['cache'])) { - return false; - } - if (!$id) { - $id = $this->_makeId(); - if (!$id) { - return false; - } - } - $array = $this->load($id); - if ($array !== false) { - $data = $array['data']; - $headers = $array['headers']; - if (!headers_sent()) { - foreach ($headers as $key=>$headerCouple) { - $name = $headerCouple[0]; - $value = $headerCouple[1]; - header("$name: $value"); - } - } - if ($this->_specificOptions['debug_header']) { - echo 'DEBUG HEADER : This is a cached page !'; - } - echo $data; - if ($doNotDie) { - return true; - } - die(); - } - ob_start(array($this, '_flush')); - ob_implicit_flush(false); - return false; - } - - /** - * Cancel the current caching process - */ - public function cancel() - { - $this->_cancel = true; - } - - /** - * callback for output buffering - * (shouldn't really be called manually) - * - * @param string $data Buffered output - * @return string Data to send to browser - */ - public function _flush($data) - { - if ($this->_cancel) { - return $data; - } - $contentType = null; - $storedHeaders = array(); - $headersList = headers_list(); - foreach($this->_specificOptions['memorize_headers'] as $key=>$headerName) { - foreach ($headersList as $headerSent) { - $tmp = explode(':', $headerSent); - $headerSentName = trim(array_shift($tmp)); - if (strtolower($headerName) == strtolower($headerSentName)) { - $headerSentValue = trim(implode(':', $tmp)); - $storedHeaders[] = array($headerSentName, $headerSentValue); - } - } - } - $array = array( - 'data' => $data, - 'headers' => $storedHeaders - ); - $this->save($array, null, $this->_activeOptions['tags'], $this->_activeOptions['specific_lifetime'], $this->_activeOptions['priority']); - return $data; - } - - /** - * Make an id depending on REQUEST_URI and superglobal arrays (depending on options) - * - * @return mixed|false a cache id (string), false if the cache should have not to be used - */ - protected function _makeId() - { - $tmp = $_SERVER['REQUEST_URI']; - $array = explode('?', $tmp, 2); - $tmp = $array[0]; - foreach (array('Get', 'Post', 'Session', 'Files', 'Cookie') as $arrayName) { - $tmp2 = $this->_makePartialId($arrayName, $this->_activeOptions['cache_with_' . strtolower($arrayName) . '_variables'], $this->_activeOptions['make_id_with_' . strtolower($arrayName) . '_variables']); - if ($tmp2===false) { - return false; - } - $tmp = $tmp . $tmp2; - } - return md5($tmp); - } - - /** - * Make a partial id depending on options - * - * @param string $arrayName Superglobal array name - * @param bool $bool1 If true, cache is still on even if there are some variables in the superglobal array - * @param bool $bool2 If true, we have to use the content of the superglobal array to make a partial id - * @return mixed|false Partial id (string) or false if the cache should have not to be used - */ - protected function _makePartialId($arrayName, $bool1, $bool2) - { - switch ($arrayName) { - case 'Get': - $var = $_GET; - break; - case 'Post': - $var = $_POST; - break; - case 'Session': - if (isset($_SESSION)) { - $var = $_SESSION; - } else { - $var = null; - } - break; - case 'Cookie': - if (isset($_COOKIE)) { - $var = $_COOKIE; - } else { - $var = null; - } - break; - case 'Files': - $var = $_FILES; - break; - default: - return false; - } - if ($bool1) { - if ($bool2) { - return serialize($var); - } - return ''; - } - if (count($var) > 0) { - return false; - } - return ''; - } - -} diff --git a/library/vendor/Zend/Cache/Manager.php b/library/vendor/Zend/Cache/Manager.php deleted file mode 100644 index 5196c193d..000000000 --- a/library/vendor/Zend/Cache/Manager.php +++ /dev/null @@ -1,304 +0,0 @@ - array( - 'frontend' => array( - 'name' => 'Core', - 'options' => array( - 'automatic_serialization' => true, - ), - ), - 'backend' => array( - 'name' => 'File', - 'options' => array( - // use system temp dir by default of file backend - // 'cache_dir' => '../cache', - ), - ), - ), - - // Static Page HTML Cache - 'page' => array( - 'frontend' => array( - 'name' => 'Capture', - 'options' => array( - 'ignore_user_abort' => true, - ), - ), - 'backend' => array( - 'name' => 'Static', - 'options' => array( - 'public_dir' => '../public', - ), - ), - ), - - // Tag Cache - 'pagetag' => array( - 'frontend' => array( - 'name' => 'Core', - 'options' => array( - 'automatic_serialization' => true, - 'lifetime' => null - ), - ), - 'backend' => array( - 'name' => 'File', - 'options' => array( - // use system temp dir by default of file backend - // 'cache_dir' => '../cache', - // use default umask of file backend - // 'cache_file_umask' => 0644 - ), - ), - ), - ); - - /** - * Set a new cache for the Cache Manager to contain - * - * @param string $name - * @param Zend_Cache_Core $cache - * @return Zend_Cache_Manager - */ - public function setCache($name, Zend_Cache_Core $cache) - { - $this->_caches[$name] = $cache; - return $this; - } - - /** - * Check if the Cache Manager contains the named cache object, or a named - * configuration template to lazy load the cache object - * - * @param string $name - * @return bool - */ - public function hasCache($name) - { - if (isset($this->_caches[$name]) - || $this->hasCacheTemplate($name) - ) { - return true; - } - return false; - } - - /** - * Fetch the named cache object, or instantiate and return a cache object - * using a named configuration template - * - * @param string $name - * @return Zend_Cache_Core - */ - public function getCache($name) - { - if (isset($this->_caches[$name])) { - return $this->_caches[$name]; - } - if (isset($this->_optionTemplates[$name])) { - if ($name == self::PAGECACHE - && (!isset($this->_optionTemplates[$name]['backend']['options']['tag_cache']) - || !$this->_optionTemplates[$name]['backend']['options']['tag_cache'] instanceof Zend_Cache_Core) - ) { - $this->_optionTemplates[$name]['backend']['options']['tag_cache'] - = $this->getCache(self::PAGETAGCACHE); - } - - $this->_caches[$name] = Zend_Cache::factory( - $this->_optionTemplates[$name]['frontend']['name'], - $this->_optionTemplates[$name]['backend']['name'], - isset($this->_optionTemplates[$name]['frontend']['options']) ? $this->_optionTemplates[$name]['frontend']['options'] : array(), - isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array(), - isset($this->_optionTemplates[$name]['frontend']['customFrontendNaming']) ? $this->_optionTemplates[$name]['frontend']['customFrontendNaming'] : false, - isset($this->_optionTemplates[$name]['backend']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['customBackendNaming'] : false, - isset($this->_optionTemplates[$name]['frontendBackendAutoload']) ? $this->_optionTemplates[$name]['frontendBackendAutoload'] : false - ); - - return $this->_caches[$name]; - } - } - - /** - * Fetch all available caches - * - * @return array An array of all available caches with it's names as key - */ - public function getCaches() - { - $caches = $this->_caches; - foreach ($this->_optionTemplates as $name => $tmp) { - if (!isset($caches[$name])) { - $caches[$name] = $this->getCache($name); - } - } - return $caches; - } - - /** - * Set a named configuration template from which a cache object can later - * be lazy loaded - * - * @param string $name - * @param array $options - * @return Zend_Cache_Manager - * @throws Zend_Cache_Exception - */ - public function setCacheTemplate($name, $options) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (!is_array($options)) { - throw new Zend_Cache_Exception('Options passed must be in' - . ' an associative array or instance of Zend_Config'); - } - $this->_optionTemplates[$name] = $options; - return $this; - } - - /** - * Check if the named configuration template - * - * @param string $name - * @return bool - */ - public function hasCacheTemplate($name) - { - if (isset($this->_optionTemplates[$name])) { - return true; - } - return false; - } - - /** - * Get the named configuration template - * - * @param string $name - * @return array - */ - public function getCacheTemplate($name) - { - if (isset($this->_optionTemplates[$name])) { - return $this->_optionTemplates[$name]; - } - } - - /** - * Pass an array containing changes to be applied to a named - * configuration - * template - * - * @param string $name - * @param array $options - * @return Zend_Cache_Manager - * @throws Zend_Cache_Exception for invalid options format or if option templates do not have $name - */ - public function setTemplateOptions($name, $options) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (!is_array($options)) { - throw new Zend_Cache_Exception('Options passed must be in' - . ' an associative array or instance of Zend_Config'); - } - if (!isset($this->_optionTemplates[$name])) { - throw new Zend_Cache_Exception('A cache configuration template' - . 'does not exist with the name "' . $name . '"'); - } - $this->_optionTemplates[$name] - = $this->_mergeOptions($this->_optionTemplates[$name], $options); - return $this; - } - - /** - * Simple method to merge two configuration arrays - * - * @param array $current - * @param array $options - * @return array - */ - protected function _mergeOptions(array $current, array $options) - { - if (isset($options['frontend']['name'])) { - $current['frontend']['name'] = $options['frontend']['name']; - } - if (isset($options['backend']['name'])) { - $current['backend']['name'] = $options['backend']['name']; - } - if (isset($options['frontend']['options'])) { - foreach ($options['frontend']['options'] as $key => $value) { - $current['frontend']['options'][$key] = $value; - } - } - if (isset($options['backend']['options'])) { - foreach ($options['backend']['options'] as $key => $value) { - $current['backend']['options'][$key] = $value; - } - } - if (isset($options['frontend']['customFrontendNaming'])) { - $current['frontend']['customFrontendNaming'] = $options['frontend']['customFrontendNaming']; - } - if (isset($options['backend']['customBackendNaming'])) { - $current['backend']['customBackendNaming'] = $options['backend']['customBackendNaming']; - } - if (isset($options['frontendBackendAutoload'])) { - $current['frontendBackendAutoload'] = $options['frontendBackendAutoload']; - } - return $current; - } -} diff --git a/library/vendor/Zend/Config.php b/library/vendor/Zend/Config.php deleted file mode 100644 index 59c32656d..000000000 --- a/library/vendor/Zend/Config.php +++ /dev/null @@ -1,481 +0,0 @@ -_allowModifications = (boolean) $allowModifications; - $this->_loadedSection = null; - $this->_index = 0; - $this->_data = array(); - foreach ($array as $key => $value) { - if (is_array($value)) { - $this->_data[$key] = new self($value, $this->_allowModifications); - } else { - $this->_data[$key] = $value; - } - } - $this->_count = count($this->_data); - } - - /** - * Retrieve a value and return $default if there is no element set. - * - * @param string $name - * @param mixed $default - * @return mixed - */ - public function get($name, $default = null) - { - $result = $default; - if (array_key_exists($name, $this->_data)) { - $result = $this->_data[$name]; - } - return $result; - } - - /** - * Magic function so that $obj->value will work. - * - * @param string $name - * @return mixed - */ - public function __get($name) - { - return $this->get($name); - } - - /** - * Only allow setting of a property if $allowModifications - * was set to true on construction. Otherwise, throw an exception. - * - * @param string $name - * @param mixed $value - * @throws Zend_Config_Exception - * @return void - */ - public function __set($name, $value) - { - if ($this->_allowModifications) { - if (is_array($value)) { - $this->_data[$name] = new self($value, true); - } else { - $this->_data[$name] = $value; - } - $this->_count = count($this->_data); - } else { - /** @see Zend_Config_Exception */ - throw new Zend_Config_Exception('Zend_Config is read only'); - } - } - - /** - * Deep clone of this instance to ensure that nested Zend_Configs - * are also cloned. - * - * @return void - */ - public function __clone() - { - $array = array(); - foreach ($this->_data as $key => $value) { - if ($value instanceof Zend_Config) { - $array[$key] = clone $value; - } else { - $array[$key] = $value; - } - } - $this->_data = $array; - } - - /** - * Return an associative array of the stored data. - * - * @return array - */ - public function toArray() - { - $array = array(); - $data = $this->_data; - foreach ($data as $key => $value) { - if ($value instanceof Zend_Config) { - $array[$key] = $value->toArray(); - } else { - $array[$key] = $value; - } - } - return $array; - } - - /** - * Support isset() overloading on PHP 5.1 - * - * @param string $name - * @return boolean - */ - public function __isset($name) - { - return isset($this->_data[$name]); - } - - /** - * Support unset() overloading on PHP 5.1 - * - * @param string $name - * @throws Zend_Config_Exception - * @return void - */ - public function __unset($name) - { - if ($this->_allowModifications) { - unset($this->_data[$name]); - $this->_count = count($this->_data); - $this->_skipNextIteration = true; - } else { - /** @see Zend_Config_Exception */ - throw new Zend_Config_Exception('Zend_Config is read only'); - } - - } - - /** - * Defined by Countable interface - * - * @return int - */ - public function count() - { - return $this->_count; - } - - /** - * Defined by Iterator interface - * - * @return mixed - */ - public function current() - { - $this->_skipNextIteration = false; - return current($this->_data); - } - - /** - * Defined by Iterator interface - * - * @return mixed - */ - public function key() - { - return key($this->_data); - } - - /** - * Defined by Iterator interface - * - */ - public function next() - { - if ($this->_skipNextIteration) { - $this->_skipNextIteration = false; - return; - } - next($this->_data); - $this->_index++; - } - - /** - * Defined by Iterator interface - * - */ - public function rewind() - { - $this->_skipNextIteration = false; - reset($this->_data); - $this->_index = 0; - } - - /** - * Defined by Iterator interface - * - * @return boolean - */ - public function valid() - { - return $this->_index < $this->_count; - } - - /** - * Returns the section name(s) loaded. - * - * @return mixed - */ - public function getSectionName() - { - if(is_array($this->_loadedSection) && count($this->_loadedSection) == 1) { - $this->_loadedSection = $this->_loadedSection[0]; - } - return $this->_loadedSection; - } - - /** - * Returns true if all sections were loaded - * - * @return boolean - */ - public function areAllSectionsLoaded() - { - return $this->_loadedSection === null; - } - - - /** - * Merge another Zend_Config with this one. The items - * in $merge will override the same named items in - * the current config. - * - * @param Zend_Config $merge - * @return Zend_Config - */ - public function merge(Zend_Config $merge) - { - foreach($merge as $key => $item) { - if(array_key_exists($key, $this->_data)) { - if($item instanceof Zend_Config && $this->$key instanceof Zend_Config) { - $this->$key = $this->$key->merge(new Zend_Config($item->toArray(), !$this->readOnly())); - } else { - $this->$key = $item; - } - } else { - if($item instanceof Zend_Config) { - $this->$key = new Zend_Config($item->toArray(), !$this->readOnly()); - } else { - $this->$key = $item; - } - } - } - - return $this; - } - - /** - * Prevent any more modifications being made to this instance. Useful - * after merge() has been used to merge multiple Zend_Config objects - * into one object which should then not be modified again. - * - */ - public function setReadOnly() - { - $this->_allowModifications = false; - foreach ($this->_data as $key => $value) { - if ($value instanceof Zend_Config) { - $value->setReadOnly(); - } - } - } - - /** - * Returns if this Zend_Config object is read only or not. - * - * @return boolean - */ - public function readOnly() - { - return !$this->_allowModifications; - } - - /** - * Get the current extends - * - * @return array - */ - public function getExtends() - { - return $this->_extends; - } - - /** - * Set an extend for Zend_Config_Writer - * - * @param string $extendingSection - * @param string $extendedSection - * @return void - */ - public function setExtend($extendingSection, $extendedSection = null) - { - if ($extendedSection === null && isset($this->_extends[$extendingSection])) { - unset($this->_extends[$extendingSection]); - } else if ($extendedSection !== null) { - $this->_extends[$extendingSection] = $extendedSection; - } - } - - /** - * Throws an exception if $extendingSection may not extend $extendedSection, - * and tracks the section extension if it is valid. - * - * @param string $extendingSection - * @param string $extendedSection - * @throws Zend_Config_Exception - * @return void - */ - protected function _assertValidExtend($extendingSection, $extendedSection) - { - // detect circular section inheritance - $extendedSectionCurrent = $extendedSection; - while (array_key_exists($extendedSectionCurrent, $this->_extends)) { - if ($this->_extends[$extendedSectionCurrent] == $extendingSection) { - /** @see Zend_Config_Exception */ - throw new Zend_Config_Exception('Illegal circular inheritance detected'); - } - $extendedSectionCurrent = $this->_extends[$extendedSectionCurrent]; - } - // remember that this section extends another section - $this->_extends[$extendingSection] = $extendedSection; - } - - /** - * Handle any errors from simplexml_load_file or parse_ini_file - * - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline - */ - public function _loadFileErrorHandler($errno, $errstr, $errfile, $errline) - { - if ($this->_loadFileErrorStr === null) { - $this->_loadFileErrorStr = $errstr; - } else { - $this->_loadFileErrorStr .= (PHP_EOL . $errstr); - } - } - - /** - * Merge two arrays recursively, overwriting keys of the same name - * in $firstArray with the value in $secondArray. - * - * @param mixed $firstArray First array - * @param mixed $secondArray Second array to merge into first array - * @return array - */ - protected function _arrayMergeRecursive($firstArray, $secondArray) - { - if (is_array($firstArray) && is_array($secondArray)) { - foreach ($secondArray as $key => $value) { - if (isset($firstArray[$key])) { - $firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key], $value); - } else { - if($key === 0) { - $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray, $value)); - } else { - $firstArray[$key] = $value; - } - } - } - } else { - $firstArray = $secondArray; - } - - return $firstArray; - } -} diff --git a/library/vendor/Zend/Config/Exception.php b/library/vendor/Zend/Config/Exception.php deleted file mode 100644 index abffe5bf8..000000000 --- a/library/vendor/Zend/Config/Exception.php +++ /dev/null @@ -1,32 +0,0 @@ -hostname === "staging" - * $data->db->connection === "database" - * - * The $options parameter may be provided as either a boolean or an array. - * If provided as a boolean, this sets the $allowModifications option of - * Zend_Config. If provided as an array, there are three configuration - * directives that may be set. For example: - * - * $options = array( - * 'allowModifications' => false, - * 'nestSeparator' => ':', - * 'skipExtends' => false, - * ); - * - * @param string $filename - * @param mixed $section - * @param boolean|array $options - * @throws Zend_Config_Exception - * @return void - */ - public function __construct($filename, $section = null, $options = false) - { - if (empty($filename)) { - /** - * @see Zend_Config_Exception - */ - throw new Zend_Config_Exception('Filename is not set'); - } - - $allowModifications = false; - if (is_bool($options)) { - $allowModifications = $options; - } elseif (is_array($options)) { - if (isset($options['allowModifications'])) { - $allowModifications = (bool) $options['allowModifications']; - } - if (isset($options['nestSeparator'])) { - $this->_nestSeparator = (string) $options['nestSeparator']; - } - if (isset($options['skipExtends'])) { - $this->_skipExtends = (bool) $options['skipExtends']; - } - } - - $iniArray = $this->_loadIniFile($filename); - - if (null === $section) { - // Load entire file - $dataArray = array(); - foreach ($iniArray as $sectionName => $sectionData) { - if(!is_array($sectionData)) { - $dataArray = $this->_arrayMergeRecursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData)); - } else { - $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName); - } - } - parent::__construct($dataArray, $allowModifications); - } else { - // Load one or more sections - if (!is_array($section)) { - $section = array($section); - } - $dataArray = array(); - foreach ($section as $sectionName) { - if (!isset($iniArray[$sectionName])) { - /** - * @see Zend_Config_Exception - */ - throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $filename"); - } - $dataArray = $this->_arrayMergeRecursive($this->_processSection($iniArray, $sectionName), $dataArray); - - } - parent::__construct($dataArray, $allowModifications); - } - - $this->_loadedSection = $section; - } - - /** - * Load the INI file from disk using parse_ini_file(). Use a private error - * handler to convert any loading errors into a Zend_Config_Exception - * - * @param string $filename - * @throws Zend_Config_Exception - * @return array - */ - protected function _parseIniFile($filename) - { - set_error_handler(array($this, '_loadFileErrorHandler')); - $iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed - restore_error_handler(); - - // Check if there was a error while loading file - if ($this->_loadFileErrorStr !== null) { - /** - * @see Zend_Config_Exception - */ - throw new Zend_Config_Exception($this->_loadFileErrorStr); - } - - return $iniArray; - } - - /** - * Load the ini file and preprocess the section separator (':' in the - * section name (that is used for section extension) so that the resultant - * array has the correct section names and the extension information is - * stored in a sub-key called ';extends'. We use ';extends' as this can - * never be a valid key name in an INI file that has been loaded using - * parse_ini_file(). - * - * @param string $filename - * @throws Zend_Config_Exception - * @return array - */ - protected function _loadIniFile($filename) - { - $loaded = $this->_parseIniFile($filename); - $iniArray = array(); - foreach ($loaded as $key => $data) - { - $pieces = explode($this->_sectionSeparator, $key); - $thisSection = trim($pieces[0]); - switch (count($pieces)) { - case 1: - $iniArray[$thisSection] = $data; - break; - - case 2: - $extendedSection = trim($pieces[1]); - $iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data); - break; - - default: - /** - * @see Zend_Config_Exception - */ - throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections in $filename"); - } - } - - return $iniArray; - } - - /** - * Process each element in the section and handle the ";extends" inheritance - * key. Passes control to _processKey() to handle the nest separator - * sub-property syntax that may be used within the key name. - * - * @param array $iniArray - * @param string $section - * @param array $config - * @throws Zend_Config_Exception - * @return array - */ - protected function _processSection($iniArray, $section, $config = array()) - { - $thisSection = $iniArray[$section]; - - foreach ($thisSection as $key => $value) { - if (strtolower($key) == ';extends') { - if (isset($iniArray[$value])) { - $this->_assertValidExtend($section, $value); - - if (!$this->_skipExtends) { - $config = $this->_processSection($iniArray, $value, $config); - } - } else { - /** - * @see Zend_Config_Exception - */ - throw new Zend_Config_Exception("Parent section '$section' cannot be found"); - } - } else { - $config = $this->_processKey($config, $key, $value); - } - } - return $config; - } - - /** - * Assign the key's value to the property list. Handles the - * nest separator for sub-properties. - * - * @param array $config - * @param string $key - * @param string $value - * @throws Zend_Config_Exception - * @return array - */ - protected function _processKey($config, $key, $value) - { - if (strpos($key, $this->_nestSeparator) !== false) { - $pieces = explode($this->_nestSeparator, $key, 2); - if (strlen($pieces[0]) && strlen($pieces[1])) { - if (!isset($config[$pieces[0]])) { - if ($pieces[0] === '0' && !empty($config)) { - // convert the current values in $config into an array - $config = array($pieces[0] => $config); - } else { - $config[$pieces[0]] = array(); - } - } elseif (!is_array($config[$pieces[0]])) { - /** - * @see Zend_Config_Exception - */ - throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists"); - } - $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value); - } else { - /** - * @see Zend_Config_Exception - */ - throw new Zend_Config_Exception("Invalid key '$key'"); - } - } else { - $config[$key] = $value; - } - return $config; - } -} diff --git a/library/vendor/Zend/Config/Writer.php b/library/vendor/Zend/Config/Writer.php deleted file mode 100644 index 8c255b3c8..000000000 --- a/library/vendor/Zend/Config/Writer.php +++ /dev/null @@ -1,101 +0,0 @@ -setOptions($options); - } - } - - /** - * Set options via a Zend_Config instance - * - * @param Zend_Config $config - * @return Zend_Config_Writer - */ - public function setConfig(Zend_Config $config) - { - $this->_config = $config; - - return $this; - } - - /** - * Set options via an array - * - * @param array $options - * @return Zend_Config_Writer - */ - public function setOptions(array $options) - { - foreach ($options as $key => $value) { - if (in_array(strtolower($key), $this->_skipOptions)) { - continue; - } - - $method = 'set' . ucfirst($key); - if (method_exists($this, $method)) { - $this->$method($value); - } - } - - return $this; - } - - /** - * Write a Zend_Config object to it's target - * - * @return void - */ - abstract public function write(); -} diff --git a/library/vendor/Zend/Config/Writer/Array.php b/library/vendor/Zend/Config/Writer/Array.php deleted file mode 100644 index f7cd50296..000000000 --- a/library/vendor/Zend/Config/Writer/Array.php +++ /dev/null @@ -1,54 +0,0 @@ -_config->toArray(); - $sectionName = $this->_config->getSectionName(); - - if (is_string($sectionName)) { - $data = array($sectionName => $data); - } - - $arrayString = "_filename = $filename; - - return $this; - } - - /** - * Set wether to exclusively lock the file or not - * - * @param boolean $exclusiveLock - * @return Zend_Config_Writer_Array - */ - public function setExclusiveLock($exclusiveLock) - { - $this->_exclusiveLock = $exclusiveLock; - - return $this; - } - - /** - * Write configuration to file. - * - * @param string $filename - * @param Zend_Config $config - * @param bool $exclusiveLock - * @return void - */ - public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null) - { - if ($filename !== null) { - $this->setFilename($filename); - } - - if ($config !== null) { - $this->setConfig($config); - } - - if ($exclusiveLock !== null) { - $this->setExclusiveLock($exclusiveLock); - } - - if ($this->_filename === null) { - throw new Zend_Config_Exception('No filename was set'); - } - - if ($this->_config === null) { - throw new Zend_Config_Exception('No config was set'); - } - - $configString = $this->render(); - - $flags = 0; - - if ($this->_exclusiveLock) { - $flags |= LOCK_EX; - } - - $result = @file_put_contents($this->_filename, $configString, $flags); - - if ($result === false) { - throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"'); - } - } - - /** - * Render a Zend_Config into a config file string. - * - * @since 1.10 - * @todo For 2.0 this should be redone into an abstract method. - * @return string - */ - public function render() - { - return ""; - } -} diff --git a/library/vendor/Zend/Config/Writer/Ini.php b/library/vendor/Zend/Config/Writer/Ini.php deleted file mode 100644 index 67aaf8941..000000000 --- a/library/vendor/Zend/Config/Writer/Ini.php +++ /dev/null @@ -1,191 +0,0 @@ -_nestSeparator = $separator; - - return $this; - } - - /** - * Set if rendering should occour without sections or not. - * - * If set to true, the INI file is rendered without sections completely - * into the global namespace of the INI file. - * - * @param bool $withoutSections - * @return Zend_Config_Writer_Ini - */ - public function setRenderWithoutSections($withoutSections=true) - { - $this->_renderWithoutSections = (bool)$withoutSections; - return $this; - } - - /** - * Render a Zend_Config into a INI config string. - * - * @since 1.10 - * @return string - */ - public function render() - { - $iniString = ''; - $extends = $this->_config->getExtends(); - $sectionName = $this->_config->getSectionName(); - - if($this->_renderWithoutSections == true) { - $iniString .= $this->_addBranch($this->_config); - } else if (is_string($sectionName)) { - $iniString .= '[' . $sectionName . ']' . "\n" - . $this->_addBranch($this->_config) - . "\n"; - } else { - $config = $this->_sortRootElements($this->_config); - foreach ($config as $sectionName => $data) { - if (!($data instanceof Zend_Config)) { - $iniString .= $sectionName - . ' = ' - . $this->_prepareValue($data) - . "\n"; - } else { - if (isset($extends[$sectionName])) { - $sectionName .= ' : ' . $extends[$sectionName]; - } - - $iniString .= '[' . $sectionName . ']' . "\n" - . $this->_addBranch($data) - . "\n"; - } - } - } - - return $iniString; - } - - /** - * Add a branch to an INI string recursively - * - * @param Zend_Config $config - * @return void - */ - protected function _addBranch(Zend_Config $config, $parents = array()) - { - $iniString = ''; - - foreach ($config as $key => $value) { - $group = array_merge($parents, array($key)); - - if ($value instanceof Zend_Config) { - $iniString .= $this->_addBranch($value, $group); - } else { - $iniString .= implode($this->_nestSeparator, $group) - . ' = ' - . $this->_prepareValue($value) - . "\n"; - } - } - - return $iniString; - } - - /** - * Prepare a value for INI - * - * @param mixed $value - * @return string - */ - protected function _prepareValue($value) - { - if (is_integer($value) || is_float($value)) { - return $value; - } elseif (is_bool($value)) { - return ($value ? 'true' : 'false'); - } elseif (strpos($value, '"') === false) { - return '"' . $value . '"'; - } else { - /** @see Zend_Config_Exception */ - throw new Zend_Config_Exception('Value can not contain double quotes "'); - } - } - - /** - * Root elements that are not assigned to any section needs to be - * on the top of config. - * - * @see http://framework.zend.com/issues/browse/ZF-6289 - * @param Zend_Config - * @return Zend_Config - */ - protected function _sortRootElements(Zend_Config $config) - { - $configArray = $config->toArray(); - $sections = array(); - - // remove sections from config array - foreach ($configArray as $key => $value) { - if (is_array($value)) { - $sections[$key] = $value; - unset($configArray[$key]); - } - } - - // readd sections to the end - foreach ($sections as $key => $value) { - $configArray[$key] = $value; - } - - return new Zend_Config($configArray); - } -} diff --git a/library/vendor/Zend/Controller/Action.php b/library/vendor/Zend/Controller/Action.php deleted file mode 100644 index 35c450a95..000000000 --- a/library/vendor/Zend/Controller/Action.php +++ /dev/null @@ -1,789 +0,0 @@ -setRequest($request) - ->setResponse($response) - ->_setInvokeArgs($invokeArgs); - $this->_helper = new Zend_Controller_Action_HelperBroker($this); - $this->init(); - } - - /** - * Initialize object - * - * Called from {@link __construct()} as final step of object instantiation. - * - * @return void - */ - public function init() - { - } - - /** - * Initialize View object - * - * Initializes {@link $view} if not otherwise a Zend_View_Interface. - * - * If {@link $view} is not otherwise set, instantiates a new Zend_View - * object, using the 'views' subdirectory at the same level as the - * controller directory for the current module as the base directory. - * It uses this to set the following: - * - script path = views/scripts/ - * - helper path = views/helpers/ - * - filter path = views/filters/ - * - * @return Zend_View_Interface - * @throws Zend_Controller_Exception if base view directory does not exist - */ - public function initView() - { - if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) { - return $this->view; - } - - if (isset($this->view) && ($this->view instanceof Zend_View_Interface)) { - return $this->view; - } - - $request = $this->getRequest(); - $module = $request->getModuleName(); - $dirs = $this->getFrontController()->getControllerDirectory(); - if (empty($module) || !isset($dirs[$module])) { - $module = $this->getFrontController()->getDispatcher()->getDefaultModule(); - } - $baseDir = dirname($dirs[$module]) . DIRECTORY_SEPARATOR . 'views'; - if (!file_exists($baseDir) || !is_dir($baseDir)) { - throw new Zend_Controller_Exception('Missing base view directory ("' . $baseDir . '")'); - } - - $this->view = new Zend_View(array('basePath' => $baseDir)); - - return $this->view; - } - - /** - * Render a view - * - * Renders a view. By default, views are found in the view script path as - *
- * $text = "WHERE date < ?";
- * $date = "2005-01-02";
- * $safe = $sql->quoteInto($text, $date);
- * // $safe = "WHERE date < '2005-01-02'"
- *
- *
- * @param string $text The text with a placeholder.
- * @param mixed $value The value to quote.
- * @param string $type OPTIONAL SQL datatype
- * @param integer $count OPTIONAL count of placeholders to replace
- * @return string An SQL-safe quoted value placed into the original text.
- */
- public function quoteInto($text, $value, $type = null, $count = null)
- {
- if ($count === null) {
- return str_replace('?', $this->quote($value, $type), $text);
- } else {
- return implode($this->quote($value, $type), explode('?', $text, $count + 1));
- }
- }
-
- /**
- * Quotes an identifier.
- *
- * Accepts a string representing a qualified indentifier. For Example:
- *
- * $adapter->quoteIdentifier('myschema.mytable')
- *
- * Returns: "myschema"."mytable"
- *
- * Or, an array of one or more identifiers that may form a qualified identifier:
- *
- * $adapter->quoteIdentifier(array('myschema','my.table'))
- *
- * Returns: "myschema"."my.table"
- *
- * The actual quote character surrounding the identifiers may vary depending on
- * the adapter.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier.
- */
- public function quoteIdentifier($ident, $auto=false)
- {
- return $this->_quoteIdentifierAs($ident, null, $auto);
- }
-
- /**
- * Quote a column identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the column.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- public function quoteColumnAs($ident, $alias, $auto=false)
- {
- return $this->_quoteIdentifierAs($ident, $alias, $auto);
- }
-
- /**
- * Quote a table identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the table.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- public function quoteTableAs($ident, $alias = null, $auto = false)
- {
- return $this->_quoteIdentifierAs($ident, $alias, $auto);
- }
-
- /**
- * Quote an identifier and an optional alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An optional alias.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @param string $as The string to add between the identifier/expression and the alias.
- * @return string The quoted identifier and alias.
- */
- protected function _quoteIdentifierAs($ident, $alias = null, $auto = false, $as = ' AS ')
- {
- if ($ident instanceof Zend_Db_Expr) {
- $quoted = $ident->__toString();
- } elseif ($ident instanceof Zend_Db_Select) {
- $quoted = '(' . $ident->assemble() . ')';
- } else {
- if (is_string($ident)) {
- $ident = explode('.', $ident);
- }
- if (is_array($ident)) {
- $segments = array();
- foreach ($ident as $segment) {
- if ($segment instanceof Zend_Db_Expr) {
- $segments[] = $segment->__toString();
- } else {
- $segments[] = $this->_quoteIdentifier($segment, $auto);
- }
- }
- if ($alias !== null && end($ident) == $alias) {
- $alias = null;
- }
- $quoted = implode('.', $segments);
- } else {
- $quoted = $this->_quoteIdentifier($ident, $auto);
- }
- }
- if ($alias !== null) {
- $quoted .= $as . $this->_quoteIdentifier($alias, $auto);
- }
- return $quoted;
- }
-
- /**
- * Quote an identifier.
- *
- * @param string $value The identifier or expression.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- protected function _quoteIdentifier($value, $auto=false)
- {
- if ($auto === false || $this->_autoQuoteIdentifiers === true) {
- $q = $this->getQuoteIdentifierSymbol();
- return ($q . str_replace("$q", "$q$q", $value) . $q);
- }
- return $value;
- }
-
- /**
- * Returns the symbol the adapter uses for delimited identifiers.
- *
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- return '"';
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- return null;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- return null;
- }
-
- /**
- * Helper method to change the case of the strings used
- * when returning result sets in FETCH_ASSOC and FETCH_BOTH
- * modes.
- *
- * This is not intended to be used by application code,
- * but the method must be public so the Statement class
- * can invoke it.
- *
- * @param string $key
- * @return string
- */
- public function foldCase($key)
- {
- switch ($this->_caseFolding) {
- case Zend_Db::CASE_LOWER:
- $value = strtolower((string) $key);
- break;
- case Zend_Db::CASE_UPPER:
- $value = strtoupper((string) $key);
- break;
- case Zend_Db::CASE_NATURAL:
- default:
- $value = (string) $key;
- }
- return $value;
- }
-
- /**
- * called when object is getting serialized
- * This disconnects the DB object that cant be serialized
- *
- * @throws Zend_Db_Adapter_Exception
- * @return array
- */
- public function __sleep()
- {
- if ($this->_allowSerialization == false) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception(
- get_class($this) . ' is not allowed to be serialized'
- );
- }
- $this->_connection = null;
-
- return array_keys(
- array_diff_key(get_object_vars($this), array('_connection' => null))
- );
- }
-
- /**
- * called when object is getting unserialized
- *
- * @return void
- */
- public function __wakeup()
- {
- if ($this->_autoReconnectOnUnserialize == true) {
- $this->getConnection();
- }
- }
-
- /**
- * Abstract Methods
- */
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- abstract public function listTables();
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- abstract public function describeTable($tableName, $schemaName = null);
-
- /**
- * Creates a connection to the database.
- *
- * @return void
- */
- abstract protected function _connect();
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- abstract public function isConnected();
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- abstract public function closeConnection();
-
- /**
- * Prepare a statement and return a PDOStatement-like object.
- *
- * @param string|Zend_Db_Select $sql SQL query
- * @return Zend_Db_Statement|PDOStatement
- */
- abstract public function prepare($sql);
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- abstract public function lastInsertId($tableName = null, $primaryKey = null);
-
- /**
- * Begin a transaction.
- */
- abstract protected function _beginTransaction();
-
- /**
- * Commit a transaction.
- */
- abstract protected function _commit();
-
- /**
- * Roll-back a transaction.
- */
- abstract protected function _rollBack();
-
- /**
- * Set the fetch mode.
- *
- * @param integer $mode
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- abstract public function setFetchMode($mode);
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param mixed $sql
- * @param integer $count
- * @param integer $offset
- * @return string
- */
- abstract public function limit($sql, $count, $offset = 0);
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- abstract public function supportsParameters($type);
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- abstract public function getServerVersion();
-}
diff --git a/library/vendor/Zend/Db/Adapter/Db2.php b/library/vendor/Zend/Db/Adapter/Db2.php
deleted file mode 100644
index 28793d100..000000000
--- a/library/vendor/Zend/Db/Adapter/Db2.php
+++ /dev/null
@@ -1,827 +0,0 @@
- (string) Connect to the database as this username.
- * password => (string) Password associated with the username.
- * host => (string) What host to connect to (default 127.0.0.1)
- * dbname => (string) The name of the database to user
- * protocol => (string) Protocol to use, defaults to "TCPIP"
- * port => (integer) Port number to use for TCP/IP if protocol is "TCPIP"
- * persistent => (boolean) Set TRUE to use a persistent connection (db2_pconnect)
- * os => (string) This should be set to 'i5' if the db is on an os400/i5
- * schema => (string) The default schema the connection should use
- *
- * @var array
- */
- protected $_config = array(
- 'dbname' => null,
- 'username' => null,
- 'password' => null,
- 'host' => 'localhost',
- 'port' => '50000',
- 'protocol' => 'TCPIP',
- 'persistent' => false,
- 'os' => null,
- 'schema' => null
- );
-
- /**
- * Execution mode
- *
- * @var int execution flag (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
- */
- protected $_execute_mode = DB2_AUTOCOMMIT_ON;
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Db2';
- protected $_isI5 = false;
-
- /**
- * Keys are UPPERCASE SQL datatypes or the constants
- * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
- *
- * Values are:
- * 0 = 32-bit integer
- * 1 = 64-bit integer
- * 2 = float or decimal
- *
- * @var array Associative array of datatypes to values 0, 1, or 2.
- */
- protected $_numericDataTypes = array(
- Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a connection resource.
- *
- * @return void
- */
- protected function _connect()
- {
- if (is_resource($this->_connection)) {
- // connection already exists
- return;
- }
-
- if (!extension_loaded('ibm_db2')) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but the extension is not loaded');
- }
-
- $this->_determineI5();
- if ($this->_config['persistent']) {
- // use persistent connection
- $conn_func_name = 'db2_pconnect';
- } else {
- // use "normal" connection
- $conn_func_name = 'db2_connect';
- }
-
- if (!isset($this->_config['driver_options']['autocommit'])) {
- // set execution mode
- $this->_config['driver_options']['autocommit'] = &$this->_execute_mode;
- }
-
- if (isset($this->_config['options'][Zend_Db::CASE_FOLDING])) {
- $caseAttrMap = array(
- Zend_Db::CASE_NATURAL => DB2_CASE_NATURAL,
- Zend_Db::CASE_UPPER => DB2_CASE_UPPER,
- Zend_Db::CASE_LOWER => DB2_CASE_LOWER
- );
- $this->_config['driver_options']['DB2_ATTR_CASE'] = $caseAttrMap[$this->_config['options'][Zend_Db::CASE_FOLDING]];
- }
-
- if ($this->_isI5 && isset($this->_config['driver_options']['i5_naming'])) {
- if ($this->_config['driver_options']['i5_naming']) {
- $this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_ON;
- } else {
- $this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_OFF;
- }
- }
-
- if ($this->_config['host'] !== 'localhost' && !$this->_isI5) {
- // if the host isn't localhost, use extended connection params
- $dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' .
- ';DATABASE=' . $this->_config['dbname'] .
- ';HOSTNAME=' . $this->_config['host'] .
- ';PORT=' . $this->_config['port'] .
- ';PROTOCOL=' . $this->_config['protocol'] .
- ';UID=' . $this->_config['username'] .
- ';PWD=' . $this->_config['password'] .';';
- $this->_connection = $conn_func_name(
- $dbname,
- null,
- null,
- $this->_config['driver_options']
- );
- } else {
- // host is localhost, so use standard connection params
- $this->_connection = $conn_func_name(
- $this->_config['dbname'],
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['driver_options']
- );
- }
-
- // check the connection
- if (!$this->_connection) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error());
- }
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) (is_resource($this->_connection)
- && get_resource_type($this->_connection) == 'DB2 Connection'));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- db2_close($this->_connection);
- }
- $this->_connection = null;
- }
-
- /**
- * Returns an SQL statement for preparation.
- *
- * @param string $sql The SQL statement with placeholders.
- * @return Zend_Db_Statement_Db2
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Gets the execution mode
- *
- * @return int the execution mode (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
- */
- public function _getExecuteMode()
- {
- return $this->_execute_mode;
- }
-
- /**
- * @param integer $mode
- * @return void
- */
- public function _setExecuteMode($mode)
- {
- switch ($mode) {
- case DB2_AUTOCOMMIT_OFF:
- case DB2_AUTOCOMMIT_ON:
- $this->_execute_mode = $mode;
- db2_autocommit($this->_connection, $mode);
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception("execution mode not supported");
- break;
- }
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- /**
- * Use db2_escape_string() if it is present in the IBM DB2 extension.
- * But some supported versions of PHP do not include this function,
- * so fall back to default quoting in the parent class.
- */
- if (function_exists('db2_escape_string')) {
- return "'" . db2_escape_string($value) . "'";
- }
- return parent::_quote($value);
- }
-
- /**
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- $this->_connect();
- $info = db2_server_info($this->_connection);
- if ($info) {
- $identQuote = $info->IDENTIFIER_QUOTE_CHAR;
- } else {
- // db2_server_info() does not return result on some i5 OS version
- if ($this->_isI5) {
- $identQuote ="'";
- }
- }
- return $identQuote;
- }
-
- /**
- * Returns a list of the tables in the database.
- * @param string $schema OPTIONAL
- * @return array
- */
- public function listTables($schema = null)
- {
- $this->_connect();
-
- if ($schema === null && $this->_config['schema'] != null) {
- $schema = $this->_config['schema'];
- }
-
- $tables = array();
-
- if (!$this->_isI5) {
- if ($schema) {
- $stmt = db2_tables($this->_connection, null, $schema);
- } else {
- $stmt = db2_tables($this->_connection);
- }
- while ($row = db2_fetch_assoc($stmt)) {
- $tables[] = $row['TABLE_NAME'];
- }
- } else {
- $tables = $this->_i5listTables($schema);
- }
-
- return $tables;
- }
-
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * DB2 not supports UNSIGNED integer.
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- // Ensure the connection is made so that _isI5 is set
- $this->_connect();
-
- if ($schemaName === null && $this->_config['schema'] != null) {
- $schemaName = $this->_config['schema'];
- }
-
- if (!$this->_isI5) {
-
- $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
- c.typename, c.default, c.nulls, c.length, c.scale,
- c.identity, tc.type AS tabconsttype, k.colseq
- FROM syscat.columns c
- LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
- ON (k.tabschema = tc.tabschema
- AND k.tabname = tc.tabname
- AND tc.type = 'P'))
- ON (c.tabschema = k.tabschema
- AND c.tabname = k.tabname
- AND c.colname = k.colname)
- WHERE "
- . $this->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
-
- if ($schemaName) {
- $sql .= $this->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
- }
-
- $sql .= " ORDER BY c.colno";
-
- } else {
-
- // DB2 On I5 specific query
- $sql = "SELECT DISTINCT C.TABLE_SCHEMA, C.TABLE_NAME, C.COLUMN_NAME, C.ORDINAL_POSITION,
- C.DATA_TYPE, C.COLUMN_DEFAULT, C.NULLS ,C.LENGTH, C.SCALE, LEFT(C.IDENTITY,1),
- LEFT(tc.TYPE, 1) AS tabconsttype, k.COLSEQ
- FROM QSYS2.SYSCOLUMNS C
- LEFT JOIN (QSYS2.syskeycst k JOIN QSYS2.SYSCST tc
- ON (k.TABLE_SCHEMA = tc.TABLE_SCHEMA
- AND k.TABLE_NAME = tc.TABLE_NAME
- AND LEFT(tc.type,1) = 'P'))
- ON (C.TABLE_SCHEMA = k.TABLE_SCHEMA
- AND C.TABLE_NAME = k.TABLE_NAME
- AND C.COLUMN_NAME = k.COLUMN_NAME)
- WHERE "
- . $this->quoteInto('UPPER(C.TABLE_NAME) = UPPER(?)', $tableName);
-
- if ($schemaName) {
- $sql .= $this->quoteInto(' AND UPPER(C.TABLE_SCHEMA) = UPPER(?)', $schemaName);
- }
-
- $sql .= " ORDER BY C.ORDINAL_POSITION FOR FETCH ONLY";
- }
-
- $desc = array();
- $stmt = $this->query($sql);
-
- /**
- * To avoid case issues, fetch using FETCH_NUM
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- /**
- * The ordering of columns is defined by the query so we can map
- * to variables to improve readability
- */
- $tabschema = 0;
- $tabname = 1;
- $colname = 2;
- $colno = 3;
- $typename = 4;
- $default = 5;
- $nulls = 6;
- $length = 7;
- $scale = 8;
- $identityCol = 9;
- $tabconstType = 10;
- $colseq = 11;
-
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$tabconstType] == 'P') {
- $primary = true;
- $primaryPosition = $row[$colseq];
- }
- /**
- * In IBM DB2, an column can be IDENTITY
- * even if it is not part of the PRIMARY KEY.
- */
- if ($row[$identityCol] == 'Y') {
- $identity = true;
- }
-
- // only colname needs to be case adjusted
- $desc[$this->foldCase($row[$colname])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$tabschema]),
- 'TABLE_NAME' => $this->foldCase($row[$tabname]),
- 'COLUMN_NAME' => $this->foldCase($row[$colname]),
- 'COLUMN_POSITION' => (!$this->_isI5) ? $row[$colno]+1 : $row[$colno],
- 'DATA_TYPE' => $row[$typename],
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
- 'UNSIGNED' => false,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
-
- return $desc;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
-
- if (!$this->_isI5) {
- $quotedSequenceName = $this->quoteIdentifier($sequenceName, true);
- $sql = 'SELECT PREVVAL FOR ' . $quotedSequenceName . ' AS VAL FROM SYSIBM.SYSDUMMY1';
- } else {
- $quotedSequenceName = $sequenceName;
- $sql = 'SELECT PREVVAL FOR ' . $this->quoteIdentifier($sequenceName, true) . ' AS VAL FROM QSYS2.QSQPTABL';
- }
-
- $value = $this->fetchOne($sql);
- return (string) $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $sql = 'SELECT NEXTVAL FOR '.$this->quoteIdentifier($sequenceName, true).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->fetchOne($sql);
- return (string) $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * The IDENTITY_VAL_LOCAL() function gives the last generated identity value
- * in the current process, even if it was for a GENERATED column.
- *
- * @param string $tableName OPTIONAL
- * @param string $primaryKey OPTIONAL
- * @param string $idType OPTIONAL used for i5 platform to define sequence/idenity unique value
- * @return string
- */
-
- public function lastInsertId($tableName = null, $primaryKey = null, $idType = null)
- {
- $this->_connect();
-
- if ($this->_isI5) {
- return (string) $this->_i5LastInsertId($tableName, $idType);
- }
-
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
-
- $sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->fetchOne($sql);
- return (string) $value;
- }
-
- /**
- * Begin a transaction.
- *
- * @return void
- */
- protected function _beginTransaction()
- {
- $this->_setExecuteMode(DB2_AUTOCOMMIT_OFF);
- }
-
- /**
- * Commit a transaction.
- *
- * @return void
- */
- protected function _commit()
- {
- if (!db2_commit($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception(
- db2_conn_errormsg($this->_connection),
- db2_conn_error($this->_connection));
- }
-
- $this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
- }
-
- /**
- * Rollback a transaction.
- *
- * @return void
- */
- protected function _rollBack()
- {
- if (!db2_rollback($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception(
- db2_conn_errormsg($this->_connection),
- db2_conn_error($this->_connection));
- }
- $this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
- }
-
- /**
- * Set the fetch mode.
- *
- * @param integer $mode
- * @return void
- * @throws Zend_Db_Adapter_Db2_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_NUM: // seq array
- case Zend_Db::FETCH_ASSOC: // assoc array
- case Zend_Db::FETCH_BOTH: // seq+assoc array
- case Zend_Db::FETCH_OBJ: // object
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- if ($offset == 0) {
- $limit_sql = $sql . " FETCH FIRST $count ROWS ONLY";
- return $limit_sql;
- }
-
- /**
- * DB2 does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT ROW_NUMBER() OVER() AS \"ZEND_DB_ROWNUM\", z1.*
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.zend_db_rownum BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- return $limit_sql;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- if ($type == 'positional') {
- return true;
- }
-
- // if its 'named' or anything else
- return false;
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $server_info = db2_server_info($this->_connection);
- if ($server_info !== false) {
- $version = $server_info->DBMS_VER;
- if ($this->_isI5) {
- $version = (int) substr($version, 0, 2) . '.' . (int) substr($version, 2, 2) . '.' . (int) substr($version, 4);
- }
- return $version;
- } else {
- return null;
- }
- }
-
- /**
- * Return whether or not this is running on i5
- *
- * @return bool
- */
- public function isI5()
- {
- if ($this->_isI5 === null) {
- $this->_determineI5();
- }
-
- return (bool) $this->_isI5;
- }
-
- /**
- * Check the connection parameters according to verify
- * type of used OS
- *
- * @return void
- */
- protected function _determineI5()
- {
- // first us the compiled flag.
- $this->_isI5 = (php_uname('s') == 'OS400') ? true : false;
-
- // if this is set, then us it
- if (isset($this->_config['os'])){
- if (strtolower($this->_config['os']) === 'i5') {
- $this->_isI5 = true;
- } else {
- // any other value passed in, its null
- $this->_isI5 = false;
- }
- }
-
- }
-
- /**
- * Db2 On I5 specific method
- *
- * Returns a list of the tables in the database .
- * Used only for DB2/400.
- *
- * @return array
- */
- protected function _i5listTables($schema = null)
- {
- //list of i5 libraries.
- $tables = array();
- if ($schema) {
- $tablesStatement = db2_tables($this->_connection, null, $schema);
- while ($rowTables = db2_fetch_assoc($tablesStatement) ) {
- if ($rowTables['TABLE_NAME'] !== null) {
- $tables[] = $rowTables['TABLE_NAME'];
- }
- }
- } else {
- $schemaStatement = db2_tables($this->_connection);
- while ($schema = db2_fetch_assoc($schemaStatement)) {
- if ($schema['TABLE_SCHEM'] !== null) {
- // list of the tables which belongs to the selected library
- $tablesStatement = db2_tables($this->_connection, NULL, $schema['TABLE_SCHEM']);
- if (is_resource($tablesStatement)) {
- while ($rowTables = db2_fetch_assoc($tablesStatement) ) {
- if ($rowTables['TABLE_NAME'] !== null) {
- $tables[] = $rowTables['TABLE_NAME'];
- }
- }
- }
- }
- }
- }
-
- return $tables;
- }
-
- protected function _i5LastInsertId($objectName = null, $idType = null)
- {
-
- if ($objectName === null) {
- $sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM QSYS2.QSQPTABL';
- $value = $this->fetchOne($sql);
- return $value;
- }
-
- if (strtoupper($idType) === 'S'){
- //check i5_lib option
- $sequenceName = $objectName;
- return $this->lastSequenceId($sequenceName);
- }
-
- //returns last identity value for the specified table
- //if (strtoupper($idType) === 'I') {
- $tableName = $objectName;
- return $this->fetchOne('SELECT IDENTITY_VAL_LOCAL() from ' . $this->quoteIdentifier($tableName));
- }
-
-}
-
-
diff --git a/library/vendor/Zend/Db/Adapter/Db2/Exception.php b/library/vendor/Zend/Db/Adapter/Db2/Exception.php
deleted file mode 100644
index d12dc48e6..000000000
--- a/library/vendor/Zend/Db/Adapter/Db2/Exception.php
+++ /dev/null
@@ -1,44 +0,0 @@
-getCode();
- }
- parent::__construct($message, $code, $e);
- }
-
- public function hasChainedException()
- {
- return ($this->getPrevious() !== null);
- }
-
- public function getChainedException()
- {
- return $this->getPrevious();
- }
-
-}
diff --git a/library/vendor/Zend/Db/Adapter/Mysqli.php b/library/vendor/Zend/Db/Adapter/Mysqli.php
deleted file mode 100644
index 087d3ac16..000000000
--- a/library/vendor/Zend/Db/Adapter/Mysqli.php
+++ /dev/null
@@ -1,543 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'MEDIUMINT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'SERIAL' => Zend_Db::BIGINT_TYPE,
- 'DEC' => Zend_Db::FLOAT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'FIXED' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * @var Zend_Db_Statement_Mysqli
- */
- protected $_stmt = null;
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Mysqli';
-
- /**
- * Quote a raw string.
- *
- * @param mixed $value Raw string
- *
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- $this->_connect();
- return "'" . $this->_connection->real_escape_string($value) . "'";
- }
-
- /**
- * Returns the symbol the adapter uses for delimiting identifiers.
- *
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- return "`";
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $result = array();
- // Use mysqli extension API, because SHOW doesn't work
- // well as a prepared statement on MySQL 4.1.
- $sql = 'SHOW TABLES';
- if ($queryResult = $this->getConnection()->query($sql)) {
- while ($row = $queryResult->fetch_row()) {
- $result[] = $row[0];
- }
- $queryResult->close();
- } else {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception($this->getConnection()->error);
- }
- return $result;
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- /**
- * @todo use INFORMATION_SCHEMA someday when
- * MySQL's implementation isn't too slow.
- */
-
- if ($schemaName) {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier("$schemaName.$tableName", true);
- } else {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier($tableName, true);
- }
-
- /**
- * Use mysqli extension API, because DESCRIBE doesn't work
- * well as a prepared statement on MySQL 4.1.
- */
- if ($queryResult = $this->getConnection()->query($sql)) {
- while ($row = $queryResult->fetch_assoc()) {
- $result[] = $row;
- }
- $queryResult->close();
- } else {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception($this->getConnection()->error);
- }
-
- $desc = array();
-
- $row_defaults = array(
- 'Length' => null,
- 'Scale' => null,
- 'Precision' => null,
- 'Unsigned' => null,
- 'Primary' => false,
- 'PrimaryPosition' => null,
- 'Identity' => false
- );
- $i = 1;
- $p = 1;
- foreach ($result as $key => $row) {
- $row = array_merge($row_defaults, $row);
- if (preg_match('/unsigned/', $row['Type'])) {
- $row['Unsigned'] = true;
- }
- if (preg_match('/^((?:var)?char)\((\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = $matches[1];
- $row['Length'] = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = 'decimal';
- $row['Precision'] = $matches[1];
- $row['Scale'] = $matches[2];
- } else if (preg_match('/^float\((\d+),(\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = 'float';
- $row['Precision'] = $matches[1];
- $row['Scale'] = $matches[2];
- } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = $matches[1];
- /**
- * The optional argument of a MySQL int type is not precision
- * or length; it is only a hint for display width.
- */
- }
- if (strtoupper($row['Key']) == 'PRI') {
- $row['Primary'] = true;
- $row['PrimaryPosition'] = $p;
- if ($row['Extra'] == 'auto_increment') {
- $row['Identity'] = true;
- } else {
- $row['Identity'] = false;
- }
- ++$p;
- }
- $desc[$this->foldCase($row['Field'])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($tableName),
- 'COLUMN_NAME' => $this->foldCase($row['Field']),
- 'COLUMN_POSITION' => $i,
- 'DATA_TYPE' => $row['Type'],
- 'DEFAULT' => $row['Default'],
- 'NULLABLE' => (bool) ($row['Null'] == 'YES'),
- 'LENGTH' => $row['Length'],
- 'SCALE' => $row['Scale'],
- 'PRECISION' => $row['Precision'],
- 'UNSIGNED' => $row['Unsigned'],
- 'PRIMARY' => $row['Primary'],
- 'PRIMARY_POSITION' => $row['PrimaryPosition'],
- 'IDENTITY' => $row['Identity']
- );
- ++$i;
- }
- return $desc;
- }
-
- /**
- * Creates a connection to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Mysqli_Exception
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
-
- if (!extension_loaded('mysqli')) {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded');
- }
-
- if (isset($this->_config['port'])) {
- $port = (integer) $this->_config['port'];
- } else {
- $port = null;
- }
-
- if (isset($this->_config['socket'])) {
- $socket = $this->_config['socket'];
- } else {
- $socket = null;
- }
-
- $this->_connection = mysqli_init();
-
- if(!empty($this->_config['driver_options'])) {
- foreach($this->_config['driver_options'] as $option=>$value) {
- if(is_string($option)) {
- // Suppress warnings here
- // Ignore it if it's not a valid constant
- $option = @constant(strtoupper($option));
- if($option === null)
- continue;
- }
- mysqli_options($this->_connection, $option, $value);
- }
- }
-
- // Suppress connection warnings here.
- // Throw an exception instead.
- $_isConnected = @mysqli_real_connect(
- $this->_connection,
- $this->_config['host'],
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['dbname'],
- $port,
- $socket
- );
-
- if ($_isConnected === false || mysqli_connect_errno()) {
-
- $this->closeConnection();
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error());
- }
-
- if (!empty($this->_config['charset'])) {
- mysqli_set_charset($this->_connection, $this->_config['charset']);
- }
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) ($this->_connection instanceof mysqli));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- $this->_connection->close();
- }
- $this->_connection = null;
- }
-
- /**
- * Prepare a statement and return a PDOStatement-like object.
- *
- * @param string $sql SQL query
- * @return Zend_Db_Statement_Mysqli
- */
- public function prepare($sql)
- {
- $this->_connect();
- if ($this->_stmt) {
- $this->_stmt->close();
- }
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- if ($stmt === false) {
- return false;
- }
- $stmt->setFetchMode($this->_fetchMode);
- $this->_stmt = $stmt;
- return $stmt;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * MySQL does not support sequences, so $tableName and $primaryKey are ignored.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- * @todo Return value should be int?
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $mysqli = $this->_connection;
- return (string) $mysqli->insert_id;
- }
-
- /**
- * Begin a transaction.
- *
- * @return void
- */
- protected function _beginTransaction()
- {
- $this->_connect();
- $this->_connection->autocommit(false);
- }
-
- /**
- * Commit a transaction.
- *
- * @return void
- */
- protected function _commit()
- {
- $this->_connect();
- $this->_connection->commit();
- $this->_connection->autocommit(true);
- }
-
- /**
- * Roll-back a transaction.
- *
- * @return void
- */
- protected function _rollBack()
- {
- $this->_connect();
- $this->_connection->rollback();
- $this->_connection->autocommit(true);
- }
-
- /**
- * Set the fetch mode.
- *
- * @param int $mode
- * @return void
- * @throws Zend_Db_Adapter_Mysqli_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_LAZY:
- case Zend_Db::FETCH_ASSOC:
- case Zend_Db::FETCH_NUM:
- case Zend_Db::FETCH_BOTH:
- case Zend_Db::FETCH_NAMED:
- case Zend_Db::FETCH_OBJ:
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception("Invalid fetch mode '$mode' specified");
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param int $count
- * @param int $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- throw new Zend_Db_Adapter_Mysqli_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- switch ($type) {
- case 'positional':
- return true;
- case 'named':
- default:
- return false;
- }
- }
-
- /**
- * Retrieve server version in PHP style
- *
- *@return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $version = $this->_connection->server_version;
- $major = (int) ($version / 10000);
- $minor = (int) ($version % 10000 / 100);
- $revision = (int) ($version % 100);
- return $major . '.' . $minor . '.' . $revision;
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Mysqli/Exception.php b/library/vendor/Zend/Db/Adapter/Mysqli/Exception.php
deleted file mode 100644
index 9c94adcc9..000000000
--- a/library/vendor/Zend/Db/Adapter/Mysqli/Exception.php
+++ /dev/null
@@ -1,39 +0,0 @@
- (string) Connect to the database as this username.
- * password => (string) Password associated with the username.
- * dbname => Either the name of the local Oracle instance, or the
- * name of the entry in tnsnames.ora to which you want to connect.
- * persistent => (boolean) Set TRUE to use a persistent connection
- * @var array
- */
- protected $_config = array(
- 'dbname' => null,
- 'username' => null,
- 'password' => null,
- 'persistent' => false
- );
-
- /**
- * Keys are UPPERCASE SQL datatypes or the constants
- * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
- *
- * Values are:
- * 0 = 32-bit integer
- * 1 = 64-bit integer
- * 2 = float or decimal
- *
- * @var array Associative array of datatypes to values 0, 1, or 2.
- */
- protected $_numericDataTypes = array(
- Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE,
- 'NUMBER' => Zend_Db::FLOAT_TYPE,
- );
-
- /**
- * @var integer
- */
- protected $_execute_mode = null;
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Oracle';
-
- /**
- * Check if LOB field are returned as string
- * instead of OCI-Lob object
- *
- * @var boolean
- */
- protected $_lobAsString = null;
-
- /**
- * Creates a connection resource.
- *
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- protected function _connect()
- {
- if (is_resource($this->_connection)) {
- // connection already exists
- return;
- }
-
- if (!extension_loaded('oci8')) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but the extension is not loaded');
- }
-
- $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
-
- $connectionFuncName = ($this->_config['persistent'] == true) ? 'oci_pconnect' : 'oci_connect';
-
- $this->_connection = @$connectionFuncName(
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['dbname'],
- $this->_config['charset']);
-
- // check the connection
- if (!$this->_connection) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception(oci_error());
- }
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) (is_resource($this->_connection)
- && (get_resource_type($this->_connection) == 'oci8 connection'
- || get_resource_type($this->_connection) == 'oci8 persistent connection')));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- oci_close($this->_connection);
- }
- $this->_connection = null;
- }
-
- /**
- * Activate/deactivate return of LOB as string
- *
- * @param string $lob_as_string
- * @return Zend_Db_Adapter_Oracle
- */
- public function setLobAsString($lobAsString)
- {
- $this->_lobAsString = (bool) $lobAsString;
- return $this;
- }
-
- /**
- * Return whether or not LOB are returned as string
- *
- * @return boolean
- */
- public function getLobAsString()
- {
- if ($this->_lobAsString === null) {
- // if never set by user, we use driver option if it exists otherwise false
- if (isset($this->_config['driver_options']) &&
- isset($this->_config['driver_options']['lob_as_string'])) {
- $this->_lobAsString = (bool) $this->_config['driver_options']['lob_as_string'];
- } else {
- $this->_lobAsString = false;
- }
- }
- return $this->_lobAsString;
- }
-
- /**
- * Returns an SQL statement for preparation.
- *
- * @param string $sql The SQL statement with placeholders.
- * @return Zend_Db_Statement_Oracle
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- if ($stmt instanceof Zend_Db_Statement_Oracle) {
- $stmt->setLobAsString($this->getLobAsString());
- }
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- $value = str_replace("'", "''", $value);
- return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
- }
-
- /**
- * Quote a table identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the table.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- public function quoteTableAs($ident, $alias = null, $auto = false)
- {
- // Oracle doesn't allow the 'AS' keyword between the table identifier/expression and alias.
- return $this->_quoteIdentifierAs($ident, $alias, $auto, ' ');
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- $sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual';
- $value = $this->fetchOne($sql);
- return $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual';
- $value = $this->fetchOne($sql);
- return $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * Oracle does not support IDENTITY columns, so if the sequence is not
- * specified, this method returns null.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
-
- // No support for IDENTITY columns; return null
- return null;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $this->_connect();
- $data = $this->fetchCol('SELECT table_name FROM all_tables');
- return $data;
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $version = $this->getServerVersion();
- if (($version === null) || version_compare($version, '9.0.0', '>=')) {
- $sql = "SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC
- LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
- ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
- ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- } else {
- $subSql="SELECT AC.OWNER, AC.TABLE_NAME, ACC.COLUMN_NAME, AC.CONSTRAINT_TYPE, ACC.POSITION
- from ALL_CONSTRAINTS AC, ALL_CONS_COLUMNS ACC
- WHERE ACC.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
- AND ACC.TABLE_NAME = AC.TABLE_NAME
- AND ACC.OWNER = AC.OWNER
- AND AC.CONSTRAINT_TYPE = 'P'
- AND UPPER(AC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $subSql .= ' AND UPPER(ACC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql="SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, CC.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC, ($subSql) CC
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)
- AND TC.OWNER = CC.OWNER(+) AND TC.TABLE_NAME = CC.TABLE_NAME(+) AND TC.COLUMN_NAME = CC.COLUMN_NAME(+)";
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- }
-
- $stmt = $this->query($sql, $bind);
-
- /**
- * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $table_name = 0;
- $owner = 1;
- $column_name = 2;
- $data_type = 3;
- $data_default = 4;
- $nullable = 5;
- $column_id = 6;
- $data_length = 7;
- $data_scale = 8;
- $data_precision = 9;
- $constraint_type = 10;
- $position = 11;
-
- $desc = array();
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$constraint_type] == 'P') {
- $primary = true;
- $primaryPosition = $row[$position];
- /**
- * Oracle does not support auto-increment keys.
- */
- $identity = false;
- }
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$owner]),
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => $row[$column_id],
- 'DATA_TYPE' => $row[$data_type],
- 'DEFAULT' => $row[$data_default],
- 'NULLABLE' => (bool) ($row[$nullable] == 'Y'),
- 'LENGTH' => $row[$data_length],
- 'SCALE' => $row[$data_scale],
- 'PRECISION' => $row[$data_precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Leave autocommit mode and begin a transaction.
- *
- * @return void
- */
- protected function _beginTransaction()
- {
- $this->_setExecuteMode(OCI_DEFAULT);
- }
-
- /**
- * Commit a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- protected function _commit()
- {
- if (!oci_commit($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection));
- }
- $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
- }
-
- /**
- * Roll back a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- protected function _rollBack()
- {
- if (!oci_rollback($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection));
- }
- $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
- }
-
- /**
- * Set the fetch mode.
- *
- * @todo Support FETCH_CLASS and FETCH_INTO.
- *
- * @param integer $mode A fetch mode.
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_NUM: // seq array
- case Zend_Db::FETCH_ASSOC: // assoc array
- case Zend_Db::FETCH_BOTH: // seq+assoc array
- case Zend_Db::FETCH_OBJ: // object
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- /**
- * Oracle does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT z1.*, ROWNUM AS \"zend_db_rownum\"
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.\"zend_db_rownum\" BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- return $limit_sql;
- }
-
- /**
- * @param integer $mode
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- private function _setExecuteMode($mode)
- {
- switch($mode) {
- case OCI_COMMIT_ON_SUCCESS:
- case OCI_DEFAULT:
- case OCI_DESCRIBE_ONLY:
- $this->_execute_mode = $mode;
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- throw new Zend_Db_Adapter_Oracle_Exception("Invalid execution mode '$mode' specified");
- break;
- }
- }
-
- /**
- * @return int
- */
- public function _getExecuteMode()
- {
- return $this->_execute_mode;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- switch ($type) {
- case 'named':
- return true;
- case 'positional':
- default:
- return false;
- }
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $version = oci_server_version($this->_connection);
- if ($version !== false) {
- $matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
- return $matches[1];
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Oracle/Exception.php b/library/vendor/Zend/Db/Adapter/Oracle/Exception.php
deleted file mode 100644
index 6b7d91471..000000000
--- a/library/vendor/Zend/Db/Adapter/Oracle/Exception.php
+++ /dev/null
@@ -1,59 +0,0 @@
-message = $error['code'] .' '. $error['message'];
- } else {
- $this->message = $error['code'] .' '. $error['message']." "
- . substr($error['sqltext'], 0, $error['offset'])
- . "*"
- . substr($error['sqltext'], $error['offset']);
- }
- $this->code = $error['code'];
- } else if (is_string($error)) {
- $this->message = $error;
- }
- if (!$this->code && $code) {
- $this->code = $code;
- }
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Abstract.php b/library/vendor/Zend/Db/Adapter/Pdo/Abstract.php
deleted file mode 100644
index 3a0e13ebf..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Abstract.php
+++ /dev/null
@@ -1,397 +0,0 @@
-_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- // baseline of DSN parts
- $dsn = $this->_config;
-
- // don't pass the username, password, charset, persistent and driver_options in the DSN
- unset($dsn['username']);
- unset($dsn['password']);
- unset($dsn['options']);
- unset($dsn['charset']);
- unset($dsn['persistent']);
- unset($dsn['driver_options']);
-
- // use all remaining parts in the DSN
- foreach ($dsn as $key => $val) {
- $dsn[$key] = "$key=$val";
- }
-
- return $this->_pdoType . ':' . implode(';', $dsn);
- }
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- // if we already have a PDO object, no need to re-connect.
- if ($this->_connection) {
- return;
- }
-
- // get the dsn first, because some adapters alter the $_pdoType
- $dsn = $this->_dsn();
-
- // check for PDO extension
- if (!extension_loaded('pdo')) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
- }
-
- // check the PDO driver is available
- if (!in_array($this->_pdoType, PDO::getAvailableDrivers())) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception('The ' . $this->_pdoType . ' driver is not currently installed');
- }
-
- // create PDO connection
- $q = $this->_profiler->queryStart('connect', Zend_Db_Profiler::CONNECT);
-
- // add the persistence flag if we find it in our config array
- if (isset($this->_config['persistent']) && ($this->_config['persistent'] == true)) {
- $this->_config['driver_options'][PDO::ATTR_PERSISTENT] = true;
- }
-
- try {
- $this->_connection = new PDO(
- $dsn,
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['driver_options']
- );
-
- $this->_profiler->queryEnd($q);
-
- // set the PDO connection to perform case-folding on array keys, or not
- $this->_connection->setAttribute(PDO::ATTR_CASE, $this->_caseFolding);
-
- // always use exceptions.
- $this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- } catch (PDOException $e) {
- $message = $e->getMessage();
- if ($e->getPrevious() !== null && preg_match('~^SQLSTATE\[HY000\] \[\d{1,4}\]\s$~', $message)) {
- // See https://bugs.php.net/bug.php?id=76604
- $message .= $e->getPrevious()->getMessage();
- }
-
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception($message, $e->getCode(), $e);
- }
-
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) ($this->_connection instanceof PDO));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- $this->_connection = null;
- }
-
- /**
- * Prepares an SQL statement.
- *
- * @param string $sql The SQL statement with placeholders.
- * @param array $bind An array of data to bind to the placeholders.
- * @return PDOStatement
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * On RDBMS brands that don't support sequences, $tableName and $primaryKey
- * are ignored.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $this->_connect();
- return $this->_connection->lastInsertId();
- }
-
- /**
- * Special handling for PDO query().
- * All bind parameter names must begin with ':'
- *
- * @param string|Zend_Db_Select $sql The SQL statement with placeholders.
- * @param array $bind An array of data to bind to the placeholders.
- * @return Zend_Db_Statement_Pdo
- * @throws Zend_Db_Adapter_Exception To re-throw PDOException.
- */
- public function query($sql, $bind = array())
- {
- if (empty($bind) && $sql instanceof Zend_Db_Select) {
- $bind = $sql->getBind();
- }
-
- if (is_array($bind)) {
- foreach ($bind as $name => $value) {
- if (!is_int($name) && !preg_match('/^:/', $name)) {
- $newName = ":$name";
- unset($bind[$name]);
- $bind[$newName] = $value;
- }
- }
- }
-
- try {
- return parent::query($sql, $bind);
- } catch (PDOException $e) {
- /**
- * @see Zend_Db_Statement_Exception
- */
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Executes an SQL statement and return the number of affected rows
- *
- * @param mixed $sql The SQL statement with placeholders.
- * May be a string or Zend_Db_Select.
- * @return integer Number of rows that were modified
- * or deleted by the SQL statement
- */
- public function exec($sql)
- {
- if ($sql instanceof Zend_Db_Select) {
- $sql = $sql->assemble();
- }
-
- try {
- $affected = $this->getConnection()->exec($sql);
-
- if ($affected === false) {
- $errorInfo = $this->getConnection()->errorInfo();
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception($errorInfo[2]);
- }
-
- return $affected;
- } catch (PDOException $e) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if ($value === null) {
- $value = '';
- } elseif (is_int($value) || is_float($value)) {
- return $value;
- }
- $this->_connect();
- return $this->_connection->quote($value);
- }
-
- /**
- * Begin a transaction.
- */
- protected function _beginTransaction()
- {
- $this->_connect();
- $this->_connection->beginTransaction();
- }
-
- /**
- * Commit a transaction.
- */
- protected function _commit()
- {
- $this->_connect();
- $this->_connection->commit();
- }
-
- /**
- * Roll-back a transaction.
- */
- protected function _rollBack() {
- $this->_connect();
- $this->_connection->rollBack();
- }
-
- /**
- * Set the PDO fetch mode.
- *
- * @todo Support FETCH_CLASS and FETCH_INTO.
- *
- * @param int $mode A PDO fetch mode.
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- public function setFetchMode($mode)
- {
- //check for PDO extension
- if (!extension_loaded('pdo')) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
- }
- switch ($mode) {
- case PDO::FETCH_LAZY:
- case PDO::FETCH_ASSOC:
- case PDO::FETCH_NUM:
- case PDO::FETCH_BOTH:
- case PDO::FETCH_NAMED:
- case PDO::FETCH_OBJ:
- $this->_fetchMode = $mode;
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- switch ($type) {
- case 'positional':
- case 'named':
- default:
- return true;
- }
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- try {
- $version = $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
- } catch (PDOException $e) {
- // In case of the driver doesn't support getting attributes
- return null;
- }
- $matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
- return $matches[1];
- } else {
- return null;
- }
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Ibm.php b/library/vendor/Zend/Db/Adapter/Pdo/Ibm.php
deleted file mode 100644
index cfb11a35f..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Ibm.php
+++ /dev/null
@@ -1,354 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DEC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * The IBM data server is set.
- * Current options are DB2 or IDS
- * @todo also differentiate between z/OS and i/5
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- public function _connect()
- {
- if ($this->_connection) {
- return;
- }
- parent::_connect();
-
- $this->getConnection()->setAttribute(Zend_Db::ATTR_STRINGIFY_FETCHES, true);
-
- try {
- if ($this->_serverType === null) {
- $server = substr($this->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3);
-
- switch ($server) {
- case 'DB2':
- $this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Db2($this);
-
- // Add DB2-specific numeric types
- $this->_numericDataTypes['DECFLOAT'] = Zend_Db::FLOAT_TYPE;
- $this->_numericDataTypes['DOUBLE'] = Zend_Db::FLOAT_TYPE;
- $this->_numericDataTypes['NUM'] = Zend_Db::FLOAT_TYPE;
-
- break;
- case 'IDS':
- $this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Ids($this);
-
- // Add IDS-specific numeric types
- $this->_numericDataTypes['SERIAL'] = Zend_Db::INT_TYPE;
- $this->_numericDataTypes['SERIAL8'] = Zend_Db::BIGINT_TYPE;
- $this->_numericDataTypes['INT8'] = Zend_Db::BIGINT_TYPE;
- $this->_numericDataTypes['SMALLFLOAT'] = Zend_Db::FLOAT_TYPE;
- $this->_numericDataTypes['MONEY'] = Zend_Db::FLOAT_TYPE;
-
- break;
- }
- }
- } catch (PDOException $e) {
- /** @see Zend_Db_Adapter_Exception */
- $error = strpos($e->getMessage(), 'driver does not support that attribute');
- if ($error) {
- throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later", 0, $e);
- } else {
- throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
- }
-
- /**
- * Creates a PDO DSN for the adapter from $this->_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- $this->_checkRequiredOptions($this->_config);
-
- // check if using full connection string
- if (array_key_exists('host', $this->_config)) {
- $dsn = ';DATABASE=' . $this->_config['dbname']
- . ';HOSTNAME=' . $this->_config['host']
- . ';PORT=' . $this->_config['port']
- // PDO_IBM supports only DB2 TCPIP protocol
- . ';PROTOCOL=' . 'TCPIP;';
- } else {
- // catalogued connection
- $dsn = $this->_config['dbname'];
- }
- return $this->_pdoType . ': ' . $dsn;
- }
-
- /**
- * Checks required options
- *
- * @param array $config
- * @throws Zend_Db_Adapter_Exception
- * @return void
- */
- protected function _checkRequiredOptions(array $config)
- {
- parent::_checkRequiredOptions($config);
-
- if (array_key_exists('host', $this->_config) &&
- !array_key_exists('port', $config)) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified");
- }
- }
-
- /**
- * Prepares an SQL statement.
- *
- * @param string $sql The SQL statement with placeholders.
- * @param array $bind An array of data to bind to the placeholders.
- * @return PDOStatement
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $this->_connect();
- return $this->_serverType->listTables();
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $this->_connect();
- return $this->_serverType->describeTable($tableName, $schemaName);
- }
-
- /**
- * Inserts a table row with specified data.
- * Special handling for PDO_IBM
- * remove empty slots
- *
- * @param mixed $table The table to insert data into.
- * @param array $bind Column-value pairs.
- * @return int The number of affected rows.
- */
- public function insert($table, array $bind)
- {
- $this->_connect();
- $newbind = array();
- if (is_array($bind)) {
- foreach ($bind as $name => $value) {
- if($value !== null) {
- $newbind[$name] = $value;
- }
- }
- }
-
- return parent::insert($table, $newbind);
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $this->_connect();
- return $this->_serverType->limit($sql, $count, $offset);
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT
- * column.
- *
- * @param string $tableName OPTIONAL
- * @param string $primaryKey OPTIONAL
- * @return integer
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $this->_connect();
-
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
-
- $id = $this->getConnection()->lastInsertId();
-
- return $id;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- return $this->_serverType->lastSequenceId($sequenceName);
- }
-
- /**
- * Generate a new value from the specified sequence in the database,
- * and return it.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- return $this->_serverType->nextSequenceId($sequenceName);
- }
-
- /**
- * Retrieve server version in PHP style
- * Pdo_Idm doesn't support getAttribute(PDO::ATTR_SERVER_VERSION)
- * @return string
- */
- public function getServerVersion()
- {
- try {
- $stmt = $this->query('SELECT service_level, fixpack_num FROM TABLE (sysproc.env_get_inst_info()) as INSTANCEINFO');
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- if (count($result)) {
- $matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $result[0][0], $matches)) {
- return $matches[1];
- } else {
- return null;
- }
- }
- return null;
- } catch (PDOException $e) {
- return null;
- }
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Ibm/Db2.php b/library/vendor/Zend/Db/Adapter/Pdo/Ibm/Db2.php
deleted file mode 100644
index 1c11c8bd8..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Ibm/Db2.php
+++ /dev/null
@@ -1,224 +0,0 @@
-_adapter = $adapter;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT tabname "
- . "FROM SYSCAT.TABLES ";
- return $this->_adapter->fetchCol($sql);
- }
-
- /**
- * DB2 catalog lookup for describe table
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
- c.typename, c.default, c.nulls, c.length, c.scale,
- c.identity, tc.type AS tabconsttype, k.colseq
- FROM syscat.columns c
- LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
- ON (k.tabschema = tc.tabschema
- AND k.tabname = tc.tabname
- AND tc.type = 'P'))
- ON (c.tabschema = k.tabschema
- AND c.tabname = k.tabname
- AND c.colname = k.colname)
- WHERE "
- . $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
- if ($schemaName) {
- $sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
- }
- $sql .= " ORDER BY c.colno";
-
- $desc = array();
- $stmt = $this->_adapter->query($sql);
-
- /**
- * To avoid case issues, fetch using FETCH_NUM
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- /**
- * The ordering of columns is defined by the query so we can map
- * to variables to improve readability
- */
- $tabschema = 0;
- $tabname = 1;
- $colname = 2;
- $colno = 3;
- $typename = 4;
- $default = 5;
- $nulls = 6;
- $length = 7;
- $scale = 8;
- $identityCol = 9;
- $tabconstype = 10;
- $colseq = 11;
-
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$tabconstype] == 'P') {
- $primary = true;
- $primaryPosition = $row[$colseq];
- }
- /**
- * In IBM DB2, an column can be IDENTITY
- * even if it is not part of the PRIMARY KEY.
- */
- if ($row[$identityCol] == 'Y') {
- $identity = true;
- }
-
- $desc[$this->_adapter->foldCase($row[$colname])] = array(
- 'SCHEMA_NAME' => $this->_adapter->foldCase($row[$tabschema]),
- 'TABLE_NAME' => $this->_adapter->foldCase($row[$tabname]),
- 'COLUMN_NAME' => $this->_adapter->foldCase($row[$colname]),
- 'COLUMN_POSITION' => $row[$colno]+1,
- 'DATA_TYPE' => $row[$typename],
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
- 'UNSIGNED' => false,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
-
- return $desc;
- }
-
- /**
- * Adds a DB2-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- } else {
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- if ($offset == 0 && $count > 0) {
- $limit_sql = $sql . " FETCH FIRST $count ROWS ONLY";
- return $limit_sql;
- }
- /**
- * DB2 does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT ROW_NUMBER() OVER() AS \"ZEND_DB_ROWNUM\", z1.*
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.zend_db_rownum BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- }
- return $limit_sql;
- }
-
- /**
- * DB2-specific last sequence id
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $sql = 'SELECT PREVVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-
- /**
- * DB2-specific sequence id value
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $sql = 'SELECT NEXTVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Ibm/Ids.php b/library/vendor/Zend/Db/Adapter/Pdo/Ibm/Ids.php
deleted file mode 100644
index eeec43f28..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Ibm/Ids.php
+++ /dev/null
@@ -1,297 +0,0 @@
-_adapter = $adapter;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT tabname "
- . "FROM systables ";
-
- return $this->_adapter->fetchCol($sql);
- }
-
- /**
- * IDS catalog lookup for describe table
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- // this is still a work in progress
-
- $sql= "SELECT DISTINCT t.owner, t.tabname, c.colname, c.colno, c.coltype,
- d.default, c.collength, t.tabid
- FROM syscolumns c
- JOIN systables t ON c.tabid = t.tabid
- LEFT JOIN sysdefaults d ON c.tabid = d.tabid AND c.colno = d.colno
- WHERE "
- . $this->_adapter->quoteInto('UPPER(t.tabname) = UPPER(?)', $tableName);
- if ($schemaName) {
- $sql .= $this->_adapter->quoteInto(' AND UPPER(t.owner) = UPPER(?)', $schemaName);
- }
- $sql .= " ORDER BY c.colno";
-
- $desc = array();
- $stmt = $this->_adapter->query($sql);
-
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- /**
- * The ordering of columns is defined by the query so we can map
- * to variables to improve readability
- */
- $tabschema = 0;
- $tabname = 1;
- $colname = 2;
- $colno = 3;
- $typename = 4;
- $default = 5;
- $length = 6;
- $tabid = 7;
-
- $primaryCols = null;
-
- foreach ($result as $key => $row) {
- $primary = false;
- $primaryPosition = null;
-
- if (!$primaryCols) {
- $primaryCols = $this->_getPrimaryInfo($row[$tabid]);
- }
-
- if (array_key_exists($row[$colno], $primaryCols)) {
- $primary = true;
- $primaryPosition = $primaryCols[$row[$colno]];
- }
-
- $identity = false;
- if ($row[$typename] == 6 + 256 ||
- $row[$typename] == 18 + 256) {
- $identity = true;
- }
-
- $desc[$this->_adapter->foldCase($row[$colname])] = array (
- 'SCHEMA_NAME' => $this->_adapter->foldCase($row[$tabschema]),
- 'TABLE_NAME' => $this->_adapter->foldCase($row[$tabname]),
- 'COLUMN_NAME' => $this->_adapter->foldCase($row[$colname]),
- 'COLUMN_POSITION' => $row[$colno],
- 'DATA_TYPE' => $this->_getDataType($row[$typename]),
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) !($row[$typename] - 256 >= 0),
- 'LENGTH' => $row[$length],
- 'SCALE' => ($row[$typename] == 5 ? $row[$length]&255 : 0),
- 'PRECISION' => ($row[$typename] == 5 ? (int)($row[$length]/256) : 0),
- 'UNSIGNED' => false,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
-
- return $desc;
- }
-
- /**
- * Map number representation of a data type
- * to a string
- *
- * @param int $typeNo
- * @return string
- */
- protected function _getDataType($typeNo)
- {
- $typemap = array(
- 0 => "CHAR",
- 1 => "SMALLINT",
- 2 => "INTEGER",
- 3 => "FLOAT",
- 4 => "SMALLFLOAT",
- 5 => "DECIMAL",
- 6 => "SERIAL",
- 7 => "DATE",
- 8 => "MONEY",
- 9 => "NULL",
- 10 => "DATETIME",
- 11 => "BYTE",
- 12 => "TEXT",
- 13 => "VARCHAR",
- 14 => "INTERVAL",
- 15 => "NCHAR",
- 16 => "NVARCHAR",
- 17 => "INT8",
- 18 => "SERIAL8",
- 19 => "SET",
- 20 => "MULTISET",
- 21 => "LIST",
- 22 => "Unnamed ROW",
- 40 => "Variable-length opaque type",
- 4118 => "Named ROW"
- );
-
- if ($typeNo - 256 >= 0) {
- $typeNo = $typeNo - 256;
- }
-
- return $typemap[$typeNo];
- }
-
- /**
- * Helper method to retrieve primary key column
- * and column location
- *
- * @param int $tabid
- * @return array
- */
- protected function _getPrimaryInfo($tabid)
- {
- $sql = "SELECT i.part1, i.part2, i.part3, i.part4, i.part5, i.part6,
- i.part7, i.part8, i.part9, i.part10, i.part11, i.part12,
- i.part13, i.part14, i.part15, i.part16
- FROM sysindexes i
- JOIN sysconstraints c ON c.idxname = i.idxname
- WHERE i.tabid = " . $tabid . " AND c.constrtype = 'P'";
-
- $stmt = $this->_adapter->query($sql);
- $results = $stmt->fetchAll();
-
- $cols = array();
-
- // this should return only 1 row
- // unless there is no primary key,
- // in which case, the empty array is returned
- if ($results) {
- $row = $results[0];
- } else {
- return $cols;
- }
-
- $position = 0;
- foreach ($row as $key => $colno) {
- $position++;
- if ($colno == 0) {
- return $cols;
- } else {
- $cols[$colno] = $position;
- }
- }
- }
-
- /**
- * Adds an IDS-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- } else if ($count == 0) {
- $limit_sql = str_ireplace("SELECT", "SELECT * FROM (SELECT", $sql);
- $limit_sql .= ") WHERE 0 = 1";
- } else {
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
- if ($offset == 0) {
- $limit_sql = str_ireplace("SELECT", "SELECT FIRST $count", $sql);
- } else {
- $limit_sql = str_ireplace("SELECT", "SELECT SKIP $offset LIMIT $count", $sql);
- }
- }
- return $limit_sql;
- }
-
- /**
- * IDS-specific last sequence id
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $sql = 'SELECT '.$this->_adapter->quoteIdentifier($sequenceName).'.CURRVAL FROM '
- .'systables WHERE tabid = 1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-
- /**
- * IDS-specific sequence id value
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $sql = 'SELECT '.$this->_adapter->quoteIdentifier($sequenceName).'.NEXTVAL FROM '
- .'systables WHERE tabid = 1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Mssql.php b/library/vendor/Zend/Db/Adapter/Pdo/Mssql.php
deleted file mode 100644
index 7c7c1cd15..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Mssql.php
+++ /dev/null
@@ -1,435 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE,
- 'MONEY' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'SMALLMONEY' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO DSN for the adapter from $this->_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- // baseline of DSN parts
- $dsn = $this->_config;
-
- // don't pass the username and password in the DSN
- unset($dsn['username']);
- unset($dsn['password']);
- unset($dsn['options']);
- unset($dsn['persistent']);
- unset($dsn['driver_options']);
-
- if (isset($dsn['port'])) {
- $seperator = ':';
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- $seperator = ',';
- }
- $dsn['host'] .= $seperator . $dsn['port'];
- unset($dsn['port']);
- }
-
- // this driver supports multiple DSN prefixes
- // @see http://www.php.net/manual/en/ref.pdo-dblib.connection.php
- if (isset($dsn['pdoType'])) {
- switch (strtolower($dsn['pdoType'])) {
- case 'freetds':
- case 'sybase':
- $this->_pdoType = 'sybase';
- break;
- case 'mssql':
- $this->_pdoType = 'mssql';
- break;
- case 'dblib':
- default:
- $this->_pdoType = 'dblib';
- break;
- }
- unset($dsn['pdoType']);
- }
-
- // use all remaining parts in the DSN
- foreach ($dsn as $key => $val) {
- $dsn[$key] = "$key=$val";
- }
-
- $dsn = $this->_pdoType . ':' . implode(';', $dsn);
- return $dsn;
- }
-
- /**
- * @return void
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
- parent::_connect();
- $this->_connection->exec('SET QUOTED_IDENTIFIER ON');
- }
-
- /**
- * Begin a transaction.
- *
- * It is necessary to override the abstract PDO transaction functions here, as
- * the PDO driver for MSSQL does not support transactions.
- */
- protected function _beginTransaction()
- {
- $this->_connect();
- $this->_connection->exec('BEGIN TRANSACTION');
- return true;
- }
-
- /**
- * Commit a transaction.
- *
- * It is necessary to override the abstract PDO transaction functions here, as
- * the PDO driver for MSSQL does not support transactions.
- */
- protected function _commit()
- {
- $this->_connect();
- $this->_connection->exec('COMMIT TRANSACTION');
- return true;
- }
-
- /**
- * Roll-back a transaction.
- *
- * It is necessary to override the abstract PDO transaction functions here, as
- * the PDO driver for MSSQL does not support transactions.
- */
- protected function _rollBack() {
- $this->_connect();
- $this->_connection->exec('ROLLBACK TRANSACTION');
- return true;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * PRIMARY_AUTO => integer; position of auto-generated column in primary key
- *
- * @todo Discover column primary key position.
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- if ($schemaName != null) {
- if (strpos($schemaName, '.') !== false) {
- $result = explode('.', $schemaName);
- $schemaName = $result[1];
- }
- }
- /**
- * Discover metadata information about this table.
- */
- $sql = "exec sp_columns @table_name = " . $this->quoteIdentifier($tableName, true);
- if ($schemaName != null) {
- $sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
- }
-
- $stmt = $this->query($sql);
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $table_name = 2;
- $column_name = 3;
- $type_name = 5;
- $precision = 6;
- $length = 7;
- $scale = 8;
- $nullable = 10;
- $column_def = 12;
- $column_position = 16;
-
- /**
- * Discover primary key column(s) for this table.
- */
- $sql = "exec sp_pkeys @table_name = " . $this->quoteIdentifier($tableName, true);
- if ($schemaName != null) {
- $sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
- }
-
- $stmt = $this->query($sql);
- $primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- $primaryKeyColumn = array();
- $pkey_column_name = 3;
- $pkey_key_seq = 4;
- foreach ($primaryKeysResult as $pkeysRow) {
- $primaryKeyColumn[$pkeysRow[$pkey_column_name]] = $pkeysRow[$pkey_key_seq];
- }
-
- $desc = array();
- $p = 1;
- foreach ($result as $key => $row) {
- $identity = false;
- $words = explode(' ', $row[$type_name], 2);
- if (isset($words[0])) {
- $type = $words[0];
- if (isset($words[1])) {
- $identity = (bool) preg_match('/identity/', $words[1]);
- }
- }
-
- $isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
- if ($isPrimary) {
- $primaryPosition = $primaryKeyColumn[$row[$column_name]];
- } else {
- $primaryPosition = null;
- }
-
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => (int) $row[$column_position],
- 'DATA_TYPE' => $type,
- 'DEFAULT' => $row[$column_def],
- 'NULLABLE' => (bool) $row[$nullable],
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => $row[$precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $isPrimary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql = preg_replace(
- '/^SELECT\s+(DISTINCT\s)?/i',
- 'SELECT $1TOP ' . ($count+$offset) . ' ',
- $sql
- );
-
- if ($offset > 0) {
- $orderby = stristr($sql, 'ORDER BY');
-
- if ($orderby !== false) {
- $orderParts = explode(',', substr($orderby, 8));
- $pregReplaceCount = null;
- $orderbyInverseParts = array();
- foreach ($orderParts as $orderPart) {
- $orderPart = rtrim($orderPart);
- $inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount);
- if ($pregReplaceCount) {
- $orderbyInverseParts[] = $inv;
- continue;
- }
- $inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount);
- if ($pregReplaceCount) {
- $orderbyInverseParts[] = $inv;
- continue;
- } else {
- $orderbyInverseParts[] = $orderPart . ' DESC';
- }
- }
-
- $orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts);
- }
-
-
-
-
- $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
- if ($orderby !== false) {
- $sql .= ' ' . $orderbyInverse . ' ';
- }
- $sql .= ') AS outer_tbl';
- if ($orderby !== false) {
- $sql .= ' ' . $orderby;
- }
- }
-
- return $sql;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * Microsoft SQL Server does not support sequences, so the arguments to
- * this method are ignored.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- * @throws Zend_Db_Adapter_Exception
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $sql = 'SELECT SCOPE_IDENTITY()';
- return (int)$this->fetchOne($sql);
- }
-
- /**
- * Retrieve server version in PHP style
- * Pdo_Mssql doesn't support getAttribute(PDO::ATTR_SERVER_VERSION)
- * @return string
- */
- public function getServerVersion()
- {
- try {
- $stmt = $this->query("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR)");
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- if (count($result)) {
- return $result[0][0];
- }
- return null;
- } catch (PDOException $e) {
- return null;
- }
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (!is_int($value) && !is_float($value)) {
- // Fix for null-byte injection
- $value = addcslashes($value, "\000\032");
- }
- return parent::_quote($value);
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Mysql.php b/library/vendor/Zend/Db/Adapter/Pdo/Mysql.php
deleted file mode 100644
index 951d665c4..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Mysql.php
+++ /dev/null
@@ -1,269 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'MEDIUMINT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'SERIAL' => Zend_Db::BIGINT_TYPE,
- 'DEC' => Zend_Db::FLOAT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'FIXED' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Override _dsn() and ensure that charset is incorporated in mysql
- * @see Zend_Db_Adapter_Pdo_Abstract::_dsn()
- */
- protected function _dsn()
- {
- $dsn = parent::_dsn();
- if (isset($this->_config['charset'])) {
- $dsn .= ';charset=' . $this->_config['charset'];
- }
- return $dsn;
- }
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
-
- if (!empty($this->_config['charset'])
- && version_compare(PHP_VERSION, '5.3.6', '<')
- ) {
- $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
- $this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
- }
-
- parent::_connect();
- }
-
- /**
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- return "`";
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- return $this->fetchCol('SHOW TABLES');
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- // @todo use INFORMATION_SCHEMA someday when MySQL's
- // implementation has reasonably good performance and
- // the version with this improvement is in wide use.
-
- if ($schemaName) {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier("$schemaName.$tableName", true);
- } else {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier($tableName, true);
- }
- $stmt = $this->query($sql);
-
- // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $field = 0;
- $type = 1;
- $null = 2;
- $key = 3;
- $default = 4;
- $extra = 5;
-
- $desc = array();
- $i = 1;
- $p = 1;
- foreach ($result as $row) {
- list($length, $scale, $precision, $unsigned, $primary, $primaryPosition, $identity)
- = array(null, null, null, null, false, null, false);
- if (preg_match('/unsigned/', $row[$type])) {
- $unsigned = true;
- }
- if (preg_match('/^((?:var)?char)\((\d+)\)/', $row[$type], $matches)) {
- $row[$type] = $matches[1];
- $length = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row[$type], $matches)) {
- $row[$type] = 'decimal';
- $precision = $matches[1];
- $scale = $matches[2];
- } else if (preg_match('/^float\((\d+),(\d+)\)/', $row[$type], $matches)) {
- $row[$type] = 'float';
- $precision = $matches[1];
- $scale = $matches[2];
- } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row[$type], $matches)) {
- $row[$type] = $matches[1];
- // The optional argument of a MySQL int type is not precision
- // or length; it is only a hint for display width.
- }
- if (strtoupper($row[$key]) == 'PRI') {
- $primary = true;
- $primaryPosition = $p;
- if ($row[$extra] == 'auto_increment') {
- $identity = true;
- } else {
- $identity = false;
- }
- ++$p;
- }
- $desc[$this->foldCase($row[$field])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($tableName),
- 'COLUMN_NAME' => $this->foldCase($row[$field]),
- 'COLUMN_POSITION' => $i,
- 'DATA_TYPE' => $row[$type],
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) ($row[$null] == 'YES'),
- 'LENGTH' => $length,
- 'SCALE' => $scale,
- 'PRECISION' => $precision,
- 'UNSIGNED' => $unsigned,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- ++$i;
- }
- return $desc;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Oci.php b/library/vendor/Zend/Db/Adapter/Pdo/Oci.php
deleted file mode 100644
index eb4e6fcf1..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Oci.php
+++ /dev/null
@@ -1,375 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE,
- 'NUMBER' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO DSN for the adapter from $this->_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- // baseline of DSN parts
- $dsn = $this->_config;
-
- if (isset($dsn['host'])) {
- $tns = 'dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' .
- '(HOST=' . $dsn['host'] . ')';
-
- if (isset($dsn['port'])) {
- $tns .= '(PORT=' . $dsn['port'] . ')';
- } else {
- $tns .= '(PORT=1521)';
- }
-
- $tns .= '))(CONNECT_DATA=(SID=' . $dsn['dbname'] . ')))';
- } else {
- $tns = 'dbname=' . $dsn['dbname'];
- }
-
- if (isset($dsn['charset'])) {
- $tns .= ';charset=' . $dsn['charset'];
- }
-
- return $this->_pdoType . ':' . $tns;
- }
-
- /**
- * Quote a raw string.
- * Most PDO drivers have an implementation for the quote() method,
- * but the Oracle OCI driver must use the same implementation as the
- * Zend_Db_Adapter_Abstract class.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- $value = str_replace("'", "''", $value);
- return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
- }
-
- /**
- * Quote a table identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the table.
- * @return string The quoted identifier and alias.
- */
- public function quoteTableAs($ident, $alias = null, $auto = false)
- {
- // Oracle doesn't allow the 'AS' keyword between the table identifier/expression and alias.
- return $this->_quoteIdentifierAs($ident, $alias, $auto, ' ');
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $data = $this->fetchCol('SELECT table_name FROM all_tables');
- return $data;
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $version = $this->getServerVersion();
- if (($version === null) || version_compare($version, '9.0.0', '>=')) {
- $sql = "SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC
- LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
- ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
- ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- } else {
- $subSql="SELECT AC.OWNER, AC.TABLE_NAME, ACC.COLUMN_NAME, AC.CONSTRAINT_TYPE, ACC.POSITION
- from ALL_CONSTRAINTS AC, ALL_CONS_COLUMNS ACC
- WHERE ACC.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
- AND ACC.TABLE_NAME = AC.TABLE_NAME
- AND ACC.OWNER = AC.OWNER
- AND AC.CONSTRAINT_TYPE = 'P'
- AND UPPER(AC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $subSql .= ' AND UPPER(ACC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql="SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, CC.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC, ($subSql) CC
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)
- AND TC.OWNER = CC.OWNER(+) AND TC.TABLE_NAME = CC.TABLE_NAME(+) AND TC.COLUMN_NAME = CC.COLUMN_NAME(+)";
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- }
-
- $stmt = $this->query($sql, $bind);
-
- /**
- * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $table_name = 0;
- $owner = 1;
- $column_name = 2;
- $data_type = 3;
- $data_default = 4;
- $nullable = 5;
- $column_id = 6;
- $data_length = 7;
- $data_scale = 8;
- $data_precision = 9;
- $constraint_type = 10;
- $position = 11;
-
- $desc = array();
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$constraint_type] == 'P') {
- $primary = true;
- $primaryPosition = $row[$position];
- /**
- * Oracle does not support auto-increment keys.
- */
- $identity = false;
- }
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$owner]),
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => $row[$column_id],
- 'DATA_TYPE' => $row[$data_type],
- 'DEFAULT' => $row[$data_default],
- 'NULLABLE' => (bool) ($row[$nullable] == 'Y'),
- 'LENGTH' => $row[$data_length],
- 'SCALE' => $row[$data_scale],
- 'PRECISION' => $row[$data_precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- $value = $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual');
- return $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $value = $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual');
- return $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * Oracle does not support IDENTITY columns, so if the sequence is not
- * specified, this method returns null.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= $this->foldCase("_$primaryKey");
- }
- $sequenceName .= $this->foldCase('_seq');
- return $this->lastSequenceId($sequenceName);
- }
- // No support for IDENTITY columns; return null
- return null;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- /**
- * Oracle does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT z1.*, ROWNUM AS \"zend_db_rownum\"
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.\"zend_db_rownum\" BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- return $limit_sql;
- }
-
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Pgsql.php b/library/vendor/Zend/Db/Adapter/Pdo/Pgsql.php
deleted file mode 100644
index 060ed2847..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Pgsql.php
+++ /dev/null
@@ -1,333 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SERIAL' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'BIGSERIAL' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
-
- parent::_connect();
-
- if (!empty($this->_config['charset'])) {
- $sql = "SET NAMES '" . $this->_config['charset'] . "'";
- $this->_connection->exec($sql);
- }
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- // @todo use a better query with joins instead of subqueries
- $sql = "SELECT c.relname AS table_name "
- . "FROM pg_class c, pg_user u "
- . "WHERE c.relowner = u.usesysid AND c.relkind = 'r' "
- . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
- . "AND c.relname !~ '^(pg_|sql_)' "
- . "UNION "
- . "SELECT c.relname AS table_name "
- . "FROM pg_class c "
- . "WHERE c.relkind = 'r' "
- . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
- . "AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner) "
- . "AND c.relname !~ '^pg_'";
-
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $sql = "SELECT
- a.attnum,
- n.nspname,
- c.relname,
- a.attname AS colname,
- t.typname AS type,
- a.atttypmod,
- FORMAT_TYPE(a.atttypid, a.atttypmod) AS complete_type,
- d.adsrc AS default_value,
- a.attnotnull AS notnull,
- a.attlen AS length,
- co.contype,
- ARRAY_TO_STRING(co.conkey, ',') AS conkey
- FROM pg_attribute AS a
- JOIN pg_class AS c ON a.attrelid = c.oid
- JOIN pg_namespace AS n ON c.relnamespace = n.oid
- JOIN pg_type AS t ON a.atttypid = t.oid
- LEFT OUTER JOIN pg_constraint AS co ON (co.conrelid = c.oid
- AND a.attnum = ANY(co.conkey) AND co.contype = 'p')
- LEFT OUTER JOIN pg_attrdef AS d ON d.adrelid = c.oid AND d.adnum = a.attnum
- WHERE a.attnum > 0 AND c.relname = ".$this->quote($tableName);
- if ($schemaName) {
- $sql .= " AND n.nspname = ".$this->quote($schemaName);
- }
- $sql .= ' ORDER BY a.attnum';
-
- $stmt = $this->query($sql);
-
- // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $attnum = 0;
- $nspname = 1;
- $relname = 2;
- $colname = 3;
- $type = 4;
- $atttypemod = 5;
- $complete_type = 6;
- $default_value = 7;
- $notnull = 8;
- $length = 9;
- $contype = 10;
- $conkey = 11;
-
- $desc = array();
- foreach ($result as $key => $row) {
- $defaultValue = $row[$default_value];
- if ($row[$type] == 'varchar' || $row[$type] == 'bpchar' ) {
- if (preg_match('/character(?: varying)?(?:\((\d+)\))?/', $row[$complete_type], $matches)) {
- if (isset($matches[1])) {
- $row[$length] = $matches[1];
- } else {
- $row[$length] = null; // unlimited
- }
- }
- if (preg_match("/^'(.*?)'::(?:character varying|bpchar)$/", $defaultValue, $matches)) {
- $defaultValue = $matches[1];
- }
- }
- list($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$contype] == 'p') {
- $primary = true;
- $primaryPosition = array_search($row[$attnum], explode(',', $row[$conkey])) + 1;
- $identity = (bool) (preg_match('/^nextval/', $row[$default_value]));
- }
- $desc[$this->foldCase($row[$colname])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$nspname]),
- 'TABLE_NAME' => $this->foldCase($row[$relname]),
- 'COLUMN_NAME' => $this->foldCase($row[$colname]),
- 'COLUMN_POSITION' => $row[$attnum],
- 'DATA_TYPE' => $row[$type],
- 'DEFAULT' => $defaultValue,
- 'NULLABLE' => (bool) ($row[$notnull] != 't'),
- 'LENGTH' => $row[$length],
- 'SCALE' => null, // @todo
- 'PRECISION' => null, // @todo
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- $sequenceName = str_replace($this->getQuoteIdentifierSymbol(), '', (string) $sequenceName);
- $value = $this->fetchOne("SELECT CURRVAL("
- . $this->quote($this->quoteIdentifier($sequenceName, true))
- . ")");
- return $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $sequenceName = str_replace($this->getQuoteIdentifierSymbol(), '', (string) $sequenceName);
- $value = $this->fetchOne("SELECT NEXTVAL("
- . $this->quote($this->quoteIdentifier($sequenceName, true))
- . ")");
- return $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
- return $this->_connection->lastInsertId($tableName);
- }
-
-}
diff --git a/library/vendor/Zend/Db/Adapter/Pdo/Sqlite.php b/library/vendor/Zend/Db/Adapter/Pdo/Sqlite.php
deleted file mode 100644
index 645333948..000000000
--- a/library/vendor/Zend/Db/Adapter/Pdo/Sqlite.php
+++ /dev/null
@@ -1,305 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::BIGINT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Constructor.
- *
- * $config is an array of key/value pairs containing configuration
- * options. Note that the SQLite options are different than most of
- * the other PDO adapters in that no username or password are needed.
- * Also, an extra config key "sqlite2" specifies compatibility mode.
- *
- * dbname => (string) The name of the database to user (required,
- * use :memory: for memory-based database)
- *
- * sqlite2 => (boolean) PDO_SQLITE defaults to SQLite 3. For compatibility
- * with an older SQLite 2 database, set this to TRUE.
- *
- * @param array $config An array of configuration keys.
- */
- public function __construct(array $config = array())
- {
- if (isset($config['sqlite2']) && $config['sqlite2']) {
- $this->_pdoType = 'sqlite2';
- }
-
- // SQLite uses no username/password. Stub to satisfy parent::_connect()
- $this->_config['username'] = null;
- $this->_config['password'] = null;
-
- return parent::__construct($config);
- }
-
- /**
- * Check for config options that are mandatory.
- * Throw exceptions if any are missing.
- *
- * @param array $config
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _checkRequiredOptions(array $config)
- {
- // we need at least a dbname
- if (! array_key_exists('dbname', $config)) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
- }
- }
-
- /**
- * DSN builder
- */
- protected function _dsn()
- {
- return $this->_pdoType .':'. $this->_config['dbname'];
- }
-
- /**
- * Special configuration for SQLite behavior: make sure that result sets
- * contain keys like 'column' instead of 'table.column'.
- *
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- /**
- * if we already have a PDO object, no need to re-connect.
- */
- if ($this->_connection) {
- return;
- }
-
- parent::_connect();
-
- $retval = $this->_connection->exec('PRAGMA full_column_names=0');
- if ($retval === false) {
- $error = $this->_connection->errorInfo();
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception($error[2]);
- }
-
- $retval = $this->_connection->exec('PRAGMA short_column_names=1');
- if ($retval === false) {
- $error = $this->_connection->errorInfo();
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception($error[2]);
- }
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT name FROM sqlite_master WHERE type='table' "
- . "UNION ALL SELECT name FROM sqlite_temp_master "
- . "WHERE type='table' ORDER BY name";
-
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $sql = 'PRAGMA ';
-
- if ($schemaName) {
- $sql .= $this->quoteIdentifier($schemaName) . '.';
- }
-
- $sql .= 'table_info('.$this->quoteIdentifier($tableName).')';
-
- $stmt = $this->query($sql);
-
- /**
- * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $cid = 0;
- $name = 1;
- $type = 2;
- $notnull = 3;
- $dflt_value = 4;
- $pk = 5;
-
- $desc = array();
-
- $p = 1;
- foreach ($result as $key => $row) {
- list($length, $scale, $precision, $primary, $primaryPosition, $identity) =
- array(null, null, null, false, null, false);
- if (preg_match('/^((?:var)?char)\((\d+)\)/i', $row[$type], $matches)) {
- $row[$type] = $matches[1];
- $length = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/i', $row[$type], $matches)) {
- $row[$type] = 'DECIMAL';
- $precision = $matches[1];
- $scale = $matches[2];
- }
- if ((bool) $row[$pk]) {
- $primary = true;
- $primaryPosition = $p;
- /**
- * SQLite INTEGER primary key is always auto-increment.
- */
- $identity = (bool) ($row[$type] == 'INTEGER');
- ++$p;
- }
- $desc[$this->foldCase($row[$name])] = array(
- 'SCHEMA_NAME' => $this->foldCase($schemaName),
- 'TABLE_NAME' => $this->foldCase($tableName),
- 'COLUMN_NAME' => $this->foldCase($row[$name]),
- 'COLUMN_POSITION' => $row[$cid]+1,
- 'DATA_TYPE' => $row[$type],
- 'DEFAULT' => $row[$dflt_value],
- 'NULLABLE' => ! (bool) $row[$notnull],
- 'LENGTH' => $length,
- 'SCALE' => $scale,
- 'PRECISION' => $precision,
- 'UNSIGNED' => null, // Sqlite3 does not support unsigned data
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (!is_int($value) && !is_float($value)) {
- // Fix for null-byte injection
- $value = addcslashes($value, "\000\032");
- }
- return parent::_quote($value);
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Sqlsrv.php b/library/vendor/Zend/Db/Adapter/Sqlsrv.php
deleted file mode 100644
index ce3324f33..000000000
--- a/library/vendor/Zend/Db/Adapter/Sqlsrv.php
+++ /dev/null
@@ -1,662 +0,0 @@
- (string) Connect to the database as this username.
- * password => (string) Password associated with the username.
- * dbname => The name of the local SQL Server instance
- *
- * @var array
- */
- protected $_config = array(
- 'dbname' => null,
- 'username' => null,
- 'password' => null,
- );
-
- /**
- * Last insert id from INSERT query
- *
- * @var int
- */
- protected $_lastInsertId;
-
- /**
- * Query used to fetch last insert id
- *
- * @var string
- */
- protected $_lastInsertSQL = 'SELECT SCOPE_IDENTITY() as Current_Identity';
-
- /**
- * Keys are UPPERCASE SQL datatypes or the constants
- * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
- *
- * Values are:
- * 0 = 32-bit integer
- * 1 = 64-bit integer
- * 2 = float or decimal
- *
- * @var array Associative array of datatypes to values 0, 1, or 2.
- */
- protected $_numericDataTypes = array(
- Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE,
- 'MONEY' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'SMALLMONEY' => Zend_Db::FLOAT_TYPE,
- );
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Sqlsrv';
-
- /**
- * Creates a connection resource.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _connect()
- {
- if (is_resource($this->_connection)) {
- // connection already exists
- return;
- }
-
- if (!extension_loaded('sqlsrv')) {
- /**
- * @see Zend_Db_Adapter_Sqlsrv_Exception
- */
- throw new Zend_Db_Adapter_Sqlsrv_Exception('The Sqlsrv extension is required for this adapter but the extension is not loaded');
- }
-
- $serverName = $this->_config['host'];
- if (isset($this->_config['port'])) {
- $port = (integer) $this->_config['port'];
- $serverName .= ', ' . $port;
- }
-
- $connectionInfo = array(
- 'Database' => $this->_config['dbname'],
- );
-
- if (isset($this->_config['username']) && isset($this->_config['password']))
- {
- $connectionInfo += array(
- 'UID' => $this->_config['username'],
- 'PWD' => $this->_config['password'],
- );
- }
- // else - windows authentication
-
- if (!empty($this->_config['driver_options'])) {
- foreach ($this->_config['driver_options'] as $option => $value) {
- // A value may be a constant.
- if (is_string($value)) {
- $constantName = strtoupper($value);
- if (defined($constantName)) {
- $connectionInfo[$option] = constant($constantName);
- } else {
- $connectionInfo[$option] = $value;
- }
- }
- }
- }
-
- $this->_connection = sqlsrv_connect($serverName, $connectionInfo);
-
- if (!$this->_connection) {
- /**
- * @see Zend_Db_Adapter_Sqlsrv_Exception
- */
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Check for config options that are mandatory.
- * Throw exceptions if any are missing.
- *
- * @param array $config
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _checkRequiredOptions(array $config)
- {
- // we need at least a dbname
- if (! array_key_exists('dbname', $config)) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
- }
-
- if (! array_key_exists('password', $config) && array_key_exists('username', $config)) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials.
- If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.");
- }
-
- if (array_key_exists('password', $config) && !array_key_exists('username', $config)) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials.
- If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.");
- }
- }
-
- /**
- * Set the transaction isoltion level.
- *
- * @param integer|null $level A fetch mode from SQLSRV_TXN_*.
- * @return true
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- public function setTransactionIsolationLevel($level = null)
- {
- $this->_connect();
- $sql = null;
-
- // Default transaction level in sql server
- if ($level === null)
- {
- $level = SQLSRV_TXN_READ_COMMITTED;
- }
-
- switch ($level) {
- case SQLSRV_TXN_READ_UNCOMMITTED:
- $sql = "READ UNCOMMITTED";
- break;
- case SQLSRV_TXN_READ_COMMITTED:
- $sql = "READ COMMITTED";
- break;
- case SQLSRV_TXN_REPEATABLE_READ:
- $sql = "REPEATABLE READ";
- break;
- case SQLSRV_TXN_SNAPSHOT:
- $sql = "SNAPSHOT";
- break;
- case SQLSRV_TXN_SERIALIZABLE:
- $sql = "SERIALIZABLE";
- break;
- default:
- throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified");
- }
-
- if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) {
- throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'");
- }
-
- return true;
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return (is_resource($this->_connection)
- && (get_resource_type($this->_connection) == 'SQL Server Connection')
- );
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- sqlsrv_close($this->_connection);
- }
- $this->_connection = null;
- }
-
- /**
- * Returns an SQL statement for preparation.
- *
- * @param string $sql The SQL statement with placeholders.
- * @return Zend_Db_Statement_Sqlsrv
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
-
- if (!class_exists($stmtClass)) {
- /**
- * @see Zend_Loader
- */
- Zend_Loader::loadClass($stmtClass);
- }
-
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value)) {
- return $value;
- } elseif (is_float($value)) {
- return sprintf('%F', $value);
- }
-
- $value = addcslashes($value, "\000\032");
- return "'" . str_replace("'", "''", $value) . "'";
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName) {
- $tableName = $this->quote($tableName);
- $sql = 'SELECT IDENT_CURRENT (' . $tableName . ') as Current_Identity';
- return (string) $this->fetchOne($sql);
- }
-
- if ($this->_lastInsertId > 0) {
- return (string) $this->_lastInsertId;
- }
-
- $sql = $this->_lastInsertSQL;
- return (string) $this->fetchOne($sql);
- }
-
- /**
- * Inserts a table row with specified data.
- *
- * @param mixed $table The table to insert data into.
- * @param array $bind Column-value pairs.
- * @return int The number of affected rows.
- */
- public function insert($table, array $bind)
- {
- // extract and quote col names from the array keys
- $cols = array();
- $vals = array();
- foreach ($bind as $col => $val) {
- $cols[] = $this->quoteIdentifier($col, true);
- if ($val instanceof Zend_Db_Expr) {
- $vals[] = $val->__toString();
- unset($bind[$col]);
- } else {
- $vals[] = '?';
- }
- }
-
- // build the statement
- $sql = "INSERT INTO "
- . $this->quoteIdentifier($table, true)
- . ' (' . implode(', ', $cols) . ') '
- . 'VALUES (' . implode(', ', $vals) . ')'
- . ' ' . $this->_lastInsertSQL;
-
- // execute the statement and return the number of affected rows
- $stmt = $this->query($sql, array_values($bind));
- $result = $stmt->rowCount();
-
- $stmt->nextRowset();
-
- $this->_lastInsertId = $stmt->fetchColumn();
-
- return $result;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $this->_connect();
- $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- /**
- * Discover metadata information about this table.
- */
- $sql = "exec sp_columns @table_name = " . $this->quoteIdentifier($tableName, true);
- $stmt = $this->query($sql);
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- // ZF-7698
- $stmt->closeCursor();
-
- if (count($result) == 0) {
- return array();
- }
-
- $owner = 1;
- $table_name = 2;
- $column_name = 3;
- $type_name = 5;
- $precision = 6;
- $length = 7;
- $scale = 8;
- $nullable = 10;
- $column_def = 12;
- $column_position = 16;
-
- /**
- * Discover primary key column(s) for this table.
- */
- $tableOwner = $result[0][$owner];
- $sql = "exec sp_pkeys @table_owner = " . $tableOwner
- . ", @table_name = " . $this->quoteIdentifier($tableName, true);
- $stmt = $this->query($sql);
-
- $primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- $primaryKeyColumn = array();
-
- // Per http://msdn.microsoft.com/en-us/library/ms189813.aspx,
- // results from sp_keys stored procedure are:
- // 0=TABLE_QUALIFIER 1=TABLE_OWNER 2=TABLE_NAME 3=COLUMN_NAME 4=KEY_SEQ 5=PK_NAME
-
- $pkey_column_name = 3;
- $pkey_key_seq = 4;
- foreach ($primaryKeysResult as $pkeysRow) {
- $primaryKeyColumn[$pkeysRow[$pkey_column_name]] = $pkeysRow[$pkey_key_seq];
- }
-
- $desc = array();
- $p = 1;
- foreach ($result as $key => $row) {
- $identity = false;
- $words = explode(' ', $row[$type_name], 2);
- if (isset($words[0])) {
- $type = $words[0];
- if (isset($words[1])) {
- $identity = (bool) preg_match('/identity/', $words[1]);
- }
- }
-
- $isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
- if ($isPrimary) {
- $primaryPosition = $primaryKeyColumn[$row[$column_name]];
- } else {
- $primaryPosition = null;
- }
-
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => (int) $row[$column_position],
- 'DATA_TYPE' => $type,
- 'DEFAULT' => $row[$column_def],
- 'NULLABLE' => (bool) $row[$nullable],
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => $row[$precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $isPrimary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity,
- );
- }
-
- return $desc;
- }
-
- /**
- * Leave autocommit mode and begin a transaction.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _beginTransaction()
- {
- if (!sqlsrv_begin_transaction($this->_connection)) {
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Commit a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _commit()
- {
- if (!sqlsrv_commit($this->_connection)) {
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Roll back a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _rollBack()
- {
- if (!sqlsrv_rollback($this->_connection)) {
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Set the fetch mode.
- *
- * @todo Support FETCH_CLASS and FETCH_INTO.
- *
- * @param integer $mode A fetch mode.
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_NUM: // seq array
- case Zend_Db::FETCH_ASSOC: // assoc array
- case Zend_Db::FETCH_BOTH: // seq+assoc array
- case Zend_Db::FETCH_OBJ: // object
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- throw new Zend_Db_Adapter_Sqlsrv_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- if ($offset == 0) {
- $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $sql);
- } else {
- $orderby = stristr($sql, 'ORDER BY');
-
- if (!$orderby) {
- $over = 'ORDER BY (SELECT 0)';
- } else {
- $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);
- }
-
- // Remove ORDER BY clause from $sql
- $sql = preg_replace('/\s+ORDER BY(.*)/', '', $sql);
-
- // Add ORDER BY clause as an argument for ROW_NUMBER()
- $sql = "SELECT ROW_NUMBER() OVER ($over) AS \"ZEND_DB_ROWNUM\", * FROM ($sql) AS inner_tbl";
-
- $start = $offset + 1;
-
- if ($count == PHP_INT_MAX) {
- $sql = "WITH outer_tbl AS ($sql) SELECT * FROM outer_tbl WHERE \"ZEND_DB_ROWNUM\" >= $start";
- }
- else {
- $end = $offset + $count;
- $sql = "WITH outer_tbl AS ($sql) SELECT * FROM outer_tbl WHERE \"ZEND_DB_ROWNUM\" BETWEEN $start AND $end";
- }
- }
-
- return $sql;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- if ($type == 'positional') {
- return true;
- }
-
- // if its 'named' or anything else
- return false;
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $serverInfo = sqlsrv_server_info($this->_connection);
-
- if ($serverInfo !== false) {
- return $serverInfo['SQLServerVersion'];
- }
-
- return null;
- }
-}
diff --git a/library/vendor/Zend/Db/Adapter/Sqlsrv/Exception.php b/library/vendor/Zend/Db/Adapter/Sqlsrv/Exception.php
deleted file mode 100644
index 2bbc84d6b..000000000
--- a/library/vendor/Zend/Db/Adapter/Sqlsrv/Exception.php
+++ /dev/null
@@ -1,62 +0,0 @@
-_expression = (string) $expression;
- }
-
- /**
- * @return string The string of the SQL expression stored in this object.
- */
- public function __toString()
- {
- return $this->_expression;
- }
-
-}
diff --git a/library/vendor/Zend/Db/Profiler.php b/library/vendor/Zend/Db/Profiler.php
deleted file mode 100644
index c80ec5db0..000000000
--- a/library/vendor/Zend/Db/Profiler.php
+++ /dev/null
@@ -1,469 +0,0 @@
-setEnabled($enabled);
- }
-
- /**
- * Enable or disable the profiler. If $enable is false, the profiler
- * is disabled and will not log any queries sent to it.
- *
- * @param boolean $enable
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function setEnabled($enable)
- {
- $this->_enabled = (boolean) $enable;
-
- return $this;
- }
-
- /**
- * Get the current state of enable. If True is returned,
- * the profiler is enabled.
- *
- * @return boolean
- */
- public function getEnabled()
- {
- return $this->_enabled;
- }
-
- /**
- * Sets a minimum number of seconds for saving query profiles. If this
- * is set, only those queries whose elapsed time is equal or greater than
- * $minimumSeconds will be saved. To save all queries regardless of
- * elapsed time, set $minimumSeconds to null.
- *
- * @param integer $minimumSeconds OPTIONAL
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function setFilterElapsedSecs($minimumSeconds = null)
- {
- if (null === $minimumSeconds) {
- $this->_filterElapsedSecs = null;
- } else {
- $this->_filterElapsedSecs = (integer) $minimumSeconds;
- }
-
- return $this;
- }
-
- /**
- * Returns the minimum number of seconds for saving query profiles, or null if
- * query profiles are saved regardless of elapsed time.
- *
- * @return integer|null
- */
- public function getFilterElapsedSecs()
- {
- return $this->_filterElapsedSecs;
- }
-
- /**
- * Sets the types of query profiles to save. Set $queryType to one of
- * the Zend_Db_Profiler::* constants to only save profiles for that type of
- * query. To save more than one type, logical OR them together. To
- * save all queries regardless of type, set $queryType to null.
- *
- * @param integer $queryTypes OPTIONAL
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function setFilterQueryType($queryTypes = null)
- {
- $this->_filterTypes = $queryTypes;
-
- return $this;
- }
-
- /**
- * Returns the types of query profiles saved, or null if queries are saved regardless
- * of their types.
- *
- * @return integer|null
- * @see Zend_Db_Profiler::setFilterQueryType()
- */
- public function getFilterQueryType()
- {
- return $this->_filterTypes;
- }
-
- /**
- * Clears the history of any past query profiles. This is relentless
- * and will even clear queries that were started and may not have
- * been marked as ended.
- *
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function clear()
- {
- $this->_queryProfiles = array();
-
- return $this;
- }
-
- /**
- * Clone a profiler query
- *
- * @param Zend_Db_Profiler_Query $query
- * @return integer or null
- */
- public function queryClone(Zend_Db_Profiler_Query $query)
- {
- $this->_queryProfiles[] = clone $query;
-
- end($this->_queryProfiles);
-
- return key($this->_queryProfiles);
- }
-
- /**
- * Starts a query. Creates a new query profile object (Zend_Db_Profiler_Query)
- * and returns the "query profiler handle". Run the query, then call
- * queryEnd() and pass it this handle to make the query as ended and
- * record the time. If the profiler is not enabled, this takes no
- * action and immediately returns null.
- *
- * @param string $queryText SQL statement
- * @param integer $queryType OPTIONAL Type of query, one of the Zend_Db_Profiler::* constants
- * @return integer|null
- */
- public function queryStart($queryText, $queryType = null)
- {
- if (!$this->_enabled) {
- return null;
- }
-
- // make sure we have a query type
- if (null === $queryType) {
- switch (strtolower(substr(ltrim($queryText), 0, 6))) {
- case 'insert':
- $queryType = self::INSERT;
- break;
- case 'update':
- $queryType = self::UPDATE;
- break;
- case 'delete':
- $queryType = self::DELETE;
- break;
- case 'select':
- $queryType = self::SELECT;
- break;
- default:
- $queryType = self::QUERY;
- break;
- }
- }
-
- /**
- * @see Zend_Db_Profiler_Query
- */
- $this->_queryProfiles[] = new Zend_Db_Profiler_Query($queryText, $queryType);
-
- end($this->_queryProfiles);
-
- return key($this->_queryProfiles);
- }
-
- /**
- * Ends a query. Pass it the handle that was returned by queryStart().
- * This will mark the query as ended and save the time.
- *
- * @param integer $queryId
- * @throws Zend_Db_Profiler_Exception
- * @return string Inform that a query is stored or ignored.
- */
- public function queryEnd($queryId)
- {
- // Don't do anything if the Zend_Db_Profiler is not enabled.
- if (!$this->_enabled) {
- return self::IGNORED;
- }
-
- // Check for a valid query handle.
- if (!isset($this->_queryProfiles[$queryId])) {
- /**
- * @see Zend_Db_Profiler_Exception
- */
- throw new Zend_Db_Profiler_Exception("Profiler has no query with handle '$queryId'.");
- }
-
- $qp = $this->_queryProfiles[$queryId];
-
- // Ensure that the query profile has not already ended
- if ($qp->hasEnded()) {
- /**
- * @see Zend_Db_Profiler_Exception
- */
- throw new Zend_Db_Profiler_Exception("Query with profiler handle '$queryId' has already ended.");
- }
-
- // End the query profile so that the elapsed time can be calculated.
- $qp->end();
-
- /**
- * If filtering by elapsed time is enabled, only keep the profile if
- * it ran for the minimum time.
- */
- if (null !== $this->_filterElapsedSecs && $qp->getElapsedSecs() < $this->_filterElapsedSecs) {
- unset($this->_queryProfiles[$queryId]);
- return self::IGNORED;
- }
-
- /**
- * If filtering by query type is enabled, only keep the query if
- * it was one of the allowed types.
- */
- if (null !== $this->_filterTypes && !($qp->getQueryType() & $this->_filterTypes)) {
- unset($this->_queryProfiles[$queryId]);
- return self::IGNORED;
- }
-
- return self::STORED;
- }
-
- /**
- * Get a profile for a query. Pass it the same handle that was returned
- * by queryStart() and it will return a Zend_Db_Profiler_Query object.
- *
- * @param integer $queryId
- * @throws Zend_Db_Profiler_Exception
- * @return Zend_Db_Profiler_Query
- */
- public function getQueryProfile($queryId)
- {
- if (!array_key_exists($queryId, $this->_queryProfiles)) {
- /**
- * @see Zend_Db_Profiler_Exception
- */
- throw new Zend_Db_Profiler_Exception("Query handle '$queryId' not found in profiler log.");
- }
-
- return $this->_queryProfiles[$queryId];
- }
-
- /**
- * Get an array of query profiles (Zend_Db_Profiler_Query objects). If $queryType
- * is set to one of the Zend_Db_Profiler::* constants then only queries of that
- * type will be returned. Normally, queries that have not yet ended will
- * not be returned unless $showUnfinished is set to True. If no
- * queries were found, False is returned. The returned array is indexed by the query
- * profile handles.
- *
- * @param integer $queryType
- * @param boolean $showUnfinished
- * @return array|false
- */
- public function getQueryProfiles($queryType = null, $showUnfinished = false)
- {
- $queryProfiles = array();
- foreach ($this->_queryProfiles as $key => $qp) {
- if ($queryType === null) {
- $condition = true;
- } else {
- $condition = ($qp->getQueryType() & $queryType);
- }
-
- if (($qp->hasEnded() || $showUnfinished) && $condition) {
- $queryProfiles[$key] = $qp;
- }
- }
-
- if (empty($queryProfiles)) {
- $queryProfiles = false;
- }
-
- return $queryProfiles;
- }
-
- /**
- * Get the total elapsed time (in seconds) of all of the profiled queries.
- * Only queries that have ended will be counted. If $queryType is set to
- * one or more of the Zend_Db_Profiler::* constants, the elapsed time will be calculated
- * only for queries of the given type(s).
- *
- * @param integer $queryType OPTIONAL
- * @return float
- */
- public function getTotalElapsedSecs($queryType = null)
- {
- $elapsedSecs = 0;
- foreach ($this->_queryProfiles as $key => $qp) {
- if (null === $queryType) {
- $condition = true;
- } else {
- $condition = ($qp->getQueryType() & $queryType);
- }
- if (($qp->hasEnded()) && $condition) {
- $elapsedSecs += $qp->getElapsedSecs();
- }
- }
- return $elapsedSecs;
- }
-
- /**
- * Get the total number of queries that have been profiled. Only queries that have ended will
- * be counted. If $queryType is set to one of the Zend_Db_Profiler::* constants, only queries of
- * that type will be counted.
- *
- * @param integer $queryType OPTIONAL
- * @return integer
- */
- public function getTotalNumQueries($queryType = null)
- {
- if (null === $queryType) {
- return count($this->_queryProfiles);
- }
-
- $numQueries = 0;
- foreach ($this->_queryProfiles as $qp) {
- if ($qp->hasEnded() && ($qp->getQueryType() & $queryType)) {
- $numQueries++;
- }
- }
-
- return $numQueries;
- }
-
- /**
- * Get the Zend_Db_Profiler_Query object for the last query that was run, regardless if it has
- * ended or not. If the query has not ended, its end time will be null. If no queries have
- * been profiled, false is returned.
- *
- * @return Zend_Db_Profiler_Query|false
- */
- public function getLastQueryProfile()
- {
- if (empty($this->_queryProfiles)) {
- return false;
- }
-
- end($this->_queryProfiles);
-
- return current($this->_queryProfiles);
- }
-
-}
-
diff --git a/library/vendor/Zend/Db/Profiler/Exception.php b/library/vendor/Zend/Db/Profiler/Exception.php
deleted file mode 100644
index c2f76fa6f..000000000
--- a/library/vendor/Zend/Db/Profiler/Exception.php
+++ /dev/null
@@ -1,39 +0,0 @@
-_query = $query;
- $this->_queryType = $queryType;
- // by default, and for backward-compatibility, start the click ticking
- $this->start();
- }
-
- /**
- * Clone handler for the query object.
- * @return void
- */
- public function __clone()
- {
- $this->_boundParams = array();
- $this->_endedMicrotime = null;
- $this->start();
- }
-
- /**
- * Starts the elapsed time click ticking.
- * This can be called subsequent to object creation,
- * to restart the clock. For instance, this is useful
- * right before executing a prepared query.
- *
- * @return void
- */
- public function start()
- {
- $this->_startedMicrotime = microtime(true);
- }
-
- /**
- * Ends the query and records the time so that the elapsed time can be determined later.
- *
- * @return void
- */
- public function end()
- {
- $this->_endedMicrotime = microtime(true);
- }
-
- /**
- * Returns true if and only if the query has ended.
- *
- * @return boolean
- */
- public function hasEnded()
- {
- return $this->_endedMicrotime !== null;
- }
-
- /**
- * Get the original SQL text of the query.
- *
- * @return string
- */
- public function getQuery()
- {
- return $this->_query;
- }
-
- /**
- * Get the type of this query (one of the Zend_Db_Profiler::* constants)
- *
- * @return integer
- */
- public function getQueryType()
- {
- return $this->_queryType;
- }
-
- /**
- * @param string $param
- * @param mixed $variable
- * @return void
- */
- public function bindParam($param, $variable)
- {
- $this->_boundParams[$param] = $variable;
- }
-
- /**
- * @param array $param
- * @return void
- */
- public function bindParams(array $params)
- {
- if (array_key_exists(0, $params)) {
- array_unshift($params, null);
- unset($params[0]);
- }
- foreach ($params as $param => $value) {
- $this->bindParam($param, $value);
- }
- }
-
- /**
- * @return array
- */
- public function getQueryParams()
- {
- return $this->_boundParams;
- }
-
- /**
- * Get the elapsed time (in seconds) that the query ran.
- * If the query has not yet ended, false is returned.
- *
- * @return float|false
- */
- public function getElapsedSecs()
- {
- if (null === $this->_endedMicrotime) {
- return false;
- }
-
- return $this->_endedMicrotime - $this->_startedMicrotime;
- }
-
- /**
- * Get the time (in seconds) when the profiler started running.
- *
- * @return bool|float
- */
- public function getStartedMicrotime()
- {
- if(null === $this->_startedMicrotime) {
- return false;
- }
-
- return $this->_startedMicrotime;
- }
-}
-
diff --git a/library/vendor/Zend/Db/Select.php b/library/vendor/Zend/Db/Select.php
deleted file mode 100644
index 64908e3f6..000000000
--- a/library/vendor/Zend/Db/Select.php
+++ /dev/null
@@ -1,1368 +0,0 @@
- false,
- self::COLUMNS => array(),
- self::UNION => array(),
- self::FROM => array(),
- self::WHERE => array(),
- self::GROUP => array(),
- self::HAVING => array(),
- self::ORDER => array(),
- self::LIMIT_COUNT => null,
- self::LIMIT_OFFSET => null,
- self::FOR_UPDATE => false
- );
-
- /**
- * Specify legal join types.
- *
- * @var array
- */
- protected static $_joinTypes = array(
- self::INNER_JOIN,
- self::LEFT_JOIN,
- self::RIGHT_JOIN,
- self::FULL_JOIN,
- self::CROSS_JOIN,
- self::NATURAL_JOIN,
- );
-
- /**
- * Specify legal union types.
- *
- * @var array
- */
- protected static $_unionTypes = array(
- self::SQL_UNION,
- self::SQL_UNION_ALL
- );
-
- /**
- * The component parts of a SELECT statement.
- * Initialized to the $_partsInit array in the constructor.
- *
- * @var array
- */
- protected $_parts = array();
-
- /**
- * Tracks which columns are being select from each table and join.
- *
- * @var array
- */
- protected $_tableCols = array();
-
- /**
- * Class constructor
- *
- * @param Zend_Db_Adapter_Abstract $adapter
- */
- public function __construct(Zend_Db_Adapter_Abstract $adapter)
- {
- $this->_adapter = $adapter;
- $this->_parts = self::$_partsInit;
- }
-
- /**
- * Get bind variables
- *
- * @return array
- */
- public function getBind()
- {
- return $this->_bind;
- }
-
- /**
- * Set bind variables
- *
- * @param mixed $bind
- * @return Zend_Db_Select
- */
- public function bind($bind)
- {
- $this->_bind = $bind;
-
- return $this;
- }
-
- /**
- * Makes the query SELECT DISTINCT.
- *
- * @param bool $flag Whether or not the SELECT is DISTINCT (default true).
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function distinct($flag = true)
- {
- $this->_parts[self::DISTINCT] = (bool) $flag;
- return $this;
- }
-
- /**
- * Adds a FROM table and optional columns to the query.
- *
- * The first parameter $name can be a simple string, in which case the
- * correlation name is generated automatically. If you want to specify
- * the correlation name, the first parameter must be an associative
- * array in which the key is the correlation name, and the value is
- * the physical table name. For example, array('alias' => 'table').
- * The correlation name is prepended to all columns fetched for this
- * table.
- *
- * The second parameter can be a single string or Zend_Db_Expr object,
- * or else an array of strings or Zend_Db_Expr objects.
- *
- * The first parameter can be null or an empty string, in which case
- * no correlation name is generated or prepended to the columns named
- * in the second parameter.
- *
- * @param array|string|Zend_Db_Expr $name The table name or an associative array
- * relating correlation name to table name.
- * @param array|string|Zend_Db_Expr $cols The columns to select from this table.
- * @param string $schema The schema name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function from($name, $cols = '*', $schema = null)
- {
- return $this->_join(self::FROM, $name, null, $cols, $schema);
- }
-
- /**
- * Specifies the columns used in the FROM clause.
- *
- * The parameter can be a single string or Zend_Db_Expr object,
- * or else an array of strings or Zend_Db_Expr objects.
- *
- * @param array|string|Zend_Db_Expr $cols The columns to select from this table.
- * @param string $correlationName Correlation name of target table. OPTIONAL
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function columns($cols = '*', $correlationName = null)
- {
- if ($correlationName === null && count($this->_parts[self::FROM])) {
- $correlationNameKeys = array_keys($this->_parts[self::FROM]);
- $correlationName = current($correlationNameKeys);
- }
-
- if (!array_key_exists($correlationName, $this->_parts[self::FROM])) {
- /**
- * @see Zend_Db_Select_Exception
- */
- throw new Zend_Db_Select_Exception("No table has been specified for the FROM clause");
- }
-
- $this->_tableCols($correlationName, $cols);
-
- return $this;
- }
-
- /**
- * Adds a UNION clause to the query.
- *
- * The first parameter has to be an array of Zend_Db_Select or
- * sql query strings.
- *
- *
- * $sql1 = $db->select();
- * $sql2 = "SELECT ...";
- * $select = $db->select()
- * ->union(array($sql1, $sql2))
- * ->order("id");
- *
- *
- * @param array $select Array of select clauses for the union.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function union($select = array(), $type = self::SQL_UNION)
- {
- if (!is_array($select)) {
- throw new Zend_Db_Select_Exception(
- "union() only accepts an array of Zend_Db_Select instances of sql query strings."
- );
- }
-
- if (!in_array($type, self::$_unionTypes)) {
- throw new Zend_Db_Select_Exception("Invalid union type '{$type}'");
- }
-
- foreach ($select as $target) {
- $this->_parts[self::UNION][] = array($target, $type);
- }
-
- return $this;
- }
-
- /**
- * Adds a JOIN table and columns to the query.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function join($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->joinInner($name, $cond, $cols, $schema);
- }
-
- /**
- * Add an INNER JOIN table and colums to the query
- * Rows in both tables are matched according to the expression
- * in the $cond argument. The result set is comprised
- * of all cases where rows from the left table match
- * rows from the right table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinInner($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::INNER_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a LEFT OUTER JOIN table and colums to the query
- * All rows from the left operand table are included,
- * matching rows from the right operand table included,
- * and the columns from the right operand table are filled
- * with NULLs if no row exists matching the left table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinLeft($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::LEFT_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a RIGHT OUTER JOIN table and colums to the query.
- * Right outer join is the complement of left outer join.
- * All rows from the right operand table are included,
- * matching rows from the left operand table included,
- * and the columns from the left operand table are filled
- * with NULLs if no row exists matching the right table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinRight($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::RIGHT_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a FULL OUTER JOIN table and colums to the query.
- * A full outer join is like combining a left outer join
- * and a right outer join. All rows from both tables are
- * included, paired with each other on the same row of the
- * result set if they satisfy the join condition, and otherwise
- * paired with NULLs in place of columns from the other table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinFull($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::FULL_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a CROSS JOIN table and colums to the query.
- * A cross join is a cartesian product; there is no join condition.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinCross($name, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::CROSS_JOIN, $name, null, $cols, $schema);
- }
-
- /**
- * Add a NATURAL JOIN table and colums to the query.
- * A natural join assumes an equi-join across any column(s)
- * that appear with the same name in both tables.
- * Only natural inner joins are supported by this API,
- * even though SQL permits natural outer joins as well.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinNatural($name, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::NATURAL_JOIN, $name, null, $cols, $schema);
- }
-
- /**
- * Adds a WHERE condition to the query by AND.
- *
- * If a value is passed as the second param, it will be quoted
- * and replaced into the condition wherever a question-mark
- * appears. Array values are quoted and comma-separated.
- *
- *
- * // simplest but non-secure
- * $select->where("id = $id");
- *
- * // secure (ID is quoted but matched anyway)
- * $select->where('id = ?', $id);
- *
- * // alternatively, with named binding
- * $select->where('id = :id');
- *
- *
- * Note that it is more correct to use named bindings in your
- * queries for values other than strings. When you use named
- * bindings, don't forget to pass the values when actually
- * making a query:
- *
- *
- * $db->fetchAll($select, array('id' => 5));
- *
- *
- * @param string $cond The WHERE condition.
- * @param mixed $value OPTIONAL The value to quote into the condition.
- * @param int $type OPTIONAL The type of the given value
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function where($cond, $value = null, $type = null)
- {
- $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, true);
-
- return $this;
- }
-
- /**
- * Adds a WHERE condition to the query by OR.
- *
- * Otherwise identical to where().
- *
- * @param string $cond The WHERE condition.
- * @param mixed $value OPTIONAL The value to quote into the condition.
- * @param int $type OPTIONAL The type of the given value
- * @return Zend_Db_Select This Zend_Db_Select object.
- *
- * @see where()
- */
- public function orWhere($cond, $value = null, $type = null)
- {
- $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, false);
-
- return $this;
- }
-
- /**
- * Adds grouping to the query.
- *
- * @param array|string $spec The column(s) to group by.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function group($spec)
- {
- if (!is_array($spec)) {
- $spec = array($spec);
- }
-
- foreach ($spec as $val) {
- // Remove comments from SQL statement
- $noComments = preg_replace(self::REGEX_SQL_COMMENTS, '$1', (string) $val);
- if (preg_match(self::REGEX_COLUMN_EXPR_GROUP, $noComments)) {
- $val = new Zend_Db_Expr($val);
- }
- $this->_parts[self::GROUP][] = $val;
- }
-
- return $this;
- }
-
- /**
- * Adds a HAVING condition to the query by AND.
- *
- * If a value is passed as the second param, it will be quoted
- * and replaced into the condition wherever a question-mark
- * appears. See {@link where()} for an example
- *
- * @param string $cond The HAVING condition.
- * @param mixed $value OPTIONAL The value to quote into the condition.
- * @param int $type OPTIONAL The type of the given value
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function having($cond, $value = null, $type = null)
- {
- if ($value !== null) {
- $cond = $this->_adapter->quoteInto($cond, $value, $type);
- }
-
- if ($this->_parts[self::HAVING]) {
- $this->_parts[self::HAVING][] = self::SQL_AND . " ($cond)";
- } else {
- $this->_parts[self::HAVING][] = "($cond)";
- }
-
- return $this;
- }
-
- /**
- * Adds a HAVING condition to the query by OR.
- *
- * Otherwise identical to orHaving().
- *
- * @param string $cond The HAVING condition.
- * @param mixed $value OPTIONAL The value to quote into the condition.
- * @param int $type OPTIONAL The type of the given value
- * @return Zend_Db_Select This Zend_Db_Select object.
- *
- * @see having()
- */
- public function orHaving($cond, $value = null, $type = null)
- {
- if ($value !== null) {
- $cond = $this->_adapter->quoteInto($cond, $value, $type);
- }
-
- if ($this->_parts[self::HAVING]) {
- $this->_parts[self::HAVING][] = self::SQL_OR . " ($cond)";
- } else {
- $this->_parts[self::HAVING][] = "($cond)";
- }
-
- return $this;
- }
-
- /**
- * Adds a row order to the query.
- *
- * @param mixed $spec The column(s) and direction to order by.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function order($spec)
- {
- if (!is_array($spec)) {
- $spec = array($spec);
- }
-
- // force 'ASC' or 'DESC' on each order spec, default is ASC.
- foreach ($spec as $val) {
- if ($val instanceof Zend_Db_Expr) {
- $expr = $val->__toString();
- if (empty($expr)) {
- continue;
- }
- $this->_parts[self::ORDER][] = $val;
- } else {
- if (empty($val)) {
- continue;
- }
- $direction = self::SQL_ASC;
- if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) {
- $val = trim($matches[1]);
- $direction = $matches[2];
- }
- // Remove comments from SQL statement
- $noComments = preg_replace(self::REGEX_SQL_COMMENTS, '$1', (string) $val);
- if (preg_match(self::REGEX_COLUMN_EXPR_ORDER, $noComments)) {
- $val = new Zend_Db_Expr($val);
- }
- $this->_parts[self::ORDER][] = array($val, $direction);
- }
- }
-
- return $this;
- }
-
- /**
- * Sets a limit count and offset to the query.
- *
- * @param int $count OPTIONAL The number of rows to return.
- * @param int $offset OPTIONAL Start returning after this many rows.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function limit($count = null, $offset = null)
- {
- $this->_parts[self::LIMIT_COUNT] = (int) $count;
- $this->_parts[self::LIMIT_OFFSET] = (int) $offset;
- return $this;
- }
-
- /**
- * Sets the limit and count by page number.
- *
- * @param int $page Limit results to this page number.
- * @param int $rowCount Use this many rows per page.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function limitPage($page, $rowCount)
- {
- $page = ($page > 0) ? $page : 1;
- $rowCount = ($rowCount > 0) ? $rowCount : 1;
- $this->_parts[self::LIMIT_COUNT] = (int) $rowCount;
- $this->_parts[self::LIMIT_OFFSET] = (int) $rowCount * ($page - 1);
- return $this;
- }
-
- /**
- * Makes the query SELECT FOR UPDATE.
- *
- * @param bool $flag Whether or not the SELECT is FOR UPDATE (default true).
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function forUpdate($flag = true)
- {
- $this->_parts[self::FOR_UPDATE] = (bool) $flag;
- return $this;
- }
-
- /**
- * Get part of the structured information for the current query.
- *
- * @param string $part
- * @return mixed
- * @throws Zend_Db_Select_Exception
- */
- public function getPart($part)
- {
- $part = strtolower($part);
- if (!array_key_exists($part, $this->_parts)) {
- throw new Zend_Db_Select_Exception("Invalid Select part '$part'");
- }
- return $this->_parts[$part];
- }
-
- /**
- * Executes the current select object and returns the result
- *
- * @param integer $fetchMode OPTIONAL
- * @param mixed $bind An array of data to bind to the placeholders.
- * @return PDO_Statement|Zend_Db_Statement
- */
- public function query($fetchMode = null, $bind = array())
- {
- if (!empty($bind)) {
- $this->bind($bind);
- }
-
- $stmt = $this->_adapter->query($this);
- if ($fetchMode == null) {
- $fetchMode = $this->_adapter->getFetchMode();
- }
- $stmt->setFetchMode($fetchMode);
- return $stmt;
- }
-
- /**
- * Converts this object to an SQL SELECT string.
- *
- * @return string|null This object as a SELECT string. (or null if a string cannot be produced.)
- */
- public function assemble()
- {
- $sql = self::SQL_SELECT;
- foreach (array_keys(self::$_partsInit) as $part) {
- $method = '_render' . ucfirst($part);
- if (method_exists($this, $method)) {
- $sql = $this->$method($sql);
- }
- }
- return $sql;
- }
-
- /**
- * Clear parts of the Select object, or an individual part.
- *
- * @param string $part OPTIONAL
- * @return Zend_Db_Select
- */
- public function reset($part = null)
- {
- if ($part == null) {
- $this->_parts = self::$_partsInit;
- } elseif (array_key_exists($part, self::$_partsInit)) {
- $this->_parts[$part] = self::$_partsInit[$part];
- }
- return $this;
- }
-
- /**
- * Gets the Zend_Db_Adapter_Abstract for this
- * particular Zend_Db_Select object.
- *
- * @return Zend_Db_Adapter_Abstract
- */
- public function getAdapter()
- {
- return $this->_adapter;
- }
-
- /**
- * Populate the {@link $_parts} 'join' key
- *
- * Does the dirty work of populating the join key.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param null|string $type Type of join; inner, left, and null are currently supported
- * @param array|string|Zend_Db_Expr $name Table name
- * @param string $cond Join on this condition
- * @param array|string $cols The columns to select from the joined table
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object
- * @throws Zend_Db_Select_Exception
- */
- protected function _join($type, $name, $cond, $cols, $schema = null)
- {
- if (!in_array($type, self::$_joinTypes) && $type != self::FROM) {
- /**
- * @see Zend_Db_Select_Exception
- */
- throw new Zend_Db_Select_Exception("Invalid join type '$type'");
- }
-
- if (count($this->_parts[self::UNION])) {
- throw new Zend_Db_Select_Exception("Invalid use of table with " . self::SQL_UNION);
- }
-
- if (empty($name)) {
- $correlationName = $tableName = '';
- } elseif (is_array($name)) {
- // Must be array($correlationName => $tableName) or array($ident, ...)
- foreach ($name as $_correlationName => $_tableName) {
- if (is_string($_correlationName)) {
- // We assume the key is the correlation name and value is the table name
- $tableName = $_tableName;
- $correlationName = $_correlationName;
- } else {
- // We assume just an array of identifiers, with no correlation name
- $tableName = $_tableName;
- $correlationName = $this->_uniqueCorrelation($tableName);
- }
- break;
- }
- } elseif ($name instanceof Zend_Db_Expr|| $name instanceof Zend_Db_Select) {
- $tableName = $name;
- $correlationName = $this->_uniqueCorrelation('t');
- } elseif (preg_match('/^(.+)\s+AS\s+(.+)$/i', $name, $m)) {
- $tableName = $m[1];
- $correlationName = $m[2];
- } else {
- $tableName = $name;
- $correlationName = $this->_uniqueCorrelation($tableName);
- }
-
- // Schema from table name overrides schema argument
- if (!is_object($tableName) && false !== strpos($tableName, '.')) {
- list($schema, $tableName) = explode('.', $tableName);
- }
-
- $lastFromCorrelationName = null;
- if (!empty($correlationName)) {
- if (array_key_exists($correlationName, $this->_parts[self::FROM])) {
- /**
- * @see Zend_Db_Select_Exception
- */
- throw new Zend_Db_Select_Exception("You cannot define a correlation name '$correlationName' more than once");
- }
-
- if ($type == self::FROM) {
- // append this from after the last from joinType
- $tmpFromParts = $this->_parts[self::FROM];
- $this->_parts[self::FROM] = array();
- // move all the froms onto the stack
- while ($tmpFromParts) {
- $currentCorrelationName = key($tmpFromParts);
- if ($tmpFromParts[$currentCorrelationName]['joinType'] != self::FROM) {
- break;
- }
- $lastFromCorrelationName = $currentCorrelationName;
- $this->_parts[self::FROM][$currentCorrelationName] = array_shift($tmpFromParts);
- }
- } else {
- $tmpFromParts = array();
- }
- $this->_parts[self::FROM][$correlationName] = array(
- 'joinType' => $type,
- 'schema' => $schema,
- 'tableName' => $tableName,
- 'joinCondition' => $cond
- );
- while ($tmpFromParts) {
- $currentCorrelationName = key($tmpFromParts);
- $this->_parts[self::FROM][$currentCorrelationName] = array_shift($tmpFromParts);
- }
- }
-
- // add to the columns from this joined table
- if ($type == self::FROM && $lastFromCorrelationName == null) {
- $lastFromCorrelationName = true;
- }
- $this->_tableCols($correlationName, $cols, $lastFromCorrelationName);
-
- return $this;
- }
-
- /**
- * Handle JOIN... USING... syntax
- *
- * This is functionality identical to the existing JOIN methods, however
- * the join condition can be passed as a single column name. This method
- * then completes the ON condition by using the same field for the FROM
- * table and the JOIN table.
- *
- *
- * $select = $db->select()->from('table1')
- * ->joinUsing('table2', 'column1');
- *
- * // SELECT * FROM table1 JOIN table2 ON table1.column1 = table2.column2
- *
- *
- * These joins are called by the developer simply by adding 'Using' to the
- * method name. E.g.
- * * joinUsing
- * * joinInnerUsing
- * * joinFullUsing
- * * joinRightUsing
- * * joinLeftUsing
- *
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function _joinUsing($type, $name, $cond, $cols = '*', $schema = null)
- {
- if (empty($this->_parts[self::FROM])) {
- throw new Zend_Db_Select_Exception("You can only perform a joinUsing after specifying a FROM table");
- }
-
- $join = $this->_adapter->quoteIdentifier(key($this->_parts[self::FROM]), true);
- $from = $this->_adapter->quoteIdentifier($this->_uniqueCorrelation($name), true);
-
- $joinCond = array();
- foreach ((array)$cond as $fieldName) {
- $cond1 = $from . '.' . $fieldName;
- $cond2 = $join . '.' . $fieldName;
- $joinCond[] = $cond1 . ' = ' . $cond2;
- }
- $cond = implode(' '.self::SQL_AND.' ', $joinCond);
-
- return $this->_join($type, $name, $cond, $cols, $schema);
- }
-
- /**
- * Generate a unique correlation name
- *
- * @param string|array $name A qualified identifier.
- * @return string A unique correlation name.
- */
- private function _uniqueCorrelation($name)
- {
- if (is_array($name)) {
- $k = key($name);
- $c = is_string($k) ? $k : end($name);
- } else {
- // Extract just the last name of a qualified table name
- $dot = strrpos($name,'.');
- $c = ($dot === false) ? $name : substr($name, $dot+1);
- }
- for ($i = 2; array_key_exists($c, $this->_parts[self::FROM]); ++$i) {
- $c = $name . '_' . (string) $i;
- }
- return $c;
- }
-
- /**
- * Adds to the internal table-to-column mapping array.
- *
- * @param string $tbl The table/join the columns come from.
- * @param array|string $cols The list of columns; preferably as
- * an array, but possibly as a string containing one column.
- * @param bool|string True if it should be prepended, a correlation name if it should be inserted
- * @return void
- */
- protected function _tableCols($correlationName, $cols, $afterCorrelationName = null)
- {
- if (!is_array($cols)) {
- $cols = array($cols);
- }
-
- if ($correlationName == null) {
- $correlationName = '';
- }
-
- $columnValues = array();
-
- foreach (array_filter($cols) as $alias => $col) {
- $currentCorrelationName = $correlationName;
- if (is_string($col)) {
- // Check for a column matching "- | This file and the 14 PostScript(R) AFM files it accompanies may be used, copied, and distributed for any purpose and without charge, with or without modification, provided that all copyright notices are retained; that the AFM files are not distributed without this file; that all modifications to this file or any of the AFM files are prominently noted in the modified file(s); and that this paragraph is not modified. Adobe Systems has no responsibility or obligation to support the use of the AFM files. Col | -
Source http://www.adobe.com/devnet/font/#pcfi
- - \ No newline at end of file diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/broken_image.png b/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/broken_image.png deleted file mode 100644 index 771a1a378..000000000 Binary files a/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/broken_image.png and /dev/null differ diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/broken_image.svg b/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/broken_image.svg deleted file mode 100644 index 83ba7e74c..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/broken_image.svg +++ /dev/null @@ -1,8 +0,0 @@ - - \ No newline at end of file diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/html.css b/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/html.css deleted file mode 100644 index 89dcde633..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/lib/res/html.css +++ /dev/null @@ -1,518 +0,0 @@ -/** - * dompdf default stylesheet. - * - * @package dompdf - * @link https://github.com/dompdf/dompdf - * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License - * - * Portions from Mozilla - * @link https://dxr.mozilla.org/mozilla-central/source/layout/style/res/html.css - * @license http://mozilla.org/MPL/2.0/ Mozilla Public License, v. 2.0 - * - * Portions from W3C - * @link https://drafts.csswg.org/css-ui-3/#default-style-sheet - * - */ - -@page { - margin: 1.2cm; -} - -html { - display: -dompdf-page !important; - counter-reset: page; -} - -/* blocks */ - -article, -aside, -details, -div, -dt, -figcaption, -footer, -form, -header, -hgroup, -main, -nav, -noscript, -section, -summary { - display: block; -} - -body { - page-break-before: avoid; - display: block !important; - counter-increment: page; -} - -p, dl, multicol { - display: block; - margin: 1em 0; -} - -dd { - display: block; - margin-left: 40px; -} - -blockquote, figure { - display: block; - margin: 1em 40px; -} - -address { - display: block; - font-style: italic; -} - -center { - display: block; - text-align: center; -} - -blockquote[type=cite] { - display: block; - margin: 1em 0; - padding-left: 1em; - border-left: solid; - border-color: blue; - border-width: thin; -} - -h1, h2, h3, h4, h5, h6 { - display: block; - font-weight: bold; -} - -h1 { - font-size: 2em; - margin: .67em 0; -} - -h2 { - font-size: 1.5em; - margin: .83em 0; -} - -h3 { - font-size: 1.17em; - margin: 1em 0; -} - -h4 { - margin: 1.33em 0; -} - -h5 { - font-size: 0.83em; - margin: 1.67em 0; -} - -h6 { - font-size: 0.67em; - margin: 2.33em 0; -} - -listing { - display: block; - font-family: fixed; - font-size: medium; - white-space: pre; - margin: 1em 0; -} - -plaintext, pre, xmp { - display: block; - font-family: fixed; - white-space: pre; - margin: 1em 0; -} - -/* tables */ - -table { - display: table; - border-spacing: 2px; - border-collapse: separate; - margin-top: 0; - margin-bottom: 0; - text-indent: 0; - text-align: left; /* quirk */ -} - -table[border] { - border: outset gray; -} - -table[border] td, -table[border] th { - border: 1px inset gray; -} - -table[border="0"] td, -table[border="0"] th { - border-width: 0; -} - -/* make sure backgrounds are inherited in tables -- see bug 4510 */ -td, th, tr { - background: inherit; -} - -/* caption inherits from table not table-outer */ -caption { - display: table-caption; - text-align: center; -} - -tr { - display: table-row; - vertical-align: inherit; -} - -col { - display: table-column; -} - -colgroup { - display: table-column-group; -} - -tbody { - display: table-row-group; - vertical-align: middle; -} - -thead { - display: table-header-group; - vertical-align: middle; -} - -tfoot { - display: table-footer-group; - vertical-align: middle; -} - -/* To simulate tbody auto-insertion */ -table > tr { - vertical-align: middle; -} - -td { - display: table-cell; - vertical-align: inherit; - text-align: inherit; - padding: 1px; -} - -th { - display: table-cell; - vertical-align: inherit; - text-align: center; - font-weight: bold; - padding: 1px; -} - -/* inlines */ - -q:before { - content: open-quote; -} - -q:after { - content: close-quote; -} - -:link { - color: #00c; - text-decoration: underline; -} - -b, strong { - font-weight: bolder; -} - -i, cite, em, var, dfn { - font-style: italic; -} - -tt, code, kbd, samp { - font-family: fixed; -} - -u, ins { - text-decoration: underline; -} - -s, strike, del { - text-decoration: line-through; -} - -big { - font-size: larger; -} - -small { - font-size: smaller; -} - -sub { - vertical-align: sub; - font-size: smaller; - line-height: normal; -} - -sup { - vertical-align: super; - font-size: smaller; - line-height: normal; -} - -nobr { - white-space: nowrap; -} - -mark { - background: yellow; - color: black; -} - -/* titles */ - -abbr[title], acronym[title] { - text-decoration: dotted underline; -} - -/* lists */ - -ul, menu, dir { - display: block; - list-style-type: disc; - margin: 1em 0; - padding-left: 40px; -} - -ol { - display: block; - list-style-type: decimal; - margin: 1em 0; - padding-left: 40px; -} - -li { - display: list-item; -} - -/*li:before { - display: -dompdf-list-bullet !important; - content: counter(-dompdf-default-counter) ". "; - padding-right: 0.5em; -}*/ - -/* nested lists have no top/bottom margins */ -:matches(ul, ol, dir, menu, dl) ul, -:matches(ul, ol, dir, menu, dl) ol, -:matches(ul, ol, dir, menu, dl) dir, -:matches(ul, ol, dir, menu, dl) menu, -:matches(ul, ol, dir, menu, dl) dl { - margin-top: 0; - margin-bottom: 0; -} - -/* 2 deep unordered lists use a circle */ -:matches(ul, ol, dir, menu) ul, -:matches(ul, ol, dir, menu) ul, -:matches(ul, ol, dir, menu) ul, -:matches(ul, ol, dir, menu) ul { - list-style-type: circle; -} - -/* 3 deep (or more) unordered lists use a square */ -:matches(ul, ol, dir, menu) :matches(ul, ol, dir, menu) ul, -:matches(ul, ol, dir, menu) :matches(ul, ol, dir, menu) menu, -:matches(ul, ol, dir, menu) :matches(ul, ol, dir, menu) dir { - list-style-type: square; -} - -/* forms */ -/* From https://drafts.csswg.org/css-ui-3/#default-style-sheet */ -form { - display: block; -} - -input, button, select { - display: inline-block; - font-family: sans-serif; -} - -input[type=text], -input[type=password], -select { - width: 12em; -} - -input[type=text], -input[type=password], -input[type=button], -input[type=submit], -input[type=reset], -input[type=file], -button, -textarea, -select { - background: #FFF; - border: 1px solid #999; - padding: 2px; - margin: 2px; -} - -input[type=button], -input[type=submit], -input[type=reset], -input[type=file], -button { - background: #CCC; - text-align: center; -} - -input[type=file] { - width: 8em; -} - -input[type=text]:before, -input[type=button]:before, -input[type=submit]:before, -input[type=reset]:before { - content: attr(value); -} - -input[type=file]:before { - content: "Choose a file"; -} - -input[type=password][value]:before { - font-family: "DejaVu Sans" !important; - content: "\2022\2022\2022\2022\2022\2022\2022\2022"; - line-height: 1em; -} - -input[type=checkbox], -input[type=radio], -select:after { - font-family: "DejaVu Sans" !important; - font-size: 18px; - line-height: 1; -} - -input[type=checkbox]:before { - content: "\2610"; -} - -input[type=checkbox][checked]:before { - content: "\2611"; -} - -input[type=radio]:before { - content: "\25CB"; -} - -input[type=radio][checked]:before { - content: "\25C9"; -} - -textarea { - display: block; - height: 3em; - overflow: hidden; - font-family: monospace; - white-space: pre-wrap; - word-wrap: break-word; -} - -select { - position: relative!important; - overflow: hidden!important; -} - -select:after { - position: absolute; - right: 0; - top: 0; - height: 5em; - width: 1.4em; - text-align: center; - background: #CCC; - content: "\25BE"; -} - -select option { - display: none; -} - -select option[selected] { - display: inline; -} - -fieldset { - display: block; - margin: 0.6em 2px 2px; - padding: 0.75em; - border: 1pt groove #666; - position: relative; -} - -fieldset > legend { - position: absolute; - top: -0.6em; - left: 0.75em; - padding: 0 0.3em; - background: white; -} - -legend { - display: inline-block; -} - -/* leafs */ - -hr { - display: block; - height: 0; - border: 1px inset; - margin: 0.5em auto 0.5em auto; -} - -hr[size="1"] { - border-style: solid none none none; -} - -iframe { - border: 2px inset; -} - -noframes { - display: block; -} - -br { - display: -dompdf-br; -} - -img, img_generated { - display: -dompdf-image !important; -} - -dompdf_generated { - display: inline; -} - -/* hidden elements */ -area, base, basefont, head, meta, script, style, title, -noembed, param { - display: none; - -dompdf-keep: yes; -} diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/CPDF.php b/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/CPDF.php deleted file mode 100644 index e8fc6ae4d..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/CPDF.php +++ /dev/null @@ -1,944 +0,0 @@ - [0.0, 0.0, 4767.87, 6740.79], - "2a0" => [0.0, 0.0, 3370.39, 4767.87], - "a0" => [0.0, 0.0, 2383.94, 3370.39], - "a1" => [0.0, 0.0, 1683.78, 2383.94], - "a2" => [0.0, 0.0, 1190.55, 1683.78], - "a3" => [0.0, 0.0, 841.89, 1190.55], - "a4" => [0.0, 0.0, 595.28, 841.89], - "a5" => [0.0, 0.0, 419.53, 595.28], - "a6" => [0.0, 0.0, 297.64, 419.53], - "a7" => [0.0, 0.0, 209.76, 297.64], - "a8" => [0.0, 0.0, 147.40, 209.76], - "a9" => [0.0, 0.0, 104.88, 147.40], - "a10" => [0.0, 0.0, 73.70, 104.88], - "b0" => [0.0, 0.0, 2834.65, 4008.19], - "b1" => [0.0, 0.0, 2004.09, 2834.65], - "b2" => [0.0, 0.0, 1417.32, 2004.09], - "b3" => [0.0, 0.0, 1000.63, 1417.32], - "b4" => [0.0, 0.0, 708.66, 1000.63], - "b5" => [0.0, 0.0, 498.90, 708.66], - "b6" => [0.0, 0.0, 354.33, 498.90], - "b7" => [0.0, 0.0, 249.45, 354.33], - "b8" => [0.0, 0.0, 175.75, 249.45], - "b9" => [0.0, 0.0, 124.72, 175.75], - "b10" => [0.0, 0.0, 87.87, 124.72], - "c0" => [0.0, 0.0, 2599.37, 3676.54], - "c1" => [0.0, 0.0, 1836.85, 2599.37], - "c2" => [0.0, 0.0, 1298.27, 1836.85], - "c3" => [0.0, 0.0, 918.43, 1298.27], - "c4" => [0.0, 0.0, 649.13, 918.43], - "c5" => [0.0, 0.0, 459.21, 649.13], - "c6" => [0.0, 0.0, 323.15, 459.21], - "c7" => [0.0, 0.0, 229.61, 323.15], - "c8" => [0.0, 0.0, 161.57, 229.61], - "c9" => [0.0, 0.0, 113.39, 161.57], - "c10" => [0.0, 0.0, 79.37, 113.39], - "ra0" => [0.0, 0.0, 2437.80, 3458.27], - "ra1" => [0.0, 0.0, 1729.13, 2437.80], - "ra2" => [0.0, 0.0, 1218.90, 1729.13], - "ra3" => [0.0, 0.0, 864.57, 1218.90], - "ra4" => [0.0, 0.0, 609.45, 864.57], - "sra0" => [0.0, 0.0, 2551.18, 3628.35], - "sra1" => [0.0, 0.0, 1814.17, 2551.18], - "sra2" => [0.0, 0.0, 1275.59, 1814.17], - "sra3" => [0.0, 0.0, 907.09, 1275.59], - "sra4" => [0.0, 0.0, 637.80, 907.09], - "letter" => [0.0, 0.0, 612.00, 792.00], - "half-letter" => [0.0, 0.0, 396.00, 612.00], - "legal" => [0.0, 0.0, 612.00, 1008.00], - "ledger" => [0.0, 0.0, 1224.00, 792.00], - "tabloid" => [0.0, 0.0, 792.00, 1224.00], - "executive" => [0.0, 0.0, 521.86, 756.00], - "folio" => [0.0, 0.0, 612.00, 936.00], - "commercial #10 envelope" => [0.0, 0.0, 684.00, 297.00], - "catalog #10 1/2 envelope" => [0.0, 0.0, 648.00, 864.00], - "8.5x11" => [0.0, 0.0, 612.00, 792.00], - "8.5x14" => [0.0, 0.0, 612.00, 1008.00], - "11x17" => [0.0, 0.0, 792.00, 1224.00], - ]; - - /** - * The Dompdf object - * - * @var Dompdf - */ - protected $_dompdf; - - /** - * Instance of Cpdf class - * - * @var \Dompdf\Cpdf - */ - protected $_pdf; - - /** - * PDF width, in points - * - * @var float - */ - protected $_width; - - /** - * PDF height, in points - * - * @var float - */ - protected $_height; - - /** - * Current page number - * - * @var int - */ - protected $_page_number; - - /** - * Total number of pages - * - * @var int - */ - protected $_page_count; - - /** - * Array of pages for accessing after rendering is initially complete - * - * @var array - */ - protected $_pages; - - /** - * Currently-applied opacity level (0 - 1) - * - * @var float - */ - protected $_current_opacity = 1; - - public function __construct($paper = "letter", $orientation = "portrait", ?Dompdf $dompdf = null) - { - if (is_array($paper)) { - $size = array_map("floatval", $paper); - } else { - $paper = strtolower($paper); - $size = self::$PAPER_SIZES[$paper] ?? self::$PAPER_SIZES["letter"]; - } - - if (strtolower($orientation) === "landscape") { - [$size[2], $size[3]] = [$size[3], $size[2]]; - } - - if ($dompdf === null) { - $this->_dompdf = new Dompdf(); - } else { - $this->_dompdf = $dompdf; - } - - $this->_pdf = new \Dompdf\Cpdf( - $size, - true, - $this->_dompdf->getOptions()->getFontCache(), - $this->_dompdf->getOptions()->getTempDir() - ); - - $this->_pdf->addInfo("Producer", sprintf("%s + CPDF", $this->_dompdf->version)); - $time = substr_replace(date('YmdHisO'), '\'', -2, 0) . '\''; - $this->_pdf->addInfo("CreationDate", "D:$time"); - $this->_pdf->addInfo("ModDate", "D:$time"); - - $this->_width = $size[2] - $size[0]; - $this->_height = $size[3] - $size[1]; - - $this->_page_number = $this->_page_count = 1; - - $this->_pages = [$this->_pdf->getFirstPageId()]; - } - - public function get_dompdf() - { - return $this->_dompdf; - } - - /** - * Returns the Cpdf instance - * - * @return \Dompdf\Cpdf - */ - public function get_cpdf() - { - return $this->_pdf; - } - - public function add_info(string $label, string $value): void - { - $this->_pdf->addInfo($label, $value); - } - - /** - * Opens a new 'object' - * - * While an object is open, all drawing actions are recorded in the object, - * as opposed to being drawn on the current page. Objects can be added - * later to a specific page or to several pages. - * - * The return value is an integer ID for the new object. - * - * @see CPDF::close_object() - * @see CPDF::add_object() - * - * @return int - */ - public function open_object() - { - $ret = $this->_pdf->openObject(); - $this->_pdf->saveState(); - return $ret; - } - - /** - * Reopens an existing 'object' - * - * @see CPDF::open_object() - * @param int $object the ID of a previously opened object - */ - public function reopen_object($object) - { - $this->_pdf->reopenObject($object); - $this->_pdf->saveState(); - } - - /** - * Closes the current 'object' - * - * @see CPDF::open_object() - */ - public function close_object() - { - $this->_pdf->restoreState(); - $this->_pdf->closeObject(); - } - - /** - * Adds a specified 'object' to the document - * - * $object int specifying an object created with {@link - * CPDF::open_object()}. $where can be one of: - * - 'add' add to current page only - * - 'all' add to every page from the current one onwards - * - 'odd' add to all odd numbered pages from now on - * - 'even' add to all even numbered pages from now on - * - 'next' add the object to the next page only - * - 'nextodd' add to all odd numbered pages from the next one - * - 'nexteven' add to all even numbered pages from the next one - * - * @see Cpdf::addObject() - * - * @param int $object - * @param string $where - */ - public function add_object($object, $where = 'all') - { - $this->_pdf->addObject($object, $where); - } - - /** - * Stops the specified 'object' from appearing in the document. - * - * The object will stop being displayed on the page following the current - * one. - * - * @param int $object - */ - public function stop_object($object) - { - $this->_pdf->stopObject($object); - } - - /** - * Serialize the pdf object's current state for retrieval later - */ - public function serialize_object($id) - { - return $this->_pdf->serializeObject($id); - } - - public function reopen_serialized_object($obj) - { - return $this->_pdf->restoreSerializedObject($obj); - } - - //........................................................................ - - public function get_width() - { - return $this->_width; - } - - public function get_height() - { - return $this->_height; - } - - public function get_page_number() - { - return $this->_page_number; - } - - public function get_page_count() - { - return $this->_page_count; - } - - /** - * Sets the current page number - * - * @param int $num - */ - public function set_page_number($num) - { - $this->_page_number = $num; - } - - public function set_page_count($count) - { - $this->_page_count = $count; - } - - /** - * Sets the stroke color - * - * See {@link Style::set_color()} for the format of the color array. - * - * @param array $color - */ - protected function _set_stroke_color($color) - { - $this->_pdf->setStrokeColor($color); - $alpha = isset($color["alpha"]) ? $color["alpha"] : 1; - $alpha *= $this->_current_opacity; - $this->_set_line_transparency("Normal", $alpha); - } - - /** - * Sets the fill colour - * - * See {@link Style::set_color()} for the format of the colour array. - * - * @param array $color - */ - protected function _set_fill_color($color) - { - $this->_pdf->setColor($color); - $alpha = isset($color["alpha"]) ? $color["alpha"] : 1; - $alpha *= $this->_current_opacity; - $this->_set_fill_transparency("Normal", $alpha); - } - - /** - * Sets line transparency - * @see Cpdf::setLineTransparency() - * - * Valid blend modes are (case-sensitive): - * - * Normal, Multiply, Screen, Overlay, Darken, Lighten, - * ColorDodge, ColorBurn, HardLight, SoftLight, Difference, - * Exclusion - * - * @param string $mode the blending mode to use - * @param float $opacity 0.0 fully transparent, 1.0 fully opaque - */ - protected function _set_line_transparency($mode, $opacity) - { - $this->_pdf->setLineTransparency($mode, $opacity); - } - - /** - * Sets fill transparency - * @see Cpdf::setFillTransparency() - * - * Valid blend modes are (case-sensitive): - * - * Normal, Multiply, Screen, Overlay, Darken, Lighten, - * ColorDogde, ColorBurn, HardLight, SoftLight, Difference, - * Exclusion - * - * @param string $mode the blending mode to use - * @param float $opacity 0.0 fully transparent, 1.0 fully opaque - */ - protected function _set_fill_transparency($mode, $opacity) - { - $this->_pdf->setFillTransparency($mode, $opacity); - } - - /** - * Sets the line style - * - * @see Cpdf::setLineStyle() - * - * @param float $width - * @param string $cap - * @param string $join - * @param array $dash - */ - protected function _set_line_style($width, $cap, $join, $dash) - { - $this->_pdf->setLineStyle($width, $cap, $join, $dash); - } - - public function set_opacity(float $opacity, string $mode = "Normal"): void - { - $this->_set_line_transparency($mode, $opacity); - $this->_set_fill_transparency($mode, $opacity); - $this->_current_opacity = $opacity; - } - - public function set_default_view($view, $options = []) - { - array_unshift($options, $view); - call_user_func_array([$this->_pdf, "openHere"], $options); - } - - /** - * Remaps y coords from 4th to 1st quadrant - * - * @param float $y - * @return float - */ - protected function y($y) - { - return $this->_height - $y; - } - - public function line($x1, $y1, $x2, $y2, $color, $width, $style = [], $cap = "butt") - { - $this->_set_stroke_color($color); - $this->_set_line_style($width, $cap, "", $style); - - $this->_pdf->line($x1, $this->y($y1), - $x2, $this->y($y2)); - $this->_set_line_transparency("Normal", $this->_current_opacity); - } - - public function arc($x, $y, $r1, $r2, $astart, $aend, $color, $width, $style = [], $cap = "butt") - { - $this->_set_stroke_color($color); - $this->_set_line_style($width, $cap, "", $style); - - $this->_pdf->ellipse($x, $this->y($y), $r1, $r2, 0, 8, $astart, $aend, false, false, true, false); - $this->_set_line_transparency("Normal", $this->_current_opacity); - } - - public function rectangle($x1, $y1, $w, $h, $color, $width, $style = [], $cap = "butt") - { - $this->_set_stroke_color($color); - $this->_set_line_style($width, $cap, "", $style); - $this->_pdf->rectangle($x1, $this->y($y1) - $h, $w, $h); - $this->_set_line_transparency("Normal", $this->_current_opacity); - } - - public function filled_rectangle($x1, $y1, $w, $h, $color) - { - $this->_set_fill_color($color); - $this->_pdf->filledRectangle($x1, $this->y($y1) - $h, $w, $h); - $this->_set_fill_transparency("Normal", $this->_current_opacity); - } - - public function clipping_rectangle($x1, $y1, $w, $h) - { - $this->_pdf->clippingRectangle($x1, $this->y($y1) - $h, $w, $h); - } - - public function clipping_roundrectangle($x1, $y1, $w, $h, $rTL, $rTR, $rBR, $rBL) - { - $this->_pdf->clippingRectangleRounded($x1, $this->y($y1) - $h, $w, $h, $rTL, $rTR, $rBR, $rBL); - } - - public function clipping_polygon(array $points): void - { - // Adjust y values - for ($i = 1; $i < count($points); $i += 2) { - $points[$i] = $this->y($points[$i]); - } - - $this->_pdf->clippingPolygon($points); - } - - public function clipping_end() - { - $this->_pdf->clippingEnd(); - } - - public function save() - { - $this->_pdf->saveState(); - } - - public function restore() - { - $this->_pdf->restoreState(); - } - - public function rotate($angle, $x, $y) - { - $this->_pdf->rotate($angle, $x, $y); - } - - public function skew($angle_x, $angle_y, $x, $y) - { - $this->_pdf->skew($angle_x, $angle_y, $x, $y); - } - - public function scale($s_x, $s_y, $x, $y) - { - $this->_pdf->scale($s_x, $s_y, $x, $y); - } - - public function translate($t_x, $t_y) - { - $this->_pdf->translate($t_x, $t_y); - } - - public function transform($a, $b, $c, $d, $e, $f) - { - $this->_pdf->transform([$a, $b, $c, $d, $e, $f]); - } - - public function polygon($points, $color, $width = null, $style = [], $fill = false) - { - $this->_set_fill_color($color); - $this->_set_stroke_color($color); - - if (!$fill && isset($width)) { - $this->_set_line_style($width, "square", "miter", $style); - } - - // Adjust y values - for ($i = 1; $i < count($points); $i += 2) { - $points[$i] = $this->y($points[$i]); - } - - $this->_pdf->polygon($points, $fill); - - $this->_set_fill_transparency("Normal", $this->_current_opacity); - $this->_set_line_transparency("Normal", $this->_current_opacity); - } - - public function circle($x, $y, $r, $color, $width = null, $style = [], $fill = false) - { - $this->_set_fill_color($color); - $this->_set_stroke_color($color); - - if (!$fill && isset($width)) { - $this->_set_line_style($width, "round", "round", $style); - } - - $this->_pdf->ellipse($x, $this->y($y), $r, 0, 0, 8, 0, 360, 1, $fill); - - $this->_set_fill_transparency("Normal", $this->_current_opacity); - $this->_set_line_transparency("Normal", $this->_current_opacity); - } - - /** - * Convert image to a PNG image - * - * @param string $image_url - * @param string $type - * - * @return string|null The url of the newly converted image - */ - protected function _convert_to_png($image_url, $type) - { - $filename = Cache::getTempImage($image_url); - - if ($filename !== null && file_exists($filename)) { - return $filename; - } - - $func_name = "imagecreatefrom$type"; - - set_error_handler([Helpers::class, "record_warnings"]); - - if (!function_exists($func_name)) { - if (!method_exists(Helpers::class, $func_name)) { - throw new Exception("Function $func_name() not found. Cannot convert $type image: $image_url. Please install the image PHP extension."); - } - $func_name = [Helpers::class, $func_name]; - } - - try { - $im = call_user_func($func_name, $image_url); - - if ($im) { - imageinterlace($im, false); - - $tmp_dir = $this->_dompdf->getOptions()->getTempDir(); - $tmp_name = @tempnam($tmp_dir, "{$type}_dompdf_img_"); - @unlink($tmp_name); - $filename = "$tmp_name.png"; - - imagepng($im, $filename); - imagedestroy($im); - } else { - $filename = null; - } - } finally { - restore_error_handler(); - } - - if ($filename !== null) { - Cache::addTempImage($image_url, $filename); - } - - return $filename; - } - - public function image($img, $x, $y, $w, $h, $resolution = "normal") - { - [$width, $height, $type] = Helpers::dompdf_getimagesize($img, $this->get_dompdf()->getHttpContext()); - - $debug_png = $this->_dompdf->getOptions()->getDebugPng(); - - if ($debug_png) { - print "[image:$img|$width|$height|$type]"; - } - - switch ($type) { - case "jpeg": - if ($debug_png) { - print '!!!jpg!!!'; - } - $this->_pdf->addJpegFromFile($img, $x, $this->y($y) - $h, $w, $h); - break; - - case "webp": - /** @noinspection PhpMissingBreakStatementInspection */ - case "gif": - /** @noinspection PhpMissingBreakStatementInspection */ - case "bmp": - if ($debug_png) print "!!!{$type}!!!"; - $img = $this->_convert_to_png($img, $type); - if ($img === null) { - if ($debug_png) print '!!!conversion to PDF failed!!!'; - $this->image(Cache::$broken_image, $x, $y, $w, $h, $resolution); - break; - } - - case "png": - if ($debug_png) print '!!!png!!!'; - - $this->_pdf->addPngFromFile($img, $x, $this->y($y) - $h, $w, $h); - break; - - case "svg": - if ($debug_png) print '!!!SVG!!!'; - - $this->_pdf->addSvgFromFile($img, $x, $this->y($y) - $h, $w, $h); - break; - - default: - if ($debug_png) print '!!!unknown!!!'; - } - } - - public function select($x, $y, $w, $h, $font, $size, $color = [0, 0, 0], $opts = []) - { - $pdf = $this->_pdf; - - $font .= ".afm"; - $pdf->selectFont($font); - - if (!isset($pdf->acroFormId)) { - $pdf->addForm(); - } - - $ft = \Dompdf\Cpdf::ACROFORM_FIELD_CHOICE; - $ff = \Dompdf\Cpdf::ACROFORM_FIELD_CHOICE_COMBO; - - $id = $pdf->addFormField($ft, rand(), $x, $this->y($y) - $h, $x + $w, $this->y($y), $ff, $size, $color); - $pdf->setFormFieldOpt($id, $opts); - } - - public function textarea($x, $y, $w, $h, $font, $size, $color = [0, 0, 0]) - { - $pdf = $this->_pdf; - - $font .= ".afm"; - $pdf->selectFont($font); - - if (!isset($pdf->acroFormId)) { - $pdf->addForm(); - } - - $ft = \Dompdf\Cpdf::ACROFORM_FIELD_TEXT; - $ff = \Dompdf\Cpdf::ACROFORM_FIELD_TEXT_MULTILINE; - - $pdf->addFormField($ft, rand(), $x, $this->y($y) - $h, $x + $w, $this->y($y), $ff, $size, $color); - } - - public function input($x, $y, $w, $h, $type, $font, $size, $color = [0, 0, 0]) - { - $pdf = $this->_pdf; - - $font .= ".afm"; - $pdf->selectFont($font); - - if (!isset($pdf->acroFormId)) { - $pdf->addForm(); - } - - $ft = \Dompdf\Cpdf::ACROFORM_FIELD_TEXT; - $ff = 0; - - switch ($type) { - case 'text': - $ft = \Dompdf\Cpdf::ACROFORM_FIELD_TEXT; - break; - case 'password': - $ft = \Dompdf\Cpdf::ACROFORM_FIELD_TEXT; - $ff = \Dompdf\Cpdf::ACROFORM_FIELD_TEXT_PASSWORD; - break; - case 'submit': - $ft = \Dompdf\Cpdf::ACROFORM_FIELD_BUTTON; - break; - } - - $pdf->addFormField($ft, rand(), $x, $this->y($y) - $h, $x + $w, $this->y($y), $ff, $size, $color); - } - - public function text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_space = 0.0, $char_space = 0.0, $angle = 0.0) - { - $pdf = $this->_pdf; - - $this->_set_fill_color($color); - - $is_font_subsetting = $this->_dompdf->getOptions()->getIsFontSubsettingEnabled(); - $pdf->selectFont($font . '.afm', '', true, $is_font_subsetting); - - $pdf->addText($x, $this->y($y) - $pdf->getFontHeight($size), $size, $text, $angle, $word_space, $char_space); - - $this->_set_fill_transparency("Normal", $this->_current_opacity); - } - - public function javascript($code) - { - $this->_pdf->addJavascript($code); - } - - //........................................................................ - - public function add_named_dest($anchorname) - { - $this->_pdf->addDestination($anchorname, "Fit"); - } - - public function add_link($url, $x, $y, $width, $height) - { - $y = $this->y($y) - $height; - - if (strpos($url, '#') === 0) { - // Local link - $name = substr($url, 1); - if ($name) { - $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); - } - } else { - $this->_pdf->addLink($url, $x, $y, $x + $width, $y + $height); - } - } - - /** - * @throws FontNotFoundException - */ - public function get_text_width($text, $font, $size, $word_spacing = 0.0, $char_spacing = 0.0) - { - $this->_pdf->selectFont($font, '', true, $this->_dompdf->getOptions()->getIsFontSubsettingEnabled()); - return $this->_pdf->getTextWidth($size, $text, $word_spacing, $char_spacing); - } - - /** - * @throws FontNotFoundException - */ - public function get_font_height($font, $size) - { - $options = $this->_dompdf->getOptions(); - $this->_pdf->selectFont($font, '', true, $options->getIsFontSubsettingEnabled()); - - return $this->_pdf->getFontHeight($size) * $options->getFontHeightRatio(); - } - - /*function get_font_x_height($font, $size) { - $this->_pdf->selectFont($font); - $ratio = $this->_dompdf->getOptions()->getFontHeightRatio(); - return $this->_pdf->getFontXHeight($size) * $ratio; - }*/ - - /** - * @throws FontNotFoundException - */ - public function get_font_baseline($font, $size) - { - $ratio = $this->_dompdf->getOptions()->getFontHeightRatio(); - return $this->get_font_height($font, $size) / $ratio; - } - - /** - * Processes a callback or script on every page. - * - * The callback function receives the four parameters `int $pageNumber`, - * `int $pageCount`, `Canvas $canvas`, and `FontMetrics $fontMetrics`, in - * that order. If a script is passed as string, the variables `$PAGE_NUM`, - * `$PAGE_COUNT`, `$pdf`, and `$fontMetrics` are available instead. Passing - * a script as string is deprecated and will be removed in a future version. - * - * This function can be used to add page numbers to all pages after the - * first one, for example. - * - * @param callable|string $callback The callback function or PHP script to process on every page - */ - public function page_script($callback): void - { - if (is_string($callback)) { - $this->processPageScript(function ( - int $PAGE_NUM, - int $PAGE_COUNT, - self $pdf, - FontMetrics $fontMetrics - ) use ($callback) { - eval($callback); - }); - return; - } - - $this->processPageScript($callback); - } - - public function page_text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_space = 0.0, $char_space = 0.0, $angle = 0.0) - { - $this->processPageScript(function (int $pageNumber, int $pageCount) use ($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle) { - $text = str_replace( - ["{PAGE_NUM}", "{PAGE_COUNT}"], - [$pageNumber, $pageCount], - $text - ); - $this->text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle); - }); - } - - public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = []) - { - $this->processPageScript(function () use ($x1, $y1, $x2, $y2, $color, $width, $style) { - $this->line($x1, $y1, $x2, $y2, $color, $width, $style); - }); - } - - /** - * @return int - */ - public function new_page() - { - $this->_page_number++; - $this->_page_count++; - - $ret = $this->_pdf->newPage(); - $this->_pages[] = $ret; - return $ret; - } - - protected function processPageScript(callable $callback): void - { - $pageNumber = 1; - - foreach ($this->_pages as $pid) { - $this->reopen_object($pid); - - $fontMetrics = $this->_dompdf->getFontMetrics(); - $callback($pageNumber, $this->_page_count, $this, $fontMetrics); - - $this->close_object(); - $pageNumber++; - } - } - - public function stream($filename = "document.pdf", $options = []) - { - if (headers_sent()) { - die("Unable to stream pdf: headers already sent"); - } - - if (!isset($options["compress"])) $options["compress"] = true; - if (!isset($options["Attachment"])) $options["Attachment"] = true; - - $debug = !$options['compress']; - $tmp = ltrim($this->_pdf->output($debug)); - - header("Cache-Control: private"); - header("Content-Type: application/pdf"); - header("Content-Length: " . mb_strlen($tmp, "8bit")); - - $filename = str_replace(["\n", "'"], "", basename($filename, ".pdf")) . ".pdf"; - $attachment = $options["Attachment"] ? "attachment" : "inline"; - header(Helpers::buildContentDispositionHeader($attachment, $filename)); - - echo $tmp; - flush(); - } - - public function output($options = []) - { - if (!isset($options["compress"])) $options["compress"] = true; - - $debug = !$options['compress']; - - return $this->_pdf->output($debug); - } - - /** - * Returns logging messages generated by the Cpdf class - * - * @return string - */ - public function get_messages() - { - return $this->_pdf->messages; - } -} diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/GD.php b/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/GD.php deleted file mode 100644 index 8c10e4766..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/GD.php +++ /dev/null @@ -1,929 +0,0 @@ -_dompdf = new Dompdf(); - } else { - $this->_dompdf = $dompdf; - } - - $this->dpi = $this->get_dompdf()->getOptions()->getDpi(); - - if ($aa_factor < 1) { - $aa_factor = 1; - } - - $this->_aa_factor = $aa_factor; - - $size[2] *= $aa_factor; - $size[3] *= $aa_factor; - - $this->_width = $size[2] - $size[0]; - $this->_height = $size[3] - $size[1]; - - $this->_actual_width = $this->_upscale($this->_width); - $this->_actual_height = $this->_upscale($this->_height); - - $this->_page_number = $this->_page_count = 0; - - if (is_null($bg_color) || !is_array($bg_color)) { - // Pure white bg - $bg_color = [1, 1, 1, 0]; - } - - $this->_bg_color_array = $bg_color; - - $this->new_page(); - } - - public function get_dompdf() - { - return $this->_dompdf; - } - - /** - * Return the GD image resource - * - * @return \GdImage|resource - */ - public function get_image() - { - return $this->_img; - } - - /** - * Return the image's width in pixels - * - * @return int - */ - public function get_width() - { - return round($this->_width / $this->_aa_factor); - } - - /** - * Return the image's height in pixels - * - * @return int - */ - public function get_height() - { - return round($this->_height / $this->_aa_factor); - } - - public function get_page_number() - { - return $this->_page_number; - } - - public function get_page_count() - { - return $this->_page_count; - } - - /** - * Sets the current page number - * - * @param int $num - */ - public function set_page_number($num) - { - $this->_page_number = $num; - } - - public function set_page_count($count) - { - $this->_page_count = $count; - } - - public function set_opacity(float $opacity, string $mode = "Normal"): void - { - // FIXME - } - - /** - * Allocate a new color. Allocate with GD as needed and store - * previously allocated colors in $this->_colors. - * - * @param array $color The new current color - * @return int The allocated color - */ - protected function _allocate_color($color) - { - $a = isset($color["alpha"]) ? $color["alpha"] : 1; - - if (isset($color["c"])) { - $color = Helpers::cmyk_to_rgb($color); - } - - list($r, $g, $b) = $color; - - $r = round($r * 255); - $g = round($g * 255); - $b = round($b * 255); - $a = round(127 - ($a * 127)); - - // Clip values - $r = $r > 255 ? 255 : $r; - $g = $g > 255 ? 255 : $g; - $b = $b > 255 ? 255 : $b; - $a = $a > 127 ? 127 : $a; - - $r = $r < 0 ? 0 : $r; - $g = $g < 0 ? 0 : $g; - $b = $b < 0 ? 0 : $b; - $a = $a < 0 ? 0 : $a; - - $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); - - if (isset($this->_colors[$key])) { - return $this->_colors[$key]; - } - - if ($a != 0) { - $this->_colors[$key] = imagecolorallocatealpha($this->get_image(), $r, $g, $b, $a); - } else { - $this->_colors[$key] = imagecolorallocate($this->get_image(), $r, $g, $b); - } - - return $this->_colors[$key]; - } - - /** - * Scales value up to the current canvas DPI from 72 DPI - * - * @param float $length - * @return int - */ - protected function _upscale($length) - { - return round(($length * $this->dpi) / 72 * $this->_aa_factor); - } - - /** - * Scales value down from the current canvas DPI to 72 DPI - * - * @param float $length - * @return float - */ - protected function _downscale($length) - { - return round(($length / $this->dpi * 72) / $this->_aa_factor); - } - - protected function convertStyle(array $style, int $color, int $width): array - { - $gdStyle = []; - - if (count($style) === 1) { - $style[] = $style[0]; - } - - foreach ($style as $index => $s) { - $d = $this->_upscale($s); - - for ($i = 0; $i < $d; $i++) { - for ($j = 0; $j < $width; $j++) { - $gdStyle[] = $index % 2 === 0 - ? $color - : IMG_COLOR_TRANSPARENT; - } - } - } - - return $gdStyle; - } - - public function line($x1, $y1, $x2, $y2, $color, $width, $style = [], $cap = "butt") - { - // Account for the fact that round and square caps are expected to - // extend outwards - if ($cap === "round" || $cap === "square") { - // Shift line by half width - $w = $width / 2; - $a = $x2 - $x1; - $b = $y2 - $y1; - $c = sqrt($a ** 2 + $b ** 2); - $dx = $a * $w / $c; - $dy = $b * $w / $c; - - $x1 -= $dx; - $x2 -= $dx; - $y1 -= $dy; - $y2 -= $dy; - - // Adapt dash pattern - if (is_array($style)) { - foreach ($style as $index => &$s) { - $s = $index % 2 === 0 ? $s + $width : $s - $width; - } - } - } - - // Scale by the AA factor and DPI - $x1 = $this->_upscale($x1); - $y1 = $this->_upscale($y1); - $x2 = $this->_upscale($x2); - $y2 = $this->_upscale($y2); - $width = $this->_upscale($width); - - $c = $this->_allocate_color($color); - - // Convert the style array if required - if (is_array($style) && count($style) > 0) { - $gd_style = $this->convertStyle($style, $c, $width); - - if (!empty($gd_style)) { - imagesetstyle($this->get_image(), $gd_style); - $c = IMG_COLOR_STYLED; - } - } - - imagesetthickness($this->get_image(), $width); - - imageline($this->get_image(), $x1, $y1, $x2, $y2, $c); - } - - public function arc($x, $y, $r1, $r2, $astart, $aend, $color, $width, $style = [], $cap = "butt") - { - // Account for the fact that round and square caps are expected to - // extend outwards - if ($cap === "round" || $cap === "square") { - // Adapt dash pattern - if (is_array($style)) { - foreach ($style as $index => &$s) { - $s = $index % 2 === 0 ? $s + $width : $s - $width; - } - } - } - - // Scale by the AA factor and DPI - $x = $this->_upscale($x); - $y = $this->_upscale($y); - $w = $this->_upscale($r1 * 2); - $h = $this->_upscale($r2 * 2); - $width = $this->_upscale($width); - - // Adapt angles as imagearc counts clockwise - $start = 360 - $aend; - $end = 360 - $astart; - - $c = $this->_allocate_color($color); - - // Convert the style array if required - if (is_array($style) && count($style) > 0) { - $gd_style = $this->convertStyle($style, $c, $width); - - if (!empty($gd_style)) { - imagesetstyle($this->get_image(), $gd_style); - $c = IMG_COLOR_STYLED; - } - } - - imagesetthickness($this->get_image(), $width); - - imagearc($this->get_image(), $x, $y, $w, $h, $start, $end, $c); - } - - public function rectangle($x1, $y1, $w, $h, $color, $width, $style = [], $cap = "butt") - { - // Account for the fact that round and square caps are expected to - // extend outwards - if ($cap === "round" || $cap === "square") { - // Adapt dash pattern - if (is_array($style)) { - foreach ($style as $index => &$s) { - $s = $index % 2 === 0 ? $s + $width : $s - $width; - } - } - } - - // Scale by the AA factor and DPI - $x1 = $this->_upscale($x1); - $y1 = $this->_upscale($y1); - $w = $this->_upscale($w); - $h = $this->_upscale($h); - $width = $this->_upscale($width); - - $c = $this->_allocate_color($color); - - // Convert the style array if required - if (is_array($style) && count($style) > 0) { - $gd_style = $this->convertStyle($style, $c, $width); - - if (!empty($gd_style)) { - imagesetstyle($this->get_image(), $gd_style); - $c = IMG_COLOR_STYLED; - } - } - - imagesetthickness($this->get_image(), $width); - - if ($c === IMG_COLOR_STYLED) { - imagepolygon($this->get_image(), [ - $x1, $y1, - $x1 + $w, $y1, - $x1 + $w, $y1 + $h, - $x1, $y1 + $h - ], $c); - } else { - imagerectangle($this->get_image(), $x1, $y1, $x1 + $w, $y1 + $h, $c); - } - } - - public function filled_rectangle($x1, $y1, $w, $h, $color) - { - // Scale by the AA factor and DPI - $x1 = $this->_upscale($x1); - $y1 = $this->_upscale($y1); - $w = $this->_upscale($w); - $h = $this->_upscale($h); - - $c = $this->_allocate_color($color); - - imagefilledrectangle($this->get_image(), $x1, $y1, $x1 + $w, $y1 + $h, $c); - } - - public function clipping_rectangle($x1, $y1, $w, $h) - { - // @todo - } - - public function clipping_roundrectangle($x1, $y1, $w, $h, $rTL, $rTR, $rBR, $rBL) - { - // @todo - } - - public function clipping_polygon(array $points): void - { - // @todo - } - - public function clipping_end() - { - // @todo - } - - public function save() - { - $this->get_dompdf()->getOptions()->setDpi(72); - } - - public function restore() - { - $this->get_dompdf()->getOptions()->setDpi($this->dpi); - } - - public function rotate($angle, $x, $y) - { - // @todo - } - - public function skew($angle_x, $angle_y, $x, $y) - { - // @todo - } - - public function scale($s_x, $s_y, $x, $y) - { - // @todo - } - - public function translate($t_x, $t_y) - { - // @todo - } - - public function transform($a, $b, $c, $d, $e, $f) - { - // @todo - } - - public function polygon($points, $color, $width = null, $style = [], $fill = false) - { - // Scale each point by the AA factor and DPI - foreach (array_keys($points) as $i) { - $points[$i] = $this->_upscale($points[$i]); - } - - $width = isset($width) ? $this->_upscale($width) : null; - - $c = $this->_allocate_color($color); - - // Convert the style array if required - if (is_array($style) && count($style) > 0 && isset($width) && !$fill) { - $gd_style = $this->convertStyle($style, $c, $width); - - if (!empty($gd_style)) { - imagesetstyle($this->get_image(), $gd_style); - $c = IMG_COLOR_STYLED; - } - } - - imagesetthickness($this->get_image(), isset($width) ? $width : 0); - - if ($fill) { - imagefilledpolygon($this->get_image(), $points, $c); - } else { - imagepolygon($this->get_image(), $points, $c); - } - } - - public function circle($x, $y, $r, $color, $width = null, $style = [], $fill = false) - { - // Scale by the AA factor and DPI - $x = $this->_upscale($x); - $y = $this->_upscale($y); - $d = $this->_upscale(2 * $r); - $width = isset($width) ? $this->_upscale($width) : null; - - $c = $this->_allocate_color($color); - - // Convert the style array if required - if (is_array($style) && count($style) > 0 && isset($width) && !$fill) { - $gd_style = $this->convertStyle($style, $c, $width); - - if (!empty($gd_style)) { - imagesetstyle($this->get_image(), $gd_style); - $c = IMG_COLOR_STYLED; - } - } - - imagesetthickness($this->get_image(), isset($width) ? $width : 0); - - if ($fill) { - imagefilledellipse($this->get_image(), $x, $y, $d, $d, $c); - } else { - imageellipse($this->get_image(), $x, $y, $d, $d, $c); - } - } - - /** - * @throws \Exception - */ - public function image($img, $x, $y, $w, $h, $resolution = "normal") - { - $img_type = Cache::detect_type($img, $this->get_dompdf()->getHttpContext()); - - if (!$img_type) { - return; - } - - $func_name = "imagecreatefrom$img_type"; - if (!function_exists($func_name)) { - if (!method_exists(Helpers::class, $func_name)) { - throw new \Exception("Function $func_name() not found. Cannot convert $img_type image: $img. Please install the image PHP extension."); - } - $func_name = [Helpers::class, $func_name]; - } - $src = @call_user_func($func_name, $img); - - if (!$src) { - return; // Probably should add to $_dompdf_errors or whatever here - } - - // Scale by the AA factor and DPI - $x = $this->_upscale($x); - $y = $this->_upscale($y); - - $w = $this->_upscale($w); - $h = $this->_upscale($h); - - $img_w = imagesx($src); - $img_h = imagesy($src); - - imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h); - } - - public function text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_spacing = 0.0, $char_spacing = 0.0, $angle = 0.0) - { - // Scale by the AA factor and DPI - $x = $this->_upscale($x); - $y = $this->_upscale($y); - $size = $this->_upscale($size) * self::FONT_SCALE; - - $h = round($this->get_font_height_actual($font, $size)); - $c = $this->_allocate_color($color); - - // imagettftext() converts numeric entities to their respective - // character. Preserve any originally double encoded entities to be - // represented as is. - // eg:   will render rather than its character. - $text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&\1', $text); - - $text = mb_encode_numericentity($text, [0x0080, 0xff, 0, 0xff], 'UTF-8'); - - $font = $this->get_ttf_file($font); - - // FIXME: word spacing - imagettftext($this->get_image(), $size, $angle, $x, $y + $h, $c, $font, $text); - } - - public function javascript($code) - { - // Not implemented - } - - public function add_named_dest($anchorname) - { - // Not implemented - } - - public function add_link($url, $x, $y, $width, $height) - { - // Not implemented - } - - public function add_info(string $label, string $value): void - { - // N/A - } - - public function set_default_view($view, $options = []) - { - // N/A - } - - public function get_text_width($text, $font, $size, $word_spacing = 0.0, $char_spacing = 0.0) - { - $font = $this->get_ttf_file($font); - $size = $this->_upscale($size) * self::FONT_SCALE; - - // imagettfbbox() converts numeric entities to their respective - // character. Preserve any originally double encoded entities to be - // represented as is. - // eg:   will render rather than its character. - $text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&\1', $text); - - $text = mb_encode_numericentity($text, [0x0080, 0xffff, 0, 0xffff], 'UTF-8'); - - // FIXME: word spacing - list($x1, , $x2) = imagettfbbox($size, 0, $font, $text); - - // Add additional 1pt to prevent text overflow issues - return $this->_downscale($x2 - $x1) + 1; - } - - /** - * @param string|null $font - * @return string - */ - public function get_ttf_file($font) - { - if ($font === null) { - $font = ""; - } - - if ( stripos($font, ".ttf") === false ) { - $font .= ".ttf"; - } - - if (!file_exists($font)) { - $font_metrics = $this->_dompdf->getFontMetrics(); - $font = $font_metrics->getFont($this->_dompdf->getOptions()->getDefaultFont()) . ".ttf"; - if (!file_exists($font)) { - if (strpos($font, "mono")) { - $font = $font_metrics->getFont("DejaVu Mono") . ".ttf"; - } elseif (strpos($font, "sans") !== false) { - $font = $font_metrics->getFont("DejaVu Sans") . ".ttf"; - } elseif (strpos($font, "serif")) { - $font = $font_metrics->getFont("DejaVu Serif") . ".ttf"; - } else { - $font = $font_metrics->getFont("DejaVu Sans") . ".ttf"; - } - } - } - - return $font; - } - - public function get_font_height($font, $size) - { - $size = $this->_upscale($size) * self::FONT_SCALE; - - $height = $this->get_font_height_actual($font, $size); - - return $this->_downscale($height); - } - - /** - * @param string $font - * @param float $size - * - * @return float - */ - protected function get_font_height_actual($font, $size) - { - $font = $this->get_ttf_file($font); - $ratio = $this->_dompdf->getOptions()->getFontHeightRatio(); - - // FIXME: word spacing - list(, $y2, , , , $y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps - return ($y2 - $y1) * $ratio; - } - - public function get_font_baseline($font, $size) - { - $ratio = $this->_dompdf->getOptions()->getFontHeightRatio(); - return $this->get_font_height($font, $size) / $ratio; - } - - public function new_page() - { - $this->_page_number++; - $this->_page_count++; - - $this->_img = imagecreatetruecolor($this->_actual_width, $this->_actual_height); - - $this->_bg_color = $this->_allocate_color($this->_bg_color_array); - imagealphablending($this->_img, true); - imagesavealpha($this->_img, true); - imagefill($this->_img, 0, 0, $this->_bg_color); - - $this->_imgs[] = $this->_img; - } - - public function open_object() - { - // N/A - } - - public function close_object() - { - // N/A - } - - public function add_object() - { - // N/A - } - - public function page_script($callback): void - { - // N/A - } - - public function page_text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_space = 0.0, $char_space = 0.0, $angle = 0.0) - { - // N/A - } - - public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = []) - { - // N/A - } - - /** - * Streams the image to the client. - * - * @param string $filename The filename to present to the client. - * @param array $options Associative array: 'type' => jpeg|jpg|png; 'quality' => 0 - 100 (JPEG only); - * 'page' => Number of the page to output (defaults to the first); 'Attachment': 1 or 0 (default 1). - */ - public function stream($filename, $options = []) - { - if (headers_sent()) { - die("Unable to stream image: headers already sent"); - } - - if (!isset($options["type"])) $options["type"] = "png"; - if (!isset($options["Attachment"])) $options["Attachment"] = true; - $type = strtolower($options["type"]); - - switch ($type) { - case "jpg": - case "jpeg": - $contentType = "image/jpeg"; - $extension = ".jpg"; - break; - case "png": - default: - $contentType = "image/png"; - $extension = ".png"; - break; - } - - header("Cache-Control: private"); - header("Content-Type: $contentType"); - - $filename = str_replace(["\n", "'"], "", basename($filename, ".$type")) . $extension; - $attachment = $options["Attachment"] ? "attachment" : "inline"; - header(Helpers::buildContentDispositionHeader($attachment, $filename)); - - $this->_output($options); - flush(); - } - - /** - * Returns the image as a string. - * - * @param array $options Associative array: 'type' => jpeg|jpg|png; 'quality' => 0 - 100 (JPEG only); - * 'page' => Number of the page to output (defaults to the first). - * @return string - */ - public function output($options = []) - { - ob_start(); - - $this->_output($options); - - return ob_get_clean(); - } - - /** - * Outputs the image stream directly. - * - * @param array $options Associative array: 'type' => jpeg|jpg|png; 'quality' => 0 - 100 (JPEG only); - * 'page' => Number of the page to output (defaults to the first). - */ - protected function _output($options = []) - { - if (!isset($options["type"])) $options["type"] = "png"; - if (!isset($options["page"])) $options["page"] = 1; - $type = strtolower($options["type"]); - - if (isset($this->_imgs[$options["page"] - 1])) { - $img = $this->_imgs[$options["page"] - 1]; - } else { - $img = $this->_imgs[0]; - } - - // Perform any antialiasing - if ($this->_aa_factor != 1) { - $dst_w = round($this->_actual_width / $this->_aa_factor); - $dst_h = round($this->_actual_height / $this->_aa_factor); - $dst = imagecreatetruecolor($dst_w, $dst_h); - imagecopyresampled($dst, $img, 0, 0, 0, 0, - $dst_w, $dst_h, - $this->_actual_width, $this->_actual_height); - } else { - $dst = $img; - } - - switch ($type) { - case "jpg": - case "jpeg": - if (!isset($options["quality"])) { - $options["quality"] = 75; - } - - imagejpeg($dst, null, $options["quality"]); - break; - case "png": - default: - imagepng($dst); - break; - } - - if ($this->_aa_factor != 1) { - imagedestroy($dst); - } - } -} diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/PDFLib.php b/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/PDFLib.php deleted file mode 100644 index ee5ae8dd2..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Adapter/PDFLib.php +++ /dev/null @@ -1,1450 +0,0 @@ - "Courier", - "courier-bold" => "Courier-Bold", - "courier-oblique" => "Courier-Oblique", - "courier-boldoblique" => "Courier-BoldOblique", - "helvetica" => "Helvetica", - "helvetica-bold" => "Helvetica-Bold", - "helvetica-oblique" => "Helvetica-Oblique", - "helvetica-boldoblique" => "Helvetica-BoldOblique", - "times" => "Times-Roman", - "times-roman" => "Times-Roman", - "times-bold" => "Times-Bold", - "times-italic" => "Times-Italic", - "times-bolditalic" => "Times-BoldItalic", - "symbol" => "Symbol", - "zapfdinbats" => "ZapfDingbats", - "zapfdingbats" => "ZapfDingbats", - ]; - - /** - * @var \Dompdf\Dompdf - */ - protected $_dompdf; - - /** - * Instance of PDFLib class - * - * @var \PDFLib - */ - protected $_pdf; - - /** - * Name of temporary file used for PDFs created on disk - * - * @var string - */ - protected $_file; - - /** - * PDF width, in points - * - * @var float - */ - protected $_width; - - /** - * PDF height, in points - * - * @var float - */ - protected $_height; - - /** - * Last fill color used - * - * @var array - */ - protected $_last_fill_color; - - /** - * Last stroke color used - * - * @var array - */ - protected $_last_stroke_color; - - /** - * The current opacity level - * - * @var float|null - */ - protected $_current_opacity; - - /** - * Cache of image handles - * - * @var array - */ - protected $_imgs; - - /** - * Cache of font handles - * - * @var array - */ - protected $_fonts; - - /** - * Cache of fontFile checks - * - * @var array - */ - protected $_fontsFiles; - - /** - * List of objects (templates) to add to multiple pages - * - * @var array - */ - protected $_objs; - - /** - * List of gstate objects created for this PDF (for reuse) - * - * @var array - */ - protected $_gstates = []; - - /** - * Current page number - * - * @var int - */ - protected $_page_number; - - /** - * Total number of pages - * - * @var int - */ - protected $_page_count; - - /** - * Array of pages for accessing after rendering is initially complete - * - * @var array - */ - protected $_pages; - - public function __construct($paper = "letter", $orientation = "portrait", ?Dompdf $dompdf = null) - { - if (is_array($paper)) { - $size = array_map("floatval", $paper); - } else { - $paper = strtolower($paper); - $size = self::$PAPER_SIZES[$paper] ?? self::$PAPER_SIZES["letter"]; - } - - if (strtolower($orientation) === "landscape") { - [$size[2], $size[3]] = [$size[3], $size[2]]; - } - - $this->_width = $size[2] - $size[0]; - $this->_height = $size[3] - $size[1]; - - if ($dompdf === null) { - $this->_dompdf = new Dompdf(); - } else { - $this->_dompdf = $dompdf; - } - - $this->_pdf = new \PDFLib(); - - $license = $dompdf->getOptions()->getPdflibLicense(); - if (strlen($license) > 0) { - $this->setPDFLibParameter("license", $license); - } - - if ($this->getPDFLibMajorVersion() < 10) { - $this->setPDFLibParameter("textformat", "utf8"); - } - if ($this->getPDFLibMajorVersion() >= 7) { - $this->setPDFLibParameter("errorpolicy", "return"); - // $this->_pdf->set_option('logging={filename=' . \APP_PATH . '/logs/pdflib.log classes={api=1 warning=2}}'); - // $this->_pdf->set_option('errorpolicy=exception'); - } else { - $this->setPDFLibParameter("fontwarning", "false"); - } - - $searchPath = $this->_dompdf->getOptions()->getFontDir(); - if (empty($searchPath) === false) { - $this->_pdf->set_option('searchpath={' . $searchPath . '}'); - } - - // fetch PDFLib version information for the producer field - $this->_pdf->set_info("Producer Addendum", sprintf("%s + PDFLib %s", $dompdf->version, $this->getPDFLibMajorVersion())); - - // Silence pedantic warnings about missing TZ settings - $tz = @date_default_timezone_get(); - date_default_timezone_set("UTC"); - $this->_pdf->set_info("Date", date("Y-m-d")); - date_default_timezone_set($tz); - - if (self::$IN_MEMORY) { - $this->_pdf->begin_document("", ""); - } else { - $tmp_dir = $this->_dompdf->getOptions()->getTempDir(); - $tmp_name = @tempnam($tmp_dir, "libdompdf_pdf_"); - @unlink($tmp_name); - $this->_file = "$tmp_name.pdf"; - $this->_pdf->begin_document($this->_file, ""); - } - - $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); - - $this->_page_number = $this->_page_count = 1; - - $this->_imgs = []; - $this->_fonts = []; - $this->_objs = []; - } - - function get_dompdf() - { - return $this->_dompdf; - } - - /** - * Close the pdf - */ - protected function _close() - { - $this->_place_objects(); - - // Close all pages - $this->_pdf->suspend_page(""); - for ($p = 1; $p <= $this->_page_count; $p++) { - $this->_pdf->resume_page("pagenumber=$p"); - $this->_pdf->end_page_ext(""); - } - - $this->_pdf->end_document(""); - } - - - /** - * Returns the PDFLib instance - * - * @return PDFLib - */ - public function get_pdflib() - { - return $this->_pdf; - } - - public function add_info(string $label, string $value): void - { - $this->_pdf->set_info($label, $value); - } - - /** - * Opens a new 'object' (template in PDFLib-speak) - * - * While an object is open, all drawing actions are recorded to the - * object instead of being drawn on the current page. Objects can - * be added later to a specific page or to several pages. - * - * The return value is an integer ID for the new object. - * - * @see PDFLib::close_object() - * @see PDFLib::add_object() - * - * @return int - */ - public function open_object() - { - $this->_pdf->suspend_page(""); - if ($this->getPDFLibMajorVersion() >= 7) { - $ret = $this->_pdf->begin_template_ext($this->_width, $this->_height, null); - } else { - $ret = $this->_pdf->begin_template($this->_width, $this->_height); - } - $this->_pdf->save(); - $this->_objs[$ret] = ["start_page" => $this->_page_number]; - - return $ret; - } - - /** - * Reopen an existing object (NOT IMPLEMENTED) - * PDFLib does not seem to support reopening templates. - * - * @param int $object the ID of a previously opened object - * - * @throws Exception - * @return void - */ - public function reopen_object($object) - { - throw new Exception("PDFLib does not support reopening objects."); - } - - /** - * Close the current template - * - * @see PDFLib::open_object() - */ - public function close_object() - { - $this->_pdf->restore(); - if ($this->getPDFLibMajorVersion() >= 7) { - $this->_pdf->end_template_ext($this->_width, $this->_height); - } else { - $this->_pdf->end_template(); - } - $this->_pdf->resume_page("pagenumber=" . $this->_page_number); - } - - /** - * Adds the specified object to the document - * - * $where can be one of: - * - 'add' add to current page only - * - 'all' add to every page from the current one onwards - * - 'odd' add to all odd numbered pages from now on - * - 'even' add to all even numbered pages from now on - * - 'next' add the object to the next page only - * - 'nextodd' add to all odd numbered pages from the next one - * - 'nexteven' add to all even numbered pages from the next one - * - * @param int $object the object handle returned by open_object() - * @param string $where - */ - public function add_object($object, $where = 'all') - { - - if (mb_strpos($where, "next") !== false) { - $this->_objs[$object]["start_page"]++; - $where = str_replace("next", "", $where); - if ($where == "") { - $where = "add"; - } - } - - $this->_objs[$object]["where"] = $where; - } - - /** - * Stops the specified template from appearing in the document. - * - * The object will stop being displayed on the page following the - * current one. - * - * @param int $object - */ - public function stop_object($object) - { - - if (!isset($this->_objs[$object])) { - return; - } - - $start = $this->_objs[$object]["start_page"]; - $where = $this->_objs[$object]["where"]; - - // Place the object on this page if required - if ($this->_page_number >= $start && - (($this->_page_number % 2 == 0 && $where === "even") || - ($this->_page_number % 2 == 1 && $where === "odd") || - ($where === "all")) - ) { - $this->_pdf->fit_image($object, 0, 0, ""); - } - - $this->_objs[$object] = null; - unset($this->_objs[$object]); - } - - /** - * Add all active objects to the current page - */ - protected function _place_objects() - { - - foreach ($this->_objs as $obj => $props) { - $start = $props["start_page"]; - $where = $props["where"]; - - // Place the object on this page if required - if ($this->_page_number >= $start && - (($this->_page_number % 2 == 0 && $where === "even") || - ($this->_page_number % 2 == 1 && $where === "odd") || - ($where === "all")) - ) { - $this->_pdf->fit_image($obj, 0, 0, ""); - } - } - } - - public function get_width() - { - return $this->_width; - } - - public function get_height() - { - return $this->_height; - } - - public function get_page_number() - { - return $this->_page_number; - } - - public function get_page_count() - { - return $this->_page_count; - } - - /** - * @param $num - */ - public function set_page_number($num) - { - $this->_page_number = (int)$num; - } - - public function set_page_count($count) - { - $this->_page_count = (int)$count; - } - - /** - * Sets the line style - * - * @param float $width - * @param string $cap - * @param string $join - * @param array $dash - */ - protected function _set_line_style($width, $cap, $join, $dash) - { - if (!is_array($dash)) { - $dash = []; - } - - // Work around PDFLib limitation with 0 dash length: - // Value 0 for option 'dasharray' is too small (minimum 1.5e-05) - foreach ($dash as &$d) { - if ($d == 0) { - $d = 1.5e-5; - } - } - - if (count($dash) === 1) { - $dash[] = $dash[0]; - } - - if ($this->getPDFLibMajorVersion() >= 9) { - if (count($dash) > 1) { - $this->_pdf->set_graphics_option("dasharray={" . implode(" ", $dash) . "}"); - } else { - $this->_pdf->set_graphics_option("dasharray=none"); - } - } else { - if (count($dash) > 1) { - $this->_pdf->setdashpattern("dasharray={" . implode(" ", $dash) . "}"); - } else { - $this->_pdf->setdash(0, 0); - } - } - - switch ($join) { - case "miter": - if ($this->getPDFLibMajorVersion() >= 9) { - $this->_pdf->set_graphics_option('linejoin=0'); - } else { - $this->_pdf->setlinejoin(0); - } - break; - - case "round": - if ($this->getPDFLibMajorVersion() >= 9) { - $this->_pdf->set_graphics_option('linejoin=1'); - } else { - $this->_pdf->setlinejoin(1); - } - break; - - case "bevel": - if ($this->getPDFLibMajorVersion() >= 9) { - $this->_pdf->set_graphics_option('linejoin=2'); - } else { - $this->_pdf->setlinejoin(2); - } - break; - - default: - break; - } - - switch ($cap) { - case "butt": - if ($this->getPDFLibMajorVersion() >= 9) { - $this->_pdf->set_graphics_option('linecap=0'); - } else { - $this->_pdf->setlinecap(0); - } - break; - - case "round": - if ($this->getPDFLibMajorVersion() >= 9) { - $this->_pdf->set_graphics_option('linecap=1'); - } else { - $this->_pdf->setlinecap(1); - } - break; - - case "square": - if ($this->getPDFLibMajorVersion() >= 9) { - $this->_pdf->set_graphics_option('linecap=2'); - } else { - $this->_pdf->setlinecap(2); - } - break; - - default: - break; - } - - $this->_pdf->setlinewidth($width); - } - - /** - * Sets the line color - * - * @param array $color array(r,g,b) - */ - protected function _set_stroke_color($color) - { - // TODO: we should check the current PDF stroke color - // instead of the cached value - if ($this->_last_stroke_color == $color) { - // FIXME: do nothing, this optimization is broken by the - // stroke being set as a side effect of other operations - //return; - } - - $alpha = isset($color["alpha"]) ? $color["alpha"] : 1; - if (isset($this->_current_opacity)) { - $alpha *= $this->_current_opacity; - } - - $this->_last_stroke_color = $color; - - if (isset($color[3])) { - $type = "cmyk"; - list($c1, $c2, $c3, $c4) = [$color[0], $color[1], $color[2], $color[3]]; - } elseif (isset($color[2])) { - $type = "rgb"; - list($c1, $c2, $c3, $c4) = [$color[0], $color[1], $color[2], null]; - } else { - $type = "gray"; - list($c1, $c2, $c3, $c4) = [$color[0], $color[1], null, null]; - } - - $this->_set_stroke_opacity($alpha, "Normal"); - $this->_pdf->setcolor("stroke", $type, $c1, $c2, $c3, $c4); - } - - /** - * Sets the fill color - * - * @param array $color array(r,g,b) - */ - protected function _set_fill_color($color) - { - // TODO: we should check the current PDF fill color - // instead of the cached value - if ($this->_last_fill_color == $color) { - // FIXME: do nothing, this optimization is broken by the - // fill being set as a side effect of other operations - //return; - } - - $alpha = isset($color["alpha"]) ? $color["alpha"] : 1; - if (isset($this->_current_opacity)) { - $alpha *= $this->_current_opacity; - } - - $this->_last_fill_color = $color; - - if (isset($color[3])) { - $type = "cmyk"; - list($c1, $c2, $c3, $c4) = [$color[0], $color[1], $color[2], $color[3]]; - } elseif (isset($color[2])) { - $type = "rgb"; - list($c1, $c2, $c3, $c4) = [$color[0], $color[1], $color[2], null]; - } else { - $type = "gray"; - list($c1, $c2, $c3, $c4) = [$color[0], $color[1], null, null]; - } - - $this->_set_fill_opacity($alpha, "Normal"); - $this->_pdf->setcolor("fill", $type, $c1, $c2, $c3, $c4); - } - - /** - * Sets the fill opacity - * - * @param float $opacity - * @param string $mode - */ - public function _set_fill_opacity($opacity, $mode = "Normal") - { - if ($mode === "Normal" && isset($opacity)) { - $this->_set_gstate("opacityfill=$opacity"); - } - } - - /** - * Sets the stroke opacity - * - * @param float $opacity - * @param string $mode - */ - public function _set_stroke_opacity($opacity, $mode = "Normal") - { - if ($mode === "Normal" && isset($opacity)) { - $this->_set_gstate("opacitystroke=$opacity"); - } - } - - public function set_opacity(float $opacity, string $mode = "Normal"): void - { - if ($mode === "Normal") { - $this->_set_gstate("opacityfill=$opacity opacitystroke=$opacity"); - $this->_current_opacity = $opacity; - } - } - - /** - * Sets the gstate - * - * @param $gstate_options - * @return int - */ - public function _set_gstate($gstate_options) - { - if (($gstate = array_search($gstate_options, $this->_gstates)) === false) { - $gstate = $this->_pdf->create_gstate($gstate_options); - $this->_gstates[$gstate] = $gstate_options; - } - - return $this->_pdf->set_gstate($gstate); - } - - public function set_default_view($view, $options = []) - { - // TODO - // http://www.pdflib.com/fileadmin/pdflib/pdf/manuals/PDFlib-8.0.2-API-reference.pdf - /** - * fitheight Fit the page height to the window, with the x coordinate left at the left edge of the window. - * fitrect Fit the rectangle specified by left, bottom, right, and top to the window. - * fitvisible Fit the visible contents of the page (the ArtBox) to the window. - * fitvisibleheight Fit the visible contents of the page to the window with the x coordinate left at the left edge of the window. - * fitvisiblewidth Fit the visible contents of the page to the window with the y coordinate top at the top edge of the window. - * fitwidth Fit the page width to the window, with the y coordinate top at the top edge of the window. - * fitwindow Fit the complete page to the window. - * fixed - */ - //$this->setPDFLibParameter("openaction", $view); - } - - /** - * Loads a specific font and stores the corresponding descriptor. - * - * @param string $font - * @param string $encoding - * @param string $options - * - * @return int the font descriptor for the font - */ - protected function _load_font($font, $encoding = null, $options = "") - { - // Fix for PDFLibs case-sensitive font names - $baseFont = basename($font); - $isNativeFont = false; - if (isset(self::$nativeFontsTpPDFLib[$baseFont])) { - $font = self::$nativeFontsTpPDFLib[$baseFont]; - $isNativeFont = true; - } - - // Check if the font is a native PDF font - // Embed non-native fonts - $test = strtolower($baseFont); - if (in_array($test, DOMPDF::$nativeFonts)) { - $font = basename($font); - } else { - // Embed non-native fonts - $options .= " embedding=true"; - } - - $options .= " autosubsetting=" . ($this->_dompdf->getOptions()->getIsFontSubsettingEnabled() === false ? "false" : "true"); - - if (is_null($encoding)) { - // Unicode encoding is only available for the commerical - // version of PDFlib and not PDFlib-Lite - if (strlen($this->_dompdf->getOptions()->getPdflibLicense()) > 0) { - $encoding = "unicode"; - } else { - $encoding = "auto"; - } - } - - $key = "$font:$encoding:$options"; - if (isset($this->_fonts[$key])) { - return $this->_fonts[$key]; - } - - // Native fonts are build in, just load it - if ($isNativeFont) { - $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); - - return $this->_fonts[$key]; - } - - $fontOutline = $this->getPDFLibParameter("FontOutline", 1); - if ($fontOutline === "" || $fontOutline <= 0) { - $families = $this->_dompdf->getFontMetrics()->getFontFamilies(); - foreach ($families as $files) { - foreach ($files as $file) { - $face = basename($file); - $afm = null; - - if (isset($this->_fontsFiles[$face])) { - continue; - } - - // Prefer ttfs to afms - if (file_exists("$file.ttf")) { - $outline = "$file.ttf"; - } elseif (file_exists("$file.TTF")) { - $outline = "$file.TTF"; - } elseif (file_exists("$file.pfb")) { - $outline = "$file.pfb"; - if (file_exists("$file.afm")) { - $afm = "$file.afm"; - } - } elseif (file_exists("$file.PFB")) { - $outline = "$file.PFB"; - if (file_exists("$file.AFM")) { - $afm = "$file.AFM"; - } - } else { - continue; - } - - $this->_fontsFiles[$face] = true; - - if ($this->getPDFLibMajorVersion() >= 9) { - $this->setPDFLibParameter("FontOutline", '{' . "$face=$outline" . '}'); - } else { - $this->setPDFLibParameter("FontOutline", "\{$face\}=\{$outline\}"); - } - - if (is_null($afm)) { - continue; - } - if ($this->getPDFLibMajorVersion() >= 9) { - $this->setPDFLibParameter("FontAFM", '{' . "$face=$afm" . '}'); - } else { - $this->setPDFLibParameter("FontAFM", "\{$face\}=\{$afm\}"); - } - } - } - } - - $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); - - return $this->_fonts[$key]; - } - - /** - * Remaps y coords from 4th to 1st quadrant - * - * @param float $y - * @return float - */ - protected function y($y) - { - return $this->_height - $y; - } - - public function line($x1, $y1, $x2, $y2, $color, $width, $style = [], $cap = "butt") - { - $this->_set_line_style($width, $cap, "", $style); - $this->_set_stroke_color($color); - - $y1 = $this->y($y1); - $y2 = $this->y($y2); - - $this->_pdf->moveto($x1, $y1); - $this->_pdf->lineto($x2, $y2); - $this->_pdf->stroke(); - - $this->_set_stroke_opacity($this->_current_opacity, "Normal"); - } - - public function arc($x, $y, $r1, $r2, $astart, $aend, $color, $width, $style = [], $cap = "butt") - { - $this->_set_line_style($width, $cap, "", $style); - $this->_set_stroke_color($color); - - $y = $this->y($y); - - $this->_pdf->arc($x, $y, $r1, $astart, $aend); - $this->_pdf->stroke(); - - $this->_set_stroke_opacity($this->_current_opacity, "Normal"); - } - - public function rectangle($x1, $y1, $w, $h, $color, $width, $style = [], $cap = "butt") - { - $this->_set_stroke_color($color); - $this->_set_line_style($width, $cap, "", $style); - - $y1 = $this->y($y1) - $h; - - $this->_pdf->rect($x1, $y1, $w, $h); - $this->_pdf->stroke(); - - $this->_set_stroke_opacity($this->_current_opacity, "Normal"); - } - - public function filled_rectangle($x1, $y1, $w, $h, $color) - { - $this->_set_fill_color($color); - - $y1 = $this->y($y1) - $h; - - $this->_pdf->rect(floatval($x1), floatval($y1), floatval($w), floatval($h)); - $this->_pdf->fill(); - - $this->_set_fill_opacity($this->_current_opacity, "Normal"); - } - - public function clipping_rectangle($x1, $y1, $w, $h) - { - $this->_pdf->save(); - - $y1 = $this->y($y1) - $h; - - $this->_pdf->rect(floatval($x1), floatval($y1), floatval($w), floatval($h)); - $this->_pdf->clip(); - } - - public function clipping_roundrectangle($x1, $y1, $w, $h, $rTL, $rTR, $rBR, $rBL) - { - if ($this->getPDFLibMajorVersion() < 9) { - //TODO: add PDFLib7 support - $this->clipping_rectangle($x1, $y1, $w, $h); - return; - } - - $this->_pdf->save(); - - // we use 0,0 for the base coordinates for the path points - // since we're drawing the path at the $x1,$y1 coordinates - - $path = 0; - //start: left edge, top end - $path = $this->_pdf->add_path_point($path, 0, 0 - $rTL + $h, "move", ""); - // line: left edge, bottom end - $path = $this->_pdf->add_path_point($path, 0, 0 + $rBL, "line", ""); - // curve: bottom-left corner - if ($rBL > 0) { - $path = $this->_pdf->add_path_point($path, 0 + $rBL, 0, "elliptical", "radius=$rBL clockwise=false"); - } - // line: bottom edge, left end - $path = $this->_pdf->add_path_point($path, 0 - $rBR + $w, 0, "line", ""); - // curve: bottom-right corner - if ($rBR > 0) { - $path = $this->_pdf->add_path_point($path, 0 + $w, 0 + $rBR, "elliptical", "radius=$rBR clockwise=false"); - } - // line: right edge, top end - $path = $this->_pdf->add_path_point($path, 0 + $w, 0 - $rTR + $h, "line", ""); - // curve: top-right corner - if ($rTR > 0) { - $path = $this->_pdf->add_path_point($path, 0 - $rTR + $w, 0 + $h, "elliptical", "radius=$rTR clockwise=false"); - } - // line: top edge, left end - $path = $this->_pdf->add_path_point($path, 0 + $rTL, 0 + $h, "line", ""); - // curve: top-left corner - if ($rTL > 0) { - $path = $this->_pdf->add_path_point($path, 0, 0 - $rTL + $h, "elliptical", "radius=$rTL clockwise=false"); - } - $this->_pdf->draw_path($path, $x1, $this->_height-$y1-$h, "clip=true"); - } - - public function clipping_polygon(array $points): void - { - $this->_pdf->save(); - - $y = $this->y(array_pop($points)); - $x = array_pop($points); - $this->_pdf->moveto($x, $y); - - while (count($points) > 1) { - $y = $this->y(array_pop($points)); - $x = array_pop($points); - $this->_pdf->lineto($x, $y); - } - - $this->_pdf->closepath(); - $this->_pdf->clip(); - } - - public function clipping_end() - { - $this->_pdf->restore(); - } - - public function save() - { - $this->_pdf->save(); - } - - function restore() - { - $this->_pdf->restore(); - } - - public function rotate($angle, $x, $y) - { - $pdf = $this->_pdf; - $pdf->translate($x, $this->_height - $y); - $pdf->rotate(-$angle); - $pdf->translate(-$x, -$this->_height + $y); - } - - public function skew($angle_x, $angle_y, $x, $y) - { - $pdf = $this->_pdf; - $pdf->translate($x, $this->_height - $y); - $pdf->skew($angle_y, $angle_x); // Needs to be inverted - $pdf->translate(-$x, -$this->_height + $y); - } - - public function scale($s_x, $s_y, $x, $y) - { - $pdf = $this->_pdf; - $pdf->translate($x, $this->_height - $y); - $pdf->scale($s_x, $s_y); - $pdf->translate(-$x, -$this->_height + $y); - } - - public function translate($t_x, $t_y) - { - $this->_pdf->translate($t_x, -$t_y); - } - - public function transform($a, $b, $c, $d, $e, $f) - { - $this->_pdf->concat($a, $b, $c, $d, $e, $f); - } - - public function polygon($points, $color, $width = null, $style = [], $fill = false) - { - $this->_set_fill_color($color); - $this->_set_stroke_color($color); - - if (!$fill && isset($width)) { - $this->_set_line_style($width, "square", "miter", $style); - } - - $y = $this->y(array_pop($points)); - $x = array_pop($points); - $this->_pdf->moveto($x, $y); - - while (count($points) > 1) { - $y = $this->y(array_pop($points)); - $x = array_pop($points); - $this->_pdf->lineto($x, $y); - } - - if ($fill) { - $this->_pdf->fill(); - } else { - $this->_pdf->closepath_stroke(); - } - - $this->_set_fill_opacity($this->_current_opacity, "Normal"); - $this->_set_stroke_opacity($this->_current_opacity, "Normal"); - } - - public function circle($x, $y, $r, $color, $width = null, $style = [], $fill = false) - { - $this->_set_fill_color($color); - $this->_set_stroke_color($color); - - if (!$fill && isset($width)) { - $this->_set_line_style($width, "round", "round", $style); - } - - $y = $this->y($y); - - $this->_pdf->circle($x, $y, $r); - - if ($fill) { - $this->_pdf->fill(); - } else { - $this->_pdf->stroke(); - } - - $this->_set_fill_opacity($this->_current_opacity, "Normal"); - $this->_set_stroke_opacity($this->_current_opacity, "Normal"); - } - - public function image($img, $x, $y, $w, $h, $resolution = "normal") - { - $w = (int)$w; - $h = (int)$h; - - $img_type = Cache::detect_type($img, $this->get_dompdf()->getHttpContext()); - - // Strip file:// prefix - if (substr($img, 0, 7) === "file://") { - $img = substr($img, 7); - } - - if (!isset($this->_imgs[$img])) { - if (strtolower($img_type) === "svg") { - //FIXME: PDFLib loads SVG but returns error message "Function must not be called in 'page' scope" - $image_load_response = $this->_pdf->load_graphics($img_type, $img, ""); - } else { - $image_load_response = $this->_pdf->load_image($img_type, $img, ""); - } - if ($image_load_response === 0) { - //TODO: should do something with the error message - $error = $this->_pdf->get_errmsg(); - return; - } - $this->_imgs[$img] = $image_load_response; - } - - $img = $this->_imgs[$img]; - - $y = $this->y($y) - $h; - if (strtolower($img_type) === "svg") { - $this->_pdf->fit_graphics($img, $x, $y, 'boxsize={' . "$w $h" . '} fitmethod=entire'); - } else { - $this->_pdf->fit_image($img, $x, $y, 'boxsize={' . "$w $h" . '} fitmethod=entire'); - } - } - - public function text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_spacing = 0, $char_spacing = 0, $angle = 0) - { - if ($size == 0) { - return; - } - - $fh = $this->_load_font($font); - - $this->_pdf->setfont($fh, $size); - $this->_set_fill_color($color); - - $y = $this->y($y) - $this->get_font_height($font, $size); - - $word_spacing = (float)$word_spacing; - $char_spacing = (float)$char_spacing; - $angle = -(float)$angle; - - $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$word_spacing charspacing=$char_spacing "); - - $this->_set_fill_opacity($this->_current_opacity, "Normal"); - } - - public function javascript($code) - { - if (strlen($this->_dompdf->getOptions()->getPdflibLicense()) > 0) { - $this->_pdf->create_action("JavaScript", $code); - } - } - - public function add_named_dest($anchorname) - { - $this->_pdf->add_nameddest($anchorname, ""); - } - - public function add_link($url, $x, $y, $width, $height) - { - $y = $this->y($y) - $height; - if (strpos($url, '#') === 0) { - // Local link - $name = substr($url, 1); - if ($name) { - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', - "contents={$url} destname=" . substr($url, 1) . " linewidth=0"); - } - } else { - //TODO: PDFLib::create_action does not permit non-HTTP links for URI actions - $action = $this->_pdf->create_action("URI", "url={{$url}}"); - // add the annotation only if the action was created - if ($action !== 0) { - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={{$url}} action={activate=$action} linewidth=0"); - } - } - } - - public function get_text_width($text, $font, $size, $word_spacing = 0.0, $letter_spacing = 0.0) - { - if ($size == 0) { - return 0.0; - } - - $fh = $this->_load_font($font); - - // Determine the additional width due to extra spacing - $num_spaces = mb_substr_count($text, " "); - $delta = $word_spacing * $num_spaces; - - if ($letter_spacing) { - $num_chars = mb_strlen($text); - $delta += $num_chars * $letter_spacing; - } - - return $this->_pdf->stringwidth($text, $fh, $size) + $delta; - } - - public function get_font_height($font, $size) - { - if ($size == 0) { - return 0.0; - } - - $fh = $this->_load_font($font); - - $this->_pdf->setfont($fh, $size); - - $asc = $this->_pdf->info_font($fh, "ascender", "fontsize=$size"); - $desc = $this->_pdf->info_font($fh, "descender", "fontsize=$size"); - - // $desc is usually < 0, - $ratio = $this->_dompdf->getOptions()->getFontHeightRatio(); - - return (abs($asc) + abs($desc)) * $ratio; - } - - public function get_font_baseline($font, $size) - { - $ratio = $this->_dompdf->getOptions()->getFontHeightRatio(); - - return $this->get_font_height($font, $size) / $ratio * 1.1; - } - - /** - * Processes a callback or script on every page. - * - * The callback function receives the four parameters `int $pageNumber`, - * `int $pageCount`, `Canvas $canvas`, and `FontMetrics $fontMetrics`, in - * that order. If a script is passed as string, the variables `$PAGE_NUM`, - * `$PAGE_COUNT`, `$pdf`, and `$fontMetrics` are available instead. Passing - * a script as string is deprecated and will be removed in a future version. - * - * This function can be used to add page numbers to all pages after the - * first one, for example. - * - * @param callable|string $callback The callback function or PHP script to process on every page - */ - public function page_script($callback): void - { - if (is_string($callback)) { - $this->processPageScript(function ( - int $PAGE_NUM, - int $PAGE_COUNT, - self $pdf, - FontMetrics $fontMetrics - ) use ($callback) { - eval($callback); - }); - return; - } - - $this->processPageScript($callback); - } - - public function page_text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_space = 0.0, $char_space = 0.0, $angle = 0.0) - { - $this->processPageScript(function (int $pageNumber, int $pageCount) use ($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle) { - $text = str_replace( - ["{PAGE_NUM}", "{PAGE_COUNT}"], - [$pageNumber, $pageCount], - $text - ); - $this->text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle); - }); - } - - public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = []) - { - $this->processPageScript(function () use ($x1, $y1, $x2, $y2, $color, $width, $style) { - $this->line($x1, $y1, $x2, $y2, $color, $width, $style); - }); - } - - public function new_page() - { - // Add objects to the current page - $this->_place_objects(); - - $this->_pdf->suspend_page(""); - $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); - $this->_page_number = ++$this->_page_count; - } - - protected function processPageScript(callable $callback): void - { - $this->_pdf->suspend_page(""); - - for ($p = 1; $p <= $this->_page_count; $p++) { - $this->_pdf->resume_page("pagenumber=$p"); - - $fontMetrics = $this->_dompdf->getFontMetrics(); - $callback($p, $this->_page_count, $this, $fontMetrics); - - $this->_pdf->suspend_page(""); - } - - $this->_pdf->resume_page("pagenumber=" . $this->_page_number); - } - - /** - * @throws Exception - */ - public function stream($filename = "document.pdf", $options = []) - { - if (headers_sent()) { - die("Unable to stream pdf: headers already sent"); - } - - if (!isset($options["compress"])) { - $options["compress"] = true; - } - if (!isset($options["Attachment"])) { - $options["Attachment"] = true; - } - - if ($options["compress"]) { - $this->setPDFLibValue("compress", 6); - } else { - $this->setPDFLibValue("compress", 0); - } - - $this->_close(); - - $data = ""; - - if (self::$IN_MEMORY) { - $data = $this->_pdf->get_buffer(); - $size = mb_strlen($data, "8bit"); - } else { - $size = filesize($this->_file); - } - - header("Cache-Control: private"); - header("Content-Type: application/pdf"); - header("Content-Length: " . $size); - - $filename = str_replace(["\n", "'"], "", basename($filename, ".pdf")) . ".pdf"; - $attachment = $options["Attachment"] ? "attachment" : "inline"; - header(Helpers::buildContentDispositionHeader($attachment, $filename)); - - if (self::$IN_MEMORY) { - echo $data; - } else { - // Chunked readfile() - $chunk = (1 << 21); // 2 MB - $fh = fopen($this->_file, "rb"); - if (!$fh) { - throw new Exception("Unable to load temporary PDF file: " . $this->_file); - } - - while (!feof($fh)) { - echo fread($fh, $chunk); - } - fclose($fh); - - //debugpng - if ($this->_dompdf->getOptions()->getDebugPng()) { - print '[pdflib stream unlink ' . $this->_file . ']'; - } - if (!$this->_dompdf->getOptions()->getDebugKeepTemp()) { - unlink($this->_file); - } - $this->_file = null; - unset($this->_file); - } - - flush(); - } - - public function output($options = []) - { - if (!isset($options["compress"])) { - $options["compress"] = true; - } - - if ($options["compress"]) { - $this->setPDFLibValue("compress", 6); - } else { - $this->setPDFLibValue("compress", 0); - } - - $this->_close(); - - if (self::$IN_MEMORY) { - $data = $this->_pdf->get_buffer(); - } else { - $data = file_get_contents($this->_file); - - //debugpng - if ($this->_dompdf->getOptions()->getDebugPng()) { - print '[pdflib output unlink ' . $this->_file . ']'; - } - if (!$this->_dompdf->getOptions()->getDebugKeepTemp()) { - unlink($this->_file); - } - $this->_file = null; - unset($this->_file); - } - - return $data; - } - - /** - * @param string $keyword - * @param string $optlist - * @return mixed - */ - protected function getPDFLibParameter($keyword, $optlist = "") - { - if ($this->getPDFLibMajorVersion() >= 9) { - return $this->_pdf->get_option($keyword, ""); - } - - return $this->_pdf->get_parameter($keyword, $optlist); - } - - /** - * @param string $keyword - * @param string $value - * @return mixed - */ - protected function setPDFLibParameter($keyword, $value) - { - if ($this->getPDFLibMajorVersion() >= 9) { - return $this->_pdf->set_option($keyword . "=" . $value); - } - - return $this->_pdf->set_parameter($keyword, $value); - } - - /** - * @param string $keyword - * @param string $optlist - * @return mixed - */ - protected function getPDFLibValue($keyword, $optlist = "") - { - if ($this->getPDFLibMajorVersion() >= 9) { - return $this->getPDFLibParameter($keyword, $optlist); - } - - return $this->_pdf->get_value($keyword); - } - - /** - * @param string $keyword - * @param string $value - * @return mixed - */ - protected function setPDFLibValue($keyword, $value) - { - if ($this->getPDFLibMajorVersion() >= 9) { - return $this->setPDFLibParameter($keyword, $value); - } - - return $this->_pdf->set_value($keyword, $value); - } - - /** - * @return int - */ - protected function getPDFLibMajorVersion() - { - if (is_null(self::$MAJOR_VERSION)) { - if (method_exists($this->_pdf, "get_option")) { - self::$MAJOR_VERSION = abs(intval($this->_pdf->get_option("major", ""))); - } else { - self::$MAJOR_VERSION = abs(intval($this->_pdf->get_value("major", ""))); - } - } - - return self::$MAJOR_VERSION; - } -} - -// Workaround for idiotic limitation on statics... -PDFLib::$PAPER_SIZES = CPDF::$PAPER_SIZES; diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Canvas.php b/library/vendor/dompdf/vendor/dompdf/dompdf/src/Canvas.php deleted file mode 100644 index 1812def58..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Canvas.php +++ /dev/null @@ -1,477 +0,0 @@ - alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $width - * @param array $style - * @param string $cap `butt`, `round`, or `square` - */ - function line($x1, $y1, $x2, $y2, $color, $width, $style = [], $cap = "butt"); - - /** - * Draws an arc - * - * See {@link Cpdf::setLineStyle()} for a description of the format of the - * $style and $cap parameters (aka dash and cap). - * - * @param float $x X coordinate of the arc - * @param float $y Y coordinate of the arc - * @param float $r1 Radius 1 - * @param float $r2 Radius 2 - * @param float $astart Start angle in degrees - * @param float $aend End angle in degrees - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $width - * @param array $style - * @param string $cap `butt`, `round`, or `square` - */ - function arc($x, $y, $r1, $r2, $astart, $aend, $color, $width, $style = [], $cap = "butt"); - - /** - * Draws a rectangle at x1,y1 with width w and height h - * - * See {@link Cpdf::setLineStyle()} for a description of the format of the - * $style and $cap parameters (aka dash and cap). - * - * @param float $x1 - * @param float $y1 - * @param float $w - * @param float $h - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $width - * @param array $style - * @param string $cap `butt`, `round`, or `square` - */ - function rectangle($x1, $y1, $w, $h, $color, $width, $style = [], $cap = "butt"); - - /** - * Draws a filled rectangle at x1,y1 with width w and height h - * - * @param float $x1 - * @param float $y1 - * @param float $w - * @param float $h - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - */ - function filled_rectangle($x1, $y1, $w, $h, $color); - - /** - * Starts a clipping rectangle at x1,y1 with width w and height h - * - * @param float $x1 - * @param float $y1 - * @param float $w - * @param float $h - */ - function clipping_rectangle($x1, $y1, $w, $h); - - /** - * Starts a rounded clipping rectangle at x1,y1 with width w and height h - * - * @param float $x1 - * @param float $y1 - * @param float $w - * @param float $h - * @param float $tl - * @param float $tr - * @param float $br - * @param float $bl - */ - function clipping_roundrectangle($x1, $y1, $w, $h, $tl, $tr, $br, $bl); - - /** - * Starts a clipping polygon - * - * @param float[] $points - */ - public function clipping_polygon(array $points): void; - - /** - * Ends the last clipping shape - */ - function clipping_end(); - - /** - * Processes a callback on every page. - * - * The callback function receives the four parameters `int $pageNumber`, - * `int $pageCount`, `Canvas $canvas`, and `FontMetrics $fontMetrics`, in - * that order. - * - * This function can be used to add page numbers to all pages after the - * first one, for example. - * - * @param callable $callback The callback function to process on every page - */ - public function page_script($callback): void; - - /** - * Writes text at the specified x and y coordinates on every page. - * - * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced - * with their current values. - * - * @param float $x - * @param float $y - * @param string $text The text to write - * @param string $font The font file to use - * @param float $size The font size, in points - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $word_space Word spacing adjustment - * @param float $char_space Char spacing adjustment - * @param float $angle Angle to write the text at, measured clockwise starting from the x-axis - */ - public function page_text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_space = 0.0, $char_space = 0.0, $angle = 0.0); - - /** - * Draws a line at the specified coordinates on every page. - * - * @param float $x1 - * @param float $y1 - * @param float $x2 - * @param float $y2 - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $width - * @param array $style - */ - public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = []); - - /** - * Save current state - */ - function save(); - - /** - * Restore last state - */ - function restore(); - - /** - * Rotate - * - * @param float $angle angle in degrees for counter-clockwise rotation - * @param float $x Origin abscissa - * @param float $y Origin ordinate - */ - function rotate($angle, $x, $y); - - /** - * Skew - * - * @param float $angle_x - * @param float $angle_y - * @param float $x Origin abscissa - * @param float $y Origin ordinate - */ - function skew($angle_x, $angle_y, $x, $y); - - /** - * Scale - * - * @param float $s_x scaling factor for width as percent - * @param float $s_y scaling factor for height as percent - * @param float $x Origin abscissa - * @param float $y Origin ordinate - */ - function scale($s_x, $s_y, $x, $y); - - /** - * Translate - * - * @param float $t_x movement to the right - * @param float $t_y movement to the bottom - */ - function translate($t_x, $t_y); - - /** - * Transform - * - * @param float $a - * @param float $b - * @param float $c - * @param float $d - * @param float $e - * @param float $f - */ - function transform($a, $b, $c, $d, $e, $f); - - /** - * Draws a polygon - * - * The polygon is formed by joining all the points stored in the $points - * array. $points has the following structure: - * ``` - * array(0 => x1, - * 1 => y1, - * 2 => x2, - * 3 => y2, - * ... - * ); - * ``` - * - * See {@link Cpdf::setLineStyle()} for a description of the format of the - * $style parameter (aka dash). - * - * @param array $points - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $width - * @param array $style - * @param bool $fill Fills the polygon if true - */ - function polygon($points, $color, $width = null, $style = [], $fill = false); - - /** - * Draws a circle at $x,$y with radius $r - * - * See {@link Cpdf::setLineStyle()} for a description of the format of the - * $style parameter (aka dash). - * - * @param float $x - * @param float $y - * @param float $r - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $width - * @param array $style - * @param bool $fill Fills the circle if true - */ - function circle($x, $y, $r, $color, $width = null, $style = [], $fill = false); - - /** - * Add an image to the pdf. - * - * The image is placed at the specified x and y coordinates with the - * given width and height. - * - * @param string $img The path to the image - * @param float $x X position - * @param float $y Y position - * @param float $w Width - * @param float $h Height - * @param string $resolution The resolution of the image - */ - function image($img, $x, $y, $w, $h, $resolution = "normal"); - - /** - * Writes text at the specified x and y coordinates - * - * @param float $x - * @param float $y - * @param string $text The text to write - * @param string $font The font file to use - * @param float $size The font size, in points - * @param array $color Color array in the format `[r, g, b, "alpha" => alpha]` - * where r, g, b, and alpha are float values between 0 and 1 - * @param float $word_space Word spacing adjustment - * @param float $char_space Char spacing adjustment - * @param float $angle Angle to write the text at, measured clockwise starting from the x-axis - */ - function text($x, $y, $text, $font, $size, $color = [0, 0, 0], $word_space = 0.0, $char_space = 0.0, $angle = 0.0); - - /** - * Add a named destination (similar to ... in html) - * - * @param string $anchorname The name of the named destination - */ - function add_named_dest($anchorname); - - /** - * Add a link to the pdf - * - * @param string $url The url to link to - * @param float $x The x position of the link - * @param float $y The y position of the link - * @param float $width The width of the link - * @param float $height The height of the link - */ - function add_link($url, $x, $y, $width, $height); - - /** - * Add meta information to the PDF. - * - * @param string $label Label of the value (Creator, Producer, etc.) - * @param string $value The text to set - */ - public function add_info(string $label, string $value): void; - - /** - * Calculates text size, in points - * - * @param string $text The text to be sized - * @param string $font The font file to use - * @param float $size The font size, in points - * @param float $word_spacing Word spacing, if any - * @param float $char_spacing Char spacing, if any - * - * @return float - */ - function get_text_width($text, $font, $size, $word_spacing = 0.0, $char_spacing = 0.0); - - /** - * Calculates font height, in points - * - * @param string $font The font file to use - * @param float $size The font size, in points - * - * @return float - */ - function get_font_height($font, $size); - - /** - * Returns the font x-height, in points - * - * @param string $font The font file to use - * @param float $size The font size, in points - * - * @return float - */ - //function get_font_x_height($font, $size); - - /** - * Calculates font baseline, in points - * - * @param string $font The font file to use - * @param float $size The font size, in points - * - * @return float - */ - function get_font_baseline($font, $size); - - /** - * Returns the PDF's width in points - * - * @return float - */ - function get_width(); - - /** - * Returns the PDF's height in points - * - * @return float - */ - function get_height(); - - /** - * Sets the opacity - * - * @param float $opacity - * @param string $mode - */ - public function set_opacity(float $opacity, string $mode = "Normal"): void; - - /** - * Sets the default view - * - * @param string $view - * 'XYZ' left, top, zoom - * 'Fit' - * 'FitH' top - * 'FitV' left - * 'FitR' left,bottom,right - * 'FitB' - * 'FitBH' top - * 'FitBV' left - * @param array $options - */ - function set_default_view($view, $options = []); - - /** - * @param string $code - */ - function javascript($code); - - /** - * Starts a new page - * - * Subsequent drawing operations will appear on the new page. - */ - function new_page(); - - /** - * Streams the PDF to the client. - * - * @param string $filename The filename to present to the client. - * @param array $options Associative array: 'compress' => 1 or 0 (default 1); 'Attachment' => 1 or 0 (default 1). - */ - function stream($filename, $options = []); - - /** - * Returns the PDF as a string. - * - * @param array $options Associative array: 'compress' => 1 or 0 (default 1). - * - * @return string - */ - function output($options = []); -} diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/src/CanvasFactory.php b/library/vendor/dompdf/vendor/dompdf/dompdf/src/CanvasFactory.php deleted file mode 100644 index 86352e1dc..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/src/CanvasFactory.php +++ /dev/null @@ -1,58 +0,0 @@ -getOptions()->getPdfBackend()); - - if (isset($class) && class_exists($class, false)) { - $class .= "_Adapter"; - } else { - if (($backend === "auto" || $backend === "pdflib") && - class_exists("PDFLib", false) - ) { - $class = "Dompdf\\Adapter\\PDFLib"; - } - - else { - if ($backend === "gd" && extension_loaded('gd')) { - $class = "Dompdf\\Adapter\\GD"; - } else { - $class = "Dompdf\\Adapter\\CPDF"; - } - } - } - - return new $class($paper, $orientation, $dompdf); - } -} diff --git a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Cellmap.php b/library/vendor/dompdf/vendor/dompdf/dompdf/src/Cellmap.php deleted file mode 100644 index e6c1c68e6..000000000 --- a/library/vendor/dompdf/vendor/dompdf/dompdf/src/Cellmap.php +++ /dev/null @@ -1,999 +0,0 @@ - 8, - "solid" => 7, - "dashed" => 6, - "dotted" => 5, - "ridge" => 4, - "outset" => 3, - "groove" => 2, - "inset" => 1, - "none" => 0 - ]; - - /** - * The table object this cellmap is attached to. - * - * @var TableFrameDecorator - */ - protected $_table; - - /** - * The total number of rows in the table - * - * @var int - */ - protected $_num_rows; - - /** - * The total number of columns in the table - * - * @var int - */ - protected $_num_cols; - - /** - * 2D array mapping[get_font_family:"; - print '(' . $computed . '.' . $font_style . '.' . $weight . '.' . $subtype . ')'; - print '(' . $font . ")get_font_family]\n"; - } - return $font; - } - } - - $family = null; - if ($DEBUGCSS) { - print '(default)'; - } - $font = $fontMetrics->getFont($family, $subtype); - - if ($font) { - if ($DEBUGCSS) { - print '(' . $font . ")get_font_family]\n"; - } - return $font; - } - - throw new Exception("Unable to find a suitable font replacement for: '" . $computed . "'"); - } - - /** - * @param float|string $computed - * @return float - * - * @link https://www.w3.org/TR/css-text-4/#word-spacing-property - */ - protected function _get_word_spacing($computed) - { - if (\is_float($computed)) { - return $computed; - } - - // Resolve percentage values - $font_size = $this->__get("font_size"); - return $this->single_length_in_pt($computed, $font_size); - } - - /** - * @param float|string $computed - * @return float - * - * @link https://www.w3.org/TR/css-text-4/#letter-spacing-property - */ - protected function _get_letter_spacing($computed) - { - if (\is_float($computed)) { - return $computed; - } - - // Resolve percentage values - $font_size = $this->__get("font_size"); - return $this->single_length_in_pt($computed, $font_size); - } - - /** - * @param float|string $computed - * @return float - * - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-line-height - */ - protected function _get_line_height($computed) - { - // Lengths have been computed to float, number values to string - if (\is_float($computed)) { - return $computed; - } - - $font_size = $this->__get("font_size"); - $factor = $computed === "normal" - ? self::$default_line_height - : (float) $computed; - - return $factor * $font_size; - } - - /** - * @param string $computed - * @param bool $current_is_parent - * - * @return array|string - */ - protected function get_color_value($computed, bool $current_is_parent = false) - { - if ($computed === "currentcolor") { - // https://www.w3.org/TR/css-color-4/#resolving-other-colors - if ($current_is_parent) { - // Use the `color` value from the parent for the `color` - // property itself - return isset($this->parent_style) - ? $this->parent_style->__get("color") - : $this->munge_color(self::$_defaults["color"]); - } - - return $this->__get("color"); - } - - return $this->munge_color($computed) ?? "transparent"; - } - - /** - * Returns the color as an array - * - * The array has the following format: - * `array(r, g, b, "r" => r, "g" => g, "b" => b, "alpha" => alpha, "hex" => "#rrggbb")` - * - * @param string $computed - * @return array|string - * - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-color - */ - protected function _get_color($computed) - { - return $this->get_color_value($computed, true); - } - - /** - * Returns the background color as an array - * - * See {@link Style::_get_color()} for format of the color array. - * - * @param string $computed - * @return array|string - * - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-background-color - */ - protected function _get_background_color($computed) - { - return $this->get_color_value($computed); - } - - /** - * Returns the background image URI, or "none" - * - * @param string $computed - * @return string - * - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-background-image - */ - protected function _get_background_image($computed): string - { - return $this->_stylesheet->resolve_url($computed); - } - - /** - * Returns the border color as an array - * - * See {@link Style::_get_color()} for format of the color array. - * - * @param string $computed - * @return array|string - * - * @link https://www.w3.org/TR/CSS21/box.html#border-color-properties - */ - protected function _get_border_top_color($computed) - { - return $this->get_color_value($computed); - } - - /** - * @param string $computed - * @return array|string - */ - protected function _get_border_right_color($computed) - { - return $this->get_color_value($computed); - } - - /** - * @param string $computed - * @return array|string - */ - protected function _get_border_bottom_color($computed) - { - return $this->get_color_value($computed); - } - - /** - * @param string $computed - * @return array|string - */ - protected function _get_border_left_color($computed) - { - return $this->get_color_value($computed); - } - - /** - * Return an array of all border properties. - * - * The returned array has the following structure: - * - * ``` - * array("top" => array("width" => [border-width], - * "style" => [border-style], - * "color" => [border-color (array)]), - * "bottom" ... ) - * ``` - * - * @return array - */ - public function get_border_properties(): array - { - return [ - "top" => [ - "width" => $this->__get("border_top_width"), - "style" => $this->__get("border_top_style"), - "color" => $this->__get("border_top_color"), - ], - "bottom" => [ - "width" => $this->__get("border_bottom_width"), - "style" => $this->__get("border_bottom_style"), - "color" => $this->__get("border_bottom_color"), - ], - "right" => [ - "width" => $this->__get("border_right_width"), - "style" => $this->__get("border_right_style"), - "color" => $this->__get("border_right_color"), - ], - "left" => [ - "width" => $this->__get("border_left_width"), - "style" => $this->__get("border_left_style"), - "color" => $this->__get("border_left_color"), - ], - ]; - } - - /** - * Return a single border-side property - * - * @param string $side - * @return string - */ - protected function get_border_side(string $side): string - { - $color = $this->__get("border_{$side}_color"); - - return $this->__get("border_{$side}_width") . " " . - $this->__get("border_{$side}_style") . " " . - (\is_array($color) ? $color["hex"] : $color); - } - - /** - * Return full border properties as a string - * - * Border properties are returned just as specified in CSS: - * `[width] [style] [color]` - * e.g. "1px solid blue" - * - * @return string - * - * @link https://www.w3.org/TR/CSS21/box.html#border-shorthand-properties - */ - protected function _get_border_top(): string - { - return $this->get_border_side("top"); - } - - /** - * @return string - */ - protected function _get_border_right(): string - { - return $this->get_border_side("right"); - } - - /** - * @return string - */ - protected function _get_border_bottom(): string - { - return $this->get_border_side("bottom"); - } - - /** - * @return string - */ - protected function _get_border_left(): string - { - return $this->get_border_side("left"); - } - - public function has_border_radius(): bool - { - if (isset($this->has_border_radius_cache)) { - return $this->has_border_radius_cache; - } - - // Use a fixed ref size here. We don't know the border-box width here - // and font size might be 0. Since we are only interested in whether - // there is any border radius at all, this should do - $tl = (float) $this->length_in_pt($this->border_top_left_radius, 12); - $tr = (float) $this->length_in_pt($this->border_top_right_radius, 12); - $br = (float) $this->length_in_pt($this->border_bottom_right_radius, 12); - $bl = (float) $this->length_in_pt($this->border_bottom_left_radius, 12); - - $this->has_border_radius_cache = $tl + $tr + $br + $bl > 0; - return $this->has_border_radius_cache; - } - - /** - * Get the final border-radius values to use. - * - * Percentage values are resolved relative to the width of the border box. - * The border radius is additionally scaled for the given render box, and - * constrained by its width and height. - * - * @param float[] $border_box The border box of the frame. - * @param float[]|null $render_box The box to resolve the border radius for. - * - * @return float[] A 4-tuple of top-left, top-right, bottom-right, and bottom-left radius. - */ - public function resolve_border_radius( - array $border_box, - ?array $render_box = null - ): array { - $render_box = $render_box ?? $border_box; - $use_cache = $render_box === $border_box; - - if ($use_cache && isset($this->resolved_border_radius)) { - return $this->resolved_border_radius; - } - - [$x, $y, $w, $h] = $border_box; - - // Resolve percentages relative to width, as long as we have no support - // for per-axis radii - $tl = (float) $this->length_in_pt($this->border_top_left_radius, $w); - $tr = (float) $this->length_in_pt($this->border_top_right_radius, $w); - $br = (float) $this->length_in_pt($this->border_bottom_right_radius, $w); - $bl = (float) $this->length_in_pt($this->border_bottom_left_radius, $w); - - if ($tl + $tr + $br + $bl > 0) { - [$rx, $ry, $rw, $rh] = $render_box; - - $t_offset = $y - $ry; - $r_offset = $rx + $rw - $x - $w; - $b_offset = $ry + $rh - $y - $h; - $l_offset = $x - $rx; - - if ($tl > 0) { - $tl = max($tl + ($t_offset + $l_offset) / 2, 0); - } - if ($tr > 0) { - $tr = max($tr + ($t_offset + $r_offset) / 2, 0); - } - if ($br > 0) { - $br = max($br + ($b_offset + $r_offset) / 2, 0); - } - if ($bl > 0) { - $bl = max($bl + ($b_offset + $l_offset) / 2, 0); - } - - if ($tl + $bl > $rh) { - $f = $rh / ($tl + $bl); - $tl = $f * $tl; - $bl = $f * $bl; - } - if ($tr + $br > $rh) { - $f = $rh / ($tr + $br); - $tr = $f * $tr; - $br = $f * $br; - } - if ($tl + $tr > $rw) { - $f = $rw / ($tl + $tr); - $tl = $f * $tl; - $tr = $f * $tr; - } - if ($bl + $br > $rw) { - $f = $rw / ($bl + $br); - $bl = $f * $bl; - $br = $f * $br; - } - } - - $values = [$tl, $tr, $br, $bl]; - - if ($use_cache) { - $this->resolved_border_radius = $values; - } - - return $values; - } - - /** - * Returns the outline color as an array - * - * See {@link Style::_get_color()} for format of the color array. - * - * @param string $computed - * @return array|string - * - * @link https://www.w3.org/TR/css-ui-4/#propdef-outline-color - */ - protected function _get_outline_color($computed) - { - return $this->get_color_value($computed); - } - - /** - * @param string $computed - * @return string - * - * @link https://www.w3.org/TR/css-ui-4/#propdef-outline-style - */ - protected function _get_outline_style($computed): string - { - return $computed === "auto" ? "solid" : $computed; - } - - /** - * Return full outline properties as a string - * - * Outline properties are returned just as specified in CSS: - * `[width] [style] [color]` - * e.g. "1px solid blue" - * - * @return string - * - * @link https://www.w3.org/TR/CSS21/box.html#border-shorthand-properties - */ - protected function _get_outline(): string - { - $color = $this->__get("outline_color"); - - return $this->__get("outline_width") . " " . - $this->__get("outline_style") . " " . - (\is_array($color) ? $color["hex"] : $color); - } - - /** - * Returns the list style image URI, or "none" - * - * @param string $computed - * @return string - * - * @link https://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image - */ - protected function _get_list_style_image($computed): string - { - return $this->_stylesheet->resolve_url($computed); - } - - /** - * @param string $value - * @param int $default - * - * @return array|string - */ - protected function parse_counter_prop(string $value, int $default) - { - $ident = self::CSS_IDENTIFIER; - $integer = self::CSS_INTEGER; - $pattern = "/($ident)(?:\s+($integer))?/"; - - if (!preg_match_all($pattern, $value, $matches, PREG_SET_ORDER)) { - return "none"; - } - - $counters = []; - - foreach ($matches as $match) { - $counter = $match[1]; - $value = isset($match[2]) ? (int) $match[2] : $default; - $counters[$counter] = $value; - } - - return $counters; - } - - /** - * @param string $computed - * @return array|string - * - * @link https://www.w3.org/TR/CSS21/generate.html#propdef-counter-increment - */ - protected function _get_counter_increment($computed) - { - if ($computed === "none") { - return $computed; - } - - return $this->parse_counter_prop($computed, 1); - } - - /** - * @param string $computed - * @return array|string - * - * @link https://www.w3.org/TR/CSS21/generate.html#propdef-counter-reset - */ - protected function _get_counter_reset($computed) - { - if ($computed === "none") { - return $computed; - } - - return $this->parse_counter_prop($computed, 0); - } - - /** - * @param string $computed - * @return string[]|string - * - * @link https://www.w3.org/TR/CSS21/generate.html#propdef-content - */ - protected function _get_content($computed) - { - if ($computed === "normal" || $computed === "none") { - return $computed; - } - - return $this->parse_property_value($computed); - } - - /*==============================*/ - - /** - * Parse a property value into its components. - * - * @param string $value - * - * @return string[] - */ - protected function parse_property_value(string $value): array - { - $ident = self::CSS_IDENTIFIER; - $number = self::CSS_NUMBER; - - $pattern = "/\n" . - "\s* \" ( (?:[^\"]|\\\\[\"])* ) (?munge_color($val) - : $val; - - if ($munged_color === null) { - return null; - } - - return \is_array($munged_color) ? $munged_color["hex"] : $munged_color; - } - - /** - * @param string $val - * @return int|null - */ - protected function compute_integer(string $val): ?int - { - $integer = self::CSS_INTEGER; - return preg_match("/^$integer$/", $val) - ? (int) $val - : null; - } - - /** - * @param string $val - * @return float|null - */ - protected function compute_length(string $val): ?float - { - return mb_strpos($val, "%") === false - ? $this->single_length_in_pt($val) - : null; - } - - /** - * @param string $val - * @return float|null - */ - protected function compute_length_positive(string $val): ?float - { - $computed = $this->compute_length($val); - return $computed !== null && $computed >= 0 ? $computed : null; - } - - /** - * @param string $val - * @return float|string|null - */ - protected function compute_length_percentage(string $val) - { - // Compute with a fixed ref size to decide whether percentage values - // are valid - $computed = $this->single_length_in_pt($val, 12); - - if ($computed === null) { - return null; - } - - // Retain valid percentage declarations - return mb_strpos($val, "%") === false ? $computed : $val; - } - - /** - * @param string $val - * @return float|string|null - */ - protected function compute_length_percentage_positive(string $val) - { - // Compute with a fixed ref size to decide whether percentage values - // are valid - $computed = $this->single_length_in_pt($val, 12); - - if ($computed === null || $computed < 0) { - return null; - } - - // Retain valid percentage declarations - return mb_strpos($val, "%") === false ? $computed : $val; - } - - /** - * @param string $val - * @param string $style_prop The corresponding border-/outline-style property. - * - * @return float|null - * - * @link https://www.w3.org/TR/css-backgrounds-3/#typedef-line-width - */ - protected function compute_line_width(string $val, string $style_prop): ?float - { - // Border-width keywords - if ($val === "thin") { - $computed = 0.5; - } elseif ($val === "medium") { - $computed = 1.5; - } elseif ($val === "thick") { - $computed = 2.5; - } else { - $computed = $this->compute_length_positive($val); - } - - if ($computed === null) { - return null; - } - - // Computed width is 0 if the line style is `none` or `hidden` - // https://www.w3.org/TR/css-backgrounds-3/#border-width - // https://www.w3.org/TR/css-ui-4/#outline-width - $lineStyle = $this->__get($style_prop); - $hasLineStyle = $lineStyle !== "none" && $lineStyle !== "hidden"; - - return $hasLineStyle ? $computed : 0.0; - } - - /** - * @param string $val - * @return string|null - */ - protected function compute_border_style(string $val): ?string - { - return \in_array($val, self::BORDER_STYLES, true) ? $val : null; - } - - /** - * Parse a property value with 1 to 4 components into 4 values, as required - * by shorthand properties such as `margin`, `padding`, and `border-radius`. - * - * @param string $prop The shorthand property with exactly 4 sub-properties to handle. - * @param string $value The property value to parse. - * - * @return string[] - */ - protected function set_quad_shorthand(string $prop, string $value): array - { - $v = $this->parse_property_value($value); - - switch (\count($v)) { - case 1: - $values = [$v[0], $v[0], $v[0], $v[0]]; - break; - case 2: - $values = [$v[0], $v[1], $v[0], $v[1]]; - break; - case 3: - $values = [$v[0], $v[1], $v[2], $v[1]]; - break; - case 4: - $values = [$v[0], $v[1], $v[2], $v[3]]; - break; - default: - return []; - } - - return array_combine(self::$_props_shorthand[$prop], $values); - } - - /*======================*/ - - /** - * @link https://www.w3.org/TR/CSS21/visuren.html#display-prop - */ - protected function _compute_display(string $val) - { - // Make sure that common valid, but unsupported display types have an - // appropriate fallback display type - switch ($val) { - case "flow-root": - case "flex": - case "grid": - case "table-caption": - $val = "block"; - break; - case "inline-flex": - case "inline-grid": - $val = "inline-block"; - break; - } - - if (!isset(self::$valid_display_types[$val])) { - return null; - } - - // https://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo - if ($this->is_in_flow()) { - return $val; - } else { - switch ($val) { - case "inline": - case "inline-block": - // case "table-row-group": - // case "table-header-group": - // case "table-footer-group": - // case "table-row": - // case "table-cell": - // case "table-column-group": - // case "table-column": - // case "table-caption": - return "block"; - case "inline-table": - return "table"; - default: - return $val; - } - } - } - - /** - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-color - */ - protected function _compute_color(string $color) - { - return $this->compute_color_value($color); - } - - /** - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-background-color - */ - protected function _compute_background_color(string $color) - { - return $this->compute_color_value($color); - } - - /** - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-background-image - */ - protected function _compute_background_image(string $val) - { - $parsed_val = $this->_stylesheet->resolve_url($val); - - if ($parsed_val === "none") { - return "none"; - } else { - return "url($parsed_val)"; - } - } - - /** - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat - */ - protected function _compute_background_repeat(string $val) - { - $keywords = ["repeat", "repeat-x", "repeat-y", "no-repeat"]; - return \in_array($val, $keywords, true) ? $val : null; - } - - /** - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment - */ - protected function _compute_background_attachment(string $val) - { - $keywords = ["scroll", "fixed"]; - return \in_array($val, $keywords, true) ? $val : null; - } - - /** - * @link https://www.w3.org/TR/CSS21/colors.html#propdef-background-position - */ - protected function _compute_background_position(string $val) - { - $parts = preg_split("/\s+/", $val); - - if (\count($parts) > 2) { - return null; - } - - switch ($parts[0]) { - case "left": - $x = "0%"; - break; - - case "right": - $x = "100%"; - break; - - case "top": - $y = "0%"; - break; - - case "bottom": - $y = "100%"; - break; - - case "center": - $x = "50%"; - $y = "50%"; - break; - - default: - $x = $parts[0]; - break; - } - - if (isset($parts[1])) { - switch ($parts[1]) { - case "left": - $x = "0%"; - break; - - case "right": - $x = "100%"; - break; - - case "top": - $y = "0%"; - break; - - case "bottom": - $y = "100%"; - break; - - case "center": - if ($parts[0] === "left" || $parts[0] === "right" || $parts[0] === "center") { - $y = "50%"; - } else { - $x = "50%"; - } - break; - - default: - $y = $parts[1]; - break; - } - } else { - $y = "50%"; - } - - if (!isset($x)) { - $x = "0%"; - } - - if (!isset($y)) { - $y = "0%"; - } - - return [$x, $y]; - } - - /** - * Compute `background-size`. - * - * Computes to one of the following values: - * * `cover` - * * `contain` - * * `[width, height]`, each being a length, percentage, or `auto` - * - * @link https://www.w3.org/TR/css-backgrounds-3/#background-size - */ - protected function _compute_background_size(string $val) - { - if ($val === "cover" || $val === "contain") { - return $val; - } - - $parts = preg_split("/\s+/", $val); - - if (\count($parts) > 2) { - return null; - } - - $width = $parts[0]; - if ($width !== "auto") { - $width = $this->compute_length_percentage_positive($width); - } - - $height = $parts[1] ?? "auto"; - if ($height !== "auto") { - $height = $this->compute_length_percentage_positive($height); - } - - if ($width === null || $height === null) { - return null; - } - - return [$width, $height]; - } - - /** - * @link https://www.w3.org/TR/css-backgrounds-3/#propdef-background - */ - protected function _set_background(string $value): array - { - $components = $this->parse_property_value($value); - $props = []; - $pos_size = []; - - foreach ($components as $val) { - if ($val === "none" || mb_substr($val, 0, 4) === "url(") { - $props["background_image"] = $val; - } elseif ($val === "scroll" || $val === "fixed") { - $props["background_attachment"] = $val; - } elseif ($val === "repeat" || $val === "repeat-x" || $val === "repeat-y" || $val === "no-repeat") { - $props["background_repeat"] = $val; - } elseif ($this->is_color_value($val)) { - $props["background_color"] = $val; - } else { - $pos_size[] = $val; - } - } - - if (\count($pos_size)) { - // Split value list at "/" - $index = array_search("/", $pos_size, true); - - if ($index !== false) { - $pos = \array_slice($pos_size, 0, $index); - $size = \array_slice($pos_size, $index + 1); - } else { - $pos = $pos_size; - $size = []; - } - - $props["background_position"] = implode(" ", $pos); - - if (\count($size)) { - $props["background_size"] = implode(" ", $size); - } - } - - return $props; - } - - /** - * @link https://www.w3.org/TR/CSS21/fonts.html#propdef-font-size - */ - protected function _compute_font_size(string $size) - { - $parent_font_size = isset($this->parent_style) - ? $this->parent_style->__get("font_size") - : self::$default_font_size; - - switch ($size) { - case "xx-small": - case "x-small": - case "small": - case "medium": - case "large": - case "x-large": - case "xx-large": - $fs = self::$default_font_size * self::$font_size_keywords[$size]; - break; - - case "smaller": - $fs = 8 / 9 * $parent_font_size; - break; - - case "larger": - $fs = 6 / 5 * $parent_font_size; - break; - - default: - $fs = $this->single_length_in_pt($size, $parent_font_size, $parent_font_size); - break; - } - - return $fs; - } - - /** - * @link https://www.w3.org/TR/CSS21/fonts.html#font-boldness - */ - protected function _compute_font_weight(string $weight) - { - $computed_weight = $weight; - - if ($weight === "bolder") { - //TODO: One font weight heavier than the parent element (among the available weights of the font). - $computed_weight = "bold"; - } elseif ($weight === "lighter") { - //TODO: One font weight lighter than the parent element (among the available weights of the font). - $computed_weight = "normal"; - } - - return $computed_weight; - } - - /** - * Handle the `font` shorthand property. - * - * `[ font-style || font-variant || font-weight ] font-size [ / line-height ] font-family` - * - * @link https://www.w3.org/TR/CSS21/fonts.html#font-shorthand - */ - protected function _set_font(string $value): array - { - $components = $this->parse_property_value($value); - $props = []; - - $number = self::CSS_NUMBER; - $unit = "pt|px|pc|rem|em|ex|in|cm|mm|%"; - $sizePattern = "/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|$number(?:$unit))$/"; - $sizeIndex = null; - - // Find index of font-size to split the component list - foreach ($components as $i => $val) { - if (preg_match($sizePattern, $val)) { - $sizeIndex = $i; - $props["font_size"] = $val; - break; - } - } - - // `font-size` is mandatory - if ($sizeIndex === null) { - return []; - } - - // `font-style`, `font-variant`, `font-weight` in any order - $styleVariantWeight = \array_slice($components, 0, $sizeIndex); - $stylePattern = "/^(italic|oblique)$/"; - $variantPattern = "/^(small-caps)$/"; - $weightPattern = "/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900)$/"; - - if (\count($styleVariantWeight) > 3) { - return []; - } - - foreach ($styleVariantWeight as $val) { - if ($val === "normal") { - // Ignore any `normal` value, as it is valid and the initial - // value for all three properties - } elseif (!isset($props["font_style"]) && preg_match($stylePattern, $val)) { - $props["font_style"] = $val; - } elseif (!isset($props["font_variant"]) && preg_match($variantPattern, $val)) { - $props["font_variant"] = $val; - } elseif (!isset($props["font_weight"]) && preg_match($weightPattern, $val)) { - $props["font_weight"] = $val; - } else { - // Duplicates and other values disallowed here - return []; - } - } - - // Optional slash + `line-height` followed by mandatory `font-family` - $lineFamily = \array_slice($components, $sizeIndex + 1); - $hasLineHeight = $lineFamily !== [] && $lineFamily[0] === "/"; - $lineHeight = $hasLineHeight ? \array_slice($lineFamily, 1, 1) : []; - $fontFamily = $hasLineHeight ? \array_slice($lineFamily, 2) : $lineFamily; - $lineHeightPattern = "/^(normal|$number(?:$unit)?)$/"; - - // Missing `font-family` or `line-height` after slash - if ($fontFamily === [] - || ($hasLineHeight && !preg_match($lineHeightPattern, $lineHeight[0])) - ) { - return []; - } - - if ($hasLineHeight) { - $props["line_height"] = $lineHeight[0]; - } - - $props["font_family"] = implode("", $fontFamily); - - return $props; - } - - /** - * Compute `text-align`. - * - * If no alignment is set on the element and the direction is rtl then - * the property is set to "right", otherwise it is set to "left". - * - * @link https://www.w3.org/TR/CSS21/text.html#propdef-text-align - */ - protected function _compute_text_align(string $val) - { - $alignment = $val; - if ($alignment === "") { - $alignment = "left"; - if ($this->__get("direction") === "rtl") { - $alignment = "right"; - } - } - - if (!\in_array($alignment, self::TEXT_ALIGN_KEYWORDS, true)) { - return null; - } - - return $alignment; - } - - /** - * @link https://www.w3.org/TR/css-text-4/#word-spacing-property - */ - protected function _compute_word_spacing(string $val) - { - if ($val === "normal") { - return 0.0; - } - - return $this->compute_length_percentage($val); - } - - /** - * @link https://www.w3.org/TR/css-text-4/#letter-spacing-property - */ - protected function _compute_letter_spacing(string $val) - { - if ($val === "normal") { - return 0.0; - } - - return $this->compute_length_percentage($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-line-height - */ - protected function _compute_line_height(string $val) - { - if ($val === "normal") { - return $val; - } - - // Compute number values to string and lengths to float (in pt) - if (is_numeric($val)) { - return (string) $val; - } - - $font_size = $this->__get("font_size"); - $computed = $this->single_length_in_pt($val, $font_size); - return $computed !== null && $computed >= 0 ? $computed : null; - } - - /** - * @link https://www.w3.org/TR/css-text-3/#text-indent-property - */ - protected function _compute_text_indent(string $val) - { - return $this->compute_length_percentage($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/page.html#propdef-page-break-before - */ - protected function _compute_page_break_before(string $break) - { - if ($break === "left" || $break === "right") { - $break = "always"; - } - - return $break; - } - - /** - * @link https://www.w3.org/TR/CSS21/page.html#propdef-page-break-after - */ - protected function _compute_page_break_after(string $break) - { - if ($break === "left" || $break === "right") { - $break = "always"; - } - - return $break; - } - - /** - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-width - */ - protected function _compute_width(string $val) - { - if ($val === "auto") { - return $val; - } - - return $this->compute_length_percentage_positive($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-height - */ - protected function _compute_height(string $val) - { - if ($val === "auto") { - return $val; - } - - return $this->compute_length_percentage_positive($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-min-width - */ - protected function _compute_min_width(string $val) - { - // Legacy support for `none`, not covered by spec - if ($val === "auto" || $val === "none") { - return "auto"; - } - - return $this->compute_length_percentage_positive($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-min-height - */ - protected function _compute_min_height(string $val) - { - // Legacy support for `none`, not covered by spec - if ($val === "auto" || $val === "none") { - return "auto"; - } - - return $this->compute_length_percentage_positive($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-max-width - */ - protected function _compute_max_width(string $val) - { - // Legacy support for `auto`, not covered by spec - if ($val === "none" || $val === "auto") { - return "none"; - } - - return $this->compute_length_percentage_positive($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/visudet.html#propdef-max-height - */ - protected function _compute_max_height(string $val) - { - // Legacy support for `auto`, not covered by spec - if ($val === "none" || $val === "auto") { - return "none"; - } - - return $this->compute_length_percentage_positive($val); - } - - /** - * @link https://www.w3.org/TR/css-position-3/#inset-properties - * @link https://www.w3.org/TR/css-position-3/#propdef-inset - */ - protected function _set_inset(string $val): array - { - return $this->set_quad_shorthand("inset", $val); - } - - /** - * @param string $val - * @return float|string|null - */ - protected function compute_box_inset(string $val) - { - if ($val === "auto") { - return $val; - } - - return $this->compute_length_percentage($val); - } - - protected function _compute_top(string $val) - { - return $this->compute_box_inset($val); - } - - protected function _compute_right(string $val) - { - return $this->compute_box_inset($val); - } - - protected function _compute_bottom(string $val) - { - return $this->compute_box_inset($val); - } - - protected function _compute_left(string $val) - { - return $this->compute_box_inset($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/box.html#margin-properties - * @link https://www.w3.org/TR/CSS21/box.html#propdef-margin - */ - protected function _set_margin(string $val): array - { - return $this->set_quad_shorthand("margin", $val); - } - - /** - * @param string $val - * @return float|string|null - */ - protected function compute_margin(string $val) - { - // Legacy support for `none` keyword, not covered by spec - if ($val === "none") { - return 0.0; - } - - if ($val === "auto") { - return $val; - } - - return $this->compute_length_percentage($val); - } - - protected function _compute_margin_top(string $val) - { - return $this->compute_margin($val); - } - - protected function _compute_margin_right(string $val) - { - return $this->compute_margin($val); - } - - protected function _compute_margin_bottom(string $val) - { - return $this->compute_margin($val); - } - - protected function _compute_margin_left(string $val) - { - return $this->compute_margin($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/box.html#padding-properties - * @link https://www.w3.org/TR/CSS21/box.html#propdef-padding - */ - protected function _set_padding(string $val): array - { - return $this->set_quad_shorthand("padding", $val); - } - - /** - * @param string $val - * @return float|string|null - */ - protected function compute_padding(string $val) - { - // Legacy support for `none` keyword, not covered by spec - if ($val === "none") { - return 0.0; - } - - return $this->compute_length_percentage_positive($val); - } - - protected function _compute_padding_top(string $val) - { - return $this->compute_padding($val); - } - - protected function _compute_padding_right(string $val) - { - return $this->compute_padding($val); - } - - protected function _compute_padding_bottom(string $val) - { - return $this->compute_padding($val); - } - - protected function _compute_padding_left(string $val) - { - return $this->compute_padding($val); - } - - /** - * @param string $value `width || style || color` - * @param string[] $styles The list of border styles to accept. - * - * @return array Array of `[width, style, color]`, or `null` if the declaration is invalid. - */ - protected function parse_border_side(string $value, array $styles = self::BORDER_STYLES): ?array - { - $components = $this->parse_property_value($value); - $width = null; - $style = null; - $color = null; - - foreach ($components as $val) { - if ($style === null && \in_array($val, $styles, true)) { - $style = $val; - } elseif ($color === null && $this->is_color_value($val)) { - $color = $val; - } elseif ($width === null) { - // Assume width - $width = $val; - } else { - // Duplicates are not allowed - return null; - } - } - - return [$width, $style, $color]; - } - - /** - * @link https://www.w3.org/TR/CSS21/box.html#border-properties - * @link https://www.w3.org/TR/CSS21/box.html#propdef-border - */ - protected function _set_border(string $value): array - { - $values = $this->parse_border_side($value); - - if ($values === null) { - return []; - } - - return array_merge( - array_combine(self::$_props_shorthand["border_top"], $values), - array_combine(self::$_props_shorthand["border_right"], $values), - array_combine(self::$_props_shorthand["border_bottom"], $values), - array_combine(self::$_props_shorthand["border_left"], $values) - ); - } - - /** - * @param string $prop - * @param string $value - * @return array - */ - protected function set_border_side(string $prop, string $value): array - { - $values = $this->parse_border_side($value); - - if ($values === null) { - return []; - } - - return array_combine(self::$_props_shorthand[$prop], $values); - } - - protected function _set_border_top(string $val): array - { - return $this->set_border_side("border_top", $val); - } - - protected function _set_border_right(string $val): array - { - return $this->set_border_side("border_right", $val); - } - - protected function _set_border_bottom(string $val): array - { - return $this->set_border_side("border_bottom", $val); - } - - protected function _set_border_left(string $val): array - { - return $this->set_border_side("border_left", $val); - } - - /** - * @link https://www.w3.org/TR/CSS21/box.html#propdef-border-color - */ - protected function _set_border_color(string $val): array - { - return $this->set_quad_shorthand("border_color", $val); - } - - protected function _compute_border_top_color(string $val) - { - return $this->compute_color_value($val); - } - - protected function _compute_border_right_color(string $val) - { - return $this->compute_color_value($val); - } - - protected function _compute_border_bottom_color(string $val) - { - return $this->compute_color_value($val); - } - - protected function _compute_border_left_color(string $val) - { - return $this->compute_color_value($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/box.html#propdef-border-style - */ - protected function _set_border_style(string $val): array - { - return $this->set_quad_shorthand("border_style", $val); - } - - protected function _compute_border_top_style(string $val) - { - return $this->compute_border_style($val); - } - - protected function _compute_border_right_style(string $val) - { - return $this->compute_border_style($val); - } - - protected function _compute_border_bottom_style(string $val) - { - return $this->compute_border_style($val); - } - - protected function _compute_border_left_style(string $val) - { - return $this->compute_border_style($val); - } - - /** - * @link https://www.w3.org/TR/CSS21/box.html#propdef-border-width - */ - protected function _set_border_width(string $val): array - { - return $this->set_quad_shorthand("border_width", $val); - } - - protected function _compute_border_top_width(string $val) - { - return $this->compute_line_width($val, "border_top_style"); - } - - protected function _compute_border_right_width(string $val) - { - return $this->compute_line_width($val, "border_right_style"); - } - - protected function _compute_border_bottom_width(string $val) - { - return $this->compute_line_width($val, "border_bottom_style"); - } - - protected function _compute_border_left_width(string $val) - { - return $this->compute_line_width($val, "border_left_style"); - } - - /** - * @link https://www.w3.org/TR/css-backgrounds-3/#corners - * @link https://www.w3.org/TR/css-backgrounds-3/#propdef-border-radius - */ - protected function _set_border_radius(string $val): array - { - return $this->set_quad_shorthand("border_radius", $val); - } - - protected function _compute_border_top_left_radius(string $val) - { - return $this->compute_length_percentage_positive($val); - } - - protected function _compute_border_top_right_radius(string $val) - { - return $this->compute_length_percentage_positive($val); - } - - protected function _compute_border_bottom_right_radius(string $val) - { - return $this->compute_length_percentage_positive($val); - } - - protected function _compute_border_bottom_left_radius(string $val) - { - return $this->compute_length_percentage_positive($val); - } - - /** - * @link https://www.w3.org/TR/css-ui-4/#outline-props - * @link https://www.w3.org/TR/css-ui-4/#propdef-outline - */ - protected function _set_outline(string $value): array - { - $values = $this->parse_border_side($value, self::OUTLINE_STYLES); - - if ($values === null) { - return []; - } - - return array_combine(self::$_props_shorthand["outline"], $values); - } - - protected function _compute_outline_color(string $val) - { - return $this->compute_color_value($val); - } - - protected function _compute_outline_style(string $val) - { - return \in_array($val, self::OUTLINE_STYLES, true) ? $val : null; - } - - protected function _compute_outline_width(string $val) - { - return $this->compute_line_width($val, "outline_style"); - } - - /** - * @link https://www.w3.org/TR/css-ui-4/#propdef-outline-offset - */ - protected function _compute_outline_offset(string $val) - { - return $this->compute_length($val); - } - - /** - * Compute `border-spacing` to two lengths of the form - * `[horizontal, vertical]`. - * - * @link https://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing - */ - protected function _compute_border_spacing(string $val) - { - $parts = preg_split("/\s+/", $val); - - if (\count($parts) > 2) { - return null; - } - - $h = $this->compute_length_positive($parts[0]); - $v = isset($parts[1]) - ? $this->compute_length_positive($parts[1]) - : $h; - - if ($h === null || $v === null) { - return null; - } - - return [$h, $v]; - } - - /** - * @link https://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image - */ - protected function _compute_list_style_image(string $val) - { - $parsed_val = $this->_stylesheet->resolve_url($val); - - if ($parsed_val === "none") { - return "none"; - } else { - return "url($parsed_val)"; - } - } - - /** - * @link https://www.w3.org/TR/CSS21/generate.html#propdef-list-style - */ - protected function _set_list_style(string $value): array - { - static $positions = ["inside", "outside"]; - static $types = [ - "disc", "circle", "square", - "decimal-leading-zero", "decimal", "1", - "lower-roman", "upper-roman", "a", "A", - "lower-greek", - "lower-latin", "upper-latin", - "lower-alpha", "upper-alpha", - "armenian", "georgian", "hebrew", - "cjk-ideographic", "hiragana", "katakana", - "hiragana-iroha", "katakana-iroha", "none" - ]; - - $components = $this->parse_property_value($value); - $props = []; - - foreach ($components as $val) { - /* https://www.w3.org/TR/CSS21/generate.html#list-style - * A value of 'none' for the 'list-style' property sets both 'list-style-type' and 'list-style-image' to 'none' - */ - if ($val === "none") { - $props["list_style_type"] = $val; - $props["list_style_image"] = $val; - continue; - } - - //On setting or merging or inheriting list_style_image as well as list_style_type, - //and url exists, then url has precedence, otherwise fall back to list_style_type - //Firefox is wrong here (list_style_image gets overwritten on explicit list_style_type) - //Internet Explorer 7/8 and dompdf is right. - - if (mb_substr($val, 0, 4) === "url(") { - $props["list_style_image"] = $val; - continue; - } - - if (\in_array($val, $types, true)) { - $props["list_style_type"] = $val; - } elseif (\in_array($val, $positions, true)) { - $props["list_style_position"] = $val; - } - } - - return $props; - } - - /** - * @link https://www.w3.org/TR/css-page-3/#page-size-prop - */ - protected function _compute_size(string $val) - { - if ($val === "auto") { - return $val; - } - - $parts = $this->parse_property_value($val); - $count = \count($parts); - - if ($count === 0 || $count > 3) { - return null; - } - - $size = null; - $orientation = null; - $lengths = []; - - foreach ($parts as $part) { - if ($size === null && isset(CPDF::$PAPER_SIZES[$part])) { - $size = $part; - } elseif ($orientation === null && ($part === "portrait" || $part === "landscape")) { - $orientation = $part; - } else { - $lengths[] = $part; - } - } - - if ($size !== null && $lengths !== []) { - return null; - } - - if ($size !== null) { - // Standard paper size - [$l1, $l2] = \array_slice(CPDF::$PAPER_SIZES[$size], 2, 2); - } elseif ($lengths === []) { - // Orientation only, use default paper size - $dims = $this->_stylesheet->get_dompdf()->getPaperSize(); - [$l1, $l2] = \array_slice($dims, 2, 2); - } else { - // Custom paper size - $l1 = $this->compute_length_positive($lengths[0]); - $l2 = isset($lengths[1]) ? $this->compute_length_positive($lengths[1]) : $l1; - - if ($l1 === null || $l2 === null) { - return null; - } - } - - if (($orientation === "portrait" && $l1 > $l2) - || ($orientation === "landscape" && $l2 > $l1) - ) { - return [$l2, $l1]; - } - - return [$l1, $l2]; - } - - /** - * @param string $computed - * @return array - * - * @link https://www.w3.org/TR/css-transforms-1/#transform-property - */ - protected function _get_transform($computed) - { - //TODO: should be handled in setter (lengths set to absolute) - - $number = "\s*([^,\s]+)\s*"; - $tr_value = "\s*([^,\s]+)\s*"; - $angle = "\s*([^,\s]+(?:deg|rad)?)\s*"; - - if (!preg_match_all("/[a-z]+\([^\)]+\)/i", $computed, $parts, PREG_SET_ORDER)) { - return []; - } - - $functions = [ - //"matrix" => "\($number,$number,$number,$number,$number,$number\)", - - "translate" => "\($tr_value(?:,$tr_value)?\)", - "translateX" => "\($tr_value\)", - "translateY" => "\($tr_value\)", - - "scale" => "\($number(?:,$number)?\)", - "scaleX" => "\($number\)", - "scaleY" => "\($number\)", - - "rotate" => "\($angle\)", - - "skew" => "\($angle(?:,$angle)?\)", - "skewX" => "\($angle\)", - "skewY" => "\($angle\)", - ]; - - $transforms = []; - - foreach ($parts as $part) { - $t = $part[0]; - - foreach ($functions as $name => $pattern) { - if (preg_match("/$name\s*$pattern/i", $t, $matches)) { - $values = \array_slice($matches, 1); - - switch ($name) { - //
'; - foreach ($_dompdf_warnings as $msg) { - echo $msg . "\n"; - } - - if ($canvas instanceof CPDF) { - echo $canvas->get_cpdf()->messages; - } - echo ''; - flush(); - } - - if ($logOutputFile && is_writable($logOutputFile)) { - $this->writeLog($logOutputFile, $startTime); - ob_end_clean(); - } - - $this->restorePhpConfig(); - } - - /** - * Writes the output buffer in the log file - * - * @param string $logOutputFile - * @param float $startTime - */ - private function writeLog(string $logOutputFile, float $startTime): void - { - $frames = Frame::$ID_COUNTER; - $memory = memory_get_peak_usage(true) / 1024; - $time = (microtime(true) - $startTime) * 1000; - - $out = sprintf( - "%6d" . - "%10.2f KB" . - "%10.2f ms" . - " " . - ($this->quirksmode ? " ON" : "OFF") . - "
'" . mb_substr($tmp, 0, 70) . - (mb_strlen($tmp) > 70 ? "..." : "") . "'"; - } elseif ($css_class = $this->_node->getAttribute("class")) { - $str .= "CSS class: '$css_class'
" . $this->_style->__toString() . ""; - - if ($this->_decorator instanceof FrameDecorator\Block) { - $str .= "Lines:
"; - foreach ($this->_decorator->get_line_boxes() as $line) { - foreach ($line->get_frames() as $frame) { - if ($frame instanceof FrameDecorator\Text) { - $str .= "\ntext: "; - $str .= "'" . htmlspecialchars($frame->get_text()) . "'"; - } else { - $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")"; - } - } - - $str .= - "\ny => " . $line->y . "\n" . - "w => " . $line->w . "\n" . - "h => " . $line->h . "\n" . - "left => " . $line->left . "\n" . - "right => " . $line->right . "\n"; - } - $str .= ""; - } - - $str .= "\n"; - if (php_sapi_name() === "cli") { - $str = strip_tags(str_replace(["
" . print_r($mixed, true) . ""; - } - - if (php_sapi_name() !== "cli") { - echo "
"; - } - - print_r($mixed); - - if (php_sapi_name() !== "cli") { - echo ""; - } else { - echo "\n"; - } - - flush(); - - return null; - } - - /** - * builds a full url given a protocol, hostname, base path and url - * - * @param string $protocol - * @param string $host - * @param string $base_path - * @param string $url - * @return string - * - * Initially the trailing slash of $base_path was optional, and conditionally appended. - * However on dynamically created sites, where the page is given as url parameter, - * the base path might not end with an url. - * Therefore do not append a slash, and **require** the $base_url to ending in a slash - * when needed. - * Vice versa, on using the local file system path of a file, make sure that the slash - * is appended (o.k. also for Windows) - */ - public static function build_url($protocol, $host, $base_path, $url) - { - $protocol = mb_strtolower($protocol); - if (empty($protocol)) { - $protocol = "file://"; - } - if ($url === "") { - return null; - } - - $url_lc = mb_strtolower($url); - - // Is the url already fully qualified, a Data URI, or a reference to a named anchor? - // File-protocol URLs may require additional processing (e.g. for URLs with a relative path) - if ( - ( - mb_strpos($url_lc, "://") !== false - && !in_array(substr($url_lc, 0, 7), ["file://", "phar://"], true) - ) - || mb_substr($url_lc, 0, 1) === "#" - || mb_strpos($url_lc, "data:") === 0 - || mb_strpos($url_lc, "mailto:") === 0 - || mb_strpos($url_lc, "tel:") === 0 - ) { - return $url; - } - - $res = ""; - if (strpos($url_lc, "file://") === 0) { - $url = substr($url, 7); - $protocol = "file://"; - } elseif (strpos($url_lc, "phar://") === 0) { - $res = substr($url, strpos($url_lc, ".phar")+5); - $url = substr($url, 7, strpos($url_lc, ".phar")-2); - $protocol = "phar://"; - } - - $ret = ""; - - $is_local_path = in_array($protocol, ["file://", "phar://"], true); - - if ($is_local_path) { - //On Windows local file, an abs path can begin also with a '\' or a drive letter and colon - //drive: followed by a relative path would be a drive specific default folder. - //not known in php app code, treat as abs path - //($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/')) - if ($url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || (mb_strlen($url) > 1 && $url[0] !== '\\' && $url[1] !== ':'))) { - // For rel path and local access we ignore the host, and run the path through realpath() - $ret .= realpath($base_path) . '/'; - } - $ret .= $url; - $ret = preg_replace('/\?(.*)$/', "", $ret); - - $filepath = realpath($ret); - if ($filepath === false) { - return null; - } - - $ret = "$protocol$filepath$res"; - - return $ret; - } - - $ret = $protocol; - // Protocol relative urls (e.g. "//example.org/style.css") - if (strpos($url, '//') === 0) { - $ret .= substr($url, 2); - //remote urls with backslash in html/css are not really correct, but lets be genereous - } elseif ($url[0] === '/' || $url[0] === '\\') { - // Absolute path - $ret .= $host . $url; - } else { - // Relative path - //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : ""; - $ret .= $host . $base_path . $url; - } - - // URL should now be complete, final cleanup - $parsed_url = parse_url($ret); - - // reproduced from https://www.php.net/manual/en/function.parse-url.php#106731 - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; - $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; - $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; - $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; - $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; - - // partially reproduced from https://stackoverflow.com/a/1243431/264628 - /* replace '//' or '/./' or '/foo/../' with '/' */ - $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'); - for ($n=1; $n>0; $path=preg_replace($re, '/', $path, -1, $n)) {} - - $ret = "$scheme$user$pass$host$port$path$query$fragment"; - - return $ret; - } - - /** - * Builds a HTTP Content-Disposition header string using `$dispositionType` - * and `$filename`. - * - * If the filename contains any characters not in the ISO-8859-1 character - * set, a fallback filename will be included for clients not supporting the - * `filename*` parameter. - * - * @param string $dispositionType - * @param string $filename - * @return string - */ - public static function buildContentDispositionHeader($dispositionType, $filename) - { - $encoding = mb_detect_encoding($filename); - $fallbackfilename = mb_convert_encoding($filename, "ISO-8859-1", $encoding); - $fallbackfilename = str_replace("\"", "", $fallbackfilename); - $encodedfilename = rawurlencode($filename); - - $contentDisposition = "Content-Disposition: $dispositionType; filename=\"$fallbackfilename\""; - if ($fallbackfilename !== $filename) { - $contentDisposition .= "; filename*=UTF-8''$encodedfilename"; - } - - return $contentDisposition; - } - - /** - * Converts decimal numbers to roman numerals. - * - * As numbers larger than 3999 (and smaller than 1) cannot be represented in - * the standard form of roman numerals, those are left in decimal form. - * - * See https://en.wikipedia.org/wiki/Roman_numerals#Standard_form - * - * @param int|string $num - * - * @throws Exception - * @return string - */ - public static function dec2roman($num): string - { - - static $ones = ["", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"]; - static $tens = ["", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc"]; - static $hund = ["", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm"]; - static $thou = ["", "m", "mm", "mmm"]; - - if (!is_numeric($num)) { - throw new Exception("dec2roman() requires a numeric argument."); - } - - if ($num >= 4000 || $num <= 0) { - return (string) $num; - } - - $num = strrev((string)$num); - - $ret = ""; - switch (mb_strlen($num)) { - /** @noinspection PhpMissingBreakStatementInspection */ - case 4: - $ret .= $thou[$num[3]]; - /** @noinspection PhpMissingBreakStatementInspection */ - case 3: - $ret .= $hund[$num[2]]; - /** @noinspection PhpMissingBreakStatementInspection */ - case 2: - $ret .= $tens[$num[1]]; - /** @noinspection PhpMissingBreakStatementInspection */ - case 1: - $ret .= $ones[$num[0]]; - default: - break; - } - - return $ret; - } - - /** - * Restrict a length to the given range. - * - * If min > max, the result is min. - * - * @param float $length - * @param float $min - * @param float $max - * - * @return float - */ - public static function clamp(float $length, float $min, float $max): float - { - return max($min, min($length, $max)); - } - - /** - * Determines whether $value is a percentage or not - * - * @param string|float|int $value - * - * @return bool - */ - public static function is_percent($value): bool - { - return is_string($value) && false !== mb_strpos($value, "%"); - } - - /** - * Parses a data URI scheme - * http://en.wikipedia.org/wiki/Data_URI_scheme - * - * @param string $data_uri The data URI to parse - * - * @return array|bool The result with charset, mime type and decoded data - */ - public static function parse_data_uri($data_uri) - { - if (!preg_match('/^data:(?P