private function validateSlug($sSlug, $sTitle, $iId = null)
    {
        /**
         * Slugs don't matter in preview mode
         */
        if ($this->isPreviewMode) {
            return 'slug';
        }

        // --------------------------------------------------------------------------

        /**
         * Handle the slug
         * If a slug has been provided, check it is unique, if one hasn't then
         * generate one.
         */

        if (empty($sSlug)) {

            $sSlug  = $this->generateSlug($sTitle);

        } else {

            $oDb = Factory::service('Database');

            if (!empty($iId)) {
                $oDb->where('id !=', $iId);
            }
            $oDb->where('slug', $sSlug);
            if ($oDb->count_all_results($this->table)) {
                $this->setError('Slug "' . $sSlug . '" is already in use by another post.');
                return false;
            }
        }

        //  If a the slug is a reserved word then bail out
        if (array_search($sSlug, $this->reservedWords) !== false) {

            $this->setError('Slug "' . $sSlug . '" is a reserved word and cannot be used.');
            return false;
        }

        return $sSlug;
    }
private function validateSlug($sSlug, $sTitle, $iId = null)
    {
        /**
         * Slugs don't matter in preview mode
         */
        if ($this->isPreviewMode) {
            return 'slug';
        }

        // --------------------------------------------------------------------------

        /**
         * Handle the slug
         * If a slug has been provided, check it is unique, if one hasn't then
         * generate one.
         */

        if (empty($sSlug)) {

            $sSlug  = $this->generateSlug($sTitle);

        } else {

            $oDb = Factory::service('Database');

            if (!empty($iId)) {
                $oDb->where('id !=', $iId);
            }
            $oDb->where('slug', $sSlug);
            if ($oDb->count_all_results($this->table)) {
                $this->setError('Slug "' . $sSlug . '" is already in use by another post.');
                return false;
            }
        }

        //  If a the slug is a reserved word then bail out
        if (array_search($sSlug, $this->reservedWords) !== false) {

            $this->setError('Slug "' . $sSlug . '" is a reserved word and cannot be used.');
            return false;
        }

        return $sSlug;
    }
private function validateSlug ( $ sSlug , $ sTitle , $ iId = null ) { /**
         * Slugs don't matter in preview mode
         */ if ( $ this -> isPreviewMode ) { return 'slug' ; } // -------------------------------------------------------------------------- /**
         * Handle the slug
         * If a slug has been provided, check it is unique, if one hasn't then
         * generate one.
         */ if ( empty ( $ sSlug ) ) { $ sSlug = $ this -> generateSlug ( $ sTitle ) ; } else { $ oDb = Factory :: service ( 'Database' ) ; if ( ! empty ( $ iId ) ) { $ oDb -> where ( 'id !=' , $ iId ) ; } $ oDb -> where ( 'slug' , $ sSlug ) ; if ( $ oDb -> count_all_results ( $ this -> table ) ) { $ this -> setError ( 'Slug "' . $ sSlug . '" is already in use by another post.' ) ; return false ; } } //  If a the slug is a reserved word then bail out if ( array_search ( $ sSlug , $ this -> reservedWords ) !== false ) { $ this -> setError ( 'Slug "' . $ sSlug . '" is a reserved word and cannot be used.' ) ; return false ; } return $ sSlug ; }
Validates a slug, if supplied, generates one from the title, if not

@param  string  $sSlug  The slug to test
@param  string  $sTitle The title to generate a slug from if no slug available
@param  integer $siId   The ID of the post to ignore from a comparison, if any

@return string
Validates a slug if supplied generates one from the title if not