예제 #1
0
 private function showAdmin($type)
 {
     global $CONF, $DIR_LIBS, $DIR_MEDIA, $manager;
     $type = (string) $type;
     if (!class_exists('PLUGINADMIN', FALSE)) {
         include $DIR_LIBS . 'PLUGINADMIN.php';
     }
     $oPluginAdmin = new PluginAdmin('Thumbnail');
     $oPluginAdmin->start();
     echo "<h2>NP_Thumbnail</h2>\n";
     if ($this->getOption('save_thumb') === 'no') {
         echo '<p>' . $this->t(_NP_THUMBNAIL_14) . "</p>\n";
         $oPluginAdmin->end();
         return;
     }
     $logs = array();
     if ($type == 'clear') {
         if ($this->getOption('save_thumb') == 'filesystem') {
             $logs = MediaUtils::purgeDir($DIR_MEDIA, self::$thumbdir . '/');
         }
     }
     echo "<p>" . $this->t(_NP_THUMBNAIL_15, array(self::$thumbdir)) . "<br />\n";
     echo $this->t(_NP_THUMBNAIL_16, array(self::$max_sync)) . "<br />\n";
     echo $this->t(_NP_THUMBNAIL_17) . "</p>\n";
     if ($type == 'sync') {
         $maxwidth = $this->getOption('maxwidth');
         $maxheight = $this->getOption('maxheight');
         if ($this->getOption('save_thumb') == 'filesystem') {
             echo "<h3>" . $this->t(_NP_THUMBNAIL_22) . "</h3>\n";
             if (self::syncFilesystem($DIR_MEDIA, self::$thumbdir, $maxwidth, $maxheight)) {
                 echo "<p>何かのエラーメッセージ</p>\n";
             }
         }
     }
     $media = MediaUtils::getMediaList($DIR_MEDIA);
     $elected = array();
     $rejected = array();
     foreach ($media as $medium) {
         if (!array_key_exists($medium->mime, MediaUtils::$image_mime)) {
             continue;
         }
         if (file_exists($DIR_MEDIA . self::getThumbPath($medium))) {
             $rejected[] =& $medium;
             continue;
         } else {
             $elected[] =& $medium;
             continue;
         }
     }
     $total_media = count($media);
     $total_elected = count($elected);
     $total_rejected = count($rejected);
     $total_images = count($rejected) + $total_elected;
     /*
      * NOTICE: NP_Improvededia with eachblogdir option rewrite
      * global variables of "DIR_MEDIA" and "$CONF['MediaURL']"
      * in its initializing process.
      * (I realized it a bad behavior but there is no other way...)
      * Here are based on its rewriting system.
      *  (Apr. 06, 2011)
      */
     if ($manager->pluginInstalled('NP_ImprovedMedia')) {
         $NP_ImprovedMedia =& $manager->getPlugin('NP_ImprovedMedia');
         if ($NP_ImprovedMedia->getOption('IM_EACHBLOGDIR') == 'yes') {
             echo "<form method=\"post\" action=\"{$CONF['ActionURL']}?action=plugin&name=Thumbnail\" enctype=\"application/x-www-form-urlencoded\">\n";
             echo "<p>\n";
             echo "<label for=\"blogid\">" . $this->t(_NP_THUMBNAIL_18) . "</label>\n";
             echo "<select name=\"blogid\" id=\"blogid\"onchange=\"return form.submit()\">\n";
             foreach (MediaUtils::$blogs as $blogid => $bshortname) {
                 if ($blogid == MediaUtils::$blogid) {
                     echo "<option value=\"{$blogid}\" selected=\"selected\">{$bshortname}</option>\n";
                 } else {
                     echo "<option value=\"{$blogid}\">{$bshortname}</option>\n";
                 }
             }
             echo "</select>\n";
             echo "<input type=\"hidden\" id=\"admin\" name=\"type\" value=\"admin\">\n";
             echo "</p>\n";
             echo "</form>\n";
         }
     }
     echo "<form method=\"post\" action=\"{$CONF['ActionURL']}?action=plugin&name=Thumbnail\" enctype=\"application/x-www-form-urlencoded\">\n";
     echo "<ul>\n";
     echo "<li>" . $this->t(_NP_THUMBNAIL_19, array($total_media)) . "</li>\n";
     echo "<li>" . $this->t(_NP_THUMBNAIL_20, array($total_images)) . "</li>\n";
     echo "<li>" . $this->t(_NP_THUMBNAIL_21, array($total_rejected)) . "</li>\n";
     echo "</ul>\n";
     echo "<p>\n";
     echo '<input type="hidden" name="blogid" value="' . MediaUtils::$blogid . '">' . "\n";
     echo "<input type=\"submit\" name=\"type\" value=\"sync\">\n";
     echo "<input type=\"submit\" name=\"type\" value=\"clear\">\n";
     echo "</p>\n";
     if ($logs) {
         echo "<h3>" . $this->t(_NP_THUMBNAIL_22) . "</h3>\n";
         echo "<ul>\n";
         foreach ($logs as $log) {
             echo "<li>{$log}</li>\n";
         }
         echo "</ul>\n";
     }
     echo "</form>\n";
     $oPluginAdmin->end();
     return;
 }