Skip to content

Instantly share code, notes, and snippets.

@co3k
Created April 2, 2010 13:50
Show Gist options
  • Save co3k/353153 to your computer and use it in GitHub Desktop.
Save co3k/353153 to your computer and use it in GitHub Desktop.
diff --git a/apps/pc_frontend/config/factories.yml b/apps/pc_frontend/config/factories.yml
index 1465851..9463dff 100644
--- a/apps/pc_frontend/config/factories.yml
+++ b/apps/pc_frontend/config/factories.yml
@@ -92,13 +92,7 @@ all:
debug: false
untranslated_prefix: "[T]"
untranslated_suffix: "[/T]"
- cache:
- class: sfFileCache
- param:
- automatic_cleaning_factor: 0
- cache_dir: %SF_I18N_CACHE_DIR%
- lifetime: 86400
- prefix: %SF_APP_DIR%
+ cache: ~
routing:
class: sfPatternRouting
diff --git a/apps/pc_frontend/config/routing.yml b/apps/pc_frontend/config/routing.yml
index 10e96c1..1fca8c9 100644
--- a/apps/pc_frontend/config/routing.yml
+++ b/apps/pc_frontend/config/routing.yml
@@ -37,6 +37,66 @@ error:
url: /default/error
param: { module: default, action: error }
+global_search:
+ url: /search
+ param: { module: default, action: search }
+
+global_changeLanguage:
+ url: /language
+ param: { module: member, action: changeLanguage }
+
+global_privacy_policy:
+ url: /privacyPolicy
+ param: { module: default, action: privacyPolicy }
+
+global_user_agreement:
+ url: /userAgreement
+ param: { module: default, action: userAgreement }
+
+# member rules
+member_config_image:
+ url: /member/image/config
+ param: { module: member, action: configImage }
+
+member_config:
+ url: /member/config
+ param: { module: member, action: config }
+
+member_delete:
+ url: /leave
+ param: { module: member, action: delete }
+
+member_invite:
+ url: /invite
+ param: { module: member, action: invite }
+
+# friend rules
+friend_show_image:
+ url: /friend/image
+ param: { module: friend, action: showImage }
+
+friend_list:
+ url: /friend/list
+ param: { module: friend, action: list }
+
+friend_manage:
+ url: /friend/manage
+ param: { module: friend, action: manage }
+
+# community rules
+community_joinlist:
+ url: /community/joinList
+ param: { module: community, action: joinlist }
+
+# openid rules
+openid_idpxrds:
+ url: /OpenID/idpXrds
+ param: { module: OpenID, action: idpXrds }
+
+openid_list:
+ url: /OpenID/list
+ param: { module: OpenID, action: list }
+
# oauth rules
oauth_request_token:
url: /oauth/request_token
diff --git a/apps/pc_frontend/modules/community/templates/_joinListBox.php b/apps/pc_frontend/modules/community/templates/_joinListBox.php
index 03f7383..122189d 100644
--- a/apps/pc_frontend/modules/community/templates/_joinListBox.php
+++ b/apps/pc_frontend/modules/community/templates/_joinListBox.php
@@ -3,8 +3,8 @@ $options = array(
'title' => __('%community% List', array('%community%' => $op_term['community']->titleize())),
'list' => $communities,
'crownIds' => $sf_data->getRaw('crownIds'),
- 'link_to' => 'community/home?id=',
- 'moreInfo' => array(link_to(sprintf('%s(%d)', __('Show all'), $member->CommunityMember->count()), 'community/joinlist?id='.$member->id)),
+ 'link_to' => '@community_home?id=',
+ 'moreInfo' => array(link_to(sprintf('%s(%d)', __('Show all'), $member->CommunityMember->count()), '@community_joinlist?id='.$member->id)),
'type' => $sf_data->getRaw('gadget')->getConfig('type'),
'row' => $row,
'col' => $col,
diff --git a/apps/pc_frontend/modules/community/templates/joinlistSuccess.php b/apps/pc_frontend/modules/community/templates/joinlistSuccess.php
index 153ba2c..8cc5ad8 100644
--- a/apps/pc_frontend/modules/community/templates/joinlistSuccess.php
+++ b/apps/pc_frontend/modules/community/templates/joinlistSuccess.php
@@ -3,9 +3,9 @@ $options = array(
'title' => __('%community% List', array('%community%' => $op_term['community']->titleize())),
'list' => $pager->getResults(),
'crownIds' => $sf_data->getRaw('crownIds'),
- 'link_to' => 'community/home?id=',
+ 'link_to' => '@community_home?id=',
'pager' => $pager,
- 'link_to_pager' => 'community/joinlist?page=%d&id='.$member->getId(),
+ 'link_to_pager' => '@community_joinlist?page=%d&id='.$member->getId(),
);
op_include_parts('photoTable', 'communityList', $options)
?>
diff --git a/apps/pc_frontend/modules/community/templates/searchSuccess.php b/apps/pc_frontend/modules/community/templates/searchSuccess.php
index 938a7aa..ab87ada 100644
--- a/apps/pc_frontend/modules/community/templates/searchSuccess.php
+++ b/apps/pc_frontend/modules/community/templates/searchSuccess.php
@@ -26,7 +26,7 @@ $options = array(
'title' => __('Search Results'),
'pager' => $pager,
'link_to_page' => 'community/search?page=%d',
- 'link_to_detail' => 'community/home?id=%d',
+ 'link_to_detail' => '@community_home?id=%d',
'list' => $list,
);
diff --git a/apps/pc_frontend/modules/default/templates/_languageSelecterBox.php b/apps/pc_frontend/modules/default/templates/_languageSelecterBox.php
index 36d86b2..8840012 100644
--- a/apps/pc_frontend/modules/default/templates/_languageSelecterBox.php
+++ b/apps/pc_frontend/modules/default/templates/_languageSelecterBox.php
@@ -1,4 +1,4 @@
-<?php echo $form->renderFormTag(url_for('member/changeLanguage')) ?>
+<?php echo $form->renderFormTag(url_for('@global_changeLanguage')) ?>
<?php echo $form['culture']->renderLabel() ?>:
<?php echo $form['culture']->render(array('onchange' => 'submit(this.form)')) ?>
<?php echo $form->renderHiddenFields() ?>
diff --git a/apps/pc_frontend/modules/default/templates/_memberImageBox.php b/apps/pc_frontend/modules/default/templates/_memberImageBox.php
index 3ea9aa8..f6943a0 100644
--- a/apps/pc_frontend/modules/default/templates/_memberImageBox.php
+++ b/apps/pc_frontend/modules/default/templates/_memberImageBox.php
@@ -2,12 +2,12 @@
$moreInfo = array();
if ($member->getId() === $id)
{
- $moreInfo[] = link_to(__('Edit Photo'), 'member/configImage');
- $moreInfo[] = link_to(__('Show Profile'), 'member/profile');
+ $moreInfo[] = link_to(__('Edit Photo'), '@member_config_image');
+ $moreInfo[] = link_to(__('Show Profile'), '@member_profile_mine');
}
elseif ($member->getImageFileName())
{
- $moreInfo[] = link_to(__('Show more Photos'), 'friend/showImage?id='.$member->getId());
+ $moreInfo[] = link_to(__('Show more Photos'), '@friend_show_image?id='.$member->getId());
}
$options = array(
diff --git a/apps/pc_frontend/modules/friend/templates/_friendListBox.php b/apps/pc_frontend/modules/friend/templates/_friendListBox.php
index 0e3ae2f..430f84c 100644
--- a/apps/pc_frontend/modules/friend/templates/_friendListBox.php
+++ b/apps/pc_frontend/modules/friend/templates/_friendListBox.php
@@ -2,8 +2,8 @@
$options = array(
'title' => __('%friend% List', array('%friend%' => $op_term['friend']->titleize())),
'list' => $friends,
- 'link_to' => 'member/profile?id=',
- 'moreInfo' => array(link_to(sprintf('%s(%d)', __('Show all'), $member->countFriends()), 'friend/list?id='.$member->getId())),
+ 'link_to' => '@obj_member_profile?id=',
+ 'moreInfo' => array(link_to(sprintf('%s(%d)', __('Show all'), $member->countFriends()), '@friend_list?id='.$member->getId())),
'type' => $sf_data->getRaw('gadget')->getConfig('type'),
'row' => $row,
'col' => $col,
@@ -13,7 +13,7 @@ if ($member->getId() == $sf_user->getMember()->getId())
{
$options['moreInfo'][] = link_to(__('%my_friend% Setting', array(
'%my_friend%' => $op_term['my_friend']->titleize()->pluralize(),
- )), 'friend/manage');
+ )), '@friend_manage');
}
op_include_parts('nineTable', 'frendList_'.$gadget->getId(), $options);
diff --git a/apps/pc_frontend/modules/friend/templates/manageSuccess.php b/apps/pc_frontend/modules/friend/templates/manageSuccess.php
index f52dc3d..b1cb38d 100644
--- a/apps/pc_frontend/modules/friend/templates/manageSuccess.php
+++ b/apps/pc_frontend/modules/friend/templates/manageSuccess.php
@@ -1,6 +1,6 @@
<?php echo op_include_parts('manageList', 'manageList', array(
'pager' => $pager,
- 'pager_url'=> 'friend/manage?page=%d',
+ 'pager_url'=> '@friend_manage?page=%d',
'item_url' => 'obj_member_profile',
'image_filename_method' => 'getImageFilename',
'title' => __('%my_friend% Setting', array(
diff --git a/apps/pc_frontend/modules/friend/templates/unlinkInput.php b/apps/pc_frontend/modules/friend/templates/unlinkInput.php
index 7ad14c7..f46bf37 100644
--- a/apps/pc_frontend/modules/friend/templates/unlinkInput.php
+++ b/apps/pc_frontend/modules/friend/templates/unlinkInput.php
@@ -3,5 +3,5 @@ op_include_parts('yesNo', 'unlinkConfirmForm', array(
'title' => __('Do you delete %0% from %my_friend%?', array('%0%' => link_to($member->getName(), '@member_profile?id='.$member->getId()))),
'yes_form' => new sfForm(),
'no_method' => 'get',
- 'no_url' => url_for('friend/manage')
+ 'no_url' => url_for('@friend_manage')
)) ?>
diff --git a/apps/pc_frontend/modules/member/actions/actions.class.php b/apps/pc_frontend/modules/member/actions/actions.class.php
index 97f7e08..245e452 100644
--- a/apps/pc_frontend/modules/member/actions/actions.class.php
+++ b/apps/pc_frontend/modules/member/actions/actions.class.php
@@ -139,7 +139,7 @@ class memberActions extends opMemberAction
{
$this->getUser()->setFlash('error', $e->getMessage());
}
- $this->redirect('member/configImage');
+ $this->redirect('@member_config_image');
}
}
diff --git a/apps/pc_frontend/modules/member/templates/configSuccess.php b/apps/pc_frontend/modules/member/templates/configSuccess.php
index 0545456..dd352eb 100644
--- a/apps/pc_frontend/modules/member/templates/configSuccess.php
+++ b/apps/pc_frontend/modules/member/templates/configSuccess.php
@@ -5,7 +5,7 @@ foreach ($categories as $key => $value)
{
if (count($value))
{
- $list[$key] = link_to(__($categoryCaptions[$key]), 'member/config?category='.$key);
+ $list[$key] = link_to(__($categoryCaptions[$key]), '@member_config?category='.$key);
}
}
op_include_parts('pageNav', 'pageNav', array('list' => $list, 'current' => $categoryName));
@@ -13,14 +13,14 @@ op_include_parts('pageNav', 'pageNav', array('list' => $list, 'current' => $cate
<?php
$list = array(
- link_to(__('Connecting with External Application'), 'connection/list'),
- link_to(__('OpenID Configuration'), 'OpenID/list'),
+ link_to(__('Connecting with External Application'), '@connection_list'),
+ link_to(__('OpenID Configuration'), '@openid_list'),
);
op_include_parts('pageNav', 'connection', array('list' => $list));
?>
<?php
-$list = array(link_to(__('Delete your %1% account', array('%1%' => $op_config['sns_name'])), 'member/delete'));
+$list = array(link_to(__('Delete your %1% account', array('%1%' => $op_config['sns_name'])), '@member_delete'));
op_include_parts('pageNav', 'navForDelete', array('list' => $list));
?>
<?php end_slot(); ?>
diff --git a/apps/pc_frontend/modules/member/templates/inviteInput.php b/apps/pc_frontend/modules/member/templates/inviteInput.php
index 380a97a..e0671b2 100644
--- a/apps/pc_frontend/modules/member/templates/inviteInput.php
+++ b/apps/pc_frontend/modules/member/templates/inviteInput.php
@@ -2,7 +2,7 @@
$options = array(
'title' => __('Invite a friend to %1%', array('%1%' => $op_config['sns_name'])),
- 'url' => url_for('member/invite'),
+ 'url' => url_for('@member_invite'),
'button' => __('Send'),
);
op_include_form('inviteForm', $form, $options);
@@ -16,7 +16,7 @@ op_include_form('inviteForm', $form, $options);
<h3><?php echo __('Mail address list during invitation') ?></h3>
</div>
-<?php echo $listform->renderFormTag(url_for('member/invite')) ?>
+<?php echo $listform->renderFormTag(url_for('@member_invite')) ?>
<?php $i = 0 ?>
<?php foreach ($listform as $field): ?>
<?php if ($field->isHidden()) continue; ?>
diff --git a/apps/pc_frontend/templates/_footer.php b/apps/pc_frontend/templates/_footer.php
index d7f2b96..91aa7c4 100644
--- a/apps/pc_frontend/templates/_footer.php
+++ b/apps/pc_frontend/templates/_footer.php
@@ -1,6 +1,6 @@
<p>
-<?php echo link_to('プライバシーポリシー', 'default/privacyPolicy', array('target' => '_blank')); ?>
-<?php echo link_to('利用規約', 'default/userAgreement', array('target' => '_blank')); ?>
+<?php echo link_to('プライバシーポリシー', '@global_privacy_policy', array('target' => '_blank')); ?>
+<?php echo link_to('利用規約', '@global_user_agreement', array('target' => '_blank')); ?>
<?php $snsConfigSettings = sfConfig::get('openpne_sns_config'); ?>
<?php if (opToolkit::isSecurePage()) : ?>
<?php echo Doctrine::getTable('SnsConfig')->get('footer_after', $snsConfigSettings['footer_after']['Default']); ?>
diff --git a/apps/pc_frontend/templates/_partsSearchFormLine.php b/apps/pc_frontend/templates/_partsSearchFormLine.php
index 686a4a9..3444acb 100644
--- a/apps/pc_frontend/templates/_partsSearchFormLine.php
+++ b/apps/pc_frontend/templates/_partsSearchFormLine.php
@@ -1,6 +1,6 @@
<?php $options->setDefault('single', true) ?>
-<form action="<?php echo url_for('default/search') ?>" method="get">
+<form action="<?php echo url_for('@global_search') ?>" method="get">
<ul>
<li><?php echo image_tag('icon_search.gif', array('alt' => 'search')) ?></li>
<li>
diff --git a/lib/config/config/config_handlers.yml b/lib/config/config/config_handlers.yml
index cce03fb..1545895 100644
--- a/lib/config/config/config_handlers.yml
+++ b/lib/config/config/config_handlers.yml
@@ -36,3 +36,6 @@ modules/*/config/security.yml:
config/mobile_preset_color.yml:
class: sfSimpleYamlConfigHandler
+config/regions.yml:
+ class: sfSimpleYamlConfigHandler
+
diff --git a/lib/config/opProjectConfiguration.class.php b/lib/config/opProjectConfiguration.class.php
index 2d6e861..d91a22c 100644
--- a/lib/config/opProjectConfiguration.class.php
+++ b/lib/config/opProjectConfiguration.class.php
@@ -22,6 +22,73 @@ if (!defined('E_DEPRECATED'))
*/
class opProjectConfiguration extends sfProjectConfiguration
{
+ public function generateFixedMethodToDoctrineRecord(sfEvent $event)
+ {
+ if ($event->getSubject() instanceof sfDoctrineBuildModelTask)
+ {
+ if (!sfConfig::get('ebi_no_magic', false))
+ {
+ return;
+ }
+
+ $defnitionTemplate = "\n public function %s(%s)\n {\n"
+ ." return \$this->_%s('%s'%s);\n"
+ ." }\n";
+
+ $config = $event->getSubject()->getCliConfig();
+ $builderOptions = $this->getPluginConfiguration('sfDoctrinePlugin')->getModelBuilderOptions();
+
+ $models = sfFinder::type('file')->name('Base*.php')->in($config['models_path']);
+ foreach ($models as $model)
+ {
+ $code = file_get_contents($model);
+ $newDefinitions = '';
+
+ $matches = array();
+ if (preg_match_all('/@property (\w+) \$(\w+)/', $code, $matches, PREG_SET_ORDER))
+ {
+ foreach ($matches as $match)
+ {
+ $type = $match[1];
+ $property = $match[2];
+ $getter = 'get'.sfInflector::camelize($property);
+ $setter = 'set'.sfInflector::camelize($property);
+
+ // method is already exists
+ if (false !== strpos($code, 'public function '.$getter.'(')
+ || false !== strpos($code, 'public function '.$setter.'(')
+ )
+ {
+ continue;
+ }
+
+ $isColumn = ord($type[0]) >= 97 && ord($type[0]) <= 122; // a to z
+ if ($isColumn)
+ {
+ // it is not related-column
+ if (false === strpos($code, '\'local\' => \''.$property.'\''))
+ {
+ $newDefinitions .= sprintf($defnitionTemplate, $setter, '$value', 'set', $property, ', $value');
+ $newDefinitions .= sprintf($defnitionTemplate, $getter, '', 'get', $property, '');
+ }
+ }
+ }
+ }
+
+ if ($newDefinitions)
+ {
+ $pos = strrpos($code, '}');
+ $tail = substr($code, $pos);
+ $code = substr($code, 0, $pos);
+ $code .= $newDefinitions.$tail;
+ }
+
+ file_put_contents($model, $code);
+ }
+ }
+ }
+
+
static public function listenToPreCommandEvent(sfEvent $event)
{
require_once dirname(__FILE__).'/../behavior/opActivateBehavior.class.php';
@@ -40,6 +107,7 @@ class opProjectConfiguration extends sfProjectConfiguration
));
$this->dispatcher->connect('command.pre_command', array(__CLASS__, 'listenToPreCommandEvent'));
+ $this->dispatcher->connect('command.post_command', array($this, 'generateFixedMethodToDoctrineRecord'));
$this->setupProjectOpenPNE();
}
diff --git a/lib/filter/opAppendXRDSHeaderFilter.class.php b/lib/filter/opAppendXRDSHeaderFilter.class.php
index ea64256..08f92fe 100644
--- a/lib/filter/opAppendXRDSHeaderFilter.class.php
+++ b/lib/filter/opAppendXRDSHeaderFilter.class.php
@@ -23,7 +23,7 @@ class opAppendXRDSHeaderFilter extends sfFilter
if ('homepage' === $route)
{
- $this->context->getResponse()->setHttpHeader('X-XRDS-Location', $this->context->getController()->genUrl('OpenID/idpXrds', true));
+ $this->context->getResponse()->setHttpHeader('X-XRDS-Location', $this->context->getController()->genUrl('@openid_idpxrds', true));
}
$filterChain->execute();
diff --git a/lib/i18n/opI18N.class.php b/lib/i18n/opI18N.class.php
index 3c4c9e2..ce43efa 100644
--- a/lib/i18n/opI18N.class.php
+++ b/lib/i18n/opI18N.class.php
@@ -24,6 +24,80 @@ class opI18N extends sfI18N
$this->terms->configure($this->culture, sfConfig::get('sf_app'));
}
+ public function generateApplicationMessages($dirs)
+ {
+ $catalogues = array();
+
+ $files = sfFinder::type('file')
+ ->follow_link()
+ ->name('*.xml')
+ ->maxdepth(1)
+ ->in($dirs);
+
+ foreach ($files as $file)
+ {
+ $name = basename($file);
+ if (empty($catalogues[$name]))
+ {
+ $catalogues[$name] = array();
+ }
+
+ $messageSource = sfMessageSource::factory('OpenPNE', array());
+ $data = $messageSource->loadData($file);
+
+ $catalogues[$name] = array_merge($catalogues[$name], $data);
+ }
+
+ $cacheDir = sfConfig::get('sf_app_cache_dir').DIRECTORY_SEPARATOR.'i18n';
+
+ $filesystem = new sfFilesystem();
+ $filesystem->mkdirs($cacheDir);
+
+ foreach ($catalogues as $filename => $catalogue)
+ {
+ file_put_contents($cacheDir.DIRECTORY_SEPARATOR.$filename.'.php', '<?php return '.var_export($catalogue, true).';');
+ }
+ }
+
+ public function setMessageSource($dirs, $culture = null)
+ {
+ $cachedDir = sfConfig::get('sf_app_cache_dir').DIRECTORY_SEPARATOR.'i18n';
+ if (is_file($cachedDir.DIRECTORY_SEPARATOR.'messages.ja.xml.php'))
+ {
+ $this->messageSource = sfMessageSource::factory('OpenPNECached', $cachedDir);
+ }
+ else
+ {
+ $this->generateApplicationMessages($dirs);
+
+ if (null === $dirs)
+ {
+ $this->messageSource = $this->createMessageSource();
+ }
+ else
+ {
+ $this->messageSource = sfMessageSource::factory('Aggregate', array_map(array($this, 'createMessageSource'), $dirs));
+ }
+ }
+
+ if (null !== $this->cache)
+ {
+ $this->messageSource->setCache($this->cache);
+ }
+
+ if (null !== $culture)
+ {
+ $this->setCulture($culture);
+ }
+ else
+ {
+ $this->messageSource->setCulture($this->culture);
+ }
+
+ $this->messageFormat = null;
+ }
+
+
public function __($string, $args = array(), $catalogue = 'messages')
{
foreach ($args as $k => $v)
diff --git a/lib/model/doctrine/Member.class.php b/lib/model/doctrine/Member.class.php
index 3c278c6..3830845 100644
--- a/lib/model/doctrine/Member.class.php
+++ b/lib/model/doctrine/Member.class.php
@@ -20,6 +20,14 @@ class Member extends BaseMember implements opAccessControlRecordInterface
return Doctrine::getTable('MemberProfile')->getProfileListByMemberId($this->getId());
}
+ public function hasProfiles()
+ {
+ return (bool)Doctrine::getTable('MemberProfile')
+ ->createQuery()
+ ->where('member_id = ?', $this->id)
+ ->count();
+ }
+
public function getProfile($profileName)
{
$profile = Doctrine::getTable('MemberProfile')->retrieveByMemberIdAndProfileName($this->getId(), $profileName);
diff --git a/lib/util/opFormItemGenerator.class.php b/lib/util/opFormItemGenerator.class.php
index db9e9a3..6f9694f 100644
--- a/lib/util/opFormItemGenerator.class.php
+++ b/lib/util/opFormItemGenerator.class.php
@@ -129,7 +129,7 @@ class opFormItemGenerator
$obj = new sfWidgetFormChoice(array('choices' => $info->getCountries()));
break;
case 'region_select':
- $list = sfYaml::load(sfConfig::get('sf_lib_dir').'/config/config/regions.yml');
+ $list = (array)include(sfContext::getInstance()->getConfigCache()->checkConfig('config/regions.yml'));
$type = $field['ValueType'];
if ('string' !== $type && isset($list[$type]))
{
diff --git a/plugins/opAuthMailAddressPlugin/lib/user/opAuthAdapterMailAddress.class.php b/plugins/opAuthMailAddressPlugin/lib/user/opAuthAdapterMailAddress.class.php
--- a/plugins/opAuthMailAddressPlugin/lib/user/opAuthAdapterMailAddress.class.php
+++ b/plugins/opAuthMailAddressPlugin/lib/user/opAuthAdapterMailAddress.class.php
@@ -86,7 +86,7 @@
$data = Doctrine::getTable('Member')->find((int)$member_id);
opActivateBehavior::enable();
- if (!$data || !$data->getName() || !$data->getProfiles())
+ if (!$data || !$data->getName() || !$data->hasProfiles())
{
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment