*
* @license http://nucleuscms.org/license.txt GNU General Public License
* @copyright Copyright (C) 2002-2012 The Nucleus Group
- * @version $Id: ACTIONS.php 1757 2012-04-15 09:02:32Z sakamocchi $
+ * @version $Id: ACTIONS.php 1784 2012-04-22 04:28:30Z sakamocchi $
*/
class Actions extends BaseActions
* Actions::$skin_type_friendly_names
* friendly name for wrapped page types
*/
- static public $skin_type_friendly_names = array(
+ static public $default_skin_types = array(
'index' => _SKIN_PART_MAIN,
'item' => _SKIN_PART_ITEM,
'archivelist' => _SKIN_PART_ALIST,
}
/**
- * Actions::getSkinTypeFriendlyNames()
+ * Actions::getDefaultSkinTypes()
*
* @static
* @param void
* @return array list of friendly names for page actions
*/
- static public function getSkinTypeFriendlyNames()
+ static public function getDefaultSkinTypes()
{
- return self::$skin_type_friendly_names;
+ return self::$default_skin_types;
}
/**
// call constructor of superclass first
parent::__construct();
-
$this->skintype = $type;
if ( $catid )
$member->isAdmin() or $this->disallow();
$skin = new SKIN($skinid);
- $friendlyNames = $skin->getFriendlyNames();
+ $default_skin_types = $skin->getDefaultTypes();
+ $available_skin_types = $skin->getAvailableTypes();
$this->pagehead();
echo "<ul>\n";
$tabindex = 10;
- $types = array();
- foreach ( $friendlyNames as $type => $friendly_name )
+ foreach ( $default_skin_types as $type => $friendly_name )
{
echo "<li>\n";
echo "<a tabindex=\"{$tabindex}\" href=\"index.php?action=skinedittype&skinid={$skinid}&type={$type}\">";
}
echo "</ul>\n";
- $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') and sdesc=%d;";
- $query = sprintf($query, sql_table('skin'), implode("', '", array_keys($friendlyNames)) , $skinid);
- $res = sql_query($query);
-
echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
echo "<form method=\"get\" action=\"index.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"skinedittype\" />\n";
echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . "\" onclick=\"return checkSubmit();\" />\n";
echo "</form>\n";
- if ( $res && sql_num_rows($res) > 0 )
+ /* NOTE: special skin parts has FALSE in its value */
+ if ( in_array(FALSE, array_values($available_skin_types)) )
{
$tabstart = 75;
echo '<ul>';
- while ( $row = sql_fetch_assoc($res) )
+ foreach ( $available_skin_types as $type => $friendly_name )
{
- $tabstart++;
- echo "<li>\n";
- echo "<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinedittype&skinid={$skinid}&type=" . Entity::hsc(strtolower($row['stype'])) . "\">";
- echo Entity::hsc(ucfirst($row['stype']));
- echo "</a>\n";
- $tabstart++;
- echo "(<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinremovetype&skinid={$skinid}&type=" . Entity::hsc(strtolower($row['stype'])) . "\">";
- echo _LISTS_DELETE;
- echo "</a>)\n";
- echo "</li>\n";
+ if ( !$friendly_name )
+ {
+ $tabstart++;
+ echo "<li>\n";
+ echo "<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinedittype&skinid={$skinid}&type=" . Entity::hsc(strtolower($type)) . '">';
+ echo Entity::hsc(ucfirst($type));
+ echo "</a>\n";
+ $tabstart++;
+ echo "(<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinremovetype&skinid={$skinid}&type=" . Entity::hsc(strtolower($type)) . '">';
+ echo _LISTS_DELETE;
+ echo "</a>)\n";
+ echo "</li>\n";
+ }
}
echo '</ul>';
}
}
$skin = new SKIN($skinid);
- $friendlyNames = $skin->getFriendlyNames();
- if ( !array_key_exists($type, $friendlyNames) || !isset($friendlyNames[$type]) )
+ $skin_types = $skin->getAvailableTypes();
+ if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
{
$friendlyName = ucfirst($type);
}
else
{
- $friendlyName = $friendlyNames[$type];
+ $friendlyName = $skin_types[$type];
}
$this->pagehead();
echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
- if ( !in_array($type, array_keys($friendlyNames)) )
+ if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
{
help('skinpartspecial');
}
sort($actions);
- while ($current = array_shift($actions))
+ while ( $current = array_shift($actions) )
{
// skip deprecated vars
if ( in_array($current, array('ifcat', 'imagetext', 'vars')) )
// don't allow default skinparts to be deleted
$skin = new Skin($skinid);
- $friendlyNames = $skin->getFriendlyNames();
- if ( in_array($skintype, array_keys($friendlyNames)) )
+ $default_skin_types = $skin->getDefaultTypes();
+ if ( array_key_exists($skintype, $default_skin_types) )
{
$this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
}
// don't allow default skinparts to be deleted
$skin = new Skin($skinid);
- $friendlyNames = $skin->getFriendlyNames();
- if ( in_array($skintype, array_keys($friendlyNames)) )
+ $default_skin_types = $skin->getDefaultTypes();
+ if ( array_key_exists($skintype, $default_skin_types) )
{
$this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
}
*
* @license http://nucleuscms.org/license.txt GNU General Public License
* @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: SKIN.php 1779 2012-04-21 10:04:33Z sakamocchi $
+ * @version $Id: SKIN.php 1784 2012-04-22 04:28:30Z sakamocchi $
*/
if ( !function_exists('requestVar') )
}
/**
- * Skin::getAllowedActionsForType()
- * Get the allowed actions for a skin type
- * returns an array with the allowed actions
+ * Skin::getDefaultTypes()
*
- * @param string $type type of the skin (e.g. index, item, search ...)
- * @return array allowed action types
+ * @param string void
+ * @return array default skin types
*/
- public function getAllowedActionsForType($type)
+ public function getDefaultTypes()
{
- return call_user_func(array($this->action_class, 'getDefinedActions'), $type);
+ return call_user_func(array($this->action_class, 'getDefaultSkinTypes'));
}
/**
- * Skin::getFriendlyNames()
- * Get an array with the names of possible skin parts
- * Used to show all possible parts of a skin in the administration backend
+ * Skin::getAvailableTypes()
*
* @param string void
- * @return array type of the skin
+ * @return array registered skin types
+ */
+ public function getAvailableTypes()
+ {
+ $default_skintypes = $this->getDefaultTypes();
+ $query = "SELECT stype FROM %s WHERE sdesc=%d;";
+ $query = sprintf($query, sql_table('skin'), (integer) $this->id);
+
+ /* NOTE: force to put default types in the beginning */
+ $in_default = array();
+ $no_default = array();
+
+ $res = sql_query($query);
+ while ( $row = sql_fetch_array($res) )
+ {
+ if ( !array_key_exists($row['stype'], $default_skintypes) )
+ {
+ $no_default[$row['stype']] = FALSE;
+ }
+ else
+ {
+ $in_default[$row['stype']] = $default_skintypes[$row['stype']];
+ }
+ }
+
+ return array_merge($in_default, $no_default);
+ }
+
+ /**
+ * Skin::getAllowedActionsForType()
+ * Get the allowed actions for a skin type
+ * returns an array with the allowed actions
+ *
+ * @param string $type type of the skin
+ * @return array allowed action types
*/
- public function getFriendlyNames()
+ public function getAllowedActionsForType($type)
{
- return call_user_func(array($this->action_class, 'getSkinTypeFriendlyNames'));
+ return call_user_func(array($this->action_class, 'getDefinedActions'), $type);
}
+
}
*
* @license http://nucleuscms.org/license.txt GNU General Public License
* @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: showlist.php 1755 2012-04-14 10:05:49Z sakamocchi $
+ * @version $Id: showlist.php 1784 2012-04-22 04:28:30Z sakamocchi $
*/
echo "<td>\n";
echo '<p>' . Entity::hsc($current->sddesc) . "</p>\n";
- /* 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);
- }
-
/* make list of defined skins */
$skin = new Skin($current->sdnumber);
- $friendlyNames = $skin->getFriendlyNames();
+ $available_skin_types = $skin->getAvailableTypes();
echo _LIST_SKINS_DEFINED;
echo "<ul>\n";
- foreach ( $types as $type )
+ foreach ( $available_skin_types as $type => $friendlyName )
{
- if ( !array_key_exists($type, $friendlyNames) )
+ if ( $friendlyName === FALSE )
{
$friendlyName = ucfirst($type);
$article = 'skinpartspecial';
}
else
{
- $friendlyName = $friendlyNames[$type];
$article = "skinpart{$type}";
}
echo "<li>\n";