Recent Topics

Creative Commons Licenses plugin

Started by on Jan 16, 2008 – Contents updated: Jan 16, 2008

Jan 16, 2008 02:02    

Hi friends. I'm hard at work upgrading my "cc license" plugin. I'm trying to figure out how to internationalize it in the most effective (and legally most correct) manner. The thoughts and opinions of non-US b2evolution users will be appreciated and valued!

B2evolution uses aa-BB where aa is the language and NN is the country code based on an official list of some sort. Creative Commons ports their licenses to match local jurisdictions, and uses "country codes" that can easily be misleading when compared to b2evo's country code portion of locale. For example b2evo knows about "fr-BE" and "nl-BE". There is my dilemma. I can't pick up the locale from the post because (a) I don't know how and (b) it won't help anyway because I would not know which part of b2evolution's locale to use.

Could you imagine a drop-down with [url=http://creativecommons.org/international/]43+ choices[/url] in it? Even with The Admin being able to pick the default "national port", think about the blogger living in a different nation. (Does anyone know how I can tell a plugin to remember a setting on a per-blogger basis?)

Next I'm worried about backward compatibility. I think I can handle that, but now that I see where "new" licenses in some nations will be v2.0 or v2.5 or v3.0 I will have to throw away everything I've already completed regarding displaying older licenses.

So please. Share with me your thoughts on how you would like to see this plugin be with regard to non-US users. And have a GREAT day!

Jan 16, 2008 11:22

As well as settings plugins also have user settings :

	/**
	* Defaults for specific settings
	 *
	 * @return array
	 */
	function GetDefaultSettings()
	{
		$r = array(
				'foo_default' => array(
					'label' => T_( 'Plugin setting' ),
					'defaultvalue' => 'bar',
					'type' => 'text',
					'note' => T_( 'This is the default setting for foo. Users can override it in their profile.' ),
				)
			);
		return $r;
	}

	
	/**
	 * Allowing the user to override the default settings
	 *
	 * @return array
	 */
	function GetDefaultUserSettings()
	{
		$r = array(
				'foo' => array(
					'label' => T_( 'User setting' ),
					'defaultvalue' => $this->Settings->get( 'foo_default' ),
					'type' => 'text',
					'note' => T_( 'This is the users setting for foo. It overrides the plugin setting.' ),
				)
			);
		return $r;
	}


	/**
	 * Display a toolbar in admin
	 *
	 * @param array Associative array of parameters
	 * @return boolean did we display a toolbar?
	 */
	function AdminDisplayToolbar( & $params )
	{
		echo '<p>Your foo is : '. $this->UserSettings->get('foo').'</p>';
		return true;
	}

¥

Jan 16, 2008 15:24

Hooray! The plugin always used 2 lines due to the length of the longest license available. The "add me" button was the only thing on the second line :roll: So I'll put the dropdown for national jurisdiction there and include defaultusersettings for both license and nation.

This is fun!

Jan 16, 2008 16:04

Question just in case someone who knows comes along before I figure it out: When I set a default value in "GetDefaultSettings" is that what will automagically become the default value for "GetDefaultUserSettings"?

Also how would I code this in order to get the User's Settings?

	echo '<option value="2.5-ch"';
	if ( $this->Settings->get('cc_license_nation') == '2.5-ch' ) {
		echo ' selected';
		}
	echo '>Switzerland</option>';

Or will that also automagically grab DefaultUserSettings, which possibly might still be DefaultSettings?

Jan 16, 2008 17:25

As long as you tell the GetDefaultUserSettings to use the GetDefaultSettings as the default :

    /**
     * Allowing the user to override the default settings
     *
     * @return array
     */
    function GetDefaultUserSettings()
    {
        $r = array(
                'cc_license_nation' => array(
                    'label' => T_( 'Nation' ),
                    'defaultvalue' => $this->Settings->get( 'cc_license_nation' ),
                    'type' => 'text',
                    'note' => T_( 'This is the users setting for nation. It overrides the plugin setting.' ),
                )
            );
        return $r;
    } 

Then you just change your $this->Settings->get to $this->UserSettings->get( 'cc_license_nation' ) wherever you want to use them :

   echo '<option value="2.5-ch"';
   if ( $this->UserSettings->get('cc_license_nation') == '2.5-ch' ) {
      echo ' selected';
      }
   echo '>Switzerland</option>'; 

¥

Jan 16, 2008 18:13

Cool - thanks!

I blew up everything again, so I'm echoing and print_ring like crazy to find what I buggered up. Close though. Real close ... to a version that will be workable but will NOT support older existing licenses. I'm keeping placeholders for building that in though because it's important to me to make it happen.

BTW the problem with CCLs is that they used to say "okay for a different language we will add "deed.nn/" (where nn is the language) to the end of a license and translate it". NOW they say "each country that has ported CCLs has a unique license that aligns with local laws and the URLs will have "/ver/nn" in it, where ver is the ported version and nn is the country code".

They then offer translations of that localized license. For example http://creativecommons.org/licenses/by/3.0/rs/ A better example is to compare two ported licenses that are both in English: http://creativecommons.org/licenses/by/2.0/uk/ versus http://creativecommons.org/licenses/by/3.0/us/ illustrates why basing the code on both version and language doesn't work anymore.

Lotsa fun! :D

Yeah and thanks again!!!


Form is loading...

Advanced CMS – This forum is powered by b2evolution CMS, a complete engine for your website.