示例#1
0
function init_media_library()
{
    sfContext::getInstance()->getResponse()->addJavascript('/sfMediaLibraryPlugin/js/main', 'last');
    $url = url_for('sfMediaLibrary/choice');
    $js = 'sfMediaLibrary.init(\'' . $url . '\')';
    return javascript_tag($js);
}
function stop_remote_pager()
{
    use_helper('Javascript');
    // until prototype implements a stop() method for the PeriodicalExecuter,
    // the following (almost a hack) is the only simple way to stop it
    return javascript_tag("pager_watch.callback = function () {};");
}
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('/sfExtraWidgetsPlugin/js/spinbutton.js');
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/spinbutton.css');
     return parent::render($name, $value, $attributes, $errors) . javascript_tag("new SpinButton(\$('" . $this->generateId($name) . "'),{min:" . $this->getOption('min') . ", max:" . $this->getOption('max') . "}); \$('" . $this->generateId($name) . "').addClassName('spin-button');");
 }
示例#4
0
文件: mp3Handler.php 项目: EQ4/smint
 /** Returns appropriate JS code for mp3 player config.
  * @param $files Array of Filedesc instances
  * @param $aSegmSearch Array with segmentation information
  *
  */
 public static function getMp3PlayerConfig($files = array(), $aSegmSearch = array())
 {
     //needed for javascript_tag
     use_helper('JavascriptBase');
     $player = sfConfig::get('app_mp3player_defaultplayer', 'worldpress');
     switch ($player) {
         case 'flash-mp3-player':
             return '';
             break;
         case 'worldpress':
             $playerConfig = sfConfig::get('app_mp3player_worldpress');
             $autostart = isset($playerConfig['autostart']) ? $playerConfig['autostart'] : 'yes';
             $width = isset($playerConfig['width']) ? $playerConfig['width'] : '200';
             $skin = $playerConfig['skin'];
             return javascript_tag("AudioPlayer.setup('" . public_path('audio-player/player.swf') . "', \n                  {\n                    width: '{$width}', \n                    autostart: '{$autostart}', \n                    animation: 'no', \n                    {$skin},\n                  });");
             break;
         case 'smintplayer':
         default:
             // get configuration
             $playerConfig = sfConfig::get('app_mp3player_smintplayer');
             // build options array of array. First dimension is list of files, second is assoc array with values for the player
             $options = array();
             if (!isset($aSegmSearch['enabled'])) {
                 $aSegmSearch['enabled'] = false;
             }
             foreach ($files as $i => $filedesc) {
                 $filerec = FilePeer::getFileByExternalKey($filedesc->getTracknr());
                 if (!isset($filerec)) {
                     // no recrod returned - maybe no metadata in the db?
                     $tmparray = array('text' => "(No metadata available)", 'audiofile_mp3' => url_for("getAudioFile/download", true) . "?fileid=" . rawurlencode($filedesc->getTracknr()) . "&format=mp3", 'audiofile_ogg' => url_for("getAudioFile/download", true) . "?tracknr=" . rawurlencode($filedesc->getTracknr()) . "&format=ogg", 'waveformfile' => url_for("getAudioFile/download", true) . "?tracknr=" . rawurlencode($filedesc->getTracknr()) . "&format=waveform", 'duration' => isset($iDurationMs) ? $iDurationMs : 0, 'segments' => $aSegmSearch['enabled'] ? $aSegmSearch['resultsegments'][$i] : array(), 'searchsimilarfunc' => 'smint_' . smintTools::generateHtmlId($filedesc->getTracknr()) . '()', 'backlinktext' => "License track from gettyimages music", 'backlinkurl' => url_for("search/redirect") . "?url=" . rawurlencode("http://www.gettyimages.at/music/download-songs/" . $filedesc->getTracknr() . "?ref=spec"));
                 } else {
                     $iBitrate = $filerec->getBitrate();
                     $sUri = $filerec->getUri();
                     // estimate duration
                     if (file_exists($sUri)) {
                         $iSize = filesize($sUri);
                         if ($iSize) {
                             // file size divided by bytes per second, times 1000 to get ms.
                             // bitrate is k bits per second, so multiply by 1024 to get bits, and divide by 8 to get bytes
                             $iDurationMs = intval($iSize / ($iBitrate * 1024 / 8) * 1000);
                         } else {
                             mysfLog::log($this, "DEBUG Could not read file size: {$sUri}");
                             $iDurationMs = 0;
                         }
                     } else {
                         mysfLog::log($this, "WARNING File does not exist: {$sUri}");
                         $iDurationMs = 0;
                     }
                     $tmparray = array('text' => $filedesc->getTitle() . ' | ' . $filedesc->getPerformers() . ' | ' . $filedesc->getGenre(), 'audiofile_mp3' => smintUploadFileHelper::getDirectFileUrl($filerec->getUri()), 'audiofile_ogg' => url_for("getAudioFile/download", true) . "?tracknr=" . rawurlencode($filedesc->getTracknr()) . "&format=ogg", 'waveformfile' => url_for("getAudioFile/download", true) . "?tracknr=" . rawurlencode($filedesc->getTracknr()) . "&format=waveform", 'duration' => isset($iDurationMs) ? $iDurationMs : 0, 'segments' => $aSegmSearch['enabled'] ? $aSegmSearch['resultsegments'][$i] : array(), 'searchsimilarfunc' => 'smint_' . smintTools::generateHtmlId($filedesc->getTracknr()) . '()', 'backlinktext' => "License track from gettyimages music", 'backlinkurl' => url_for("search/redirect") . "?url=" . rawurlencode("http://www.gettyimages.at/music/download-songs/" . $filedesc->getTracknr() . "?ref=spec"));
                 }
                 $options[] = $tmparray;
             }
             // we cannot put all these fields into one array since the output format must be like
             // , A: XXXX, B: XXX
             // and not
             //, {A: XXXX, B: XXX}
             return ", playlist: " . smintTools::my_options_for_javascript($options) . ", waveform_resolution: " . intval(sfConfig::get('app_defaults_waveform_resolution')) . ', waveform_factor: ' . doubleval(sfConfig::get('app_defaults_waveform_factor'));
             break;
     }
 }
 function renderMenu()
 {
     echo javascript_include_tag('sfShowHideMenu/ClickShowHideMenu.js');
     echo stylesheet_tag('sfShowHideMenu/ClickShowHideMenu.css');
     echo $this->buildMenuData();
     $menu_js = "var clickMenu1 = new ClickShowHideMenu('click-menu1');\n clickMenu1.init();\n";
     echo javascript_tag($menu_js);
 }
function javascript_queue($js)
{
    if (sfContext::getInstance()->getRequest()->isXmlHttpRequest()) {
        return javascript_tag('(function(C2C){' . $js . '})(window.C2C=window.C2C||{});');
    } else {
        return javascript_tag('(function(w,c){w[c]=w[c]||{};(w[c]._q=w[c]._q||[]).push(function(){' . $js . "});})(window,'C2C');");
    }
}
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('/sfExtraWidgetsPlugin/js/tinymce/plugins/tinybrowser/tb_tinymce.js.php');
     $response->addJavascript('/sfExtraWidgetsPlugin/js/tinymce/tiny_mce.js');
     $js = "\n            tinyMCE.init({\n                // General options\n                mode : 'exact',\n                elements: '" . $this->generateId($name) . "',\n                skin : '" . sfConfig::get('app_tinymce_skin', 'o2k7') . "',\n                language: '" . substr(sfContext::getInstance()->getUser()->getCulture(), 0, 2) . "',\n                theme : 'advanced',\n                height: " . $this->getOption('height') . ",\n                width: " . $this->getOption('width') . ",\n                dialog_type: '" . sfConfig::get('app_tinymce_dialog_type', 'window') . "',\n                editor_selector : 'mceEditor',\n                editor_deselector : 'mceNoEditor',\n                relative_urls : " . sfConfig::get('app_tinymce_relative_urls', 'false') . ",\n                gecko_spellcheck: " . sfConfig::get('app_tinymce_gecko_spellcheck', 'true') . ",\n                entity_encoding : '" . sfConfig::get('app_tinymce_entity_encoding', 'raw') . "',\n                plugins : '" . sfConfig::get('app_tinymce_plugins') . "',\n\n                // Theme options\n                theme_advanced_buttons1 : '" . sfConfig::get('app_tinymce_theme_advanced_buttons1') . "',\n                theme_advanced_buttons2 : '" . sfConfig::get('app_tinymce_theme_advanced_buttons2') . "',\n                theme_advanced_buttons3 : '" . sfConfig::get('app_tinymce_theme_advanced_buttons3') . "',\n                theme_advanced_toolbar_location : '" . sfConfig::get('app_tinymce_theme_advanced_toolbar_location') . "',\n                theme_advanced_toolbar_align : '" . sfConfig::get('app_tinymce_theme_advanced_toolbar_align') . "',\n                theme_advanced_statusbar_location : '" . sfConfig::get('app_tinymce_theme_advanced_statusbar_location') . "',\n                theme_advanced_resizing : " . sfConfig::get('app_tinymce_theme_advanced_resizing') . ",\n                \n                file_browser_callback : '" . sfConfig::get('app_tinymce_file_browser_callback') . "'\n            });\n        ";
     return javascript_tag($js) . parent::render($name, $value, $attributes, $errors);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/autocompleter.css');
     $autocompleteDiv = content_tag('div', '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
     $autocompleteJs = javascript_tag("\n            function ac_update_" . $this->generateId($name) . "(text, li)\n            {\n                \$('" . $this->generateId($name) . "').value = li.id;\n            }\n            \n            new Ajax.Autocompleter(\n                '" . $this->generateId($name) . "',\n                '" . $this->generateId($name) . '_autocomplete' . "',\n                '" . url_for($this->getOption('url')) . "',\n                {\n                    paramName: '" . $this->getOption('param') . "',\n                    indicator: 'indicator-" . $this->generateId($name) . "',\n                    minChars: " . $this->getOption('min_chars') . ",\n                    afterUpdateElement: ac_update_" . $this->generateId($name) . "\n                });");
     return parent::render($name, $value, $attributes, $errors) . '<span id="indicator-' . $this->generateId($name) . '" style="display: none;">&nbsp;&nbsp;<img src="/sfExtraWidgetsPlugin/img/ajax-loader.gif" align="absmiddle" alt="Loading" /></span>' . $autocompleteDiv . $autocompleteJs;
 }
 function renderHtml()
 {
     echo stylesheet_tag('sfToolbar/dhtmlXToolbar.css');
     echo javascript_include_tag('sfToolbar/dhtmlXProtobar.js');
     echo javascript_include_tag('sfToolbar/dhtmlXToolbar.js');
     echo javascript_include_tag('sfToolbar/dhtmlXCommon.js');
     echo $this->renderTable();
     echo javascript_tag($this->buildData());
 }
示例#10
0
function fancy_assets()
{
    foreach (sfConfig::get('app_csFormTransformPlugin_javascripts') as $javascript) {
        sfContext::getInstance()->getResponse()->addJavascript($javascript, 'last');
    }
    foreach (sfConfig::get('app_csFormTransformPlugin_stylesheets') as $stylesheet) {
        sfContext::getInstance()->getResponse()->addStylesheet($stylesheet, 'last');
    }
    echo javascript_tag('$(function() { $("form.jqtransform").jqTransform();});');
}
 public function getCollapseSnippet($name, $count)
 {
     if (is_null($this->getOption('collapse')) || !$this->getOption('collapse')) {
         return null;
     }
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Javascript'));
     $id = $this->generateId($name);
     $snippet = link_to_function($this->getCollapseText($count), sprintf("document.getElementById('%s').style.display = (document.getElementById('%s').style.display == 'none' ? 'block' : 'none'); this.style.display = 'none';", $id, $id));
     $snippet .= javascript_tag(sprintf("document.getElementById('%s').style.display = 'none'", $id));
     return $snippet;
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array("JavascriptBase"));
     if (preg_match('/\\d+-\\d+-\\d+/', $value)) {
         $value = strtotime($value);
         if ($value !== false) {
             $value = date('d/m/Y', $value);
         }
     }
     return javascript_tag($this->getJavascriptCode($this->generateId($name))) . $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'style' => "width: 10em; text-align: right", 'value' => $value), $attributes)) . $this->renderOwnHelp();
 }
 /**
  * @author John.meng
  *
  */
 public function renderMenu($items = null)
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('/sfdojo/dojo');
     $header_js = "dojo.require(\"dojo.widget.Menu2\");\n dojo.hostenv.writeIncludes();\n";
     $js_data = javascript_tag($header_js);
     //	    $menu_data = $items;
     $this->renderMainContianer();
     $menu_data = $this->renderMainItem() . $this->item_html;
     return $js_data . $menu_data;
 }
 /**
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $server = $this->getServerUrl();
     $key = $this->getOption('public_key');
     if (array_key_exists('context', $attributes) && $attributes['context'] == 'ajax') {
         // Arbitrary flag, unset it
         unset($attributes['context']);
         return '<div id="captchaWrap"></div>' . javascript_tag("\n            Recaptcha.create('" . $key . "', 'captchaWrap', {" . "theme:'" . $this->getOption('theme') . "'," . " lang:'" . $this->getOption('culture') . "'" . "});");
     }
     parent::render($name, $value, $attributes, $errors);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     is_null($value) ? $value = 1 : ($value = $value);
     $response = sfContext::getInstance()->getResponse();
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/rating.css');
     $response->addJavascript('/sfExtraWidgetsPlugin/js/livepipe.js');
     $response->addJavascript('/sfExtraWidgetsPlugin/js/rating/rating.js');
     $ret = tag('input', array('name' => $name, 'id' => $this->generateId($name), 'value' => $value, 'type' => 'hidden'));
     $ret .= content_tag('div', '', array('id' => $this->generateId($name) . '_container', 'class' => 'rating_container'));
     $ret .= javascript_tag("var rating_eight = new Control.Rating('" . $this->generateId($name) . '_container' . "',{ input: '" . $this->generateId($name) . "', multiple: true, max: " . $this->getOption('max') . " });");
     return $ret;
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('/sfExtraWidgetsPlugin/js/money.js');
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/money.css');
     if (is_null($value)) {
         $value = 0;
     }
     $numberFormat = new sfNumberFormat(sfContext::getInstance()->getUser()->getCulture());
     $value = $numberFormat->format($value, '#.00');
     return '<div id="container-' . $this->generateId($name) . '">' . parent::render($name, $value, $attributes, $errors) . '</div>' . javascript_tag("new Money(\$('" . $this->generateId($name) . "'),{ symbol: '" . $this->getOption('symbol') . "'})");
 }
 public function getSlotEditor($slot)
 {
     $options = array('size' => '80x10', 'id' => 'edit_textarea' . $slot->getName(), 'tinymce_options' => sfConfig::get('app_sfSimpleCMS_tinymce_options', 'width: "100%"'));
     $script = '';
     if (sfConfig::get('app_sfSimpleCMS_rich_editing', false)) {
         sfLoader::loadHelpers(array('Javascript'));
         sfContext::getInstance()->getResponse()->addJavascript('/sfSimpleCMSPlugin/js/tiny_mce_AJAX.js', 'last');
         $script = javascript_tag('setTextareaToTinyMCE("edit_textarea' . $slot->getName() . '");');
         $options['rich'] = 'TinyMCE';
     }
     return $script . textarea_tag('slot_content', $slot->getValue(), $options);
 }
    function renderMenu()
    {
        echo stylesheet_tag('sfTreeMenu/DynamicTree.css');
        echo javascript_include_tag('sfTreeMenu/ie5.js');
        echo javascript_include_tag('sfTreeMenu/DynamicTree.js');
        echo $this->renderMenuData();
        $append_js = <<<EOD
\t\t
    var tree = new DynamicTree("tree");
    tree.init();
\t\t
EOD;
        echo javascript_tag($append_js);
    }
示例#19
0
function markdown_preview_link($field)
{
    use_helper('JavascriptBase');
    use_stylesheet('/csDoctrineMarkdownPlugin/css/markdown.css');
    $submit = content_tag('a', 'Preview', array('href' => '#', 'onclick' => 'javascript:markdown_preview(this);return false'));
    $js = javascript_tag(sprintf(<<<EOF
  function markdown_preview (e) {
    var markdown_text = \$('form *[name=%s]').val();
    \$('#markdown_preview').load('%s', { 'markdown_value': markdown_text }, function() { \$(this).append("<a href='#' onclick='\$(\\"#markdown_preview\\").hide()'>hide</a>") } ).css('display', 'block');
  }
EOF
, $field, url_for('csMarkdown/preview?markdown_field=' . $field)));
    return $submit . $js;
}
function make_app_setting_modal_box($id)
{
    sfContext::getInstance()->getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/prototype');
    sfContext::getInstance()->getResponse()->addJavascript('util');
    $modalbox = '<div id="' . $id . '" class="modalWall" style="display:none" onclick="iframeModalBox.close(); false;"></div>' . '<div id="' . $id . '_contents" class="modalBox" style="display: none;">' . '<iframe width="400" height="400" frameborder="0"></iframe>' . '</div>';
    $javascript = <<<EOT
var iframeModalBox = new IframeModalBox("%id%");
(function (){
  var contents = \$("%id%_contents");
  contents.setStyle(getCenterMuchScreen(contents));
})();
EOT;
    $javascript = preg_replace('/%id%/', $id, $javascript);
    return $modalbox . javascript_tag($javascript);
}
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $id = $this->generateId($name);
     $options = array();
     foreach ((array) $this->getOption('editarea_options') as $key => $val) {
         if (is_bool($val)) {
             $options[] = "{$key}: " . ($val ? 'true' : 'false');
         } else {
             $options[] = "{$key}: '{$val}'";
         }
     }
     $options = '{' . implode(', ', $options) . '}';
     $contentTag = parent::render($name, $value, $attributes, $errors);
     $contentTag .= javascript_tag("\n      if(\$.fn.editArea)\n        \$('#{$id}').editArea({$options});\n      else\n        throw 'EditArea JS not included!';\n    ");
     return $contentTag;
 }
示例#22
0
function ie6_update()
{
    use_helper('Javascript');
    echo "<!--[if lte IE 6]>";
    javascript_tag();
    echo <<<EOF
    /*Load jQuery if not already loaded*/ if(typeof jQuery == 'undefined'){ document.write("<script type=\\"text/javascript\\"   src=\\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\\"></"+"script>"); var __noconflict = true; } 
      var IE6UPDATE_OPTIONS = {
        icons_path: "http://static.ie6update.com/hosted/ie6update/images/"
      }
    </script>
    <script type="text/javascript" src="http://static.ie6update.com/hosted/ie6update/ie6update.js">
EOF;
    end_javascript_tag();
    echo "<![endif]-->";
}
示例#23
0
/**
 *
 * @param string $name
 * @param string $url
 * @param array $opts
 * @return string 
 */
function lb_link_to($name, $url, $lnk_opts = array(), $lb_opts = array())
{
    $opts = array_merge($opts, array('class' => 'lightbox'));
    if (!isset($lb_opts['width'])) {
        $lb_opts['width'] = sfConfig::get('app_ddlightbox_width');
    }
    if (!isset($lb_opts['height'])) {
        $lb_opts['height'] = sfConfig::get('app_ddlightbox_height');
    }
    $url .= '?lightbox[width]=' . $lb_opts['width'] . '&lightbox[height]=' . $lb_opts['height'] . (isset($lb_opts['modal']) ? '&lightbox[modal]=' . $lb_opts['modal'] : '');
    $response = sfContext::getInstance()->getResponse();
    $response->addJavascript(sfConfig::get("app_ddlightbox_js_dir") . 'jquery.lightbox.min.js');
    $response->addStylesheet(sfConfig::get("app_ddlightbox_css_dir") . 'jquery.lightbox.css');
    echo javascript_tag("\$('.lightbox').lightbox();");
    return link_to($name, $url, $opts);
}
function light_image_activate()
{
    if (!sfContext::hasInstance()) {
        return;
    }
    //add resources
    $response = sfContext::getInstance()->getResponse();
    //check if jqueryreloaded plugin is activated
    if (sfConfig::has('sf_jquery_web_dir') && sfConfig::has('sf_jquery_core')) {
        $response->addJavascript(sfConfig::get('sf_jquery_web_dir') . '/js/' . sfConfig::get('sf_jquery_core'));
    } else {
        throw new Exception("Theres is no JqueryReloaded plugin !");
    }
    //JQuery Lightbox specific
    $response->addJavascript(sfConfig::get("app_sf_jquery_lightbox_js_dir") . 'jquery.lightbox-0.5.js');
    $response->addStylesheet(sfConfig::get("app_sf_jquery_lightbox_css_dir") . 'jquery.lightbox-0.5.css');
    $code = "\$(function() {\r\n    \$('a.lightbox').lightBox({\r\n      imageLoading: '" . sfConfig::get('app_sf_jquery_lightbox_imageLoading') . "',\r\n      imageBtnClose: '" . sfConfig::get('app_sf_jquery_lightbox_imageBtnClose') . "',\r\n      imageBtnPrev: '" . sfConfig::get('app_sf_jquery_lightbox_imageBtnPrev') . "',\r\n      imageBtnNext: '" . sfConfig::get('app_sf_jquery_lightbox_imageBtnNext') . "',\r\n      imageBlank: '" . sfConfig::get('app_sf_jquery_lightbox_imageBlank') . "',\r\n      txtImage: '" . sfConfig::get('app_sf_jquery_lightbox_txtImage') . "',\r\n      txtOf: '" . sfConfig::get('app_sf_jquery_lightbox_txtOf') . "' });\r\n  });";
    echo javascript_tag($code);
}
    function renderFootJs()
    {
        $image_arrow1 = image_path('sfDropDownMenu/arrow1.gif');
        $image_arrow2 = image_path('sfDropDownMenu/arrow2.gif');
        if ($this->display_mode == "horizontal") {
            $display_mode_html = "";
        } else {
            $display_mode_html = "\n menu1.type = \"vertical\";\n menu1.position.level1.left = 2;\n";
        }
        $parse_menu_js = <<<EOD
\t\t
    var menu1 = new XulMenu("menu1");
    {$display_mode_html}
    menu1.arrow1 = "{$image_arrow1}";
    menu1.arrow2 = "{$image_arrow2}";
    menu1.init();
\t\t
EOD;
        echo javascript_tag($parse_menu_js);
    }
示例#26
0
function WeekCalendar($name, $json_events)
{
    _WeekCalendar_common();
    $first_day = SchoolBehaviourFactory::getInstance()->getFirstCourseSubjectWeekday();
    $days_to_show = SchoolBehaviourFactory::getInstance()->getLastCourseSubjectWeekday() - SchoolBehaviourFactory::getInstance()->getFirstCourseSubjectWeekday() + 1;
    $day_names_to_sort = CourseSubjectDay::geti18Names();
    $order = array(7, 1, 2, 3, 4, 5, 6, 7);
    foreach ($order as $index) {
        $day_names[] = $day_names_to_sort[$index];
    }
    $day_names = json_encode($day_names);
    $hours = SchoolBehaviourFactory::getInstance()->getHoursArrayForSubjectWeekday();
    ksort($hours, SORT_NUMERIC);
    $start_hour = array_shift($hours);
    $end_hour = count($hours) > 0 ? array_pop($hours) : $start_hour;
    if (++$end_hour > 24) {
        $end_hour--;
    }
    return '<div id="' . $name . '"></div>' . javascript_tag("\n   jQuery(document).ready(function() {\n    jQuery('#{$name}').weekCalendar({\n        readonly: true,\n        overlapEventsSeparate: true,\n        timeSeparator: ' - ',\n        timeslotsPerHour: 4,\n        buttons: false,\n        firstDayOfWeek: {$first_day},\n        daysToShow: {$days_to_show},\n        height: function(\$calendar){\n          return jQuery(window).height() - jQuery(\"h1\").outerHeight();\n        },\n        longDays: {$day_names} ,\n        headerShowDay: false,\n        highlightToday: false,\n        use24Hour: true,\n        businessHours: {start: {$start_hour}, end: {$end_hour}, limitDisplay: true},\n        data: { events: {$json_events} },\n\n    });\n   });\n ");
}
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/autocompleter.css');
     if ($this->getOption('obj') && $value) {
         try {
             $this->getOption('obj')->setId($value);
             $this->getOption('obj')->setNew(false);
             $this->getOption('obj')->reload();
             $this->setOption('print', $this->getOption('obj')->__toString());
         } catch (Doctrine_Record_Exception $ex) {
             // Doctrine Fix
             $q = Doctrine::getTable($this->getOption('obj')->getTable()->getOption('name'))->createQuery('u');
             $this->setOption('print', $q->execute()->getFirst());
         }
     }
     $widgetInput = $this->renderTag('input', array_merge(array('type' => 'text', 'name' => $this->generateId($name . '_search'), 'id' => $this->generateId($name . '_search'), 'value' => $this->getOption('print')), $attributes));
     $widgetInputHidden = new sfWidgetFormInputHidden(array(), $this->getAttributes());
     $autocompleteDiv = content_tag('div', '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
     $autocompleteJs = javascript_tag("\n            function ac_update_" . $this->generateId($name) . "(text, li)\n            {\n                \$('" . $this->generateId($name) . "').value = li.id;\n                \n                if(li.id == '')\n                {\n                    \$('" . $this->generateId($name) . "_search').value = '';\n                }\n            }\n            \n            new Ajax.Autocompleter(\n                '" . $this->generateId($name . '_search') . "',\n                '" . $this->generateId($name) . '_autocomplete' . "',\n                '" . url_for($this->getOption('url')) . "',\n                {\n                    paramName: '" . $this->getOption('param') . "',\n                    indicator: 'indicator-" . $this->generateId($name) . "',\n                    minChars: " . $this->getOption('min_chars') . ",\n                    afterUpdateElement: ac_update_" . $this->generateId($name) . "\n                });");
     return $widgetInputHidden->render($name, $value, $attributes, $errors) . $widgetInput . '<span id="indicator-' . $this->generateId($name) . '" style="display: none;">&nbsp;&nbsp;<img src="/sfExtraWidgetsPlugin/img/ajax-loader.gif" align="absmiddle" alt="Loading" /></span>' . $autocompleteDiv . $autocompleteJs;
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $js = '';
     if (self::$isFirstRender) {
         sfContext::getInstance()->getResponse()->addSmtJavascript('jquery.min.js');
         sfContext::getInstance()->getResponse()->addSmtJavascript('jquery-ui.min.js');
         sfContext::getInstance()->getResponse()->addSmtJavascript('tiny_mce/tiny_mce');
         sfContext::getInstance()->getResponse()->addSmtJavascript('op_emoji');
         sfContext::getInstance()->getResponse()->addSmtJavascript('Selection');
         sfContext::getInstance()->getResponse()->addSmtJavascript('decoration');
         $relativeUrlRoot = sfContext::getInstance()->getRequest()->getRelativeUrlRoot();
         $js .= sprintf("function op_mce_editor_get_config() { return %s; }\n", json_encode(self::getButtons()));
         $js .= sprintf('function op_get_relative_uri_root() { return "%s"; }', $relativeUrlRoot);
         self::$isFirstRender = false;
     }
     if ($js) {
         sfProjectConfiguration::getActive()->loadHelpers('Javascript');
         $js = javascript_tag($js);
     }
     $id = $this->getId($name, $attributes);
     $this->setOption('textarea_template', '<div id="' . $id . '_buttonmenu" class="' . $id . '">' . get_partial('global/richTextareaOpenPNEButton', array('id' => $id, 'configs' => self::getButtons(), 'onclick_actions' => self::$buttonOnclickActions)) . '</div>' . $this->getOption('textarea_template'));
     return $js . parent::render($name, $value, $attributes, $errors);
 }
 protected function handleErrorForAjax()
 {
     $errors = $this->getRequest()->getErrors();
     $field_error = sfConfig::get('app_form_field_error');
     $js_errors = "'#" . implode(", #", array_keys($errors)) . "'";
     $arrow = sfConfig::get('sf_validation_error_prefix', '');
     $this->getResponse()->setStatusCode(404);
     sfLoader::loadHelpers(array('Javascript', 'Tag'));
     // add error class on fields via js
     $js = "\$('.{$field_error}').removeClass('{$field_error}');";
     $js .= "\$('.form_error').hide();";
     // remove all errors
     $js .= "\$({$js_errors}).addClass('{$field_error}');";
     // display new ones (if any);
     // global form error
     $toReturn = $this->__('Oups!') . '<ul>';
     foreach ($errors as $name => $error) {
         $js .= "\$('#error_for_{$name}').html(" . json_encode($arrow . $this->__($error) . $arrow) . ").show();";
         $toReturn .= '<li>' . $this->__($error) . '</li>';
     }
     $toReturn .= '</ul>';
     return $this->renderText(javascript_tag($js) . $toReturn);
 }
示例#30
0
function init_assets_library_popup()
{
    use_javascript('/sfAssetsLibraryPlugin/js/main', 'last');
    return javascript_tag('sfAssetsLibrary.init(\'' . url_for('sfAsset/list') . '?popup=2' . '\')');
}