User:J*

From FollowTheScore
Jump to: navigation, search

imagecontainer

DynamicPageList2.php.bak was DPL version 1.7.3

--- DynamicPageList2.php.bak	2008-05-04 22:13:08.000000000 +0200
+++ DynamicPageList2.php	2008-05-05 09:28:12.000000000 +0200
@@ -534,6 +534,11 @@
          */
         'imageused'              => array('default' => ''),
         /**
+	 * this parameter restricts the output to images which are used (contained) by one of the specified pages.
+	 * Examples:   imagecontainer=my article|your article
+	 */
+	 'imagecontainer'	 => array('default' => ''),
+        /**
          * this parameter restricts the output to articles which use the specified template.
          * Examples:   uses=Template:my template
          */
@@ -1256,6 +1261,8 @@
     
         $aImageUsed = array();
 
+        $aImageContainer = array();
+
         $aUses       = array();
         $aNotUses    = array();
         
@@ -1520,6 +1527,19 @@
                     $bConflictsWithOpenReferences=true;
                     break;
 
+		case 'imagecontainer':
+		    $pages = explode('|', trim($sArg));
+		    $n=0;
+                    foreach($pages as $page) {
+                        if (trim($page)=='') continue;
+                        if (!($theTitle = Title::newFromText(trim($page)))) return $logger->msgWrongParam('imageused', $sArg);
+                        $aImageContainer[$n++] = $theTitle;
+                        $bSelectionCriteriaFound=true;
+                    }
+                    if(!$bSelectionCriteriaFound) return $logger->msgWrongParam('imageUsed', $sArg);
+                    //$bConflictsWithOpenReferences=true;
+                    break;
+
                 case 'uses':
                     $pages = explode('|', $sArg);
                     $n=0;
@@ -2544,6 +2564,21 @@
             $sSqlCond_page_pl .= ')';
         }
 
+	// imagecontainer
+	if ( count($aImageContainer)>0 ) {
+            $sSqlPageLinksTable .= $sImageLinksTable . ' as ic, ';
+            $sSqlCond_page_pl .= ' AND '.$sPageTable.'.page_namespace=\'6\' AND '.$sPageTable.'.page_title=ic.il_to AND (';
+            $n=0;
+            foreach ($aImageContainer as $link) {
+                if ($n>0) $sSqlCond_page_pl .= ' OR ';
+                if ($bIgnoreCase)       $sSqlCond_page_pl .= "UPPER(ic.il_from)=UPPER(" . $dbr->addQuotes( $link->getArticleID() ).')';
+                else                            $sSqlCond_page_pl .= "ic.il_from=" . $dbr->addQuotes( $link->getArticleID() );
+                $n++;
+            }
+            $sSqlCond_page_pl .= ')';
+        }
+
+
         // uses
         if ( count($aUses)>0 ) {
             $sSqlPageLinksTable .= ' '.$sTemplateLinksTable . ' as tl, ';