protected function getInlineStyle($id, $offset = 10) { $spriteOffset = Am_View::getSpriteOffset($id); if ($spriteOffset === false) { return ''; } $realOffset = $offset - $spriteOffset; return sprintf(' style="background-position: %spx center;" ', $realOffset); }
protected function getInlineStyle($id, $offset = 10) { $spriteOffset = Am_View::getSpriteOffset($id); if ($spriteOffset !== false) { $realOffset = $offset - $spriteOffset; return sprintf(' style="background-position: %spx center;" ', $realOffset); } elseif ($src = $this->view->_scriptImg('icons/' . $id . '.png')) { return sprintf(' style="background-position: %spx center; background-image:url(\'%s\')" ', $offset, $src); } else { return false; } }
public function icon($name, $alt = '', $source = 'icon') { $arr = is_string($alt) ? array('alt' => $alt) : (array) $alt; $attrs = ""; foreach ($arr as $k => $v) { $attrs .= $this->view->escape($k) . '="' . $this->view->escape($v) . '" '; } $spriteOffset = Am_View::getSpriteOffset($name, $source); if ($spriteOffset !== false) { if (!empty($arr['alt'])) { $attrs .= ' title="' . $this->view->escape($arr['alt']) . '"'; } $res = sprintf('<div class="glyph sprite-%s" style="background-position: %spx center;" %s></div>', $source, -1 * $spriteOffset, $attrs); } elseif ($src = $this->view->_scriptImg('icons/' . $name . '.png')) { $res = sprintf('<img src="%s" ' . $attrs . ' />', $src); } else { if (!empty($arr['alt'])) { $res = $arr['alt']; } else { $res = null; } } return $res; }