本文整理汇总了PHP中Validator::isUuid方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::isUuid方法的具体用法?PHP Validator::isUuid怎么用?PHP Validator::isUuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::isUuid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
if (substr($this->url, 0, 7) == 'mailto:') {
$this->url = \StringUtil::encodeEmail($this->url);
} else {
$this->url = ampersand($this->url);
}
$embed = explode('%s', $this->embed);
if ($this->linkTitle == '') {
$this->linkTitle = $this->url;
}
// Use an image instead of the title
if ($this->useImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate('ce_hyperlink_image');
$this->Template = $objTemplate;
$this->Template->setData($this->arrData);
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
$this->Template->linkTitle = specialchars($this->linkTitle);
}
}
if (strncmp($this->rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
$this->Template->attribute = ' rel="' . $this->rel . '"';
} else {
$this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
}
$this->Template->rel = $this->rel;
// Backwards compatibility
$this->Template->href = $this->url;
$this->Template->embed_pre = $embed[0];
$this->Template->embed_post = $embed[1];
$this->Template->link = $this->linkTitle;
$this->Template->linkTitle = specialchars($this->titleText ?: $this->linkTitle);
$this->Template->target = '';
// Override the link target
if ($this->target) {
$this->Template->target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
}
// Unset the title attributes in the back end (see #6258)
if (TL_MODE == 'BE') {
$this->Template->title = '';
$this->Template->linkTitle = '';
}
}
示例2: generate
/**
* Return if there are no files
*
* @return string
*/
public function generate()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && $this->User->homeDir) {
$this->multiSRC = array($this->User->homeDir);
}
} else {
$this->multiSRC = deserialize($this->multiSRC);
}
// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
if (!\Validator::isUuid($this->multiSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
return parent::generate();
}
示例3: __construct
/**
* __construct function.
*
* @access public
* @param string
* @return void
*/
public function __construct($uuid)
{
if (!\Validator::isUuid($uuid)) {
return;
}
$this->uuid = $uuid;
}
示例4: addUuids
/**
* add uuids to tl_gallery_creator_pictures version added in 4.8.0
*/
public static function addUuids()
{
// add field
if (!\Database::getInstance()->fieldExists('uuid', 'tl_gallery_creator_pictures')) {
\Database::getInstance()->query("ALTER TABLE `tl_gallery_creator_pictures` ADD `uuid` BINARY(16) NULL");
}
$objDB = \Database::getInstance()->execute("SELECT * FROM tl_gallery_creator_pictures WHERE uuid IS NULL");
while ($objDB->next()) {
if ($objDB->path == '') {
continue;
}
if (is_file(TL_ROOT . '/' . $objDB->path)) {
\Dbafs::addResource($objDB->path);
} else {
continue;
}
$oFile = new \File($objDB->path);
$oFile->close();
$fileModel = $oFile->getModel();
if (\Validator::isUuid($fileModel->uuid)) {
\Database::getInstance()->prepare("UPDATE tl_gallery_creator_pictures SET uuid=? WHERE id=?")->execute($fileModel->uuid, $objDB->id);
$_SESSION["TL_CONFIRM"][] = "Added a valid file-uuid into tl_gallery_creator_pictures.uuid ID " . $objDB->id . ". Please check if all the galleries are running properly.";
}
}
}
示例5: addDummyImage
protected function addDummyImage(&$objTemplate, $arrArticle, $objModule)
{
if ($objTemplate->addImage) {
return;
}
$objArchive = \NewsArchiveModel::findByPk($arrArticle['pid']);
if ($objArchive === null) {
return;
}
$objTemplate->addDummyImage = false;
if ($objArchive->addDummyImage && $objArchive->dummyImageSingleSRC != '') {
$objModel = \FilesModel::findByUuid($objArchive->dummyImageSingleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($objArchive->dummyImageSingleSRC)) {
$objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
// Override the default image size
if ($objModule->imgSize != '') {
$size = deserialize($objModule->imgSize);
if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
$arrArticle['size'] = $objModule->imgSize;
}
}
$arrArticle['singleSRC'] = $objModel->path;
$this->addImageToTemplate($objTemplate, $arrArticle);
$objTemplate->class .= ' dummy-image';
$objTemplate->addDummyImage = true;
$objTemplate->addImage = false;
}
}
}
示例6: getFileModel
/**
* @param $file
*
* @return bool|FilesModel
* @throws \RuntimeException
*/
public static function getFileModel($file)
{
if (empty($file)) {
/**
* No file model source given
*/
return false;
} elseif (\Validator::isUuid($file)) {
/**
* Get file by DBAFS UUID
*/
$file = FilesModel::findByUuid($file, array('uncached' => true));
} else {
/**
* Search the old way
*/
return parent::getFileModel($file);
}
/**
* Get path from model
*/
if ($file instanceof FilesModel) {
return $file;
}
return false;
}
示例7: generateAddActions
public function generateAddActions($arrData, $id, Watchlist $objWatchlist)
{
global $objPage;
if ($objPage === null) {
return;
}
if (\Validator::isUuid($id)) {
$objFile = \FilesModel::findByUuid($id);
} else {
$objFile = \FilesModel::findBy('path', $id);
}
$objItem = new WatchlistItemModel();
$objItem->pid = Watchlist::getInstance()->getId();
$objItem->uuid = $objFile->uuid;
$objItem->pageID = $objPage->id;
$objItem->cid = $arrData['id'];
$objItem->type = $arrData['type'];
$objT = new \FrontendTemplate('watchlist_add_actions');
$objT->addHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_ADD . '&cid=' . $objItem->cid . '&type=' . $objItem->type . '&id=' . $strUuid . '&title=' . urlencode($objItem->getTitle()));
$objT->addTitle = $GLOBALS['TL_LANG']['WATCHLIST']['addTitle'];
$objT->addLink = $GLOBALS['TL_LANG']['WATCHLIST']['addLink'];
$objT->active = $objWatchlist->isInList($strUuid);
$objT->id = $strUuid;
return $objT->parse();
}
示例8: generate
/**
* Return if there are no files
* @return string
*/
public function generate()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && $this->User->homeDir) {
$this->folderSRC = $this->User->homeDir;
}
}
// Return if there is no folder defined
if (empty($this->folderSRC)) {
return '';
}
// Get the folders from the database
$this->objFolder = \FilesModel::findByUuid($this->folderSRC);
if ($this->objFolder === null) {
if (!\Validator::isUuid($this->folderSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
$file = \Input::get('file', true);
// Send the file to the browser and do not send a 404 header (see #4632)
if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
if (strpos(dirname($file), $this->objFolder->path) !== FALSE) {
\Controller::sendFileToBrowser($file);
}
}
return parent::generate();
}
示例9: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \StringUtil::toXhtml($this->text);
} else {
$this->text = \StringUtil::toHtml5($this->text);
}
$this->Template->text = \StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
$classes = deserialize($this->mooClasses);
$this->Template->toggler = $classes[0] ?: 'toggler';
$this->Template->accordion = $classes[1] ?: 'accordion';
$this->Template->headlineStyle = $this->mooStyle;
$this->Template->headline = $this->mooHeadline;
}
示例10: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \String::toXhtml($this->text);
} else {
$this->text = \String::toHtml5($this->text);
}
// Add the static files URL to images
if (TL_FILES_URL != '') {
$path = \Config::get('uploadPath') . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
$this->Template->text = \String::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
示例11: generate
/**
* Return if there are no files
*
* @return string
*/
public function generate()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && $this->User->homeDir) {
$this->multiSRC = array($this->User->homeDir);
}
} else {
$this->multiSRC = deserialize($this->multiSRC);
}
// Return if there are no files
if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
return '';
}
// Get the file entries from the database
$this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
if ($this->objFiles === null) {
if (!\Validator::isUuid($this->multiSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
$file = \Input::get('file', true);
// Send the file to the browser and do not send a 404 header (see #4632)
if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
while ($this->objFiles->next()) {
if ($file == $this->objFiles->path || dirname($file) == $this->objFiles->path) {
\Controller::sendFileToBrowser($file);
}
}
$this->objFiles->reset();
}
return parent::generate();
}
示例12: generate
/**
* Return if the file does not exist
* @return string
*/
public function generate()
{
// Return if there is no file
if ($this->singleSRC == '') {
return '';
}
$objFile = \FilesModel::findByUuid($this->singleSRC);
if ($objFile === null) {
if (!\Validator::isUuid($this->singleSRC)) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
$allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
// Return if the file type is not allowed
if (!in_array($objFile->extension, $allowedDownload)) {
return '';
}
$file = \Input::get('file', true);
// Send the file to the browser and do not send a 404 header (see #4632)
if ($file != '' && $file == $objFile->path) {
\Controller::sendFileToBrowser($file);
}
$this->singleSRC = $objFile->path;
return parent::generate();
}
示例13: compile
/**
* Generate module
*/
protected function compile()
{
if (TL_MODE == 'BE') {
// Im Backend-Modus
$this->strTemplate = 'be_wildcard';
$this->Template = new \BackendTemplate($this->strTemplate);
if ($this->headline) {
$this->Template->title = $this->headline;
}
$this->Template->wildcard = $this->text;
$this->Template->wildcard .= '<hr style="margin: 0 15px 5px;" />';
$this->cmh = unserialize($this->cmHeadline);
$this->cm_headline = $this->cmh['value'];
if ($this->cm_headline) {
$this->Template->wildcard .= '<h1>' . $this->cm_headline . "</h1>";
}
$this->Template->wildcard .= $this->cmText;
return;
}
// Im Frontend-Modus
// CSS einbinden
$GLOBALS['TL_CSS'][] = 'system/modules/content-memory/assets/ce_content-memory.css';
$this->Template->headline = $this->headline;
$this->Template->hl = $this->hl;
$this->Template->textvorn = $this->text;
$this->cmh = unserialize($this->cmHeadline);
$this->cm_headline = $this->cmh['value'];
$this->cm_hl = $this->cmh['unit'];
$this->Template->cmheadline = $this->cm_headline;
$this->Template->cmhl = $this->cm_hl;
$this->Template->texthint = $this->cmText;
//$this->Template->addImage = false;
//$this->Template->cmAddImage = false;
// add an image to the front side
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->textvorn = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
// add an image to the back side
if ($this->cmAddImage && $this->cmSingleSRC != '') {
$objModel = \FilesModel::findByUuid($this->cmSingleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->cmSingleSRC)) {
$this->Template->texthint = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->cmSingleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
示例14: onCreate
public function onCreate($strTable, $insertID, $arrSet, \DataContainer $dc)
{
if (($objModel = SubmissionArchiveModel::findByPk($insertID)) === null) {
return;
}
if (($uuid = Submissions::getDefaultAttachmentSRC()) !== null && \Validator::isUuid($uuid)) {
$objModel->attachmentUploadFolder = class_exists('Contao\\StringUtil') ? \StringUtil::uuidToBin($uuid) : \String::uuidToBin($uuid);
}
$objModel->save();
}
示例15: findMultipleByIds
/**
* Find multiple files by their IDs or UUIDs (backwards compatibility)
*
* @param array $arrIds An array of IDs or UUIDs
* @param array $arrOptions An optional options array
*
* @return \Model\Collection|null A collection of models or null if there are no files
*/
public static function findMultipleByIds($arrIds, array $arrOptions = array())
{
if (!is_array($arrIds) || empty($arrIds)) {
return null;
}
if (\Validator::isUuid(current($arrIds))) {
return static::findMultipleByUuids($arrIds, $arrOptions);
}
return parent::findMultipleByIds($arrIds, $arrOptions);
}