public function run() { $tags = Tag::model()->findAll(); if ($tags) { foreach ($tags as $tag) { $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name)); $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name)); $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name)); $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name)); if (!$post && !$image && !$soft && !$video) { $tag->delete(); } else { $tag->data_count = count($post) + count($image) + count($soft); $tag->save(); } } } $tagdatas = TagData::model()->findAll(); if ($tagdatas) { foreach ($tagdatas as $value) { $modelType = ModelType::model()->findByPk($value->type); $model = $modelType->model; $data = $model::model()->findByPk($value->content_id); if (!$data) { $value->delete(); } } } $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index')); }
public function findByModelName($modelName) { if (empty($modelName)) { throw new \Exception("Model name may not be empty"); } $model = $this->findSingleByAttribute('model_name', $modelName); if ($model) { return $model->id; } $model = new ModelType(); $model->model_name = $modelName; $model->save(); return $model->id; }
public function run() { $this->content_id = trim(Yii::app()->request->getParam('content_id')); $this->type_key = strtolower(trim(Yii::app()->request->getParam('type_key'))); $type = ModelType::model()->findByAttributes(array('type_key' => $this->type_key)); if (!$type) { $this->controller->message('error', Yii::t('admin', 'Invialid Content Type')); } if (!$this->content_id) { $this->controller->message('error', Yii::t('admin', 'Invialid Content')); } $this->type_id = $type->id; if (Yii::app()->request->isPostRequest) { //提交推荐 $this->submitData(); } //所有推荐位 $positionModel = new RecommendPosition(); $criteria = new CDbCriteria(); $criteria->order = 'id ASC'; //统计 $count = $positionModel->count($criteria); //分页 $pages = new CPagination($count); $pages->pageSize = 20; $pages->applyLimit($criteria); //查询 $result = $positionModel->findAll($criteria); $this->controller->render('create', array('model' => $positionModel, 'datalist' => $result, 'pagebar' => $pages)); }
public function init() { //栏目 parent::init(); $this->_catalog = Catalog::model()->findAll(); $this->_model_type = ModelType::model()->findAll(); }
public function init() { $this->_yii = Yii::app(); $this->_baseUrl = Yii::app()->baseUrl; $this->_basePath = Yii::app()->basePath; $this->_request = Yii::app()->request; $this->_fonts = ROOT_PATH . '/public'; $this->_data = ROOT_PATH . '/protected/data/'; $this->_static_public = $this->_baseUrl . '/public'; //检测系统是否已经安装 if (!file_exists($this->_data . '/install.lock')) { $this->redirect($this->createUrl('/install/step1')); } //后台全局设置 $settings = Setting::model()->findAll(); foreach ($settings as $row) { $this->_setting[$row['variable']] = $row['value']; } //内容模型id $model_types = ModelType::model()->findAll(); if ($model_types && is_array($model_types)) { foreach ($model_types as $tp) { $this->_type_ids[$tp->type_key] = $tp->id; } } //内容模型对象 $this->_content_models = ModelType::getContentModel(); }
public function run() { $model = new Comment(); //条件 $criteria = new CDbCriteria(); $type = trim(Yii::app()->request->getParam('type')); $type && $criteria->addColumnCondition(array('type' => $type)); $status = trim(Yii::app()->request->getParam('status')); $status && $criteria->addColumnCondition(array('status' => $status)); $title = trim(Yii::app()->request->getParam('content')); $title && $criteria->addSearchCondition('content', $title); $criteria->order = 't.id DESC'; $count = $model->count($criteria); //分页 $pages = new CPagination($count); $pages->pageSize = 10; $pages->applyLimit($criteria); //查询 $result = $model->findAll($criteria); //全部类型 $model_types = ModelType::model()->findAll(); Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css"); Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END); $this->controller->render('index', array('model' => $model, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages)); }
/** * 评论管理 * */ public function actionIndex() { $this->_model_type = ModelType::model()->findAll(); $model = new Comment(); $criteria = new CDbCriteria(); $condition = '1'; $status = $this->_request->getParam('status'); $title = $this->_request->getParam('postTitle'); $content = $this->_request->getParam('content'); $type = $this->_request->getParam('type') ? $this->_request->getParam('type') : $this->_type_ids['post']; $type && ($condition .= " AND type={$type}"); $status && ($condition .= " AND t.status='{$status}'"); $table = array_search($type, $this->_type_ids); if ($table == 'goods') { $title && ($condition .= " AND {$table}.goods_name LIKE '%{$title} %'"); } else { $title && ($condition .= " AND {$table}.title LIKE '%{$title} %'"); } $content && ($condition .= ' AND t.content LIKE \'%' . $content . '%\''); $criteria->condition = $condition; $criteria->order = 't.id DESC'; $criteria->with = array($table); $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 13; $pageParams = $this->buildCondition($_GET, array('postTitle', 'status', 'content', 'type')); $pages->params = is_array($pageParams) ? $pageParams : array(); $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END); $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'table' => $table)); }
function getModelType() { if ($this->mt === null) { $this->mt = ModelType::get_by_code($this->modelType); } return $this->mt; }
/** * 首页 */ public function actionIndex() { $catalog_id = trim($this->_request->getParam('catalog_id')); $keyword = trim($this->_request->getParam('keyword')); //获取子孙分类(包括本身) $data = Catalog::model()->getChildren($catalog_id); $catalog = $data['catalog']; $db_in_ids = $data['db_in_ids']; //SEO if ($catalog) { $this->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->_setting['site_name']; $this->_seoKeywords = $catalog->seo_keywords; $this->_seoDescription = $catalog->seo_description; $navs[] = array('url' => $this->createUrl('soft/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name); } else { $seo = ModelType::getSEO('goods'); $this->_seoTitle = $seo['seo_title'] . ' - ' . $this->_setting['site_name']; $this->_seoKeywords = $seo['seo_keywords']; $this->_seoDescription = $seo['seo_description']; $navs[] = array('url' => $this->_request->getUrl(), 'name' => $this->_seoTitle); } //获取所有符合条件的商品 $condition = ''; $catalog && ($condition .= ' AND catalog_id IN (' . $db_in_ids . ')'); $datalist = Goods::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages); //最新的商品 $last_goods = Goods::model()->getList(array('condition' => $condition, 'limit' => 10)); //加载css,js Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/list.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js"); $this->render('index', array('navs' => $navs, 'goods' => $datalist, 'pagebar' => $pages, 'last_goods' => $last_goods)); }
public function run() { $model = new ModelType(); //条件 $criteria = new CDbCriteria(); $type_name = trim(Yii::app()->request->getParam('type_name')); $type_name && $criteria->addSearchCondition('type_name', $type_name); $criteria->order = 't.id ASC'; $count = $model->count($criteria); //分页 $pages = new CPagination($count); $pages->pageSize = 10; $pages->applyLimit($criteria); //查询 $result = $model->findAll($criteria); $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages)); }
/** * 判断数据是否存在 * * return \$this->model */ public function loadModel() { if ($this->model === null) { if (isset($_GET['id'])) { $this->model = ModelType::model()->findbyPk($_GET['id']); } if ($this->model === null) { throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.')); } } return $this->model; }
function validateAdd($mt) { if (!$mt->code) { FlashMessage::add('Codul nu poate fi vid.'); } if (ModelType::get_by_code($mt->code)) { FlashMessage::add("Codul '{$mt->code}' este deja folosit."); } if (!$mt->description) { FlashMessage::add('Descrierea nu poate fi vidă. Ea trebuie să indice partea de vorbire și este vizibilă la afișarea paradigmelor.'); } return FlashMessage::getMessage() == null; }
public function run() { $parent_id = Yii::app()->request->getParam('id'); $children = Catalog::getChildren($parent_id); if ($children) { foreach ($children as $k => $v) { $result[$k] = array('id' => $v['id'], 'parent_id' => $v['parent_id'], 'name' => $v['catalog_name'], 'type' => ModelType::getTypeName($v['type']), 'layer' => $v['layer'], 'sort_order' => $v['sort_order'], 'create_time' => date('Y-m-d H:i', $v['create_time']), 'update_time' => date('Y-m-d H:i', $v['update_time']), 'children_url' => $this->controller->createUrl('catalog/children', array('id' => $v['id'])), 'update_url' => $this->controller->createUrl('catalog/update', array('id' => $v['id'])), 'delete_url' => $this->controller->createUrl('catalog/batch', array('command' => 'delete', 'id' => $v['id']))); } } else { $result = array(); } exit(CJSON::encode($result)); }
public function run() { $catalog_id = trim(Yii::app()->request->getParam('catalog_id')); $order = trim(Yii::app()->request->getParam('order')); if (!$order) { $order = 'id'; } switch ($order) { case 'id': $order_by = 't.id DESC'; break; case 'view_count': $order_by = 'view_count DESC'; break; default: $order = 'id'; $order_by = 't.id DESC'; break; } //SEO $navs = array(); $search_cats = '所有'; if ($catalog_id) { $condition = ' AND catalog_id = ' . $catalog_id; $catalog = Catalog::model()->findByPk($catalog_id); if ($catalog) { $this->controller->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->controller->_setting['site_name']; $this->controller->_seoKeywords = $catalog->seo_keywords; $this->controller->_seoDescription = $catalog->seo_description; $navs[] = array('url' => $this->controller->createUrl('image/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name); //已搜索的分类 $cat_parents = Catalog::getParantsCatalog($catalog_id); $search_cats = $cat_parents ? implode('>', $cat_parents) . '>' . $catalog->catalog_name : $catalog->catalog_name; } } if (!$navs) { $condition = ''; $catalog = array(); $seo = ModelType::getSEO('image'); $this->controller->_seoTitle = $seo['seo_title'] . ' - ' . $this->controller->_setting['site_name']; $this->controller->_seoKeywords = $seo['seo_keywords']; $this->controller->_seoDescription = $seo['seo_description']; $navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $this->controller->_seoTitle); } //获取所有符合条件的图集 $pages = array(); $datalist = Image::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages); //该栏目下最新的图集 $last_images = Image::model()->getList(array('condition' => $condition, 'limit' => 10)); $this->controller->render('index', array('navs' => $navs, 'catalog' => $catalog, 'datalist' => $datalist, 'pagebar' => $pages, 'last_images' => $last_images, 'order' => $order, 'search_cats' => $search_cats)); }
/** * 首页 */ public function actionIndex() { $catalog_id = trim($this->_request->getParam('catalog_id')); $order = trim($this->_request->getParam('order')); $keyword = trim($this->_request->getParam('keyword')); if (!$order) { $order = 'id'; } switch ($order) { case 'id': $order_by = 't.id DESC'; break; case 'view_count': $order_by = 'view_count DESC'; break; default: $order = 'id'; $order_by = 't.id DESC'; break; } //获取子孙分类(包括本身) $data = Catalog::model()->getChildren($catalog_id); $catalog = $data['catalog']; $db_in_ids = $data['db_in_ids']; //SEO $navs = array(); if ($catalog) { $this->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->_setting['site_name']; $this->_seoKeywords = $catalog->seo_keywords; $this->_seoDescription = $catalog->seo_description; $navs[] = array('url' => $this->createUrl('post/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name); } else { $seo = ModelType::getSEO('post'); $this->_seoTitle = $seo['seo_title'] . ' - ' . $this->_setting['site_name']; $this->_seoKeywords = $seo['seo_keywords']; $this->_seoDescription = $seo['seo_description']; $navs[] = array('url' => $this->_request->getUrl(), 'name' => $this->_seoTitle); } //获取所有符合条件的文章 $condition = ''; $catalog && ($condition .= ' AND catalog_id IN (' . $db_in_ids . ')'); $datalist = Post::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages); //该栏目下最新的文章 $last_posts = Post::model()->getList(array('condition' => $condition, 'limit' => 10)); //加载css,js Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/list.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js"); $this->render('index', array('navs' => $navs, 'catalog' => $catalog, 'posts' => $datalist, 'pagebar' => $pages, 'tags' => $tags, 'last_posts' => $last_posts, 'order' => $order)); }
public function run() { $tags = preg_replace('/(\\s)+/', ',', trim(Yii::app()->request->getParam('tag'))); $tag_ids = array(); if ($tags) { $arr_tag = explode(',', $tags); foreach ($arr_tag as $tag) { $t = Tag::model()->find('tag_name = :tn', array(':tn' => $tag)); $t && ($tag_ids[] = $t->id); } } else { $alltags = Tag::model()->findAll(array('order' => 'data_count')); foreach ((array) $alltags as $tv) { $tag_ids[] = $tv->id; } } if (!$tag_ids) { throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.')); } $datas = array(); $td = new TagData(); $criteria = new CDbCriteria(); $criteria->addColumnCondition(array('status' => 'Y')); $criteria->addInCondition('tag_id', $tag_ids); $criteria->group = 'content_id, type'; //分页 $count = $td->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $tddata = $td->findAll($criteria); if ($tddata) { foreach ($tddata as $value) { $modelType = ModelType::model()->findByPk($value->type); $model = $modelType->model; $value['type'] = $modelType->type_key; $value['data'] = $model::model()->findByPk($value->content_id); if ($value['data']) { $datas[] = $value; } } } //SEO $this->controller->_seoTitle = $tags ? $tags . ' - ' . $this->controller->_setting['site_name'] : '所有标签 - ' . $this->controller->_setting['site_name']; $navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $tags ? $tags : '所有标签'); $this->controller->render('index', array('navs' => $navs, 'datas' => $datas, 'pagebar' => $pages, 'tags' => $tags)); }
public function run() { $tags = preg_replace('/(\\s)+/', ',', trim(Yii::app()->request->getParam('tag'))); $tag_ids = array(); if ($tags) { $arr_tag = explode(',', $tags); foreach ($arr_tag as $tag) { $t = Tag::model()->find('tag_name = :tn', array(':tn' => $tag)); $t && ($tag_ids[] = $t->id); } } else { $alltags = Tag::model()->findAll(array('order' => 'data_count')); foreach ((array) $alltags as $tv) { $tag_ids[] = $tv->id; } } $ajax = Yii::app()->request->getParam('ajax'); $data = array(); $searchData = array(); if ($tag_ids && $ajax == 1) { $td = new TagData(); $condition = "status = 'Y'"; $criteria = new CDbCriteria(); $criteria->condition = $condition; $criteria->addInCondition('tag_id', $tag_ids); //分页 $count = $td->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $tddata = $td->findAll($criteria); foreach ((array) $tddata as $value) { $modelType = ModelType::model()->findByPk($value->type); $model = $modelType->model; $c = $model::model()->findByPk($value->content_id, array('select' => 'id,title')); if ($c) { $data[] = array('type' => $modelType->type_key, 'data' => $c); } } foreach ($data as $key => $new) { $searchData[$key]['url'] = $this->controller->createUrl("{$new['type']}/view", array('id' => $new['data']['id'])); $searchData[$key]['title'] = $new['data']['title']; } } exit(CJSON::encode($searchData)); }
public function run() { $ids = Yii::app()->request->getParam('id'); $command = Yii::app()->request->getParam('command'); empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select')); if (!is_array($ids)) { $ids = array($ids); } $criteria = new CDbCriteria(); $criteria->addInCondition('id', $ids); switch ($command) { case 'show': //显示 ModelType::model()->updateAll(['status' => Reply::STATUS_SHOW], $criteria); break; case 'hide': //隐藏 ModelType::model()->updateAll(['status' => Reply::STATUS_HIDE], $criteria); break; default: $this->controller->message('error', Yii::t('admin', 'Error Operation')); } $this->controller->message('success', Yii::t('admin', 'Batch Operate Success')); }
/** * 更新统计数据 * * @param array $contents * @param string $count_field */ private function _updateLinkData($contents = array(), $count_field = '') { $model_type = new ModelType(); var_dump($contents); foreach ($contents as $c) { $type = $model_type->findByPk($c->type); if ($type && $count_field) { $type_name = ucfirst($type->type_key); $content_mod = new $type_name(); $cur_post = $content_mod->findByPk($c->cid); if ($cur_post->{$count_field} > 0) { $content_mod->updateCounters(array($count_field => -1), 'id=:id', array('id' => $c->cid)); } } } }
} else { $l = Lexem::create($m->exponent, $modelType, $m->number, ''); $l->isLoc = true; $paradigm = getNewForms($l, $locVersion); } $lexems[] = $l; $paradigms[] = $paradigm; } smarty_assign('modelsToDisplay', $modelsToDisplay); smarty_assign('lexems', $lexems); smarty_assign('paradigms', $paradigms); } else { smarty_assign('selectedLocVersion', $locVersions[0]->name); // LocVersion::changeDatabase($locVersion); } $modelTypes = ModelType::loadCanonical(); $models = FlexModel::loadByType($modelType ? $modelType : $modelTypes[0]->code); smarty_assign('page_title', 'Modele de flexiune'); smarty_assign('locVersions', $locVersions); smarty_assign('modelTypes', $modelTypes); smarty_assign('models', $models); smarty_displayCommonPageWithSkin('modele-flexiune.ihtml'); /*************************************************************************/ /** * Load the forms to display for a model when a lexem already exists. This code is specific to each LOC version. */ function getExistingForms($lexemId, $locVersion) { if ($locVersion >= '5.0') { return InflectedForm::loadByLexemIdMapByInflectionRank($lexemId); } else {
$models[] = $m; $models[] = FlexModel::create('MF', $modelNumber, '', $m->exponent); } else { $models[] = Model::factory('FlexModel')->where('modelType', $modelType)->where('number', $modelNumber)->find_one(); } } $hasInvariableModel = $hasInvariableModel || $modelType == 'I'; } } // Always add the Invariable model if (!$hasInvariableModel) { $models[] = Model::factory('FlexModel')->where('modelType', 'I')->where('number', '1')->find_one(); } $modelTypes = array(); foreach ($models as $m) { $modelTypes[] = ModelType::get_by_code($m->modelType); } $lexems = Model::factory('Lexem')->table_alias('l')->select('l.*')->join('LexemModel', 'lm.lexemId = l.id', 'lm')->where('lm.modelType', 'T')->where_like('l.reverse', "{$reverseSuffix}%")->order_by_asc('l.formNoAccent')->limit(20)->find_many(); // $lmMatrix[$i][$j] = lexem model (with inflected forms) for lexem $i and model $j $lmMatrix = array(); foreach ($lexems as $l) { $lm = $l->getFirstLexemModel(); $lmArray = array(); foreach ($models as $m) { // Force a reload $lm = LexemModel::get_by_id($lm->id); $lm->modelType = $m->modelType; $lm->modelNumber = $m->number; $lm->generateInflectedFormMap(); $lmArray[] = $lm; }
<?php require_once "../phplib/util.php"; define('MODEL_TYPE', 'SP'); define('MODEL_TYPE_DESCRIPTION', 'Substantiv propriu'); $INFLECTIONS = array(1 => 'Substantiv propriu, Nominativ-Acuzativ, singular, nearticulat', 2 => 'Substantiv propriu, Genitiv-Dativ, singular, nearticulat', 3 => 'Substantiv propriu, Nominativ-Acuzativ, plural, nearticulat', 4 => 'Substantiv propriu, Genitiv-Dativ, plural, nearticulat', 5 => 'Substantiv propriu, Nominativ-Acuzativ, singular, articulat', 6 => 'Substantiv propriu, Genitiv-Dativ, singular, articulat', 7 => 'Substantiv propriu, Nominativ-Acuzativ, plural, articulat', 8 => 'Substantiv propriu, Genitiv-Dativ, plural, articulat'); /** Also, don't forget to edit templates/common/paradigm/current/paradigm.ihtml accordingly. **/ $existingMT = ModelType::get_by_code(MODEL_TYPE); if ($existingMT) { die('Tipul de model ' . MODEL_TYPE . " există deja.\n"); } $mt = Model::factory('ModelType')->create(); $mt->code = MODEL_TYPE; $mt->description = MODEL_TYPE_DESCRIPTION; $mt->canonical = MODEL_TYPE; $mt->save(); foreach ($INFLECTIONS as $rank => $description) { $i = Model::factory('Inflection')->create(); $i->description = $description; $i->modelType = MODEL_TYPE; $i->rank = $rank; $i->save(); } $m = Model::factory('FlexModel')->create(); $m->modelType = MODEL_TYPE; $m->number = '1'; $m->description = ''; $m->exponent = 'exponent'; $m->flag = 0; $m->save();
/** * 批量操作 * */ public function actionBatch() { if ($this->method() == 'GET') { $command = trim($_GET['command']); $ids = intval($_GET['id']); } else { if ($this->method() == 'POST') { $command = trim($_POST['command']); $ids = $_POST['id']; } else { $this->message('errorBack', Yii::t('admin', 'Only POST Or GET')); } } empty($ids) && $this->message('error', Yii::t('admin', 'No Select')); switch ($command) { case 'show': foreach ((array) $ids as $id) { $model = ModelType::model()->findByPk($id); if ($model) { $model->status = 'Y'; $model->save(); } } break; case 'hidden': foreach ((array) $ids as $id) { $model = ModelType::model()->findByPk($id); if ($model) { $model->status = 'N'; $model->save(); } } break; default: throw new CHttpException(404, Yii::t('admin', 'Error Operation')); break; } $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index')); }
/** * Get the model to which this reminder belongs. A reminder can belong to an Event or Task for example. * * @return \GO\Base\Db\ActiveRecord|boolean */ public function getRelatedModel() { if (!$this->model_type_id || !$this->model_id) { return false; } $modelType = ModelType::model()->findByPk($this->model_type_id); $model = \GO::getModel($modelType->model_name)->findByPk($this->model_id); return $model; }
/** * ajax搜索 */ public function actionAjax() { $tags = trim($this->_request->getParam('tag')); $tags = preg_replace('/(\\s)+/', ',', trim($tags)); $arr_tag = explode(',', $tags); foreach ((array) $arr_tag as $tag) { $t = Tag::model()->find('tag_name = :tn', array(':tn' => $tag)); $t && ($tag_ids[] = $t->id); } $ajax = $this->_request->getParam('ajax'); $data = array(); $searchData = array(); if ($tag_ids && $ajax == 1) { $td = new TagData(); $condition = "status = 'Y'"; $criteria = new CDbCriteria(); $criteria->condition = $condition; $criteria->addInCondition('tag_id', $tag_ids); //分页 $count = $td->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $tddata = $td->findAll($criteria); foreach ((array) $tddata as $value) { $modelType = ModelType::model()->findByPk($value->type); $model = $modelType->model; $value['type'] = $modelType->type_key; $value['data'] = $model::model()->findByPk($value->content_id, '', array('select' => 'id,title')); $data[] = $value; } foreach ($data as $key => $new) { $searchData[$key]['url'] = $this->createUrl("{$new->type}/view", array('id' => $new->data->id)); $searchData[$key]['title'] = $new->data->title; } } exit(CJSON::encode($searchData)); }
<?php require_once "../phplib/util.php"; setlocale(LC_ALL, "ro_RO.utf8"); DebugInfo::disable(); $locVersion = util_getRequestParameter('locVersion'); $modelType = util_getRequestParameter('modelType'); $modelType = ModelType::get_by_code($modelType); // Use the ModelType object from this point on if (!$locVersion || !$modelType) { FlashMessage::add('Date incorecte'); util_redirect('scrabble'); } LocVersion::changeDatabase($locVersion); $models = FlexModel::loadByType($modelType->code); $lexemModels = array(); foreach ($models as $m) { $lexemModels[] = getLexemModel($m->exponent, $modelType->code, $m->number); } SmartyWrap::addCss('paradigm'); SmartyWrap::assign('page_title', 'Modele de flexiune'); SmartyWrap::assign('models', $models); SmartyWrap::assign('lexemModels', $lexemModels); SmartyWrap::assign('locVersion', $locVersion); SmartyWrap::assign('modelType', $modelType); SmartyWrap::display('modele-flexiune.ihtml'); /*************************************************************************/ /** * Returns a LexemModel for a given word and model. Creates one if one doesn't exist. **/ function getLexemModel($form, $modelType, $modelNumber)
<?php require_once "../../phplib/util.php"; ini_set('memory_limit', '512M'); ini_set('max_execution_time', '3600'); util_assertModerator(PRIV_LOC); util_assertNotMirror(); DebugInfo::disable(); $modelType = util_getRequestParameter('modelType'); $modelNumber = util_getRequestParameter('modelNumber'); $previewButton = util_getRequestParameter('previewButton'); $confirmButton = util_getRequestParameter('confirmButton'); $modelType = ModelType::canonicalize($modelType); $inflections = Model::factory('Inflection')->where('modelType', $modelType)->order_by_asc('rank')->find_many(); // Load the original data $model = Model::factory('FlexModel')->where('modelType', $modelType)->where('number', $modelNumber)->find_one(); $exponent = $model->exponent; $lexem = Lexem::create($exponent, $modelType, $modelNumber, ''); $ifs = $lexem->generateParadigm(); $mdMap = ModelDescription::getByModelIdMapByInflectionIdVariantApplOrder($model->id); $forms = array(); foreach ($inflections as $infl) { $forms[$infl->id] = array(); } foreach ($ifs as $if) { $forms[$if->inflectionId][] = array('form' => $if->form, 'isLoc' => $mdMap[$if->inflectionId][$if->variant][0]->isLoc, 'recommended' => $mdMap[$if->inflectionId][$if->variant][0]->recommended); } $participleNumber = $modelType == 'V' ? ParticipleModel::loadByVerbModel($modelNumber)->adjectiveModel : ''; if ($previewButton || $confirmButton) { // Load the new forms and exponent; $newModelNumber = util_getRequestParameter('newModelNumber');
?> <tr class="tb_list"> <td ><input type="checkbox" name="id[]" value="<?php echo $row->id; ?> "> <?php echo $row->id; ?> </td> <td ><?php echo $row->recommend_name; ?> </td> <td ><?php $type = ModelType::model()->findByPk($row->type); echo $type->type_name; ?> </td> <td > <a href="<?php echo $this->createUrl('Update', array('id' => $row->id)); ?> "><img src="<?php echo $this->module->assetsUrl; ?> /images/update.png" align="absmiddle" /></a> <a href="<?php echo $this->createUrl('batch', array('command' => 'Delete', 'id' => $row->id)); ?> " class="confirmSubmit"><img src="<?php
if ($submitButton) { // Re-rank the inflections according to the order in $inflectionIds $modelTypeMap = array(); foreach ($inflectionIds as $inflId) { $infl = Inflection::get_by_id($inflId); $rank = array_key_exists($infl->modelType, $modelTypeMap) ? $modelTypeMap[$infl->modelType] + 1 : 1; $modelTypeMap[$infl->modelType] = $rank; $infl->rank = $rank; $infl->save(); } // Add a new inflection if one is given if ($newDescription) { $infl = Model::factory('Inflection')->create(); $infl->description = $newDescription; $infl->modelType = $newModelType; $infl->rank = $modelTypeMap[$newModelType] + 1; $infl->save(); } util_redirect('flexiuni'); } // Tag inflections which can be safely deleted (only those that aren't being used by any model) $inflections = Model::factory('Inflection')->order_by_asc('modelType')->order_by_asc('rank')->find_many(); $usedInflectionIds = db_getArray('select distinct inflectionId from ModelDescription'); foreach ($inflections as $infl) { $infl->canDelete = !in_array($infl->id, $usedInflectionIds); } SmartyWrap::assign('suggestHiddenSearchForm', true); SmartyWrap::assign('inflections', $inflections); SmartyWrap::assign('modelTypes', ModelType::loadCanonical()); SmartyWrap::addJs('jqTableDnd'); SmartyWrap::display('flexiuni.tpl');
public function run() { $controller = $this->getController(); $op = Yii::app()->request->getParam('op'); $ids = Yii::app()->request->getParam('id'); $uid = Yii::app()->user->id; $res = false; //操作状态 $count = true; //是否需要统计 $count_field = ''; //统计数据的字段名 $action = ''; //要返回的action名 if (!$uid) { $message = Yii::t('common', 'You Need Login'); } else { if (!$ids) { $message = Yii::t('common', 'Operation Failed'); } else { switch ($op) { case 'collect': $collect_mod = new Collect(); //检测是否是自己收藏的 foreach ((array) $ids as $k => $id) { $tmp = $collect_mod->findByPk($id); if ($tmp->user_id != $uid) { unset($ids[$k]); } else { $content[] = $collect_mod->findByPk($id); } } $collect_mod->deleteByPk($ids); $res = true; $count_field = 'favorite_count'; $action = 'mycollect'; break; case 'attention': $attention_mod = new Attention(); //检测是否是自己关注的 foreach ((array) $ids as $k => $id) { $tmp = $attention_mod->findByPk($id); if ($tmp->user_id != $uid) { unset($ids[$k]); } else { $content[] = $attention_mod->findByPk($id); } } $attention_mod->deleteByPk($ids); $res = true; $count_field = 'attention_count'; $action = 'myattention'; break; case 'friend': $friend_mod = new Friend(); //检测是否是自己的好友 foreach ((array) $ids as $k => $id) { $tmp = $friend_mod->findByPk($id); if ($tmp->uid1 != $uid && $tmp->uid2 != $uid) { unset($ids[$k]); } } $friend_mod->deleteByPk($ids); $res = true; $count = false; $action = 'myfriends'; break; default: break; } if ($res) { $message = Yii::t('common', 'Cancel Success'); if ($count && $content) { //减少统计数据 $model_type = new ModelType(); foreach ($content as $c) { $type = $model_type->findByPk($c->type); $type_name = ucfirst($type->type_key); if ($type_name && $c && $count_field) { $content_mod = new $type_name(); $cur_post = $content_mod->findByPk($c->cid); if ($cur_post->{$count_field} > 0) { $content_mod->updateCounters(array($count_field => -1), 'id=:id', array('id' => $c->cid)); } } } } } else { $message = Yii::t('common', 'Operation Failed'); } } } //用setFlash提示信息(类似alert) $controller->layout = false; Yii::app()->user->setFlash($res ? 'success' : 'error', $message); $controller->redirect($controller->createUrl('user/' . $action)); }