Public Member Functions | |
init () | |
Initialises the Class. | |
main () | |
Main Method, rendering either colorpicker or frameset depending on ->showPicker. | |
printContent () | |
Returnes the sourcecode to the browser. | |
frameSet () | |
Returnes a frameset so our JavaScript Reference isn't lost Took some brains to figure this one out ;-) If Peter wouldn't have been I would've gone insane... | |
colorMatrix () | |
Creates a color matrix table. | |
colorList () | |
Creates a selector box with all HTML color names. | |
colorImage () | |
Creates a color image selector. | |
getIndex ($im, $x, $y) | |
Gets the HTML (Hex) Color Code for the selected pixel of an image This method handles the correct imageResource no matter what format. | |
Public Attributes | |
$P | |
$colorValue | |
$fieldChangeFunc | |
$fieldName | |
$formName | |
$md5ID | |
$showPicker | |
$HTMLcolorList = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white" | |
$pickerImage = '' | |
$imageError = '' | |
$doc | |
$content |
|
Creates a color image selector.
Definition at line 383 of file wizard_colorpicker.php. 00383 { 00384 global $LANG; 00385 00386 // Handling color-picker image if any: 00387 if (!$this->imageError) { 00388 if ($this->pickerImage) { 00389 if(t3lib_div::_POST('coords_x')) { 00390 $this->colorValue = '#'.$this->getIndex(t3lib_stdgraphic::imageCreateFromGif($this->pickerImage),t3lib_div::_POST('coords_x'),t3lib_div::_POST('coords_y')); 00391 } 00392 $pickerFormImage = ' 00393 <p class="c-head">'.$LANG->getLL('colorpicker_fromImage',1).'</p> 00394 <input type="image" src="../'.substr($this->pickerImage,strlen(PATH_site)).'" name="coords" style="cursor:crosshair;" /><br />'; 00395 } else { 00396 $pickerFormImage = ''; 00397 } 00398 } else { 00399 $pickerFormImage = ' 00400 <p class="c-head">'.htmlspecialchars($this->imageError).'</p>'; 00401 } 00402 00403 return $pickerFormImage; 00404 }
|
|
Creates a selector box with all HTML color names.
Definition at line 353 of file wizard_colorpicker.php. 00353 { 00354 global $LANG; 00355 00356 // Initialize variables: 00357 $colors = explode(',',$this->HTMLcolorList); 00358 $currentValue = strtolower($this->colorValue); 00359 $opt = array(); 00360 $opt[] = '<option value=""></option>'; 00361 00362 // Traverse colors, making option tags for selector box. 00363 foreach($colors as $colorName) { 00364 $opt[] = '<option style="background-color: '.$colorName.';" value="'.htmlspecialchars($colorName).'"'.($currentValue==$colorName ? ' selected="selected"' : '').'>'.htmlspecialchars($colorName).'</option>'; 00365 } 00366 00367 // Compile selector box and return result: 00368 $output = ' 00369 <p class="c-head">'.$LANG->getLL('colorpicker_fromList',1).'</p> 00370 <select onchange="document.colorform.colorValue.value = this.options[this.selectedIndex].value; document.colorform.submit(); return false;"> 00371 '.implode(' 00372 ',$opt).' 00373 </select><br/>'; 00374 00375 return $output; 00376 }
|
|
Creates a color matrix table.
Definition at line 304 of file wizard_colorpicker.php. References $tRows, and table(). 00304 { 00305 global $LANG; 00306 00307 $steps = 51; 00308 00309 // Get colors: 00310 $color = array(); 00311 00312 for($rr=0;$rr<256;$rr+=$steps) { 00313 for($gg=0;$gg<256;$gg+=$steps) { 00314 for($bb=0;$bb<256;$bb+=$steps) { 00315 $color[] = '#'. 00316 substr('0'.dechex($rr),-2). 00317 substr('0'.dechex($gg),-2). 00318 substr('0'.dechex($bb),-2); 00319 } 00320 } 00321 } 00322 00323 // Traverse colors: 00324 $columns = 24; 00325 00326 $rows = 0; 00327 $tRows = array(); 00328 while(isset($color[$columns*$rows])) { 00329 $tCells = array(); 00330 for($i=0;$i<$columns;$i++) { 00331 $tCells[] = ' 00332 <td bgcolor="'.$color[$columns*$rows+$i].'" onclick="document.colorform.colorValue.value = \''.$color[$columns*$rows+$i].'\'; document.colorform.submit();" title="'.$color[$columns*$rows+$i].'"> </td>'; 00333 } 00334 $tRows[] = ' 00335 <tr>'.implode('',$tCells).' 00336 </tr>'; 00337 $rows++; 00338 } 00339 00340 $table = ' 00341 <p class="c-head">'.$LANG->getLL('colorpicker_fromMatrix',1).'</p> 00342 <table border="0" cellpadding="1" cellspacing="1" style="width:100%; border: 1px solid black; cursor:crosshair;">'.implode('',$tRows).' 00343 </table>'; 00344 00345 return $table; 00346 }
|
|
Returnes a frameset so our JavaScript Reference isn't lost Took some brains to figure this one out ;-) If Peter wouldn't have been I would've gone insane...
Definition at line 245 of file wizard_colorpicker.php. 00245 { 00246 global $LANG; 00247 00248 // Set doktype: 00249 $GLOBALS['TBE_TEMPLATE']->docType = 'xhtml_frames'; 00250 $GLOBALS['TBE_TEMPLATE']->JScode = $GLOBALS['TBE_TEMPLATE']->wrapScriptTags(' 00251 if (!window.opener) { 00252 alert("ERROR: Sorry, no link to main window... Closing"); 00253 close(); 00254 } 00255 '); 00256 00257 $this->content = $GLOBALS['TBE_TEMPLATE']->startPage($LANG->getLL('colorpicker_title')); 00258 00259 // URL for the inner main frame: 00260 $url = 'wizard_colorpicker.php?showPicker=1'. 00261 '&colorValue='.rawurlencode($this->P['currentValue']). 00262 '&fieldName='.rawurlencode($this->P['itemName']). 00263 '&formName='.rawurlencode($this->P['formName']). 00264 '&exampleImg='.rawurlencode($this->P['exampleImg']). 00265 '&md5ID='.rawurlencode($this->P['md5ID']). 00266 '&fieldChangeFunc='.rawurlencode(serialize($this->P['fieldChangeFunc'])); 00267 00268 $this->content.=' 00269 <frameset rows="*,1" framespacing="0" frameborder="0" border="0"> 00270 <frame name="content" src="'.htmlspecialchars($url).'" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" /> 00271 <frame name="menu" src="dummy.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" /> 00272 </frameset> 00273 '; 00274 00275 $this->content.=' 00276 </html>'; 00277 }
|
|
Gets the HTML (Hex) Color Code for the selected pixel of an image This method handles the correct imageResource no matter what format.
Definition at line 416 of file wizard_colorpicker.php. 00416 { 00417 $rgb = ImageColorAt($im, $x, $y); 00418 $colorrgb = imagecolorsforindex($im,$rgb); 00419 $index['r'] = dechex($colorrgb['red']); 00420 $index['g'] = dechex($colorrgb['green']); 00421 $index['b'] = dechex($colorrgb['blue']); 00422 foreach ($index as $value) { 00423 if(strlen($value) == 1) { 00424 $hexvalue[] = strtoupper('0'.$value); 00425 } else { 00426 $hexvalue[] = strtoupper($value); 00427 } 00428 } 00429 $hex = implode('',$hexvalue); 00430 return $hex; 00431 }
|
|
Initialises the Class.
Definition at line 103 of file wizard_colorpicker.php. 00103 { 00104 global $BACK_PATH, $LANG; 00105 00106 // Setting GET vars (used in frameset script): 00107 $this->P = t3lib_div::_GP('P',1); 00108 00109 // Setting GET vars (used in colorpicker script): 00110 $this->colorValue = t3lib_div::_GP('colorValue'); 00111 $this->fieldChangeFunc = t3lib_div::_GP('fieldChangeFunc'); 00112 $this->fieldName = t3lib_div::_GP('fieldName'); 00113 $this->formName = t3lib_div::_GP('formName'); 00114 $this->md5ID = t3lib_div::_GP('md5ID'); 00115 $this->exampleImg = t3lib_div::_GP('exampleImg'); 00116 00117 00118 // Resolving image (checking existence etc.) 00119 $this->imageError = ''; 00120 if ($this->exampleImg) { 00121 $this->pickerImage = t3lib_div::getFileAbsFileName($this->exampleImg,1,1); 00122 if (!$this->pickerImage || !@is_file($this->pickerImage)) { 00123 $this->imageError = 'ERROR: The image, "'.$this->exampleImg.'", could not be found!'; 00124 } 00125 } 00126 00127 // Setting field-change functions: 00128 $fieldChangeFuncArr = unserialize($this->fieldChangeFunc); 00129 $update = ''; 00130 if (is_array($fieldChangeFuncArr)) { 00131 unset($fieldChangeFuncArr['alert']); 00132 foreach($fieldChangeFuncArr as $v) { 00133 $update.= ' 00134 parent.opener.'.$v; 00135 } 00136 } 00137 00138 // Initialize document object: 00139 $this->doc = t3lib_div::makeInstance('smallDoc'); 00140 $this->doc->backPath = $BACK_PATH; 00141 $this->doc->docType = 'xhtml_trans'; 00142 $this->doc->JScode = $this->doc->wrapScriptTags(' 00143 function checkReference() { // 00144 if (parent.opener && parent.opener.document && parent.opener.document.'.$this->formName.' && parent.opener.document.'.$this->formName.'["'.$this->fieldName.'"]) { 00145 return parent.opener.document.'.$this->formName.'["'.$this->fieldName.'"]; 00146 } else { 00147 close(); 00148 } 00149 } 00150 function changeBGcolor(color) { // Changes the color in the table sample back in the TCEform. 00151 if (parent.opener.document.layers) { 00152 parent.opener.document.layers["'.$this->md5ID.'"].bgColor = color; 00153 } else if (parent.opener.document.all) { 00154 parent.opener.document.all["'.$this->md5ID.'"].style.background = color; 00155 } else if (parent.opener.document.getElementById && parent.opener.document.getElementById("'.$this->md5ID.'")) { 00156 parent.opener.document.getElementById("'.$this->md5ID.'").bgColor = color; 00157 } 00158 } 00159 function setValue(input) { // 00160 var field = checkReference(); 00161 if (field) { 00162 field.value = input; 00163 '.$update.' 00164 changeBGcolor(input); 00165 } 00166 } 00167 function getValue() { // 00168 var field = checkReference(); 00169 return field.value; 00170 } 00171 '); 00172 00173 // Start page: 00174 $this->content.=$this->doc->startPage($LANG->getLL('colorpicker_title')); 00175 }
|
|
Main Method, rendering either colorpicker or frameset depending on ->showPicker.
Definition at line 182 of file wizard_colorpicker.php. References $content, and table(). 00182 { 00183 global $LANG; 00184 00185 if(!t3lib_div::_GP('showPicker')) { // Show frameset by default: 00186 $this->frameSet(); 00187 } else { 00188 00189 // Putting together the items into a form: 00190 $content = ' 00191 <form name="colorform" method="post" action="wizard_colorpicker.php"> 00192 '.$this->colorMatrix().' 00193 '.$this->colorList().' 00194 '.$this->colorImage().' 00195 00196 <!-- Value box: --> 00197 <p class="c-head">'.$LANG->getLL('colorpicker_colorValue',1).'</p> 00198 <table border="0" cellpadding="0" cellspacing="3"> 00199 <tr> 00200 <td><input type="text" '.$this->doc->formWidth(7).' maxlength="10" name="colorValue" value="'.htmlspecialchars($this->colorValue).'" /></td> 00201 <td style="background-color:'.htmlspecialchars($this->colorValue).'; border: 1px solid black;"> <span style="color: black;">'.$LANG->getLL('colorpicker_black',1).'</span> <span style="color: white;">'.$LANG->getLL('colorpicker_white',1).'</span> </td> 00202 <td><input type="submit" name="save_close" value="'.$LANG->getLL('colorpicker_setClose',1).'" /></td> 00203 </tr> 00204 </table> 00205 00206 <!-- Hidden fields with values that has to be kept constant --> 00207 <input type="hidden" name="showPicker" value="1" /> 00208 <input type="hidden" name="fieldChangeFunc" value="'.htmlspecialchars($this->fieldChangeFunc).'" /> 00209 <input type="hidden" name="fieldName" value="'.htmlspecialchars($this->fieldName).'" /> 00210 <input type="hidden" name="formName" value="'.htmlspecialchars($this->formName).'" /> 00211 <input type="hidden" name="md5ID" value="'.htmlspecialchars($this->md5ID).'" /> 00212 <input type="hidden" name="exampleImg" value="'.htmlspecialchars($this->exampleImg).'" /> 00213 </form>'; 00214 00215 // If the save/close button is clicked, then close: 00216 if(t3lib_div::_GP('save_close')) { 00217 $content.=$this->doc->wrapScriptTags(' 00218 setValue(\''.$this->colorValue.'\'); 00219 parent.close(); 00220 '); 00221 } 00222 00223 // Output: 00224 $this->content.=$this->doc->section($LANG->getLL('colorpicker_title'), $content, 0,1); 00225 $this->content.=$this->doc->endPage(); 00226 } 00227 }
|
|
Returnes the sourcecode to the browser.
Definition at line 234 of file wizard_colorpicker.php. 00234 { 00235 echo $this->content; 00236 }
|
|
Definition at line 79 of file wizard_colorpicker.php. |
|
Definition at line 93 of file wizard_colorpicker.php. |
|
Definition at line 92 of file wizard_colorpicker.php. |
|
Definition at line 80 of file wizard_colorpicker.php. |
|
Definition at line 81 of file wizard_colorpicker.php. |
|
Definition at line 82 of file wizard_colorpicker.php. |
|
Definition at line 87 of file wizard_colorpicker.php. |
|
Definition at line 91 of file wizard_colorpicker.php. |
|
Definition at line 83 of file wizard_colorpicker.php. |
|
Definition at line 78 of file wizard_colorpicker.php. |
|
Definition at line 90 of file wizard_colorpicker.php. |
|
Definition at line 84 of file wizard_colorpicker.php. |