Esempio n. 1
0
 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     if ($this->request->getParameter('dm_embed')) {
         sfConfig::set('dm_admin_embedded', true);
         sfConfig::set('dm_toolBar_enabled', false);
     }
     $this->saveApplicationUrl();
     $this->loadAssetConfig();
     if (sfConfig::get('dm_admin_embedded')) {
         $this->response->addStylesheet('admin.embed', 'last');
         $this->getContext()->getEventDispatcher()->connect('admin.save_object', array($this, 'listenToAdminSaveObjectWhenEmbedded'));
     }
     $this->updateLock();
     $filterChain->execute();
     if (sfConfig::get('dm_admin_embedded')) {
         $this->response->addStylesheet('admin.embed');
     } else {
         // If response has no title, generate one with the H1
         if ($this->response->isHtmlForHuman() && !$this->response->getTitle()) {
             preg_match('|<h1[^>]*>(.*)</h1>|iuUx', $this->response->getContent(), $matches);
             if (isset($matches[1])) {
                 $title = 'Admin : ' . strip_tags($matches[1]) . ' - ' . dmConfig::get('site_name');
                 $this->response->setContent(str_replace('<title></title>', '<title>' . $title . '</title>', $this->response->getContent()));
             }
         }
     }
 }
Esempio n. 2
0
  protected function secure()
  {
    $user = $this->getUser();
    
    $accessDenied =
          // the site is not active and requires the site_view permission to be displayed
          (!dmConfig::get('site_active') && !$user->can('site_view'))
          // the page is not active and requires the site_view permission to be displayed
      ||  (!$this->page->get('is_active') && !$user->can('site_view'))
          // the page is secured and requires authentication to be displayed
      ||  ($this->page->get('is_secure') && !$user->isAuthenticated())
          // the page is secured and the user has not required credentials
      ||  ($this->page->get('is_secure') && $this->page->get('credentials') && !$user->can($this->page->get('credentials')))
    ;

    $accessDenied = $this->getDispatcher()->filter(
      new sfEvent($this, 'dm.page.deny_access', array('page' => $this->page, 'context' => $this->context)),
      $accessDenied
    )->getReturnValue();

    if($accessDenied)
    {
      if(!$this->page->get('is_active'))
      {
        $this->forward404();
      }

      // use main/signin page
      $this->getRequest()->setParameter('dm_page', dmDb::table('DmPage')->fetchSignin());

      $this->getResponse()->setStatusCode($user->isAuthenticated() ? 403 : 401);

      $this->forward('dmFront', 'page');
    }
  }
Esempio n. 3
0
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new OrderForm();
     if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) {
         $order = $form->save();
         $order->setUid(md5(rand(1111, 9999) . time()));
         $order->save();
         // link order details
         $this->shopping_cart = $shopping_cart = $this->getUser()->getShoppingCart();
         $this->items = $shopping_cart->getItems();
         foreach ($shopping_cart->getItems() as $i => $item) {
             $od = new OrderDetail();
             $od->fromArray(array('product_id' => $item->getId(), 'order_id' => $order->id, 'quantity' => $item->getQuantity(), 'price' => $item->getPrice()));
             $od->save();
         }
         if (sfConfig::get('app_send_order', false)) {
             dm::enableMailer();
             //send mail
             $message = $this->getMailer()->compose($_from = dmConfig::get('orderEmail'), $_to = array($order->email, dmConfig::get('orderEmail')), $_subj = '[' . dmConfig::get('siteName') . '] thanks for order');
             $message->setBody($this->getPartial('order/mailOrder', array('order' => $order, 'companyName' => dmConfig::get('companyName'), 'companyPhone' => dmConfig::get('companyPhone'), 'siteUrl' => dmConfig::get('siteUrl'), 'siteName' => dmConfig::get('siteName'))));
             $message->setContentType('text/html');
             $this->getMailer()->send($message);
         }
         // if send order
         // clear cart now
         $shopping_cart->clear();
         //redirect to order info
         $this->redirect($this->getHelper()->link('main/ordershow?uid=' . $order->uid)->getHref());
         //$this->redirectBack();
     }
     $this->forms['Order'] = $form;
 }
Esempio n. 4
0
 protected function useSearchIndex($slug)
 {
     if (!dmConfig::get('smart_404')) {
         return false;
     }
     try {
         $searchIndex = $this->serviceContainer->get('search_engine')->getCurrentIndex();
         $queryString = str_replace('/', ' ', dmString::unSlugify($slug));
         $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
         $results = $searchIndex->search($query);
         $foundPage = null;
         foreach ($results as $result) {
             if ($result->getScore() > 0.5) {
                 if ($foundPage = $result->getPage()) {
                     break;
                 }
             } else {
                 break;
             }
         }
         if ($foundPage) {
             return $this->serviceContainer->getService('helper')->link($foundPage)->getHref();
         }
     } catch (Exception $e) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Can not use search index to find redirection for slug ' . $slug, sfLogger::ERR)));
         if (sfConfig::get('dm_debug')) {
             throw $e;
         }
     }
 }
Esempio n. 5
0
 public function renderGoogleAnalytics()
 {
     if (($gaKey = dmConfig::get('ga_key')) && !$this->getService('user')->can('admin') && !dmOs::isLocalhost()) {
         return $this->getGoogleAnalyticsCode($gaKey);
     }
     return '';
 }
Esempio n. 6
0
 public function configure(array $data)
 {
     $userId = dmArray::get($data, 'user_id', $this->serviceContainer->getService('user')->getUserId());
     if (!$userId && dmConfig::isCli()) {
         $userId = 'task';
     }
     $this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'ip' => (string) $this->getCurrentRequestIp(), 'session_id' => (string) session_id(), 'user_id' => (string) $userId, 'action' => (string) $data['action'], 'type' => (string) $data['type'], 'subject' => dmString::truncate($data['subject'], 500), 'record' => isset($data['record']) ? get_class($data['record']) . ':' . $data['record']->get('id') : '');
 }
 protected function loadConfiguration()
 {
     sfConfig::add(array('sf_i18n' => true, 'sf_charset' => 'utf-8', 'sf_upload_dir_name' => str_replace(dmOs::normalize(sfConfig::get('sf_web_dir') . '/'), '', dmOs::normalize(sfConfig::get('sf_upload_dir'))), 'dm_data_dir' => dmOs::join(sfConfig::get('sf_data_dir'), 'dm'), 'dm_cache_dir' => dmOs::join(sfConfig::get('sf_cache_dir'), 'dm')));
     if (extension_loaded('mbstring')) {
         mb_internal_encoding('UTF-8');
     }
     dmConfig::initialize($this->dispatcher);
 }
Esempio n. 8
0
 protected function initialize(array $options = array())
 {
     $this->configure($options);
     sfConfig::set('sf_logging_enabled', false);
     $culture = $this->getOption('culture');
     sfConfig::set('sf_default_culture', $culture);
     dmDoctrineRecord::setDefaultCulture($culture);
     dmConfig::setCulture($culture);
 }
 public function configure()
 {
     $this->widgetSchema['media_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true));
     $this->validatorSchema['media_id'] = new sfValidatorDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true));
     $this->validatorSchema['media_link'] = new sfValidatorPass();
     $this->validatorSchema['media_alt'] = new sfValidatorPass();
     $this->validatorSchema['media_position'] = new sfValidatorPass();
     $this->widgetSchema['width'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['width'] = new dmValidatorCssSize(array('required' => false));
     $this->widgetSchema['height'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['height'] = new dmValidatorCssSize(array('required' => false));
     $this->widgetSchema['cols'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['cols'] = new sfValidatorNumber(array('required' => false, 'min' => 1, 'max' => 20));
     if (!$this->hasDefault('cols')) {
         $this->setDefault('cols', 3);
     }
     $this->widgetSchema['rows'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['rows'] = new sfValidatorNumber(array('required' => false, 'min' => 1, 'max' => 20));
     if (!$this->hasDefault('rows')) {
         $this->setDefault('rows', 3);
     }
     $this->widgetSchema['margin'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['margin'] = new dmValidatorCssSize(array('required' => false));
     $this->widgetSchema['big_width'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['big_width'] = new dmValidatorCssSize(array('required' => false));
     $this->widgetSchema['big_height'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['big_height'] = new dmValidatorCssSize(array('required' => false));
     $methods = $this->getService('i18n')->translateArray(self::$methods);
     $this->widgetSchema['method'] = new sfWidgetFormSelect(array('choices' => $methods));
     $this->validatorSchema['method'] = new sfValidatorChoice(array('choices' => array_keys($methods)));
     if (!$this->getDefault('method')) {
         $this->setDefault('method', dmConfig::get('image_resize_method', 'center'));
     }
     $transitions = $this->getService('i18n')->translateArray(self::$transitions);
     $this->widgetSchema['transition'] = new sfWidgetFormSelect(array('choices' => $transitions));
     $this->validatorSchema['transition'] = new sfValidatorChoice(array('choices' => array_keys($transitions)));
     if (!$this->getDefault('transition')) {
         $this->setDefault('transition', dmArray::first(array_keys($transitions)));
     }
     $this->widgetSchema['speed'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['speed'] = new sfValidatorNumber(array('required' => false, 'min' => 0, 'max' => 2000));
     $this->widgetSchema['opacity'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['opacity'] = new sfValidatorNumber(array('required' => false, 'min' => 0, 'max' => 1));
     $this->widgetSchema['config'] = new sfWidgetFormTextarea(array(), array('cols' => 15, 'rows' => 3));
     $this->validatorSchema['config'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['quality'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['quality'] = new sfValidatorInteger(array('required' => false, 'min' => 0, 'max' => 100));
     if (!$this->getDefault('medias')) {
         $this->setDefault('medias', array());
     }
     //    $this->widgetSchema['background'] = new sfWidgetFormInputText(array(), array('size' =>7));
     //    $this->validatorSchema['background'] = new sfValidatorString(array(
     //      'required' => false
     //    ));
     $this->validatorSchema['widget_width'] = new sfValidatorInteger(array('required' => false));
     parent::configure();
 }
Esempio n. 10
0
 /**
  * Gets credentials the user must have to access this action.
  *
  * @return mixed An array or a string describing the credentials the user must have to access this action
  */
 public function getCredential()
 {
     $credentials = parent::getCredential();
     if (!dmConfig::get('site_active')) {
         $credentials = (array) $credentials;
         $credentials[] = 'site_view';
     }
     return $credentials;
 }
Esempio n. 11
0
 protected function configureFromData($data)
 {
     if (!$this->getOption('file_name')) {
         $this->setOption('file_name', dmString::slugify(dmConfig::get('site_name')) . '-' . dmString::random(8));
     }
     if (!$this->getOption('file_size')) {
         $this->setOption('file_size', strlen($data));
     }
 }
Esempio n. 12
0
 /**
  * Add ga_token setting if missing
  */
 protected function upgradeToAddGaToken()
 {
     if (!dmConfig::has('ga_token')) {
         $setting = new DmSetting();
         $setting->set('name', 'ga_token');
         $setting->fromArray(array('description' => 'Auth token gor Google Analytics, computed from password', 'group_name' => 'internal', 'credentials' => 'google_analytics'));
         $setting->save();
     }
 }
Esempio n. 13
0
 protected function redirectNoScriptName()
 {
     if (!sfConfig::get('sf_no_script_name') || dmConfig::isCli()) {
         return;
     }
     $absoluteUrlRoot = $this->request->getAbsoluteUrlRoot();
     if (0 === strpos($this->request->getUri(), $absoluteUrlRoot . '/index.php')) {
         $this->context->getController()->redirect(str_replace($absoluteUrlRoot . '/index.php', $absoluteUrlRoot, $this->request->getUri()), 0, 301);
     }
 }
Esempio n. 14
0
 public function executeIndex(dmWebRequest $request)
 {
     $this->sitemap = $this->getService('xml_sitemap_generator')->setOption('domain', $this->getRequest()->getAbsoluteUrlRoot());
     if ($this->getUser()->can('system')) {
         $this->shellUser = dmConfig::canSystemCall() ? exec('whoami') : 'www-data';
         $this->phpCli = dmConfig::canSystemCall() ? sfToolkit::getPhpCli() : '/path/to/php';
         $this->rootDir = sfConfig::get('sf_root_dir');
         $this->domainName = $this->getRequest()->getHost();
     }
 }
Esempio n. 15
0
 protected function initialize(array $options)
 {
     try {
         $this->gapi = $this->serviceContainer->getService('gapi')->authenticate(null, null, dmConfig::get('ga_token'));
     } catch (dmGapiException $e) {
         $this->available = false;
         if (sfConfig::get('dm_debug')) {
             throw $e;
         }
     }
     parent::initialize($options);
 }
Esempio n. 16
0
 protected function redirectTrailingSlash()
 {
     if (dmConfig::isCli()) {
         return;
     }
     $uri = $this->request->getUri();
     if ('/' === substr($uri, -1)) {
         if ($uri !== $this->request->getAbsoluteUrlRoot() . '/') {
             $this->context->getController()->redirect(rtrim($uri, '/'), 0, 301);
         }
     }
 }
Esempio n. 17
0
 protected function secure()
 {
     $user = $this->getUser();
     $accessDenied = !dmConfig::get('site_active') && !$user->can('site_view') || !$this->page->get('is_active') && !$user->can('site_view') || $this->page->get('is_secure') && !$user->isAuthenticated() || $this->page->get('is_secure') && $this->page->get('credentials') && !$user->can($this->page->get('credentials'));
     $accessDenied = $this->getDispatcher()->filter(new sfEvent($this, 'dm.page.deny_access', array('page' => $this->page, 'context' => $this->context)), $accessDenied)->getReturnValue();
     if ($accessDenied) {
         // use main/signin page
         $this->getRequest()->setParameter('dm_page', dmDb::table('DmPage')->fetchSignin());
         $this->getResponse()->setStatusCode($user->isAuthenticated() ? 403 : 401);
         $this->forward('dmFront', 'page');
     }
 }
Esempio n. 18
0
 protected function connectServices()
 {
     if (!dmConfig::isCli()) {
         /*
          * Connect the tree watcher to make it aware of database modifications
          */
         $this->getService('page_tree_watcher')->connect();
         /*
          * Connect the cache cleaner
          */
         $this->getService('cache_cleaner')->connect();
     }
     if ('test' != sfConfig::get('sf_environment')) {
         /*
          * Connect the error watcher to make it aware of thrown exceptions
          */
         $this->getService('error_watcher')->connect();
         /*
          * Connect the event log to make it aware of database modifications
          */
         $this->getService('event_log')->connect();
         /*
          * Connect the request log to make it aware of controller end
          */
         $this->getService('request_log')->connect();
     }
     if ($this->getService('response')->isHtmlForHuman()) {
         /*
          * Enable stylesheet compression
          */
         $this->getService('stylesheet_compressor')->connect();
         /*
          * Enable javascript compression
          */
         $this->getService('javascript_compressor')->connect();
     }
     $this->getService('user')->connect();
     /*
      * Enable page i18n builder for multilingual sites
      */
     $cultures = $this->getService('i18n')->getCultures();
     if (count($cultures) > 1) {
         $this->mergeParameter('page_i18n_builder.options', array('cultures' => $cultures));
         $this->getService('page_i18n_builder')->connect();
     }
     /*
      * Disable logging when request has a dm_nolog parameter
      */
     if ($this->getService('request')->getParameter('dm_nolog')) {
         $this->getService('event_log')->setOption('enabled', false);
         $this->getService('request_log')->setOption('enabled', false);
     }
 }
 protected function renameSite()
 {
     $siteName = 'Diem demo';
     $this->log('Rename site to ' . $siteName);
     dmConfig::set('site_name', $siteName);
     foreach (dmDb::table('DmLayout')->findAll() as $layout) {
         $widget = $layout->getArea('top')->Zones[0]->Widgets[0];
         $values = $widget->values;
         if ('Diem' == dmArray::get($values, 'text')) {
             $values['text'] = 'Diem <em>demo</em>';
             $widget->values = $values;
             $widget->save();
         }
     }
 }
Esempio n. 20
0
 public function getReportId()
 {
     if ($this->reportId) {
         return $this->reportId;
     }
     if (!($gaKey = dmConfig::get('ga_key'))) {
         throw new dmGapiException('You must configure a ga_key in the configuration panel');
     }
     foreach ($this->requestAccountData() as $account) {
         if ($account->getWebPropertyId() === $gaKey) {
             return $this->reportId = $account->getProfileId();
         }
     }
     throw new dmGapiException('Current report not found for ga key : ' . $gaKey);
 }
 /**
  * Copy dmConfig(app_*) to sfConfig(app_*) and dmConfig(app::{current_app}_*) to sfConfig(app_*).
  * 
  * @param sfEvent $e
  */
 public function listenToContextLoadedEvent(sfEvent $e)
 {
     $sf_app_prefix = sfConfig::get('sf_app') . '_';
     $sf_app_len = strlen($sf_app_prefix);
     foreach (dmConfig::getAll() as $key => $val) {
         if (substr($key, 0, 4) == 'app_') {
             sfConfig::set($key, $val);
         } else {
             if (substr($key, 0, 5) == 'app::') {
                 if (substr($key, 5, $sf_app_len) == $sf_app_prefix) {
                     sfConfig::set('app_' . substr($key, 5 + $sf_app_len), $val);
                 }
             }
         }
     }
 }
 public function executeGetProcessedImageURL(dmWebRequest $request)
 {
     if (!$this->isAuthorized('media')) {
         return $this->forwardSecure();
     }
     if (!($mediaId = $request->getParameter('media_id'))) {
         return $this->forward404();
     }
     $media = dmDb::table('DmMedia')->findOneBy('id', $mediaId);
     $src = '/' . $media->getWebPath();
     $width = $request->getParameter('width') ? intval($request->getParameter('width')) : null;
     $height = $request->getParameter('height') ? intval($request->getParameter('height')) : null;
     if ($width || $height) {
         $src = $this->getHelper()->media($media)->size($width, $height)->method($request->getParameter('method') ? $request->getParameter('method') : dmConfig::get('image_resize_method'))->getSrc();
     }
     return $this->renderJson(array('src' => $src));
 }
Esempio n. 23
0
 public function get($app = null, $env = null, $culture = null)
 {
     $app = null === $app ? sfConfig::get('sf_app') : $app;
     $env = null === $env ? sfConfig::get('sf_environment') : $env;
     $culture = null === $culture ? $this->culture : $culture;
     if ($config = dmConfig::get('base_urls')) {
         $knownAppUrls = json_decode($config, true);
     } else {
         $knownAppUrls = array();
     }
     $appUrlKey = implode('-', array($app, $env, $culture));
     if (!($appUrl = dmArray::get($knownAppUrls, $appUrlKey))) {
         if (!($script = $this->guessBootScriptFromWebDir($app, $env))) {
             throw new dmException(sprintf('Diem can not guess %s app url', $app));
         }
         $appUrl = $this->requestContext['absolute_url_root'] . '/' . $script;
     }
     return $appUrl;
 }
Esempio n. 24
0
 public function executeIndex(dmWebRequest $request)
 {
     $this->form = new dmConfigForm();
     $this->settings = dmDb::table('DmSetting')->fetchGrouped();
     $this->groups = array();
     foreach ($this->settings as $group => $settings) {
         if ('internal' == $group) {
             continue;
         }
         foreach ($settings as $index => $setting) {
             if ($this->getUser()->can($setting->get('credentials'))) {
                 $this->form->addSetting($setting);
                 if (!in_array($setting->get('group_name'), $this->groups)) {
                     $this->groups[] = $setting->get('group_name');
                 }
             } else {
                 unset($this->settings[$group][$index]);
             }
         }
         if (empty($this->settings[$group])) {
             unset($this->settings[$group]);
         }
     }
     $this->getDispatcher()->notify(new sfEvent($this->form, 'form.post_configure'));
     if ($request->isMethod('post')) {
         if ($this->form->bindAndValid($request)) {
             $formValues = $this->form->getValues();
             foreach ($this->settings as $group => $settings) {
                 foreach ($settings as $index => $setting) {
                     $settingName = $setting->get('name');
                     if (isset($formValues[$settingName]) && $formValues[$settingName] != $setting->value) {
                         dmConfig::set($settingName, $formValues[$settingName]);
                     }
                 }
             }
             $this->getUser()->logInfo('Your modifications have been saved', true);
             return $this->redirect('@dm_config_panel');
         } else {
             $this->getUser()->logAlert('The item has not been saved due to some errors.', true);
         }
     }
 }
Esempio n. 25
0
 protected function doReload()
 {
     if (dmConfig::canSystemCall()) {
         $filesystem = $this->getService('filesystem');
         if (!$filesystem->sf('dm:search-update')) {
             throw new dmException(implode("\n", array($filesystem->getLastExec('command'), $filesystem->getLastExec('output'), 'return code : ' . $filesystem->getLastExec('return'))));
         }
     } else {
         $browser = $this->getService('web_browser');
         $url = $this->getHelper()->link('app:front/+/dmFront/reloadSearchIndex')->getHref();
         touch(sfConfig::get('sf_cache_dir') . '/dm/search_index_' . time());
         $browser->get($url);
         if (200 != $browser->getResponseCode()) {
             throw new dmException('The reload search index call returned the code ' . $browser->getResponseCode());
         }
         $response = $browser->getResponseText();
         if ('ok' != $response) {
             throw new dmException('An error occured: ' . $response);
         }
     }
 }
 public function configure()
 {
     $this->widgetSchema['media_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true));
     $this->validatorSchema['media_id'] = new sfValidatorDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true));
     $this->validatorSchema['media_link'] = new sfValidatorPass();
     $this->validatorSchema['media_alt'] = new sfValidatorPass();
     $this->validatorSchema['media_position'] = new sfValidatorPass();
     $this->widgetSchema['width'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['width'] = new dmValidatorCssSize(array('required' => false));
     $this->widgetSchema['height'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['height'] = new dmValidatorCssSize(array('required' => false));
     $methods = $this->getService('i18n')->translateArray(self::$methods);
     $this->widgetSchema['method'] = new sfWidgetFormSelect(array('choices' => $methods));
     $this->validatorSchema['method'] = new sfValidatorChoice(array('choices' => array_keys($methods)));
     if (!$this->getDefault('method')) {
         $this->setDefault('method', dmConfig::get('image_resize_method', 'center'));
     }
     $this->widgetSchema['show_pager'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['show_pager'] = new sfValidatorBoolean();
     $animations = $this->getService('i18n')->translateArray(self::$animations);
     $this->widgetSchema['animation'] = new sfWidgetFormSelect(array('choices' => $animations));
     $this->validatorSchema['animation'] = new sfValidatorChoice(array('choices' => array_keys($animations)));
     if (!$this->getDefault('animation')) {
         $this->setDefault('animation', dmArray::first(array_keys($animations)));
     }
     $this->widgetSchema['delay'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['delay'] = new sfValidatorNumber(array('required' => false, 'min' => 0, 'max' => 1000));
     if (!$this->hasDefault('delay')) {
         $this->setDefault('delay', 3);
     }
     $this->widgetSchema['quality'] = new sfWidgetFormInputText(array(), array('size' => 5));
     $this->validatorSchema['quality'] = new sfValidatorInteger(array('required' => false, 'min' => 0, 'max' => 100));
     if (!$this->getDefault('medias')) {
         $this->setDefault('medias', array());
     }
     $this->widgetSchema['background'] = new sfWidgetFormInputText(array(), array('size' => 7));
     $this->validatorSchema['background'] = new sfValidatorString(array('required' => false));
     $this->validatorSchema['widget_width'] = new sfValidatorInteger(array('required' => false));
     parent::configure();
 }
Esempio n. 27
0
 public function executeIndex(dmWebRequest $request)
 {
     if ($this->getUser()->can('google_analytics')) {
         $this->form = new dmGoogleAnalyticsForm();
         $this->form->setGapi($this->getService('gapi'));
         if ($request->isMethod('post')) {
             dmConfig::set('ga_key', dmArray::get($request->getParameter($this->form->getName()), 'key'));
             if ($this->form->bindAndValid($request)) {
                 $this->form->save();
                 return $this->redirect('@dm_google_analytics');
             }
         }
     }
     $this->gapiConnected = false;
     if (dmConfig::get('ga_token')) {
         try {
             $this->getService('gapi')->authenticate(null, null, dmConfig::get('ga_token'));
             $this->gapiConnected = true;
         } catch (dmGapiException $e) {
             // bad token
         }
     }
 }
Esempio n. 28
0
 protected function loadSettings()
 {
     $array = array('site_name' => array('default_value' => dmString::humanize(dmProject::getKey()), 'description' => 'The site name', 'group_name' => 'site'), 'site_active' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is the site ready for visitors ?', 'group_name' => 'site'), 'site_indexable' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is the site ready for search engine crawlers ?', 'group_name' => 'site'), 'site_working_copy' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is this site the current working copy ?', 'group_name' => 'site'), 'ga_key' => array('description' => 'The google analytics key without javascript stuff ( e.g. UA-9876614-1 )', 'group_name' => 'tracking', 'credentials' => 'google_analytics'), 'ga_token' => array('description' => 'Auth token gor Google Analytics, computed from password', 'group_name' => 'internal', 'credentials' => 'google_analytics'), 'gwt_key' => array('description' => 'The google webmaster tools filename without google and .html ( e.g. a913b555ba9b4f13 )', 'group_name' => 'tracking', 'credentials' => 'google_webmaster_tools'), 'xiti_code' => array('type' => 'textarea', 'description' => 'The xiti html code', 'group_name' => 'tracking', 'credentials' => 'xiti'), 'search_stop_words' => array('type' => 'textarea', 'description' => 'Words to exclude from searches (e.g. the, a, to )', 'group_name' => 'search engine', 'credentials' => 'search_engine'), 'base_urls' => array('type' => 'textarea', 'description' => 'Diem base urls for different applications/environments/cultures', 'group_name' => 'internal', 'credentials' => 'system'), 'image_resize_method' => array('type' => 'select', 'default_value' => 'center', 'description' => 'Default method when an image needs to be resized', 'params' => 'fit=Fit scale=Scale inflate=Inflate top=Top right=Right left=Left bottom=Bottom center=Center', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'image_resize_quality' => array('type' => 'number', 'default_value' => 95, 'description' => 'Jpeg default quality when generating thumbnails', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_external_blank' => array('type' => 'boolean', 'default_value' => 0, 'description' => 'Links to other domain get automatically a _blank target', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_current_span' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Links to current page are changed from <a> to <span>', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_use_page_title' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Add an automatic title on link based on the target page title', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'title_prefix' => array('default_value' => '', 'description' => 'Append something at the beginning of all pages title', 'group_name' => 'seo', 'credentials' => 'manual_metas'), 'title_suffix' => array('default_value' => ' | ' . dmString::humanize(dmProject::getKey()), 'description' => 'Append something at the end of all pages title', 'group_name' => 'seo', 'credentials' => 'manual_metas'), 'smart_404' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'When a page is not found, user is redirect to a similar page. The internal search index is used to find the best page for requested url.', 'group_name' => 'seo', 'credentials' => 'url_redirection'));
     $existingSettings = dmDb::query('DmSetting s INDEXBY s.name')->withI18n()->fetchRecords();
     foreach ($array as $name => $config) {
         if (!isset($existingSettings[$name])) {
             $setting = new DmSetting();
             $setting->set('name', $name);
             $setting->fromArray($config);
             $setting->save();
         } elseif (!$existingSettings[$name]->hasCurrentTranslation()) {
             /*
              * Try to find an existing config from another culture
              */
             $existing = dmDb::query('DmSettingTranslation s')->where('s.id = ?', $existingSettings[$name]->id)->limit(1)->fetchArray();
             if ($existing = dmArray::first($existing)) {
                 $config = $existing;
                 unset($config['id'], $config['lang']);
             }
             $existingSettings[$name]->fromArray($config)->getCurrentTranslation()->save();
         }
     }
     dmConfig::load(false);
 }
Esempio n. 29
0
$expected = dmProject::rootify(dmArray::get($helper->get('service_container')->getParameter('search_engine.options'), 'dir'));
$t->is($engine->getFullPath(), $expected, 'Current engine full path is ' . $expected);
$t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir');
$engine->setDir('cache/testIndex');
foreach ($helper->get('i18n')->getCultures() as $culture) {
    $user->setCulture($culture);
    $currentIndex = $engine->getCurrentIndex();
    $t->is($currentIndex->getName(), 'dm_page_' . $culture, 'Current index name is ' . $currentIndex->getName());
    $t->is($currentIndex->getCulture(), $culture, 'Current index culture is ' . $culture);
    $t->is($currentIndex->getFullPath(), dmProject::rootify('cache/testIndex/' . $currentIndex->getName()), 'Current index full path is ' . $currentIndex->getFullPath());
}
$user->setCulture(sfConfig::get('sf_default_culture'));
$currentIndex = $engine->getCurrentIndex();
$t->isa_ok($currentIndex->getLuceneIndex(), 'Zend_Search_Lucene_Proxy', 'The current index is instanceof Zend_Search_Lucene_Proxy');
$t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir');
dmConfig::set('search_stop_words', 'un le  les de,du , da, di ,do   ou ');
$t->is($currentIndex->getStopWords(), array('un', 'le', 'les', 'de', 'du', 'da', 'di', 'do', 'ou'), 'stop words retrieved from site instance : ' . implode(', ', $currentIndex->getStopWords()));
$t->diag('Cleaning text');
$html = '<ol><li><a class="link dm_parent" href="symfony">Accueil</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines">Domaines</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines/77-cursus-proin1i471j0u">cursus. Proin1i471j0u</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1">trices interdum risus. Duisgpcinqn1</a></li><li>></li><li><span class="link dm_current">Info : t, auctor ornare, risus. Donec lo</span></li></ol><span class="link dm_current">Info : t, auctor ornare, risus. Donec lo</span><div class="info_tag list_by_info"><ul class="elements"><li class="element clearfix"><a class="link" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1/t-auctor-ornare-risus-donec-lo-79/t-donec">t. Donec</a></li><li class="element clearfix"><a class="link" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1/t-auctor-ornare-risus-donec-lo-79/em-ipsu">em ipsu</a></li></ul></div>';
$expected = 'accueil domaines cursus proin1i471j0u trices interdum risus duisgpcinqn1 info t auctor ornare risus donec lo info t auctor ornare risus donec lo t donec em ipsu';
$t->is($currentIndex->cleanText($html), $expected, 'cleaned text : ' . $expected);
$html = '<div>some content<a href="url">a link text  é àî</a>... end</div>';
$expected = 'some content a link text e ai end';
$t->is($currentIndex->cleanText($html), $expected, 'cleaned text : ' . $expected);
// for now this doesn't work on windows
if ('/' !== DIRECTORY_SEPARATOR) {
    return;
}
$t->diag('Populate all indices');
$t->ok($engine->populate(), 'Indices populated');
$t->is($user->getCulture(), sfConfig::get('sf_default_culture'), 'User\'s culture has not been changed');
Esempio n. 30
0
<?php

echo _open('div.dm.dm_auth.unsupported_browser');
echo _tag('h1.site_name', dmConfig::get('site_name'));
echo _tag('div.message', _tag('p.dm_browser_unsupported.mt10', __("Sorry, it looks like you're using a browser that isn't supported.")) . _tag('p.dm_browser_suggestion.mt10', __("We suggest that you use one of these browsers:")) . _tag('div.dm_suggested_browsers.clearfix', _link('http://www.mozilla.com/firefox/')->text(_media('dmCore/images/64/firefox.png')->size(64, 64) . 'Firefox') . _link('http://www.google.com/chrome')->text(_media('dmCore/images/64/chrome.png')->size(64, 64) . 'Chrome') . _link('http://www.apple.com/safari/')->text(_media('dmCore/images/64/safari.png')->size(64, 64) . 'Safari') . _link('http://www.opera.com/browser/')->text(_media('dmCore/images/64/opera.png')->size(64, 64) . 'Opera')) . _tag('div.dm_skip_browser_detection', _link('@signin?skip_browser_detection=1')->text(__('Or continue at your own peril'))));
echo _close('div');
echo _link('http://diem-project.org/')->text('Diem CMF CMS for symfony')->set('.generator_link');