示例#1
0
 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);
 }
示例#2
0
 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;
     }
 }
示例#3
0
 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;
 }