public function setup()
 {
     parent::setup();
     unset($this['id']);
     unset($this['community_topic_id']);
     unset($this['member_id']);
     unset($this['number']);
     unset($this['created_at']);
     unset($this['updated_at']);
     if (opMobileUserAgent::getInstance()->getMobile()->isNonMobile()) {
         $images = array();
         if (!$this->isNew()) {
             $images = $this->getObject()->getImagesWithNumber();
         }
         $max = (int) sfConfig::get('app_community_topic_comment_max_image_file_num', 3);
         for ($i = 1; $i <= $max; $i++) {
             $key = 'photo_' . $i;
             if (isset($images[$i])) {
                 $image = $images[$i];
             } else {
                 $image = new CommunityTopicCommentImage();
                 $image->setCommunityTopicComment($this->getObject());
                 $image->setNumber($i);
             }
             $imageForm = new opCommunityTopicPluginImageForm($image);
             $imageForm->getWidgetSchema()->setFormFormatterName('list');
             $this->embedForm($key, $imageForm, '<ul id="community_topic_comment_' . $key . '">%content%</ul>');
         }
     }
     $this->widgetSchema->setLabel('body', sfContext::getInstance()->getI18N()->__('Comment'));
     $this->setValidator('body', new opValidatorString(array('rtrim' => true)));
 }
 public function setup()
 {
     parent::setup();
     unset($this['id']);
     unset($this['community_id']);
     unset($this['member_id']);
     unset($this['created_at']);
     unset($this['updated_at']);
     unset($this['topic_updated_at']);
     if (opMobileUserAgent::getInstance()->getMobile()->isNonMobile()) {
         $images = array();
         if (!$this->isNew()) {
             $images = $this->getObject()->getImages();
         }
         $max = (int) sfConfig::get('app_community_topic_max_image_file_num', 3);
         for ($i = 0; $i < $max; $i++) {
             $key = 'photo_' . ($i + 1);
             if (isset($images[$i])) {
                 $image = $images[$i];
             } else {
                 $image = new CommunityTopicImage();
                 $image->setCommunityTopic($this->getObject());
                 $image->setNumber($i + 1);
             }
             $imageForm = new opCommunityTopicPluginImageForm($image);
             $imageForm->getWidgetSchema()->setFormFormatterName('list');
             $this->embedForm($key, $imageForm, '<ul id="community_topic_' . $key . '">%content%</ul>');
         }
     }
     $this->setWidget('name', new sfWidgetFormInput());
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('community_topic_form');
 }
 public function setMobile($userAgent = null)
 {
     if ($userAgent) {
         $this->mobileUserAgent = $userAgent;
     }
     $_SERVER['HTTP_USER_AGENT'] = $this->mobileUserAgent;
     opMobileUserAgent::resetInstance();
 }
 public function initialize()
 {
     parent::initialize();
     if (!opMobileUserAgent::getInstance()->isCookie()) {
         ini_set('session.use_only_cookies', 0);
         ini_set('session.use_cookies', 0);
         ini_set('session.use_trans_sid', 1);
     }
     sfWidgetFormSchema::setDefaultFormFormatterName('mobile');
 }
Esempio n. 5
0
 public function setMobile($userAgent, $headers = array())
 {
     $_SERVER['HTTP_USER_AGENT'] = $userAgent;
     foreach ($headers as $key => $header) {
         if (null === $header) {
             unset($_SERVER[$key]);
         } else {
             $_SERVER[$key] = $header;
         }
     }
     opMobileUserAgent::resetInstance();
 }
 public function setup()
 {
     parent::setup();
     unset($this['id']);
     unset($this['community_id']);
     unset($this['member_id']);
     unset($this['created_at']);
     unset($this['updated_at']);
     unset($this['event_updated_at']);
     $dateParam = array('culture' => sfContext::getInstance()->getUser()->getCulture(), 'month_format' => 'number', 'can_be_empty' => true);
     $this->setWidget('name', new sfWidgetFormInput());
     $this->setWidget('open_date', new opWidgetFormDate($dateParam));
     $this->setWidget('application_deadline', new opWidgetFormDate($dateParam));
     $this->setWidget('open_date_comment', new sfWidgetFormInput());
     $this->setWidget('area', new sfWidgetFormInput());
     $this->setValidator('name', new opValidatorString(array('rtrim' => true)));
     $this->setValidator('body', new opValidatorString(array('rtrim' => true)));
     $this->setValidator('area', new opValidatorString(array('rtrim' => true)));
     $this->setValidator('open_date_comment', new sfValidatorString(array('required' => false)));
     $this->setValidator('application_deadline', new sfValidatorDate(array('required' => false, 'min' => strtotime(date('Y-m-d'))), array('min' => 'The date must be after now.')));
     $this->setValidator('capacity', new sfValidatorInteger(array('required' => false, 'max' => 2147483647, 'min' => 0), array('invalid' => 'Invalid.', 'max' => 'Invalid.', 'min' => 'Invalid.')));
     $validatorOpenDate = new sfValidatorCallback(array('callback' => array($this, 'validateOpenDate')));
     $this->mergePostValidator($validatorOpenDate);
     $validatorApplicationDeadline = new sfValidatorCallback(array('callback' => array($this, 'validateApplicationDeadline')));
     $validatorApplicationDeadline->addMessage('invalid_application_deadline', 'The application deadline must be before the open date.');
     $this->mergePostValidator($validatorApplicationDeadline);
     if (opMobileUserAgent::getInstance()->getMobile()->isNonMobile()) {
         $images = array();
         if (!$this->isNew()) {
             $images = $this->getObject()->getImages();
         }
         $max = (int) sfConfig::get('app_community_topic_max_image_file_num', 3);
         for ($i = 0; $i < $max; $i++) {
             $key = 'photo_' . ($i + 1);
             if (isset($images[$i])) {
                 $image = $images[$i];
             } else {
                 $image = new CommunityEventImage();
                 $image->setCommunityEvent($this->getObject());
                 $image->setNumber($i + 1);
             }
             $imageForm = new opCommunityTopicPluginImageForm($image);
             $imageForm->getWidgetSchema()->setFormFormatterName('list');
             $this->embedForm($key, $imageForm, '<ul id="community_event_' . $key . '">%content%</ul>');
         }
     }
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('community_event_form');
 }
 public function setup()
 {
     parent::setup();
     unset($this['id']);
     unset($this['community_event_id']);
     unset($this['member_id']);
     unset($this['number']);
     unset($this['created_at']);
     unset($this['updated_at']);
     if ('mobile_frontend' == sfConfig::get('sf_app')) {
         $label = sprintf('<font color="%s">*</font>', opColorConfig::get('core_color_22')) . sfContext::getInstance()->getI18N()->__('Comment');
     } else {
         $label = sfContext::getInstance()->getI18N()->__('Comment') . ' <strong>*</strong>';
     }
     $this->widgetSchema->setLabel('body', $label);
     $this->setValidator('body', new opValidatorString(array('rtrim' => true)));
     if (opMobileUserAgent::getInstance()->getMobile()->isNonMobile()) {
         $images = array();
         if (!$this->isNew()) {
             $images = $this->getObject()->getImages();
         }
         $max = (int) sfConfig::get('app_community_topic_max_image_file_num', 3);
         for ($i = 0; $i < $max; $i++) {
             $key = 'photo_' . ($i + 1);
             if (isset($images[$i])) {
                 $image = $images[$i];
             } else {
                 $image = new CommunityEventCommentImage();
                 $image->setCommunityEventComment($this->getObject());
                 $image->setNumber($i + 1);
             }
             $imageForm = new opCommunityTopicPluginImageForm($image);
             $imageForm->getWidgetSchema()->setFormFormatterName('list');
             $this->embedForm($key, $imageForm, '<ul id="community_event_comment_' . $key . '">%content%</ul>');
         }
     }
 }
Esempio n. 8
0
 public function isCookie()
 {
     return opMobileUserAgent::getInstance()->isCookie();
 }
 public static function resetInstance()
 {
     self::$mobile = null;
     return self::getInstance();
 }
Esempio n. 10
0
<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */
require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
// load opMobileUserAgent before initializing application
$old_error_level = error_reporting();
error_reporting($old_error_level & ~(E_STRICT | E_DEPRECATED));
set_include_path(dirname(__FILE__) . '/../lib/vendor/PEAR/' . PATH_SEPARATOR . get_include_path());
require_once dirname(__FILE__) . '/../lib/util/opMobileUserAgent.class.php';
$is_mobile = !opMobileUserAgent::getInstance()->getMobile()->isNonMobile();
error_reporting($old_error_level);
// decide an application that should load
if ($is_mobile) {
    $configuration = ProjectConfiguration::getApplicationConfiguration('mobile_frontend', 'prod', false);
} else {
    $configuration = ProjectConfiguration::getApplicationConfiguration('pc_frontend', 'prod', false);
}
sfContext::createInstance($configuration)->dispatch();
Esempio n. 11
0
<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */
require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('pc_frontend', 'prod', false);
if (!opMobileUserAgent::getInstance()->getMobile()->isNonMobile()) {
    $configuration = ProjectConfiguration::getApplicationConfiguration('mobile_frontend', 'prod', false);
}
sfContext::createInstance($configuration)->dispatch();