| 1 |
<?php
|
| 2 |
|
| 3 |
/* Common Drupal methods definitons using in Artisteer theme export */
|
| 4 |
|
| 5 |
/**
|
| 6 |
* Generate the HTML representing a given menu with Artisteer style.
|
| 7 |
*
|
| 8 |
* @param $mid
|
| 9 |
* The block navigation content.
|
| 10 |
*
|
| 11 |
* @ingroup themeable
|
| 12 |
*/
|
| 13 |
function art_navigation_links_worker($content = NULL) {
|
| 14 |
if (!$content) {
|
| 15 |
return '';
|
| 16 |
}
|
| 17 |
|
| 18 |
$output = $content;
|
| 19 |
$menu_str = ' class="menu"';
|
| 20 |
if(strpos($content, $menu_str) !== false) {
|
| 21 |
$empty_str = '';
|
| 22 |
$pattern = '/class="menu"/i';
|
| 23 |
$replacement = 'class="artmenu"';
|
| 24 |
$output = preg_replace($pattern, $replacement, $output, 1);
|
| 25 |
$output = str_replace($menu_str, $empty_str, $output);
|
| 26 |
}
|
| 27 |
$output = preg_replace('~(<a [^>]*>)([^<]*)(</a>)~', '$1<span class="l"></span><span class="r"></span><span class="t">$2</span>$3', $output);
|
| 28 |
|
| 29 |
return $output;
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Allow themable wrapping of all breadcrumbs.
|
| 34 |
*/
|
| 35 |
function art_breadcrumb_woker($breadcrumb) {
|
| 36 |
$breadcrumb = menu_get_active_breadcrumb();
|
| 37 |
if (!empty($breadcrumb)) {
|
| 38 |
return '<div class="breadcrumb">' . implode(' | ', $breadcrumb) . '</div>';
|
| 39 |
}
|
| 40 |
}
|
| 41 |
|
| 42 |
/**
|
| 43 |
* Allow themable wrapping of all comments.
|
| 44 |
*/
|
| 45 |
function art_comment_woker($content, $type = null) {
|
| 46 |
static $node_type;
|
| 47 |
if (isset($type)) $node_type = $type;
|
| 48 |
return '<div id="comments">'. $content . '</div>';
|
| 49 |
}
|
| 50 |
|
| 51 |
/*
|
| 52 |
* Split out taxonomy terms by vocabulary.
|
| 53 |
*
|
| 54 |
* @param $node
|
| 55 |
* An object providing all relevant information for displaying a node:
|
| 56 |
* - $node->nid: The ID of the node.
|
| 57 |
* - $node->type: The content type (story, blog, forum...).
|
| 58 |
* - $node->title: The title of the node.
|
| 59 |
* - $node->created: The creation date, as a UNIX timestamp.
|
| 60 |
* - $node->teaser: A shortened version of the node body.
|
| 61 |
* - $node->body: The entire node contents.
|
| 62 |
* - $node->changed: The last modification date, as a UNIX timestamp.
|
| 63 |
* - $node->uid: The ID of the author.
|
| 64 |
* - $node->username: The username of the author.
|
| 65 |
*
|
| 66 |
* @ingroup themeable
|
| 67 |
*/
|
| 68 |
function art_terms_worker($node) {
|
| 69 |
$output = '';
|
| 70 |
if (isset($node->links)) {
|
| 71 |
$output = ' | ';
|
| 72 |
}
|
| 73 |
$terms = $node->taxonomy;
|
| 74 |
|
| 75 |
if ($terms) {
|
| 76 |
$links = array();
|
| 77 |
ob_start();?><img class="metadata-icon" src="<?php echo get_full_path_to_theme(); ?>/images/PostTagIcon.png" width="18" height="18" alt="PostTagIcon"/> <?php
|
| 78 |
$output .= ob_get_clean();
|
| 79 |
$output .= t('Tags: ');
|
| 80 |
foreach ($terms as $term) {
|
| 81 |
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
|
| 82 |
}
|
| 83 |
$output .= implode(', ', $links);
|
| 84 |
$output .= ', ';
|
| 85 |
}
|
| 86 |
|
| 87 |
$output = substr($output, 0, strlen($output)-2); // removes last comma with space
|
| 88 |
return $output;
|
| 89 |
}
|
| 90 |
|
| 91 |
/**
|
| 92 |
* Return a themed set of links.
|
| 93 |
*
|
| 94 |
* @param $links
|
| 95 |
* A keyed array of links to be themed.
|
| 96 |
* @param $attributes
|
| 97 |
* A keyed array of attributes
|
| 98 |
* @return
|
| 99 |
* A string containing an unordered list of links.
|
| 100 |
*/
|
| 101 |
function art_links_woker($links, $attributes = array('class' => 'links')) {
|
| 102 |
$output = '';
|
| 103 |
|
| 104 |
if (count($links) > 0) {
|
| 105 |
$output = '';
|
| 106 |
|
| 107 |
$num_links = count($links);
|
| 108 |
$index = 0;
|
| 109 |
|
| 110 |
foreach ($links as $key => $link) {
|
| 111 |
$class = $key;
|
| 112 |
|
| 113 |
if (strpos ($class, "read_more") !== FALSE) {
|
| 114 |
break;
|
| 115 |
}
|
| 116 |
|
| 117 |
// Automatically add a class to each link and also to each LI
|
| 118 |
if (isset($link['attributes']) && isset($link['attributes']['class'])) {
|
| 119 |
$link['attributes']['class'] .= ' ' . $key;
|
| 120 |
}
|
| 121 |
else {
|
| 122 |
$link['attributes']['class'] = $key;
|
| 123 |
}
|
| 124 |
|
| 125 |
if ($index > 0) {
|
| 126 |
$output .= ' | ';
|
| 127 |
}
|
| 128 |
|
| 129 |
// Add first and last classes to the list of links to help out themers.
|
| 130 |
$extra_class = '';
|
| 131 |
if ($index == 1) {
|
| 132 |
$extra_class .= 'first ';
|
| 133 |
}
|
| 134 |
if ($index == $num_links) {
|
| 135 |
$extra_class .= 'last ';
|
| 136 |
}
|
| 137 |
|
| 138 |
if ($class) {
|
| 139 |
if (strpos ($class, "comment") !== FALSE) {
|
| 140 |
ob_start();?><img class="metadata-icon" src="<?php echo get_full_path_to_theme(); ?>/images/PostCommentsIcon.png" width="18" height="18" alt="PostCommentsIcon"/> <?php
|
| 141 |
$output .= ob_get_clean();
|
| 142 |
}
|
| 143 |
else {
|
| 144 |
ob_start();?><img class="metadata-icon" src="<?php echo get_full_path_to_theme(); ?>/images/PostCategoryIcon.png" width="18" height="18" alt="PostCategoryIcon"/> <?php
|
| 145 |
$output .= ob_get_clean();
|
| 146 |
}
|
| 147 |
}
|
| 148 |
|
| 149 |
$index++;
|
| 150 |
$output .= get_html_link_output($link);
|
| 151 |
}
|
| 152 |
}
|
| 153 |
|
| 154 |
return $output;
|
| 155 |
}
|
| 156 |
|
| 157 |
function get_html_link_output($link) {
|
| 158 |
$output = '';
|
| 159 |
// Is the title HTML?
|
| 160 |
$html = isset($link['html']) && $link['html'];
|
| 161 |
|
| 162 |
// Initialize fragment and query variables.
|
| 163 |
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
|
| 164 |
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
|
| 165 |
|
| 166 |
if (isset($link['href'])) {
|
| 167 |
if (get_drupal_version() == 5) {
|
| 168 |
$output = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
|
| 169 |
}
|
| 170 |
else {
|
| 171 |
$output = l($link['title'], $link['href'], array('language' => $link['language'], 'attributes'=>$link['attributes'], 'query'=>$link['query'], 'fragment'=>$link['fragment'], 'absolute'=>FALSE, 'html'=>$html));
|
| 172 |
}
|
| 173 |
}
|
| 174 |
else if ($link['title']) {
|
| 175 |
//Some links are actually not links, but we wrap these in <span> for adding title and class attributes
|
| 176 |
if (!$html) {
|
| 177 |
$link['title'] = check_plain($link['title']);
|
| 178 |
}
|
| 179 |
$output = $link['title'];
|
| 180 |
}
|
| 181 |
|
| 182 |
return $output;
|
| 183 |
}
|
| 184 |
|
| 185 |
/**
|
| 186 |
* Returns the rendered local tasks. The default implementation renders them as tabs.
|
| 187 |
*
|
| 188 |
* @ingroup themeable
|
| 189 |
*/
|
| 190 |
function art_menu_local_tasks() {
|
| 191 |
$output = '';
|
| 192 |
|
| 193 |
if ($primary = menu_primary_local_tasks()) {
|
| 194 |
$output .= $primary;
|
| 195 |
}
|
| 196 |
if ($secondary = menu_secondary_local_tasks()) {
|
| 197 |
$output .= $secondary;
|
| 198 |
}
|
| 199 |
return $output;
|
| 200 |
}
|
| 201 |
|
| 202 |
/**
|
| 203 |
* Format the forum body.
|
| 204 |
*
|
| 205 |
* @ingroup themeable
|
| 206 |
*/
|
| 207 |
function art_content_replace($content) {
|
| 208 |
$first_time_str = '<div id="first-time"';
|
| 209 |
$article_str = 'class="article"';
|
| 210 |
$pos = strpos($content, $first_time_str);
|
| 211 |
if($pos !== false)
|
| 212 |
{
|
| 213 |
$output = str_replace($first_time_str, $first_time_str . $article_str, $content);
|
| 214 |
$output = <<< EOT
|
| 215 |
<div class="Post">
|
| 216 |
<div class="Post-tl"></div>
|
| 217 |
<div class="Post-tr"></div>
|
| 218 |
<div class="Post-bl"></div>
|
| 219 |
<div class="Post-br"></div>
|
| 220 |
<div class="Post-tc"></div>
|
| 221 |
<div class="Post-bc"></div>
|
| 222 |
<div class="Post-cl"></div>
|
| 223 |
<div class="Post-cr"></div>
|
| 224 |
<div class="Post-cc"></div>
|
| 225 |
<div class="Post-body">
|
| 226 |
<div class="Post-inner">
|
| 227 |
|
| 228 |
<div class="PostContent">
|
| 229 |
|
| 230 |
$output
|
| 231 |
|
| 232 |
</div>
|
| 233 |
<div class="cleared"></div>
|
| 234 |
|
| 235 |
|
| 236 |
</div>
|
| 237 |
|
| 238 |
</div>
|
| 239 |
</div>
|
| 240 |
|
| 241 |
EOT;
|
| 242 |
}
|
| 243 |
else
|
| 244 |
{
|
| 245 |
$output = $content;
|
| 246 |
}
|
| 247 |
return $output;
|
| 248 |
}
|
| 249 |
|
| 250 |
function art_placeholders_output($var1, $var2, $var3) {
|
| 251 |
$output = '';
|
| 252 |
if (!empty($var1) && !empty($var2) && !empty($var3)) {
|
| 253 |
$output .= <<< EOT
|
| 254 |
<table class="position" width="100%" cellpadding="0" cellspacing="0" border="0">
|
| 255 |
<tr valign="top">
|
| 256 |
<td width="33%">$var1</td>
|
| 257 |
<td width="33%">$var2</td>
|
| 258 |
<td>$var3</td>
|
| 259 |
</tr>
|
| 260 |
</table>
|
| 261 |
EOT;
|
| 262 |
}
|
| 263 |
else if (!empty($var1) && !empty($var2)) {
|
| 264 |
$output .= <<< EOT
|
| 265 |
<table class="position" width="100%" cellpadding="0" cellspacing="0" border="0">
|
| 266 |
<tr valign="top">
|
| 267 |
<td width="33%">$var1</td>
|
| 268 |
<td>$var2</td>
|
| 269 |
</tr>
|
| 270 |
</table>
|
| 271 |
EOT;
|
| 272 |
}
|
| 273 |
else if (!empty($var2) && !empty($var3)) {
|
| 274 |
$output .= <<< EOT
|
| 275 |
<table class="position" width="100%" cellpadding="0" cellspacing="0" border="0">
|
| 276 |
<tr valign="top">
|
| 277 |
<td width="67%">$var2</td>
|
| 278 |
<td>$var3</td>
|
| 279 |
</tr>
|
| 280 |
</table>
|
| 281 |
EOT;
|
| 282 |
}
|
| 283 |
else if (!empty($var1) && !empty($var3)) {
|
| 284 |
$output .= <<< EOT
|
| 285 |
<table class="position" width="100%" cellpadding="0" cellspacing="0" border="0">
|
| 286 |
<tr valign="top">
|
| 287 |
<td width="50%">$var1</td>
|
| 288 |
<td>$var3</td>
|
| 289 |
</tr>
|
| 290 |
</table>
|
| 291 |
EOT;
|
| 292 |
}
|
| 293 |
else {
|
| 294 |
if (!empty($var1)) {
|
| 295 |
$output .= <<< EOT
|
| 296 |
<div id="var1">$var1</div>
|
| 297 |
EOT;
|
| 298 |
}
|
| 299 |
if (!empty($var2)) {
|
| 300 |
$output .= <<< EOT
|
| 301 |
<div id="var1">$var2</div>
|
| 302 |
EOT;
|
| 303 |
}
|
| 304 |
if (!empty($var3)) {
|
| 305 |
$output .= <<< EOT
|
| 306 |
<div id="var1">$var3</div>
|
| 307 |
EOT;
|
| 308 |
}
|
| 309 |
}
|
| 310 |
|
| 311 |
return $output;
|
| 312 |
}
|
| 313 |
|
| 314 |
function artxGetContentCellStyle($left, $right, $content)
|
| 315 |
{
|
| 316 |
if (!empty($left) && !empty($right))
|
| 317 |
return 'content';
|
| 318 |
if (!empty($right))
|
| 319 |
return 'content-sidebar1';
|
| 320 |
if (!empty($left) > 0)
|
| 321 |
return 'content-sidebar2';
|
| 322 |
return 'content-wide';
|
| 323 |
}
|
| 324 |
|
| 325 |
function art_submitted_worker($submitted, $date, $name)
|
| 326 |
{
|
| 327 |
$output = '';
|
| 328 |
ob_start();?><img class="metadata-icon" src="<?php echo get_full_path_to_theme(); ?>/images/PostDateIcon.png" width="17" height="18" alt="PostDateIcon"/> <?php
|
| 329 |
$output .= ob_get_clean();
|
| 330 |
$output .= $date;
|
| 331 |
$output .= ' | ';
|
| 332 |
ob_start();?><img class="metadata-icon" src="<?php echo get_full_path_to_theme(); ?>/images/PostAuthorIcon.png" width="14" height="14" alt="PostAuthorIcon"/> <?php
|
| 333 |
$output .= ob_get_clean();
|
| 334 |
$output .= $name;
|
| 335 |
return $output;
|
| 336 |
}
|