예제 #1
0
파일: RssAction.php 프로젝트: Cranky4/npfs
 public function run()
 {
     $this->controller->layout = false;
     $feedSettings = CMap::mergeArray($this->getDefaultFeedSettings(), $this->getFeedSettings());
     $feedItems = $this->getRssItems();
     $feed = new EFeed($this->type);
     $channelTags = HArray::val($feedSettings, 'channelTags', array());
     unset($feedSettings['channelTags']);
     //Настраиваем канал
     foreach ($feedSettings as $settingName => $settingValue) {
         $feed->{$settingName} = $settingValue;
     }
     $feed->addChannelTagsArray($channelTags);
     //Заносим элементы канала
     $c = count($feedItems);
     for ($i = 0; $i < $c; $i++) {
         $feed->addItem($feedItems[$i]);
     }
     if ($c == 0) {
         echo 'No feed items';
         return;
     }
     //рендерим канал
     $feed->generateFeed();
 }
예제 #2
0
 protected function renderDataCellContent($row, $data)
 {
     $idInstance = $data->getIdInstance();
     $cnt = HArray::val($this->commentsCount, $idInstance, 0);
     $link = Yii::app()->createUrl(BackendModule::ROUTE_INSTANCE_LIST, array(ObjectUrlRule::PARAM_OBJECT => CommentYii::ID_OBJECT, CommentEventHandler::URL_PARAM_OBJECT => $this->object->id_object, CommentEventHandler::URL_PARAM_INSTANCE => $idInstance));
     echo CHtml::link('<i class="glyphicon glyphicon-comment"></i> ' . $cnt, $link, array('title' => 'Комментарии'));
 }
예제 #3
0
 protected function getProducts()
 {
     $modelClass = get_class(BaseActiveRecord::model('Product'));
     $productItems = Yii::app()->request->getPost($modelClass, array());
     $ids = HArray::column($productItems, 'id_product');
     if (empty($ids)) {
         return array();
     }
     $result = array();
     $products = BaseActiveRecord::model('Product')->with('category')->findAllByPk($ids);
     foreach ($productItems as $item) {
         foreach ($products as $product) {
             if ($product->getPrimaryKey() == (int) HArray::val($item, 'id_product')) {
                 //чтобы появилась возможность заполнять кастомные поля (поля, определенные прикладным программистом)
                 //делаем массовое присваивание
                 unset($item['id_product']);
                 $product->scenario = 'offer';
                 $product->attributes = $item;
                 if (floatval($product->countInCart) > 0) {
                     $result[] = $product;
                 }
                 break;
             }
         }
     }
     return $result;
 }
예제 #4
0
 public static function newModel($modelName, $scenario = 'insert')
 {
     $models = isset(Yii::app()->models) ? Yii::app()->models : array();
     $className = HArray::val($models, $modelName, $modelName);
     $className = Yii::import($className, true);
     return new $className($scenario);
 }
예제 #5
0
 protected function renderDataCellContent($row, $data)
 {
     $idInstance = $data->getIdInstance();
     $photoCount = HArray::val($this->photoCountList, $idInstance, 0);
     $link = Yii::app()->createUrl(BackendModule::ROUTE_INSTANCE_LIST, array(ObjectUrlRule::PARAM_OBJECT => PhotogalleryPhoto::ID_OBJECT, PhotogalleryPhoto::URL_PARAM_OBJECT => $this->object->id_object, PhotogalleryPhoto::URL_PARAM_INSTANCE => $idInstance));
     echo CHtml::link('<i class="glyphicon glyphicon-picture"></i> ' . $photoCount, $link, array('title' => 'Фотографии', 'class' => 'btn btn-xs btn-primary'));
 }
예제 #6
0
 public function run()
 {
     $msgType = array('success' => 'alert-success', 'error' => 'alert-danger', 'warning' => 'alert-info');
     $type = HArray::val($msgType, $this->type, 'alert-info');
     $script = "daAlert(" . CJavaScript::encode($this->title) . ", " . CJavaScript::encode($this->message) . ", '" . $this->btTitle . "', '" . $type . "');";
     $cs = Yii::app()->clientScript;
     $cs->registerScript(__CLASS__ . self::$_cnt++, $script, CClientScript::POS_READY);
 }
예제 #7
0
 /**
  * @return CTheme|mixed
  */
 public function getFrontendTheme()
 {
     $theme = HArray::val($this->getFrontendConfig(), 'theme');
     if ($theme != null) {
         return $this->themeManager->getTheme($theme);
     }
     return $theme;
 }
예제 #8
0
 public function behaviors()
 {
     $with = array('productCount');
     if (Yii::app()->daShop->imageCategoryOnMain) {
         $with[] = 'photo';
     }
     //Берем конфигурацию из настроек модуля
     $config = HArray::val(Yii::app()->daShop->getModelConfig(__CLASS__), 'ImagePreview');
     return array('tree' => array('class' => 'ActiveRecordTreeBehavior', 'order' => 'id_parent DESC, sequence ASC', 'idParentField' => 'id_parent', 'with' => $with), 'ImagePreview' => CMap::mergeArray(array('class' => 'ImagePreviewBehavior', 'imageProperty' => 'photo', 'formats' => array('_sm' => array('width' => 170, 'height' => 130))), $config));
 }
예제 #9
0
 public function actionBlank()
 {
     $model = new Request();
     $this->performAjaxValidation($model, 'requestForm');
     if ($data = HArray::val($_POST, get_class($model))) {
         $model->attributes = $data;
         if (!$model->save()) {
             Yii::app()->user->setFlash('request-status', CHtml::errorSummary($model, '<p>Не удалось отправить форму</p>'));
         } else {
             Yii::app()->user->setFlash('request-status', "Заявка успешно отправлена. Скоро с вами свяжется менеджер. Спасибо!");
         }
     }
     $model->bdate = date('d.m.Y');
     $model->passport_date = date('d.m.Y');
     $this->render('blank', array('model' => $model));
 }
예제 #10
0
 public function beforeValidate($event)
 {
     //устанавливаем модели идешники загруженных файлов
     foreach ($this->getFileObjectParameters() as $objectParam) {
         if ($objectParam->id_parameter_type == DataType::FILE && ($files = HArray::val($this->getFiles(), $objectParam->id_parameter, array()))) {
             $mainFile = null;
             foreach ($files as $file) {
                 if (empty($file->id_parent_file)) {
                     $mainFile = $file;
                     break;
                 }
             }
             if ($mainFile) {
                 $this->owner->{$objectParam->field_name} = $mainFile->id_file;
             }
         }
     }
 }
예제 #11
0
 public function getImagePreview($postfix, $property = null)
 {
     if ($property === null) {
         $property = $this->imageProperty;
     }
     $format = HArray::val($this->formats, $postfix, null);
     if ($format === null) {
         return null;
     }
     $width = HArray::val($format, 'width', $this->defaultWidth);
     $height = HArray::val($format, 'height', $this->defaultHeight);
     $crop = HArray::val($format, 'crop', $this->defaultCrop);
     $quality = HArray::val($format, 'quality', $this->defaultQuality);
     $resize = HArray::val($format, 'resize', $this->defaultResize);
     if ($this->owner->{$property} !== null) {
         return $this->owner->{$property}->getPreview($width, $height, $postfix, $crop, $quality, $resize);
     }
     return null;
 }
예제 #12
0
 public function deactivate(Plugin $plugin)
 {
     $data = $plugin->getData();
     if (!is_array($data)) {
         throw new ErrorException('Плагин установлен неверно.');
     }
     $trans = Yii::app()->db->beginTransaction();
     $idMenuKeys = array('idMenuLogin', 'idMenuRegister', 'idMenuRecover', 'idMenuProfile', 'idMenuUser');
     //если в массиве $data нет всех ключей из $idMenuKeys
     if (count(array_diff($idMenuKeys, array_keys($data))) > 0) {
         throw new ErrorException('Плагин установлен неверно.');
     }
     //удаляем разделы меню
     foreach ($idMenuKeys as $idMenuKey) {
         $data = $this->deleteMenu($data[$idMenuKey], $data, 'id_menu_module_template_' . $idMenuKey);
         unset($data[$idMenuKey]);
     }
     //удаляем типы событий
     $paramNames = array('idEventTypeRecover', 'idEventTypeRegister');
     $etIds = array();
     foreach ($paramNames as $paramName) {
         if ($id = HArray::val($data, $paramName)) {
             $etIds[] = $id;
         }
     }
     if ($etIds) {
         foreach (NotifierEventType::model()->findAllByPk($etIds) as $eventType) {
             $eventType->delete();
         }
     }
     unset($data['idEventTypeRecover'], $data['idEventSubscriberRecover'], $data['idEventTypeRegister']);
     //удаляем виджет авторизации
     $data = $this->deleteSiteModule($data['id_widget_authorize'], $data, 'widget_authorize_place');
     unset($data['id_widget_authorize']);
     $data['cabinetEnabled'] = false;
     $plugin->setData($data);
     $trans->commit();
 }
예제 #13
0
파일: Product.php 프로젝트: Cranky4/npfs
 public function behaviors()
 {
     //Берем конфигурацию из настроек модуля
     $config = HArray::val(Yii::app()->daShop->getModelConfig(__CLASS__), 'ImagePreview');
     return array('photos' => array('class' => 'PhotosBehavior', 'idObject' => $this->getIdObject()), 'ImagePreview' => CMap::mergeArray(array('class' => 'ImagePreviewBehavior', 'imageProperty' => 'mainPhoto', 'formats' => array('_list' => array('width' => 100), '_one' => array('width' => 300, 'height' => 300), '_offer' => array('width' => 50, 'height' => 50))), $config));
 }
예제 #14
0
파일: reviews.php 프로젝트: Cranky4/npfs
        ?>
</p>

                                                <p><?php 
        echo $review->city;
        ?>
</p>
                                            </div>
                                        </div>
                                    </div>
                                <?php 
    }
    ?>

                                <?php 
    if ($review = HArray::val($reviews, ++$i)) {
        ?>
                                    <div class="col-md-6 hidden-sm hidden-xs">
                                        <div class="copy center-block reviews">
                                            <div class="quote">
                                                <p><?php 
        echo $review->text;
        ?>
</p>
                                            </div>
                                            <div class="student">
                                                <div class="photo">
                                                    <?php 
        if ($src = $review->getPhotoPath()) {
            ?>
                                                        <?php 
예제 #15
0
 public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
 {
     $pathInfo .= '/';
     if (preg_match('~^page/([\\da-zA-Z\\-\\_]+)(.*)~', $pathInfo, $matches)) {
         $idObject = $matches[1];
         $remainUrl = $matches[2];
         self::$_currentUrlParams[self::PARAM_OBJECT] = $idObject;
         $idInstance = null;
         $idView = null;
         if (preg_match('~^page/[\\da-zA-Z\\-\\_]+/([\\d\\-]+|[a-zA-Z\\d\\_]+\\-[a-zA-Z\\d\\-\\_]+)(/.*)~', $pathInfo, $matches)) {
             $idInstance = trim($matches[1]);
             $remainUrl = $matches[2];
             if ($idInstance == '') {
                 $idInstance = null;
             }
         }
         if ($idInstance != null) {
             self::$_currentUrlParams[self::PARAM_OBJECT_INSTANCE] = $idInstance;
             $_GET[self::PARAM_OBJECT_INSTANCE] = $idInstance;
         }
         preg_match_all('~([a-zA-z\\-\\_0-9]+)/(.+?)(?:/|$)~', $remainUrl, $matches);
         if (is_array($matches) && is_array($matches[1]) && count($matches[1]) > 0) {
             $count = count($matches[1]);
             for ($i = 0; $i < $count; $i++) {
                 $param = $matches[1][$i];
                 if ($param == self::PARAM_OBJECT) {
                     continue;
                 }
                 $value = $matches[2][$i];
                 self::$_currentUrlParams[$param] = $value;
                 $_GET[$param] = $value;
             }
             $idView = HArray::val(self::$_currentUrlParams, self::PARAM_OBJECT_VIEW);
         }
         // пока тут определяем текущий объект и представление
         if ($idView != null) {
             $objectView = DaObjectView::model()->with('columns:onlyVisible')->findByPk($idView);
             if ($objectView == null) {
                 throw new CHttpException(404);
             }
             Yii::app()->backend->objectView = $objectView;
             Yii::app()->backend->object = DaObject::getById($objectView->id_object);
         } else {
             $object = DaObject::getById($idObject);
             if ($object == null || $object->table_name == null) {
                 throw new CHttpException(404);
             }
             Yii::app()->backend->object = $object;
             if ($object->object_type == DaObject::OBJECT_TYPE_CONTROLLER) {
                 return $object->table_name;
             }
             $cr = new CDbCriteria();
             $cr->addColumnCondition(array('t.id_object' => $idObject));
             $cr->order = 't.order_no';
             $objectView = DaObjectView::model()->with('columns:onlyVisible')->find($cr);
             if ($objectView == null) {
                 return false;
             }
             $objectView->object = $object;
             Yii::app()->backend->objectView = $objectView;
         }
         if ($idInstance != null || isset(self::$_currentUrlParams[self::PARAM_ACTION_VIEW])) {
             return BackendModule::ROUTE_INSTANCE_VIEW;
         }
         if (isset(self::$_currentUrlParams[self::PARAM_GROUP_OBJECT])) {
             return BackendModule::ROUTE_INSTANCE_LIST_GROUP;
         }
         return BackendModule::ROUTE_INSTANCE_LIST;
     }
     return false;
     // не применяем данное правило
 }
예제 #16
0
 public static function getProductsFromCookie()
 {
     if (ShopModule::$_productsCookie !== null) {
         return ShopModule::$_productsCookie;
     }
     $productsFromCookie = array();
     if (isset(Yii::app()->request->cookies[self::CART_COOKIE_NAME])) {
         $productsFromCookie = CJSON::decode(Yii::app()->request->cookies[self::CART_COOKIE_NAME]->value, true);
     }
     ShopModule::$_productsCookie = array();
     if (isset($productsFromCookie) && is_array($productsFromCookie)) {
         $cartProducts = Product::model()->with('category')->findAllByPk(HArray::column($productsFromCookie, 'id'));
         $collection = new DaActiveRecordCollection($cartProducts);
         foreach ($productsFromCookie as $productCookieItem) {
             $count = HArray::val($productCookieItem, 'count', 0);
             $idProduct = HArray::val($productCookieItem, 'id');
             if ($count == 0) {
                 continue;
             }
             $product = $collection->itemAt($idProduct);
             if ($product == null) {
                 continue;
             }
             //чтобы появилась возможность заполнять кастомные поля (поля, определенные прикладным программистом)
             //делаем массовое присваивание
             $product->scenario = 'cookie';
             unset($productCookieItem['id'], $productCookieItem['count']);
             $product->attributes = CMap::mergeArray(array('countInCart' => $count), $productCookieItem);
             ShopModule::$_productsCookie[] = $product;
         }
     }
     return ShopModule::$_productsCookie;
 }
예제 #17
0
 /**
  * Сбрасывает кеш дерева у модели
  * @param string $tableName
  */
 public function flushCache($tableName)
 {
     if (($cache = Yii::app()->{$this->cacheId}) instanceof ICache) {
         $cacheKeys = $cache->get($this->getCacheKeysKey());
         if ($cacheKeys !== false) {
             $tableCacheKeys = HArray::val($cacheKeys, $tableName, array());
             foreach ($tableCacheKeys as $key) {
                 unset($cache[$key]);
             }
         }
     }
 }
예제 #18
0
 public function getDateTimeForm($attribute)
 {
     return HArray::val($this->_dateTimes, $attribute);
 }