Hello guys, attached i send you a plugin i have put together which allows you to use random colors from adobe's kuler api (http://kuler.adobe.com). Most of the important code is based on work of Niemann Ross (http://niemannross.com/nucleus/index.php?itemid=21).
The plugin works pretty well but i guess someone else (with a little more php experience and an svn account) could extend it much better than i ever could. Hope this is the right place for this and hopefully it finds an adopter. Greets, dh --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/habari-dev -~----------~----~----~----~------~----~------~--~---'kulerHeader', 'version' => '0.1', 'url' => 'http://habari.dahead.de/kulerHeader', 'author' => 'dahead', 'authorurl' => 'http://habari.dahead.de/', 'license' => 'Apache License 2.0', 'description' => 'Adds an Adobe Kuler color scheme to your themes header. Thanks go out to Niemann Ross', 'copyright' => '2008' ); } /** * Add update beacon support **/ public function action_update_check() { Update::add( $this->info->name(), '6552C3D4-616A-11DD-8476-2B1C56D89593', $this->info->version ); } // Plugin UI Options public function filter_plugin_config( $actions, $plugin_id ) { if ( $plugin_id == $this->plugin_id() ) { $actions[]= _t( 'Configure' ); $actions[]= _t( 'Clear Cache' ); } return $actions; } // User Interface Options public function action_plugin_ui( $plugin_id, $action ) { if ( $plugin_id == $this->plugin_id() ) { switch ( $action ) { case _t( 'Configure' ): $ui= new FormUI( strtolower( get_class( $this ) ) ); $ui->append( 'text', 'header_width', 'kulerHeader__header_width', _t( 'Width of your theme header (px): ' ) ); $ui->append( 'text', 'header_height', 'kulerHeader__header_height', _t( 'Height of your theme header (px): ' ) ); $ui->append( 'submit', 'save', 'Save' ); $ui->set_option( 'success_message', _t( 'Configuration saved' ) ); $ui->on_success( array( $this, 'updated_config' ) ); $ui->out(); break; case _t( 'Clear Cache' ): Cache::expire( $this->class_name ); echo '
' . _t( 'Cache has been cleared.' ) . '
'; break; } } } // Set the default options public function action_plugin_activation( $file ) { if ( realpath( $file ) == __FILE__ ) { $this->class_name = strtolower( get_class( $this ) ); } } public function updated_config( $ui ) { $ui->save(); Cache::expire( $this->class_name ); return false; } public function theme_kulerHeader() { if ( $this->plugin_configured() ) { if ( Cache::has( $this->class_name ) ) { $kulerHeader = Cache::get( $this->class_name ); } else { $kulerHeader = $this->getkulerHeader(); Cache::set( $this->class_name, $kulerHeader ); } } else { $kulerHeader = _t( 'Plugin not yet configured' ); } return $kulerHeader; } private function plugin_configured() { if ( empty( $this->config['header_width'] ) || empty( $this->config['header_height'] ) ) { return true; /* Todo: return false; This doesn't work because of the above code. */ } return true; } private function getkulerHeader() { $kulerURL = 'http://kuler.adobe.com/kuler/API/rss/get.cfm?listtype=popular×pan=30'; $kulerRoot = new SimpleXMLElement($kulerURL, NULL, TRUE); $kulerItem = $kulerRoot->channel->item->children('http://kuler.adobe.com/kuler/API/rss/'); $this->previewKulerURL = $kulerItem->themeItem->themeImage; foreach ($kulerItem->themeItem->themeSwatches->swatch as $swatchValues) { $this->swatchHexValues[] = $swatchValues->swatchHexColor ; // echo $swatchValues->swatchHexColor; } for ($i=0;$i<5;$i++) { if (empty($this->swatchHexValues[$i])) $this->swatchHexValues[$i] = dechex(16777216/($i+1)); } $output = "\n"; if ( $this->swatchHexValues) { // create five style-sheets called kulerstyle n // and also create five spans using these styles $style = ''; //$header .= '