Author: jablko
Date: Sat Nov 28 10:27:33 2009
New Revision: 3985
Log:
Factor common expression to get path info from URL into a helper
Added:
trunk/lib/Qubit.class.php (contents, props changed)
Modified:
trunk/apps/qubit/modules/actor/actions/listAction.class.php
trunk/apps/qubit/modules/function/actions/editAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
trunk/apps/qubit/modules/user/actions/editAction.class.php
trunk/plugins/qbAclPlugin/modules/aclGroup/actions/editAction.class.php
Modified: trunk/apps/qubit/modules/actor/actions/listAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/actor/actions/listAction.class.php Sat Nov 28
00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/actor/actions/listAction.class.php Sat Nov 28
10:27:33 2009 (r3985)
@@ -30,7 +30,7 @@
{
public function execute($request)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($request->getPathInfoPrefix(),
'/').'/', null, $request->getHttpHeader('Referer')));
+ $params =
$this->context->routing->parse(Qubit::pathInfo($request->getHttpHeader('Referer')));
if ($request->isXmlHttpRequest() && 'actor' == $params['module'])
{
return $this->ajaxResponse($request);
Modified: trunk/apps/qubit/modules/function/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/function/actions/editAction.class.php Sat Nov
28 00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/function/actions/editAction.class.php Sat Nov
28 10:27:33 2009 (r3985)
@@ -186,7 +186,7 @@
case 'type':
case 'descriptionStatus':
case 'descriptionDetail':
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $this->form->getValue($name)));
+ $params =
$this->context->routing->parse(Qubit::pathInfo($this->form->getValue($name)));
$fieldId = (isset($params['id'])) ? $params['id'] : null;
$this->func[$name.'Id'] = $fieldId;
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Sat Nov 28 00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Sat Nov 28 10:27:33 2009 (r3985)
@@ -249,7 +249,7 @@
case 'levelOfDescription':
case 'parent':
case 'repository':
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $this->form->getValue($field->getName())));
+ $params =
$this->context->routing->parse(Qubit::pathInfo($this->form->getValue($field->getName())));
$this->informationObject[$field->getName().'Id'] = $params['id'];
break;
@@ -259,7 +259,7 @@
$filtered = $selected = array();
foreach ($this->form->getValue($name) as $value)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
$filtered[$params['id']] = $selected[$params['id']] = $params['id'];
}
@@ -303,7 +303,7 @@
$filtered = $selected = array();
foreach ($this->form->getValue($name) as $value)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
$filtered[$params['id']] = $selected[$params['id']] = $params['id'];
}
@@ -591,7 +591,7 @@
// Use existing actor if one is selected (overrides new actor creation)
if (0 < strlen($eventFormData['actor']))
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $eventFormData['actor']));
+ $params =
$this->context->routing->parse(Qubit::pathInfo($eventFormData['actor']));
$event->actorId = $params['id'];
}
@@ -618,7 +618,7 @@
$place = new QubitObjectTermRelation;
}
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $eventFormData['place']));
+ $params =
$this->context->routing->parse(Qubit::pathInfo($eventFormData['place']));
$place->termId = $params['id'];
$event->objectTermRelationsRelatedByobjectId[] = $place;
Modified:
trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
Sat Nov 28 00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
Sat Nov 28 10:27:33 2009 (r3985)
@@ -125,7 +125,7 @@
$filtered = $flipped = array();
foreach ($this->form->getValue('types') as $value)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
$filtered[$params['id']] = $flipped[$params['id']] = $params['id'];
}
Modified:
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Sat Nov 28 00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Sat Nov 28 10:27:33 2009 (r3985)
@@ -125,7 +125,7 @@
$filtered = $flipped = array();
foreach ($this->form->getValue('creators') as $value)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
$filtered[$params['id']] = $flipped[$params['id']] = $params['id'];
}
Modified:
trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
Sat Nov 28 00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
Sat Nov 28 10:27:33 2009 (r3985)
@@ -81,7 +81,7 @@
$filtered = $flipped = array();
foreach ($this->form->getValue('types') as $value)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
$filtered[$params['id']] = $flipped[$params['id']] = $params['id'];
}
Modified:
trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
Sat Nov 28 00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
Sat Nov 28 10:27:33 2009 (r3985)
@@ -202,7 +202,7 @@
$filtered = $flipped = array();
foreach ($this->form->getValue('types') as $value)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
$filtered[$params['id']] = $flipped[$params['id']] = $params['id'];
}
Modified: trunk/apps/qubit/modules/user/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/user/actions/editAction.class.php Sat Nov 28
00:07:01 2009 (r3984)
+++ trunk/apps/qubit/modules/user/actions/editAction.class.php Sat Nov 28
10:27:33 2009 (r3985)
@@ -222,7 +222,7 @@
// Set repository conditional for permission
if ('null' != $formData['repository'])
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $formData['repository']));
+ $params =
$this->context->routing->parse(Qubit::pathInfo($formData['repository']));
$aclPermission->setRepository(QubitRepository::getById($params['id']));
}
else
Added: trunk/lib/Qubit.class.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/Qubit.class.php Sat Nov 28 10:27:33 2009 (r3985)
@@ -0,0 +1,26 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class Qubit
+{
+ public static function pathInfo($url)
+ {
+ return
preg_replace('/.*'.preg_quote(sfContext::getInstance()->request->getPathInfoPrefix(),
'/').'/', null, $url);
+ }
+}
Modified:
trunk/plugins/qbAclPlugin/modules/aclGroup/actions/editAction.class.php
==============================================================================
--- trunk/plugins/qbAclPlugin/modules/aclGroup/actions/editAction.class.php
Sat Nov 28 00:07:01 2009 (r3984)
+++ trunk/plugins/qbAclPlugin/modules/aclGroup/actions/editAction.class.php
Sat Nov 28 10:27:33 2009 (r3985)
@@ -136,7 +136,7 @@
// Set repository conditional for permission
if ('null' != $formData['repository'])
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $formData['repository']));
+ $params =
$this->context->routing->parse(Qubit::pathInfo($formData['repository']));
$aclPermission->setRepository(QubitRepository::getById($params['id']));
}
else
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.