public static function createLink($params) { $structure = array(); $structure['app'] = $params[0]; $structure['type'] = 'application'; //we need to fill $structure['icon'] with the application icon! $app = new EyeosApplicationDescriptor(utf8_basename($params[0])); $icon = FSI::toExternalUrl($app->getMeta()->get('eyeos.application.iconUrl')); $structure['icon'] = str_replace('eyeos/extern/', 'index.php?extern=', $icon); $linkName = utf8_basename($params[0]); $info = pathinfo($linkName); if (!isset($info['extension']) || $info['extension'] != 'lnk') { $linkName .= '.lnk'; } $path = 'home:///Desktop/'; $text = json_encode($structure); $newFile = FSI::getFile($path . '/' . $linkName); $newFile->createNewFile(); $newFile->putContents($text); $newfile = FSI::getFile($path . '/' . $linkName); $meta = $newfile->getMeta(); $meta->set('iconPositionX', $params[1]); $meta->set('iconPositionY', $params[2]); $newfile->setMeta($meta); $return = array('class' => get_class($newfile), 'type' => $newfile->isDirectory() ? 'folder' : ($newfile->isLink() ? 'link' : 'file'), 'extension' => utf8_strtoupper($newfile->getExtension()), 'size' => $newfile->isDirectory() ? 0 : $newfile->getSize(), 'permissions' => $newfile->getPermissions(false), 'owner' => $newfile->getOwner(), 'group' => $newfile->getGroup(), 'absolutepath' => $newfile->getAbsolutePath(), 'meta' => $newfile->getMeta()->getAll()); if ($return['extension'] == 'LNK') { $return['content'] = $newfile->getContents(); } $return['name'] = $newfile->getName() != '/' ? $newfile->getName() : $return['absolutepath']; if ($newfile instanceof EyeosAbstractVirtualFile) { $return['virtual'] = 'true'; } else { $return['virtual'] = 'false'; } return $return; }
public function searchApplication($input) { $directory = new DirectoryIterator(EYE_ROOT . '/' . APPS_DIR); $searchResults = array(); foreach ($directory as $fileInfo) { $fileInfoName = $fileInfo->getFilename(); if ($fileInfo->isDir() && $fileInfoName[0] != '.') { if (!empty($input)) { $app = new EyeosApplicationDescriptor($fileInfoName); $meta = $app->getMeta(); if (stristr($fileInfoName, $input) || stristr($meta->get('eyeos.application.name'), $input) || stristr($meta->get('eyeos.application.description'), $input)) { $searchResults[] = $app; } } else { $searchResults[] = new EyeosApplicationDescriptor($fileInfoName); } } } return $searchResults; }