function RenderChunk($slug = "", $cachelength = "") { if (!empty($slug)) { // Returns a new query or a cached one $cache_folder = SERVER_CACHE_ROOT; // This usually points to /htdocs/cache/ on Modwest servers if (empty($cachelength)) { $cachelength = 60 * 60 * 3; } // seconds * minutes * hours = cache for 3 hours $usecache = false; $cachefile = $cache_folder . $slug . '.html'; $user = Users::GetCurrentUser(); // Skip using a cached file is there is a user logged in right now if (empty($user)) { // Check if we have this request cached recently; if (file_exists($cachefile)) { if (time() - filemtime($cachefile) <= $cachelength) { // Is this file recent enough to use? $cachecontents = file_get_contents($cachefile); // Return the cached xml if (!empty($cachecontents)) { return $cachecontents; $usecache = true; // not neccesary, as the return statement stops execution } } else { unlink($cachefile); } // File stale or empty, delete } } if (!$usecache) { $result = Chunks::FindBySlug($slug); $result = image_display($result->content); $result = email_display($result); // Store our cache version file_put_contents($cachefile, $result); return $result; } } else { return null; } }
function rss_getContent() { $content_to_display = $this->content; $content_to_display = document_display($content_to_display); $content_to_display = image_display($content_to_display); // Remove the rest of the tags $content_to_display = scrub_HCd_Tags($content_to_display); return $content_to_display; }
function get_content() { if (array_key_exists('content', $this)) { $content = $this->content; } elseif (array_key_exists('description', $this)) { $content = $this->description; } else { return null; } if (isset($content)) { // The order in which these run is important. $content = document_display($content); // searching for {{document:name_of_doc{{ pattern $content = video_display($content); // searching for {{video:name_of_vid{{ pattern $content = email_display($content); /// Need to run email before we insert them from a product $content = product_display($content); // searching for {{product:name_of_product{{ pattern $content = image_display($content); // searching for {{name_of_image{{ pattern $content = gallery_display($content); // searching for {{galery:name_of_gal{{ pattern $content = carousel_display($content); // searching for {{carousel:name_of_gal{{ pattern $content = random_from_gallery_display($content); // searching for {{random-from-gallery:name_of_gal{{ pattern $content = testimonial_display($content); // searching for {{testimonial:name_of_test{{ pattern return $content; } }
/** * * This function is needed so that we can use the Prev/Next module functionality * * * */ function pn_node($node, $mode = 'n') { if (!function_exists('prev_next_nid')) { return NULL; } switch ($mode) { case 'p': $n_nid = prev_next_nid($node->nid, 'prev'); break; case 'n': $n_nid = prev_next_nid($node->nid, 'next'); break; default: return NULL; } if ($n_nid) { $n_node = node_load($n_nid); $options = array('attributes' => array('class' => 'thumbnail'), 'html' => TRUE); switch ($n_node->type) { // For image nodes only case 'image': // This is an image node, get the thumbnail $html = l(image_display($n_node, 'thumbnail'), "node/{$n_nid}", $options); $html .= l($link_text, "node/{$n_nid}", array('html' => TRUE)); return $html; // For video nodes only // For video nodes only case 'video': foreach ($n_node->files as $fid => $file) { $html = '<img src="' . base_path() . $file->filepath; $html .= '" alt="' . $n_node->title; $html .= '" title="' . $n_node->title; $html .= '" class="image image-thumbnail" />'; $img_html = l($html, "node/{$n_nid}", $options); $text_html = l($link_text, "node/{$n_nid}", array('html' => TRUE)); return $img_html . $text_html; } default: // ... theme? What theme?! :-) $link_text = $n_node->title; $html = l($link_text, "page/{$n_nid}", array('html' => TRUE)); return $html; } } }
/** * Theme an image node teaser */ function phptemplate_image_teaser($node) { return l(image_display($node, 'thumbnail'), 'node/' . $node->nid, array('class' => 'image'), NULL, NULL, TRUE, TRUE) . $node->teaser; }
/** * Support for image_annotate on image nodes * */ function phptemplate_image_body($node, $size) { if (user_access('view image annotations') || user_access('create image annotations') || user_access('administer image annotations')) { // Retrieve all the annotations for that image field // We sort by area (height*width) to make sure small annotations are always on the top and avoid having some unhoverable ones $result = db_query('SELECT i.*, c.uid, c.comment, u.name FROM {image_annotate} i INNER JOIN {comments} c ON i.cid = c.cid JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d ORDER BY (i.size_height*i.size_width) ASC', $node->nid); // Build the array of notes settings global $user; $notes = array(); while ($note = db_fetch_object($result)) { $editable = user_access('administer image annotations') || user_access('create image annotations') && $note->uid && $note->uid == $user->uid; $author = theme('username', $note); $text = check_plain($note->comment); // . '"<span class="author"> '. t('by') .' '. $author . '</span>'; // if (user_access('access comments')) { // $text .= '<span class="actions"> » '. l(t('View comment'), $_GET['q'], array('fragment'=>'comment-'. $note->cid)) .'</span>'; // } $notes[] = array('aid' => $note->aid, 'cid' => $note->cid, 'uid' => $note->uid, 'height' => $note->size_height, 'width' => $note->size_width, 'top' => $note->position_top, 'left' => $note->position_left, 'text' => $text, 'editable' => $editable); } // Build the field settings $settings = array(array('nid' => $node->nid, 'field' => 'image', 'notes' => $notes, 'editable' => user_access('administer image annotations') || user_access('create image annotations'))); module_load_include('module', 'jquery_ui'); // Load all the JS and CSS magic drupal_add_js(array('imageAnnotate' => $settings), 'setting'); jquery_ui_add(array('ui.resizable', 'ui.draggable')); drupal_add_js('misc/collapse.js'); drupal_add_js(drupal_get_path('module', 'image_annotate') . '/tag.js'); drupal_add_css(drupal_get_path('module', 'image_annotate') . '/tag.css'); //BVDM 13/09/09: substitute image-annotate-image for image-annotate-nid-$node->nid to create a unique class per inserted image $class = 'imagefield imagefield-image image-annotate-nid-' . $node->nid; return image_display($node, $size, array('class' => $class)); } }