Jump to content

Martijn Geerts

PW-Moderators
  • Posts

    2,769
  • Joined

  • Last visited

  • Days Won

    31

Everything posted by Martijn Geerts

  1. I wanted to use Soma's Sliders to generate hsl colours.( 3 sliders ) But Older IE needs rgb. here's just a bunch of code I used/created to manage it. maybe helpful. <?php header("Content-type: text/css"); // rgbToHsl function rgbToHsl ( array $rgb ) { list( $r, $g, $b ) = $rgb; $r/= 255; $g/= 255; $b/= 255; $max = max( $r, $g, $b ); $min = min( $r, $g, $b ); $h; $s; $l = ( $max + $min )/ 2; if ( $max == $min ) { $h = $s = 0; } else { $d = $max - $min; $s = $l > 0.5 ? $d/ ( 2 - $max - $min ) : $d/ ( $max + $min ); switch( $max ) { case $r: $h = ( $g - $b )/ $d + ( $g < $b ? 6 : 0 ); break; case $g: $h = ( $b - $r )/ $d + 2; break; case $b: $h = ( $r - $g )/ $d + 4; break; } $h/= 6; } return array( $h, $s, $l ); } // hslToRgb function hslToRgb ( array $hsl ) { list( $h, $s, $l ) = $hsl; $r; $g; $b; if ( $s == 0 ) { $r = $g = $b = $l; } else { $q = $l < 0.5 ? $l * ( 1 + $s ) : $l + $s - $l * $s; $p = 2 * $l - $q; $r = hueToRgb( $p, $q, $h + 1/ 3 ); $g = hueToRgb( $p, $q, $h ); $b = hueToRgb( $p, $q, $h - 1/ 3 ); } return array( round( $r * 255 ), round( $g * 255 ), round( $b * 255 ) ); } // Convert percentages to points (0-255) function normalizeCssRgb ( array $rgb ) { foreach ( $rgb as &$val ) { if ( strpos( $val, '%' ) !== false ) { $val = str_replace( '%', '', $val ); $val = round( $val * 2.55 ); } } return $rgb; } // cssHslToRgb function cssHslToRgb ( array $hsl ) { // Normalize the hue degree value then convert to float $h = array_shift( $hsl ); $h = $h % 360; if ( $h < 0 ) { $h = 360 + $h; } $h = $h/ 360; // Convert s and l to floats foreach ( $hsl as &$val ) { $val = str_replace( '%', '', $val ); $val/= 100; } list( $s, $l ) = $hsl; $hsl = array( $h, $s, $l ); $rgb = hslToRgb( $hsl ); return $rgb; } // hueToRgb function hueToRgb ( $p, $q, $t ) { if ( $t < 0 ) $t += 1; if ( $t > 1 ) $t -= 1; if ( $t < 1/6 ) return $p + ( $q - $p ) * 6 * $t; if ( $t < 1/2 ) return $q; if ( $t < 2/3 ) return $p + ( $q - $p ) * ( 2/ 3 - $t ) * 6; return $p; } // rgbToHex function rgbToHex ( array $rgb ) { $hex_out = '#'; foreach ( $rgb as $val ) { $hex_out .= str_pad( dechex( $val ), 2, '0', STR_PAD_LEFT ); } return $hex_out; } // hexToRgb function hexToRgb ( $hex ) { $hex = substr( $hex, 1 ); // Handle shortened format if ( strlen( $hex ) === 3 ) { $long_hex = array(); foreach ( str_split( $hex ) as $val ) { $long_hex[] = $val . $val; } $hex = $long_hex; } else { $hex = str_split( $hex, 2 ); } return array_map( 'hexdec', $hex ); } /** * * Output to a "r, g, b" string * */ function colorStringRGB($h, $s, $l ) { $output = ''; $hsl = array($h, $s, $l); $color = cssHslToRgb($hsl); foreach( $color as $rgb ) $output .= $rgb . ', '; $output = rtrim( $output, ', ' ); return $output; } // --------------------------------------------------------------------------------------- $out = ''; $sections = array( 'aa' => 'value-a', 'bb' => 'value-b', 'cc' => 'value-c', 'dd' => 'value-d', 'ee' => 'value-e', 'ff' => 'value-f', 'gg' => 'value-g', ); /** * * Converts HSL to RGB. * * */ $minH = $page->css_hue->min; $maxH = $page->css_hue->max; $count = count($sections); $steps = round(( $maxH - $minH ) / $count); $minL = $page->css_lightness->min; $maxL = $page->css_lightness->max; // l is defined in the foreach $h = $page->css_check == 1 ? $minH : $maxH; $s = $page->css_saturation; foreach($sections as $key => $value) { $out .= "\n\nli." . $key . ' {'; $out .= "\n\t" . 'background-color: rgb(' . colorStringRGB($h, ($s+20), $minL) . ');'; $out .= "\n" . '}'; $out .= "\n"; $out .= "\n\ndiv." . $key . ' {'; $out .= "\n\t" . 'background-color: rgb(' . colorStringRGB($h, ($s+20), $minL) . ');'; $out .= "\n" . '}'; $out .= "\n"; $out .= "\n." . $key . ' .column { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(2n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(3n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(5n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(7n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(11n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(13n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(17n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column:nth-child(23n) { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column.r1.c8 { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $out .= "\n." . $key . ' .column.r3.c1 { background-color: rgb(' . colorStringRGB($h, $s, rand($minL,$maxL)) . '); }'; $h = $page->css_check == 1 ? $h + $steps : $h - $steps; } echo $out; ?>
  2. You could create a styles.php template. And add your colorpicker there. then on top of that PHP file: <?php header("Content-type: text/css"); ?>
  3. Big Thanks Antii...
  4. mindplay.dk & diogo, tnx for sharing. Used this today & love it!
  5. @ Antii, Your module append the styles (ProcessRedirects.css?v=100) to the $config->styles when working in templates (front-end) also. Maybee it's better to check if you're in the admin & then append the style. For now "$config->styles->remove('/site/modules/ProcessRedirects/ProcessRedirects.css?v=100');" solves this 'issue' BTW, I love your module..
  6. Often I use the internal domain names ( in hosts file ) with the extension .local. Sites developing with that extension responds as it should in safari (mac). On Google Chrome however, the respond is very slow. It looks like Google wants to collect as much data posible and before the request is send to apache the data is send to mighty Google. Changing the extension from .local to .loc (in host file ) solves the lagging for me. Hopefully this post is helpful for people experience the same issue.
  7. Good work Teppo ! Sometimes when we ask customers to tell what browser they're using for the admin, the respond with "windows" Thank you for making this module !
  8. Soma has a lot of great modules! Check his teflon admin theme to!
  9. for use in modules: ( after sertain dependencies are loaded ) $this->pages->get('/url/') works everywhere: (maybee some overhead) wire('pages')->get('/url/') works within templates: $pages->get();
  10. @AnotherAndrew, thanks for your reply. There's an discussion here, maybe you're interested.
  11. @ClintonSkakun, thankyou for posting. @AnotherAndrew, ryan is helping users whenever he can. Sometimes I think there are 2 of them. There's a lot of time spend on building the cms, community & modules. PW without formbuilder is fantastic on its own. You don't have to use it. It's good that there are more possibilities. For me buying formbuilder is next to the usefulness also a way to say thank you to ryan.
  12. From ProcessWire I learned the single quote markup attributes. I love those & never used it before I started to work with PW. For associative arrays i like closing parenthese receive an extra tab & the key => value pares to have 2 tabs. $array = array( "foo" => "bar", "bar" => "foo", ); Now with ProcessWire, I struggle less with php style cause I like the style used in the core & modules.
  13. 1000 !!! Thank you Ryan...
  14. Not a real answer. But if a user knows his login/password, let him log-in, after that he can reset the password to what ever he wants. So no need to know the password.
  15. "this request was aborted because it appears to be forged" message is also shown when try to login and cookies are disabled. (Somewhat confusing, better to get a message to enable cookies before tying to login)
  16. Sorry ryan, saw this message today... So you say when hosting a site on server with ext4 file system, there's no real file issue for PW. tnx
  17. Mapping those fonts is indeed tricky and surely not that obvious as doing it with images... Didn't know that IE7 already bocked, thats a good thing. As apeisa mentioned XP sticks on IE8.
  18. I do like your module. Thats for sure. Here's my reply just for the discussion The color issue is no issue, if you use it as pseudo element you could use Soma's beautiful color picker. (love that one) Think there are a lot of opensource icon fonts, although the size would be bigger then all the icons you would use together. But there would be only 1 request instead, think it's quicker. About the older browsers I should agre when it's in the open, but in the admin think it's a good practice to learn editors to use a modern browser. (Maybe even a good idea to block IE7 & lower & serve links to alternatives on PW back-end, as I think that could increase functionality with cleaner code )
  19. 2.2.5 seems to work fine with languages, as a site ( site not yet online ) is working fine with your language url module.
  20. I Think icon fonts is the way to go for pageList icons. And then use them as pseudo elements. This way You're free of screen density & color etc. Then if used a module, everyone could blend it in within their theme.
  21. Love to see the possibilities. I've used Soma's approach for now. Learned a lot today, thanks guys. Tomorrow (boss sends me away now), gonna try to figure out why I can't get the changed value of InputfieldPageListSelect via jQuery. Don't know why I always get the old value. $('#id_of_the_InputfieldPageListSelect').change(function(){ alert('I alert the old value here:' + this.value + 'but want to get the changed value'); });
  22. Yeah did tried it many times, but it didn't function somehow. Now tried again, and it does... Thank you for your time. (did something stupid I think)
  23. Think you're setting the attribute 'value' from the form tag, with the contents of the variable $table. want PW spit out something like this & love nice code without markup. It's not a big problem to do it any other way. <form action="./import"> <table class="AdminDataTable AdminDataList AdminDataTableSortable"> <thead> <tr> <th class="header"> <label><input type="checkbox" id="check_all" value="check_all" checked="checked"> </label></th> <th class="header"></th> <th class="header">YouTube ID</th> <th class="header">YouTube User</th> <th class="header">Title</th> <th class="header">Description</th> </tr> </thead> <tbody> <!-- repeated & repeated --> <tr> <td> <label><input type="checkbox" id="InputfieldCheckbox11" value="mAnUFR5lsiY" checked="checked"> </label></td> <td><div style="position: relative; overflow: hidden;"> <a href="http://i.ytimg.com/vi/mAnUFR5lsiY/0.jpg" class="lightbox"> <img src="http://i.ytimg.com/vi/mAnUFR5lsiY/1.jpg" width="60" height="45" style="margin: -8px 0;"> </a> </div></td> <td><a href="https://www.youtube.com/embed/mAnUFR5lsiY?autoplay=1&fs=1&modestbranding=0&color=white&rel=0&theme=light&autohide=2&enablejsapi=1&showinfo=0&origin=processvideodata" class="iframe video" title="*THROWBACK* Westwood - Ndubz freestyle with Westwood on Radio 1"><span class="icon">►</span> mAnUFR5lsiY</a></td> <td><a href="https://www.youtube.com/profile?user=timwestwoodtv">timwestwoodtv</a></td> <td>*THROWBACK* Westwood - Nd…</td> <td>Westwood in the studio with UK hip hop group NDubz…</td> </tr> <tr> <td> <label><input type="checkbox" id="InputfieldCheckbox60" value="MRiybrVTS90" checked="checked"> </label></td> <td><div style="position: relative; overflow: hidden;"> <a href="http://i.ytimg.com/vi/MRiybrVTS90/0.jpg" class="lightbox"> <img src="http://i.ytimg.com/vi/MRiybrVTS90/1.jpg" width="60" height="45" style="margin: -8px 0;"> </a> </div></td> <td><a href="https://www.youtube.com/embed/MRiybrVTS90?autoplay=1&fs=1&modestbranding=0&color=white&rel=0&theme=light&autohide=2&enablejsapi=1&showinfo=0&origin=processvideodata" class="iframe video" title="Taylor Swift - Begin Again (Single) (full) (LYRICS)"><span class="icon">►</span> MRiybrVTS90</a></td> <td><a href="https://www.youtube.com/profile?user=horcruxkilling">horcruxkilling</a></td> <td>Taylor Swift - Begin Agai…</td> <td>Taylor Swift's second single off of her new album …</td> </tr> </tbody> </table> <p><a href="import/"><button class="ui-button ui-widget ui-state-default ui-corner-all" name="button" value="Import Selected" type="button"><span class="ui-button-text">Import Selected</span></button></a> </p></form>
  24. I'm confused about your "InputfieldForm" solution. The table contains (depending on search) 50 or less rows with checkboxes. @Nik: thank you, I can use your render solution in many other situations to.
  25. Thank you Nik, trying to build a youtube video scraper (based on gData Api) process module. Wich import video id's to pages. Yesterday installed your module at home, didn't looked at the source. Will install it here & gonna check it out. I think i get what you're saying... Thank you Nik for your explanation.
×
×
  • Create New...