private function getAttachment() { // FIXME: Do we really need to mess with memory limits here? We're only reading ~80KB at a time... @ini_set('memory_limit', '128M'); if (!$this->isRequiredIDValid('id', $_GET)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'No attachment ID specified.'); } $attachmentID = $_GET['id']; $attachments = new Attachments(-1); $rs = $attachments->get($attachmentID, false); if (empty($rs) || md5($rs['directoryName']) != $_GET['directoryNameHash']) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid id / directory / filename, or you do not have permission to access this attachment.'); } $directoryName = $rs['directoryName']; $fileName = $rs['storedFilename']; $filePath = sprintf('attachments/%s/%s', $directoryName, $fileName); /* Check for the existence of the backup. If it is gone, send the user to a page informing them to press back and generate the backup again. */ if ($rs['contentType'] == 'catsbackup' && !file_exists($filePath)) { CommonErrors::fatal(COMMONERROR_FILENOTFOUND, $this, 'The specified backup file no longer exists. Please go back and regenerate the backup before downloading. We are sorry for the inconvenience.'); } // FIXME: Stream file rather than redirect? (depends on download preparer working). if (!eval(Hooks::get('ATTACHMENT_RETRIEVAL'))) { return; } /* Determine MIME content type of the file. */ $contentType = Attachments::fileMimeType($fileName); /* Open the file and verify that it is readable. */ $fp = @fopen($filePath, 'r'); if ($fp === false) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'This attachment is momentarily offline, please try again later. The support staff has been notified.'); } /* Set headers for sending the file. */ header('Content-Disposition: inline; filename="' . $fileName . '"'); //Disposition attachment was default, but forces download. header('Content-Type: ' . $contentType); header('Content-Length: ' . filesize($filePath)); header('Pragma: no-cache'); header('Expires: 0'); /* Read the file in ATTACHMENT_BLOCK_SIZE-sized chunks from disk and * output to the browser. */ while (!feof($fp)) { print fread($fp, self::ATTACHMENT_BLOCK_SIZE); } fclose($fp); /* Exit to prevent output after the attachment. */ exit; }
* Cognizo Technologies, Inc. All Rights Reserved. * * * $Id: getAttachmentLocal.php 3078 2007-09-21 20:25:28Z will $ */ $interface = new SecureAJAXInterface(); include_once './lib/CommonErrors.php'; include_once './lib/Attachments.php'; @ini_set('memory_limit', '256M'); if (!isset($_POST['id']) || !$interface->isRequiredIDValid('id')) { $interface->outputXMLErrorPage(-2, 'No attachment ID specified.'); die; } $attachmentID = $_POST['id']; $attachments = new Attachments(-1); $rs = $attachments->get($attachmentID, false); if (!isset($rs['directoryName']) || !isset($rs['storedFilename']) || md5($rs['directoryName']) != $_POST['directoryNameHash']) { $interface->outputXMLErrorPage(-2, 'Invalid directory name hash.'); die; } $directoryName = $rs['directoryName']; $fileName = $rs['storedFilename']; /* Check for the existence of the backup. If it is gone, send the user to a page informing them to press back and generate the backup again. */ if ($rs['contentType'] == 'catsbackup') { if (!file_exists('attachments/' . $directoryName . '/' . $fileName)) { $interface->outputXMLErrorPage(-2, 'The specified backup file no longer exists. Please press back and regenerate the backup before downloading. We are sorry for the inconvenience.'); die; } } $url = 'attachments/' . $directoryName . '/' . $fileName; if (!eval(Hooks::get('ATTACHMENT_RETRIEVAL'))) {
<div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> <?php } ?> </div> <a href="#project-inside" class="discover-more">Discover</a> <?php $gallery = array(); $attachments = new Attachments('attachments', get_the_ID()); if ($attachments->exist()) { while ($attachments->get()) { array_push($gallery, $attachments->src('full')); } } //ottengo il contenuto $content = ""; if (have_posts()) { // Start the loop. while (have_posts()) { the_post(); $content = get_the_content(); // End the loop. } } //ottengo gli artisti $pages = get_posts(array('post_type' => 'page', 'meta_key' => '_wp_page_template', 'meta_value' => 'page-artist.php'));
function add_photo_to_objects($content) { global $post; $attachments = new Attachments('my_attachments'); /* pass the instance name */ if ($attachments->exist()) { ob_start(); ?> <section class="object-photo-s"> <h1>Фотографии</h1> <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <?php $attachments = new Attachments('my_attachments'); /* pass the instance name */ $i = 0; while ($attachment = $attachments->get()) { ?> <li data-target="#carousel-example-generic" data-slide-to="<?php echo $i; ?> " <?php if ($i == 0) { echo 'class="active"'; } ?> ></li> <?php $i++; } ?> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <?php $attachments = new Attachments('my_attachments'); /* pass the instance name */ $i = 0; while ($attachment = $attachments->get()) { ?> <div class="item <?php if ($i == 0) { echo "active"; } ?> "> <?php echo wp_get_attachment_image($attachment->id, 'full'); ?> </div> <?php $i++; } ?> </div> <!-- Controls --> <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Назад</span> </a> <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Далее</span> </a> </div> <ul> <?php while ($attachment = $attachments->get()) { ?> <li> <pre><?php print_r($attachment); ?> </pre> </li> <?php } ?> </ul> </section> <?php $html = ob_get_contents(); ob_get_clean(); $content .= $html; } return $content; }
<?php get_header(); ?> <main> <?php $attachments = new Attachments('attachments'); if ($attachments->exist()) { ?> <div id="carousel" class="carousel slide carousel-fade" data-ride="carousel" data-interval="3500" data-pause="false"> <div class="carousel-inner" role="listbox"> <?php while ($index = $attachments->get()) { ?> <div class="item<?php if ($index->id == $attachments->id(0)) { ?> active<?php } ?> " data-title="<?php echo sanitize_title($attachments->field('title')); ?> " style="background-image:url(<?php echo $attachments->src('full'); ?> );"></div> <?php }
function printElement($post) { $attachments = new Attachments('gallery_attachments', $post->ID); $path_img = esc_url(get_template_directory_uri()) . '/images/'; if ($attachments->exist()) { //VIDEO INTERNO //echo '<div class="swiper-slide video-player-interno">'; echo '<video class="cover-video" autoplay muted loop>'; while ($attachments->get()) { $extension = explode('.', $attachments->url()); $ext = $extension[count($extension) - 1]; echo '<source src="' . $attachments->url() . '" type="video/' . $ext . '">'; } echo '</video>'; //echo '<div class="slide-description"><img src="'.$path_img.'video_play_black.png" /><h1 class="hidden-xs hidden-sm">'.$post->post_title.'</h1><p class="hidden-xs hidden-sm">'.$post->post_content.'</p></div>'; //echo '</div>'; } else { if (wp_get_attachment_url(get_post_thumbnail_id($post->ID)) != false) { //è un'immagine echo '<div class="swiper-slide">'; echo '<div class="swiper-slide-image" style="background:url(\'' . wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '\') center center" />'; echo '<div class="slide-description hidden-xs hidden-sm"><h1>' . $post->post_title . '</h1><p>' . $post->post_content . '</p></div>'; echo '</div>'; echo '</div>'; } else { //è un video di youtube //$embed_video = str_replace('watch?v=', 'embed/', get_post_meta($post->ID, 'video', true)); $embed_video = explode('watch?v=', get_post_meta($post->ID, 'video', true)); $idVideo = $embed_video[count($embed_video) - 1]; ?> <div id="video"></div> <script> $('#video').YTPlayer({ fitToBackground: true, videoId: '<?php echo $idVideo; ?> ' }); </script> <?php } } }
private function add($contents = '', $fields = array()) { $candidates = new Candidates($this->_siteID); /* Get possible sources. */ $sourcesRS = $candidates->getPossibleSources(); $sourcesString = ListEditor::getStringFromList($sourcesRS, 'name'); /* Get extra fields. */ $extraFieldRS = $candidates->extraFields->getValuesForAdd(); /* Get passed variables. */ $preassignedFields = $_GET; if (count($fields) > 0) { $preassignedFields = array_merge($preassignedFields, $fields); } /* Get preattached resume, if any. */ if ($this->isRequiredIDValid('attachmentID', $_GET)) { $associatedAttachment = $_GET['attachmentID']; $attachments = new Attachments($this->_siteID); $associatedAttachmentRS = $attachments->get($associatedAttachment); /* Show an attachment icon based on the document's file type. */ $attachmentIcon = strtolower(FileUtility::getAttachmentIcon($associatedAttachmentRS['originalFilename'])); $associatedAttachmentRS['attachmentIcon'] = $attachmentIcon; /* If the text field has any text, show a preview icon. */ if ($associatedAttachmentRS['hasText']) { $associatedAttachmentRS['previewLink'] = sprintf('<a href="#" onclick="window.open(\'%s?m=candidates&a=viewResume&attachmentID=%s\', \'viewResume\', \'scrollbars=1,width=800,height=760\')"><img width="15" height="15" style="border: none;" src="images/popup.gif" alt="(Preview)" /></a>', CATSUtility::getIndexName(), $associatedAttachmentRS['attachmentID']); } else { $associatedAttachmentRS['previewLink'] = ' '; } } else { $associatedAttachment = 0; $associatedAttachmentRS = array(); } /* Get preuploaded resume text, if any */ if ($this->isRequiredIDValid('resumeTextID', $_GET, true)) { $associatedTextResume = $_SESSION['CATS']->retrieveData($_GET['resumeTextID']); } else { $associatedTextResume = false; } /* Get preuploaded resume file (unattached), if any */ if ($this->isRequiredIDValid('resumeFileID', $_GET, true)) { $associatedFileResume = $_SESSION['CATS']->retrieveData($_GET['resumeFileID']); $associatedFileResume['id'] = $_GET['resumeFileID']; $associatedFileResume['attachmentIcon'] = strtolower(FileUtility::getAttachmentIcon($associatedFileResume['filename'])); } else { $associatedFileResume = false; } $EEOSettings = new EEOSettings($this->_siteID); $EEOSettingsRS = $EEOSettings->getAll(); if (!eval(Hooks::get('CANDIDATE_ADD'))) { return; } /* If parsing is not enabled server-wide, say so. */ if (!LicenseUtility::isParsingEnabled()) { $isParsingEnabled = false; } else { if (!isset($preassignedFields['email'])) { $isParsingEnabled = true; } else { if (empty($preassignedFields['email'])) { $isParsingEnabled = true; } else { if (isset($preassignedFields['isFromParser']) && $preassignedFields['isFromParser']) { $isParsingEnabled = true; } else { $isParsingEnabled = false; } } } } if (is_array($parsingStatus = LicenseUtility::getParsingStatus()) && isset($parsingStatus['parseLimit'])) { $parsingStatus['parseLimit'] = $parsingStatus['parseLimit'] - 1; } $this->_template->assign('parsingStatus', $parsingStatus); $this->_template->assign('isParsingEnabled', $isParsingEnabled); $this->_template->assign('contents', $contents); $this->_template->assign('extraFieldRS', $extraFieldRS); $this->_template->assign('active', $this); $this->_template->assign('subActive', 'Add Candidate'); $this->_template->assign('sourcesRS', $sourcesRS); $this->_template->assign('sourcesString', $sourcesString); $this->_template->assign('preassignedFields', $preassignedFields); $this->_template->assign('associatedAttachment', $associatedAttachment); $this->_template->assign('associatedAttachmentRS', $associatedAttachmentRS); $this->_template->assign('associatedTextResume', $associatedTextResume); $this->_template->assign('associatedFileResume', $associatedFileResume); $this->_template->assign('EEOSettingsRS', $EEOSettingsRS); $this->_template->assign('isModal', false); /* REMEMBER TO ALSO UPDATE JobOrdersUI::addCandidateModal() IF * APPLICABLE. */ $this->_template->display('./modules/candidates/Add.tpl'); }
function rcl_gallery_product($content) { global $post; if (get_post_type($post->ID) == 'products') { if (get_post_meta($post->ID, 'recall_slider', 1) != 1 || !is_single()) { return $content; } if (!class_exists('Attachments')) { $postmeta = get_post_meta($post->ID, 'children_prodimage', 1); if ($postmeta) { rcl_bxslider_scripts(); $values = explode(',', $postmeta); $gallery = '<div id="product-gallery">' . '<ul class="rcl-gallery">'; foreach ((array) $values as $children) { $large = wp_get_attachment_image_src($children, 'large'); $gallery .= '<li><a class="fancybox" href="' . $large[0] . '"><img src="' . $large[0] . '"></a></li>'; $thumbs[] = $large[0]; } $gallery .= '</ul>'; if (count($thumbs) > 1) { $gallery .= '<div id="bx-pager">'; foreach ($thumbs as $k => $src) { $gallery .= '<a data-slide-index="' . $k . '" href=""><img src="' . $src . '" /></a>'; } $gallery .= '</div>'; } $gallery .= '</div>'; } return $gallery . $content; } else { $attachments = new Attachments('attachments_products'); if ($attachments->exist()) { rcl_bxslider_scripts(); $num = 0; $gallery = '<div id="product-gallery">' . '<ul class="rcl-gallery">'; while ($attachments->get()) { $num++; $large = wp_get_attachment_image_src($children, 'large'); $gallery .= '<li><a class="fancybox" href="' . $attachments->src('full') . '"><img src="' . $attachments->src('thumbnail') . '"></a></li>'; $thumbs[] = $large[0]; } $gallery .= '</ul>'; $gallery .= '<div id="bx-pager">'; foreach ($thumbs as $k => $src) { $gallery .= '<a data-slide-index="' . $k . '" href=""><img src="' . $src . '" /></a>'; } $gallery .= '</div>'; } $gallery .= '</div>'; return $gallery . $content; } } else { return $content; } }
function get_attachments_array($name, $srcSize = 'full') { $return = array(); $attachments = new Attachments($name); if ($attachments->exist()) { $i = 0; while ($attachments->get()) { $return[$i]['id'] = $attachments->id(); $return[$i]['type'] = $attachments->type(); $return[$i]['subtype'] = $attachments->subtype(); $return[$i]['url'] = $attachments->url(); $return[$i]['thumbnail'] = $attachments->image('thumbnail'); $return[$i]['srcfull'] = $attachments->src('full'); $return[$i]['src'] = $attachments->src($srcSize); $return[$i]['filesize'] = $attachments->filesize(); $return[$i]['title'] = $attachments->field('title'); $return[$i]['caption'] = $attachments->field('caption'); $i++; } } return $return; }
function getSection($sectionName, $posts, $thisPostType) { $rtn = '<section class="section">'; $rtn .= '<h2 class="section-title">' . $sectionName . '</h2>'; $rtn .= '<table class="cpts-table">'; $rtn .= '<thead>'; $rtn .= '<tr>'; $rtn .= '<th class="col-number">Číslo</th>'; $rtn .= '<th class="col-name">Název</th>'; $rtn .= '<th class="col-date">Schváleno</th>'; $rtn .= '<th class="col-download">Česky</th>'; $rtn .= '<th class="col-download">Anglicky</th>'; $rtn .= '</tr>'; $rtn .= '</thead>'; $rtn .= '<tbody>'; while ($posts->have_posts()) { $posts->the_post(); $attachments = new Attachments('netevl_attachments_' . $thisPostType); $fileCz = null; $fileEn = null; if ($attachments->exist()) { while ($attachment = $attachments->get()) { if ($attachment->fields->file_lang == 'cz') { $fileCz = $attachments->url(); } if ($attachment->fields->file_lang == 'en') { $fileEn = $attachments->url(); } } } $rtn .= '<tr>'; $rtn .= '<td class="col-number">' . get_post_meta(get_the_ID(), '_netevl_' . $thisPostType . '_cislo', true) . '</td>'; $rtn .= '<td class="col-name"><h3 class="title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3></td>'; $rtn .= '<td class="col-date">' . get_post_meta(get_the_ID(), '_netevl_' . $thisPostType . '_schvaleno', true) . '</td>'; $rtn .= '<td class="col-download">'; if (!is_null($fileCz)) { $rtn .= '<a href="' . $fileCz . '" class="picto-pdf" target="_blank"></a>'; } $rtn .= '</td>'; $rtn .= '<td class="col-download">'; if (!is_null($fileEn)) { $rtn .= '<a href="' . $fileEn . '" class="picto-pdf" target="_blank"></a>'; } $rtn .= '</td>'; $rtn .= '</tr>'; } $rtn .= '</tbody>'; $rtn .= '</table>'; $rtn .= '</section>'; echo $rtn; }