function initSmoothGalleryPF($parser) { global $wgSmoothGalleryDelimiter; $numargs = func_num_args(); if ($numargs < 2) { $input = "#SmoothGallery: no arguments specified"; return str_replace('§', '<', '§pre>§nowiki>' . $input . '§/nowiki>§/pre>'); } // fetch all user-provided arguments (skipping $parser) $input = ""; $argv = array(); $arg_list = func_get_args(); for ($i = 1; $i < $numargs; $i++) { $p1 = $arg_list[$i]; $aParam = explode('=', $p1, 2); if (count($aParam) < 2) { continue; } SmoothGallery::debug('sgallery tag parameter: ', $aParam); if ($aParam[0] == "imagelist") { $input = $aParam[1]; continue; } $sKey = trim($aParam[0]); $sVal = trim($aParam[1]); if ($sKey != '') { $argv[$sKey] = $sVal; } } $output = initSmoothGallery($input, $argv, $parser); return array($output, 'noparse' => true, 'isHTML' => true); }
function parseGallery( $input, $parser ) { global $wgSmoothGalleryDelimiter; global $wgSmoothGalleryAllowExternal; $galleryArray = Array(); // Expand templates in the input $input = $parser->recursiveTagParse( $input ); // The image array is a delimited list of images (strings) $line_arr = preg_split( "/$wgSmoothGalleryDelimiter/", $input, -1, PREG_SPLIT_NO_EMPTY ); foreach ( $line_arr as $line ) { $img_arr = explode( "|", $line, 2 ); $img = $img_arr[0]; if ( count( $img_arr ) > 1 ) { SmoothGallery::debug( 'sgallery line has description: ' . $img_arr[1] ); $img_desc = $img_arr[1]; } else { $img_desc = ''; } SmoothGallery::debug( 'sgallery line as img_arr: ', $img_arr ); if ( $wgSmoothGalleryAllowExternal && ( ( strlen( $img ) >= 7 && substr( $img, 0, 7 ) == "http://" ) || ( strlen( $img ) >= 7 && substr( $img, 0, 8 ) == "https://" ) ) ) { $imageArray["title"] = null; // TODO: internationalize $imageArray["heading"] = "External Image"; $imageArray["description"] = $img_desc; $imageArray["full_url"] = $img; $imageArray["view_url"] = $img; $imageArray["full_thumb_url"] = $img; $imageArray["icon_thumb_url"] = $img; $imageArray["image_object"] = null; $imageArray["external"] = true; $galleryArray["images"][] = $imageArray; continue; } $title = Title::newFromText( $img, NS_IMAGE ); if ( is_null( $title ) ) { $galleryArray["missing_images"][] = $title; continue; } $ns = $title->getNamespace(); if ( $ns == NS_IMAGE ) { $galleryArray = $this->parseImage( $title, $parser, $galleryArray, $img_desc ); } elseif ( $ns == NS_CATEGORY ) { // list images in category $cat_images = $this->smoothGalleryImagesByCat( $title ); if ( $cat_images ) { foreach ( $cat_images as $title ) { $galleryArray = $this->parseImage( $title, $parser, $galleryArray, '' ); } } } } return $galleryArray; }