<commit_before><?php

/**
 * This is the model class for table "custom_pages_page".
 *
 * The followings are the available columns in table 'custom_pages_page':
 * @property integer $id
 * @property integer $type
 * @property string $title
 * @property string $icon
 * @property string $content
 * @property integer $sort_order
 * @property integer $admin_only
 * @property string $navigation_class
 */
class CustomPage extends HActiveRecord
{

    public $url;
    public $markdown;
    public $widget_class;
    public $widget_targets;
    public $widget_template;
    public $visiblity;
    public $link_type;

    // Navigations
    const NAV_CLASS_TOPNAV = 'TopMenuWidget';
    const NAV_CLASS_ACCOUNTNAV = 'AccountMenuWidget';
    // Widget Targets
    const WIDGET_DASHBOARD = 'DashboardSidebarWidget';
    const WIDGET_DIRECTORY = 'DirectorySidebarWidget';
    const WIDGET_SPACE = 'SpaceSidebarWidget';
    const WIDGET_PROFILE = 'ProfileSidebarWidget';
    // Page Types
    const TYPE_LINK = '1';
    const TYPE_HTML = '2';
    const TYPE_IFRAME = '3';
    const TYPE_MARKDOWN = '4';
	const TYPE_PHP = '5';
    const TYPE_WIDGET = '6';
    // Page Visibility
    const VISIBILITY_GUEST = '0';
    const VISIBILITY_MEMBER = '1';
    const VISIBILITY_UNLISTED = '2';


    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return CustomPage the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'custom_pages_page';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('type, title, widget_class, navigation_class', 'required'),
            array('type, sort_order, admin_only, widget_template', 'numerical', 'integerOnly' => true),
            array('title, widget_class, navigation_class', 'length', 'max' => 255, 'message' => 'Title must be less then 255 characters'),
            array('visibility', 'numerical', 'integerOnly' => true, 'max' => 2),
            array('icon, link_type', 'length', 'max' => 100),
            array('widget_targets', 'widgetCheckSpaceGuid'),
            array('visibility', 'widgetCheckVisibility'),
            array('content, url, title', 'safe'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => Yii::t('CustomPagesModule.base', 'ID'),
            'type' => Yii::t('CustomPagesModule.base', 'Type'),
            'title' => Yii::t('CustomPagesModule.base', 'Title'),
            'icon' => Yii::t('CustomPagesModule.base', 'Icon'),
            'content' => Yii::t('CustomPagesModule.base', 'Content'),
            'url' => Yii::t('CustomPagesModule.base', 'URL'),
            'link_type' => Yii::t('CustomPagesModule.base', 'Link Type'),
            'sort_order' => Yii::t('CustomPagesModule.base', 'Sort Order'),
            'admin_only' => Yii::t('CustomPagesModule.base', 'Only visible for admins'),
            'visibility' => Yii::t('CustomPagesModule.base', 'Visibility'),
            'navigation_class' => Yii::t('CustomPagesModule.base', 'Navigation Target'),
            'widget_class' => Yii::t('CustomPagesModule.base', 'Widget Type'),
            'widget_template' => Yii::t('CustomPagesModule.base', 'No Template'),
            'widget_targets' => Yii::t('CustomPagesModule.base', 'Space Targets (GUIDs separated by commas)')
        );
    }

    public function beforeSave()
    {
        if ($this->type == self::TYPE_IFRAME || $this->type == self::TYPE_LINK) {
            $this->content = $this->url;
        }
        if ($this->type == self::TYPE_WIDGET) {
            $this->navigation_class = 'null';
        } else {
            $this->widget_class = 'null';
        }
        if ($this->widget_targets != '') {
            $this->widget_targets = (stristr($this->widget_targets, ',')) ? json_encode(explode(',', trim($this->widget_targets))) : json_encode(array($this->widget_targets));
        }
        
        return parent::beforeSave();
    }

    public function afterFind()
    {
        if ($this->type == self::TYPE_IFRAME || $this->type == self::TYPE_LINK) {
            $this->url = $this->content;
        }
        if ($this->type == self::TYPE_MARKDOWN) {
            $this->markdown = $this->content;
        }
        if ($this->widget_targets != '') {
            $this->widget_targets = (count(json_decode($this->widget_targets)) > 0) ? implode(', ', json_decode($this->widget_targets)) : json_decode($this->widget_targets);
            if (is_array($this->widget_targets)) {
                $targets = $this->widget_targets;
                $this->widget_targets = '';
                foreach($targets as $widget) {
                    $this->widget_targets .= $widget;
                }
            }
        }
        
        
        return parent::afterFind();
    }

    public static function getNavigationClasses()
    {
        return array(
            self::NAV_CLASS_TOPNAV => Yii::t('CustomPagesModule.base', 'Top Navigation'),
            self::NAV_CLASS_ACCOUNTNAV => Yii::t('CustomPagesModule.base', 'User Account Menu (Settings)'),
        );
    }
    
    public static function getWidgetClasses()
    {
        return array(
            self::WIDGET_DASHBOARD => Yii::t('CustomPagesModule.base', 'Dashboard (Sidebar Widget)'),
            self::WIDGET_DIRECTORY => Yii::t('CustomPagesModule.base', 'Directory (Sidebar Widget)'),
            self::WIDGET_SPACE => Yii::t('CustomPagesModule.base', 'Space (Sidebar Widget)'),
            self::WIDGET_PROFILE => Yii::t('CustomPagesModule.base', 'Profile (Sidebar Widget)')
        );
    }

    public static function getPageTypes()
    {
        return array(
            self::TYPE_LINK => Yii::t('CustomPagesModule.base', 'Link'),
            self::TYPE_HTML => Yii::t('CustomPagesModule.base', 'HTML'),
            self::TYPE_MARKDOWN => Yii::t('CustomPagesModule.base', 'MarkDown'),
            self::TYPE_IFRAME => Yii::t('CustomPagesModule.base', 'IFrame'),
            self::TYPE_PHP => Yii::t('CustomPagesModule.base', 'PHP'),
            self::TYPE_WIDGET => Yii::t('CustomPagesModule.base', 'Widget'),
        );
    }
    
    public static function getVisiblityTypes()
    {
        return array(
            self::VISIBILITY_GUEST => Yii::t('CustomPagesModule.base', 'Guest (Everyone)'),
            self::VISIBILITY_MEMBER => Yii::t('CustomPagesModule.base', 'Members (Members only)'),
            self::VISIBILITY_UNLISTED => Yii::t('CustomPagesModule.base', 'Unlisted (No menu links)'),
        );
    }<commit_msg>Remove Guest Mode Option...<commit_after><?php

/**
 * This is the model class for table "custom_pages_page".
 *
 * The followings are the available columns in table 'custom_pages_page':
 * @property integer $id
 * @property integer $type
 * @property string $title
 * @property string $icon
 * @property string $content
 * @property integer $sort_order
 * @property integer $admin_only
 * @property string $navigation_class
 */
class CustomPage extends HActiveRecord
{

    public $url;
    public $markdown;
    public $widget_class;
    public $widget_targets;
    public $widget_template;
    public $visiblity;
    public $link_type;

    // Navigations
    const NAV_CLASS_TOPNAV = 'TopMenuWidget';
    const NAV_CLASS_ACCOUNTNAV = 'AccountMenuWidget';
    // Widget Targets
    const WIDGET_DASHBOARD = 'DashboardSidebarWidget';
    const WIDGET_DIRECTORY = 'DirectorySidebarWidget';
    const WIDGET_SPACE = 'SpaceSidebarWidget';
    const WIDGET_PROFILE = 'ProfileSidebarWidget';
    // Page Types
    const TYPE_LINK = '1';
    const TYPE_HTML = '2';
    const TYPE_IFRAME = '3';
    const TYPE_MARKDOWN = '4';
	const TYPE_PHP = '5';
    const TYPE_WIDGET = '6';
    // Page Visibility
    const VISIBILITY_GUEST = '0';
    const VISIBILITY_MEMBER = '1';
    const VISIBILITY_UNLISTED = '2';


    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return CustomPage the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'custom_pages_page';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('type, title, widget_class, navigation_class', 'required'),
            array('type, sort_order, admin_only, widget_template', 'numerical', 'integerOnly' => true),
            array('title, widget_class, navigation_class', 'length', 'max' => 255, 'message' => 'Title must be less then 255 characters'),
            array('visibility', 'numerical', 'integerOnly' => true, 'max' => 2),
            array('icon, link_type', 'length', 'max' => 100),
            array('widget_targets', 'widgetCheckSpaceGuid'),
            array('visibility', 'widgetCheckVisibility'),
            array('content, url, title', 'safe'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => Yii::t('CustomPagesModule.base', 'ID'),
            'type' => Yii::t('CustomPagesModule.base', 'Type'),
            'title' => Yii::t('CustomPagesModule.base', 'Title'),
            'icon' => Yii::t('CustomPagesModule.base', 'Icon'),
            'content' => Yii::t('CustomPagesModule.base', 'Content'),
            'url' => Yii::t('CustomPagesModule.base', 'URL'),
            'link_type' => Yii::t('CustomPagesModule.base', 'Link Type'),
            'sort_order' => Yii::t('CustomPagesModule.base', 'Sort Order'),
            'admin_only' => Yii::t('CustomPagesModule.base', 'Only visible for admins'),
            'visibility' => Yii::t('CustomPagesModule.base', 'Visibility'),
            'navigation_class' => Yii::t('CustomPagesModule.base', 'Navigation Target'),
            'widget_class' => Yii::t('CustomPagesModule.base', 'Widget Type'),
            'widget_template' => Yii::t('CustomPagesModule.base', 'No Template'),
            'widget_targets' => Yii::t('CustomPagesModule.base', 'Space Targets (GUIDs separated by commas)')
        );
    }

    public function beforeSave()
    {
        if ($this->type == self::TYPE_IFRAME || $this->type == self::TYPE_LINK) {
            $this->content = $this->url;
        }
        if ($this->type == self::TYPE_WIDGET) {
            $this->navigation_class = 'null';
        } else {
            $this->widget_class = 'null';
        }
        if ($this->widget_targets != '') {
            $this->widget_targets = (stristr($this->widget_targets, ',')) ? json_encode(explode(',', trim($this->widget_targets))) : json_encode(array($this->widget_targets));
        }
        
        return parent::beforeSave();
    }

    public function afterFind()
    {
        if ($this->type == self::TYPE_IFRAME || $this->type == self::TYPE_LINK) {
            $this->url = $this->content;
        }
        if ($this->type == self::TYPE_MARKDOWN) {
            $this->markdown = $this->content;
        }
        if ($this->widget_targets != '') {
            $this->widget_targets = (count(json_decode($this->widget_targets)) > 0) ? implode(', ', json_decode($this->widget_targets)) : json_decode($this->widget_targets);
            if (is_array($this->widget_targets)) {
                $targets = $this->widget_targets;
                $this->widget_targets = '';
                foreach($targets as $widget) {
                    $this->widget_targets .= $widget;
                }
            }
        }
        
        
        return parent::afterFind();
    }

    public static function getNavigationClasses()
    {
        return array(
            self::NAV_CLASS_TOPNAV => Yii::t('CustomPagesModule.base', 'Top Navigation'),
            self::NAV_CLASS_ACCOUNTNAV => Yii::t('CustomPagesModule.base', 'User Account Menu (Settings)'),
        );
    }
    
    public static function getWidgetClasses()
    {
        return array(
            self::WIDGET_DASHBOARD => Yii::t('CustomPagesModule.base', 'Dashboard (Sidebar Widget)'),
            self::WIDGET_DIRECTORY => Yii::t('CustomPagesModule.base', 'Directory (Sidebar Widget)'),
            self::WIDGET_SPACE => Yii::t('CustomPagesModule.base', 'Space (Sidebar Widget)'),
            self::WIDGET_PROFILE => Yii::t('CustomPagesModule.base', 'Profile (Sidebar Widget)')
        );
    }

    public static function getPageTypes()
    {
        return array(
            self::TYPE_LINK => Yii::t('CustomPagesModule.base', 'Link'),
            self::TYPE_HTML => Yii::t('CustomPagesModule.base', 'HTML'),
            self::TYPE_MARKDOWN => Yii::t('CustomPagesModule.base', 'MarkDown'),
            self::TYPE_IFRAME => Yii::t('CustomPagesModule.base', 'IFrame'),
            self::TYPE_PHP => Yii::t('CustomPagesModule.base', 'PHP'),
            self::TYPE_WIDGET => Yii::t('CustomPagesModule.base', 'Widget'),
        );
    }
    
    public static function getVisiblityTypes()
    {
    	$arr = array();
        if (HSetting::Get('allowGuestAccess', 'authentication_internal')) {
            $arr[] = self::VISIBILITY_GUEST => Yii::t('CustomPagesModule.base', 'Guest (Everyone)'),
        }
        $arr[] = self::VISIBILITY_MEMBER => Yii::t('CustomPagesModule.base', 'Members (Members only)');
        $arr[] = self::VISIBILITY_UNLISTED => Yii::t('CustomPagesModule.base', 'Unlisted (No menu links)');
        return $arr;
    }
{'fraction_non_alphanumeric': 0.14586160108548168, 'fraction_numerical': 0.0027137042062415195, 'mean_word_length': 2.6298941147500616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1164778', 'n_tokens_mistral': 4312, 'n_tokens_neox': 4220, 'n_words': 947}