// Just pointing to another video continue; } else { if (preg_match("@{{Curatevideo\\|(wonderhowto|videojug|youtube|howcast|5min)\\|([^\\|]+)\\|@", $body, $matches)) { // Check to see if the supported video providers videos are valid (ie video still exists). If not, add them to the unsupported list if (!isSupportedVideo($matches[1], $matches[2])) { $video['vid_id'] = $matches[2]; $video['vid_service'] = $matches[1]; $unsupported[] = $video; printVideo($video); removeVideo($video); } } else { $video['vid_service'] = "UNKNOWN"; $unsupported[] = $video; printVideo($video); removeVideo($video); } } } else { error("oops. couldn't load page_id {$page}\n"); } } #var_dump($unsupported); echo "\n\n\nTotal videos to remove: " . sizeof($unsupported) . "\n"; function removeVideo(&$video) { if (!removeVideosFromLinkedArticles($video)) { return; } if (!removeVideoPage($video)) {
function printPreviewBlogPosts($fields, $evidenza, $numPost, $offset) { //controllo l'articolo in evidenza $firstElement = $evidenza; /** foreach($fields as $item){ $categories = get_the_category($item->ID); foreach($categories as $category){ if($category->name == 'evidenza'){ $firstElement = $item; } } } **/ if ($firstElement != null) { $newArray = array(); //metto l'elemento in evidenza in testa array_push($newArray, $firstElement); //aggiungo gli altri saltando quello in evidenza $counter = 0; foreach ($fields as $item) { if ($counter == $numPost) { break; } if ($item->ID != $firstElement->ID) { array_push($newArray, $item); } $counter++; } $fields = $newArray; } //prendo i video //VIDEO //Ottengo i valori relativi ai campi di descrizione $args = array('post_type' => 'baa_videos', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'video_type', 'field' => 'slug', 'terms' => 'blog-detail'))); $fieldsVideo = get_posts($args); $videos = array(); foreach ($fieldsVideo as $field) { $video = array(); $video['titolo'] = $field->post_title; $video['descrizione'] = $field->post_content; //$video['image'] = wp_get_attachment_url( get_post_thumbnail_id($field->ID)); //ridimensiono il video $videoHTML = get_the_post_thumbnail($field->ID, array(400, 235)); $temp = new DOMDocument(); $temp->loadHTML($videoHTML); $xpath = new DOMXPath($temp); $video['image'] = $xpath->evaluate("string(//img/@src)"); # "/images/image.jpg" $embed_video = explode('watch?v=', get_post_meta($field->ID, 'video', true)); $idVideo = $embed_video[count($embed_video) - 1]; $video['url'] = $idVideo; array_push($videos, $video); } $path_img = esc_url(get_template_directory_uri()) . '/images/'; $startDivTag = false; $count_post = 0; foreach ($fields as $item) { if ($count_post == 0) { ?> <div class="row" > <div class="show-video video hidden-xs hidden-sm col-md-3"> <?php if (count($videos) > 0) { ?> <ul class="videos-container col-xs-12"> <?php $count = 0; foreach ($videos as $video) { if ($count < 3) { printVideo($video); } else { break; } $count++; } ?> <li class="clear"></li> </ul> <?php } ?> </div> <div class="col-xs-12 col-md-6 first-post"> <?php printPreviewBlogPost($item); ?> </div> <div class="show-video video hidden-xs hidden-sm col-md-3"> <?php if (count($videos) > 0) { ?> <ul class="videos-container col-xs-12"> <?php $count = 0; foreach ($videos as $video) { if ($count >= 3) { printVideo($video); } $count++; } ?> <li class="clear"></li> </ul> <?php } ?> </div> </div> <?php } else { if ($count_post > 0 && $startDivTag == false) { ?> <div class="container-blog-posts col-xs-12 row" > <?php $startDivTag = true; } if ($count_post % 2 != 0) { ?> <div class="row"> <?php } ?> <div class="col-xs-12 col-md-6 not-first-post"> <?php printPreviewBlogPost($item); ?> </div> <?php if ($count_post % 2 == 0 || $count_post == count($fields) - 1) { //chiudo il div se il post è divisibile per due oppure è l'ultimo ?> </div> <?php } if ($count_post == count($fields) - 1) { ?> <div id="more-results"></div> <div class="more-results-search"> <input type="hidden" name="number-current-posts" value="<?php echo $offset; ?> " autocomplete="off" /> <a id="more-post">Show more</a> </div> </div> <?php } } $count_post++; } }
<?php require_once 'commandLine.inc'; require_once "{$IP}/extensions/wikihow/DatabaseHelper.class.php"; $dbr = wfGetDB(DB_SLAVE); $articles = DatabaseHelper::batchSelect('page', array('page_id', 'page_title'), array('page_namespace' => NS_VIDEO, 'page_is_redirect' => 0)); foreach ($articles as $row) { $r = Revision::loadFromPageId($dbr, $row->page_id); if ($r) { $wikitext = $r->getText(); if (preg_match("@{{Curatevideo\\|howcast\\|([^\\|]+)\\|([^\\|]+)@", $wikitext, $matches)) { printVideo($matches[1], $matches[2], $r->getTitle()); } } } function printVideo($vidId, &$vidTitle, &$t) { $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('templatelinks', array('tl_from'), array('tl_namespace' => NS_VIDEO, 'tl_title' => $t->getDBKey()), __METHOD__, array('LIMIT 1')); if ($row = $dbr->fetchObject($res)) { $nt = Title::newFromId($row->tl_from); if ($nt && $nt->exists()) { $day30 = Pagestats::get30day($row->tl_from, $dbr); echo "{$vidId}\t{$vidTitle}\thttp://www.wikihow.com" . $nt->getLocalUrl() . "\t{$day30}\n"; } } }