OSDN Git Service

MERGE: リビジョン1778/1779のマージ。Skin::getFriendlyNames()のアクセス方法の変更
authorsakamocchi <o-takashi@sakamocchi.jp>
Sat, 21 Apr 2012 10:07:03 +0000 (19:07 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sat, 21 Apr 2012 10:07:03 +0000 (19:07 +0900)
Skin::getFriendlyNames()をインスタンス経由でアクセスするように変更。

関連して以下を修正した。
listplug_table_skinlist() in showlist.php
Admin::action_skinoverview()
Admin::action_skinedit()
Admin::action_skinedittype()
Admin::action_skinremovetype()
Admin::action_skinremovetypeconfirm()

nucleus/libs/ADMIN.php
nucleus/libs/SKIN.php
nucleus/libs/showlist.php

index 2fe1145..faaa1b1 100644 (file)
@@ -4263,7 +4263,7 @@ selector();
 
         $this->action_templateoverview();
     }
-
+       
        /**
         * Admin::action_skinoverview()
         * 
@@ -4285,7 +4285,7 @@ selector();
                $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname;';
                $template['content'] = 'skinlist';
                $template['tabindex'] = 10;
-               $template['friendly_names'] = Skin::getFriendlyNames('Actions');
+               
                showlist($query,'table',$template);
                
                echo '<h3>' . _SKIN_NEW_TITLE . "</h3>\n";
@@ -4318,7 +4318,7 @@ selector();
                $this->pagefoot();
                return;
        }
-
+       
     /**
      * @todo document this
      */
@@ -4355,20 +4355,10 @@ selector();
                $member->isAdmin() or $this->disallow();
                
                $skin = new SKIN($skinid);
+               $friendlyNames = $skin->getFriendlyNames();
                
                $this->pagehead();
                
-               $skin_default_types = array(
-                       'index'                 => _SKIN_PART_MAIN,
-                       'item'                  => _SKIN_PART_ITEM,
-                       'archivelist'   => _SKIN_PART_ALIST,
-                       'archive'               => _SKIN_PART_ARCHIVE,
-                       'search'                => _SKIN_PART_SEARCH,
-                       'error'                 => _SKIN_PART_ERROR,
-                       'member'                => _SKIN_PART_MEMBER,
-                       'imagepopup'    => _SKIN_PART_POPUP
-               );
-               
                echo "<p>";
                echo '( <a href="index.php?action=skinoverview">' . _SKIN_BACK . "</a> )";
                echo "</p>\n";
@@ -4380,7 +4370,7 @@ selector();
                
                $tabindex = 10;
                $types = array();
-               foreach ( $skin_default_types as $type => $friendly_name )
+               foreach ( $friendlyNames as $type => $friendly_name )
                {
                        echo "<li>\n";
                        echo "<a tabindex=\"{$tabindex}\" href=\"index.php?action=skinedittype&amp;skinid={$skinid}&amp;type={$type}\">";
@@ -4389,12 +4379,11 @@ selector();
                        help("skinpart{$type}");
                        echo "</li>\n";
                        $tabindex++;
-                       $types[] = $type;
                }
                echo "</ul>\n";
                
                $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') and sdesc=%d;";
-               $query = sprintf($query, sql_table('skin'), implode("', '", $types) , $skinid);
+               $query = sprintf($query, sql_table('skin'), implode("', '", array_keys($friendlyNames)) , $skinid);
                $res = sql_query($query);
                
                echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
@@ -4536,7 +4525,7 @@ selector();
                }
                
                $skin = new SKIN($skinid);
-               $friendlyNames = Skin::getFriendlyNames();
+               $friendlyNames = $skin->getFriendlyNames();
                if ( !array_key_exists($type, $friendlyNames) || !isset($friendlyNames[$type]) )
                {
                        $friendlyName = ucfirst($type);
@@ -4569,7 +4558,7 @@ selector();
                echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
                echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
                
-               if ( !in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup')) )
+               if ( !in_array($type, array_keys($friendlyNames)) )
                {
                        help('skinpartspecial');
                }
@@ -4726,81 +4715,110 @@ selector();
 
         $this->action_skinoverview();
     }
-
-    /**
-     * @todo document this
-     */
-    function action_skinremovetype() {
-        global $member, $manager, $CONF;
-
-        $skinid = intRequestVar('skinid');
-        $skintype = requestVar('type');
-
-        if (!isValidShortName($skintype)) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $member->isAdmin() or $this->disallow();
-
-        // don't allow default skinparts to be deleted
-        if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $this->pagehead();
-
-        $skin = new SKIN($skinid);
-        $name = $skin->getName();
-        $desc = $skin->getDescription();
-
-        ?>
-            <h2><?php echo _DELETE_CONFIRM?></h2>
-
-            <p>
-                <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo Entity::hsc($skintype); ?> (<?php echo Entity::hsc($name); ?>)</b> (<?php echo  Entity::hsc($desc)?>)
-            </p>
-
-            <form method="post" action="index.php"><div>
-                <input type="hidden" name="action" value="skinremovetypeconfirm" />
-                <?php $manager->addTicketHidden() ?>
-                <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
-                <input type="hidden" name="type" value="<?php echo Entity::hsc($skintype); ?>" />
-                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-            </div></form>
-        <?php
-        $this->pagefoot();
-    }
-
-    /**
-     * @todo document this
-     */
-    function action_skinremovetypeconfirm() {
-        global $member, $CONF, $manager;
-
-        $skinid = intRequestVar('skinid');
-        $skintype = requestVar('type');
-
-        if (!isValidShortName($skintype)) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $member->isAdmin() or $this->disallow();
-
-        // don't allow default skinparts to be deleted
-        if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-        }
-
-        $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-        // delete part
-        sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
-
-        $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-        $this->action_skinedit();
-    }
-
+       
+       /**
+        * Admin::action_skinremovetype()
+        *
+        * @param       void
+        * @return      void
+        */
+       public function action_skinremovetype()
+       {
+               global $member, $manager, $CONF;
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
+               
+               if ( !isValidShortName($skintype) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $member->isAdmin() or $this->disallow();
+               
+               // don't allow default skinparts to be deleted
+               $skin = new Skin($skinid);
+               $friendlyNames = $skin->getFriendlyNames();
+               if ( in_array($skintype, array_keys($friendlyNames)) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $name = $skin->getName();
+               $desc = $skin->getDescription();
+               
+               $this->pagehead();
+               
+               echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
+               echo "<p>\n";
+               echo _CONFIRMTXT_SKIN_PARTS_SPECIAL;
+               echo Entity::hsc($skintype);
+               echo  '(' . Entity::hsc($name) . ')</b>';
+               echo ' (' . Entity::hsc($desc) . ')';
+               echo "</p>\n";
+               
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               echo "<input type=\"hidden\" name=\"action\" value=\"skinremovetypeconfirm\" />\n";
+               $manager->addTicketHidden();
+               echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
+               echo '<input type="hidden" name="type" value="' . Entity::hsc($skintype) . '" />' . "\n";
+               echo '<input type="submit" tabindex="10" value="' . _DELETE_CONFIRM_BTN . '" />' . "\n";
+               echo "</div>\n";
+               echo "</form>\n";
+               $this->pagefoot();
+               return;
+       }
+       
+       /**
+        * Admin::action_skinremovetypeconfirm()
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function action_skinremovetypeconfirm()
+       {
+               global $member, $CONF, $manager;
+               
+               $skinid = intRequestVar('skinid');
+               $skintype = requestVar('type');
+               
+               if ( !isValidShortName($skintype) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $member->isAdmin() or $this->disallow();
+               
+               // don't allow default skinparts to be deleted
+               $skin = new Skin($skinid);
+               $friendlyNames = $skin->getFriendlyNames();
+               if ( in_array($skintype, array_keys($friendlyNames)) )
+               {
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+               }
+               
+               $data = array(
+                       'skinid'        => $skinid,
+                       'skintype'      => $skintype
+               );
+               $manager->notify('PreDeleteSkinPart', $data);
+               
+               // delete part
+               $query = "DELETE FROM %s WHERE sdesc=%d AND stype='%s';";
+               $query = sprintf($query, sql_table('skin'), (integer) $skinid, $skintype);
+               sql_query($query);
+               
+               $data = array(
+                       'skinid'        => $skinid,
+                       'skintype'      => $skintype
+               );
+               $manager->notify('PostDeleteSkinPart', $data);
+               
+               $this->action_skinedit();
+               return;
+       }
+       
     /**
      * @todo document this
      */
@@ -4832,20 +4850,7 @@ selector();
             $skin->getIncludeMode(),
             $skin->getIncludePrefix()
         );
-
-
-        // 3. clone
-        /*
-        $this->skinclonetype($skin, $newid, 'index');
-        $this->skinclonetype($skin, $newid, 'item');
-        $this->skinclonetype($skin, $newid, 'archivelist');
-        $this->skinclonetype($skin, $newid, 'archive');
-        $this->skinclonetype($skin, $newid, 'search');
-        $this->skinclonetype($skin, $newid, 'error');
-        $this->skinclonetype($skin, $newid, 'member');
-        $this->skinclonetype($skin, $newid, 'imagepopup');
-        */
-
+        
         $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
         $res = sql_query($query);
         while ($row = sql_fetch_assoc($res)) {
index 9bcc04d..08afb7f 100644 (file)
@@ -14,7 +14,7 @@
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: SKIN.php 1755 2012-04-14 10:05:49Z sakamocchi $
+ * @version $Id: SKIN.php 1779 2012-04-21 10:04:33Z sakamocchi $
  */
 
 if ( !function_exists('requestVar') ) 
@@ -594,52 +594,13 @@ class Skin
         * @param       string  $action_class   name of action class (optional)
         * @param       array   type of the skin
         */
-       static public function getFriendlyNames($action_class='Actions')
+       public function getFriendlyNames($action_class='Actions')
        {
-               global $DIR_LIBS;
-               
-               /*
-                * NOTE: include needed action class
-                */
-               if ( $action_class != 'Actions' )
-               {
-                       if ( !class_exists($action_class, FALSE)
-                         && (!file_exists("{$DIR_LIBS}{$action_class}.php")
-                          || !include("{$DIR_LIBS}{$action_class}.php")) )
-                       {
-                               return;
-                       }
-               }
-               else
-               {
-                       if ( !class_exists('Actions', FALSE)
-                         && (!file_exists("{$DIR_LIBS}ACTIONS.php")
-                          || !include("{$DIR_LIBS}ACTIONS.php")) )
-                       {
-                               return;
-                       }
-               }
-               
                /**
                 * NOTE: static method with variable class name is supported since PHP 5.3
                 *  So now we utilize eval function.
                 */
                eval("\$friendly_names = {$action_class}::getSkinTypeFriendlyNames();");
-               
-               $action_names = array();
-               foreach ( $friendly_names as $action_name => $friendly_name )
-               {
-                       $action_names[] = $action_name;
-               }
-               
-               $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s');";
-               $query = sprintf($query, sql_table('skin'), implode("','", $action_names));
-               $res = sql_query($query);
-               
-               while ( $row = sql_fetch_array($res) )
-               {
-                       $friendly_names[strtolower($row['stype'])] = $row['stype'];
-               }
                return $friendly_names;
        }
 }
index dd40f7e..b87494b 100644 (file)
@@ -825,39 +825,43 @@ function listplug_table_skinlist($template, $type)
                        echo "<td>\n";
                        echo '<p>' . Entity::hsc($current->sddesc) . "</p>\n";
                        
-                       /* show list of defined parts */
+                       /* make list of registered skins */
                        $query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype";
                        $query = sprintf($query, sql_table('skin'), $current->sdnumber);
                        $r = sql_query($query);
-                       
                        $types = array();
                        while ( $o = sql_fetch_object($r) )
                        {
                                array_push($types, $o->stype);
                        }
-                       if ( sizeof($types) > 0 )
+                       
+                       /* make list of defined skins */
+                       $skin = new Skin($current->sdnumber);
+                       $friendlyNames = $skin->getFriendlyNames();
+                       
+                       echo _LIST_SKINS_DEFINED;
+                       echo "<ul>\n";
+                       foreach ( $types as $type )
                        {
-                               for ( $i = 0; $i < sizeof($types); $i++ )
+                               if ( !array_key_exists($type, $friendlyNames) )
                                {
-                                       $type = $types[$i];
-                                       if ( !array_key_exists($type, $template['friendly_names']) || $type == strtolower($template['friendly_names'][$type]) )
-                                       {
-                                               $article = 'skinpartspecial';
-                                       }
-                                       else
-                                       {
-                                               $article = "skinpart{$type}";
-                                       }
-                                       $types[$i]  = "<li>\n"
-                                                   . helpHtml($article) . "\n"
-                                                   . "<a href=\"index.php?action=skinedittype&amp;skinid={$current->sdnumber}&amp;type={$type}\" tabindex=\"{$template['tabindex']}\">"
-                                                   . Entity::hsc($template['friendly_names'][$type])
-                                                   . "</a>\n"
-                                                   . "</li>\n";
+                                       $friendlyName = ucfirst($type);
+                                       $article = 'skinpartspecial';
+                               }
+                               else
+                               {
+                                       $friendlyName = $friendlyNames[$type];
+                                       $article = "skinpart{$type}";
                                }
-                               echo _LIST_SKINS_DEFINED;
-                               echo '<ul>' . implode('', $types) . "</ul>\n";
+                               echo "<li>\n";
+                               echo helpHtml($article) . "\n";
+                               echo "<a href=\"index.php?action=skinedittype&amp;skinid={$current->sdnumber}&amp;type={$type}\" tabindex=\"{$template['tabindex']}\">";
+                               echo Entity::hsc($friendlyName);
+                               echo "</a>\n";
+                               echo "</li>\n";
                        }
+                       echo "</ul>\n";
+                       
                        echo "</td>";
                        echo "<td>\n";
                        echo "<a href=\nindex.php?action=skinedit&amp;skinid={$current->sdnumber}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "</a>\n";