Beispiel #1
0
    public static function form()
    {
        $className = __CLASS__;
        $slideWidth = 'js:function(event,ui)' . <<<JS
 {
\t\$('#{$className}_width').val(ui.value);
\t{$className}_makesize(ui.value, false, ui.handle);
}
JS;
        $changeWidth = 'js:function(event,ui)' . <<<JS
 {
\t{$className}_makesize(ui.value, false, ui.handle);
}
JS;
        $slideHeight = 'js:function(event,ui)' . <<<JS
 {
\t\$('#{$className}_height').val(ui.value);
\t{$className}_makesize(ui.value, true, ui.handle);
}
JS;
        $changeHeight = 'js:function(event,ui)' . <<<JS
 {
\t{$className}_makesize(ui.value, true, ui.handle);
}
JS;
        $cfg = ContentUnit::loadConfig();
        return array('elements' => array(Form::tab(Yii::t('UnitRandomimage.main', 'Images')), 'images' => array('type' => 'FileManager', 'width' => 900, 'height' => 350, 'multiple' => true, 'options' => array('onlyMimes' => array('image/jpeg', 'image/gif', 'image/png')), 'element' => array(array('name' => 'caption', 'type' => 'text', 'size' => 40, 'label' => Yii::t('UnitRandomimage.main', 'Caption'), 'i18n' => true))), Form::tab(Yii::t('UnitRandomimage.main', 'Size & link')), Yii::app()->controller->renderPartial($cfg['UnitImage'] . '.image.assets.imagesize', compact('className'), true), 'width' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 2000, 'step' => 1, 'slide' => $slideWidth, 'change' => $changeWidth)), 'height' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 2000, 'step' => 1, 'slide' => $slideHeight, 'change' => $changeHeight)), 'url' => array('type' => 'text', 'size' => 40), 'target' => array('type' => 'dropdownlist', 'items' => array('' => Yii::t('UnitRandomimage.main', 'Current window'), '_blank' => Yii::t('UnitRandomimage.main', 'New window')))));
    }
Beispiel #2
0
    public static function form()
    {
        $className = __CLASS__;
        $slideWidth = 'js:function(event,ui)' . <<<JS
 {
\t\$('#{$className}_width').val(ui.value);
\t{$className}_makesize(ui.value, false, ui.handle);
}
JS;
        $changeWidth = 'js:function(event,ui)' . <<<JS
 {
\t{$className}_makesize(ui.value, false, ui.handle);
}
JS;
        $slideHeight = 'js:function(event,ui)' . <<<JS
 {
\t\$('#{$className}_height').val(ui.value);
\t{$className}_makesize(ui.value, true, ui.handle);
}
JS;
        $changeHeight = 'js:function(event,ui)' . <<<JS
 {
\t{$className}_makesize(ui.value, true, ui.handle);
}
JS;
        $cfg = ContentUnit::loadConfig();
        return array('elements' => array(Form::tab(Yii::t('UnitVideo.main', 'Video')), 'video' => array('type' => 'Link', 'size' => 40, 'showPageSelectButton' => false), 'show_link' => array('type' => 'checkbox'), Yii::app()->controller->renderPartial($cfg['UnitVideo'] . '.video.assets.containersize', array('attribute' => 'video', 'width' => 'width', 'height' => 'height', 'selector' => 'object, embed, iframe', 'sizes' => array('425x344' => '425 × 344', '480x385' => '480 × 385', '640x505' => '640 × 505', '960x745' => '960 × 745'), 'className' => $className), true), 'width' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 1000, 'step' => 1, 'slide' => $slideWidth, 'change' => $changeWidth)), 'height' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 1000, 'step' => 1, 'slide' => $slideHeight, 'change' => $changeHeight)), Form::tab(Yii::t('UnitVideo.main', 'HTML')), 'html' => array('hint' => Yii::t('UnitVideo.main', 'If the link to your video is not recognized, use the version with the html-code.'), 'type' => 'textarea', 'rows' => 6, 'cols' => 60)));
    }
Beispiel #3
0
 protected function proccessRequest()
 {
     if (Yii::app()->request->getPost('logout') !== null) {
         Yii::app()->user->logout();
         Yii::app()->controller->refresh();
         return true;
     }
     if (Yii::app()->request->getPost('LoginForm') !== null) {
         $model = new LoginForm();
         $model->attributes = Yii::app()->request->getPost('LoginForm');
         if ($model->validate() && $model->login()) {
             Yii::app()->controller->refresh();
             return true;
         }
     }
     if (Yii::app()->request->getPost('RememberForm') !== null) {
         $model = new RememberForm();
         $model->attributes = Yii::app()->request->getPost('RememberForm');
         if ($model->validate()) {
             $user = User::model()->find('`login` = :username OR `email` = :username', array('username' => $model->username));
             if ($user) {
                 $user->saveAttributes(array('authcode' => User::hash($user->id . $user->email . time() . rand())));
                 $cfg = ContentUnit::loadConfig();
                 $viewFileDir = $cfg['UnitLogin'] . '.login.templates.mail.';
                 $tpldata['model'] = $user;
                 $tpldata['settings'] = Yii::app()->settings->model->getAttributes();
                 $tpldata['page'] = $this->params['content']->getUnitPageArray();
                 // send 'to_user_confirm' mail
                 Yii::app()->messenger->send('email', $user->email, Yii::t('UnitLogin.main', 'Password reset'), Yii::app()->controller->renderPartial($viewFileDir . 'password_reset', $tpldata, true));
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #4
0
 public function init()
 {
     parent::init();
     $id = __CLASS__ . $this->params['content']->id;
     $this->params['profileVar'] = $this->urlParam('view');
     $blank = true;
     if (Yii::app()->request->getParam($this->params['profileVar']) !== null) {
         $profile = User::model()->findByPk(intval(Yii::app()->request->getParam($this->params['profileVar'])));
         if ($profile) {
             $this->params['details'] = Yii::app()->controller->widget('zii.widgets.CDetailView', array('data' => $profile, 'attributes' => $this->makeFields($this->params['content']->displayed_fields, $profile)), true);
             $this->params['profile'] = $profile->getAttributes();
             if (Yii::app()->user->hasRole($profile->send_message) && $profile->id != $this->params['user']->id && $profile->email) {
                 $vm = new VirtualModel($this->params['content']->feedback_form, 'FieldSet');
                 $config = $vm->formMap;
                 $config['id'] = sprintf('%x', crc32(serialize(array_keys($this->params['content']->feedback_form))));
                 $config['buttons'] = array('send' => array('type' => 'submit', 'label' => Yii::t('UnitProfiles.main', 'Send')));
                 $config['activeForm'] = Form::ajaxify($config['id']);
                 $config['activeForm']['clientOptions']['validationUrl'] = '/?r=view/widget&pageWidgetId=' . $this->params['pageWidget']->id . '&' . $this->params['profileVar'] . '=' . $profile->id;
                 $config['activeForm']['clientOptions']['afterValidate'] = "js:function(f,d,h){if (!h) {return true;}}";
                 $form = new Form($config, $vm);
                 if (Yii::app()->request->getParam('ajax-validate') !== null) {
                     echo CActiveForm::validate($vm);
                     Yii::app()->end();
                 }
                 if ($form->submitted('send')) {
                     $vm = $form->model;
                     if ($form->validate()) {
                         $cfg = ContentUnit::loadConfig();
                         $viewFileDir = $cfg['UnitProfiles'] . '.profiles.templates.mail.';
                         $labels = $vm->attributeLabels();
                         foreach ($vm->getAttributes() as $attr => $value) {
                             $tpldata['fields'][$labels[$attr]] = $value;
                         }
                         $tpldata['profile'] = $profile->getAttributes();
                         $tpldata['settings'] = Yii::app()->settings->model->getAttributes();
                         $tpldata['page'] = $this->params['content']->getWidgetPageArray();
                         $registerModel = ModelRegister::model()->find('widget_id > 0');
                         $registerWidget = new WidgetRegister();
                         if ($registerUnit) {
                             $tpldata['profileEditUrl'] = $registerModel->getWidgetUrl();
                             $tpldata['profileEditUrlParams'] = $registerWidget->urlParam('do') . '=edit';
                         }
                         Yii::app()->messenger->send('email', $profile->email, '[' . $_SERVER['HTTP_HOST'] . '] ' . Yii::t('UnitProfiles.main', 'Feedback form'), Yii::app()->controller->renderPartial($viewFileDir . 'feedback', $tpldata, true));
                         Yii::app()->user->setFlash('UnitProfilesSend-permanent', Yii::t('UnitProfiles.main', 'Your message was successfully sent'));
                         Yii::app()->controller->refresh();
                     }
                 }
                 $this->params['feedbackForm'] = $form->render();
             }
         } else {
             $this->params['error'] = Yii::t('UnitProfiles.main', 'Profile not found');
         }
         $blank = false;
     }
     if ($blank) {
         $this->prepareTable();
     }
 }
Beispiel #5
0
 public static function getHtmlByUrl($url, $width = 0, $height = 0, $title = '')
 {
     /*
      * TODO:
      * - vkontakte.ru
      * - video.yandex.ru
      * - bbc ?
      * - cnn ?
      * -
      */
     $vs = array('youtube.com' => array('pattern' => "|youtube\\.com([^0-9\\?\\#\\=]*)(\\?v[=/])?(#p/u/)?([0-9]*/)?([a-zA-Z0-9\\-]*)|msi", 'match' => 5, 'width' => 480, 'height' => 270, 'view' => 'youtube'), 'youtu.be' => array('pattern' => "|youtu\\.be\\/([a-zA-Z0-9\\-]*)|msi", 'match' => 1, 'width' => 480, 'height' => 270, 'view' => 'youtube'), 'vimeo.com' => array('pattern' => "|vimeo\\.com(/video)?/([0-9]*)|msi", 'match' => 2, 'width' => 480, 'height' => 270, 'view' => 'vimeo'), 'rutube.ru' => array('pattern' => "|rutube\\.ru.*v=([0-9a-f]*)|msi", 'match' => 1, 'width' => 480, 'height' => 360, 'view' => 'rutube'), 'godtube.com' => array('pattern' => "|godtube\\.com.*v[=/]([a-zA-Z0-9]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'godtube'), 'tangle.com' => array('pattern' => "|tangle\\.com.*viewkey=([0-9a-f]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'tangle'), 'video.google.com' => array('pattern' => "|google\\.com.*docid=([\\-0-9]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'google'), 'myspace.com' => array('pattern' => "|myspace\\.com.*videoid=([0-9]*)|msi", 'match' => 1, 'width' => 425, 'height' => 360, 'view' => 'myspace'), 'dailymotion.com' => array('pattern' => "|dailymotion\\.com/video/([^?]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'dailymotion'), 'truegod.tv' => array('pattern' => "|truegod\\.tv.*viewkey=([0-9a-f]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'truegod'), 'smotri.com' => array('pattern' => "|smotri\\.com.*id=([0-9a-z]*)|msi", 'match' => 1, 'width' => 640, 'height' => 360, 'view' => 'smotri'), '1tv.ru' => array('pattern' => "|1tv\\.ru[^0-9]*([0-9]*)|msi", 'match' => 1, 'width' => 460, 'height' => 353, 'view' => '1tv'), 'video.bigmir.net' => array('pattern' => "|bigmir\\.net[^0-9]*([0-9]*)|msi", 'match' => 1, 'width' => 608, 'height' => 342, 'view' => 'bigmir'), 'video.online.ua' => array('pattern' => "|online\\.ua[^0-9]*([0-9]*)|msi", 'match' => 1, 'width' => 640, 'height' => 400, 'view' => 'online_ua'), 'vision.rambler.ru' => array('pattern' => "|rambler\\.ru/users/(.*)|msi", 'match' => 1, 'width' => 480, 'height' => 291, 'view' => 'rambler'), 'video.utro.ua' => array('pattern' => "|utro\\.ua.*id=([0-9a-z]*)|msi", 'match' => 1, 'width' => 640, 'height' => 360, 'view' => 'utro'), 'nbc.com' => array('pattern' => "|nbc\\.com/[^/]*/video/[^/]*/([0-9]*)|msi", 'match' => 1, 'width' => 512, 'height' => 347, 'view' => 'nbc'), $_SERVER['HTTP_HOST'] => array('pattern' => "|(.*)|msi", 'match' => 1, 'width' => 492, 'height' => 300, 'view' => 'jwplayer'), '.flv' => array('pattern' => "|(.*)|msi", 'match' => 1, 'width' => 492, 'height' => 300, 'view' => 'jwplayer'), '.mp4' => array('pattern' => "|(.*)|msi", 'match' => 1, 'width' => 492, 'height' => 300, 'view' => 'jwplayer'));
     foreach ($vs as $site => $arr) {
         if (strpos($url, $site) !== false) {
             preg_match($arr['pattern'], $url, $matches);
             $id = $matches[$arr['match']];
             $w = $width ? $width : $arr['width'];
             $h = $height ? $height : $arr['height'];
             $cfg = ContentUnit::loadConfig();
             return Yii::app()->controller->renderPartial($cfg['UnitVideo'] . '.video.codes.' . $arr['view'], array('id' => $id, 'width' => $w, 'height' => $h, 'title' => $title), true);
         }
     }
     return false;
 }
Beispiel #6
0
 protected function proccessRequest($model = null)
 {
     if (Yii::app()->request->getPost('User') !== null) {
         if (!$model) {
             $model = new User('register');
             $model->makeForm('register', $this->params['content']->fields, $this->params['content']->fields_req);
         }
         $tpldata = array();
         $model->attributes = Yii::app()->request->getPost('User');
         if ($model->password == '') {
             $model->password = $model->password_repeat = $tpldata['generatedPassword'] = User::generatePassword();
             $model->askfill = true;
         }
         if ($model->validate()) {
             $model->save(false);
             $cfg = ContentUnit::loadConfig();
             $viewFileDir = $cfg['UnitRegister'] . '.register.templates.mail.';
             $tpldata['model'] = $model->getAttributes();
             $tpldata['settings'] = Yii::app()->settings->model->getAttributes();
             $tpldata['page'] = $this->params['content']->getWidgetPageArray();
             if ($this->params['content']->notify_admin) {
                 // send 'to_admin_notify' mail
                 Yii::app()->messenger->send('email', Yii::app()->settings->getValue('adminEmail'), '[' . $_SERVER['HTTP_HOST'] . '] ' . Yii::t('UnitRegister.main', 'New user registration'), Yii::app()->controller->renderPartial($viewFileDir . 'to_admin_notify', $tpldata, true));
             }
             if ($this->params['content']->is_emailauth_req) {
                 $model->saveAttributes(array('authcode' => User::hash($model->id . $model->login . time() . rand())));
                 $tpldata['model'] = $model;
                 // send 'to_user_confirm' mail
                 Yii::app()->messenger->send('email', $model->email, Yii::t('UnitRegister.main', 'Registration confirm'), Yii::app()->controller->renderPartial($viewFileDir . 'to_user_confirm', $tpldata, true));
                 return true;
             } else {
                 $model->saveAttributes(array('active' => true));
                 if ($this->params['content']->notify_user || $tpldata['generatedPassword']) {
                     // send 'to_user_notify' mail
                     Yii::app()->messenger->send('email', $model->email, Yii::t('UnitRegister.main', 'Registration completed'), Yii::app()->controller->renderPartial($viewFileDir . 'to_user_notify', $tpldata, true));
                 }
                 $loginForm = new LoginForm();
                 $loginForm->username = $model->email;
                 $loginForm->password = !empty($_POST['User']['password']) ? $_POST['User']['password'] : $tpldata['generatedPassword'];
                 if ($loginForm->login()) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
Beispiel #7
0
 public static function getInstalledModels($flatten = false)
 {
     $units = ContentUnit::getInstalledUnits(true);
     $return = array();
     $unitConfig = ContentUnit::loadConfig();
     foreach ($units as $unitClassName => $name) {
         $unit = array('className' => $unitClassName, 'name' => $name, 'icon' => call_user_func(array($unitClassName, 'icon')), 'models' => array());
         $dir = strtolower(substr($unitClassName, 4));
         $models = call_user_func(array($unitClassName, 'models'));
         foreach ($models as $className => $alias) {
             if (is_int($className)) {
                 $className = $alias;
                 $alias = $unitConfig[$unitClassName] . '.' . $dir . '.' . $className;
             }
             $unit['models'][] = array('className' => $className, 'name' => call_user_func(array($className, 'modelName')), 'icon' => call_user_func(array($className, 'icon')));
         }
         $return[] = $unit;
     }
     if ($flatten) {
         $units = $return;
         $models = array();
         foreach ($units as $unit) {
             foreach ($unit['models'] as $model) {
                 $models[$model['className']] = $model['name'];
             }
         }
         $return = $models;
     }
     return $return;
 }
Beispiel #8
0
                    oneAtTime: false,
                    appendType: 'append'
                })
                .css({ 'position': 'fixed',
                    'marginTop': '10px',
                    'left': Math.ceil(\$('body').width()/2-125)+'px',
                    'width': '300px',
                    'z-index': '100000'
                });


JS
, CClientScript::POS_READY);
$js = '';
$flashes = Yii::app()->user->getFlashes(false);
$unitConfig = ContentUnit::loadConfig();
if (Yii::app()->user->hasState('askfill') && isset($unitConfig['register'])) {
    $registerModel = ModelRegister::model()->find('widget_id > 0');
    if ($registerModel) {
        $shortMessage = '<a href=\'' . $registerModel->getWidgetUrl() . '\'>' . Yii::t('cms', 'Please fill all required fields in your personal profile. And if necessary, change your password.') . '</a>';
        $message = '<h3>' . Yii::t('cms', 'Attention') . '</h3><p>' . $shortMessage . '</p>';
        if (Yii::app()->user->getState('askfill') == 'first') {
            $fancyPath = $am->publish(Yii::getPathOfAlias('application.vendors.fancybox'));
            $cs->registerScriptFile($fancyPath . '/jquery.fancybox-1.3.1.pack.js');
            $cs->registerCssFile($fancyPath . '/jquery.fancybox-1.3.1.css');
            $js .= '$.fancybox("' . $message . '");';
            Yii::app()->user->setState('askfill', 'second');
        } else {
            $flashes['askfill-permanent'] = $shortMessage;
        }
    }
Beispiel #9
0
 public static function getInstalledWidgets()
 {
     $units = ContentUnit::getInstalledUnits(true);
     $return = array();
     $unitConfig = ContentUnit::loadConfig();
     foreach ($units as $unitClassName => $name) {
         $unit = array('className' => $unitClassName, 'name' => $name, 'icon' => call_user_func(array($unitClassName, 'icon')), 'widgets' => array());
         $dir = strtolower(substr($unitClassName, 4));
         $widgets = call_user_func(array($unitClassName, 'widgets'));
         foreach ($widgets as $className => $alias) {
             if (is_int($className)) {
                 $className = $alias;
                 $alias = $unitConfig[$unitClassName] . '.' . $dir . '.' . $className;
             }
             $unit['widgets'][] = array('className' => $className, 'name' => call_user_func(array($className, 'name')), 'icon' => call_user_func(array($className, 'icon')));
         }
         $return[] = $unit;
     }
     return $return;
 }