本文整理汇总了PHP中FilesModel::findByPk方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesModel::findByPk方法的具体用法?PHP FilesModel::findByPk怎么用?PHP FilesModel::findByPk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilesModel
的用法示例。
在下文中一共展示了FilesModel::findByPk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* @return string
*/
public function generate()
{
if (TL_MODE === 'BE') {
$template = new \BackendTemplate('be_wildcard');
$template->wildcard = '### ANTRAGO Event-Details ###';
$template->title = 'Event Details';
//"Kategorien: " . implode(', ',deserialize($this->arrData['ac_categories']));
return $template->parse();
}
// hole event details;
$url = $_SERVER["REQUEST_URI"];
$id = explode("veranstaltung=", $url)[1];
$this->configuration = AntragoConnector::getAntragoConfiguration($this->arrData['ac_event_details_config']);
$db = \Database::getInstance();
$this->product = $db->prepare("SELECT * FROM tl_antrago_products WHERE productId=?")->execute($id)->fetchAssoc();
$this->formConfig = array('showRegisterForm' => $this->arrData['ac_event_details_show_register'], 'showApplicationForm' => $this->arrData['ac_event_details_show_applicationform']);
// contact
$this->contact = $db->prepare("SELECT * FROM tl_antrago_contacts WHERE id =?")->execute($this->product['productContact'])->fetchAssoc();
$oContactImage = \FilesModel::findByPk($this->contact['image']);
// Add cover image
if ($oContactImage !== null) {
$sImage = \Image::get($oContactImage->path, '80', '100', 'center_center');
}
$this->contact['image'] = $sImage;
return parent::generate();
}
示例2: compile
/**
* Generate the module
*/
protected function compile()
{
$intList = $this->athletes_group;
$objMembers = $this->Database->prepare("SELECT * FROM tl_athlete WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList);
//$objMembers = \MembersModel;
// Return if no Members were found
if (!$objMembers->numRows) {
return;
}
$strLink = '';
// Generate a jumpTo link
if ($this->jumpTo > 0) {
$objJump = \PageModel::findByPk($this->jumpTo);
if ($objJump !== null) {
$strLink = $this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s');
}
}
$arrMembers = array();
// Generate Members
while ($objMembers->next()) {
$strPhoto = '';
$objPhoto = \FilesModel::findByPk($objMembers->photo);
// Add photo image
if ($objPhoto !== null) {
$strPhoto = \Image::getHtml(\Image::get($objPhoto->path, '140', '187', 'center_center'));
}
$arrMembers[] = array('name' => $objMembers->name, 'family' => $objMembers->family, 'post' => $objMembers->post, 'joined' => $objMembers->joined, 'photo' => $strPhoto, 'link' => strlen($strLink) ? sprintf($strLink, $objMembers->alias) : '');
}
$this->Template->members = $arrMembers;
}
示例3: updateFileTreeFields
/**
* Update FileTree fields
*/
public function updateFileTreeFields()
{
$objDatabase = \Database::getInstance();
$arrFields = array('singleSRC', 'imgSRC');
// Check the column type
$objDesc = $objDatabase->query("DESC tl_downloadarchiveitems singleSRC");
// Change the column type
if ($objDesc->Type != 'binary(16)') {
foreach ($arrFields as $field) {
$objFiles = $objDatabase->execute("SELECT id,{$field} FROM tl_downloadarchiveitems");
$objDatabase->query("ALTER TABLE tl_downloadarchiveitems CHANGE {$field} {$field} binary(16) NULL");
#$objDatabase->query("UPDATE tl_downloadarchiveitems SET $field=NULL WHERE $field='' OR $field=0");
while ($objFiles->next()) {
$objHelper = $this->generateHelperObject($this->changePath($objFiles->{$field}));
// UUID already
if ($objHelper->isUuid) {
continue;
}
// Numeric ID to UUID
if ($objHelper->isNumeric) {
$objFile = \FilesModel::findByPk($objHelper->value);
$objDatabase->prepare("UPDATE tl_downloadarchiveitems SET {$field}=? WHERE id=?")->execute($objFile->uuid, $objFiles->id);
} else {
$objFile = \FilesModel::findByPath($objHelper->value);
$objDatabase->prepare("UPDATE tl_downloadarchiveitems SET {$field}=? WHERE id=?")->execute($objFile->uuid, $objFiles->id);
}
}
}
}
}
示例4: updateFileField
protected function updateFileField($table)
{
$database = \Database::getInstance();
if (!$database->tableExists($table)) {
return;
}
if ($database->fieldExists('file', $table)) {
// get the field description
$desc = $database->query('DESC ' . $table . ' file');
// convert the field into a blob
if ($desc->Type != 'blob') {
$database->query('ALTER TABLE `' . $table . '` CHANGE `file` `file` blob NULL');
$database->query('UPDATE `' . $table . '` SET `file`=NULL WHERE `file`=\'\' OR `file`=0');
}
// select fields with numeric values
$resultSet = $database->query('SELECT id, file FROM ' . $table . ' WHERE file REGEXP \'^[0-9]+$\'');
while ($resultSet->next()) {
// Numeric ID to UUID
$file = \FilesModel::findByPk($resultSet->file);
if ($file) {
$database->prepare('UPDATE `' . $table . '` SET file=? WHERE id=?')->execute($file->uuid, $resultSet->id);
}
}
}
}
示例5: generate
/**
* Return if the file does not exist
* @return string
*/
public function generate()
{
// Return if there is no file
if ($this->singleSRC == '') {
return '';
}
// Check for version 3 format
if (!is_numeric($this->singleSRC)) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
$objFile = \FilesModel::findByPk($this->singleSRC);
if ($objFile === null) {
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) {
$this->sendFileToBrowser($file);
}
$this->singleSRC = $objFile->path;
return parent::generate();
}
示例6: compile
/**
* Generate the content element
*/
protected function compile()
{
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 = $GLOBALS['TL_CONFIG']['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 != '') {
if (!is_numeric($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
} else {
$objModel = \FilesModel::findByPk($this->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
}
示例7: generateSprite
/**
* Generate sprite from given data
*/
public function generateSprite(\DataContainer $row)
{
// Get the theme meta data
$objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?")->execute($row->id);
if ($objTheme->numRows < 1) {
return;
}
if ($objTheme->spritegen_enable != false) {
// Replace the numeric folder IDs
$objInputFolder = FilesModel::findByPk($objTheme->spritegen_source);
$objOutputFolder = FilesModel::findByPk($objTheme->spritegen_output_folder);
if ($objInputFolder !== null) {
// Provide settings for SpriteGen()
$cssSprites = new \SpriteGen();
$cssSprites->addImageFolder(TL_ROOT . '/' . $objInputFolder->path);
$cssSprites->setOutputFolder(TL_ROOT . '/' . $objOutputFolder->path);
$cssSprites->setCacheTime(0);
$cssSprites->useDatabase($objTheme->spritegen_modify_selectors, unserialize($objTheme->spritegen_selectors));
// Generate Sprite
$cssSprites->generateSprite($objTheme->spritegen_output_file, $objTheme->id, true, $objTheme->spritegen_direction, $objTheme->spritegen_output_width);
// Display success confirmation
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['spritegen_successful']);
$this->log('Generated image and style sheet for sprite ' . $objTheme->spritegen_output_file, __METHOD__, CRON);
}
}
}
示例8: compile
/**
* Generate the module
*/
protected function compile()
{
$this->Template->size = '';
// Set the size
if ($this->playerSize != '') {
$size = deserialize($this->playerSize);
if (is_array($size)) {
$this->Template->size = ' width="' . $size[0] . 'px" height="' . $size[1] . 'px"';
}
}
$this->Template->poster = false;
// Optional poster
if ($this->posterSRC != '') {
if (($objFile = \FilesModel::findByPk($this->posterSRC)) !== null) {
$this->Template->poster = $objFile->path;
}
}
// Pre-sort the array by preference
if (in_array($this->objFiles->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) {
$this->Template->isVideo = true;
$arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null);
} else {
$this->Template->isVideo = false;
$arrFiles = array('m4a' => null, 'mp3' => null, 'wma' => null, 'mpeg' => null, 'wav' => null);
}
$this->objFiles->reset();
// Pass File objects to the template
while ($this->objFiles->next()) {
$objFile = new \File($this->objFiles->path);
$arrFiles[$objFile->extension] = $objFile;
}
$this->Template->files = array_values(array_filter($arrFiles));
$this->Template->autoplay = $this->autoplay;
}
示例9: generateItemRow
/**
* Generate a song row and return it as HTML string
* @param array
* @return string
*/
public function generateItemRow($arrRow)
{
$objImage = \FilesModel::findByPk($arrRow['singleSRC']);
if ($objImage !== null) {
$strImage = \Image::getHtml(\Image::get($objImage->path, '30', '30', 'center_center'));
}
return '<div><div style="float:left; margin-right:10px;">' . $strImage . '</div>' . $arrRow['title'] . '</div>';
}
示例10: generateActRow
public function generateActRow($arrRow)
{
$objImage = \FilesModel::findByPk($arrRow['singleSRC']);
if ($objImage !== null) {
$strImage = \Image::getHtml(\Image::get($objImage->path, '25', '33', 'center_center'));
}
return '<div><div style="float:left; margin-right:10px;">' . $strImage . '</div>' . $arrRow['title'] . ' <br /><span style="padding-left:3px;color:#b3b3b3;">[' . $arrRow['post'] . ']</span></div>';
}
示例11: parseExtJs
protected function parseExtJs($objLayout, &$arrReplace)
{
$arrJs = array();
$objJs = ExtJsModel::findMultipleByIds(deserialize($objLayout->extjs));
if ($objJs === null) {
return false;
}
$cache = !$GLOBALS['TL_CONFIG']['debugMode'];
while ($objJs->next()) {
$objFiles = ExtJsFileModel::findMultipleByPid($objJs->id);
if ($objFiles === null) {
continue;
}
$strChunk = '';
$strFile = 'assets/js/' . $objJs->title . '.js';
$strFileMinified = str_replace('.js', '.min.js', $strFile);
$objGroup = new \File($strFile, file_exists(TL_ROOT . '/' . $strFile));
$objGroupMinified = new \File($strFileMinified, file_exists(TL_ROOT . '/' . $strFile));
$rewrite = $objJs->tstamp > $objGroup->mtime || $objGroup->size == 0 || $cache && $objGroupMinified->size == 0;
while ($objFiles->next()) {
$objFileModel = \FilesModel::findByPk($objFiles->src);
if ($objFileModel === null || !file_exists(TL_ROOT . '/' . $objFileModel->path)) {
continue;
}
$objFile = new \File($objFileModel->path);
$strChunk .= $objFile->getContent() . "\n";
if ($objFile->mtime > $objGroup->mtime) {
$rewrite = true;
}
}
// simple file caching
if ($rewrite) {
$objGroup->write($strChunk);
$objGroup->close();
// minify js
if ($cache) {
$objGroup = new \File($strFileMinified);
$objMinify = new \MatthiasMullie\Minify\JS();
$objMinify->add($strChunk);
$objGroup->write(rtrim($objMinify->minify(), ";") . ";");
// append semicolon, otherwise "(intermediate value)(...) is not a function"
$objGroup->close();
}
}
$arrJs[] = $cache ? "{$strFileMinified}|static" : "{$strFile}";
}
// HOOK: add custom css
if (isset($GLOBALS['TL_HOOKS']['parseExtJs']) && is_array($GLOBALS['TL_HOOKS']['parseExtJs'])) {
foreach ($GLOBALS['TL_HOOKS']['parseExtJs'] as $callback) {
$arrJs = static::importStatic($callback[0])->{$callback}[1]($arrJs);
}
}
if ($objJs->addBootstrap) {
$this->addTwitterBootstrap();
}
// inject extjs before other plugins, otherwise bootstrap may not work
$GLOBALS['TL_JAVASCRIPT'] = is_array($GLOBALS['TL_JAVASCRIPT']) ? array_merge($GLOBALS['TL_JAVASCRIPT'], $arrJs) : $arrJs;
}
示例12: compile
/**
* Generate the module
*/
protected function compile()
{
$objFaq = \FaqModel::findPublishedByPids($this->faq_categories);
if ($objFaq === null) {
$this->Template->faq = array();
return;
}
global $objPage;
$arrFaq = array_fill_keys($this->faq_categories, array());
// Add FAQs
while ($objFaq->next()) {
$objTemp = (object) $objFaq->row();
// Clean RTE output
if ($objPage->outputFormat == 'xhtml') {
$objFaq->answer = \String::toXhtml($objFaq->answer);
} else {
$objFaq->answer = \String::toHtml5($objFaq->answer);
}
$objTemp->answer = \String::encodeEmail($objFaq->answer);
$objTemp->addImage = false;
// Add an image
if ($objFaq->addImage && $objFaq->singleSRC != '') {
if (!is_numeric($objFaq->singleSRC)) {
$objTemp->answer = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
} else {
$objModel = \FilesModel::findByPk($objFaq->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$objFaq->singleSRC = $objModel->path;
$this->addImageToTemplate($objTemp, $objFaq->row());
}
}
}
$objTemp->enclosure = array();
// Add enclosure
if ($objFaq->addEnclosure) {
$this->addEnclosuresToTemplate($objTemp, $objFaq->row());
}
$objTemp->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], $this->parseDate($objPage->dateFormat, $objFaq->tstamp), $objFaq->getRelated('author')->name);
// Order by PID
$arrFaq[$objFaq->pid]['items'][] = $objTemp;
$arrFaq[$objFaq->pid]['headline'] = $objFaq->category;
}
$arrFaq = array_values(array_filter($arrFaq));
$limit_i = count($arrFaq) - 1;
// Add classes first, last, even and odd
for ($i = 0; $i <= $limit_i; $i++) {
$class = ($i == 0 ? 'first ' : '') . ($i == $limit_i ? 'last ' : '') . ($i % 2 == 0 ? 'even' : 'odd');
$arrFaq[$i]['class'] = trim($class);
$limit_j = count($arrFaq[$i]['items']) - 1;
for ($j = 0; $j <= $limit_j; $j++) {
$class = ($j == 0 ? 'first ' : '') . ($j == $limit_j ? 'last ' : '') . ($j % 2 == 0 ? 'even' : 'odd');
$arrFaq[$i]['items'][$j]->class = trim($class);
}
}
$this->Template->faq = $arrFaq;
$this->Template->request = $this->getIndexFreeRequest(true);
$this->Template->topLink = $GLOBALS['TL_LANG']['MSC']['backToTop'];
}
示例13: getArrayOfPerson
/**
* Return array of person
*
* @param object $objPerson
* @param array $arrSize
* @return array
*/
protected function getArrayOfPerson($objPerson, $arrSize)
{
$arrData = $objPerson->row();
$objFile = \FilesModel::findByPk($objPerson->image);
$arrData['singleSRC'] = $objFile->path;
$arrData['size'] = $arrSize;
$arrData['alt'] = $objPerson->firstname . ' ' . $objPerson->lastname;
return $arrData;
}
示例14: addTeaserImage
/**
* Insert a teaser image to the template
* @param object
* @param array
* @return void
* called from parseArticles HOOK
*/
public function addTeaserImage($objTemplate, $row)
{
if (!$objTemplate->teaser_addImage) {
return;
}
// original image setting
$addNewsImage = $objTemplate->addImage;
$addTeaserImage = $objTemplate->teaser_addImage;
// overwrite image sizes if set in module
if ($row['size'] != '') {
$objTemplate->size = $row['size'];
$objTemplate->teaser_size = $row['size'];
}
// teaser image
if ($addTeaserImage) {
// fetch teaser image
$objFile = \FilesModel::findByPk($objTemplate->teaser_singleSRC);
if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) {
return;
}
$objTemplate->teaser_singleSRC = $objFile->path;
$arrTeaserImage = array('singleSRC' => $objTemplate->teaser_singleSRC, 'size' => $objTemplate->teaser_size, 'alt' => $objTemplate->teaser_alt, 'imageUrl' => $objTemplate->teaser_imageUrl, 'fullsize' => $objTemplate->teaser_fullsize, 'floating' => $objTemplate->teaser_floating, 'imagemargin' => $objTemplate->teaser_imagemargin, 'linkedimage' => $objTemplate->teaser_linkedimage);
}
// news image
if ($addNewsImage) {
// store news image data
$arrNewsImage = array('singleSRC' => $objTemplate->singleSRC, 'size' => $objTemplate->size, 'alt' => $objTemplate->alt, 'imageUrl' => $objTemplate->imageUrl, 'fullsize' => $objTemplate->fullsize, 'floating' => $objTemplate->floating, 'imagemargin' => $objTemplate->imagemaring);
}
// Add teaser image.
if ($addTeaserImage) {
//Use contao internal function. (overwrites news image values)
parent::addImageToTemplate($objTemplate, $arrTeaserImage);
// set template vars
$objTemplate->teaser_imgSize = $objTemplate->imgSize;
$objTemplate->teaser_src = $objTemplate->src;
$objTemplate->teaser_attributes = $objTemplate->attributes;
$objTemplate->teaser_addBefore = $objTemplate->addBefore;
$objTemplate->teaser_margin = $objTemplate->margin;
$objTemplate->teaser_title = $objTemplate->title;
$objTemplate->teaser_alt = $objTemplate->alt;
$objTemplate->teaser_href = $objTemplate->href;
$objTemplate->teaser_float = $objTemplate->float;
$objTemplate->teaser_floatClass = $objTemplate->floatClass;
// link to post
if ($objTemplate->teaser_linkedimage && TL_MODE == 'FE') {
$objTemplate->teaser_href = $objTemplate->link;
$objTemplate->teaser_attributes = $objTemplate->teaser_fullsize ? LINK_NEW_WINDOW : '';
}
}
// Add news image.
if ($addNewsImage) {
// restore news image in template
parent::addImageToTemplate($objTemplate, $arrNewsImage);
}
$objTemplate->addImage = $addNewsImage;
$objTemplate->teaser_addImage = $addTeaserImage;
}
示例15: compile
/**
* Generate the content element
*/
protected function compile()
{
global $objPage;
if (substr($this->url, 0, 7) == 'mailto:') {
$this->url = \String::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 != '' && is_numeric($this->singleSRC)) {
$objModel = \FilesModel::findByPk($this->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$this->Template = new \FrontendTemplate('ce_hyperlink_image');
$this->Template->setData($this->arrData);
$objFile = new \File($objModel->path);
if ($objFile->isGdImage) {
$size = deserialize($this->size);
$intMaxWidth = TL_MODE == 'BE' ? 320 : $GLOBALS['TL_CONFIG']['maxImageWidth'];
// Adjust the image size
if ($intMaxWidth > 0 && ($size[0] > $intMaxWidth || !$size[0] && $objFile->width > $intMaxWidth)) {
$size[0] = $intMaxWidth;
$size[1] = floor($intMaxWidth * $objFile->height / $objFile->width);
}
$src = \Image::get($objModel->path, $size[0], $size[1], $size[2]);
if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) {
$this->Template->arrSize = $imgSize;
$this->Template->imgSize = ' ' . $imgSize[3];
}
$this->Template->src = TL_FILES_URL . $src;
$this->Template->alt = specialchars($this->alt);
$this->Template->linkTitle = specialchars($this->linkTitle);
$this->Template->caption = $this->caption;
}
}
}
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->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"';
}
}