Exemplo n.º 1
0
 /**
  * full create function, renders the sprite and saves it as a new file
  * 
  * @depends testInstantiateSprite
  */
 public function testCreate()
 {
     // build the object
     $sprite = new Sprite('test');
     $file_name = $sprite->create();
     // assert the new file exists
     $this->assertFileExists($file_name);
 }
Exemplo n.º 2
0
    }
    public function createCss($img, $type, $dim)
    {
        $name = $img;
        if (($pos = strrpos($name, "/")) !== false) {
            $name = substr($name, $pos + 1, strlen($name));
        }
        $name = substr($name, 0, strrpos($name, "."));
        $name = preg_replace('/[^a-zA-Z0-9]/', "-", $name);
        $k = str_replace($this->webDir, "", $img);
        $className = isset($this->preCss[$k]) ? $this->preCss[$k] : "icon-" . $name;
        $this->html .= '<img src="web/extjs-3/resources/images/default/s.gif" class="' . $className . '" width="' . $dim[2] . '" height="' . $dim[3] . '"/> ' . "\t" . $dim[0] . 'px -' . $dim[1] . 'px ' . "\t | class:" . $className . "\t | file:" . $img . "<hr>";
        $this->css .= "." . $className . ' {background:url("../../' . $this->spriteImage . '.' . $type . '") no-repeat ' . $dim[0] . ' -' . $dim[1] . 'px !important;}
';
    }
    public function addFromDir($dir)
    {
        $items = scandir($dir);
        foreach ($items as $item) {
            $this->add($dir . "/" . $item);
        }
    }
}
$sp = new Sprite();
//Specify the path where the sprite should created
$sp->setSpriteImageName("web/images/sprite");
//Specify the path where css file should be created
$sp->setSpriteCssName("batch/sprite/sprite");
//$sp->addFromDir("W:\manager\plugins\appFlowerPlugin\web\images");
$sp->create();