@@ -646,13 +646,6 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
|
|||||||
.' alt="" width="16" height="16" />';
|
.' alt="" width="16" height="16" />';
|
||||||
}
|
}
|
||||||
echo __('Edit PDF Pages') . '</a></fieldset>';
|
echo __('Edit PDF Pages') . '</a></fieldset>';
|
||||||
// Export Relational Schema View
|
|
||||||
echo '<fieldset><a href="export_relation_schema.php?' . $url_query . '">';
|
|
||||||
if ($cfg['PropertiesIconic']) {
|
|
||||||
echo '<img class="icon" src="' . $pmaThemeImage . 'b_edit.png"'
|
|
||||||
.' alt="" width="16" height="16" />';
|
|
||||||
}
|
|
||||||
echo __('Export Relational Schema View') . '</a></fieldset>';
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,161 +1,161 @@
|
|||||||
.colorpicker {
|
.colorpicker {
|
||||||
width: 356px;
|
width: 356px;
|
||||||
height: 176px;
|
height: 176px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: url(../images/colorpicker_background.png);
|
background: url(../images/colorpicker_background.png);
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.colorpicker_color {
|
.colorpicker_color {
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
left: 14px;
|
left: 14px;
|
||||||
top: 13px;
|
top: 13px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #f00;
|
background: #f00;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
cursor: crosshair;
|
cursor: crosshair;
|
||||||
}
|
}
|
||||||
.colorpicker_color div {
|
.colorpicker_color div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
background: url(../images/colorpicker_overlay.png);
|
background: url(../images/colorpicker_overlay.png);
|
||||||
}
|
}
|
||||||
.colorpicker_color div div {
|
.colorpicker_color div div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 11px;
|
width: 11px;
|
||||||
height: 11px;
|
height: 11px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: url(../images/colorpicker_select.gif);
|
background: url(../images/colorpicker_select.gif);
|
||||||
margin: -5px 0 0 -5px;
|
margin: -5px 0 0 -5px;
|
||||||
}
|
}
|
||||||
.colorpicker_hue {
|
.colorpicker_hue {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 13px;
|
top: 13px;
|
||||||
left: 171px;
|
left: 171px;
|
||||||
width: 35px;
|
width: 35px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
cursor: n-resize;
|
cursor: n-resize;
|
||||||
}
|
}
|
||||||
.colorpicker_hue div {
|
.colorpicker_hue div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 35px;
|
width: 35px;
|
||||||
height: 9px;
|
height: 9px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: url(../images/colorpicker_indic.gif) left top;
|
background: url(../images/colorpicker_indic.gif) left top;
|
||||||
margin: -4px 0 0 0;
|
margin: -4px 0 0 0;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
}
|
}
|
||||||
.colorpicker_new_color {
|
.colorpicker_new_color {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 60px;
|
width: 60px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
left: 213px;
|
left: 213px;
|
||||||
top: 13px;
|
top: 13px;
|
||||||
background: #f00;
|
background: #f00;
|
||||||
}
|
}
|
||||||
.colorpicker_current_color {
|
.colorpicker_current_color {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 60px;
|
width: 60px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
left: 283px;
|
left: 283px;
|
||||||
top: 13px;
|
top: 13px;
|
||||||
background: #f00;
|
background: #f00;
|
||||||
}
|
}
|
||||||
.colorpicker input {
|
.colorpicker input {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
color: #898989;
|
color: #898989;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
right: 11px;
|
right: 11px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: 11px;
|
height: 11px;
|
||||||
}
|
}
|
||||||
.colorpicker_hex {
|
.colorpicker_hex {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 72px;
|
width: 72px;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
background: url(../images/colorpicker_hex.png) top;
|
background: url(../images/colorpicker_hex.png) top;
|
||||||
left: 212px;
|
left: 212px;
|
||||||
top: 142px;
|
top: 142px;
|
||||||
}
|
}
|
||||||
.colorpicker_hex input {
|
.colorpicker_hex input {
|
||||||
right: 6px;
|
right: 6px;
|
||||||
}
|
}
|
||||||
.colorpicker_field {
|
.colorpicker_field {
|
||||||
height: 22px;
|
height: 22px;
|
||||||
width: 62px;
|
width: 62px;
|
||||||
background-position: top;
|
background-position: top;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
.colorpicker_field span {
|
.colorpicker_field span {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 12px;
|
width: 12px;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
cursor: n-resize;
|
cursor: n-resize;
|
||||||
}
|
}
|
||||||
.colorpicker_rgb_r {
|
.colorpicker_rgb_r {
|
||||||
background-image: url(../images/colorpicker_rgb_r.png);
|
background-image: url(../images/colorpicker_rgb_r.png);
|
||||||
top: 52px;
|
top: 52px;
|
||||||
left: 212px;
|
left: 212px;
|
||||||
}
|
}
|
||||||
.colorpicker_rgb_g {
|
.colorpicker_rgb_g {
|
||||||
background-image: url(../images/colorpicker_rgb_g.png);
|
background-image: url(../images/colorpicker_rgb_g.png);
|
||||||
top: 82px;
|
top: 82px;
|
||||||
left: 212px;
|
left: 212px;
|
||||||
}
|
}
|
||||||
.colorpicker_rgb_b {
|
.colorpicker_rgb_b {
|
||||||
background-image: url(../images/colorpicker_rgb_b.png);
|
background-image: url(../images/colorpicker_rgb_b.png);
|
||||||
top: 112px;
|
top: 112px;
|
||||||
left: 212px;
|
left: 212px;
|
||||||
}
|
}
|
||||||
.colorpicker_hsb_h {
|
.colorpicker_hsb_h {
|
||||||
background-image: url(../images/colorpicker_hsb_h.png);
|
background-image: url(../images/colorpicker_hsb_h.png);
|
||||||
top: 52px;
|
top: 52px;
|
||||||
left: 282px;
|
left: 282px;
|
||||||
}
|
}
|
||||||
.colorpicker_hsb_s {
|
.colorpicker_hsb_s {
|
||||||
background-image: url(../images/colorpicker_hsb_s.png);
|
background-image: url(../images/colorpicker_hsb_s.png);
|
||||||
top: 82px;
|
top: 82px;
|
||||||
left: 282px;
|
left: 282px;
|
||||||
}
|
}
|
||||||
.colorpicker_hsb_b {
|
.colorpicker_hsb_b {
|
||||||
background-image: url(../images/colorpicker_hsb_b.png);
|
background-image: url(../images/colorpicker_hsb_b.png);
|
||||||
top: 112px;
|
top: 112px;
|
||||||
left: 282px;
|
left: 282px;
|
||||||
}
|
}
|
||||||
.colorpicker_submit {
|
.colorpicker_submit {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 22px;
|
width: 22px;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
background: url(../images/colorpicker_submit.png) top;
|
background: url(../images/colorpicker_submit.png) top;
|
||||||
left: 322px;
|
left: 322px;
|
||||||
top: 142px;
|
top: 142px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.colorpicker_focus {
|
.colorpicker_focus {
|
||||||
background-position: center;
|
background-position: center;
|
||||||
}
|
}
|
||||||
.colorpicker_hex.colorpicker_focus {
|
.colorpicker_hex.colorpicker_focus {
|
||||||
background-position: bottom;
|
background-position: bottom;
|
||||||
}
|
}
|
||||||
.colorpicker_submit.colorpicker_focus {
|
.colorpicker_submit.colorpicker_focus {
|
||||||
background-position: bottom;
|
background-position: bottom;
|
||||||
}
|
}
|
||||||
.colorpicker_slider {
|
.colorpicker_slider {
|
||||||
background-position: bottom;
|
background-position: bottom;
|
||||||
}
|
}
|
||||||
|
@@ -1,218 +1,218 @@
|
|||||||
/*body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
|
/*body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
|
||||||
margin:0;
|
margin:0;
|
||||||
padding:0;
|
padding:0;
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
border-collapse:collapse;
|
border-collapse:collapse;
|
||||||
border-spacing:0;
|
border-spacing:0;
|
||||||
}
|
}
|
||||||
fieldset,img {
|
fieldset,img {
|
||||||
border:0;
|
border:0;
|
||||||
}
|
}
|
||||||
address,caption,cite,code,dfn,em,strong,th,var {
|
address,caption,cite,code,dfn,em,strong,th,var {
|
||||||
font-style:normal;
|
font-style:normal;
|
||||||
font-weight:normal;
|
font-weight:normal;
|
||||||
}
|
}
|
||||||
ol,ul {
|
ol,ul {
|
||||||
list-style:none;
|
list-style:none;
|
||||||
}
|
}
|
||||||
caption,th {
|
caption,th {
|
||||||
text-align:left;
|
text-align:left;
|
||||||
}
|
}
|
||||||
h1,h2,h3,h4,h5,h6 {
|
h1,h2,h3,h4,h5,h6 {
|
||||||
font-size:100%;
|
font-size:100%;
|
||||||
font-weight:normal;
|
font-weight:normal;
|
||||||
}
|
}
|
||||||
q:before,q:after {
|
q:before,q:after {
|
||||||
content:'';
|
content:'';
|
||||||
}
|
}
|
||||||
abbr,acronym { border:0;
|
abbr,acronym { border:0;
|
||||||
}
|
}
|
||||||
html, body {
|
html, body {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
color: #52697E;
|
color: #52697E;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
.wrapper {
|
.wrapper {
|
||||||
width: 700px;
|
width: 700px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 21px;
|
font-size: 21px;
|
||||||
height: 47px;
|
height: 47px;
|
||||||
line-height: 47px;
|
line-height: 47px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
.navigationTabs {
|
.navigationTabs {
|
||||||
height: 23px;
|
height: 23px;
|
||||||
line-height: 23px;
|
line-height: 23px;
|
||||||
border-bottom: 1px solid #ccc;
|
border-bottom: 1px solid #ccc;
|
||||||
}
|
}
|
||||||
.navigationTabs li {
|
.navigationTabs li {
|
||||||
float: left;
|
float: left;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
line-height: 23px;
|
line-height: 23px;
|
||||||
padding-right: 3px;
|
padding-right: 3px;
|
||||||
}
|
}
|
||||||
.navigationTabs li a{
|
.navigationTabs li a{
|
||||||
float: left;
|
float: left;
|
||||||
dispaly: block;
|
dispaly: block;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
line-height: 23px;
|
line-height: 23px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
color: #52697E;
|
color: #52697E;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
position: relative;
|
position: relative;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
.navigationTabs li a:hover {
|
.navigationTabs li a:hover {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
}
|
}
|
||||||
.navigationTabs li a.active {
|
.navigationTabs li a.active {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-bottom: 0px solid;
|
border-bottom: 0px solid;
|
||||||
}
|
}
|
||||||
.tabsContent {
|
.tabsContent {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-top: 0px solid;
|
border-top: 0px solid;
|
||||||
width: 698px;
|
width: 698px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.tab {
|
.tab {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.tab h2 {
|
.tab h2 {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
.tab h3 {
|
.tab h3 {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
.tab p {
|
.tab p {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
.tab ul {
|
.tab ul {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
list-style: disc;
|
list-style: disc;
|
||||||
}
|
}
|
||||||
.tab li {
|
.tab li {
|
||||||
margin: 10px 0 0 35px;
|
margin: 10px 0 0 35px;
|
||||||
}
|
}
|
||||||
.tab a {
|
.tab a {
|
||||||
color: #8FB0CF;
|
color: #8FB0CF;
|
||||||
}
|
}
|
||||||
.tab strong {
|
.tab strong {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.tab pre {
|
.tab pre {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
width: 668px;
|
width: 668px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
.tab table {
|
.tab table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.tab table td {
|
.tab table td {
|
||||||
padding: 6px 10px 6px 0;
|
padding: 6px 10px 6px 0;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
.tab dt {
|
.tab dt {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
#colorSelector {
|
#colorSelector {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
background: url(../images/select.png);
|
background: url(../images/select.png);
|
||||||
}
|
}
|
||||||
#colorSelector div {
|
#colorSelector div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 3px;
|
top: 3px;
|
||||||
left: 3px;
|
left: 3px;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
background: url(../images/select.png) center;
|
background: url(../images/select.png) center;
|
||||||
}
|
}
|
||||||
#colorSelector2 {
|
#colorSelector2 {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
background: url(../images/select2.png);
|
background: url(../images/select2.png);
|
||||||
}
|
}
|
||||||
#colorSelector2 div {
|
#colorSelector2 div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
left: 4px;
|
left: 4px;
|
||||||
width: 28px;
|
width: 28px;
|
||||||
height: 28px;
|
height: 28px;
|
||||||
background: url(../images/select2.png) center;
|
background: url(../images/select2.png) center;
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 {
|
#colorpickerHolder2 {
|
||||||
top: 32px;
|
top: 32px;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 356px;
|
width: 356px;
|
||||||
height: 0;
|
height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker {
|
#colorpickerHolder2 .colorpicker {
|
||||||
background-image: url(../images/custom_background.png);
|
background-image: url(../images/custom_background.png);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_hue div {
|
#colorpickerHolder2 .colorpicker_hue div {
|
||||||
background-image: url(../images/custom_indic.gif);
|
background-image: url(../images/custom_indic.gif);
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_hex {
|
#colorpickerHolder2 .colorpicker_hex {
|
||||||
background-image: url(../images/custom_hex.png);
|
background-image: url(../images/custom_hex.png);
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_rgb_r {
|
#colorpickerHolder2 .colorpicker_rgb_r {
|
||||||
background-image: url(../images/custom_rgb_r.png);
|
background-image: url(../images/custom_rgb_r.png);
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_rgb_g {
|
#colorpickerHolder2 .colorpicker_rgb_g {
|
||||||
background-image: url(../images/custom_rgb_g.png);
|
background-image: url(../images/custom_rgb_g.png);
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_rgb_b {
|
#colorpickerHolder2 .colorpicker_rgb_b {
|
||||||
background-image: url(../images/custom_rgb_b.png);
|
background-image: url(../images/custom_rgb_b.png);
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_hsb_s {
|
#colorpickerHolder2 .colorpicker_hsb_s {
|
||||||
background-image: url(../images/custom_hsb_s.png);
|
background-image: url(../images/custom_hsb_s.png);
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_hsb_h {
|
#colorpickerHolder2 .colorpicker_hsb_h {
|
||||||
background-image: url(../images/custom_hsb_h.png);
|
background-image: url(../images/custom_hsb_h.png);
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_hsb_b {
|
#colorpickerHolder2 .colorpicker_hsb_b {
|
||||||
background-image: url(../images/custom_hsb_b.png);
|
background-image: url(../images/custom_hsb_b.png);
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker_submit {
|
#colorpickerHolder2 .colorpicker_submit {
|
||||||
background-image: url(../images/custom_submit.png);
|
background-image: url(../images/custom_submit.png);
|
||||||
}
|
}
|
||||||
#colorpickerHolder2 .colorpicker input {
|
#colorpickerHolder2 .colorpicker input {
|
||||||
color: #778398;
|
color: #778398;
|
||||||
}
|
}
|
||||||
#customWidget {
|
#customWidget {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
}
|
}
|
||||||
|
@@ -1,484 +1,484 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Color picker
|
* Color picker
|
||||||
* Author: Stefan Petre www.eyecon.ro
|
* Author: Stefan Petre www.eyecon.ro
|
||||||
*
|
*
|
||||||
* Dual licensed under the MIT and GPL licenses
|
* Dual licensed under the MIT and GPL licenses
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
(function ($) {
|
(function ($) {
|
||||||
var ColorPicker = function () {
|
var ColorPicker = function () {
|
||||||
var
|
var
|
||||||
ids = {},
|
ids = {},
|
||||||
inAction,
|
inAction,
|
||||||
charMin = 65,
|
charMin = 65,
|
||||||
visible,
|
visible,
|
||||||
tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
|
tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
|
||||||
defaults = {
|
defaults = {
|
||||||
eventName: 'click',
|
eventName: 'click',
|
||||||
onShow: function () {},
|
onShow: function () {},
|
||||||
onBeforeShow: function(){},
|
onBeforeShow: function(){},
|
||||||
onHide: function () {},
|
onHide: function () {},
|
||||||
onChange: function () {},
|
onChange: function () {},
|
||||||
onSubmit: function () {},
|
onSubmit: function () {},
|
||||||
color: 'ff0000',
|
color: 'ff0000',
|
||||||
livePreview: true,
|
livePreview: true,
|
||||||
flat: false
|
flat: false
|
||||||
},
|
},
|
||||||
fillRGBFields = function (hsb, cal) {
|
fillRGBFields = function (hsb, cal) {
|
||||||
var rgb = HSBToRGB(hsb);
|
var rgb = HSBToRGB(hsb);
|
||||||
$(cal).data('colorpicker').fields
|
$(cal).data('colorpicker').fields
|
||||||
.eq(1).val(rgb.r).end()
|
.eq(1).val(rgb.r).end()
|
||||||
.eq(2).val(rgb.g).end()
|
.eq(2).val(rgb.g).end()
|
||||||
.eq(3).val(rgb.b).end();
|
.eq(3).val(rgb.b).end();
|
||||||
},
|
},
|
||||||
fillHSBFields = function (hsb, cal) {
|
fillHSBFields = function (hsb, cal) {
|
||||||
$(cal).data('colorpicker').fields
|
$(cal).data('colorpicker').fields
|
||||||
.eq(4).val(hsb.h).end()
|
.eq(4).val(hsb.h).end()
|
||||||
.eq(5).val(hsb.s).end()
|
.eq(5).val(hsb.s).end()
|
||||||
.eq(6).val(hsb.b).end();
|
.eq(6).val(hsb.b).end();
|
||||||
},
|
},
|
||||||
fillHexFields = function (hsb, cal) {
|
fillHexFields = function (hsb, cal) {
|
||||||
$(cal).data('colorpicker').fields
|
$(cal).data('colorpicker').fields
|
||||||
.eq(0).val(HSBToHex(hsb)).end();
|
.eq(0).val(HSBToHex(hsb)).end();
|
||||||
},
|
},
|
||||||
setSelector = function (hsb, cal) {
|
setSelector = function (hsb, cal) {
|
||||||
$(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
|
$(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
|
||||||
$(cal).data('colorpicker').selectorIndic.css({
|
$(cal).data('colorpicker').selectorIndic.css({
|
||||||
left: parseInt(150 * hsb.s/100, 10),
|
left: parseInt(150 * hsb.s/100, 10),
|
||||||
top: parseInt(150 * (100-hsb.b)/100, 10)
|
top: parseInt(150 * (100-hsb.b)/100, 10)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setHue = function (hsb, cal) {
|
setHue = function (hsb, cal) {
|
||||||
$(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
|
$(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
|
||||||
},
|
},
|
||||||
setCurrentColor = function (hsb, cal) {
|
setCurrentColor = function (hsb, cal) {
|
||||||
$(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
|
$(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
|
||||||
},
|
},
|
||||||
setNewColor = function (hsb, cal) {
|
setNewColor = function (hsb, cal) {
|
||||||
$(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
|
$(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
|
||||||
},
|
},
|
||||||
keyDown = function (ev) {
|
keyDown = function (ev) {
|
||||||
var pressedKey = ev.charCode || ev.keyCode || -1;
|
var pressedKey = ev.charCode || ev.keyCode || -1;
|
||||||
if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
|
if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var cal = $(this).parent().parent();
|
var cal = $(this).parent().parent();
|
||||||
if (cal.data('colorpicker').livePreview === true) {
|
if (cal.data('colorpicker').livePreview === true) {
|
||||||
change.apply(this);
|
change.apply(this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
change = function (ev) {
|
change = function (ev) {
|
||||||
var cal = $(this).parent().parent(), col;
|
var cal = $(this).parent().parent(), col;
|
||||||
if (this.parentNode.className.indexOf('_hex') > 0) {
|
if (this.parentNode.className.indexOf('_hex') > 0) {
|
||||||
cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
|
cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
|
||||||
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
|
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
|
||||||
cal.data('colorpicker').color = col = fixHSB({
|
cal.data('colorpicker').color = col = fixHSB({
|
||||||
h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
|
h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
|
||||||
s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
|
s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
|
||||||
b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
|
b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
|
cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
|
||||||
r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
|
r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
|
||||||
g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
|
g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
|
||||||
b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
|
b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (ev) {
|
if (ev) {
|
||||||
fillRGBFields(col, cal.get(0));
|
fillRGBFields(col, cal.get(0));
|
||||||
fillHexFields(col, cal.get(0));
|
fillHexFields(col, cal.get(0));
|
||||||
fillHSBFields(col, cal.get(0));
|
fillHSBFields(col, cal.get(0));
|
||||||
}
|
}
|
||||||
setSelector(col, cal.get(0));
|
setSelector(col, cal.get(0));
|
||||||
setHue(col, cal.get(0));
|
setHue(col, cal.get(0));
|
||||||
setNewColor(col, cal.get(0));
|
setNewColor(col, cal.get(0));
|
||||||
cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
|
cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
|
||||||
},
|
},
|
||||||
blur = function (ev) {
|
blur = function (ev) {
|
||||||
var cal = $(this).parent().parent();
|
var cal = $(this).parent().parent();
|
||||||
cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
|
cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
|
||||||
},
|
},
|
||||||
focus = function () {
|
focus = function () {
|
||||||
charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
|
charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
|
||||||
$(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
|
$(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
|
||||||
$(this).parent().addClass('colorpicker_focus');
|
$(this).parent().addClass('colorpicker_focus');
|
||||||
},
|
},
|
||||||
downIncrement = function (ev) {
|
downIncrement = function (ev) {
|
||||||
var field = $(this).parent().find('input').focus();
|
var field = $(this).parent().find('input').focus();
|
||||||
var current = {
|
var current = {
|
||||||
el: $(this).parent().addClass('colorpicker_slider'),
|
el: $(this).parent().addClass('colorpicker_slider'),
|
||||||
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
||||||
y: ev.pageY,
|
y: ev.pageY,
|
||||||
field: field,
|
field: field,
|
||||||
val: parseInt(field.val(), 10),
|
val: parseInt(field.val(), 10),
|
||||||
preview: $(this).parent().parent().data('colorpicker').livePreview
|
preview: $(this).parent().parent().data('colorpicker').livePreview
|
||||||
};
|
};
|
||||||
$(document).bind('mouseup', current, upIncrement);
|
$(document).bind('mouseup', current, upIncrement);
|
||||||
$(document).bind('mousemove', current, moveIncrement);
|
$(document).bind('mousemove', current, moveIncrement);
|
||||||
},
|
},
|
||||||
moveIncrement = function (ev) {
|
moveIncrement = function (ev) {
|
||||||
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
|
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
|
||||||
if (ev.data.preview) {
|
if (ev.data.preview) {
|
||||||
change.apply(ev.data.field.get(0), [true]);
|
change.apply(ev.data.field.get(0), [true]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
upIncrement = function (ev) {
|
upIncrement = function (ev) {
|
||||||
change.apply(ev.data.field.get(0), [true]);
|
change.apply(ev.data.field.get(0), [true]);
|
||||||
ev.data.el.removeClass('colorpicker_slider').find('input').focus();
|
ev.data.el.removeClass('colorpicker_slider').find('input').focus();
|
||||||
$(document).unbind('mouseup', upIncrement);
|
$(document).unbind('mouseup', upIncrement);
|
||||||
$(document).unbind('mousemove', moveIncrement);
|
$(document).unbind('mousemove', moveIncrement);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
downHue = function (ev) {
|
downHue = function (ev) {
|
||||||
var current = {
|
var current = {
|
||||||
cal: $(this).parent(),
|
cal: $(this).parent(),
|
||||||
y: $(this).offset().top
|
y: $(this).offset().top
|
||||||
};
|
};
|
||||||
current.preview = current.cal.data('colorpicker').livePreview;
|
current.preview = current.cal.data('colorpicker').livePreview;
|
||||||
$(document).bind('mouseup', current, upHue);
|
$(document).bind('mouseup', current, upHue);
|
||||||
$(document).bind('mousemove', current, moveHue);
|
$(document).bind('mousemove', current, moveHue);
|
||||||
},
|
},
|
||||||
moveHue = function (ev) {
|
moveHue = function (ev) {
|
||||||
change.apply(
|
change.apply(
|
||||||
ev.data.cal.data('colorpicker')
|
ev.data.cal.data('colorpicker')
|
||||||
.fields
|
.fields
|
||||||
.eq(4)
|
.eq(4)
|
||||||
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
|
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
|
||||||
.get(0),
|
.get(0),
|
||||||
[ev.data.preview]
|
[ev.data.preview]
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
upHue = function (ev) {
|
upHue = function (ev) {
|
||||||
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||||
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||||
$(document).unbind('mouseup', upHue);
|
$(document).unbind('mouseup', upHue);
|
||||||
$(document).unbind('mousemove', moveHue);
|
$(document).unbind('mousemove', moveHue);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
downSelector = function (ev) {
|
downSelector = function (ev) {
|
||||||
var current = {
|
var current = {
|
||||||
cal: $(this).parent(),
|
cal: $(this).parent(),
|
||||||
pos: $(this).offset()
|
pos: $(this).offset()
|
||||||
};
|
};
|
||||||
current.preview = current.cal.data('colorpicker').livePreview;
|
current.preview = current.cal.data('colorpicker').livePreview;
|
||||||
$(document).bind('mouseup', current, upSelector);
|
$(document).bind('mouseup', current, upSelector);
|
||||||
$(document).bind('mousemove', current, moveSelector);
|
$(document).bind('mousemove', current, moveSelector);
|
||||||
},
|
},
|
||||||
moveSelector = function (ev) {
|
moveSelector = function (ev) {
|
||||||
change.apply(
|
change.apply(
|
||||||
ev.data.cal.data('colorpicker')
|
ev.data.cal.data('colorpicker')
|
||||||
.fields
|
.fields
|
||||||
.eq(6)
|
.eq(6)
|
||||||
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
|
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
|
||||||
.end()
|
.end()
|
||||||
.eq(5)
|
.eq(5)
|
||||||
.val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
|
.val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
|
||||||
.get(0),
|
.get(0),
|
||||||
[ev.data.preview]
|
[ev.data.preview]
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
upSelector = function (ev) {
|
upSelector = function (ev) {
|
||||||
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||||
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||||
$(document).unbind('mouseup', upSelector);
|
$(document).unbind('mouseup', upSelector);
|
||||||
$(document).unbind('mousemove', moveSelector);
|
$(document).unbind('mousemove', moveSelector);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
enterSubmit = function (ev) {
|
enterSubmit = function (ev) {
|
||||||
$(this).addClass('colorpicker_focus');
|
$(this).addClass('colorpicker_focus');
|
||||||
},
|
},
|
||||||
leaveSubmit = function (ev) {
|
leaveSubmit = function (ev) {
|
||||||
$(this).removeClass('colorpicker_focus');
|
$(this).removeClass('colorpicker_focus');
|
||||||
},
|
},
|
||||||
clickSubmit = function (ev) {
|
clickSubmit = function (ev) {
|
||||||
var cal = $(this).parent();
|
var cal = $(this).parent();
|
||||||
var col = cal.data('colorpicker').color;
|
var col = cal.data('colorpicker').color;
|
||||||
cal.data('colorpicker').origColor = col;
|
cal.data('colorpicker').origColor = col;
|
||||||
setCurrentColor(col, cal.get(0));
|
setCurrentColor(col, cal.get(0));
|
||||||
cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
|
cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
|
||||||
},
|
},
|
||||||
show = function (ev) {
|
show = function (ev) {
|
||||||
var cal = $('#' + $(this).data('colorpickerId'));
|
var cal = $('#' + $(this).data('colorpickerId'));
|
||||||
cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
|
cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
|
||||||
var pos = $(this).offset();
|
var pos = $(this).offset();
|
||||||
var viewPort = getViewport();
|
var viewPort = getViewport();
|
||||||
var top = pos.top + this.offsetHeight;
|
var top = pos.top + this.offsetHeight;
|
||||||
var left = pos.left;
|
var left = pos.left;
|
||||||
if (top + 176 > viewPort.t + viewPort.h) {
|
if (top + 176 > viewPort.t + viewPort.h) {
|
||||||
top -= this.offsetHeight + 176;
|
top -= this.offsetHeight + 176;
|
||||||
}
|
}
|
||||||
if (left + 356 > viewPort.l + viewPort.w) {
|
if (left + 356 > viewPort.l + viewPort.w) {
|
||||||
left -= 356;
|
left -= 356;
|
||||||
}
|
}
|
||||||
cal.css({left: left + 'px', top: top + 'px'});
|
cal.css({left: left + 'px', top: top + 'px'});
|
||||||
if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
|
if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
|
||||||
cal.show();
|
cal.show();
|
||||||
}
|
}
|
||||||
$(document).bind('mousedown', {cal: cal}, hide);
|
$(document).bind('mousedown', {cal: cal}, hide);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
hide = function (ev) {
|
hide = function (ev) {
|
||||||
if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
|
if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
|
||||||
if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
||||||
ev.data.cal.hide();
|
ev.data.cal.hide();
|
||||||
}
|
}
|
||||||
$(document).unbind('mousedown', hide);
|
$(document).unbind('mousedown', hide);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isChildOf = function(parentEl, el, container) {
|
isChildOf = function(parentEl, el, container) {
|
||||||
if (parentEl == el) {
|
if (parentEl == el) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (parentEl.contains) {
|
if (parentEl.contains) {
|
||||||
return parentEl.contains(el);
|
return parentEl.contains(el);
|
||||||
}
|
}
|
||||||
if ( parentEl.compareDocumentPosition ) {
|
if ( parentEl.compareDocumentPosition ) {
|
||||||
return !!(parentEl.compareDocumentPosition(el) & 16);
|
return !!(parentEl.compareDocumentPosition(el) & 16);
|
||||||
}
|
}
|
||||||
var prEl = el.parentNode;
|
var prEl = el.parentNode;
|
||||||
while(prEl && prEl != container) {
|
while(prEl && prEl != container) {
|
||||||
if (prEl == parentEl)
|
if (prEl == parentEl)
|
||||||
return true;
|
return true;
|
||||||
prEl = prEl.parentNode;
|
prEl = prEl.parentNode;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
getViewport = function () {
|
getViewport = function () {
|
||||||
var m = document.compatMode == 'CSS1Compat';
|
var m = document.compatMode == 'CSS1Compat';
|
||||||
return {
|
return {
|
||||||
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
||||||
t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
|
t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
|
||||||
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
|
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
|
||||||
h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
|
h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
fixHSB = function (hsb) {
|
fixHSB = function (hsb) {
|
||||||
return {
|
return {
|
||||||
h: Math.min(360, Math.max(0, hsb.h)),
|
h: Math.min(360, Math.max(0, hsb.h)),
|
||||||
s: Math.min(100, Math.max(0, hsb.s)),
|
s: Math.min(100, Math.max(0, hsb.s)),
|
||||||
b: Math.min(100, Math.max(0, hsb.b))
|
b: Math.min(100, Math.max(0, hsb.b))
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
fixRGB = function (rgb) {
|
fixRGB = function (rgb) {
|
||||||
return {
|
return {
|
||||||
r: Math.min(255, Math.max(0, rgb.r)),
|
r: Math.min(255, Math.max(0, rgb.r)),
|
||||||
g: Math.min(255, Math.max(0, rgb.g)),
|
g: Math.min(255, Math.max(0, rgb.g)),
|
||||||
b: Math.min(255, Math.max(0, rgb.b))
|
b: Math.min(255, Math.max(0, rgb.b))
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
fixHex = function (hex) {
|
fixHex = function (hex) {
|
||||||
var len = 6 - hex.length;
|
var len = 6 - hex.length;
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
var o = [];
|
var o = [];
|
||||||
for (var i=0; i<len; i++) {
|
for (var i=0; i<len; i++) {
|
||||||
o.push('0');
|
o.push('0');
|
||||||
}
|
}
|
||||||
o.push(hex);
|
o.push(hex);
|
||||||
hex = o.join('');
|
hex = o.join('');
|
||||||
}
|
}
|
||||||
return hex;
|
return hex;
|
||||||
},
|
},
|
||||||
HexToRGB = function (hex) {
|
HexToRGB = function (hex) {
|
||||||
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
||||||
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
||||||
},
|
},
|
||||||
HexToHSB = function (hex) {
|
HexToHSB = function (hex) {
|
||||||
return RGBToHSB(HexToRGB(hex));
|
return RGBToHSB(HexToRGB(hex));
|
||||||
},
|
},
|
||||||
RGBToHSB = function (rgb) {
|
RGBToHSB = function (rgb) {
|
||||||
var hsb = {
|
var hsb = {
|
||||||
h: 0,
|
h: 0,
|
||||||
s: 0,
|
s: 0,
|
||||||
b: 0
|
b: 0
|
||||||
};
|
};
|
||||||
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
||||||
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
||||||
var delta = max - min;
|
var delta = max - min;
|
||||||
hsb.b = max;
|
hsb.b = max;
|
||||||
if (max != 0) {
|
if (max != 0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
hsb.s = max != 0 ? 255 * delta / max : 0;
|
hsb.s = max != 0 ? 255 * delta / max : 0;
|
||||||
if (hsb.s != 0) {
|
if (hsb.s != 0) {
|
||||||
if (rgb.r == max) {
|
if (rgb.r == max) {
|
||||||
hsb.h = (rgb.g - rgb.b) / delta;
|
hsb.h = (rgb.g - rgb.b) / delta;
|
||||||
} else if (rgb.g == max) {
|
} else if (rgb.g == max) {
|
||||||
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
||||||
} else {
|
} else {
|
||||||
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hsb.h = -1;
|
hsb.h = -1;
|
||||||
}
|
}
|
||||||
hsb.h *= 60;
|
hsb.h *= 60;
|
||||||
if (hsb.h < 0) {
|
if (hsb.h < 0) {
|
||||||
hsb.h += 360;
|
hsb.h += 360;
|
||||||
}
|
}
|
||||||
hsb.s *= 100/255;
|
hsb.s *= 100/255;
|
||||||
hsb.b *= 100/255;
|
hsb.b *= 100/255;
|
||||||
return hsb;
|
return hsb;
|
||||||
},
|
},
|
||||||
HSBToRGB = function (hsb) {
|
HSBToRGB = function (hsb) {
|
||||||
var rgb = {};
|
var rgb = {};
|
||||||
var h = Math.round(hsb.h);
|
var h = Math.round(hsb.h);
|
||||||
var s = Math.round(hsb.s*255/100);
|
var s = Math.round(hsb.s*255/100);
|
||||||
var v = Math.round(hsb.b*255/100);
|
var v = Math.round(hsb.b*255/100);
|
||||||
if(s == 0) {
|
if(s == 0) {
|
||||||
rgb.r = rgb.g = rgb.b = v;
|
rgb.r = rgb.g = rgb.b = v;
|
||||||
} else {
|
} else {
|
||||||
var t1 = v;
|
var t1 = v;
|
||||||
var t2 = (255-s)*v/255;
|
var t2 = (255-s)*v/255;
|
||||||
var t3 = (t1-t2)*(h%60)/60;
|
var t3 = (t1-t2)*(h%60)/60;
|
||||||
if(h==360) h = 0;
|
if(h==360) h = 0;
|
||||||
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
|
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
|
||||||
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
|
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
|
||||||
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
|
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
|
||||||
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
|
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
|
||||||
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
|
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
|
||||||
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
|
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
|
||||||
else {rgb.r=0; rgb.g=0; rgb.b=0}
|
else {rgb.r=0; rgb.g=0; rgb.b=0}
|
||||||
}
|
}
|
||||||
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
|
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
|
||||||
},
|
},
|
||||||
RGBToHex = function (rgb) {
|
RGBToHex = function (rgb) {
|
||||||
var hex = [
|
var hex = [
|
||||||
rgb.r.toString(16),
|
rgb.r.toString(16),
|
||||||
rgb.g.toString(16),
|
rgb.g.toString(16),
|
||||||
rgb.b.toString(16)
|
rgb.b.toString(16)
|
||||||
];
|
];
|
||||||
$.each(hex, function (nr, val) {
|
$.each(hex, function (nr, val) {
|
||||||
if (val.length == 1) {
|
if (val.length == 1) {
|
||||||
hex[nr] = '0' + val;
|
hex[nr] = '0' + val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return hex.join('');
|
return hex.join('');
|
||||||
},
|
},
|
||||||
HSBToHex = function (hsb) {
|
HSBToHex = function (hsb) {
|
||||||
return RGBToHex(HSBToRGB(hsb));
|
return RGBToHex(HSBToRGB(hsb));
|
||||||
},
|
},
|
||||||
restoreOriginal = function () {
|
restoreOriginal = function () {
|
||||||
var cal = $(this).parent();
|
var cal = $(this).parent();
|
||||||
var col = cal.data('colorpicker').origColor;
|
var col = cal.data('colorpicker').origColor;
|
||||||
cal.data('colorpicker').color = col;
|
cal.data('colorpicker').color = col;
|
||||||
fillRGBFields(col, cal.get(0));
|
fillRGBFields(col, cal.get(0));
|
||||||
fillHexFields(col, cal.get(0));
|
fillHexFields(col, cal.get(0));
|
||||||
fillHSBFields(col, cal.get(0));
|
fillHSBFields(col, cal.get(0));
|
||||||
setSelector(col, cal.get(0));
|
setSelector(col, cal.get(0));
|
||||||
setHue(col, cal.get(0));
|
setHue(col, cal.get(0));
|
||||||
setNewColor(col, cal.get(0));
|
setNewColor(col, cal.get(0));
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
init: function (opt) {
|
init: function (opt) {
|
||||||
opt = $.extend({}, defaults, opt||{});
|
opt = $.extend({}, defaults, opt||{});
|
||||||
if (typeof opt.color == 'string') {
|
if (typeof opt.color == 'string') {
|
||||||
opt.color = HexToHSB(opt.color);
|
opt.color = HexToHSB(opt.color);
|
||||||
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
||||||
opt.color = RGBToHSB(opt.color);
|
opt.color = RGBToHSB(opt.color);
|
||||||
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
||||||
opt.color = fixHSB(opt.color);
|
opt.color = fixHSB(opt.color);
|
||||||
} else {
|
} else {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
if (!$(this).data('colorpickerId')) {
|
if (!$(this).data('colorpickerId')) {
|
||||||
var options = $.extend({}, opt);
|
var options = $.extend({}, opt);
|
||||||
options.origColor = opt.color;
|
options.origColor = opt.color;
|
||||||
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
||||||
$(this).data('colorpickerId', id);
|
$(this).data('colorpickerId', id);
|
||||||
var cal = $(tpl).attr('id', id);
|
var cal = $(tpl).attr('id', id);
|
||||||
if (options.flat) {
|
if (options.flat) {
|
||||||
cal.appendTo(this).show();
|
cal.appendTo(this).show();
|
||||||
} else {
|
} else {
|
||||||
cal.appendTo(document.body);
|
cal.appendTo(document.body);
|
||||||
}
|
}
|
||||||
options.fields = cal
|
options.fields = cal
|
||||||
.find('input')
|
.find('input')
|
||||||
.bind('keyup', keyDown)
|
.bind('keyup', keyDown)
|
||||||
.bind('change', change)
|
.bind('change', change)
|
||||||
.bind('blur', blur)
|
.bind('blur', blur)
|
||||||
.bind('focus', focus);
|
.bind('focus', focus);
|
||||||
cal
|
cal
|
||||||
.find('span').bind('mousedown', downIncrement).end()
|
.find('span').bind('mousedown', downIncrement).end()
|
||||||
.find('>div.colorpicker_current_color').bind('click', restoreOriginal);
|
.find('>div.colorpicker_current_color').bind('click', restoreOriginal);
|
||||||
options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
|
options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
|
||||||
options.selectorIndic = options.selector.find('div div');
|
options.selectorIndic = options.selector.find('div div');
|
||||||
options.el = this;
|
options.el = this;
|
||||||
options.hue = cal.find('div.colorpicker_hue div');
|
options.hue = cal.find('div.colorpicker_hue div');
|
||||||
cal.find('div.colorpicker_hue').bind('mousedown', downHue);
|
cal.find('div.colorpicker_hue').bind('mousedown', downHue);
|
||||||
options.newColor = cal.find('div.colorpicker_new_color');
|
options.newColor = cal.find('div.colorpicker_new_color');
|
||||||
options.currentColor = cal.find('div.colorpicker_current_color');
|
options.currentColor = cal.find('div.colorpicker_current_color');
|
||||||
cal.data('colorpicker', options);
|
cal.data('colorpicker', options);
|
||||||
cal.find('div.colorpicker_submit')
|
cal.find('div.colorpicker_submit')
|
||||||
.bind('mouseenter', enterSubmit)
|
.bind('mouseenter', enterSubmit)
|
||||||
.bind('mouseleave', leaveSubmit)
|
.bind('mouseleave', leaveSubmit)
|
||||||
.bind('click', clickSubmit);
|
.bind('click', clickSubmit);
|
||||||
fillRGBFields(options.color, cal.get(0));
|
fillRGBFields(options.color, cal.get(0));
|
||||||
fillHSBFields(options.color, cal.get(0));
|
fillHSBFields(options.color, cal.get(0));
|
||||||
fillHexFields(options.color, cal.get(0));
|
fillHexFields(options.color, cal.get(0));
|
||||||
setHue(options.color, cal.get(0));
|
setHue(options.color, cal.get(0));
|
||||||
setSelector(options.color, cal.get(0));
|
setSelector(options.color, cal.get(0));
|
||||||
setCurrentColor(options.color, cal.get(0));
|
setCurrentColor(options.color, cal.get(0));
|
||||||
setNewColor(options.color, cal.get(0));
|
setNewColor(options.color, cal.get(0));
|
||||||
if (options.flat) {
|
if (options.flat) {
|
||||||
cal.css({
|
cal.css({
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
display: 'block'
|
display: 'block'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$(this).bind(options.eventName, show);
|
$(this).bind(options.eventName, show);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showPicker: function() {
|
showPicker: function() {
|
||||||
return this.each( function () {
|
return this.each( function () {
|
||||||
if ($(this).data('colorpickerId')) {
|
if ($(this).data('colorpickerId')) {
|
||||||
show.apply(this);
|
show.apply(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
hidePicker: function() {
|
hidePicker: function() {
|
||||||
return this.each( function () {
|
return this.each( function () {
|
||||||
if ($(this).data('colorpickerId')) {
|
if ($(this).data('colorpickerId')) {
|
||||||
$('#' + $(this).data('colorpickerId')).hide();
|
$('#' + $(this).data('colorpickerId')).hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setColor: function(col) {
|
setColor: function(col) {
|
||||||
if (typeof col == 'string') {
|
if (typeof col == 'string') {
|
||||||
col = HexToHSB(col);
|
col = HexToHSB(col);
|
||||||
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
||||||
col = RGBToHSB(col);
|
col = RGBToHSB(col);
|
||||||
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
||||||
col = fixHSB(col);
|
col = fixHSB(col);
|
||||||
} else {
|
} else {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return this.each(function(){
|
return this.each(function(){
|
||||||
if ($(this).data('colorpickerId')) {
|
if ($(this).data('colorpickerId')) {
|
||||||
var cal = $('#' + $(this).data('colorpickerId'));
|
var cal = $('#' + $(this).data('colorpickerId'));
|
||||||
cal.data('colorpicker').color = col;
|
cal.data('colorpicker').color = col;
|
||||||
cal.data('colorpicker').origColor = col;
|
cal.data('colorpicker').origColor = col;
|
||||||
fillRGBFields(col, cal.get(0));
|
fillRGBFields(col, cal.get(0));
|
||||||
fillHSBFields(col, cal.get(0));
|
fillHSBFields(col, cal.get(0));
|
||||||
fillHexFields(col, cal.get(0));
|
fillHexFields(col, cal.get(0));
|
||||||
setHue(col, cal.get(0));
|
setHue(col, cal.get(0));
|
||||||
setSelector(col, cal.get(0));
|
setSelector(col, cal.get(0));
|
||||||
setCurrentColor(col, cal.get(0));
|
setCurrentColor(col, cal.get(0));
|
||||||
setNewColor(col, cal.get(0));
|
setNewColor(col, cal.get(0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
ColorPicker: ColorPicker.init,
|
ColorPicker: ColorPicker.init,
|
||||||
ColorPickerHide: ColorPicker.hidePicker,
|
ColorPickerHide: ColorPicker.hidePicker,
|
||||||
ColorPickerShow: ColorPicker.showPicker,
|
ColorPickerShow: ColorPicker.showPicker,
|
||||||
ColorPickerSetColor: ColorPicker.setColor
|
ColorPickerSetColor: ColorPicker.setColor
|
||||||
});
|
});
|
||||||
})(jQuery)
|
})(jQuery)
|
@@ -1434,14 +1434,8 @@ function refreshDragOption(e) {
|
|||||||
function refreshLayout() {
|
function refreshLayout() {
|
||||||
var elm = $('#pdflayout')
|
var elm = $('#pdflayout')
|
||||||
var orientation = $('#orientation_opt').val();
|
var orientation = $('#orientation_opt').val();
|
||||||
if($('#paper_opt').length==1)
|
var paper = $('#paper_opt').val();
|
||||||
{
|
|
||||||
var paper = $('#paper_opt').val();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var paper = 'A4';
|
|
||||||
}
|
|
||||||
if (orientation == 'P') {
|
if (orientation == 'P') {
|
||||||
posa = 'x';
|
posa = 'x';
|
||||||
posb = 'y';
|
posb = 'y';
|
||||||
@@ -1731,24 +1725,5 @@ $(document).ready(function(){
|
|||||||
insertQuery(evt.target.id);
|
insertQuery(evt.target.id);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#export_type").change(function(){
|
|
||||||
|
|
||||||
if($("#export_type").val()!='pdf')
|
|
||||||
{
|
|
||||||
$("#show_grid_opt").attr("disabled","disabled");
|
|
||||||
$("#orientation_opt").attr("disabled","disabled");
|
|
||||||
$("#with_doc").attr("disabled","disabled");
|
|
||||||
$(this).css("background-color","yellow");
|
|
||||||
|
|
||||||
}
|
|
||||||
if($("#export_type").val()=='pdf')
|
|
||||||
{
|
|
||||||
$("#show_grid_opt").removeAttr("disabled");
|
|
||||||
$("#orientation_opt").removeAttr("disabled");
|
|
||||||
$("#with_doc").removeAttr("disabled","disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,193 +1,193 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_APC
|
* PHPExcel_CachedObjectStorage_APC
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
private $_cachePrefix = null;
|
private $_cachePrefix = null;
|
||||||
|
|
||||||
private $_cacheTime = 600;
|
private $_cacheTime = 600;
|
||||||
|
|
||||||
|
|
||||||
private function _storeData() {
|
private function _storeData() {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
throw new Exception('Failed to store cell in APC');
|
throw new Exception('Failed to store cell in APC');
|
||||||
}
|
}
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
} // function _storeData()
|
} // function _storeData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
}
|
}
|
||||||
$this->_cellCache[$pCoord] = true;
|
$this->_cellCache[$pCoord] = true;
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->_currentObject = $cell;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
* @return void
|
* @return void
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isDataSet($pCoord) {
|
public function isDataSet($pCoord) {
|
||||||
// Check if the requested entry is the current object, or exists in the cache
|
// Check if the requested entry is the current object, or exists in the cache
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
if ($this->_currentObjectID == $pCoord) {
|
if ($this->_currentObjectID == $pCoord) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check if the requested entry still exists in apc
|
// Check if the requested entry still exists in apc
|
||||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||||
if ($success === false) {
|
if ($success === false) {
|
||||||
// Entry no longer exists in APC, so clear it from the cache array
|
// Entry no longer exists in APC, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new Exception('Cell entry no longer exists in APC');
|
throw new Exception('Cell entry no longer exists in APC');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} // function isDataSet()
|
} // function isDataSet()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||||
if ($obj === false) {
|
if ($obj === false) {
|
||||||
// Entry no longer exists in APC, so clear it from the cache array
|
// Entry no longer exists in APC, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new Exception('Cell entry no longer exists in APC');
|
throw new Exception('Cell entry no longer exists in APC');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($obj);
|
$this->_currentObject = unserialize($obj);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach the parent worksheet
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this->_parent);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a cell in cache identified by coordinate address
|
* Delete a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function deleteCacheData($pCoord) {
|
public function deleteCacheData($pCoord) {
|
||||||
// Delete the entry from APC
|
// Delete the entry from APC
|
||||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||||
|
|
||||||
// Delete the entry from our cell address array
|
// Delete the entry from our cell address array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
} // function deleteCacheData()
|
} // function deleteCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
if(!is_null($this->_currentObject)) {
|
if(!is_null($this->_currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->_currentObject = $this->_currentObjectID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the APC cache
|
// Flush the APC cache
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
|
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
|
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||||
|
|
||||||
if (is_null($this->_cachePrefix)) {
|
if (is_null($this->_cachePrefix)) {
|
||||||
if (function_exists('posix_getpid')) {
|
if (function_exists('posix_getpid')) {
|
||||||
$baseUnique = posix_getpid();
|
$baseUnique = posix_getpid();
|
||||||
} else {
|
} else {
|
||||||
$baseUnique = mt_rand();
|
$baseUnique = mt_rand();
|
||||||
}
|
}
|
||||||
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
||||||
$this->_cacheTime = $cacheTime;
|
$this->_cacheTime = $cacheTime;
|
||||||
|
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
$cacheList = $this->getCellList();
|
$cacheList = $this->getCellList();
|
||||||
foreach($cacheList as $cellID) {
|
foreach($cacheList as $cellID) {
|
||||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
||||||
}
|
}
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,153 +1,153 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_CacheBase
|
* PHPExcel_CachedObjectStorage_CacheBase
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_CacheBase {
|
class PHPExcel_CachedObjectStorage_CacheBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent worksheet
|
* Parent worksheet
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Worksheet
|
* @var PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
protected $_parent;
|
protected $_parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The currently active Cell
|
* The currently active Cell
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Cell
|
* @var PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
protected $_currentObject = null;
|
protected $_currentObject = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Coordinate address of the currently active Cell
|
* Coordinate address of the currently active Cell
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_currentObjectID = null;
|
protected $_currentObjectID = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||||
* and indexed by their coordinate address within the worksheet
|
* and indexed by their coordinate address within the worksheet
|
||||||
*
|
*
|
||||||
* @var array of mixed
|
* @var array of mixed
|
||||||
*/
|
*/
|
||||||
protected $_cellCache = array();
|
protected $_cellCache = array();
|
||||||
|
|
||||||
|
|
||||||
public function __construct(PHPExcel_Worksheet $parent) {
|
public function __construct(PHPExcel_Worksheet $parent) {
|
||||||
// Set our parent worksheet.
|
// Set our parent worksheet.
|
||||||
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
|
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
|
||||||
// they are woken from a serialized state
|
// they are woken from a serialized state
|
||||||
$this->_parent = $parent;
|
$this->_parent = $parent;
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
* @return void
|
* @return void
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isDataSet($pCoord) {
|
public function isDataSet($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check if the requested entry exists in the cache
|
// Check if the requested entry exists in the cache
|
||||||
return isset($this->_cellCache[$pCoord]);
|
return isset($this->_cellCache[$pCoord]);
|
||||||
} // function isDataSet()
|
} // function isDataSet()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache
|
* Add or Update a cell in cache
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function updateCacheData(PHPExcel_Cell $cell) {
|
public function updateCacheData(PHPExcel_Cell $cell) {
|
||||||
$pCoord = $cell->getCoordinate();
|
$pCoord = $cell->getCoordinate();
|
||||||
|
|
||||||
return $this->addCacheData($pCoord,$cell);
|
return $this->addCacheData($pCoord,$cell);
|
||||||
} // function updateCacheData()
|
} // function updateCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a cell in cache identified by coordinate address
|
* Delete a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function deleteCacheData($pCoord) {
|
public function deleteCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->_cellCache[$pCoord])) {
|
if (isset($this->_cellCache[$pCoord])) {
|
||||||
$this->_cellCache[$pCoord]->detach();
|
$this->_cellCache[$pCoord]->detach();
|
||||||
unset($this->_cellCache[$pCoord]);
|
unset($this->_cellCache[$pCoord]);
|
||||||
}
|
}
|
||||||
} // function deleteCacheData()
|
} // function deleteCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all cell addresses currently held in cache
|
* Get a list of all cell addresses currently held in cache
|
||||||
*
|
*
|
||||||
* @return array of string
|
* @return array of string
|
||||||
*/
|
*/
|
||||||
public function getCellList() {
|
public function getCellList() {
|
||||||
return array_keys($this->_cellCache);
|
return array_keys($this->_cellCache);
|
||||||
} // function getCellList()
|
} // function getCellList()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort the list of all cell addresses currently held in cache by row and column
|
* Sort the list of all cell addresses currently held in cache by row and column
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function getSortedCellList() {
|
public function getSortedCellList() {
|
||||||
$sortKeys = array();
|
$sortKeys = array();
|
||||||
foreach ($this->_cellCache as $coord => $value) {
|
foreach ($this->_cellCache as $coord => $value) {
|
||||||
preg_match('/^(\w+)(\d+)$/U',$coord,$matches);
|
preg_match('/^(\w+)(\d+)$/U',$coord,$matches);
|
||||||
list(,$colNum,$rowNum) = $matches;
|
list(,$colNum,$rowNum) = $matches;
|
||||||
$sortKeys[$coord] = str_pad($rowNum . str_pad($colNum,3,'@',STR_PAD_LEFT),12,'0',STR_PAD_LEFT);
|
$sortKeys[$coord] = str_pad($rowNum . str_pad($colNum,3,'@',STR_PAD_LEFT),12,'0',STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
asort($sortKeys);
|
asort($sortKeys);
|
||||||
|
|
||||||
return array_keys($sortKeys);
|
return array_keys($sortKeys);
|
||||||
} // function sortCellList()
|
} // function sortCellList()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,143 +1,143 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_DiscISAM
|
* PHPExcel_CachedObjectStorage_DiscISAM
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
private $_fileName = null;
|
private $_fileName = null;
|
||||||
private $_fileHandle = null;
|
private $_fileHandle = null;
|
||||||
|
|
||||||
|
|
||||||
private function _storeData() {
|
private function _storeData() {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
fseek($this->_fileHandle,0,SEEK_END);
|
fseek($this->_fileHandle,0,SEEK_END);
|
||||||
$offset = ftell($this->_fileHandle);
|
$offset = ftell($this->_fileHandle);
|
||||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||||
'sz' => ftell($this->_fileHandle) - $offset
|
'sz' => ftell($this->_fileHandle) - $offset
|
||||||
);
|
);
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
} // function _storeData()
|
} // function _storeData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->_currentObject = $cell;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
if (!isset($this->_cellCache[$pCoord])) {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||||
// Re-attach the parent worksheet
|
// Re-attach the parent worksheet
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this->_parent);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
if(!is_null($this->_currentObject)) {
|
if(!is_null($this->_currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->_currentObject = $this->_currentObjectID = null;
|
||||||
}
|
}
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
|
|
||||||
// Close down the temporary cache file
|
// Close down the temporary cache file
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
|
|
||||||
public function __construct(PHPExcel_Worksheet $parent) {
|
public function __construct(PHPExcel_Worksheet $parent) {
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
if (is_null($this->_fileHandle)) {
|
if (is_null($this->_fileHandle)) {
|
||||||
if (function_exists('posix_getpid')) {
|
if (function_exists('posix_getpid')) {
|
||||||
$baseUnique = posix_getpid();
|
$baseUnique = posix_getpid();
|
||||||
} else {
|
} else {
|
||||||
$baseUnique = mt_rand();
|
$baseUnique = mt_rand();
|
||||||
}
|
}
|
||||||
$this->_fileName = sys_get_temp_dir().'/PHPExcel.'.uniqid($baseUnique,true).'.cache';
|
$this->_fileName = sys_get_temp_dir().'/PHPExcel.'.uniqid($baseUnique,true).'.cache';
|
||||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
$this->_fileHandle = fopen($this->_fileName,'a+');
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
if (!is_null($this->_fileHandle)) {
|
if (!is_null($this->_fileHandle)) {
|
||||||
fclose($this->_fileHandle);
|
fclose($this->_fileHandle);
|
||||||
unlink($this->_fileName);
|
unlink($this->_fileName);
|
||||||
}
|
}
|
||||||
$this->_fileHandle = null;
|
$this->_fileHandle = null;
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,214 +1,214 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_Memcache
|
* PHPExcel_CachedObjectStorage_Memcache
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
private $_cachePrefix = null;
|
private $_cachePrefix = null;
|
||||||
|
|
||||||
private $_cacheTime = 600;
|
private $_cacheTime = 600;
|
||||||
|
|
||||||
private $_memcache = null;
|
private $_memcache = null;
|
||||||
|
|
||||||
|
|
||||||
private function _storeData() {
|
private function _storeData() {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
$obj = serialize($this->_currentObject);
|
$obj = serialize($this->_currentObject);
|
||||||
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||||
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
throw new Exception('Failed to store cell in Memcache');
|
throw new Exception('Failed to store cell in Memcache');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
} // function _storeData()
|
} // function _storeData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
}
|
}
|
||||||
$this->_cellCache[$pCoord] = true;
|
$this->_cellCache[$pCoord] = true;
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->_currentObject = $cell;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
* @return void
|
* @return void
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isDataSet($pCoord) {
|
public function isDataSet($pCoord) {
|
||||||
// Check if the requested entry is the current object, or exists in the cache
|
// Check if the requested entry is the current object, or exists in the cache
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
if ($this->_currentObjectID == $pCoord) {
|
if ($this->_currentObjectID == $pCoord) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check if the requested entry still exists in apc
|
// Check if the requested entry still exists in apc
|
||||||
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||||
if ($success === false) {
|
if ($success === false) {
|
||||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new Exception('Cell entry no longer exists in Memcache');
|
throw new Exception('Cell entry no longer exists in Memcache');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} // function isDataSet()
|
} // function isDataSet()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||||
if ($obj === false) {
|
if ($obj === false) {
|
||||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new Exception('Cell entry no longer exists in Memcache');
|
throw new Exception('Cell entry no longer exists in Memcache');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($obj);
|
$this->_currentObject = unserialize($obj);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach the parent worksheet
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this->_parent);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a cell in cache identified by coordinate address
|
* Delete a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function deleteCacheData($pCoord) {
|
public function deleteCacheData($pCoord) {
|
||||||
// Delete the entry from Memcache
|
// Delete the entry from Memcache
|
||||||
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
|
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
|
||||||
|
|
||||||
// Delete the entry from our cell address array
|
// Delete the entry from our cell address array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
} // function deleteCacheData()
|
} // function deleteCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
if(!is_null($this->_currentObject)) {
|
if(!is_null($this->_currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->_currentObject = $this->_currentObjectID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the Memcache cache
|
// Flush the Memcache cache
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
|
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
|
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||||
|
|
||||||
if (is_null($this->_cachePrefix)) {
|
if (is_null($this->_cachePrefix)) {
|
||||||
if (function_exists('posix_getpid')) {
|
if (function_exists('posix_getpid')) {
|
||||||
$baseUnique = posix_getpid();
|
$baseUnique = posix_getpid();
|
||||||
} else {
|
} else {
|
||||||
$baseUnique = mt_rand();
|
$baseUnique = mt_rand();
|
||||||
}
|
}
|
||||||
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
||||||
|
|
||||||
// Set a new Memcache object and connect to the Memcache server
|
// Set a new Memcache object and connect to the Memcache server
|
||||||
$this->_memcache = new Memcache();
|
$this->_memcache = new Memcache();
|
||||||
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback')) {
|
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback')) {
|
||||||
throw new Exception('Could not connect to Memcache server at '.$memcacheServer.':'.$memcachePort);
|
throw new Exception('Could not connect to Memcache server at '.$memcacheServer.':'.$memcachePort);
|
||||||
}
|
}
|
||||||
$this->_cacheTime = $cacheTime;
|
$this->_cacheTime = $cacheTime;
|
||||||
|
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
public function failureCallback($host, $port) {
|
public function failureCallback($host, $port) {
|
||||||
throw new Exception('memcache '.$host.':'.$port' failed');
|
throw new Exception('memcache '.$host.':'.$port' failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
$cacheList = $this->getCellList();
|
$cacheList = $this->getCellList();
|
||||||
foreach($cacheList as $cellID) {
|
foreach($cacheList as $cellID) {
|
||||||
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
|
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
|
||||||
}
|
}
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,85 +1,85 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_Memory
|
* PHPExcel_CachedObjectStorage_Memory
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
$this->_cellCache[$pCoord] = $cell;
|
$this->_cellCache[$pCoord] = $cell;
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
if (!isset($this->_cellCache[$pCoord])) {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_cellCache[$pCoord];
|
return $this->_cellCache[$pCoord];
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
||||||
foreach($this->_cellCache as $k => &$cell) {
|
foreach($this->_cellCache as $k => &$cell) {
|
||||||
$cell->detach();
|
$cell->detach();
|
||||||
$this->_cellCache[$k] = null;
|
$this->_cellCache[$k] = null;
|
||||||
}
|
}
|
||||||
unset($cell);
|
unset($cell);
|
||||||
|
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,107 +1,107 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_MemoryGZip
|
* PHPExcel_CachedObjectStorage_MemoryGZip
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
private function _storeData() {
|
private function _storeData() {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
|
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
} // function _storeData()
|
} // function _storeData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->_currentObject = $cell;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
if (!isset($this->_cellCache[$pCoord])) {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
||||||
// Re-attach the parent worksheet
|
// Re-attach the parent worksheet
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this->_parent);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
if(!is_null($this->_currentObject)) {
|
if(!is_null($this->_currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->_currentObject = $this->_currentObjectID = null;
|
||||||
}
|
}
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,107 +1,107 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_MemorySerialized
|
* PHPExcel_CachedObjectStorage_MemorySerialized
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
private function _storeData() {
|
private function _storeData() {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
|
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
} // function _storeData()
|
} // function _storeData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->_currentObject = $cell;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
if (!isset($this->_cellCache[$pCoord])) {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach the parent worksheet
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this->_parent);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
if(!is_null($this->_currentObject)) {
|
if(!is_null($this->_currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->_currentObject = $this->_currentObjectID = null;
|
||||||
}
|
}
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,137 +1,137 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_PHPTemp
|
* PHPExcel_CachedObjectStorage_PHPTemp
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
private $_fileHandle = null;
|
private $_fileHandle = null;
|
||||||
|
|
||||||
|
|
||||||
private function _storeData() {
|
private function _storeData() {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
fseek($this->_fileHandle,0,SEEK_END);
|
fseek($this->_fileHandle,0,SEEK_END);
|
||||||
$offset = ftell($this->_fileHandle);
|
$offset = ftell($this->_fileHandle);
|
||||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||||
'sz' => ftell($this->_fileHandle) - $offset
|
'sz' => ftell($this->_fileHandle) - $offset
|
||||||
);
|
);
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
} // function _storeData()
|
} // function _storeData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->_currentObject = $cell;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
if (!isset($this->_cellCache[$pCoord])) {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||||
// Re-attach the parent worksheet
|
// Re-attach the parent worksheet
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this->_parent);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
if(!is_null($this->_currentObject)) {
|
if(!is_null($this->_currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->_currentObject = $this->_currentObjectID = null;
|
||||||
}
|
}
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
|
|
||||||
// Close down the php://temp file
|
// Close down the php://temp file
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
|
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $memoryCacheSize = '1MB') {
|
public function __construct(PHPExcel_Worksheet $parent, $memoryCacheSize = '1MB') {
|
||||||
$memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
$memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
||||||
|
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
if (is_null($this->_fileHandle)) {
|
if (is_null($this->_fileHandle)) {
|
||||||
$this->_fileHandle = fopen('php://temp/maxmemory:'.$memoryCacheSize,'a+');
|
$this->_fileHandle = fopen('php://temp/maxmemory:'.$memoryCacheSize,'a+');
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
if (!is_null($this->_fileHandle)) {
|
if (!is_null($this->_fileHandle)) {
|
||||||
fclose($this->_fileHandle);
|
fclose($this->_fileHandle);
|
||||||
}
|
}
|
||||||
$this->_fileHandle = null;
|
$this->_fileHandle = null;
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,201 +1,201 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2010 PHPExcel
|
* Copyright (c) 2006 - 2010 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 1.7.3c, 2010-06-01
|
* @version 1.7.3c, 2010-06-01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_CachedObjectStorage_Wincache
|
* PHPExcel_CachedObjectStorage_Wincache
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_CachedObjectStorage
|
* @package PHPExcel_CachedObjectStorage
|
||||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||||
|
|
||||||
private $_cachePrefix = null;
|
private $_cachePrefix = null;
|
||||||
|
|
||||||
private $_cacheTime = 600;
|
private $_cacheTime = 600;
|
||||||
|
|
||||||
|
|
||||||
private function _storeData() {
|
private function _storeData() {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
$obj = serialize($this->_currentObject);
|
$obj = serialize($this->_currentObject);
|
||||||
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
|
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
|
||||||
wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
|
wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
|
||||||
} else {
|
} else {
|
||||||
wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
|
wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = null;
|
||||||
} // function _storeData()
|
} // function _storeData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache identified by coordinate address
|
* Add or Update a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
}
|
}
|
||||||
$this->_cellCache[$pCoord] = true;
|
$this->_cellCache[$pCoord] = true;
|
||||||
|
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = $cell;
|
$this->_currentObject = $cell;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to check
|
* @param string $pCoord Coordinate address of the cell to check
|
||||||
* @return void
|
* @return void
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isDataSet($pCoord) {
|
public function isDataSet($pCoord) {
|
||||||
// Check if the requested entry is the current object, or exists in the cache
|
// Check if the requested entry is the current object, or exists in the cache
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
if ($this->_currentObjectID == $pCoord) {
|
if ($this->_currentObjectID == $pCoord) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check if the requested entry still exists in cache
|
// Check if the requested entry still exists in cache
|
||||||
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
|
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
|
||||||
if ($success === false) {
|
if ($success === false) {
|
||||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new Exception('Cell entry no longer exists in Wincache');
|
throw new Exception('Cell entry no longer exists in Wincache');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} // function isDataSet()
|
} // function isDataSet()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell at a specific coordinate
|
* Get cell at a specific coordinate
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate of the cell
|
* @param string $pCoord Coordinate of the cell
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
$obj = null;
|
$obj = null;
|
||||||
if (parent::isDataSet($pCoord)) {
|
if (parent::isDataSet($pCoord)) {
|
||||||
$success = false;
|
$success = false;
|
||||||
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
|
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
|
||||||
if ($success === false) {
|
if ($success === false) {
|
||||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
throw new Exception('Cell entry no longer exists in Wincache');
|
throw new Exception('Cell entry no longer exists in Wincache');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($obj);
|
$this->_currentObject = unserialize($obj);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach the parent worksheet
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this->_parent);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a cell in cache identified by coordinate address
|
* Delete a cell in cache identified by coordinate address
|
||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to delete
|
* @param string $pCoord Coordinate address of the cell to delete
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function deleteCacheData($pCoord) {
|
public function deleteCacheData($pCoord) {
|
||||||
// Delete the entry from Wincache
|
// Delete the entry from Wincache
|
||||||
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
|
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||||
|
|
||||||
// Delete the entry from our cell address array
|
// Delete the entry from our cell address array
|
||||||
parent::deleteCacheData($pCoord);
|
parent::deleteCacheData($pCoord);
|
||||||
} // function deleteCacheData()
|
} // function deleteCacheData()
|
||||||
|
|
||||||
|
|
||||||
public function unsetWorksheetCells() {
|
public function unsetWorksheetCells() {
|
||||||
if(!is_null($this->_currentObject)) {
|
if(!is_null($this->_currentObject)) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObject = $this->_currentObjectID = null;
|
$this->_currentObject = $this->_currentObjectID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the Wincache cache
|
// Flush the Wincache cache
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
|
|
||||||
$this->_cellCache = array();
|
$this->_cellCache = array();
|
||||||
|
|
||||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
} // function unsetWorksheetCells()
|
} // function unsetWorksheetCells()
|
||||||
|
|
||||||
|
|
||||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||||
|
|
||||||
if (is_null($this->_cachePrefix)) {
|
if (is_null($this->_cachePrefix)) {
|
||||||
if (function_exists('posix_getpid')) {
|
if (function_exists('posix_getpid')) {
|
||||||
$baseUnique = posix_getpid();
|
$baseUnique = posix_getpid();
|
||||||
} else {
|
} else {
|
||||||
$baseUnique = mt_rand();
|
$baseUnique = mt_rand();
|
||||||
}
|
}
|
||||||
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
||||||
$this->_cacheTime = $cacheTime;
|
$this->_cacheTime = $cacheTime;
|
||||||
|
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
$cacheList = $this->getCellList();
|
$cacheList = $this->getCellList();
|
||||||
foreach($cacheList as $cellID) {
|
foreach($cacheList as $cellID) {
|
||||||
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
|
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
|
||||||
}
|
}
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
@@ -1,131 +1,131 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PHPExcel_CachedObjectStorageFactory {
|
class PHPExcel_CachedObjectStorageFactory {
|
||||||
const cache_in_memory = 'Memory';
|
const cache_in_memory = 'Memory';
|
||||||
const cache_in_memory_gzip = 'MemoryGZip';
|
const cache_in_memory_gzip = 'MemoryGZip';
|
||||||
const cache_in_memory_serialized = 'MemorySerialized';
|
const cache_in_memory_serialized = 'MemorySerialized';
|
||||||
const cache_to_discISAM = 'DiscISAM';
|
const cache_to_discISAM = 'DiscISAM';
|
||||||
const cache_to_apc = 'APC';
|
const cache_to_apc = 'APC';
|
||||||
const cache_to_memcache = 'Memcache';
|
const cache_to_memcache = 'Memcache';
|
||||||
const cache_to_phpTemp = 'PHPTemp';
|
const cache_to_phpTemp = 'PHPTemp';
|
||||||
const cache_to_wincache = 'Wincache';
|
const cache_to_wincache = 'Wincache';
|
||||||
|
|
||||||
|
|
||||||
private static $_cacheStorageMethod = null;
|
private static $_cacheStorageMethod = null;
|
||||||
|
|
||||||
private static $_cacheStorageClass = null;
|
private static $_cacheStorageClass = null;
|
||||||
|
|
||||||
|
|
||||||
private static $_storageMethods = array(
|
private static $_storageMethods = array(
|
||||||
self::cache_in_memory,
|
self::cache_in_memory,
|
||||||
self::cache_in_memory_gzip,
|
self::cache_in_memory_gzip,
|
||||||
self::cache_in_memory_serialized,
|
self::cache_in_memory_serialized,
|
||||||
self::cache_to_phpTemp,
|
self::cache_to_phpTemp,
|
||||||
self::cache_to_discISAM,
|
self::cache_to_discISAM,
|
||||||
self::cache_to_apc,
|
self::cache_to_apc,
|
||||||
self::cache_to_memcache,
|
self::cache_to_memcache,
|
||||||
self::cache_to_wincache,
|
self::cache_to_wincache,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
private static $_storageMethodDefaultParameters = array(
|
private static $_storageMethodDefaultParameters = array(
|
||||||
self::cache_in_memory => array(
|
self::cache_in_memory => array(
|
||||||
),
|
),
|
||||||
self::cache_in_memory_gzip => array(
|
self::cache_in_memory_gzip => array(
|
||||||
),
|
),
|
||||||
self::cache_in_memory_serialized => array(
|
self::cache_in_memory_serialized => array(
|
||||||
),
|
),
|
||||||
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
||||||
),
|
),
|
||||||
self::cache_to_discISAM => array(
|
self::cache_to_discISAM => array(
|
||||||
),
|
),
|
||||||
self::cache_to_apc => array( 'cacheTime' => 600
|
self::cache_to_apc => array( 'cacheTime' => 600
|
||||||
),
|
),
|
||||||
self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
|
self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
|
||||||
'memcachePort' => 11211,
|
'memcachePort' => 11211,
|
||||||
'cacheTime' => 600
|
'cacheTime' => 600
|
||||||
),
|
),
|
||||||
self::cache_to_wincache => array( 'cacheTime' => 600
|
self::cache_to_wincache => array( 'cacheTime' => 600
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
private static $_storageMethodParameters = array();
|
private static $_storageMethodParameters = array();
|
||||||
|
|
||||||
|
|
||||||
public static function getCacheStorageMethod() {
|
public static function getCacheStorageMethod() {
|
||||||
if (!is_null(self::$_cacheStorageMethod)) {
|
if (!is_null(self::$_cacheStorageMethod)) {
|
||||||
return self::$_cacheStorageMethod;
|
return self::$_cacheStorageMethod;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // function getCacheStorageMethod()
|
} // function getCacheStorageMethod()
|
||||||
|
|
||||||
|
|
||||||
public static function getCacheStorageClass() {
|
public static function getCacheStorageClass() {
|
||||||
if (!is_null(self::$_cacheStorageClass)) {
|
if (!is_null(self::$_cacheStorageClass)) {
|
||||||
return self::$_cacheStorageClass;
|
return self::$_cacheStorageClass;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // function getCacheStorageClass()
|
} // function getCacheStorageClass()
|
||||||
|
|
||||||
|
|
||||||
public static function getCacheStorageMethods() {
|
public static function getCacheStorageMethods() {
|
||||||
return self::$_storageMethods;
|
return self::$_storageMethods;
|
||||||
} // function getCacheStorageMethods()
|
} // function getCacheStorageMethods()
|
||||||
|
|
||||||
|
|
||||||
public static function initialize($method = self::cache_in_memory, $arguments = array()) {
|
public static function initialize($method = self::cache_in_memory, $arguments = array()) {
|
||||||
if (!in_array($method,self::$_storageMethods)) {
|
if (!in_array($method,self::$_storageMethods)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($method) {
|
switch($method) {
|
||||||
case self::cache_to_apc :
|
case self::cache_to_apc :
|
||||||
if (!function_exists('apc_store')) {
|
if (!function_exists('apc_store')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (apc_sma_info() === false) {
|
if (apc_sma_info() === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::cache_to_memcache :
|
case self::cache_to_memcache :
|
||||||
if (!function_exists('memcache_add')) {
|
if (!function_exists('memcache_add')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::cache_to_wincache :
|
case self::cache_to_wincache :
|
||||||
if (!function_exists('wincache_ucache_add')) {
|
if (!function_exists('wincache_ucache_add')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
||||||
foreach($arguments as $k => $v) {
|
foreach($arguments as $k => $v) {
|
||||||
if (isset(self::$_storageMethodParameters[$method][$k])) {
|
if (isset(self::$_storageMethodParameters[$method][$k])) {
|
||||||
self::$_storageMethodParameters[$method][$k] = $v;
|
self::$_storageMethodParameters[$method][$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null(self::$_cacheStorageMethod)) {
|
if (is_null(self::$_cacheStorageMethod)) {
|
||||||
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||||
self::$_cacheStorageMethod = $method;
|
self::$_cacheStorageMethod = $method;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} // function initialize()
|
} // function initialize()
|
||||||
|
|
||||||
|
|
||||||
public static function getInstance(PHPExcel_Worksheet $parent) {
|
public static function getInstance(PHPExcel_Worksheet $parent) {
|
||||||
if (is_null(self::$_cacheStorageMethod)) {
|
if (is_null(self::$_cacheStorageMethod)) {
|
||||||
self::initialize();
|
self::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
$instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
|
$instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
|
||||||
if (!is_null($instance)) {
|
if (!is_null($instance)) {
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // function getInstance()
|
} // function getInstance()
|
||||||
|
|
||||||
}
|
}
|
@@ -160,9 +160,9 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
*/
|
*/
|
||||||
public function canRead($pFilename)
|
public function canRead($pFilename)
|
||||||
{
|
{
|
||||||
// Check if zip class exists
|
// Check if zip class exists
|
||||||
if (!class_exists('ZipArchive')) {
|
if (!class_exists('ZipArchive')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -69,11 +69,11 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
|||||||
|
|
||||||
if (is_resource($filename)) {
|
if (is_resource($filename)) {
|
||||||
$this->_FILEH_ = $filename;
|
$this->_FILEH_ = $filename;
|
||||||
} else if ($filename == '-' || $filename == '') {
|
} else if ($filename == '-' || $filename == '') {
|
||||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
|
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
|
||||||
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
|
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
|
||||||
if ($this->_FILEH_ == false) {
|
if ($this->_FILEH_ == false) {
|
||||||
throw new Exception("Can't create temporary file.");
|
throw new Exception("Can't create temporary file.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_FILEH_ = fopen($filename, "wb");
|
$this->_FILEH_ = fopen($filename, "wb");
|
||||||
|
@@ -589,7 +589,7 @@ $cfg['LoginCookieRecall'] = true;
|
|||||||
*
|
*
|
||||||
* @global integer $cfg['LoginCookieValidity']
|
* @global integer $cfg['LoginCookieValidity']
|
||||||
*/
|
*/
|
||||||
$cfg['LoginCookieValidity'] = 99440;
|
$cfg['LoginCookieValidity'] = 1440;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* how long login cookie should be stored (in seconds)
|
* how long login cookie should be stored (in seconds)
|
||||||
|
7
libraries/schema/diaSchema.class.php
Normal file
7
libraries/schema/diaSchema.class.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class diaSchema extends exportRelationSchema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
7
libraries/schema/epsSchema.class.php
Normal file
7
libraries/schema/epsSchema.class.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class epsSchema extends exportRelationSchema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
9
libraries/schema/pdfSchema.class.php
Normal file
9
libraries/schema/pdfSchema.class.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class pdfSchema extends exportRelationSchema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
$pdf= new pdfSchema();
|
||||||
|
$pdf->createPageHTML();
|
||||||
|
?>
|
53
libraries/schema/relationSchema.abstract.class.php
Normal file
53
libraries/schema/relationSchema.abstract.class.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
// Using Abstract Factory Pattern for exporting relational Schema in different Formats !
|
||||||
|
abstract class exportRelationSchema
|
||||||
|
{
|
||||||
|
private $pageTitle; // Title of the page
|
||||||
|
private $autoLayoutType; // Internal or Foreign Key Relations;
|
||||||
|
|
||||||
|
public function setPageTitle($title)
|
||||||
|
{
|
||||||
|
$this->pageTitle=$title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public function createPageHTML()
|
||||||
|
{
|
||||||
|
?>
|
||||||
|
<form method="post" action="pdf_pages.php" name="crpage">
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<?php echo __('Create a page') . "\n"; ?>
|
||||||
|
</legend>
|
||||||
|
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
|
||||||
|
<input type="hidden" name="do" value="createpage" />
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><label for="id_newpage"><?php echo __('Page name'); ?></label></td>
|
||||||
|
<td><input type="text" name="newpage" id="id_newpage" size="20" maxlength="50" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo __('Automatic layout based on'); ?></td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" name="auto_layout_internal" id="id_auto_layout_internal" /><label for="id_auto_layout_internal"><?php echo __('Internal relations'); ?></label><br />
|
||||||
|
<?php
|
||||||
|
if (PMA_StorageEngine::isValid('InnoDB') || PMA_StorageEngine::isValid('PBXT')) {
|
||||||
|
?>
|
||||||
|
<input type="checkbox" name="auto_layout_foreign" id="id_auto_layout_foreign" /><label for="id_auto_layout_foreign">FOREIGN KEY</label><br />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="tblFooters">
|
||||||
|
<input type="submit" value="<?php echo __('Go'); ?>" />
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
libraries/schema/svgSchema.class.php
Normal file
7
libraries/schema/svgSchema.class.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class svgSchema extends exportRelationSchema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
7
libraries/schema/visioSchema.class.php
Normal file
7
libraries/schema/visioSchema.class.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class visioSchema extends exportRelationSchema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
Reference in New Issue
Block a user