My Console Application Class Reference

RelationController

Package application.controllers.RelationController
Inheritance class RelationController » Controller » SBaseController » CController » CBaseController » CComponent
Views admin, annotate, create, list, mapMetadata4Copy, mapMetadatas, pdfannoedit, pdfannonew, pdfannoreply, pdfnewcomment, show, update, updaterela, updatereps
Source Code app/controllers/RelationController.php
RelationController defines relation actions, communicates between models and views.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
action CAction the action currently being executed, null if no active action. CController
back Controller
cachingStack CStack stack of COutputCache objects CController
clips CMap Returns the list of clips. CController
defaultAction string specifies the default action to be 'list'. RelationController
id string ID of the controller CController
layout string the default layout for the controller view. Controller
module CWebModule the module that this controller belongs to. CController
pageTitle string the page title. CController
roots Controller
route string the route (module ID, controller ID and action ID) of the current request. CController
selectedTA Controller
tree Controller
uniqueId string the controller ID that is prefixed with the module ID (if any). CController
viewPath string Returns the directory containing view files for this controller. CController

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. CComponent
__construct() CController
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
accessRules() Specifies the access control rules. RelationController
actionAdmin() Manages all models. RelationController
actionAnnotate() Annotates image, video, document, audio relation RelationController
actionCopyMetadata() Copy metadata from file to record RelationController
actionCreate() Creates a new model. RelationController
actionDelete() Deletes a particular model. RelationController
actionDeleteRecRela() Deletes a particular model. RelationController
actionList() Lists all models. RelationController
actionPdfannodel() Deletes pdf annotation RelationController
actionPdfannoedit() Shows pdf annotation dialog edit window RelationController
actionPdfannonew() Shows pdf annotation dialog new window RelationController
actionPdfannoreply() Shows pdf annotation dialog reply window RelationController
actionPdfnewcomment() Shows pdf annotation comment dialog window RelationController
actionShow() Shows a particular model. RelationController
actionUpdate() Updates a particular model. RelationController
actionUpdaterela() Updates a represents relation model. RelationController
actionUpdatereps() Updates a represents relation model, with copy metadata and main main options RelationController
actions() Returns a list of external action classes. CController
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
beginCache() Begins fragment caching. CBaseController
beginClip() Begins recording a clip. CBaseController
beginContent() Begins the rendering of content that is to be decorated by the specified view. CBaseController
beginWidget() Creates a widget and executes it. CBaseController
behaviors() Returns a list of behaviors that this controller should behave as. CController
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
clearPageStates() Removes all page states. CController
copyMetadata() Copy metadata from file to record, filled in metadata only RelationController
copyMetadata2() Copy metadata from file to record RelationController
createAbsoluteUrl() Creates an absolute URL for the specified action defined in this controller. CController
createAction() Creates the action instance based on the action name. CController
createUrl() Creates a relative URL for the specified action defined in this controller. CController
createWidget() Creates a widget and initializes it. CBaseController
delPdfAnno() Deletes pdf annotation RelationController
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
endCache() Ends fragment caching. CBaseController
endClip() Ends recording a clip. CBaseController
endContent() Ends the rendering of content. CBaseController
endWidget() Ends the execution of the named widget. CBaseController
evaluateExpression() Evaluates a PHP expression or callback under the context of this component. CComponent
filterAccessControl() The filter method for 'accessControl' filter. CController
filterAjaxOnly() The filter method for 'ajaxOnly' filter. CController
filterPostOnly() The filter method for 'postOnly' filter. CController
filters() RelationController
forward() Processes the request using another controller action. CController
getAction() Returns the action currently being executed, null if no active action. CController
getCachingStack() Returns stack of COutputCache objects CController
getClips() Returns the list of clips. CController
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getId() Returns ID of the controller CController
getLayoutFile() Looks for the layout view script based on the layout name. CController
getModule() Returns the module that this controller belongs to. It returns null if the controller does not belong to any module CController
getPageState() Returns a persistent page state value. CController
getPageTitle() Returns the page title. Defaults to the controller name and the action name. CController
getPrjMetadataType() Gets project metadata types of a particular entity type RelationController
getRoute() Returns the route (module ID, controller ID and action ID) of the current request. CController
getUniqueId() Returns the controller ID that is prefixed with the module ID (if any). CController
getViewFile() Looks for the view file according to the given view name. CController
getViewPath() Returns the directory containing view files for this controller. CController
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the controller. CController
isCachingStackEmpty() CController
loadrelation() Returns the data model based on the primary key given in the GET variable. RelationController
makeAsMain() Makes a file entity as main representation of a record RelationController
missingAction() Handles the request whose action is not recognized. CController
paginate() Generates pagination information. CController
processDynamicOutput() Postprocesses the dynamic output. CController
processOutput() Postprocesses the output generated by render(). CController
raiseEvent() Raises an event. CComponent
recordCachingAction() Records a method call when an output cache is in effect. CController
redirect() Redirects the browser to the specified URL or route (controller/action). CController
refresh() Refreshes the current page. CController
render() Renders a view with a layout. CController
renderDynamic() Renders dynamic content returned by the specified callback. CController
renderDynamicInternal() This method is internally used. CController
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
renderPartial() Renders a view. CController
renderPartialWithHisOwnClientScript() Controller
renderText() Renders a static text string. CController
resolveViewFile() Finds a view file based on its name. CController
run() Runs the named action. CController
runAction() Runs the action after passing through all filters. CController
runActionWithFilters() Runs an action with the specified filters. CController
searchPdfAnno() Finds pdf annotation RelationController
setAction() Sets the action currently being executed. CController
setPageState() Saves a persistent page state value. CController
setPageTitle() Sets the page title. CController
widget() Creates a widget and executes it. CBaseController

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
afterAction() This method is invoked right after an action is executed. CController
allowedAccess() The auth items that access is always allowed. Configured in srbac module's SBaseController
beforeAction() Checks if srbac access is granted for the current user SBaseController
createActionFromMap() Creates the action instance based on the action map. CController
loadPageStates() Loads page states from a hidden input. CController
onUnauthorizedAccess() SBaseController
processAdminCommand() Executes any command triggered on the admin page. RelationController
replaceDynamicOutput() Replaces the dynamic content placeholders with actual content. CController
savePageStates() Saves page states as a base64 string. CController

Events

Hide inherited events

EventDescriptionDefined By
onUnauthorizedAccess SBaseController

Property Details

defaultAction property
public string $defaultAction;

specifies the default action to be 'list'.

Method Details

accessRules() method
public array accessRules()
{return} array access control rules
Source Code: app/controllers/RelationController.php#35 (show)
public function accessRules()
{
    return array(
/*
        array('allow',  // allow all users to perform 'list' and 'show' actions
            'actions'=>array('list','show'),
            'users'=>array('*'),
        ),
        array('allow', // allow authenticated user to perform 'create' and 'update' actions
            'actions'=>array('create','update','updatereps','updaterela','annotate'),
            'users'=>array('@'),
        ),
        array('allow', // allow admin user to perform 'admin' and 'delete' actions
            'actions'=>array('admin','delete','deleteRecRela'),
            'users'=>array('admin'),
        ),
        array('deny',  // deny all users
            'users'=>array('*'),
        ),*/
    
);
}

Specifies the access control rules. This method is used by the 'accessControl' filter.

actionAdmin() method
public void actionAdmin()
Source Code: app/controllers/RelationController.php#382 (show)
public function actionAdmin()
{
    
$this->processAdminCommand();

    
$criteria=new CDbCriteria;

    
$pages=new CPagination(relation::model()->count($criteria));
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);

    
$sort=new CSort('relation');
    
$sort->applyOrder($criteria);

    
$models=relation::model()->findAll($criteria);

    
$this->render('admin',array(
        
'models'=>$models,
        
'pages'=>$pages,
        
'sort'=>$sort,
    ));
}

Manages all models.

actionAnnotate() method
public void actionAnnotate()
Source Code: app/controllers/RelationController.php#406 (show)
public function actionAnnotate(){
    if(isset(
$_GET['prjId'])&&$_GET['prjId']!=null){
        
$prjId $_GET['prjId'];
        
Yii::app()->setGlobalState('currentProject'$prjId);
    }        
    
$relation $this->loadrelation();
    
//if(($relation->entity1entity->typeId==entityType::DOCUMENT_TYPE) && (preg_match("/\.pdf$/i",$relation->entity1entity->name))){
    
if($relation->entity1entity->typeId==entityType::DOCUMENT_TYPE){
        
$pdfAnnos $this->searchPdfAnno($relation->entity1entity->id$relation->entity2entity->id);
        
$i 0;        
        try{    
            list(
$width$height$type$attr)=getimagesize(Yii::app()->params['ajUrl']."/tmp/documents/".$relation->entity1entity->id."_page-".$i.".jpg"); 
        }catch(
Exception $e){
            list(
$width$height$type$attr)=getimagesize(Yii::app()->params['ajUrl']."/tmp/documents/".$relation->entity1entity->id."_page-".$i.".gif"); 
        }
        while(
file_exists(Yii::app()->params['ajPath']."/tmp/documents/".$relation->entity1entity->id."_page-".$i.".jpg")) {
            
            
$i++;
        }
        if(
$i==1)
        while(
file_exists(Yii::app()->params['ajPath']."/tmp/documents/".$relation->entity1entity->id."_page-".$i.".gif")) {
            
$i++;
        }
        
        
$this->render('annotate',array('relation'=>$relation'pdfAnnos'=>$pdfAnnos'pagenum'=>$i-1'width'=>$width'height'=>$height'username'=>$username));

    }else{
        
$this->render('annotate',array('relation'=>$relation));
    }
}

Annotates image, video, document, audio relation

actionCopyMetadata() method
public void actionCopyMetadata()
Source Code: app/controllers/RelationController.php#147 (show)
public function actionCopyMetadata(){
    if(isset(
$_POST['fileId'])&&isset($_POST['recordId'])){
        
$record entity::model()->findbyPk($_POST['recordId']);
        
$file entity::model()->findbyPk($_POST['fileId']);

        
$recordMetadatas explode("&listItem1[]="$_POST['list1']); //echo $record->id; echo "test<br/>"; 
        
        
$fileMetadatas explode("&listItem2[]="$_POST['list2']);//echo $file->id; echo "test<br/>"; 
        
        
$this->copyMetadata2($file$record$recordMetadatas$fileMetadatas); 
    }
    
$this->redirect(array('record/show','id'=>$record->id));
    
}

Copy metadata from file to record

actionCreate() method
public void actionCreate()
Source Code: app/controllers/RelationController.php#68 (show)
public function actionCreate()
{
    
$model=new relation;
    if(isset(
$_POST['relation']))
    {
        
$model->attributes=$_POST['relation'];
        if(
$model->save())
            
$this->redirect(array('show','entity1'=>$model->entity1,'entity2'=>$model->entity2));
    }
    
$this->render('create',array('model'=>$model));
}

Creates a new model. If creation is successful, the browser will be redirected to the 'show' page.

actionDelete() method
public void actionDelete()
Source Code: app/controllers/RelationController.php#332 (show)
public function actionDelete()
{
    if(
Yii::app()->request->isPostRequest)
    {
        
// we only allow deletion via POST request
        
$this->loadrelation()->delete();
        
$this->redirect(array('list'));
    }
    else
        throw new 
CHttpException(400,'Invalid request. Please do not repeat this request again.');
}

Deletes a particular model. If deletion is successful, the browser will be redirected to the 'list' page.

actionDeleteRecRela() method
public void actionDeleteRecRela()
Source Code: app/controllers/RelationController.php#348 (show)
public function actionDeleteRecRela()
{
    if(
Yii::app()->request->isPostRequest)
    {
        
// we only allow deletion via POST request
        
$this->loadrelation()->delete();
        
$this->redirect(array('record/show&id='.$_GET['recordId']));
    }
    else
        throw new 
CHttpException(400,'Invalid request. Please do not repeat this request again.');
}

Deletes a particular model. If deletion is successful, the browser will be redirected to the record 'show' page.

actionList() method
public void actionList()
Source Code: app/controllers/RelationController.php#363 (show)
public function actionList()
{
    
$criteria=new CDbCriteria;

    
$pages=new CPagination(relation::model()->count($criteria));
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);

    
$models=relation::model()->findAll($criteria);

    
$this->render('list',array(
        
'models'=>$models,
        
'pages'=>$pages,
    ));
}

Lists all models.

actionPdfannodel() method
public void actionPdfannodel()
Source Code: app/controllers/RelationController.php#572 (show)
public function actionPdfannodel(){
    
$id=$_POST['id'];
    if(
$id!=null){
        
$this->delPdfAnno($id);            
    }
    
//print "<script>this->close();</script>";
}

Deletes pdf annotation

actionPdfannoedit() method
public void actionPdfannoedit()
Source Code: app/controllers/RelationController.php#518 (show)
public function actionPdfannoedit(){
    
//for save
    
if($_POST['id']!=null&&$_POST['title']!=null&&$_POST['body']!=null){
        
$pdfanno pdfRepsAnnotation::model()->findbyPk($_POST['id']);
        
$pdfanno->title $_POST['title'];
        
//handle line change
        
$tmp_text str_replace("\r"''$_POST['body']);
        
$pdfanno->body str_replace("\n"'\n'$tmp_text);
        if(
$pdfanno->save())
            print 
$_POST['title'];
    } else if(
$_GET['id']!=null){//for showing the window
        
$pdfanno pdfRepsAnnotation::model()->findbyPk($_GET['id']); 
        
$title $pdfanno->title;
        
$body str_replace('\n'"&#13;&#10;"$pdfanno->body);
        
$username="";
        if(
$pdfanno->body->owner_id!=null){
            
$user user::model()->findbyPk($pdfanno->owner_id); 
            
$username $user->username;
        }
        
$this->renderPartial('pdfannoedit',array('id'=>$_GET['id'],'title'=>$title,'body'=>$body'username'=>$username));        
    }
}

Shows pdf annotation dialog edit window

actionPdfannonew() method
public void actionPdfannonew()
Source Code: app/controllers/RelationController.php#440 (show)
public function actionPdfannonew(){
    
//for save
    
if($_POST['entity2']!=null&&$_POST['document_id']!=null&&$_POST['page']!=null&&$_POST['left']!=null&&$_POST['top']!=null&&$_POST['width']!=null&&$_POST['height']!=null&&$_POST['title']!=null&&$_POST['body']!=null){
        
$entity2 $_POST['entity2'];
        
$document_id $_POST['document_id'];
        
$page $_POST['page'];
        
$left $_POST['left'];
        
$top $_POST['top'];
        
$width $_POST['width'];
        
$height $_POST['height'];
        
$title $_POST['title'];
        
//handle line change
        
$tmp_text str_replace("\r"''$_POST['body']);
        
$body str_replace("\n"'\n'$tmp_text);
        
$pdfanno = new pdfRepsAnnotation;
        
$pdfanno->entity1 $_POST['document_id'];
        
$pdfanno->entity2 $_POST['entity2'];
        
$pdfanno->title $_POST['title'];
        
$tmp_text str_replace("\r"''$_POST['body']);
        
$pdfanno->body str_replace("\n"'\n'$tmp_text);
        
$pdfanno->owner_id Yii::app()->user->id;
        
$annoarea = new pdfAnnoArea;
        if(
$pdfanno->save()){
            
$annoarea->page $_POST['page'];
            
$annoarea->left $_POST['left'];
            
$annoarea->top $_POST['top'];
            
$annoarea->width $_POST['width'];
            
$annoarea->height $_POST['height'];
            
$annoarea->anno_id $pdfanno->id;
            
$annoarea->save();
        }
    }else{
//for showing the new window
        
$entity2 $_GET['entity2'];
        
$document_id $_GET['document_id'];
        
$page $_GET['area']['page'];
        
$left $_GET['area']['left'];
        
$top $_GET['area']['top'];
        
$width $_GET['area']['width'];
        
$height $_GET['area']['height'];
        
$this->renderPartial('pdfannonew',array('entity2'=>$entity2,'document_id'=>$document_id,'page'=>$page,'left'=>$left,'top'=>$top,'width'=>$width,'height'=>$height));
        
    }
}

Shows pdf annotation dialog new window

actionPdfannoreply() method
public void actionPdfannoreply()
Source Code: app/controllers/RelationController.php#545 (show)
public function actionPdfannoreply(){
    
//for save
    
if($_POST['id']!=null&&$_POST['title']!=null&&$_POST['body']!=null&$_POST['entity2']!=null&&$_POST['document_id']!=null){
        
$annoreply = new pdfRepsAnnotation;
        
$annoreply->reply_to $_POST['id'];
        
$annoreply->title $_POST['title'];
        
//handle line change
        
$tmp_text str_replace("\r"''$_POST['body']);
        
$annoreply->body str_replace("\n"'\n'$tmp_text);
        
$annoreply->entity1 $_POST['document_id'];
        
$annoreply->entity2 $_POST['entity2'];
        if(
$annoreply->save())
            print 
$_POST['title'];
    }else if(
$_GET['id']!=null&$_GET['entity2']!=null&&$_GET['document_id']!=null){//for showing the window
        
$pdfanno pdfRepsAnnotation::model()->findbyPk($_GET['id']); 
        
$title $pdfanno->title;
        
$tmp_text str_replace("\r"''$pdfanno->body);
        
$body str_replace('\n'"<br />"$tmp_text);
        
$this->renderPartial('pdfannoreply',array('id'=>$_GET['id'],'title'=>$title,'body'=>$body'entity2'=>$_GET['entity2'],'document_id'=>$_GET['document_id']));
        
    }
}

Shows pdf annotation dialog reply window

actionPdfnewcomment() method
public void actionPdfnewcomment()
Source Code: app/controllers/RelationController.php#488 (show)
public function actionPdfnewcomment(){
    
//for save
    
if($_POST['entity2']!=null&&$_POST['document_id']!=null&&$_POST['title']!=null&&$_POST['body']!=null){
        
$entity2 $_POST['entity2'];
        
$document_id $_POST['document_id'];
        
        
$title $_POST['title'];
        
$body $_POST['body'];
        
$pdfanno = new pdfRepsAnnotation;
        
$pdfanno->entity1 $_POST['document_id'];
        
$pdfanno->entity2 $_POST['entity2'];
        
$pdfanno->title $_POST['title'];
        
//handle line change
        
$tmp_text str_replace("\r"''$_POST['body']);
        
$pdfanno->body str_replace("\n"'\n'$tmp_text);
        
$pdfanno->owner_id Yii::app()->user->id;
        
$pdfanno->save();
    }else{
//for showing the window
        
$entity2 $_GET['entity2'];
        
$document_id $_GET['document_id'];
        
        
$this->renderPartial('pdfnewcomment',array('entity2'=>$entity2,'document_id'=>$document_id));
        
    }
}

Shows pdf annotation comment dialog window

actionShow() method
public void actionShow()
Source Code: app/controllers/RelationController.php#59 (show)
public function actionShow()
{
    
$this->render('show',array('model'=>$this->loadrelation()));
}

Shows a particular model.

actionUpdate() method
public void actionUpdate()
Source Code: app/controllers/RelationController.php#84 (show)
public function actionUpdate()
{
    
$model=$this->loadrelation();
    if(isset(
$_POST['relation']))
    {
        
$model->attributes=$_POST['relation'];
        if(
$model->save())
            
$this->redirect(array('show','entity1'=>$model->entity1,'entity2'=>$model->entity2));
    }
    
$this->render('update',array('model'=>$model));
}

Updates a particular model. If update is successful, the browser will be redirected to the 'show' page.

actionUpdaterela() method
public void actionUpdaterela()
Source Code: app/controllers/RelationController.php#315 (show)
public function actionUpdaterela()
{
    
$model=$this->loadrelation();
    
$recordId$_GET['recordId'];
    if(isset(
$_POST['relation']))
    {
        
$recordId$_POST['recordId'];
        
$model->attributes=$_POST['relation'];
        if(
$model->save())
            
$this->redirect(array('record/show','id'=>$recordId));
    }
    
$this->render('updaterela',array('model'=>$model,'recordId'=>$recordId));
}

Updates a represents relation model. If update is successful, the browser will be redirected to the 'record/show' page.

actionUpdatereps() method
public void actionUpdatereps()
Source Code: app/controllers/RelationController.php#100 (show)
public function actionUpdatereps()
{
    
$model=$this->loadrelation();
    
$recordId$_GET['recordId'];
    if(isset(
$_POST['relation']))
    {
        
$recordId$_POST['recordId'];
        
$model->attributes=$_POST['relation'];
        
$makemain $_POST['makemain'];
        if(
$makemain){
            
$model->name="main";
            
$this->makeAsMain($model->entity1,$recordId);
        }
        
$copymeta $_POST['copymeta'];
        
        if(
$model->save()){
            if(
$copymeta){
                
//$this->copyMetadata($model->entity1,$recordId);
                
$file $model->entity1entity;
                
$fileType $file->typeId;
                
$record entity::model()->findbyPk($recordId);
                
$recordType $record->typeId;
                
                
$criteria=new CDbCriteria;
                
$currentProject_id Yii::app()->getGlobalState('currentProject');
                
$condition='entityType='.$recordType.' and prjId='.$currentProject_id;
                
$criteria->condition $condition;
                
$prjMetadataTypes=prjMetadataType::model()->findAll($criteria);
                
                
$criteria=new CDbCriteria;
                
$condition='entityType='.$fileType;
                
$criteria->condition $condition;
                
$fileMetadataTypes=defMetadataType::model()->findAll($criteria);
                
                
//$this->render('mapMetadatas', array('files'=>$files, 'typeId'=>$typeId, 'models'=>$models, 'fileTypeModels'=>$fileTypeModels)); 
                
$this->render('mapMetadata4Copy',array('file'=>$file'record'=>$record'fileType'=>$fileType'recordType'=>$recordType'prjMetadataTypes'=>$prjMetadataTypes'fileMetadataTypes'=>$fileMetadataTypes));
            }else
                
$this->redirect(array('record/show','id'=>$recordId));
            
        }
    }else
        
$this->render('updatereps',array('model'=>$model,'recordId'=>$recordId));
}

Updates a represents relation model, with copy metadata and main main options If update is successful, the browser will be redirected to the 'record/show' page.

copyMetadata() method
public void copyMetadata(entity $copyfrom, entity $copyto)
$copyfrom entity file entity model
$copyto entity record entity model
Source Code: app/controllers/RelationController.php#262 (show)
public function copyMetadata($copyfrom$copyto){ //copy if $copyfrom is digital image and $copyto is digital image object
    
$fromentity=entity::model()->findbyPk($copyfrom);
    
$toentity=entity::model()->findbyPk($copyto);
    
//if($fromentity->typeId==entityType::IMAGE_TYPE&&$toentity->typeId==entityType::IMAGE_OBJECT_TYPE){
    
if($fromentity->typeId==entityType::IMAGE_TYPE){
        
$frommetas $fromentity->metadata;
        
$tometas $toentity->metadata;
        
//substr($_GET['entity2'], 0, strpos($_GET['entity2'],"?"));
        
foreach($frommetas as $froma){
            
$new true;
            
$fromtype $froma->fileMetadataType->name;
            if(
strpos($fromtype,"*")!==false)
                
$fromtype trim(substr($fromtype0strpos($fromtype,"*")));
            else
                
$fromtype trim($fromtype);
            foreach(
$tometas as $toa){                
                
$totype $toa->fileMetadataType->name;
                if(
strpos($totype,"*")!==false)            
                    
$totype trim(substr($totype0strpos($totype,"*")));
                else
                    
$totype trim($totype);
                if(
$fromtype==$totype){
                    
$toa->content $froma->content;
                    
$toa->save();
                    
$new false;
                }
            }
            if(
$new){
                
//$metatypes = $toentity->entityType->metadataType;
                
$metatypes $this->getPrjMetadataType($toentity->typeId);
                foreach(
$metatypes as $metatype){
                    
$typename $metatype->name;
                    if(
strpos($typename,"*")!==false)
                        
$typename trim(substr($typename0strpos($typename,"*")));
                    else
                        
$typename trim($typename);
                    if(
$fromtype==$typename){
                        
$meta = new metadata();
                        
$meta->content $froma->content;
                        
$meta->typeId $metatype->id;
                        
$meta->entityId $copyto;
                        
$meta->save();
                    }
                }
            }
        }
    }
    
}

Copy metadata from file to record, filled in metadata only

copyMetadata2() method
public void copyMetadata2(entity $fromentity, entity $toentity, array $recordMetadataIds, array $fileMetadataIds)
$fromentity entity file entity model
$toentity entity record entity model
$recordMetadataIds array record metadata id array
$fileMetadataIds array file metadata id array
Source Code: app/controllers/RelationController.php#168 (show)
public function copyMetadata2($fromentity$toentity$recordMetadataIds$fileMetadataIds){ 

    
$frommetas $fromentity->metadata;
    
$tometas $toentity->metadata;
    
//substr($_GET['entity2'], 0, strpos($_GET['entity2'],"?"));
    
    
foreach($frommetas as $froma){
        
$new true;
        
$fromtype $froma->fileMetadataType->id;//print 'fromtype:'.$froma->id.'<br/>';
        
        
if($froma->fileMetadataType->sourceType==metadataType::SOURCE_FILLEDIN){
            foreach(
$tometas as $toa){                
                
$totype $toa->metadataType->id;
                foreach(
$fileMetadataIds as $i=>$fileMetadataId){
                    if(
$fromtype==$fileMetadataId&&$totype==$recordMetadataIds[$i]){
                        
$toa->content $froma->content;
                        
$toa->save();
                        
$new false;
                    }
                }
            }
            if(
$new){
                
                foreach(
$fileMetadataIds as $j=>$fileMetadataId){//print $fromtype.":".$fileMetadataId.'<br/>';
                    
if($fromtype==$fileMetadataId){
                        
$totype=$recordMetadataIds[$j];
                        if(
$totype!=null){
                            
$toMetaType prjMetadataType::model()->findbyPk($totype);
                            if(
$toMetaType->sourceType==metadataType::SOURCE_FILLEDIN){                                
                                
$meta = new metadata();
                                
$meta->content $froma->content;
                                
$meta->typeId $totype;
                                
$meta->entityId $toentity->id;
                                
$meta->save();        
                            }else if(
$toMetaType->sourceType==metadataType::SOURCE_CVLIST&&trim($froma->content)!=''){    

                                
$cvLists $toMetaType->cvListType->cvList;
                                
$addCv true;//add new cv or not
                                
foreach($cvLists as $cvList){
                                    if(
$cvList->name==$froma->content){
                                        
$addCv false;
                                        
$cvListRela = new cvListRela();
                                        
$cvListRela->entityId $toentity->id;;
                                        
$cvListRela->cvListId $cvList->id;
                                        
$cvListRela->metadataTypeId $totype;
                                        
$cvListRela->save();
                                    }
                                }
                                
//add froma content to cvlist before adding metadata in cvListRela
                                
if($addCv&&$toMetaType->cvListType->fixed==0){
                                    
$cvList = new cvList();
                                    
$cvList->name=$froma->content;
                                    
$cvList->typeId $toMetaType->cvListType->id;
                                    
$cvList->save();
                                    
$cvListRela = new cvListRela();
                                    
$cvListRela->entityId $toentity->id;;
                                    
$cvListRela->cvListId $cvList->id;
                                    
$cvListRela->metadataTypeId $totype;
                                    
$cvListRela->save();
                                }
                                
                            }
                        }
                    }
                }
            }
        }
    }
}

Copy metadata from file to record

delPdfAnno() method
public void delPdfAnno(integer $id)
$id integer pdf annotation id
Source Code: app/controllers/RelationController.php#625 (show)
public function delPdfAnno($id){

    
$pdfAnno pdfRepsAnnotation::model()->findbyPk($id);
    
$annoArea pdfAnnoArea::model()->findbyPk($id);
    if(
$pdfAnno!=null){
        
$annoArea $pdfAnno->pdfAnnoArea;
        
$pdfAnno->delete();
        if(
$annoArea!=null)
            
$annoArea->delete();
        return 
true;
        
    }
    return 
false;
}

Deletes pdf annotation

filters() method
public array filters()
{return} array action filters
Source Code: app/controllers/RelationController.php#23 (show)
public function filters()
{
    return array(
        
'accessControl'// perform access control for CRUD operations
    
);
}

getPrjMetadataType() method
public void getPrjMetadataType(integer $entityType)
$entityType integer
Source Code: app/controllers/RelationController.php#643 (show)
public function getPrjMetadataType($entityType){
    
$currentProject_id Yii::app()->getGlobalState('currentProject');
    
$criteria=new CDbCriteria;
    
$condition='entityType='.$entityType.' and prjId='.$currentProject_id;            
    
$criteria->condition $condition;
    
$criteria->select "t.id as id, t.name as name";
    
$metadataTypes=prjMetadataType::model()->findAll($criteria);
    return 
$metadataTypes;
}

Gets project metadata types of a particular entity type

loadrelation() method
public void loadrelation(integer $entity1=NULL, integer $entity2=NULL)
$entity1 integer entity1 of the relationship
$entity2 integer entity2 of the relationship
Source Code: app/controllers/RelationController.php#585 (show)
public function loadrelation($entity1=null$entity2=null)
{
    if(
$this->_model===null)
    {
        if((
entity1!==null&&entity2!==null) || (isset($_GET['entity1']) && isset($_GET['entity2']))){
            
$criteria=new CDbCriteria;
            
$entity1 $entity1!==null $entity1 $_GET['entity1'];
            
$entity2 $entity2!==null $entity2 $_GET['entity2'];
            
            
$condition='entity1='.$entity1;
             
$condition=$condition.' AND entity2='.$entity2;
            
$criteria->condition $condition;
             
$models=relation::model()->findAll($criteria);
             if(
$models!=null&&$models[0]!=null)
                 
$this->_model=$models[0];
            
        }
        if(
$this->_model===null)
            throw new 
CHttpException(404,'The requested page does not exist.');
    }
    return 
$this->_model;
}

Returns the data model based on the primary key given in the GET variable. If the data model is not found, an HTTP exception will be raised.

makeAsMain() method
public void makeAsMain(entity $mainEntity, integer $recordId)
$mainEntity entity file entity to be set as main representation
$recordId integer record id
Source Code: app/controllers/RelationController.php#242 (show)
public function makeAsMain($mainEntity$recordId){ //delete name content of other representing entity
    
$criteria=new CDbCriteria;
    
$condition='(entity2='.$recordId.")";
    
$criteria->condition $condition;
    
$relations relation::model()->findAll($criteria);        
    foreach (
$relations as $relation){
        if(
$relation->entity1==$mainEntity){
            
$relation->name "main";
        }else{
            
$relation->name "";
        }
        
$relation->save();
    }

}

Makes a file entity as main representation of a record

processAdminCommand() method
protected void processAdminCommand()
Source Code: app/controllers/RelationController.php#656 (show)
protected function processAdminCommand()
{
    if(isset(
$_POST['command'], $_POST['entity1'], $_POST['entity2']) && $_POST['command']==='delete')
    {
        
$this->loadrelation($_POST['entity1'],$_POST['entity2'])->delete();
        
// reload the current page to avoid duplicated delete actions
        
$this->refresh();
    }
}

Executes any command triggered on the admin page.

searchPdfAnno() method
public void searchPdfAnno(integer $entity1, integer $entity2)
$entity1 integer entity1 of the relationship
$entity2 integer entity2 of the relationship
Source Code: app/controllers/RelationController.php#612 (show)
public function searchPdfAnno($entity1$entity2){
    
$criteria=new CDbCriteria;
    
$condition='(entity1='.$entity1.') and (entity2='.$entity2.')';
    
$criteria->condition $condition;
    
$criteria->order "id";
    
$pdfAnnos pdfRepsAnnotation::model()->findAll($criteria);    
    return 
$pdfAnnos;
}

Finds pdf annotation

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.