Issue 1132 for ica-atom

3 views
Skip to first unread message

wu....@usask.ca

unread,
Jan 31, 2011, 11:07:32 AM1/31/11
to Qubit Toolkit Developers
Hi all,

I am now looking at the issue 1132, and got stuck there.
Thanks very much in advance

wu


class ActorContextMenuComponent extends sfComponent
{
public function execute($request)
{
$this->resource = $request->getAttribute('sf_route')->resource;

$criteria = new Criteria;
$criteria->add(QubitEvent::ACTOR_ID, $this->resource->id);
$criteria->addJoin(QubitEvent::INFORMATION_OBJECT_ID,
QubitInformationObject::ID);
$criteria->addAscendingOrderByColumn(QubitEvent::TYPE_ID);

// Sort info objects alphabetically (w/ fallback)
$criteria->addAscendingOrderByColumn('title');
$criteria = QubitCultureFallback::addFallbackCriteria($criteria,
'QubitInformationObject');

// Filter draft descriptions
$criteria = QubitAcl::addFilterDraftsCriteria($criteria);

$this->relatedInfoObjects = array();

foreach (QubitEvent::get($criteria) as $item)
{

$this->relatedInfoObjects[$item->type->getRole()][] = $item-
>informationObject;

}

$criteria = new Criteria;
$criteria->add(QubitRelation::SUBJECT_ID, $this->resource-
>id);
$criteria->add(QubitRelation::TYPE_ID,
QubitTerm::NAME_ACCESS_POINT_ID);

$value = $choices = array();
foreach (QubitRelation::get($criteria) as $item)
{
$choices[$value[] = $this->context->routing->generate(null,
array($item->object, 'module' => 'actor'))] = $item->object;
}



}
}

Jesús García Crespo

unread,
Jan 31, 2011, 2:59:58 PM1/31/11
to qubi...@googlegroups.com
Hi Wu,

On Mon, Jan 31, 2011 at 5:07 PM, wu....@usask.ca <wu....@usask.ca> wrote:
I am now looking at the issue 1132, and got stuck there.
Thanks very much in advance

Considering the portion of code that you added to actor/actions/contextMenuComponent.class.php, I suspect what you are trying to do. However, the next time, could you try to expose your problem in detail? For example, telling us if you got an error message or you have a technical question.

Ok, let's see:
 
       $criteria = new Criteria;
       $criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
       $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID);

       $value = $choices = array();
       foreach (QubitRelation::get($criteria) as $item)
       {
         $choices[$value[] = $this->context->routing->generate(null, array($item->object, 'module' => 'actor'))] = $item->object;
       }

Your ORM query is almost perfect, but you have to look for the object, not the subject. In the other hand, those arrays ($choices and $value) are very helpful if you want to populate a list of options for a sfWidgetFormSelect object (the Symfony abstraction for the <select /> tag), but in this case we don't need them. I think that a good idea would be to build just one array of information objects and pass it to the template. What do you think about this patch?

Index: apps/qubit/modules/actor/actions/contextMenuComponent.class.php
===================================================================
--- apps/qubit/modules/actor/actions/contextMenuComponent.class.php (revision 8940)
+++ apps/qubit/modules/actor/actions/contextMenuComponent.class.php (working copy)
@@ -49,5 +49,11 @@
     {
       $this->relatedInfoObjects[$item->type->getRole()][] = $item->informationObject;
     }
+
+    $this->subjectInfoObjects = array();
+    foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item)
+    {
+      $this->subjectInfoObjects[] = $item->subject;
+    }
   }
 }

Once the action is ready, you'll have to iterate over this array from the template and print its objects. Open actor/templates/_contextMenu.php, there is an example there that could inspire you. You are on the right path. Thank you!

Regards,

--
Jesús García Crespo,
Software Engineer, Artefactual Systems Inc.
http://www.artefactual.com | +1.604.527.2056

wu....@usask.ca

unread,
Feb 1, 2011, 5:33:07 PM2/1/11
to Qubit Toolkit Developers
Thanks Jesús. I got it working now.

But how do I solve internationalization lanugage issues?
Here is my code as follows for /actor/templates/_contextMenu.php

<?php foreach ($subjectInfoObjects as $subjectInfoObject): ?>
<?php if (isset($subjectInfoObject)): ?>

<div><h3><?php echo __('Subject of') ?></h3></div>
<div>
<ul>


<li><?php echo link_to(render_title($subjectInfoObject),
array($subjectInfoObject, 'module' => 'informationobject')) ?>
</li>

</ul>
</div>
<?php endif; ?>
<?php endforeach; ?>

Any help will be appreciated

THanks

-Wu

David Juhasz

unread,
Feb 1, 2011, 5:50:23 PM2/1/11
to qubi...@googlegroups.com
Hi Wu,

That code looks fine for internationalization. The __('Subject of') is
a function call that will automatically replace the content with the
translated message for the current culture. The "render_title()"
function should also return a translated string.

Are you having a specific problem with translating one of the strings?

David


--
David Juhasz,


Software Engineer, Artefactual Systems Inc.

http://www.artefactual.com | P: +1.604.527.2056 | F: +1.604.521.2059

wu....@usask.ca

unread,
Feb 2, 2011, 12:02:43 PM2/2/11
to Qubit Toolkit Developers
Here is my url: http://sain.usask.ca/ica-atom-fonds/index.php/wilson-doug;isaar

I am talking about the "subject of" for internationalization once I
switch it to other languages than english, "subject of" will not
change it to its coresponding language.

David Juhasz

unread,
Feb 2, 2011, 12:33:31 PM2/2/11
to qubi...@googlegroups.com
Hmm, you may need to add the string to the i18n messages file. From the
command line:

$ cd /var/www/ica-atom-install
$ sudo ./symfony i18n:extract --plugins --auto-save fr

This will generate the strings for French. To extract strings for all
languages currently supported by ICA-AtoM:

$ cd /var/www/ica-atom-install/apps/qubit/i18n
$ for i in *; do ../../../symfony i18n:extract --plugins --auto-save $i;
done

Cheers,

--
David Juhasz,
Software Engineer

Artefactual Systems Inc.
www.artefactual.com

Reply all
Reply to author
Forward
0 new messages