当前位置: 首页>>代码示例>>PHP>>正文


PHP c2cTools类代码示例

本文整理汇总了PHP中c2cTools的典型用法代码示例。如果您正苦于以下问题:PHP c2cTools类的具体用法?PHP c2cTools怎么用?PHP c2cTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了c2cTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeView

 /**
  * Executes view action.
  */
 public function executeView()
 {
     parent::executeView();
     if (!$this->document->isArchive() && $this->document['redirects_to'] == NULL) {
         $user = $this->getUser();
         $prefered_cultures = $user->getCulturesForDocuments();
         $associated_parkings = c2cTools::sortArray(array_filter($this->associated_docs, array('c2cTools', 'is_parking')), 'elevation');
         if (count($associated_parkings)) {
             $associated_parkings = Association::createHierarchyWithBestName($associated_parkings, $prefered_cultures, array('type' => 'pp'));
             $associated_parkings = Parking::getAssociatedParkingsData($associated_parkings);
         }
         $this->associated_parkings = $associated_parkings;
         $related_portals = array();
         Portal::getLocalPortals($related_portals, $this->associated_areas);
         $this->related_portals = $related_portals;
         $product_type_list = sfConfig::get('mod_products_types_list');
         $product_type_index_list = $this->document->get('product_type');
         $product_type_name_list = array();
         foreach ($product_type_index_list as $product_type_index) {
             $product_type_name_list[] = $this->__($product_type_list[$product_type_index]);
         }
         $product_types = implode(', ', $product_type_name_list);
         $doc_name = $this->document->get('name');
         $title = $doc_name;
         if ($this->document->isArchive()) {
             $version = $this->getRequestParameter('version');
             $title .= ' :: ' . $this->__('revision') . ' ' . $version;
         }
         $title .= ' :: ' . $product_types;
         $this->setPageTitle($title);
         $description = array($product_types . ' :: ' . $doc_name, $this->getAreasList());
         $this->getResponse()->addMeta('description', implode(' - ', $description));
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:37,代码来源:actions.class.php

示例2: executeSwitchformfactor

 public function executeSwitchformfactor()
 {
     $user = $this->getUser();
     if ($user->getAttribute('form_factor', 'desktop') === 'mobile') {
         $user->setAttribute('form_factor', 'desktop');
         if (!c2cTools::mobileRegexp()) {
             // delete form_factor cookie (not needed)
             $this->getResponse()->setCookie('form_factor', null, -1);
         } else {
             // set cookie so that we are sure to prevent redirection on next sessions
             $this->getResponse()->setCookie('form_factor', 'desktop', time() + 60 * 60 * 24 * 30);
         }
     } else {
         $user->setAttribute('form_factor', 'mobile');
         if (c2cTools::mobileRegexp()) {
             // delete form_factor cookie (not needed)
             $this->getResponse()->setCookie('form_factor', null, -1);
         } else {
             // set cookie so that we are sure to set form factor correctly on next sessions
             $this->getResponse()->setCookie('form_factor', 'mobile', time() + 60 * 60 * 24 * 30);
         }
     }
     // redirect to referer
     return $this->redirect($this->getRequest()->getReferer());
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:25,代码来源:actions.class.php

示例3: execute

 public function execute($filterChain)
 {
     $context = $this->getContext();
     $user = $context->getUser();
     if ($this->isFirstCall() && !$user->hasAttribute('form_factor')) {
         // if you make changes here, be sure also to check web/forums/include/common.php
         // and check varnish vcl file
         $cookie = $context->getRequest()->getCookie('form_factor');
         if ($cookie === 'mobile' || $cookie === null && c2cTools::mobileRegexp()) {
             $user->setAttribute('form_factor', 'mobile');
         } else {
             $user->setAttribute('form_factor', 'desktop');
         }
     }
     if ($user->getAttribute('form_factor', 'desktop') === 'mobile') {
         // change layout for mobile_layout
         $context->getResponse()->setParameter($context->getModuleName() . '_' . $context->getActionName() . '_layout', 'mobile_layout', 'symfony/action/view');
         $context->getResponse()->addStylesheet('/static/css/mobile.css', 'last');
     } else {
         $context->getResponse()->addStylesheet('/static/css/default.css');
         $context->getResponse()->addStylesheet('/static/css/menu.css');
         $context->getResponse()->addStylesheet('/static/css/print.css', 'print');
     }
     // execute next filter
     $filterChain->execute();
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:26,代码来源:FormFactorFilter.class.php

示例4: loadRessources

function loadRessources()
{
    $response = sfContext::getInstance()->getResponse();
    if (!c2cTools::mobileVersion()) {
        $response->addJavascript('/static/js/modal.js', 'last');
        $response->addStylesheet('/static/css/modal.css', 'last');
    }
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:8,代码来源:ModalBoxHelper.php

示例5: execute

 public function execute(&$value, &$error)
 {
     // file upload check
     foreach ($value['error'] as $error_code) {
         if ($error_code) {
             $error = $this->getParameter('upload_error');
             return false;
         }
     }
     $validation = sfConfig::get('app_images_validation');
     // weight check
     foreach ($value['size'] as $file_size) {
         if ($file_size > $validation['weight']) {
             $error = $this->getParameter('weight_error');
             return false;
         }
     }
     // type check
     // FIXME with symfony 1.0, the type is the one given by the browser
     // we prefer to use or own mime type checker (this is what is done in further
     // versions of symfony, using system file check)
     foreach ($value['tmp_name'] as $file) {
         $file_type = c2cTools::getMimeType($file);
         if (!in_array($file_type, $validation['mime_types'])) {
             $error = $this->getParameter('type_error');
             return false;
         }
     }
     foreach ($value['tmp_name'] as $k => $filename) {
         if ($value['type'][$k] != 'image/svg+xml') {
             list($width, $height) = getimagesize($filename);
         } else {
             // are there any script?
             if (SVG::hasScript($filename)) {
                 $error = $this->getParameter('svg_script_error');
                 return false;
             }
             // dimensions
             $dimensions = SVG::getSize($filename);
             if ($dimensions === false) {
                 $error = $this->getParameter('svg_error');
                 return false;
             } else {
                 list($width, $height) = $dimensions;
             }
         }
         // height/width check
         if ($width > $validation['max_size']['width'] || $height > $validation['max_size']['height']) {
             $error = $this->getParameter('max_dim_error');
             return false;
         }
         if ($width < $validation['min_size']['width'] || $height < $validation['min_size']['height']) {
             $error = $this->getParameter('min_dim_error');
             return false;
         }
     }
     return true;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:58,代码来源:myImagesValidator.class.php

示例6: phone_link

function phone_link($phone = '')
{
    if (!empty($phone) && c2cTools::mobileVersion()) {
        $simple_phone = preg_replace('/\\(0\\)/', '', str_replace(array(' ', '.'), '', $phone));
        // if number is not only digits,+,- do not try to present it as a link
        if (!ereg('[0-9\\+-]+', $simple_phone)) {
            return $phone;
        }
        $link = content_tag('a', $phone, array('href' => 'tel:' . $simple_phone));
        return $link;
    } else {
        return $phone;
    }
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:14,代码来源:LinkHelper.php

示例7: display_flash_message

/**
* Display flash message if needed
*/
function display_flash_message($type)
{
    $flash = sfContext::getInstance()->getUser()->getAttribute($type, null, 'symfony/flash');
    if ($flash) {
        $message = '<div class="' . $type . '" id="' . $type . '"><div>' . $flash . '</div></div>';
        if (!c2cTools::mobileVersion()) {
            // show feedback div, highlight it, and then fade it out and remove it
            $js = javascript_queue("\$('#{$type}').delay(3000).animate({opacity:0}, {duration:1500, complete: function() { \$(this).hide(); }});");
        } else {
            $js = javascript_queue("\$('#{$type}').click(function() { \$(this).hide(); });");
        }
        return $message . $js;
    }
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:17,代码来源:FlashHelper.php

示例8: execute

 public function execute(&$value, &$error)
 {
     $allowed_mime_types = $this->getParameterHolder()->get('allowed');
     $allowed_mime_types = is_array($allowed_mime_types) ? $allowed_mime_types : array($allowed_mime_types);
     // FIXME with symfony 1.0, the type is the one given by the browser
     // we prefer to use or own mime type checker (this is what is done in further
     // versions of symfony, using system file check)
     $mime_type = c2cTools::getMimeType($value['tmp_name']);
     if (!in_array($mime_type, $allowed_mime_types)) {
         $error = $this->getParameter('type_error');
         return false;
     }
     return true;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:14,代码来源:myFileMimeTypeValidator.class.php

示例9: geocode_auto_complete

function geocode_auto_complete($name, $service)
{
    $mobile_version = c2cTools::mobileVersion();
    $service_class = $service === 'nominatim' ? ' nominatim' : ' geonames';
    $out = input_tag($name, '', array('class' => 'geocode_auto_complete' . $service_class, 'placeholder' => __('enter place name'), 'data-noresult' => __('no results')));
    if ($mobile_version) {
        $out .= content_tag('span', '<br />' . __('autocomplete_help'), array('class' => 'mobile_auto_complete_background'));
        $out .= content_tag('span', 'X', array('class' => 'mobile_auto_complete_escape'));
    }
    // following script will automatically intanciate geocode autocompleter
    $out .= javascript_queue('$.ajax({
      url: "' . minify_get_combined_files_url('/static/js/geocode_autocompleter.js') . '",
      dataType: "script",
      cache: true});');
    return $out;
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:16,代码来源:AutoCompleteHelper.php

示例10: moveAll

 /**
  * Move given image and its resized versions.
  */
 public static function moveAll($file, $pathFrom, $pathTo)
 {
     c2cTools::log("moving {$file} from {$pathFrom} to {$pathTo}");
     $types = sfConfig::get('app_images_types', array());
     list($file_name, $file_ext) = self::getFileNameParts($file);
     // move original
     $success = rename($pathFrom . DIRECTORY_SEPARATOR . $file, $pathTo . DIRECTORY_SEPARATOR . $file);
     // move thumbs
     foreach ($types as $type) {
         $success = $success && rename($pathFrom . DIRECTORY_SEPARATOR . $file_name . $type['suffix'] . $file_ext, $pathTo . DIRECTORY_SEPARATOR . $file_name . $type['suffix'] . $file_ext);
     }
     // move svg if any
     if (file_exists($pathFrom . DIRECTORY_SEPARATOR . $file_name . '.svg')) {
         $success = $success && rename($pathFrom . DIRECTORY_SEPARATOR . $file_name . '.svg', $pathTo . DIRECTORY_SEPARATOR . $file_name . '.svg');
     }
     return $success;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:20,代码来源:Images.class.php

示例11: subscribe

 /**
  * Adds given address to given mailing list.
  * @param string listname
  * @param string email
  * @return boolean status (true=success, false=failure)
  */
 public static function subscribe($listname, $email)
 {
     $conn = sfDoctrine::Connection();
     try {
         $conn->beginTransaction();
         $sympa = new Sympa();
         $sympa->list_subscriber = $listname;
         $sympa->user_subscriber = $email;
         $sympa->save();
         $conn->commit();
         return true;
     } catch (Exception $e) {
         // Subscription failed! For instance because email address was already registered.
         $conn->rollback();
         c2cTools::log("Failed adding address {$email} to list {$listname}: " . $e->getMessage());
         return false;
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:24,代码来源:Sympa.class.php

示例12: language_select_list

function language_select_list($module, $id, $current_language, $translated_languages)
{
    $mobile_version = c2cTools::mobileVersion();
    $items = array();
    foreach (Language::getAll() as $language => $value) {
        $lang = format_language_c2c($language);
        if ($current_language == $language) {
            $items[] = '<div class="current_lang">' . ($mobile_version ? $language : $lang) . '</div>';
        } else {
            $existing_lang = in_array($language, $translated_languages);
            $options = $existing_lang ? array('class' => 'translated') : array('class' => 'not_translated', 'rel' => 'nofollow');
            if (!$mobile_version) {
                $items[] = link_to($lang, "@document_by_id_lang?module={$module}&id={$id}&lang={$language}", $options);
            } else {
                $items[] = $existing_lang ? link_to($language, "@document_by_id_lang?module={$module}&id={$id}&lang={$language}", $options) : '<span class="not_translated">' . $language . '</span>';
            }
        }
    }
    return implode(' |&nbsp;', $items);
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:20,代码来源:LanguageHelper.php

示例13: executeGetmultipleselect

 public function executeGetmultipleselect()
 {
     $mobile_version = c2cTools::mobileVersion();
     $separate_prefs = $this->hasRequestParameter('sep_prefs') ? $this->getRequestParameter('sep_prefs') : 'true';
     $separate_prefs = $separate_prefs == 'false' ? false : true;
     $area_type = $this->getRequestParameter('area_type');
     if (!$mobile_version) {
         $default_width = 'auto';
         $default_height = '350px';
     } else {
         $default_width = '216px';
         $default_height = '3.8em';
     }
     $height = $this->hasRequestParameter('height') ? $this->getRequestParameter('height') . 'px' : $default_height;
     $width = $this->hasRequestParameter('width') ? $this->getRequestParameter('width') . 'px' : $default_width;
     $select_id = $this->hasRequestParameter('select_id') ? $this->getRequestParameter('select_id') : 'places';
     $select_name = $this->hasRequestParameter('select_id') ? $this->getRequestParameter('select_name') : 'areas';
     $areas = $this->getAreas($area_type, $separate_prefs);
     sfLoader::loadHelpers(array('Tag', 'Form'));
     return $this->renderText(select_tag($select_name, options_for_select($areas, $separate_prefs ? null : c2cPersonalization::getInstance()->getPlacesFilter()), array('id' => $select_id, 'multiple' => true, 'style' => 'width:' . $width . '; height:' . $height . ';')) . input_hidden_tag($select_id . '_type', $area_type));
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:21,代码来源:actions.class.php

示例14: execute

 public function execute($filterChain)
 {
     $context = $this->getContext();
     $session_user = $context->getUser();
     $cookie_name = sfConfig::get('app_remember_key_cookie_name', 'c2corg_remember');
     $cookie_value = $context->getRequest()->getCookie($cookie_name);
     if ($this->isFirstCall() && !$session_user->isConnected() && !is_null($cookie_value)) {
         c2cTools::log('{rememberFilter} user has a cookie, trying to auto login');
         $remember_key = RememberKey::getKey($cookie_value);
         if ($remember_key) {
             c2cTools::log('{rememberFilter} user found from his cookie');
             $user = $remember_key->getUser();
             if ($user->exists()) {
                 $session_user->signIn($user->get('private_data')->getLoginName(), $user->get('private_data')->getPassword(), true, true);
             }
             // User has signed in, and is now correctly in symfony session. However, forums
             // and several personnalization functions rely on cookies, that will be sent with the request,
             // but are not yet 'available' from javascript if the value expired from previous sessions (they will be on next page)
             // easiest solution is to force the browser to reload the current page
             // we only do this for GET requests
             $request = $this->getContext()->getRequest();
             if ($request->getMethod() == sfRequest::GET) {
                 // symfony 1.0 getUriPrefix is not working well with https on haproxy
                 // it then tries to redirect to https://site.org:80, which is wrong
                 $proto = $request->isSecure() ? 'https' : 'http';
                 $request_uri = $proto . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
                 $this->getContext()->getController()->redirect($request_uri);
                 exit;
             }
         } else {
             // delete cookie value in client so that no more requests are made to the db
             sfContext::getInstance()->getResponse()->setCookie($cookie_name, '');
             // log this
             c2cTools::log('{rememberFilter} user has unknown remember key!');
             c2cActions::statsdIncrement('bad_remember_cookie', 'symfony.' . sfConfig::get('sf_environment') . '.users.');
         }
     }
     $filterChain->execute();
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:39,代码来源:rememberFilter.class.php

示例15: start_section_tag

function start_section_tag($label, $container_id, $state = 'opened', $map = false, $first = false, $hide = false, $show_tip = true)
{
    $class = 'article_titre_bg';
    if ($first) {
        $class .= ' hfirst';
    }
    $picto_class = $state == 'opened' ? 'picto_close' : 'picto_open';
    $status = __($state == 'opened' ? 'section close' : 'section open');
    $label = picto_tag($picto_class, '', array('id' => $container_id . '_toggle')) . __($label);
    if ($show_tip && !c2cTools::mobileVersion()) {
        $label .= '<span id="tip_' . $container_id . '" class="tips">[' . $status . ']</span>';
        $up = '<a href="#header">' . picto_tag('action_up', __('menu'), array('class' => 'go_up')) . '</a>';
    } else {
        $up = '';
    }
    $style = $hide ? '" style="display:none' : '';
    $html = '<div class="' . $class . '" id="' . $container_id . '_tbg' . $style . '">' . '<div class="title" id="' . $container_id . '_section_title" title="' . $status . '">' . '<a href="#" id="' . $container_id . '" data-toggle-view="' . $container_id . '">' . $label . '</a>' . $up . '</div>' . '</div>';
    if (!$map) {
        $display = $state == 'opened' && !$hide ? '' : ' style="display:none;"';
        $html .= '<section id="' . $container_id . '_section_container" class="section"' . $display . '>';
    }
    return $html;
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:23,代码来源:SectionsHelper.php


注:本文中的c2cTools类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。