Yii Framework Forum: Aii Publish Register Behavior extension - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Aii Publish Register Behavior extension part of Aii extensions making publsihing and registering files easier Rate Topic: -----

#1 User is offline   aztech 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 206
  • Joined: 12-December 08
  • Location:Poland

Posted 14 March 2010 - 12:44 PM

download

This behavior implements logic supporting publishing and then registering JS and CSS owner assets,
but may be used for publishing other filetypes as well.
Design of this behavior is focused on supporting widgets with publishing own JS and CSS assets, which usually
are located under widget subdirectory.
This subdirectory needs to be know to this behavior and it can be passed to behavior using {@link basePath} property value. Later, this subdirectory is avaliable also as {basePath} placeholder.
Usually you need to set it during behaviors initialization following
    $this->attachbehavior( 'pubRegManager',
         array(
             'class' => 'AiiPublishRegisterbehavior',
             'cssPath' => false,
             'jsToRegister' => array( 'audio-player.js' ),
             'basePath' => __FILE__,
             'toPublish' => array( 'mp3Folder' => $this->mp3Folder ),
     ) );

If you need to publish assets from directory which is not owner subdirectory you should can do thi with this behavior as well.

Note that you can use also other placeholders when specifying paths to publish
e.g. {assets} which points to {@link assetsPath}
{js} which points to {@link jsPath}
{css} which points to {@link cssPath}

By default behavior initializes all path properties with following value
referencing to some aforementioned placeholders
- {@link assetsPath} is initialized with
{basePath}/assets

- {@link jsPath} is initialized with
{assets}/js

- {@link cssPath} is initialized with
{assets}/css


Hint: you can use {/} as alias for DIRECTORY_SEPARATOR

Note that {@link otherResToPublish} are not set by default.
You can use this e.g. to publish such resorces as audio files, archieves, etc.

If you need to register published CSS and JS files
they need to be listed using properties
(please refer them to see how to specify this files):
- {@link cssToRegister}
- {@link jsToRegister}

You can also register Yii core scripts it owner need them by setting
{@link coreScriptsToRegister}.

Note that by default all JS scripts are registered in head. You can change
this beaavior by setting {@link jsDefaultPos} to one of constant
defined in {@link CClientScript}

All CSS files registered uses media type all. You can change this behavior by
setting {@link defaultMedia} to other value, e.g. screen.

Note that {@link cssToRegister} and {@link jsToRegister} allows to specify
media type and position of registered JS script for each file separatelly.

If you need this behavior just for registering or paths passed to
{@link assetsPath} {@link jsPath} {@link cssPath} are mixture of published
and unpublished path, you can inform this behavior about this by setting
{@link publishingStatus} to proper value. Setted value will inform behavior which
path points is published/unpublished.
For example, value 6 means that ot via {@link cssPath} and {@link jsPath}
are passed published paths.
Set 1 {@link NOT_PUBLISHED} to inform that nothing is published yet
Add 2 {@link JS_PUBLISHED} to inform that {@link jsPath} is published
Add 4 {@link CSS_PUBLISHED} to inform that {@link cssPath} is published
Add 8 {@link ASSETS_PUBLISHED} to inform that {@link assetsPath} is published
Add 16 {@link OTHERS_PUBLISHED} to inform that all resources from {@link otherResToPublish} are published

You can also update status by calling method {@link updateStatus} but we awared
that this method do not check if particular resource is really published.
Note also that calling this method twice for the same resource
will result with unproper {@link publishingStatus} property value.
To be sure that you are not changing status for second time, use method {@link checkIsPublished}

Attached File(s)


I'm not complete idiot... some parts are missing!
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users