9, ); } /* returns an array with config-relative web paths to ResourceFile instances */ public function resources() { return $this->initRes ? array( 'link/main.css' => new CSSFile(), ) : array(); } } class LinkTextFile extends MetaFile { private $_lData; /* file pattern */ public static function pattern() { return '/\.link\.txt$/i'; } /* loads the name of this element */ protected function loadName() { if (($altname = $this->getAlternativeName()) !== null) { return $altname; } $name = $this->getFilename(); $name = substr($name, 0, strrpos($name, '.l')); $name = strtr($name, '_', ' '); return $name; } /* returns the data about this link */ private function getLData() { if ($this->_lData === null) { $lines = file($this->location, FILE_IGNORE_NEW_LINES); $this->_lData = array( 'url' => isset($lines[0]) ? $lines[0] : '#', 'image' => isset($lines[1]) ? $lines[1] : '', 'label' => isset($lines[2]) ? $lines[2] : '', ); } return $this->_lData; } /* returns the HTML code for the preview */ public function getPreviewHTML() { Lonely::model()->getModule('LinkModule')->initRes = true; $l = $this->getLData(); $thumb = Factory::createFileByRelPath($l['image'], $this->getParent()); if ($thumb) { return $thumb->getPreviewHTML()."

".\LonelyGallery\escape($l['label'])."

"; } return "

Error: Please write the link (first line) and image path (second line) in this text file.

"; } /* returns the HTML code for the thumbnail */ public function getThumbHTML($profile, &$htmlclass = '') { Lonely::model()->getModule('LinkModule')->initRes = true; $l = $this->getLData(); $thumb = Factory::createFileByRelPath($l['image'], $this->getParent()); if ($thumb) { return "
".$thumb->getThumbHTML($profile)."
".\LonelyGallery\escape($l['label']).""; } return "

Error: Please write the link (first line) and image path (second line) in this text file.

"; } } class CSSFile extends \LonelyGallery\CSSFile { public function whenModified() { return filemtime(__FILE__); } public function getContent() { return <<<'CSS' .linkmodule-prev { font-size: 16px; margin: 10px 10px 0; line-height: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .linkmodule-prev ~ a { max-height: calc(100% - 50px); } .linkmodule-thumb-link + .thumb-link { display: none; } .linkmodule-thumb-link span:before, .linkmodule-prev > a:before { content: "⇒ "; } .album > .files > li .linkmodule-thumb img { margin-left: 0px; transition: margin-left 0.3s ease; } .album > .files > li:hover .linkmodule-thumb img { margin-left: -600px; } .album > .files > li > a.thumb-link.linkmodule-thumb-link { margin-left: 300px; transition: margin-left 0.3s ease; opacity: 1; } .album > .files > li:hover > a.thumb-link.linkmodule-thumb-link { margin-left: 0px; } CSS; } } ?>