Пример #1
0
 public function render(&$render_variables, $errors = array())
 {
     $result = parent::render($render_variables, $errors);
     // Clean attributes
     $id = $this->_clean_attributes($result['attributes'], 'id');
     $buffer = array();
     foreach ($this->options as $value => $title) {
         if ($this->value == $value) {
             $buffer[inflector::underscore($title)] = form::radio($result['attributes'], $value, TRUE);
         } else {
             $buffer[inflector::underscore($title)] = form::radio($result['attributes'], $value);
         }
     }
     $result['template']->element = $buffer;
     return (string) $result['template']->render();
 }
Пример #2
0
 /**
  *
  * This function takes the result cell, the link parameters, and the result row
  * and puts it all together to wrap a cell in a appropriate link!
  *
  * @return string HTML of cell wrapped in link
  * @param string $cell The current value of the cell (to be wrapped)
  * @param array $link The link parameter array
  * @param array $result The current result row
  */
 private function _cellToAnchor($cell, $link, $result, $reqAllArgs = false)
 {
     // Ensure there is something for a url
     if (!empty($link['link'])) {
         $url = $link['link'];
     } elseif (is_string($link)) {
         $url = $link;
     } else {
         $url = '';
     }
     $cell = self::_i18n($cell);
     //  Ensure attributes and arguments are set so we are not dealing with unset vars
     $attributes = empty($link['attributes']) ? '' : $link['attributes'];
     $arguments = array();
     // This ensures there is a title tag on the link
     if (empty($attributes['title'])) {
         $attributes['title'] = inflector::underscore($cell);
     }
     // Tack on any argumnets
     if (!empty($link['arguments'])) {
         // Standardize strings as arrays
         $link['arguments'] = is_array($link['arguments']) ? $link['arguments'] : array($link['arguments']);
         foreach ($link['arguments'] as $argument) {
             extract(self::_splitPath($argument));
             // If we can not fulfill the arguments (ie there was no result for an argument)
             // and we are required to do so then return false
             if (!isset($result[$hydrateName]) && $reqAllArgs) {
                 return false;
             }
             // This looks for the optional passAsSegments parameter for a column link
             if (!isset($link['passAsSegments']) || $link['passAsSegments'] == true) {
                 // If the args are passed as segments then we need to maintain the total count and order
                 $arguments[] = isset($result[$hydrateName]) ? $result[$hydrateName] : '';
             } else {
                 // If we are passing these args a GETs then we only need to do those that are set
                 if (isset($result[$hydrateName])) {
                     $arguments[] = $column . '=' . $result[$hydrateName];
                 }
             }
         }
     }
     // If arguments are passed as segments then the seperator is / and there will ALWAYS be a set amount
     if (!isset($link['passAsSegments']) || $link['passAsSegments'] == true) {
         $url = rtrim($url, '/') . '/' . rawurlencode(self::_implode($arguments, '/'));
     } else {
         // If the arguments are GETs then join on &, if there are any
         if ($args = self::_implode($arguments, '&')) {
             $url .= '?' . $args;
         }
     }
     $cell = htmlspecialchars($cell);
     // Wrap the cell results in a anchor tag
     return html::anchor($url, $cell, $attributes);
 }
Пример #3
0
 /**
  * Returns a URL Safe Title Slug, limited to the specified characters
  * 
  * @param	string	title
  * @param	int		limit (default 25)
  * @return	string	url safe slug
  */
 public static function title_slug($title, $limit = 25)
 {
     return preg_replace("/([_+]|_)\$/", "", str::limit_chars(inflector::underscore(str::strip_all_but(strtolower($title), "a-z0-9 \\_")), $limit, ""));
 }
Пример #4
0
 public function get_path()
 {
     return url::site() . 'themes/' . inflector::underscore($this->name) . '/';
 }