OSDN Git Service

Merge branch 'skinnable-master'
[nucleus-jp/nucleus-next.git] / nucleus / libs / ACTIONS.php
index f066466..db41cfc 100644 (file)
  * This class contains the functions that get called by using
  * the special tags in the skins
  *
- * The allowed tags for a type of skinpart are defined by the
- * Skin::getAllowedActionsForType($type) method
- *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2012 The Nucleus Group
- * @version $Id: ACTIONS.php 1784 2012-04-22 04:28:30Z sakamocchi $
+<<<<<<< HEAD
+ * @version $Id: ACTIONS.php 1863 2012-05-19 10:50:27Z sakamocchi $
+=======
+ * @version $Id: ACTIONS.php 1886 2012-06-17 08:27:27Z sakamocchi $
+>>>>>>> skinnable-master
  */
 
 class Actions extends BaseActions
@@ -31,9 +32,6 @@ class Actions extends BaseActions
        // generating links to items/archives/... (e.g. catid)
        private $linkparams;
        
-       // reference to the skin object for which a part is being parsed
-       private $skin;
-       
        // used when including templated forms from the include/ dir. The $formdata var
        // contains the values to fill out in there (assoc array name -> value)
        private $formdata;
@@ -53,7 +51,6 @@ class Actions extends BaseActions
                'archivelink',
                'bloglist',
                'category',
-               'charset',
                'loginform',
                'member',
                'nucleusbutton',
@@ -76,10 +73,17 @@ class Actions extends BaseActions
        );
        
        /**
+<<<<<<< HEAD
         * Actions::$skin_type_friendly_names
         * friendly name for wrapped page types
         */
        static public $default_skin_types = array(
+=======
+        * Actions::$normal_skin_types
+        * friendly name for wrapped page types
+        */
+       static public $normal_skin_types = array(
+>>>>>>> skinnable-master
                'index'                 => _SKIN_PART_MAIN,
                'item'                  => _SKIN_PART_ITEM,
                'archivelist'   => _SKIN_PART_ALIST,
@@ -91,17 +95,60 @@ class Actions extends BaseActions
        );
        
        /**
-        * Actions::getDefinedActions()
+<<<<<<< HEAD
+        * Actions::getAvailableSkinTypes()
+=======
+        * Actions::getNormalSkinTypes()
+>>>>>>> skinnable-master
         * 
         * @static
-        * @param       string  $type   page type
+        * @param       void
+        * @return      array   list of friendly names for page actions
+        */
+<<<<<<< HEAD
+       static public function getAvailableSkinTypes()
+       {
+               return self::$default_skin_types;
+=======
+       static public function getNormalSkinTypes()
+       {
+               return self::$normal_skin_types;
+>>>>>>> skinnable-master
+       }
+       
+       /**
+        * Actions::__construct()
+        * Constructor for a new Actions object
+        * 
+        * @param       string  $type
+        * @return      void
+        */
+       public function __construct($type)
+       {
+               global $catid;
+               
+               // call constructor of superclass first
+               parent::__construct();
+               $this->skintype = $type;
+               
+               if ( $catid )
+               {
+                       $this->linkparams = array('catid' => $catid);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::getAvailableActions()
+        * 
+        * @param       void
         * @return      array   allowed actions for the page type
         */
-       static public function getDefinedActions($type='')
+       public function getAvailableActions()
        {
                $extra_actions = array();
                
-               switch ( $type )
+               switch ( $this->skintype )
                {
                        case 'index':
                                $extra_actions = array(
@@ -226,66 +273,7 @@ class Actions extends BaseActions
                
                $defined_actions = array_merge(self::$default_actions, $extra_actions);
                
-               return array_merge($defined_actions, parent::getDefinedActions());
-       }
-       
-       /**
-        * Actions::getDefaultSkinTypes()
-        * 
-        * @static
-        * @param       void
-        * @return      array   list of friendly names for page actions
-        */
-       static public function getDefaultSkinTypes()
-       {
-               return self::$default_skin_types;
-       }
-       
-       /**
-        * Actions::__construct()
-        * Constructor for a new Actions object
-        * 
-        * @param       string  $type
-        * @return      void
-        */
-       public function __construct($type)
-       {
-               global $catid;
-               
-               // call constructor of superclass first
-               parent::__construct();
-               $this->skintype = $type;
-               
-               if ( $catid )
-               {
-                       $this->linkparams = array('catid' => $catid);
-               }
-               return;
-       }
-       
-       /**
-        * Actions::setSkin()
-        * Set the skin
-        * @param       object  $skin   an instance of Skin class
-        * @return      void
-        */
-       public function setSkin(&$skin)
-       {
-               $this->skin =& $skin;
-               return;
-       }
-       
-       /**
-        * Actions::setParser()
-        * Set the parser
-        * 
-        * @param       object  $parser an instance of Parser class
-        * @return      void
-        */
-       public function setParser(&$parser)
-       {
-               $this->parser =& $parser;
-               return;
+               return array_merge($defined_actions, parent::getAvailableActions());
        }
        
        /**
@@ -438,7 +426,11 @@ class Actions extends BaseActions
                $params = func_get_args();
                array_shift($params);
                
+<<<<<<< HEAD
                return call_user_func_array(array(&$plugin, 'doIf'), $params);
+=======
+               return call_user_func_array(array($plugin, 'doIf'), $params);
+>>>>>>> skinnable-master
        }
        
        /**
@@ -458,9 +450,8 @@ class Actions extends BaseActions
                {
                        return $blog->isValidCategory($catid);
                }
-               
                // check category name
-               if ( $name == 'catname' )
+               else if ( $name == 'catname' )
                {
                        $value = $blog->getCategoryIdFromName($value);
                        if ( $value == $catid )
@@ -468,9 +459,8 @@ class Actions extends BaseActions
                                return $blog->isValidCategory($catid);
                        }
                }
-               
                // check category id
-               if ( ($name == 'catid') && ($value == $catid) )
+               else if ( ($name == 'catid') && ($value == $catid) )
                {
                        return $blog->isValidCategory($catid);
                }
@@ -587,8 +577,13 @@ class Actions extends BaseActions
                // TODO: Move request uri to linkparams. this is ugly. sorry for that.
                $startpos       = (integer) $startpos;
                $parsed         = parse_url(serverVar('REQUEST_URI'));
+<<<<<<< HEAD
                $path           = $parsed['path'];
                $parsed         = $parsed['query'];
+=======
+               $path           = ( in_array('path', $parsed) ) ? $parsed['path'] : '';
+               $parsed         = ( in_array('query', $parsed) ) ? $parsed['query'] : '';
+>>>>>>> skinnable-master
                $url            = '';
                
                if ( $direction == 'prev' )
@@ -648,7 +643,7 @@ class Actions extends BaseActions
                                }
                                if ( $sqlquery )
                                {
-                                       $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
+                                       $iAmountOnPage = intval(DB::getValue($sqlquery)) - intval($startpos);
                                }
                        }
                        
@@ -744,7 +739,12 @@ class Actions extends BaseActions
        private function preBlogContent($type, &$blog)
        {
                global $manager;
+<<<<<<< HEAD
                $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
+=======
+               $data = array('blog' => &$blog, 'type' => $type);
+               $manager->notify('PreBlogContent', $data);
+>>>>>>> skinnable-master
                return;
        }
 
@@ -759,7 +759,12 @@ class Actions extends BaseActions
        private function postBlogContent($type, &$blog)
        {
                global $manager;
+<<<<<<< HEAD
                $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));
+=======
+               $data = array('blog' => &$blog, 'type' => $type);
+               $manager->notify('PostBlogContent', $data);
+>>>>>>> skinnable-master
                return;
        }
        
@@ -848,6 +853,7 @@ class Actions extends BaseActions
         * Actions::parse_archivedate()
         * %archivedate(locale,date format)%
         * 
+<<<<<<< HEAD
         * @param       string  $locale
         * @return      void
         */
@@ -867,6 +873,15 @@ class Actions extends BaseActions
                }
                 */
                
+=======
+        * @param       deprecated      $locale 
+        * @return      void
+        */
+       public function parse_archivedate($locale='')
+       {
+               global $archive;
+               
+>>>>>>> skinnable-master
                // get archive date
                sscanf($archive,'%d-%d-%d',$y,$m,$d);
                
@@ -1077,7 +1092,12 @@ class Actions extends BaseActions
        public function parse_callback($eventName, $type)
        {
                global $manager;
+<<<<<<< HEAD
                $manager->notify($eventName, array('type' => $type));
+=======
+               $data = array('type' => $type);
+               $manager->notify($eventName, $data);
+>>>>>>> skinnable-master
                return;
        }
        
@@ -1146,19 +1166,6 @@ class Actions extends BaseActions
        }
        
        /**
-        * Actions::parse_charset()
-        * Parse skinvar charset
-        * 
-        * @param       void
-        * @return      void
-        */
-       public function parse_charset()
-       {
-               echo i18n::get_current_charset();
-               return;
-       }
-       
-       /**
         * Actions::parse_commentform()
         * Parse skinvar commentform
         * 
@@ -1266,17 +1273,22 @@ class Actions extends BaseActions
         */
        public function parse_comments($template)
        {
-               global $itemid, $manager, $blog, $highlight;
+               global $manager, $blog, $highlight, $itemid;
+               
                $template =& $manager->getTemplate($template);
+<<<<<<< HEAD
+               $item =& $manager->getItem($itemid, 0, 0);
+=======
+               $item =& $manager->getitem($itemid, 0, 0);
+>>>>>>> skinnable-master
                
                // create parser object & action handler
                $handler = new ItemActions($blog);
-               $parser = new Parser($actions->getDefinedActions(),$handler);
                $handler->setTemplate($template);
-               $handler->setParser($parser);
-               $item = Item::getitem($itemid, 0, 0);
                $handler->setCurrentItem($item);
                
+               $parser = new Parser($handler);
+               
                $comments = new Comments($itemid);
                $comments->setItemActions($handler);
                // shows ALL comments
@@ -1469,7 +1481,11 @@ class Actions extends BaseActions
        public function parse_itemtitle($format = '')
        {
                global $manager, $itemid;
+<<<<<<< HEAD
                $item =& $manager->getItem($itemid,0,0);
+=======
+               $item =& $manager->getItem($itemid, 1, 1);
+>>>>>>> skinnable-master
                
                switch ( $format )
                {
@@ -1921,7 +1937,11 @@ class Actions extends BaseActions
                // add skin type on front
                array_unshift($params, $this->skintype);
                
+<<<<<<< HEAD
                call_user_func_array(array(&$plugin,'doSkinVar'), $params);
+=======
+               call_user_func_array(array($plugin,'doSkinVar'), $params);
+>>>>>>> skinnable-master
                return;
        }
        
@@ -2161,7 +2181,7 @@ class Actions extends BaseActions
         */
        public function parse_skinname()
        {
-               echo $this->skin->getName();
+               echo $this->parser->skin->getName();
                return;
        }
        
@@ -2251,6 +2271,7 @@ class Actions extends BaseActions
         * @param       string  $template       name of template
         * @return      void
         */
+<<<<<<< HEAD
        public function parse_sticky($itemnumber = 0, $template = '')
        {
                global $manager;
@@ -2262,6 +2283,21 @@ class Actions extends BaseActions
                $this->preBlogContent('sticky',$b);
                $this->amountfound = $b->readLogFromList($itemarray, $template);
                $this->postBlogContent('sticky',$b);
+=======
+       public function parse_sticky($itemid = 0, $template = '')
+       {
+               global $manager;
+               
+               $itemid = (integer) $itemid;
+               $itemarray = array($itemid);
+               
+               $item =& $manager->getItem($post['itemid'], 1, 1);
+               $blog =& $manager->getBlog($item['blogid']);
+               
+               $this->preBlogContent('sticky', $blog);
+               $this->amountfound = $blog->readLogFromList($itemarray, $template);
+               $this->postBlogContent('sticky', $blog);
+>>>>>>> skinnable-master
                return;
        }
 }