Documentation is available at classes_elements_phi.php
- <?php
- class title extends b_element {
- function title( $id, &$object ) {
- //make a title element out of the given element
- parent::b_element( 'div', $id );
- //title text
- $this->appendChild( new b_element( 'h1', NULL, $object->get_index() ) );
- //title icon
- if( $object->icon ) {
- $icon =& $this->appendChild( new b_element( 'img', $id.'_icon', NULL, array( 'src'=>$object->icon) ) );
- }
- //title tagline
- if( $object->tagline ) {
- $this->appendChild( new b_element( 'div', $id.'_tagline', $object->tagline ) );
- }
- }
- }
- class text_area extends b_element {
- var $previewLength = 50;
- function text_area( $id, &$object, $field ) {
- //make a text area out of the given object's given field
- parent::b_element( 'div', $id );
- //NOTE: text parsing here
- $contentPreview = substr( $object->$field, 0, $this->previewLength );
- $elipsis = '... ';
- $contentFull = substr( $object->$field, $this->previewLength + 1 );
- $this->appendChild( new b_element('div', $id.'_preview', $contentPreview ) );
- $this->appendChild( new b_element('div', $id.'_elipsis', $elipsis, array('style'=>'display:none') ) );
- $this->appendChild( new b_element('div', $id.'_full', $contentFull, array('style'=>'width:250px') ) );
- }
- }
- class link extends b_element {
- function link( $content, $href = '#', $attrArray = array() ) {
- if( $attrArray['id'] ) {
- $name = $attrArray['id'];
- unset( $attrArray['id'] );
- } else {
- $name = NULL;
- }
- parent::b_element( 'a', $name, $content, $attrArray );
- }
- }
- class slide_show extends b_element {
- function slide_show( $id, &$object ) {
- //make a slideshow out of the given object
- parent::b_element( 'div', $id );
- $show_images =& $this->appendChild( new b_element( 'div', $id.'_images' ) );
- $show_thumbs =& $this->appendChild( new b_element( 'div', $id.'_thumbs' ) );
- $show_info =&$this->appendChild( new b_element( 'div', $id.'_data' ) );
- if( !$images =& $object->imageArray ) {
- if( $files =& $object->get_files() ) {
- foreach( $files as $file ) {
- if( $file->type->type_class_name == 'image' ) {
- $images[] =& $file;
- }
- }
- } else {
- $images = array();
- }
- }
- foreach( $images as $image ) {
- //set image
- $show_images->appendChild( new b_element( 'img', $id.'_images_'.$image->id, NULL, array( 'src'=>$image->path ) ) );
- //set thumbnail
- $show_images->appendChild( new b_element( 'img', $id.'_thumbs_'.$image->id, NULL, array( 'src'=>$image->thumb_path ) ) );
- //set description
- $data =& $show_images->appendChild( new b_element( 'div', $id.'_data_'.$image->id ) );
- $data->appendChild( new title( $id.'_data_'.$image->id.'_title', $image ) );
- $data->appendChild( new text_area( $id.'_data_'.$image->id.'_description', $image, 'description' ) );
- }
- }
- }
- class meta_data extends b_element {
- function meta_data( $id ) {
- //make a metadata node
- parent::b_element( 'section', $id );
- }
- }
- class data extends b_element {
- function data( $function, $parameters = array() ) {
- parent::b_element( 'data', NULL, NULL, array('function'=>$function) );
- foreach( $parameters as $parameter ) {
- $param =& $this->appendChild( new b_element( 'parameter' ) );
- if( is_array($parameter) ) {
- $json = new JSON();
- $param->setAttribute( 'unserialize', 'true' );
- $param->appendChild( $json->encode( $parameter ) );
- //$param->appendChild(toJScriptArray( $parameter, '~' ));
- //$param->appendChild( serializeToJs( $parameter ) );
- } else {
- $param->appendChild( $parameter );
- }
- }
- }
- }
- function toJScriptArray( $array ) {
- $retString = '{ ';
- foreach( $array as $key => $elem ) {
- if( is_array( $elem ) ) {
- $retString .= $key.' : '.toJScriptArray($elem).',';
- } else {
- $retString .= $key.' : '.$elem.',';
- }
- }
- $retString = rtrim($retString, ',');
- return $retString.' }';
- }
- class cluster extends b_element {
- //var $id =& $this->attributes['id'];
- var $cluster_object;
- /*
- * the constructor takes three parameters
- * object_param: specifies the object which the cluster is to be built around
- * shallow: specifies the starting depth of the cluster to construct
- * deep: specifies the ending depth of the cluster to construct
- */
- function cluster( $object_param = NULL, $deep = NULL, $shallow = NULL ) {
- //format the cluster layer
- $this->id = $object_param?$object_param->id:'root';
- parent::b_element( 'cluster', $this->id, ' ');
- if( $object_param ) {
- $this->cluster_object =& $object_param;
- $this->setAttribute( 'type', $object_param->type->type_name );
- //add content
- //add a title element
- //if the object is a project
- //if there is a description
- //add a textarea
- //if there are pictures
- //add a slideshow
- //if the object is a post
- //add a textarea
- //$data->appendChild( new text_area( $this->cluster_object->id.'_textarea_text', $this->cluster_object, 'text' ) );
- //$this->set_state( NULL, 'default', array( $this->cluster_object->id.'_textarea_text' => array( 'onmousedown'=>'noDrag();' ) ) );
- }
- }
- function &get_state( $stateName, $attribute = NULL ) {
- //locate state
- $stateNameFull = $this->attributes['id'].($attribute?'_'.$attribute:'').'_'.$stateName;
- $state =& $this->getElementById( $stateNameFull );
- if( !$state ) {
- //if the meta section hasn't been created, create it
- if( !$meta =& $this->getElementById( $this->attributes['id'].'_meta' ) ) {
- $meta =& $this->appendChild( new meta_data( $this->attributes['id'].'_meta' ) );
- }
- //if attribute is specified find it and set it to be the state's parent
- if( $attribute && $attribute =& $this->getElementById( $this->attributes['id'].'_'.$attribute ) ) {
- $parent =& $meta->appendChild( new b_element( 'attribute', NULL, NULL, array( 'id'=>$this->attributes['id'].'_'.$attribute ) ) );
- } else {
- $parent =& $meta;
- }
- //append the state to the parent element
- if( $stateName == 'default' ) {
- $state =& $parent->appendChild( new b_element( 'default', NULL, NULL, array( 'id'=> $stateNameFull ) ) );
- } else {
- $state =& $parent->appendChild( new b_element( 'state', NULL, NULL, array( 'id'=> $stateNameFull ) ) );
- }
- }
- return $state;
- }
- function set_state( $attribute, $stateName = 'default', $values = array() ) {
- /*
- * when specifying state name, make sure to specify the partial name, not the full name of the element,
- * so for example if you wanted to set the state 'right' for attribute 'position' in cluster 'root',
- * attribute='position', stateName='right' (stateName != 'root_position_right')
- *
- * values should be an array of tag values indexed by target:
- * [target1][style][value],
- * [class][value],
- * [target2][style][value]...
- */
- $state =& $this->get_state( $stateName, $attribute );
- //set existing tags
- if( $definedTags = $state->getElementsByTagName( 'tag' ) ) {
- foreach( $definedTags as $key => $tag ) {
- if( $target = $values[ $tag->attributes['target'] ] ) {
- $definedTags[$key]->setAttributes( $target, true );
- unset( $values[ $tag->attributes['target'] ] );
- }
- }
- }
- //add new tags
- foreach( $values as $target => $attributes ) {
- $values[$target]['target'] = $target;
- $state->appendChild( new b_element( 'tag', NULL, NULL, $values[$target] ) );
- }
- }
- function set_states( $attribute, $states = array() ) {
- foreach( $states as $key => $state ) {
- $this->set_state( $attribute, $key, $state );
- }
- }
- function getLocalNav() {
- $retObj = new b_element( 'div', $this->id.'_localNav', ' ' );
- //get relationship types
- $related = array();
- if( $relationshipTypes =& $this->cluster_object->get_allowed_relationship_types() ) {
- foreach( $relationshipTypes as $relationshipType ) {
- $related = array_merge( $related, $relationshipType->get_byValue( array( array( 'attribute'=>'primaryID', 'operator'=>'=', 'value'=>$this->id ), array( 'attribute'=>'secondaryID', 'operator'=>'=', 'value'=>$this->id ) ) ) );
- }
- }
- //add links to related by type
- foreach( $relationshipTypes as $relationshipType ) {
- $rType =& $GLOBALS['core']->get_relationship_type( $relationshipType );
- $retObj->appendChild( new link( $rType->name, '#', array('onmouseover'=>'showRelated('.$this->id.','.$relationshipType.');') ) );
- }
- }
- }
- ?>
Documentation generated on Tue, 24 May 2005 03:57:01 -0400 by phpDocumentor 1.3.0RC3