Copywrite 2014 to Present Day - Paul Smith (aka smiffy6969, razorcms)
Author: Paul Smith
Inheritance: extends RazorAPI
示例#1
0
	/**
	 * Function that collects connection info
	 * returns a Content list used for error handling (only on debugging mode)
	 * 
	 * @return ContentList
	 */
	private function getDebuggingContentList() {
		$contents = new ContentList ( "Server", $this->host );
		$contents->addContent ( "User", $this->user );
		$contents->addContent ( "Password", $this->password );
		$contents->addContent ( "Schema", $this->schema );
		$contents->addContent ( "MySQL Error", mysql_error () );
		return $contents;
	}
示例#2
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 6)));
$caseType = ContentList::getList($params);
Template::assign('caseType', $caseType);
Template::display('ht/module/case.tpl');
示例#3
0
$msg = '操作成功';
global $currentUserInfo;
$typeid = (int) $_REQUEST['typeid'];
$id = (int) $_REQUEST['id'];
switch ($act) {
    case 'update':
        $item = array('id' => $id, 'typeid' => $typeid, 'content' => stripslashes($_REQUEST['text']), 'title' => stripslashes($_REQUEST['title']), 'lang' => 'ch', 'itemtime' => time(), 'minimg' => stripslashes($_REQUEST['minimg']), 'maximg' => stripslashes($_REQUEST['maximg']));
        if ($id) {
            ContentList::update($item);
        } else {
            ContentList::add($item);
        }
        break;
    case 'delete':
        if ($id) {
            $result = ContentList::del(array('id' => $id));
            if ($result > 0) {
                $code = 0;
                $msg = "删除成功";
            } else {
                $code = 1;
                $msg = "删除失败";
            }
        } else {
            $code = 1;
            $msg = "无效的id";
        }
        break;
    default:
        $code = 1;
        $msg = '没有这个操作';
 public function actionSuggestContent()
 {
     ContentList::suggestContent();
 }
                                                  <?php 
echo CHtml::ajax(array('url' => array('dynamicTerms'), 'data' => array('q' => 'js:$(\'#content_type_box\').val()', 'lang' => 'js:$(\'#content_lang_box\').val()', 'YII_CSRF_TOKEN' => Yii::app()->getRequest()->getCsrfToken()), 'type' => 'post', 'dataType' => 'html', 'success' => "function(data)\n                                                    {\n                                                        \$('#term_id').empty();\n                                                        \$('#term_id').append(data);\n\n                                                    } "));
?>
                                            }

                                </script>
                                <?php 
echo $form->error($model, 'content_type');
?>
                            </div>
                            <div class="left" style="margin-left:20px">
                            <?php 
echo $form->labelEx($model, 'terms');
?>
                            <?php 
echo $form->listBox($model, 'terms', ContentList::getTerms(), array('id' => 'term_id', 'multiple' => 'multiple', 'style' => 'width:250px; height:100px', 'class' => 'listbox'));
?>
                            <?php 
echo $form->error($model, 'terms');
?>
                            </div>
                            <div class="left">
                            <?php 
echo $form->labelEx($model, 'tags');
?>
                            <?php 
$this->widget('CAutoComplete', array('model' => $model, 'mustMatch' => true, 'attribute' => 'tags', 'url' => array('suggestTags'), 'multiple' => true, 'htmlOptions' => array('size' => 50, 'style' => 'width:300px')));
?>

                            <?php 
echo $form->error($model, 'tags');
示例#6
0
 public static function getContentList($content_list_id, $max = null, $pagination = null, $return_type = ConstantDefine::CONTENT_LIST_RETURN_ACTIVE_RECORD)
 {
     //Find the content list model first
     $model = ContentList::model()->findbyPk($content_list_id);
     $condition = 't.object_status = :status and t.object_date < :time';
     $params = array(':status' => ConstantDefine::OBJECT_STATUS_PUBLISHED, ':time' => time());
     if (isset($model)) {
         if ($model->type == ConstantDefine::CONTENT_LIST_TYPE_AUTO) {
             //auto
             $criteria_field = 'object_date DESC';
             //object_type
             if (isset($model->content_type)) {
                 $content_types = $model->content_type;
                 if ($content_types[0] != 'all') {
                     $condition .= ' AND (0';
                     foreach ($content_types as $type) {
                         $condition .= ' or object_type="' . $type . '"';
                     }
                     $condition .= ')';
                 }
             }
             //terms
             if (isset($model->terms)) {
                 $content_terms = $model->terms;
                 if ($content_terms[0] != '0') {
                     $condition .= ' AND (0';
                     foreach ($content_terms as $term) {
                         $condition .= ' or (ID in (select object_id from `{{object_term}}` where term_id=' . $term . '))';
                     }
                     $condition .= ')';
                 }
             }
             //criteria not newest
             if ($model->criteria != ConstantDefine::CONTENT_LIST_CRITERIA_NEWEST) {
                 $criteria_field = 'object_view DESC';
             }
             if ($return_type == ConstantDefine::CONTENT_LIST_RETURN_DATA_PROVIDER && $model->number > 1) {
                 $sort = new CSort('Object');
                 $sort->defaultOrder = 't.object_date DESC';
                 $sort->attributes = array('object_view' => array('asc' => 'object_view ASC', 'desc' => 'object_view DESC'), 'object_date' => array('asc' => 't.object_date ASC', 'desc' => 't.object_date DESC'));
                 return new CActiveDataProvider('Object', array('criteria' => array('condition' => $condition, 'order' => $criteria_field, 'params' => $params, 'limit' => isset($max) ? $max : $model->number), 'pagination' => array('pageSize' => isset($max) ? $max : $model->number * $model->paging, 'pageVar' => 'page'), 'sort' => $sort));
             }
             return Object::model()->findAll(array('condition' => $condition, 'params' => $params, 'order' => $criteria_field, 'limit' => isset($max) ? $max : $model->number));
         }
         //manual
         if (isset($model->manual_list_id)) {
             $condition = '';
             $manual_list = explode(',', $model->manual_list_id);
             $count = 0;
             foreach ($manual_list as $manual_id) {
                 //$condition .= ' OR ID = '.$manual_id;
                 if ($count == 0) {
                     $condition = 'ID =' . $manual_id;
                 } else {
                     $condition .= ' union select * from {{object}} where id=' . $manual_id;
                 }
                 if (isset($max) && $count == $max) {
                     break;
                 }
                 $count++;
             }
             if ($return_type == ConstantDefine::CONTENT_LIST_RETURN_DATA_PROVIDER && count($manual_list) > 1) {
                 return new CActiveDataProvider('Object', array('criteria' => array('condition' => $condition, 'params' => $params), 'pagination' => array('pageSize' => isset($max) ? $max : $model->number * $model->paging, 'pageVar' => 'page')));
             }
             return Object::model()->findAll(array('condition' => $condition, 'params' => $params));
         }
     }
     return null;
 }
示例#7
0
<?php

//ini_set("display_errors" ,1 );
require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = 'zhao';
//搜索关键词
$indexSearch = ContentList::search($params);
Template::assign('indexType', $indexSearch);
Template::display('search.tpl');
        
      <iframe id='contentlist_iframe'  src="<?php 
echo Yii::app()->request->baseUrl;
?>
/contentlist/create/embed/iframe" frameborder="0" onLoad="autoResize(this);" height="30px" width="100%"></iframe>
</div>           
<script type="text/javascript">
     <?php 
if (is_array($block_model->content_list) && !empty($block_model->content_list)) {
    ?>
               
            
             <?php 
    $content_items = array();
    foreach ($block_model->content_list as $obj_id) {
        $temp_object = ContentList::model()->findByPk($obj_id);
        if ($temp_object) {
            $content_items['item_' . $temp_object->content_list_id]['id'] = $temp_object->content_list_id;
            $content_items['item_' . $temp_object->content_list_id]['title'] = $temp_object->name;
        }
    }
    echo 'var manual_content_list = ' . json_encode($content_items) . ';';
    ?>
                    $.each(manual_content_list, function(k,v) {                        
                             addContentList(v.title,v.id);              
                    }); 
                           
     <?php 
}
?>
         
示例#9
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 4)));
$honorType = ContentList::getList($params);
Template::assign('honorType', $honorType);
Template::display('ht/module/honor.tpl');
示例#10
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
Template::SetTitle('首页');
$params = array('condition' => array(), 'order' => array());
define('PAGE_SIZE', 1);
$p = intval($_GET["p"]) ? intval($_GET["p"]) : "1";
$offset = PAGE_SIZE * ($p - 1);
$indexType = ContentList::getList($params, $offset, PAGE_SIZE);
$totalcount = $indexType['count'];
$pager = new Pager(array('pageSize' => PAGE_SIZE, 'rowCount' => (int) $totalcount));
Template::assign('indexType', $indexType['list']);
Template::assign('pager', $pager->genYuan());
Template::assign('usernames', $usernames);
Template::display('pager.tpl');
示例#11
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 1)));
//echo json_encode(ContentList::getList($params));
$indextype = ContentList::getList($params);
ContentList::del($params);
Template::assign('indextype', $indextype);
Template::display('ht/module/index.tpl');
示例#12
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 8)));
$contactType = ContentList::getList($params);
Template::assign('contactType', $contactType);
Template::display('ht/module/contact.tpl');
示例#13
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$caseid = $_REQUEST['id'];
$params = array('condition' => array(array('id', $caseid)));
$caseDetail = ContentList::getList($params);
Template::assign('caseDetail', $caseDetail);
Template::display('ht/module/casedetail.tpl');
示例#14
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 2)));
$aboutType = ContentList::getList($params);
Template::assign('aboutType', $aboutType);
Template::display('ht/module/about.tpl');
示例#15
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 3)));
$directorType = ContentList::getList($params);
Template::assign('directorType', $directorType);
Template::display('ht/module/director.tpl');
示例#16
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 5)));
$brandType = ContentList::getList($params);
Template::assign('brandType', $brandType);
Template::display('ht/module/brand.tpl');
示例#17
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$params = array('condition' => array(array('typeid', 7)));
$worksType = ContentList::getList($params);
Template::assign('worksType', $worksType);
Template::display('ht/module/works.tpl');
示例#18
0
 /**
  * Function to get Object Content List
  **/
 public static function getContentList($cl_id, $max = null, $paging = null, $return_type = ConstantDefine::CONTENT_LIST_RETURN_ACTIVE_RECORD)
 {
     $model = ContentList::model()->findByPk($cl_id);
     //Find the content list model first
     $condition = 't.object_status = :status and t.object_date < :time';
     $params = array(':status' => ConstantDefine::OBJECT_STATUS_PUBLISHED, ':time' => time());
     if ($paging == 0) {
         $page_number = 1;
     } else {
         $page_number = $model->paging;
     }
     if (isset($model)) {
         if ($model->type == ConstantDefine::CONTENT_LIST_TYPE_AUTO) {
             //auto
             $criteria_field = 'object_date DESC';
             //object_type
             if (isset($model->content_type)) {
                 $content_types = $model->content_type;
                 if ($content_types[0] != 'all') {
                     $condition .= ' AND (0';
                     foreach ($content_types as $type) {
                         $condition .= ' or object_type="' . $type . '"';
                     }
                     $condition .= ')';
                 }
             }
             //terms
             if (isset($model->terms)) {
                 $content_terms = $model->terms;
                 if ($content_terms[0] != '0') {
                     $condition .= ' AND (0';
                     foreach ($content_terms as $term) {
                         $condition .= ' or (object_id in (select object_id from `{{object_term}}` where term_id=' . $term . '))';
                     }
                     $condition .= ')';
                 }
             }
             //tags
             if (isset($model->tags) && $model->tags != '') {
                 $tags = $model->tags;
                 $tag_list = explode(',', $tags);
                 $tag_id_list = '';
                 foreach ($tag_list as $k => $tag_name) {
                     if ($tag_name == ' ') {
                         unset($tag_list[$k]);
                     }
                 }
                 foreach ($tag_list as $k => $tag_name) {
                     if ($tag_name != ' ') {
                         $id = Yii::app()->db->createCommand()->select('id')->from('gxc_tag')->where('name=:name', array(':name' => trim($tag_name)))->queryRow();
                         $tag_id_list .= $id['id'];
                         if ($k != sizeof($tag_list) - 1) {
                             $tag_id_list .= ',';
                         }
                     }
                 }
                 $condition .= ' or (object_id in (select object_id from `{{tag_relationships}}` where tag_id in (' . $tag_id_list . ')))';
             }
             //criteria not newest
             if ($model->criteria != ConstantDefine::CONTENT_LIST_CRITERIA_NEWEST) {
                 $criteria_field = 'object_view DESC';
             }
             if ($return_type == ConstantDefine::CONTENT_LIST_RETURN_DATA_PROVIDER && $model->number >= 1) {
                 $sort = new CSort('Object');
                 $sort->defaultOrder = 't.object_date DESC';
                 $sort->attributes = array('object_view' => array('asc' => 'object_view ASC', 'desc' => 'object_view DESC'), 'object_date' => array('asc' => 't.object_date ASC', 'desc' => 't.object_date DESC'));
                 return new CActiveDataProvider('Object', array('criteria' => array('condition' => $condition, 'order' => $criteria_field, 'params' => $params, 'limit' => isset($max) ? $max : $model->number), 'pagination' => array('pageSize' => isset($max) ? $max : $model->number * $page_number, 'pageVar' => 'page'), 'sort' => $sort));
             }
             return Object::model()->findAll(array('condition' => $condition, 'params' => $params, 'order' => $criteria_field, 'limit' => isset($max) ? $max : $model->number));
         } else {
             //manual
             if (isset($model->manual_list)) {
                 $condition = '';
                 $manual_list = $model->manual_list;
                 $count = 0;
                 $max = count($manual_list);
                 foreach ($manual_list as $manual_id) {
                     if ($count == 0) {
                         $condition_string = $manual_id;
                     } else {
                         $condition_string .= ',' . $manual_id;
                     }
                     if (isset($max) && $count == $max) {
                         break;
                     }
                     $count++;
                 }
                 $condition = 'object_id IN (' . $condition_string . ')';
                 if ($return_type == ConstantDefine::CONTENT_LIST_RETURN_DATA_PROVIDER && count($manual_list) >= 1) {
                     return new CActiveDataProvider('Object', array('criteria' => array('condition' => $condition, 'params' => $params, 'order' => 'FIELD(t.object_id, ' . $condition_string . ')'), 'pagination' => array('pageSize' => isset($max) ? $max : $model->number * $page_number, 'pageVar' => 'page')));
                 }
                 return Object::model()->findAll(array('condition' => $condition, 'params' => $params, 'order' => 'FIELD(t.object_id, ' . $condition_string . ')'));
             }
         }
     }
     return null;
 }
示例#19
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../init.inc.php';
$worksid = $_REQUEST['id'];
$params = array('condition' => array(array('id', $worksid)));
$worksDetail = ContentList::getList($params);
Template::assign('worksDetail', $worksDetail);
Template::display('ht/module/worksdetail.tpl');