All pastes #784981 Raw Edit

create-plugin.php

public php v1 · immutable
·published 2007-11-19 23:32 UTC
rendered paste body
<?phpfunction create_uuid() {   // copied from http://no.php.net/manual/fr/function.uniqid.php#65879   // The field names refer to RFC 4122 section 4.1.2    return sprintf('%04x%04x-%04x-%03x4-%04x-%04x%04x%04x',        mt_rand(0, 65535), mt_rand(0, 65535), // 32 bits for "time_low"        mt_rand(0, 65535), // 16 bits for "time_mid"        mt_rand(0, 4095),  // 12 bits before the 0100 of (version) 4 for "time_hi_and_version"        bindec(substr_replace(sprintf('%016b', mt_rand(0, 65535)), '01', 6, 2)),            // 8 bits, the last two of which (positions 6 and 7) are 01, for "clk_seq_hi_res"            // (hence, the 2nd hex digit after the 3rd hyphen can only be 1, 5, 9 or d)            // 8 bits for "clk_seq_low"        mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535) // 48 bits for "node"    );}if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {?>  Usage:  <?php echo $argv[0]; ?> <plugin name>  <name> is the name of the preformatted Habari plugin you want<?php} else {$myplugin_uuid = create_uuid();$myplugin = <<<EOT<?php/* $$argv[1] Plugin * */class $argv[1] extends Plugin{  function info()  {    return array(      'url'=>'',      'name'=>'$argv[1]',      'license'=>'Apache License 2.0',      'author'=>'',      'version'=>'0.1',    );  }}function action_update_check() {  Update::add( '$argv[1]', '$myplugin_uuid',  \$this->info->version ); );  }public function filter_plugin_config( \$actions, \$plugin_id )       {               if ( \$plugin_id == \$this->plugin_id() ) {                       \$actions[] = _('Configure');               }               return \$actions;       }public function action_plugin_ui( \$plugin_id, \$action )       {               if ( \$plugin_id == \$this->plugin_id() ) {                       switch ( \$action ) {                               case _('Configure') :                                       \$ui = new FormUI( strtolower( get_class( \$this ) ) );                                       \$customvalue= \$ui->add( 'text', 'customvalue', _('Your custom value:') );                                       \$ui->on_success( array( \$this, 'updated_config' ) );                                       \$ui->out();                               break;                       }               }       }public function updated_config( $ui )       {          return true;}?>EOT;echo $myplugin;}?>