public function getJavascript($name) { sfContext::getInstance()->getConfiguration()->loadHelpers('Tag', 'Url'); $addEmpty = $this->getOption('on_empty') ? sprintf("if(selectedVal == '') { \$('%s').html('%s').show();return;}", $this->getOption('update'), $this->getOption('on_empty')) : ''; $javascripts = <<<EOF <script type="text/javascript"> // Default jQuery wrapper \$(document).ready(function() { // When the choice widget is changed \$("#%s").change(function() { // Hide the target element var selectedVal = \$(this).attr("value"); %s \$("%s").addClass('indicator').html(' '); // url of the JSON var url = "%s" + selectedVal; // Get the JSON for the selected item \$("%s").load(url, function() { \$(this).removeClass('indicator'); %s }); })%s }); </script> EOF; return sprintf($javascripts, $this->generateId($name), $addEmpty, $this->getOption('update'), url_for($this->getOption('url')), $this->getOption('update'), $this->getOption('on_update'), $this->getOption('update_on_load') ? '.change();' : ''); }
/** * Creates a <a> link tag of the given name using a routed URL * based on the module/action passed as argument and the routing configuration. * * If null is passed as a name, the link itself will become the name. * * Examples: * echo link_to('Homepage', 'default/index') * => <a href="/">Homepage</a> * * echo link_to('News 2008/11', 'news/index?year=2008&month=11') * => <a href="/news/2008/11">News 2008/11</a> * * echo link_to('News 2008/11 [absolute url]', 'news/index?year=2008&month=11', array('absolute'=>true)) * => <a href="http://myapp.example.com/news/2008/11">News 2008/11 [absolute url]</a> * * echo link_to('Absolute url', 'http://www.google.com') * => <a href="http://www.google.com">Absolute url</a> * * echo link_to('Link with attributes', 'default/index', array('id'=>'my_link', 'class'=>'green-arrow')) * => <a id="my_link" class="green-arrow" href="/">Link with attributes</a> * * echo link_to('<img src="x.gif" width="150" height="100" alt="[link with image]" />', 'default/index' ) * => <a href="/"><img src="x.gif" width="150" height="100" alt="[link with image]" /></a> * * * Options: * 'absolute' - if set to true, the helper outputs an absolute URL * 'query_string' - to append a query string (starting by ?) to the routed url * 'anchor' - to append an anchor (starting by #) to the routed url * * @param string text appearing between the <a> tags * @param string 'module/action' or '@rule' of the action, or an absolute url * @param array additional HTML compliant <a> tag parameters * @return string XHTML compliant <a href> tag * @see url_for */ function link_to($name = '', $internal_uri = '', $options = array()) { $html_options = _parse_attributes($options); $absolute = false; if (isset($html_options['absolute'])) { $absolute = (bool) $html_options['absolute']; unset($html_options['absolute']); } // Fabrice: FIXME (genUrl() doesnt like '#anchor' ?) => ignore empty string $html_options['href'] = $internal_uri !== '' ? url_for($internal_uri, $absolute) : ''; // anchor if (isset($html_options['anchor'])) { $html_options['href'] .= '#' . $html_options['anchor']; unset($html_options['anchor']); } if (isset($html_options['query_string'])) { $html_options['href'] .= '?' . $html_options['query_string']; unset($html_options['query_string']); } if (is_object($name)) { if (method_exists($name, '__toString')) { $name = $name->__toString(); } else { DBG::error(sprintf('Object of class "%s" cannot be converted to string (Please create a __toString() method).', get_class($name))); } } if (!strlen($name)) { $name = $html_options['href']; } return content_tag('a', $name, $html_options); }
/** * Generates the url to this menu item based on the route * * @param array $options Options to pass to the url_for method */ public function getUri(array $options = array()) { if (!$this->getRoute() || $this->getRoute() == '#') { return null; } // setup the options array and single out the absolute boolean $options = array_merge($this->getUrlOptions(), $options); if (isset($options['absolute'])) { $absolute = $options['absolute']; unset($options['absolute']); } else { $absolute = false; } try { // Handling of the url options varies depending on the url format if ($this->_isOldRouteMethod()) { // old-school url_for('@route_name', $absolute); return url_for($this->getRoute(), $absolute); } else { // new-school url_for('route_name', $options, $absolute) return url_for($this->getRoute(), $options, $absolute); } } catch (sfConfigurationException $e) { throw new sfConfigurationException(sprintf('Problem with menu item "%s": %s', $this->getLabel(), $e->getMessage())); return $this->getRoute(); } }
public function __construct($loadHelper = true) { $this->helperFlag = $loadHelper; if($loadHelper == true) { $this->loadHelper(); $this->setServerUrl(url_for('layout/index',true)); } }
function print_celula_tabela_consolidado($mes, $ano, $statusConta, $listaContas) { ?> <?php $loteContas = Conta::getLoteFromListaContas($statusConta, $ano, $mes, $listaContas); ?> <div class="overlay"> <div><?php print_valor(Conta::getTotalFromLote($loteContas)); ?> </div> <a rel="#overlay" href="<?php echo url_for('financeiro/addConta?ano=' . $ano->getAno() . '&mes=' . $mes . '&statusConta=' . $statusConta->getSlug()); ?> "><?php echo image_tag("add-conta.png"); ?> </a> <?php if (count($loteContas) > 0) { ?> <a rel="#overlay" href="<?php echo url_for('financeiro/listaContas?ano=' . $ano->getAno() . '&mes=' . $mes . '&statusConta=' . $statusConta->getSlug()); ?> "><?php echo image_tag("list-conta.png", array('width' => 32, 'heigth' => 32)); ?> </a> <?php } ?> </div> <?php }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $context = sfContext::getInstance(); $response = $context->getResponse(); $autocompleteDiv = ""; // content_tag('div' , '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete')); $desc = ''; if (true === $this->getOption('desc')) { $desc = '.data( "ui-autocomplete" )._renderItem = function( ul, item ) { return $( "<li>" ) .append( "<a>" + item.label + "<br>" + item.desc + "</a>" ) .appendTo( ul ); }'; } $autocompleteJs = $this->javascriptTag("\n \n \$(function(){\n \n \$('#" . $this->generateId($name) . "_ajaxtext').autocomplete({\n source: '" . url_for($this->getOption('url')) . "',\n delay:30,\n minChars:0,\n appendTo: '" . $this->getOption('appendTo') . "',\n max:30,\n width: 300,\n matchSubset:1,\n matchContains:1,\n cacheLength:10,\n autoFill:false,\n autoFocus: true,\n select: function( event, ui ) {\n \$('#" . $this->generateId($name) . "').val(ui.item.id);\n \$('#" . get_id_from_name($name) . "_ajaxcheckbox').prop('checked', true)\n \$('#" . get_id_from_name($name) . "_ajaxcheckboxText').html('" . __('kiválasztva') . "');\n \$('#" . $this->generateId($name) . "').trigger('change', [ui.item])\n } \n }){$desc}\n \n \n \n \$.fn.autocomplete.keypressEvent = function (evt, id){\n car = evt.keyCode || evt.charCode;\n if (car != 27 && car!=9) //ESC + TAB\n {\n \$('#'+id).val('');\n \$('#'+id+'_ajaxcheckbox').attr('checked',false);\n \$('#'+id+'_ajaxcheckboxText').html('" . __('nincs kiválasztva') . "'); \n \$('#" . $this->generateId($name) . "').trigger('change')\n } \n } \n \n });"); $ihidden = new sfWidgetFormInputHidden(); $ihiddenText = $ihidden->render($name, $value, $attributes); if ($value != '') { $checked = 'checked="checked"'; $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('kiválasztva') . "</span>"; } else { $checked = ''; $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('nincs kiválasztva') . "</span>"; } $checkbox = '<input type="checkbox" id="' . get_id_from_name($name) . '_ajaxcheckbox' . '" ' . $checked . ' disabled="disabled" />'; $attributesText = array_merge($attributes, array('name' => false, 'id' => get_id_from_name($name) . '_ajaxtext')); $attributesText['onkeydown'] = "\$('#" . $this->generateId($name) . "_ajaxtext').autocomplete.keypressEvent(event, '" . $this->generateId($name) . "')"; $itextText = parent::render($name, $this->getValueFromId($value), $attributesText, $errors); $indicator = '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>'; return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs; }
function util_link_for($title = null, $ctrl = null, $action = null, $id = null, $onclick = null, $extra_params = null) { if ($title === null) { return false; } if ($ctrl === null) { $ctrl = 'main'; } if ($action === null) { $action = 'index'; } if ($id === null) { $id = 0; } $onclick = $onclick !== null ? "onclick=\"{$onclick}\"" : ''; $url = url_for($ctrl, $action, $id); if (!$url) { return false; } if ($extra_params !== null && is_array($extra_params) && count($extra_params)) { foreach ($extra_params as $param => $value) { $url .= "&{$param}={$value}"; } } return "<a href=\"{$url}\" {$onclick}>{$title}</a>"; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $textarea = parent::render($name, $value, $attributes, $errors); $js = sprintf(<<<EOF <script type="text/javascript"> /* <![CDATA[ */ lyMediaManager.init('%s'); tinyMCE.init({ convert_urls : false, mode: "exact", elements: "%s", theme: "%s", %s %s theme_advanced_toolbar_location: "top", theme_advanced_toolbar_align: "left", theme_advanced_statusbar_location: "bottom", theme_advanced_resizing: true, file_browser_callback : "lyMediaManager.fileBrowserCallBack" %s }); /* ]]> */ </script> EOF , url_for('@ly_media_asset_icons?popup=1', true), $this->generateId($name), $this->getOption('theme'), $this->getOption('width') ? sprintf('width: "%spx",', $this->getOption('width')) : '', $this->getOption('height') ? sprintf('height: "%spx",', $this->getOption('height')) : '', $this->getOption('config') ? ",\n" . $this->getOption('config') : ''); return $textarea . $js; }
function image_cache_tag($route, $format, $path, $image, $alt = null) { $_formats = sfConfig::get('imagecache_formats'); $_format = $_formats[$format]; if (!isset($_format)) { throw new RuntimeException('Format not found'); } $real_file_path = sfConfig::get('sf_upload_dir') . '/' . $path . '/' . $image; if (file_exists($real_file_path)) { $cache_file_path = sfConfig::get('sf_upload_dir') . '/cache/' . $format . '/' . $path . '/' . $image; $is_cached_file = file_exists($cache_file_path); $options = array('path' => $format . '/' . $path . '/' . $image); $url = urldecode(url_for($route, $options)); if ($is_cached_file) { $cached_image = new sfImage($cache_file_path); $width = $cached_image->getWidth(); $height = $cached_image->getHeight(); return image_tag($url, array('size' => $width . 'x' . $height, 'alt' => $alt)); } else { return image_tag($url, array('alt' => $alt)); } } else { return ''; } }
function tablePagination($pager, $url, $name = "page", $add = "") { if (strpos($url, '?')) { $char = '&'; } else { $char = '?'; } echo "<ul>"; if ($pager->haveToPaginate()) { echo "<li>"; echo "<a href=\"" . url_for($url . $char . "{$name}=" . $pager->getPreviousPage()) . "{$add}\">"; echo "\t< Précédent"; echo "</a>"; echo "</li>"; foreach ($pager->getLinks(10) as $page) { if ($page == $pager->getPage()) { echo "<li class=\"active\">"; echo "<a href=\"#\">" . $page . "</a>"; } else { echo "<li>"; echo "<a href=\"" . url_for($url . $char . "{$name}=" . $page) . "{$add}\">"; echo $page; echo "</a>"; } echo "</li>"; } echo "<li>"; echo "<a href=\"" . url_for($url . $char . "{$name}=" . $pager->getNextPage()) . "{$add}\">"; echo "\tSuivant >"; echo "</a>"; echo "</li>"; } echo "</ul>"; }
function remote_function($options) { $jsOptions = options_for_ajax($options); if (isset($options['update']) && is_array($options['update'])) { $updates = array(); if (isset($options['update']['success'])) { $updates[] = "success:'" . $options['update']['success'] . "'"; } if (isset($options['update']['failure'])) { $updates[] = "failure:'" . $options['update']['failure'] . "'"; } $update = '{' . implode(',', $updates) . '}'; } elseif (isset($options['update'])) { $update = "'" . $options['update'] . "'"; } $js = !isset($update) ? "new Ajax.Request(" : "new Ajax.Updater({$update}, "; $js .= "'" . url_for($options['url']) . "', {$jsOptions})"; if (isset($options['before'])) { $js = $options['before'] . "; {$js}"; } if (isset($options['after'])) { $js = "{$js}; " . $options['after']; } if (isset($options['condition'])) { $js = "if (" . $options['condition'] . ") { {$js}; }"; } if (isset($options['confirm'])) { $js = "if (confirm(" . addslashes($options['confirm']) . ")) { {$js}; }"; } return $js; }
/** * @param string $name The element name * @param string $value The date displayed in this widget * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetForm */ public function render($name, $value = null, $attributes = array(), $errors = array()) { $url = url_for('@pm_widget_form_propel_input_by_code', true); $options_without_template = $this->getOptions(); unset($options_without_template['template']); return parent::render($name, $value, $attributes, $errors) . sprintf($this->getOption('template'), $this->generateId($name . '_result'), $this->generateId($name), $url, serialize($options_without_template)); }
/** * Returns <link> tags with the url toward all stylesheets configured in view.yml or added to the response object. * * You can use this helper to decide the location of stylesheets in pages. * By default, if you don't call this helper, symfony will automatically include stylesheets before </head>. * Calling this helper disables this behavior. * * @return string <link> tags */ function get_combined_stylesheets() { if (!sfConfig::get('app_sfCombinePlugin_enabled', false)) { return get_stylesheets(); } $response = sfContext::getInstance()->getResponse(); sfConfig::set('symfony.asset.stylesheets_included', true); $configSfCombinePlugin['css'] = sfConfig::get('app_sfCombinePlugin_css', array()); $html = ''; $cssFiles = $include_tags = array(); foreach (array('first', '', 'last') as $position) { foreach ($response->getStylesheets($position) as $files => $options) { if (!in_array($files, $configSfCombinePlugin['css']['online']) && !in_array($files, $configSfCombinePlugin['css']['offline'])) { if (!is_array($files)) { $files = array($files); } $cssFiles = array_merge($cssFiles, $files); } else { $include_tags[] = stylesheet_tag(url_for($files)); } } } $key = _get_key($cssFiles); $include_tags[] = str_replace('.css', '', stylesheet_tag(url_for('sfCombine/css?key=' . $key))); return implode("", $include_tags); }
/** * This handles uploads to a persions channel * Need file posted as 'file' and the has poster as 'hash' */ public function upload() { switch ($this->format) { case 'xml': try { $package = Package::from_upload(array('file' => $_FILES['file']['tmp_name'], 'sig' => $_POST['signatureBase64'], 'user' => $this->user), true); if ($package->saved) { echo 'Package uploaded succesfuly!'; } } catch (Exception $e) { $this->header("HTTP/1.0 500 Internal Server Error", 500); echo $e->getMessage(); } $this->has_rendered = true; break; default: if ($_SESSION['upload_key'] !== $_POST['upload_key']) { Nimble::flash('notice', 'Invalid Upload Key'); $this->redirect_to(url_for('LandingController', 'user_index', $this->user->username)); } unset($_SESSION['upload_key']); try { $package = Package::from_upload(array('file' => $_FILES['file']['tmp_name'], 'user' => $this->user)); if ($package->saved) { $this->redirect_to(url_for('LandingController', 'user_index', $this->user->username)); } } catch (Exception $e) { Nimble::flash('notice', $e->getMessage()); $this->redirect_to(url_for('ChannelController', 'upload')); } break; } }
function before() { layout('layouts/default.html.php'); /*set('header', ' <a href="'.url_for().'">Home</a> <a href="'.url_for('people').'">Personen</a> <a href="'.url_for('roles').'">Rollen</a> <a href="'.url_for('access').'">Zugriff</a> <a href="'.url_for('servers').'">Server</a> <a href="'.url_for('daemons').'">Daemons</a> ');*/ set('header', ' <img id="header_img" src="img/aclmodel.png" width="850" height="83" usemap="#head_nav" alt="header_navigation"> <map name="head_nav"> <area id="daemons_nav" shape="rect" href="' . url_for('daemons') . '" coords="682,7,781,28" alt="daemons"> <area id="servers_nav" shape="rect" href="' . url_for('servers') . '" coords="516,7,635,28" alt="servers"> <area id="access_nav" shape="rect" href="' . url_for('access') . '" coords="391,7,478,28" alt="access"> <area id="roles_nav" shape="rect" href="' . url_for('roles') . '" coords="239,7,340,28" alt="roles"> <area id="people_nav" shape="rect" href="' . url_for('people') . '" coords="74,7,193,28" alt="people"> <area id="clients_nav" shape="rect" href="' . url_for('clients') . '" coords="2,55,98,76" alt="clients"> <area id="people_roles_nav" shape="rect" href="' . url_for('people_roles') . '" coords="176,54,267,75" alt="people_roles"> <area id="ports_nav" shape="rect" href="' . url_for('ports') . '" coords="748,55,849,76" alt="ports"> </map> '); set('footer', '© 2011 - Florian Staudacher (Frontend), Alexander Philipp Lintenhofer (Backend)'); }
public function getJavaScripts() { return array('/js/FLoginForm.js'); $url_params = sfJqueryFormValidationRules::getUrlParams(); $url_params['form'] = get_class($this); return array_merge(parent::getJavaScripts(), array(url_for($url_params))); }
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 html_default_layout($vars) { extract($vars); ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Before render filter test</title> </head> <body> <article> <?php echo $content; ?> </article> <hr> <nav> <p><strong>Menu:</strong> <a href="<?php echo url_for('/'); ?> ">Index</a> | <a href="<?php echo url_for('/error'); ?> ">Error</a> </p> </nav> <hr> </body> </html> <?php }
/** * Ссылка на удаление комментария * * @param Comment $comment */ function link_to_comment_delete($comment, $title = null) { $user = sfContext::getInstance()->getUser(); if ($user->isAuthenticated() && $user->getGuardUser()->getId() == $comment->getUserId() && $comment->hasDeletable()) { return jq_link_to_remote($title ? $title : 'Удалить', array('method' => 'post', 'url' => url_for('comment_delete', $comment), 'success' => 'jQuery("#comment-' . $comment->id . '").remove();', 'confirm' => 'Вы точно хотите удалить свой комментарий?')); } }
/** * AlbaToolsHelper. * * @package symfony * @subpackage helper * @author Fernando Toledo <*****@*****.**> * @version SVN: $Id: NumberHelper.php 7757 2008-03-07 10:55:22Z fabien $ */ function text2img($texto) { if (is_null($texto)) { return null; } return tag('img', array('alt' => $texto, 'src' => url_for('albaTools/text2img?texto=' . $texto))); }
public function execute($request) { $request->setRequestFormat('xml'); $this->date = gmdate('Y-m-d\\TH:i:s\\Z'); $this->title = sfconfig::get('app_siteTitle'); $this->description = sfconfig::get('app_siteDescription'); $this->protocolVersion = '2.0'; list($this->earliestDatestamp) = Propel::getConnection()->query('SELECT MIN(' . QubitObject::UPDATED_AT . ') FROM ' . QubitObject::TABLE_NAME)->fetch(); $this->granularity = 'YYYY-MM-DDThh:mm:ssZ'; $this->deletedRecord = 'no'; $this->compression = 'gzip'; $this->path = url_for('oai/oaiAction'); $this->attributes = $this->request->getGetParameters(); $this->attributesKeys = array_keys($this->attributes); $this->requestAttributes = ''; foreach ($this->attributesKeys as $key) { $this->requestAttributes .= ' ' . $key . '="' . $this->attributes[$key] . '"'; } $criteria = new Criteria(); $criteria->add(QubitAclUserGroup::GROUP_ID, QubitAclGroup::ADMINISTRATOR_ID); $criteria->addJoin(QubitAclUserGroup::USER_ID, QubitUser::ID); $users = QubitUser::get($criteria); $this->adminEmail = array(); foreach ($users as $user) { $this->adminEmail[] = $user->getEmail() . "\n"; } }
function get_pager_controls($pager) { $route = url_for(sfContext::getInstance()->getRouting()->getCurrentInternalUri(true)); if ($pager->getNbResults()) { $template = "<div class='pagination'>\n <span>Results <em>%first%-%last%<em> of <em>%total%<em></span>\n %pagination%\n </div>"; $pagination = ""; if ($pager->haveToPaginate()) { $pagination = "<ul>"; // Previous if ($pager->getPage() != $pager->getFirstPage()) { $pagination .= "<li><a href='" . $route . "?page=1'><<</a></li>"; $pagination .= "<li><a href='" . $route . "?page=" . $pager->getPreviousPage() . "'>Previous</a></li>"; } // In between foreach ($pager->getLinks() as $page) { if ($page == $pager->getPage()) { $pagination .= "<li>{$page}</li>"; } else { $pagination .= "<li><a href='{$route}?page={$page}'>{$page}</a></li>"; } } // Next if ($pager->getPage() != $pager->getLastPage()) { $pagination .= "<li><a href='{$route}?page=" . $pager->getNextPage() . "'>Next</a></li>"; $pagination .= "<li><a href='{$route}?page=" . $pager->getLastPage() . "'>>></a></li>"; } $pagination .= "</ul>"; } return strtr($template, array('%first%' => $pager->getFirstIndice(), '%last%' => $pager->getLastIndice(), '%total%' => $pager->getNbResults(), '%pagination%' => $pagination)); } }
/** * Constructor */ public function __construct(Invoice $invoice) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'Date')); $resultUrl = 'https://' . sfContext::getInstance()->getRequest()->getHost() . url_for('payment_liqpay_result'); $defaults = array('version' => '1.1', 'merchant_id' => sfConfig::get('app_liqpay_merchant'), 'amount' => $invoice->getAmount(), 'currency' => 'UAH', 'order_id' => $invoice->getId(), 'description' => $invoice->getDescription(), 'result_url' => $resultUrl, 'server_url' => $resultUrl); parent::__construct($defaults); }
function cryptographp_reload() { $reload_img = sfConfig::get('app_cryptographp_reloadimg', '/sfCryptographpPlugin/images/reload'); //$ret = "<a style=\"cursor:pointer\" onclick=\"javascript:document.getElementById('cryptogram').src='".url_for('cryptographp/index?id=')."/'+Math.round(Math.random(0)*1000)+1\">".image_tag('/sfCryptographpPlugin/images/reload')."</a>"; $ret = "<a style=\"cursor:pointer\" onclick=\"javascript:document.getElementById('cryptogram').src='" . url_for('cryptographp/index?id=') . "/'+Math.round(Math.random(0)*1000)+1\">" . image_tag($reload_img) . "</a>"; return $ret; }
/** * @param string $name The element name * @param string $value The value displayed in this widget * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetForm */ public function render($name, $value = null, $attributes = array(), $errors = array()) { $sfContext = sfContext::getInstance(); $resp = $sfContext->getResponse(); $resp->addJavascript('/majaxDoctrineMediaPlugin/js/grid.locale-en.js'); $resp->addJavascript('/majaxDoctrineMediaPlugin/js/jquery.jqGrid.min.js'); $resp->addStylesheet('/majaxDoctrineMediaPlugin/css/ui.jqgrid.css'); $resp->addJavascript('/majaxDoctrineMediaPlugin/js/jquery.majax.media.js'); $sfContext->getConfiguration()->loadHelpers(array('Url')); $id = $this->generateId($name); $fetch_url = url_for('majaxMediaAdminModule/list?sf_format=xml'); $lookup_url = url_for('majaxMediaAdminModule/lookup'); $out = $this->renderTag('input', array_merge(array('type' => 'text', 'name' => $name, 'value' => $value), $attributes)); $out .= '<script type="text/javascript"> (function($){ $(function(){ var opts = { lookup_url: \'' . $lookup_url . '\', fetch_url: \'' . $fetch_url . '\', }; $(\'#' . $id . '\').majaxmediaselector(opts); }); })(jQuery); </script> '; return $out; }
/** * Renders an edit form for a slot * * @param sfSympalContent $content The content on which the slot should be rendered * @param sfSympalContentSlot $slot The slot to render in a form * @param array $options An options array. Available options include: * * edit_mode * */ function get_sympal_content_slot_editor($content, $slot, $options = array()) { $slot->setContentRenderedFor($content); // merge in some global default slot options $options = array_merge(array('edit_mode' => sfSympalConfig::get('inline_editing', 'default_edit_mode'), 'view_url' => url_for('sympal_content_slot_view', array('id' => $slot->id, 'content_id' => $slot->getContentRenderedFor()->id))), $options); // merge the default config for this slot into the given config $slotOptions = sfSympalConfig::get($slot->getContentRenderedFor()->Type->slug, 'content_slots', array()); if (isset($slotOptions[$slot->name])) { $options = array_merge($slotOptions[$slot->name], $options); } /* * Finally, override the "type" option, it should be set to whatever's * in the database, regardless of what the original slot options were */ $options['type'] = $slot->type; /* * Give the slot a default value if it's blank. * * @todo Move this somewhere where it can be specified on a type-by-type * basis (e.g., if we had an "image" content slot, it might say * "Click to choose image" */ $renderedValue = $slot->render(); if (!$renderedValue) { $renderedValue = __('[Hover over and click edit to change.]'); } $inlineContent = sprintf('<a href="%s" class="sympal_slot_button">' . __('Edit') . '</a>', url_for('sympal_content_slot_form', array('id' => $slot->id, 'content_id' => $slot->getContentRenderedFor()->id))); $inlineContent .= sprintf('<span class="sympal_slot_content">%s</span>', $renderedValue); return sprintf('<span class="sympal_slot_wrapper %s" id="sympal_slot_wrapper_%s">%s</span>', htmlentities(json_encode($options)), $slot->id, $inlineContent); }
/** * Constructor */ public function __construct(Invoice $invoice) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url')); $defaults = array('WMI_MERCHANT_ID' => sfConfig::get('app_w1_merchant'), 'WMI_PAYMENT_AMOUNT' => sprintf('%01.2f', $invoice->getAmount()), 'WMI_CURRENCY_ID' => 980, 'WMI_PAYMENT_NO' => $invoice->getId(), 'WMI_DESCRIPTION' => $invoice->geDescription(), 'WMI_SUCCESS_URL' => url_for('payment_w1_success', array(), true), 'WMI_FAIL_URL' => url_for('payment_w1_fail', array(), true), 'WMI_PTENABLED' => 'CashTerminalUAH'); $defaults['WMI_SIGNATURE'] = $this->createSign($defaults); parent::__construct($defaults); }
public function execute($request) { if ($request->isMethod(sfWebRequest::POST)) { $username = $request->getParameter('txtUsername'); $password = $request->getParameter('txtPassword'); $additionalData = array('timeZoneOffset' => $request->getParameter('hdnUserTimeZoneOffset', 0)); try { $success = $this->getAuthenticationService()->setCredentials($username, $password, $additionalData); if ($success) { $this->getLoginService()->addLogin(); $paramString = $this->_getParameterString($request, true); //$this->redirect('oauth/authorize'. $paramString); $url = url_for('oauth/authorize') . $paramString; $logger = Logger::getLogger('login'); $loggedInUserId = $this->getAuthenticationService()->getLoggedInUserId(); $loggedInUser = $this->getSystemUserService()->getSystemUser($loggedInUserId); $logger->info($loggedInUserId . ', ' . $loggedInUser->getUserName() . ', ' . $_SERVER['REMOTE_ADDR']); $this->redirect($url); } else { $paramString = $this->_getParameterString($request); $this->getUser()->setFlash('message', __('Invalid credentials'), true); $this->redirect('oauth/login' . $paramString); } } catch (AuthenticationServiceException $e) { $this->getUser()->setFlash('message', $e->getMessage(), true); $paramString = $this->_getParameterString($request); $this->redirect('oauth/login' . $paramString); } } return sfView::NONE; }
public static function get() { sfProjectConfiguration::getActive()->loadHelpers(array("Url")); sfProjectConfiguration::getActive()->loadHelpers(array("Tag")); //TODO: fix this return "<div id='skulebar'>\n\t\t<a id='skule' href='/'>Skule Courses</a>\n\t\t<form method='get' action='" . url_for("search/fuzzySearch") . "' name='frmSearchBar'>\n\t\t<div style='margin: 0pt; padding: 0pt; display: inline;'>\n\t\t</div>\n\t\t<input type='text' title='Quick search in Skule Courses' size='30' name='query' id='search_search' autocomplete='off'/>\n\t\t</form>\n\t\t<div id='user'>\n\t\t<a href='/login'>Login</a>\n\t\t</div>\n\t\t</div>"; }
function authorize() { global $api; $story_app = NULL; // Successful authorization. Store the access token in the session if (!isset($_GET['error'])) { try { $api->authenticate('authorization_code', array('code' => $_GET['code'], 'redirect_uri' => option('OAUTH_REDIRECT_URI'))); $_SESSION['access_token'] = $api->oauth->access_token; $_SESSION['refresh_token'] = $api->oauth->refresh_token; $story_app = $api->app->get(STORY_APP_ID); } catch (PodioError $e) { die("There was an error. The API responded with the error type <b>{$e->body['error']}</b> and the message <b>{$e->body['error_description']}</b><br><a href='" . url_for('/') . "'>Go back</a>"); } } if ($story_app) { $_SESSION['story_app'] = $story_app; $_SESSION['space'] = $api->space->get($_SESSION['story_app']['space_id']); redirect_to(''); } else { // Something went wrong. Display appropriate error message. unset($_SESSION['access_token']); unset($_SESSION['refresh_token']); $error_description = !empty($_GET['error_description']) ? htmlentities($_GET['error_description']) : 'You do not have access to the ScrumIO apps. Try logging in as a different user.'; return html('login.html.php', NULL, array('oauth_url' => option('OAUTH_URL'), 'error_description' => $error_description)); } }