Ejemplo n.º 1
0
function form_error($param, $options = array(), $catalogue = 'messages')
{
    $param_for_sf = str_replace(array('[', ']'), array('{', '}'), $param);
    $param = str_replace(array('{', '}'), array('[', ']'), $param);
    $options = _parse_attributes($options);
    $request = sfContext::getInstance()->getRequest();
    $style = $request->hasError($param_for_sf) ? '' : 'display:none;';
    $options['style'] = $style . (isset($options['style']) ? $options['style'] : '');
    if (!isset($options['class'])) {
        $options['class'] = sfConfig::get('sf_validation_error_class', 'form_error');
    }
    if (!isset($options['id'])) {
        $options['id'] = sfConfig::get('sf_validation_error_id_prefix', 'error_for_') . get_id_from_name($param);
    }
    $prefix = sfConfig::get('sf_validation_error_prefix', '');
    if (isset($options['prefix'])) {
        $prefix = $options['prefix'];
        unset($options['prefix']);
    }
    $suffix = sfConfig::get('sf_validation_error_suffix', '');
    if (isset($options['suffix'])) {
        $suffix = $options['suffix'];
        unset($options['suffix']);
    }
    $error = $request->getError($param_for_sf, $catalogue);
    return content_tag('div', $prefix . $error . $suffix, $options) . "\n";
}
Ejemplo n.º 2
0
 public function __toString()
 {
     $name = $this->getPropertyValue('namePattern');
     $id = $this->getPropertyValue('namePattern');
     $imageHTML = tag('img', array('src' => theme_path('images/callout-left.png'), 'title' => 'Click here to edit', 'alt' => 'Edit', 'class' => 'callout dialogInvoker'));
     $placeholderGetters = $this->getPropertyValue('placeholderGetters');
     $id = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('idPattern'));
     $name = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('namePattern'));
     $comments = $this->getValue();
     $commentExtract = '';
     $allComments = '';
     // show last comment only
     if (count($comments) > 0) {
         foreach ($comments as $comment) {
             $created = new DateTime($comment->getCreated());
             $createdAt = set_datepicker_date_format($created->format('Y-m-d')) . ' ' . $created->format('H:i');
             $formatComment = $createdAt . ' ' . $comment->getCreatedByName() . "\n\n" . $comment->getComments();
             $allComments = $formatComment . "\n\n" . $allComments;
         }
         $lastComment = $comments->getLast();
         $commentExtract = $this->trimComment($lastComment->getComments());
     }
     $commentContainerHTML = content_tag('span', $commentExtract, array('id' => $this->generateAttributeValue($placeholderGetters, 'commentContainer-{id}')));
     $hiddenFieldHTML = tag('input', array('type' => 'hidden', 'id' => $id, 'name' => $name, 'value' => $allComments));
     $commentHTML = content_tag('span', $commentContainerHTML . $imageHTML . $hiddenFieldHTML, array('class' => 'commentContainerLong'));
     if ($this->isHiddenOnCallback()) {
         return ' ';
     }
     return $commentHTML . $this->getHiddenFieldHTML();
 }
Ejemplo n.º 3
0
function link_to($anchor, $path, $options = array(), $out = true)
{
    if (empty($options['href'])) {
        $options['href'] = $path;
    }
    return content_tag('a', $anchor, $options, $out);
}
Ejemplo n.º 4
0
 public function __toString()
 {
     $leaveInfo = $this->getValue();
     $elementKey = $this->getPropertyValue('elementKey');
     $leaveInfoArray = explode("_", $leaveInfo);
     $leaveTaken = count($leaveInfoArray) > $elementKey ? $leaveInfoArray[$elementKey] : '0.00';
     $linkable = $this->getPropertyValue('linkable', false);
     if ($linkable) {
         if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
             list($method, $params) = $linkable;
             $linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
             $employeeId = $this->dataObject->getEmployeeId();
         } else {
             $linkable = $this->getValue('linkable');
             $employeeId = $this->getValue('placeholderGetters');
             $employeeId = $employeeId['emp_number'];
         }
     }
     if ($linkable) {
         $placeholderGetters = $this->getPropertyValue('placeholderGetters');
         $urlPattern = $this->getPropertyValue('urlPattern');
         if ($employeeId == $this->getValue('loggedUserId')) {
             $urlPattern = $this->getPropertyValue('altUrlPattern');
         }
         $url = $urlPattern;
         foreach ($placeholderGetters as $placeholder => $getter) {
             $placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
             $url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
         }
         $linkAttributes = array('href' => $url);
         return content_tag('a', $leaveTaken, $linkAttributes) . $this->getHiddenFieldHTML();
     } else {
         return $leaveTaken;
     }
 }
Ejemplo n.º 5
0
function my_options_for_select($options = array(), $selected = '', $disabled = '', $html_options = array())
{
    $html_options = _parse_attributes($html_options);
    if (is_array($selected)) {
        $selected = array_map('strval', array_values($selected));
    }
    if (is_array($disabled)) {
        $disabled = array_map('strval', array_values($disabled));
    }
    $html = '';
    if ($value = _get_option($html_options, 'include_custom')) {
        $html .= content_tag('option', $value, array('value' => '')) . "\n";
    } else {
        if (_get_option($html_options, 'include_blank')) {
            $html .= content_tag('option', '', array('value' => '')) . "\n";
        }
    }
    foreach ($options as $key => $value) {
        if (is_array($value)) {
            $html .= content_tag('optgroup', my_options_for_select($value, $selected, $disabled, $html_options), array('label' => $key)) . "\n";
        } else {
            $option_options = array('value' => $key);
            if (is_array($selected) && in_array(strval($key), $selected, true) || strval($key) == strval($selected)) {
                $option_options['selected'] = 'selected';
            }
            if (is_array($disabled) && in_array(strval($key), $disabled, true) || strval($key) == strval($disabled)) {
                $option_options['disabled'] = 'disabled';
            }
            $html .= content_tag('option', $value, $option_options) . "\n";
        }
    }
    return $html;
}
Ejemplo n.º 6
0
 public function __toString()
 {
     $linkable = $this->getPropertyValue('linkable', true);
     if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
         list($method, $params) = $linkable;
         $linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
     }
     if ($linkable) {
         $placeholderGetters = $this->getPropertyValue('placeholderGetters');
         $urlPattern = $this->getPropertyValue('urlPattern');
         $url = $urlPattern;
         foreach ($placeholderGetters as $placeholder => $getter) {
             $placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
             $url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
         }
         if (preg_match('/^index.php/', $url)) {
             sfProjectConfiguration::getActive()->loadHelpers('Url');
             $url = public_path($url, true);
         }
         $linkAttributes = array('href' => $url);
         if ($this->hasProperty('labelGetter')) {
             $label = $this->getValue('labelGetter');
         } else {
             $label = $this->getPropertyValue('label', 'Undefined');
         }
         return content_tag('a', $label, $linkAttributes) . $this->getHiddenFieldHTML();
     } else {
         return $this->toValue() . $this->getHiddenFieldHTML();
     }
 }
/**
 * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_prioritiser($object, $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be prioritised');
        return '';
    }
    $user_id = sfContext::getInstance()->getUser()->getId();
    try {
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'prioritising-items'));
        }
        $object_id = $object->getPrioritisableReferenceKey();
        $list_content = '';
        $object_priority = is_null($object->getPriorityValue()) ? 1 : $object->getPriorityValue();
        for ($i = $object->allowsNullPriority() ? 0 : 1; $i <= $object->getMaxPriority(); $i++) {
            if ($object_priority == $i) {
                if ($object->getPriorityLastUser() != 0) {
                    $label = sprintf('Priorit&agrave; impostata da user_id:%d il %s alle %s', $object->getPriorityLastUser(), $object->getPriorityLastUpdate('d/m/Y'), $object->getPriorityLastUpdate('h:i'));
                } else {
                    $label = 'Priorit&agrave; di default';
                }
                $list_content .= content_tag('li', content_tag('span', $i, array('title' => $label)), array('class' => 'current'));
            } else {
                $label = sprintf(__('Set priority to %d'), $i);
                $list_content .= content_tag('li', link_to($i, sprintf('deppPrioritising/prioritise?object_id=%d&object_model=%s&priority=%d', $object->getId(), get_class($object), $i), array('title' => $label, 'post' => true)));
            }
        }
        return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'priority-message'));
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from deppPrioritising helper: ' . $e->getMessage());
    }
}
function lw_link($name = '', $internal_uri = '', $options = array())
{
    list($lw_options, $html_options) = _lwSplitOptions(_parse_attributes($options));
    if (isset($lw_options['lwAddResources'])) {
        $lw_options['lwAddResources'] ? _lwAddResources() : null;
        unset($lw_options['lwAddResources']);
    } else {
        _lwAddResources();
    }
    if (isset($lw_options['lw_class'])) {
        $lw_class = $lw_options['lw_class'];
        unset($lw_options['lw_class']);
    } else {
        $lw_class = 'lightwindow';
    }
    if (isset($html_options['class'])) {
        $html_options['class'] .= ' ' . $lw_class;
    } else {
        $html_options['class'] = $lw_class;
    }
    if (!empty($lw_options)) {
        $params = array();
        foreach ($lw_options as $option => $value) {
            $params[] = 'lightwindow_' . $option . '=' . $value;
        }
        $html_options['params'] = implode(',', $params);
    }
    if ($internal_uri[0] == '#') {
        $html_options['href'] = $internal_uri;
        return content_tag('a', $name, $html_options);
    }
    return link_to($name, $internal_uri, $html_options);
}
Ejemplo n.º 9
0
function writeRow($list, $keyOr = null)
{
    ?>
<ul>
  <?php 
    foreach ($list as $key => $val) {
        $id = str_replace(array('/', '.'), '', $keyOr . $val);
        ?>
    <li>
      <?php 
        if (is_array($val)) {
            echo $key;
            writeRow($val, $key . '/');
        } else {
            ?>
        <input type="checkbox" name="list[]" value="<?php 
            echo $keyOr . $val;
            ?>
" id="<?php 
            echo $id;
            ?>
">
        <?php 
            echo content_tag('label', basename($val), array('for' => $id));
            ?>
      <?php 
        }
        ?>
    </li>
  <?php 
    }
    ?>
</ul>
<?php 
}
Ejemplo n.º 10
0
 public function __toString()
 {
     $defaultOption = $this->getPropertyValue('defaultOption');
     $options = $this->getPropertyValue('options', $defaultOption);
     if ($options instanceof sfOutputEscaperArrayDecorator || is_array($options)) {
         list($object, $method, $params) = $options;
         $object = $object instanceof sfOutputEscaperObjectDecorator ? $object->getRawValue() : $object;
         $params = $params instanceof sfOutputEscaperArrayDecorator ? $params->getRawValue() : $params;
         foreach ($params as $key => $value) {
             if ($value === ohrmListConfigurationFactory::RECORD) {
                 $params[$key] = $this->dataObject;
             }
         }
         $options = call_user_func_array(array($object, $method), $params);
     }
     if ($this->getPropertyValue('hideIfEmpty', false) && empty($options)) {
         return '&nbsp;';
     }
     if ($this->isHiddenOnCallback()) {
         return '&nbsp;';
     }
     $optionsHTML = content_tag('option', __($defaultOption['label']), array('value' => $defaultOption['value'])) . "\n";
     foreach ($options as $value => $label) {
         $optionsHTML .= content_tag('option', __($label), array('value' => $value)) . "\n";
     }
     $placeholderGetters = $this->getPropertyValue('placeholderGetters');
     $id = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('idPattern'));
     $name = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('namePattern'));
     $class = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('classPattern'));
     if ($this->getPropertyValue('hideIfEmpty', false) && empty($options)) {
         return '&nbsp;';
     }
     $html = content_tag('select', $optionsHTML, array('id' => $id, 'name' => $name, 'class' => $class));
     return $html . $this->getHiddenFieldHTML();
 }
Ejemplo n.º 11
0
function link_to_star($object, $options = array())
{
    $user = sfContext::getInstance()->getUser();
    if ($user->isAuthenticated()) {
        $response = sfContext::getInstance()->getResponse();
        $has_jquery = sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_has_jquery');
        if (!$has_jquery) {
            $response->addJavascript('/sfPropelActAsStarredBehaviorPlugin/js/jquery-1.2.2.pack');
        }
        $response->addJavascript('/sfPropelActAsStarredBehaviorPlugin/js/sf_star');
        $is_starred = $object->isStarred() ? 'sf_star_on' : 'sf_star_off';
        $options = _parse_attributes($options);
        if (isset($options['class'])) {
            $options['class'] .= ' sf_star ' . $is_starred;
        } else {
            $options['class'] = 'sf_star ' . $is_starred;
        }
        $type = sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_type', null);
        if (!$type || $type == 'image') {
            $content = $object->isStarred() ? image_tag(sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_image_on', '/sfPropelActAsStarredBehaviorPlugin/images/star_on.gif')) : image_tag(sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_image_off', '/sfPropelActAsStarredBehaviorPlugin/images/star_off.gif'));
        } elseif (isset($options['txt_on']) && isset($options['txt_off'])) {
            $content = $object->isStarred() ? $options['txt_off'] : $options['txt_on'];
        } else {
            $content = $object->isStarred() ? sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_on') : sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_off');
        }
        $model = get_class($object);
        $id = $object->getPrimaryKey();
        return link_to($content, 'sfStar/starit?model=' . $model . '&id=' . $id, $options);
        // return content_tag('span',link_to($image,'sfStar/starit?model='.$model.'&id='.$id,'class=sf_star'));
    } else {
        return content_tag('span', '');
    }
}
Ejemplo n.º 12
0
 public function getHtml()
 {
     $navigationHtml = '';
     $navigationHtml .= tag('input', array('type' => 'button', 'value' => 'Back', 'id' => 'ohrmFormNavigatorButton_Back', 'class' => 'plainbtn'));
     $navigationHtml = content_tag('div', $navigationHtml, array('style' => 'margin: 4px;'));
     return $navigationHtml . $this->decoratedForm->getHtml();
 }
/**
 * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_omnibus_selector($object, $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be flagged as Omnibus');
        return '';
    }
    $user_id = sfContext::getInstance()->getUser()->getId();
    try {
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'omnibus-flag'));
        }
        $object_is_omnibus = $object->getIsOmnibus();
        $object_will_be_omnibus = !$object_is_omnibus;
        $selector = '';
        if ($object_is_omnibus) {
            $status = "Questo atto &egrave; Omnibus";
            $label = "Marcalo come non-Omnibus";
        } else {
            $status = "Questo atto non &egrave; Omnibus";
            $label = "Marcalo come Omnibus";
        }
        $selector .= link_to($label, sprintf('atto/setOmnibusStatus?id=%d&status=%d', $object->getId(), $object_will_be_omnibus), array('post' => true));
        return content_tag('div', $status) . content_tag('div', $selector, $options);
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from deppOmnibus helper: ' . $e->getMessage());
    }
}
 public function __toString()
 {
     $linkable = $this->getPropertyValue('linkable', true);
     if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
         list($method, $params) = $linkable;
         $linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
         $employeeId = $this->dataObject->getEmployeeId();
     } else {
         $linkable = $this->getValue('linkable');
         $employeeId = $this->getValue('hiddenFieldValueGetter');
     }
     if ($linkable) {
         $placeholderGetters = $this->getPropertyValue('placeholderGetters');
         $urlPattern = $this->getPropertyValue('urlPattern');
         if ($employeeId == $this->getValue('loggedUserId')) {
             $urlPattern = $this->getPropertyValue('altUrlPattern');
         }
         $url = $urlPattern;
         foreach ($placeholderGetters as $placeholder => $getter) {
             $placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
             $url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
         }
         $linkAttributes = array('href' => $url);
         $employeeName = $this->getValue('labelGetter');
         if ($this->getValue('terminatedEmployee')) {
             $employeeName .= ' (' . __('Past Employee') . ')';
         }
         return content_tag('a', $employeeName, $linkAttributes) . $this->getHiddenFieldHTML();
     } else {
         return $this->toValue();
     }
 }
 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;
 }
/**
 * Returns a JavaScript tag with the '$content' inside. If no content is passed, it works as the slot() method and will output everythin between
 * javascript_tag() and end_javascript_tag(),
 * Example:
 *   <?php echo javascript_tag("alert('All is good')") ?>
 *   => <script type="text/javascript">alert('All is good')</script>
 *   <?php javascript_tag() ?>alert('All is good')<?php end_javascript_tag() ?>
 */
function javascript_tag($content = null)
{
    if (!is_null($content)) {
        return content_tag('script', javascript_cdata_section($content), array('type' => 'text/javascript'));
    } else {
        ob_start();
    }
}
function page_title($title, $tag = 'h1', $echo = true)
{
    $sf_response = sfContext::getInstance()->getResponse();
    $sf_response->setTitle(strip_tags($title));
    if ($echo) {
        echo $tag ? content_tag($tag, $title) : $title;
    }
    return $title;
}
Ejemplo n.º 18
0
/**
 * Returns a JavaScript tag with the '$content' inside. If no content is passed, it works as the slot() method and will output everythin between
 * javascript_tag() and end_javascript_tag(),
 * Example:
 *   <?php echo javascript_tag("alert('All is good')") ?>
 *   => <script type="text/javascript">alert('All is good')</script>
 *   <?php javascript_tag() ?>alert('All is good')<?php end_javascript_tag() ?>
 */
function javascript_tag($content = null)
{
    if (null !== $content) {
        require_once dirname(__FILE__) . '/TagHelper.php';
        return content_tag('script', javascript_cdata_section($content), array('type' => 'text/javascript'));
    } else {
        ob_start();
    }
}
Ejemplo n.º 19
0
function javascript_include_tag()
{
    $html = '';
    foreach (func_get_args() as $source) {
        $source = system_url($source);
        $html .= content_tag('script', '', array('type' => 'text/javascript', 'src' => $source)) . "\n";
    }
    return $html;
}
Ejemplo n.º 20
0
 public function folder_options()
 {
     $options = content_tag("option", "Your Folder", array("value" => $this->base_dir));
     foreach ($this->get_folders(PUBLIC_DIR . $this->base_dir) as $folder) {
         $path = str_replace(PUBLIC_DIR, "", $folder["path"]);
         $options .= content_tag("option", "&nbsp;&nbsp;" . $folder["name"], array("value" => $path));
     }
     return $options;
 }
Ejemplo n.º 21
0
function button_to_modal_box_preview($name, $id_formulario, $informe)
{
    use_helper('Javascript');
    $js = "\n  function preview_informe()\n  {\n    Modalbox.show('" . url_for('informes/preview?id_informe=' . $informe->getPrimaryKey()) . "', {title: '" . __('Vista preliminar del informe') . "', width: 700});\n  }";
    $html = content_tag('script', $js, array('type' => 'text/javascript'));
    $html .= button_to_function($name, 'preview_informe();', array('class' => 'sf_action_show', 'submit' => $id_formulario));
    $html .= "\n";
    return $html;
}
Ejemplo n.º 22
0
/**
 * Returns a link that will trigger a javascript function using the
 * onclick handler and return TRUE OR FALSE after the fact 
 * depending on the $html_options['return'] parameter. 
 * This attribute is removed before we use the default content_tag helper.
 *
 * Examples:
 *   <?php echo link_to_function('Greeting', "alert('Hello world!')", array('return'=>true)) ?>
 *   <?php echo link_to_function(image_tag('delete'), "if confirm('Really?'){ do_delete(); }") ?>
 */
function ls_link_to_function($name, $function, $html_options = array())
{
    $html_options = _parse_attributes($html_options);
    $html_options['href'] = isset($html_options['href']) ? $html_options['href'] : '#';
    $html_options['onclick'] = $function . '; return ';
    $html_options['onclick'] .= isset($html_options['return']) && $html_options['return'] == true ? 'true;' : 'false;';
    unset($html_options['return']);
    return content_tag('a', $name, $html_options);
}
Ejemplo n.º 23
0
 public function __toString()
 {
     $statusDiffer = $this->dataObject->isStatusDiffer();
     if ($statusDiffer) {
         return content_tag('a', __('Go to Detailed View'), array('href' => url_for('leave/viewLeaveRequest?id=' . $this->dataObject->getId())));
     } else {
         return parent::__toString();
     }
 }
Ejemplo n.º 24
0
function antispam_email_tag($emailaddress, $content = null, $options = array())
{
    $options = _parse_attributes($options);
    $options['href'] = 'mailto:' . $emailaddress;
    if ($content === null) {
        $content = $emailaddress;
    }
    return antispam_js_encrypt(content_tag('a', $content, $options), rand(-8, 5));
}
Ejemplo n.º 25
0
 function test_content_tag()
 {
     $this->assertEqual('<a href="create" class="test">Create</a>', content_tag("a", "Create", array('href' => 'create', 'class' => 'test')));
     $this->assertEqual('<textarea><br/></textarea>', content_tag("textarea", "<br/>", NULL, false));
     $this->assertEqual('<textarea>&lt;br/&gt;</textarea>', content_tag("textarea", "<br/>", NULL, true));
     $this->assertEqual('<br class="break"/>', content_tag("br", NULL, array('class' => 'break')));
     $this->assertEqual('<select multiple></select>', content_tag("select", "", array('multiple' => true)));
     $this->assertEqual('<select multiple></select>', content_tag("select", "", array('multiple' => 'multiple')));
     $this->assertEqual('<select multiple></select>', content_tag("select", "", array('multiple' => '')));
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $id = $this->generateId($name);
     if (isset($attributes['class'])) {
         $attributes['class'] .= ' w-theme-editor-color';
     } else {
         $attributes['class'] = ' w-theme-editor-color';
     }
     return content_tag('span', parent::render($name, $value, $attributes, $errors) . content_tag('span', image_tag('/sfPlopPlugin/vendor/famfamfam/silk/shading.png'), array('class' => 'w-clickable w-theme-editor-transparent', 'data-target' => $id)) . content_tag('span', image_tag('/sfPlopPlugin/vendor/famfamfam/silk/delete.png'), array('class' => 'w-clickable w-theme-editor-delete', 'data-target' => $id)));
 }
Ejemplo n.º 27
0
function ajax_feedback($inline = false)
{
    $afs = sfConfig::get('app_ajax_feedback_div_name_success');
    $aff = sfConfig::get('app_ajax_feedback_div_name_failure');
    $indicator = content_tag('div', __(' loading...'), array('id' => 'indicator', 'style' => 'display:none;'));
    $style = $inline ? sfConfig::get('app_ajax_feedback_div_style_inline') : sfConfig::get('app_ajax_feedback_div_style_absolute');
    $ajax_success_feedback = content_tag('div', '', array('id' => $afs, 'class' => $style, 'style' => 'display:none;'));
    $ajax_failure_feedback = content_tag('div', '', array('id' => $aff, 'class' => $style, 'style' => 'display:none;'));
    return $indicator . $ajax_success_feedback . $ajax_failure_feedback;
}
 public function getSlotValue($slot, $settings)
 {
     sfProjectConfiguration::getActive()->loadHelpers('sfAsset');
     $asset_id = $slot->getOption('asset_id', null, $settings['culture']);
     $asset = empty($asset_id) ? new sfAsset() : sfAssetPeer::retrieveFromUrl($asset_id);
     if (!$asset) {
         $asset = new sfAsset();
     }
     return asset_image_tag($asset, $asset->isNew() ? 'small' : 'full') . ($asset->getDescription() != '' ? content_tag('span', $asset->getDescription(), 'class=desc') : null);
 }
Ejemplo n.º 29
0
/**
 * gButton
 * Returns a Google Styled Button (<button/> or <a/>);
 * 
 * @author Carlos Escribano
 *
 * @param string Button text
 * @param array  Classic HTML options
 * @param array  Button options
 * 
 * Button options:
 * - button:  boolean; if true uses a button tag (<button/>)
 * - primary: boolean; if true the text appears bolded
 * - pill:    left|center|right; Button belongs to a group with "pill" (<button/> buttons).
 */
function gButton($text, $html_options = null, $button_options = array())
{
    $class = array('btn');
    $html_options = _parse_attributes($html_options);
    $button_options = _parse_attributes($button_options);
    if (isset($button_options['button']) && $button_options['button'] == true) {
        $tag = 'button';
        if (!isset($html_options['type'])) {
            $html_options['type'] = 'button';
        }
    } elseif (isset($html_options['type'])) {
        $tag = 'button';
    } else {
        $tag = 'a';
    }
    if (isset($button_options['pill'])) {
        $old = $tag;
        $tag = 'button';
        switch ($button_options['pill']) {
            case 'left':
                $class[] = 'pill-l';
                break;
            case 'center':
                $class[] = 'pill-c';
                break;
            case 'right':
                $class[] = 'pill-r';
                break;
            default:
                $tag = $old;
                break;
        }
    }
    if (isset($button_options['primary']) && $button_options['primary'] == true) {
        $class[] = 'primary';
    }
    if (isset($html_options['class'])) {
        $class = array_merge($class, (array) $html_options['class']);
    }
    $html_options['class'] = implode(' ', $class);
    if (isset($html_options['href'])) {
        if ($tag != 'button') {
            $html_options['href'] = url_for($html_options['href']);
        } else {
            $html_options['onclick'] = "document.location.href='" . url_for($html_options['href']) . "';";
            $html_options['href'] = '#';
        }
    } else {
        if (isset($html_options['onclick']) && $tag == 'a') {
            $html_options['href'] = '#';
        }
    }
    $html = content_tag($tag, content_tag('span', content_tag('span', $text)), $html_options);
    return $html;
}
Ejemplo n.º 30
0
/**
 * Returns a <script> include tag per source given as argument.
 *
 * <b>Examples:</b>
 * <code>
 *  echo javascript_include_tag('xmlhr');
 *    => <script language="JavaScript" type="text/javascript" src="/js/xmlhr.js"></script>
 *  echo javascript_include_tag('common.javascript', '/elsewhere/cools');
 *    => <script language="JavaScript" type="text/javascript" src="/js/common.javascript"></script>
 *       <script language="JavaScript" type="text/javascript" src="/elsewhere/cools.js"></script>
 * </code>
 *
 * @param  string asset names
 * @return  string XHTML compliant <script> tag(s)
 * @see    javascript_path 
 */
function javascript_include_tag()
{
    $sources = func_get_args();
    $sourceOptions = func_num_args() > 1 && is_array($sources[func_num_args() - 1]) ? array_pop($sources) : array();
    $html = '';
    foreach ($sources as $source) {
        $options = array_merge(array('type' => 'text/javascript', 'src' => $source), $sourceOptions);
        $html .= '  ' . content_tag('script', '', $options) . "\n";
    }
    return $html;
}