Exemplo n.º 1
0
function set_post_view($ID)
{
    $count = Meta::get($ID, 'post_views_count');
    if (empty($count)) {
        add_post_meta($ID, 'post_views_count', 1);
    } else {
        update_post_meta($ID, 'post_views_count', $count++);
    }
}
Exemplo n.º 2
0
function slhb_set_title($post_id, $post, $update)
{
    $dateStr = Meta::get($post_id, 'match_date');
    $title = $dateStr . ' - ' . Meta::get($post_id, 'match_team_dom') . ' - ' . Meta::get($post_id, 'match_team_ext');
    $date = date($dateStr);
    //This temporarily removes filter to prevent infinite loops
    remove_action('save_post_slhb_match', __FUNCTION__);
    wp_update_post(array('ID' => $post_id, 'post_title' => $title, 'match_date' => $date));
    //redo filter
    add_action('save_post_slhb_match', __FUNCTION__, 10, 3);
}
Exemplo n.º 3
0
 public function testGeneral()
 {
     $meta = new Meta();
     $this->assertEmpty($meta->get('first'));
     $this->assertNotEmpty($meta->render());
     $this->assertNotEmpty($meta->getVars());
     $vars = ['test1', 'test2'];
     $meta->setVars($vars);
     $this->assertEquals($vars, $meta->getVars());
     $this->assertNotEmpty($meta->render());
 }
Exemplo n.º 4
0
 public static function getCurrent()
 {
     $team = get_queried_object();
     #add custom properties
     $bannerId = Meta::get($team->ID, 'profile', $single = true);
     $image_attributes = wp_get_attachment_image_src($bannerId, "full");
     if ($image_attributes) {
         $image_attributes[0];
         $team->banner = $image_attributes[0];
     }
     return $team;
 }
Exemplo n.º 5
0
 /**
  * Return only the last match played, with additional informations (teams and scores included)
  *
  * @return Match Object
  */
 public static function getNextMatch()
 {
     $matchs = MatchModel::getNextMatchs(1);
     if (count($matchs) == 1) {
         $match = $matchs[0];
         $matchId = $match->ID;
         $match->match_date = Meta::get($matchId, 'match_date');
         $match->match_team_dom = Meta::get($matchId, 'match_team_dom');
         $match->match_team_ext = Meta::get($matchId, 'match_team_ext');
         return $match;
     }
 }
Exemplo n.º 6
0
 /**
  * Formats the file info to be returned as OPDS to the client
  *
  * @param \OCP\Files\FileInfo $i
  * @return array formatted file info
  */
 public static function formatFileInfo(\OCP\Files\FileInfo $i)
 {
     $entry = array();
     $entry['id'] = $i['fileid'];
     $entry['mtime'] = $i['mtime'];
     $entry['name'] = $i->getName();
     $entry['type'] = $i['type'];
     if ($i['type'] === 'file') {
         $entry['mimetype'] = $i['mimetype'];
         $entry['humansize'] = \OC_Helper::humanFileSize($i['size']);
         $entry['meta'] = Meta::get($i['fileid']);
     }
     return $entry;
 }
Exemplo n.º 7
0
 /**
  * Returns an array of 3 popular books excepted
  * the one that is promoted.
  * 
  * @param int $id ID of a book to ignore for cross references.
  * @return array
  */
 public function getPopularBooks($id)
 {
     $books = array();
     $query = new WP_Query(array('post_type' => $this->slug, 'posts_per_page' => 3, 'post__not_in' => array($id), 'post_status' => 'publish', 'orderby' => 'rand'));
     $results = $query->get_posts();
     foreach ($results as $book) {
         $b = new stdClass();
         // Title
         $b->title = $book->post_title;
         // Featured image
         $b->image = get_the_post_thumbnail($book->ID);
         // Color
         $b->color = Meta::get($book->ID, 'color');
         // Excerpt
         $b->excerpt = $book->post_excerpt;
         // Permalink
         $b->link = get_permalink($book->ID);
         // Add the book object
         $books[] = $b;
     }
     return $books;
 }
Exemplo n.º 8
0
 /**
  * @brief offer preview for download
  *
  * if no preview exists for this file, send icon instead
  * 
  * @param string $path full path to file
  * @param string type type of preview requested
  */
 public static function servePreview($path, $type)
 {
     \OCP\User::checkLoggedIn();
     \OC::$server->getSession()->close();
     $i = \OC\Files\Filesystem::getFileInfo($path, false);
     /* check for predefined cover, if found replace $path with that of cover file */
     $meta = Meta::get($i['fileid']);
     if ($meta['cover']) {
         $path = pathinfo($path)['dirname'] . '/' . $meta['cover'];
         $i = \OC\Files\Filesystem::getFileInfo($path, false);
     }
     if (\OC::$server->getPreviewManager()->isMimeSupported($i['mimetype'])) {
         $preview = new \OC\Preview(\OC_User::getUser(), 'files');
         $preview->setFile($path);
         switch ($type) {
             case 'cover':
                 $preview->setMaxX(Config::getApp('cover-x', '200'));
                 $preview->setMaxY(Config::getApp('cover-y', '200'));
                 break;
             case 'thumbnail':
                 $preview->setMaxX(Config::getApp('thumb-x', '36'));
                 $preview->setMaxY(Config::getApp('thumb-y', '36'));
                 break;
         }
         $preview->showPreview();
     } else {
         // no preview, serve icon instead
         $scheme = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http';
         header("Location: " . $scheme . "://" . $_SERVER['HTTP_HOST'] . \OC_Helper::mimetypeIcon($i->getMimeType()));
         /* Note: relative URL should be enough (RFC7231) but some OPDS clients
          * (especially those in dedicated book readers) might not support them
          * 
          * header("Location: " . \OC_Helper::mimetypeIcon($i->getMimeType()));
          */
     }
 }
Exemplo n.º 9
0
 /**
  * A function that checks if we are using a page template.
  *
  * @param array $name Template properties.
  * @return boolean True: use of a template. False: no template.
  */
 function themosis_is_template(array $name = [])
 {
     $queriedObject = get_queried_object();
     if (is_a($queriedObject, 'WP_Post') && 'page' === $queriedObject->post_type) {
         // Sanitized value
         $template = Meta::get($queriedObject->ID, '_themosisPageTemplate');
         // If no template selected, just return;
         if ($template === 'none') {
             return false;
         }
         // If template...
         if (isset($template) && !empty($template)) {
             /*-----------------------------------------------------------------------*/
             // If the page template name is defined within the routes array, handle
             // the template
             /*-----------------------------------------------------------------------*/
             if (in_array($template, $name)) {
                 return true;
             }
         }
         return false;
     }
 }
Exemplo n.º 10
0
@include('header')

	@loop
		<!-- BOOK PROMO -->
		<div id="bks-promo" style="background-color: {{ Meta::get(Loop::id(), 'color') }};">
			<div class="wrapper">
				<div class="promo-wrapper">
					<div class="promo-container">
						<h1>{{ Loop::title() }}</h1>
						<h5>By {{ Meta::get(Loop::id(), 'author') }}</h5>
						<a href="#" class="big-button">Buy book</a>
					</div>
					<div class="promo-media">
						<?php 
$image = wp_get_attachment_image_src(Meta::get(Loop::id(), 'promo-image'), 'book-promo');
?>
						<img src="{{ $image[0] }}" alt="Demo Book" width="399" height="435">
					</div>
				</div>
			</div>
		</div>
		<!-- END BOOK PROMO -->
		<!-- BOOK CONTENT -->
		<div class="wrapper">
			<div id="book--container">
				<div class="bks-title-box">
					<h1>Content</h1>
				</div>
				<div id="book--content">
					{{ Loop::content() }}
				</div>
Exemplo n.º 11
0
 /**
  * Set source file.
  *
  * @param [[@doctodo param_type:sourceFile]] $sourceFile [[@doctodo param_description:sourceFile]]
  *
  * @return [[@doctodo return_type:setSourceFile]] [[@doctodo return_description:setSourceFile]]
  */
 public function setSourceFile($sourceFile)
 {
     $this->_meta = Meta::get($this->interface, $sourceFile);
     return $this;
 }
Exemplo n.º 12
0
 /**
  * Handle about page request.
  *
  * @param \WP_Post $post
  * @return mixed
  */
 public function about($post)
 {
     return View::make('pages.about', array('members' => Meta::get($post->ID, 'collaborators')));
 }