示例#1
0
    public function run()
    {
        //begin form
        echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'class' => $this->class));
        foreach ($this->model as $item) {
            if ($this->selector) {
                echo CHtml::checkBox('selector_' . $item['key']);
            }
            $name = Awecms::generateFriendlyName($item["key"]);
            ?>
            <div class="settings row">
                <?php 
            echo $this->getlabel($item['key']);
            switch ($item['type']) {
                //add new types here
                case 'textfield':
                    echo $this->getFullTextField($item);
                    break;
                case 'boolean':
                    echo CHtml::hiddenField($item['key'], 0);
                    echo CHtml::checkBox($item['key'], $item['value']);
                    break;
                case 'image_url':
                    echo $this->getFullTextField($item);
                    echo "<a class=\"right\" href=\"{$item["value"]}\" target=\"_blank\"><img src=\"{$item["value"]}\" title=\"{$name}\" alt=\"{$name}\" /></a>";
                    break;
                case 'email':
                    echo $this->getFullTextField($item);
                    break;
                case 'textarea':
                    echo CHtml::textArea($item['key'], $item['value']);
                case 'NULL':
                    break;
                default:
                    echo "Unsupported type: " . $item['type'] . " of " . $item['key'] . " with value " . $item['value'] . "<br/>";
                    break;
            }
            if (isset($item['hint'])) {
                ?>
                    <p class="hint">
                        <?php 
                echo $item['hint'];
                ?>
                    </p>
                    <?php 
            }
            ?>

            </div>
            <?php 
        }
        ?>
        <div class="row buttons">
            <?php 
        echo CHtml::submitButton('Submit!');
        ?>
        </div>
        <?php 
        echo CHtml::endForm();
    }
示例#2
0
 public function getTree()
 {
     $allCategories = BusinessCategory::model()->findAll();
     $whole = Awecms::buildTree(Awecms::quickSort($allCategories));
     $part = self::getNode($whole, $this->id);
     //        print_r($part);
     //        die();
     return array($part);
 }
示例#3
0
 public function actionListImages()
 {
     $uploadPath = Yii::app()->basePath . '/../uploads/';
     if (Settings::get('gallery', 'upload_path')) {
         $uploadPath = '/' . trim(Settings::get('gallery', 'upload_path'), '/') . '/';
     }
     $array = Awecms::rglob($uploadPath, '*.{jpg,png,gif}', GLOB_BRACE);
     echo stripslashes(json_encode($array));
 }
示例#4
0
文件: Menu.php 项目: awecode/awecms
 public function getThemes()
 {
     $themeDirs = array_map('basename', glob(Yii::getPathOfAlias('menu.assets.frontend.themes') . '/*', GLOB_ONLYDIR));
     $return = array();
     foreach ($themeDirs as $item) {
         $return[$item] = Awecms::generateFriendlyName($item);
     }
     return $return;
 }
示例#5
0
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     $page = $model->page;
     //set page title
     Yii::app()->getController()->pageTitle = $page->title . Awecms::getTitlePrefix();
     //increase view count
     $model->increaseViewCount();
     $this->render('view', array('model' => $model));
 }
示例#6
0
 public function actionView($id)
 {
     $page = $this->loadModel($id);
     //set page title
     Yii::app()->getController()->pageTitle = $page->title . Awecms::getTitlePrefix();
     if (Yii::app()->hasModule('tag') && Settings::get('SEO', 'use_page_tags_for_keywords')) {
         $this->pageKeywords = implode(', ', $page->getTags());
     }
     //increase view count
     $page->increaseViewCount();
     $this->render('view', array('page' => $page));
 }
示例#7
0
 public function actionView($id)
 {
     $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.modules.event.assets'));
     Yii::app()->getClientScript()->registerCssFile($baseUrl . '/events.css');
     $model = $this->loadModel($id);
     $page = $model->page;
     //set page title
     Yii::app()->getController()->pageTitle = $page->title . Awecms::getTitlePrefix();
     //increase view count
     $model->increaseViewCount();
     $this->render('view', array('model' => $model));
 }
示例#8
0
 public function showSettings($actionID)
 {
     if (!empty($_POST)) {
         Settings::set($actionID, Awecms::removeMetaFromPost($_POST));
         $selections = Awecms::getSelections($_POST);
         if (count($selections)) {
             Settings::delete($actionID, $selections);
         }
     }
     $this->layout = 'main';
     $dataProvider = array('settings' => Settings::get($actionID), 'action' => $actionID);
     $this->render('index', $dataProvider);
 }
示例#9
0
 public function actionView($id)
 {
     $this->webpageType = 'ImageGallery';
     $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.modules.gallery.assets'));
     Yii::app()->getClientScript()->registerCssFile($baseUrl . '/gallery.css');
     $images = Image::model()->findAllByAttributes(array('album_id' => $id));
     $model = $this->loadModel($id);
     $page = $model->page;
     //set page title
     Yii::app()->getController()->pageTitle = $page->title . Awecms::getTitlePrefix();
     //increase view count
     $model->increaseViewCount();
     $this->render('view', array('model' => $model, 'images' => $images));
 }
示例#10
0
 public function actionIndex()
 {
     $feed_title = Awecms::getSiteName();
     $feed_description = Settings::get('site', 'tagline');
     //provide model name or array of models, implementing page behavior
     $pageModels = array('Page', 'News', Event::model()->findAll());
     //for models other than implementing Page behavior
     $otherModels = array(array('Album', 'title', 'content', '/gallery/album/view/id/{id}'), array('Business', 'title', 'content', '/directory/business/view/id/{id}'), array('Image', 'title', 'description', '/gallery/image/view/id/{id}'));
     foreach ($otherModels as $otherModel) {
         $link = isset($otherModel[3]) ? $otherModel[3] : NULL;
         $this->addToFeed($otherModel[0], $otherModel[1], $otherModel[2], $link);
     }
     foreach ($pageModels as $model) {
         $this->addToFeed($model, 'title', 'content');
     }
     // generate and render RSS feed
     $feed = Zend_Feed::importArray(array('title' => $feed_title, 'description' => $feed_description, 'link' => $this->createUrl(''), 'charset' => 'UTF-8', 'generator' => 'AweCMS', 'entries' => $this->entries), 'rss');
     $feed->send();
 }
示例#11
0
 public static function getLinkForModules()
 {
     //modules to ignore
     $ignoreToList = array('admin');
     $ignoreToLink = array('mail', 'eauth');
     $r = array();
     foreach (Yii::app()->metadata->getModules() as $module) {
         $item = array();
         if (in_array($module, $ignoreToList)) {
             continue;
         }
         $item['label'] = Awecms::generateFriendlyName($module);
         if (!in_array($module, $ignoreToLink)) {
             $item['url'] = '/' . $module;
         }
         $r[] = $item;
     }
     return $r;
 }
示例#12
0
文件: Share.php 项目: awecode/awecms
 public function run()
 {
     $iconsDir = Yii::app()->assetManager->publish(__DIR__ . DIRECTORY_SEPARATOR . 'icons', false, -1);
     $rep = array('url' => $this->url, 'text' => $this->text, 'via' => $this->via);
     foreach ($this->networks as $name => $network) {
         if (!in_array(strtolower($name), array_map('strtolower', $this->shareTo))) {
             continue;
         }
         $url = str_replace(array_map('self::maskit', array_keys($rep)), array_values($rep), $network['format']);
         if (Awecms::isUrl($network['icon'])) {
             $icon = $network['icon'];
         } else {
             $icon = $iconsDir . '/' . $network['icon'];
         }
         $str = '<a href="' . $url . '"';
         if ($this->openInNewTab) {
             $str .= ' target="_blank"';
         }
         $str .= 'title="' . $network['tip'] . '"><img src="' . $icon . '" alt="' . $name . '"></a>';
         echo $str;
     }
     parent::run();
 }
示例#13
0
 public function actionUpdate($id)
 {
     $assetsUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/../assets/');
     Yii::app()->getClientScript()->registerScriptFile($assetsUrl . '/accessForm.js');
     $model = new Access();
     $model = $this->loadModel($id);
     if (isset($_POST['Access'])) {
         $model->setAttributes($_POST['Access']);
         if (isset($_POST['Access']['roles'])) {
             $model->roles = $_POST['Access']['roles'];
         } else {
             $model->roles = array();
         }
         try {
             if ($model->save()) {
                 if (isset($_GET['returnUrl'])) {
                     $this->redirect($_GET['returnUrl']);
                 } else {
                     $this->redirect(array('/role/access'));
                 }
             }
         } catch (Exception $e) {
             $model->addError('', $e->getMessage());
         }
     }
     //if module is selected from drop down, set it to model and nullify controller from old module
     if (isset($_GET['module'])) {
         $model->module = $_GET['module'];
         $controllers = Awecms::getControllers($model->module);
         $model->controller = reset($controllers);
     }
     //if controller is selected from dropdown set it to model
     if (isset($_GET['controller'])) {
         $model->controller = $_GET['controller'];
     }
     $this->render('update', array('model' => $model));
 }
示例#14
0
文件: view.php 项目: awecode/awecms
?>
 $this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes' => array(
<?php 
foreach ($this->tableSchema->columns as $column) {
    if ($column->isForeignKey) {
        echo "\t\tarray(\n";
        echo "\t\t\t'name'=>'{$column->name}',\n";
        foreach ($this->relations as $key => $relation) {
            if (($relation[0] == "CHasOneRelation" || $relation[0] == "CBelongsToRelation") && $relation[2] == $column->name) {
                $relatedModel = CActiveRecord::model($relation[1]);
                $identificationColumn = AweCrudCode::getIdentificationColumnFromTableSchema($relatedModel->tableSchema);
                $controller = $this->resolveController($relation);
                $value = "(\$model->{$key} !== null)?";
                $primaryKey = Awecms::getPrimaryKeyColumn($relatedModel);
                $value .= "CHtml::link(\$model->{$key}->{$identificationColumn}, array('{$controller}/view','{$primaryKey}'=>\$model->{$key}->{$primaryKey})).' '";
                //$value .= ".CHtml::link(Yii::t('app','Update'), array('{$controller}/update','{$relatedModel->tableSchema->primaryKey}'=>\$model->{$key}->{$relatedModel->tableSchema->primaryKey}), array('class'=>'edit'))";
                $value .= ":'n/a'";
                echo "\t\t\t'value'=>{$value},\n";
                echo "\t\t\t'type'=>'html',\n";
                break;
            }
        }
        echo "\t\t),\n";
    } else {
        echo $this->getDetailViewAttribute($column);
    }
}
echo ")));";
echo "?>";
示例#15
0
文件: main.php 项目: awecode/awecms
//                    'panels' => AdminModule::getDashboardMenu(),
//                    'options' => array(
//                        'collapsible' => true,
//                        'active' => 0,
//                        'animated' => 'slide',
//                        'navigation' => true,
//                        'collapsible' => false,
//                    ),
//                    'htmlOptions' => array(
//                        'style' => 'width:220px;'
//                    ),
//                ));
?>
        <?php 
$this->beginWidget('zii.widgets.CPortlet', array('title' => 'Operations'));
$this->widget('zii.widgets.CMenu', array('items' => Awecms::filterMenu($this->menu), 'htmlOptions' => array('class' => 'operations')));
$this->endWidget();
?>


</nav>

<div id="main_wrapper">
    <?php 
echo $content;
?>

</div>
</div>
<footer>
示例#16
0
文件: view.php 项目: awecode/awecms
<?php

$this->pageTitle = $model->name . Awecms::getTitlePrefix();
$this->breadcrumbs = array(Yii::t('app', 'All Tags') => array('/tag'), Yii::t('app', $model->name));
if (!isset($this->menu) || $this->menu === array()) {
    $this->menu = array(array('label' => Yii::t('app', 'View')), array('label' => Yii::t('app', 'All Tags'), 'url' => array('/tag')), array('label' => Yii::t('app', 'Delete This Tag'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')));
}
?>

<h1><?php 
echo $model->name;
?>
</h1>

<?php 
if (count($model->pages)) {
    ?>
    <ul>
        <?php 
    if (is_array($model->pages)) {
        foreach ($model->pages as $foreignobj) {
            echo '<li>';
            echo CHtml::link($foreignobj->title, array('/page/page/view', 'id' => $foreignobj->id));
        }
    }
    ?>
</ul>
<?php 
}
示例#17
0
文件: view.php 项目: awecode/awecms

<h1><?php 
echo $model->title;
?>
 (<?php 
echo $model->count;
?>
)</h1>

<?php 
$this->renderPartial('_tree', array('items' => $model->tree[0]->children, 'depth' => 0));
if (count($model->allBusinesses)) {
    ?>
    <h2><?php 
    echo Yii::t('app', Awecms::pluralize('Business', 'Businesses', $model->allBusinesses));
    ?>
:</h2>
    <ul>
        <?php 
    if (is_array($model->allBusinesses)) {
        foreach ($model->allBusinesses as $foreignobj) {
            echo '<li>';
            echo CHtml::link($foreignobj[0]->title, array('/directory/business/view', 'id' => $foreignobj[0]->id));
            echo '</li>';
        }
    }
    ?>
    </ul>
<?php 
}
示例#18
0
文件: _view.php 项目: awecode/awecms
<div class="view">

    <?php 
$possibleIdentifiers = array('name', 'title', 'slug');
$identificationColumn = $this->getIdentificationColumn();
if (!in_array($identificationColumn, $possibleIdentifiers)) {
    echo "<h2><?php echo CHtml::encode(\$data->getAttributeLabel('{$identificationColumn}')); ?>:</h2>\n";
}
echo "<h2><?php echo CHtml::link(CHtml::encode(\$data->{$identificationColumn}), array('view', '" . Awecms::getPrimaryKeyColumn($this) . "' => \$data->" . Awecms::getPrimaryKeyColumn($this) . ")); ?></h2>\n";
foreach ($this->tableSchema->columns as $column) {
    if ($column->name !== $identificationColumn && !$column->isPrimaryKey && !in_array(strtolower($column->name), $this->passwordFields)) {
        $columnName = $column->name;
        if ($column->isForeignKey) {
            $relations = $this->getRelations();
            foreach ($relations as $relationName => $relation) {
                if ($relation[2] == $columnName) {
                    $relatedModel = CActiveRecord::model($relation[1]);
                    $columnName = $relationName . '->' . AweCrudCode::getIdentificationColumnFromTableSchema($relatedModel->tableSchema);
                }
            }
        }
        if (!in_array($column->dbType, $this->booleanTypes)) {
            echo "\n    <?php\n    if (!empty(\$data->{$columnName})) {\n        ?>";
        }
        echo "\n    <div class=\"field\">\n            <div class=\"field_name\">\n                <b><?php echo CHtml::encode(\$data->getAttributeLabel('{$column->name}')); ?>:</b>\n            </div>\n<div class=\"field_value\">\n";
        if (in_array($column->dbType, $this->dateTypes)) {
            /*
            echo "\techo Yii::app()->getDateFormatter()->formatDateTime(\$data->{$columnName}, 'medium', 'medium'); ?>\n\t<br />\n\n";
            */
            echo "                <?php\n                echo date('D, d M y H:i:s', strtotime(\$data->" . $columnName . "));\n                ?>\n\n        </div>\n        </div>\n";
        } else {
示例#19
0
 public static function generatePairs($array)
 {
     $return = array();
     foreach ($array as $item) {
         $return[$item] = Awecms::generateFriendlyName($item);
     }
     return $return;
 }
示例#20
0
文件: index.php 项目: awecode/awecms
    <?php 
    foreach ($results as $result) {
        ?>
                  
        <a href="<?php 
        echo Yii::app()->createUrl($result->link);
        ?>
" title="<?php 
        echo CHtml::encode($result->title);
        ?>
">
        <?php 
        echo $query->highlightMatches(CHtml::encode($result->title));
        ?>
        </a>
        <br/>
        <?php 
        echo $query->highlightMatches(Awecms::summarize($result->content));
        ?>
        <br/>
        <hr/>
    <?php 
    }
    ?>

<?php 
} else {
    ?>
    <p class="error">No results matched your search terms.</p>
<?php 
}
示例#21
0
文件: index.php 项目: awecode/awecms
<?php

$this->breadcrumbs = array(Yii::t('app', 'Business Categories'));
if (!isset($this->menu) || $this->menu === array()) {
    $this->menu = array(array('label' => Yii::t('app', 'List All'), 'url' => array('/directory/business')), array('label' => Yii::t('app', 'Add New'), 'url' => array('/directory/business/create')), array('label' => Yii::t('app', 'Manage All'), 'url' => array('/directory/business/manage')), array('label' => Yii::t('app', 'All Categories')), array('label' => Yii::t('app', 'Create New Category'), 'url' => array('/directory/categories/create')), array('label' => Yii::t('app', 'Manage All Categories'), 'url' => array('/directory/categories/manage')));
}
?>

<h1><?php 
echo Yii::t('app', 'Business Categories');
?>
</h1>

<?php 
$this->widget('SearchBlock', array('type' => 'directory'));
$categories = Awecms::buildTree(Awecms::quickSort($allCategories));
$this->renderPartial('_tree', array('items' => $categories, 'depth' => 0));
////writeTree($categories);
//
//function writeTree($items, $depth = 0) {
//    echo '<ul>';
//    if (is_array($items)) {
//        foreach ($items as $key => $item) {
////            $link = '<a href="' . Yii::app()->baseUrl . '/directory/categories/view' . $item->id . '">' . $item->title . '</a>';
//            $link = '<a href="' . Yii::app()->createUrl('directory/categories/view', array('id' => $item->id)) . '">' . $item->title . '</a>';
//            echo '<li class="depth' . $depth . '">' . $link . '</li>';
//            if (isset($item->children))
//                writeTree($item->children, $depth + 1);
//        }
//    }else {
//        echo $depth . $items->title;
示例#22
0
文件: Page.php 项目: awecode/awecms
 public function getExcerpt()
 {
     return Awecms::summarize($this->content);
 }
示例#23
0
<footer itemtype="http://schema.org/WPFooter">
    <?php 
echo Yii::t('app', 'Copyright');
?>
 &copy; <?php 
echo date('Y');
?>
 <a href="<?php 
echo Yii::app()->baseUrl;
?>
/"><?php 
echo Settings::get('site', 'name');
?>
</a> <br/>
    <?php 
echo Awecms::powered();
?>
</footer>
示例#24
0
?>
']);
<?php 
foreach (CActiveRecord::model($this->modelClass)->relations() as $key => $relation) {
    if ($relation[0] == CActiveRecord::BELONGS_TO || $relation[0] == CActiveRecord::MANY_MANY) {
        printf("\t\t\t\$model->{$key} = \$_POST['{$this->modelClass}']['{$key}'];\n");
    }
}
?>
                try {
                    if($model->save()) {
                        if (isset($_GET['returnUrl'])) {
                                $this->redirect($_GET['returnUrl']);
                        } else {
                                $this->redirect(array('view','id'=>$model-><?php 
echo Awecms::getPrimaryKeyColumn($this);
?>
));
                        }
                    }
                } catch (Exception $e) {
                        $model->addError('<?php 
echo $this->identificationColumn;
?>
', $e->getMessage());
                }

            }

        $this->render('update',array(
                'model'=>$model,
示例#25
0
 public function actionUpload()
 {
     //handle folders
     $this->path = Settings::get('gallery', 'uploadPath');
     $path = Yii::app()->getBasePath() . Settings::get('gallery', 'uploadPath');
     $this->publicPath = Settings::get('gallery', 'uploadUrl');
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
         chmod($path, 0777);
         //throw new CHttpException(500, "{$this->path} does not exists.");
     } else {
         if (!is_writable($path)) {
             chmod($path, 0777);
             //throw new CHttpException(500, "{$this->path} is not writable.");
         }
     }
     if ($this->subfolderVar !== null && Yii::app()->request->getQuery($this->subfolderVar)) {
         $this->_subfolder = Yii::app()->request->getQuery($this->subfolderVar, date("mdY"));
     } else {
         if (isset($_GET['album_id'])) {
             $this->_subfolder = Awecms::getCamelCase(Album::model()->findByPk($_GET['album_id'])->page->title);
         } else {
             if ($this->subfolderVar !== false) {
                 $this->_subfolder = date("mdY");
             }
         }
     }
     //handle upload file
     header('Vary: Accept');
     if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
         header('Content-type: application/json');
     } else {
         header('Content-type: text/plain');
     }
     if (isset($_GET["_method"])) {
         if ($_GET["_method"] == "delete") {
             $success = is_file($_GET["file"]) && $_GET["file"][0] !== '.' && unlink($_GET["file"]);
             echo json_encode($success);
         }
     } else {
         $model = new Image();
         $file = CUploadedFile::getInstance($model, 'file');
         if ($file !== null) {
             $path = $this->_subfolder != "" ? "{$path}/{$this->_subfolder}/" : "{$path}/";
             $this->path = $this->_subfolder != "" ? "{$this->path}/{$this->_subfolder}/" : "{$this->path}/";
             $time = time();
             $model->mime_type = $file->getType();
             $model->size = $file->getSize();
             $model->name = $file->getName();
             $model->title = $_POST['title'][$model->size . $model->name];
             $model->description = $_POST['description'][$model->size . $model->name];
             $model->file = $this->_subfolder . '/' . $time . $model->name;
             if (isset($_GET['album_id'])) {
                 $model->album_id = $_GET['album_id'];
             }
             if ($model->save()) {
                 $this->publicPath = rtrim($this->publicPath, '/');
                 $publicPath = $this->_subfolder != "" ? "{$this->publicPath}/{$this->_subfolder}/" : "{$this->publicPath}/";
                 if (!is_dir($path)) {
                     mkdir($path, 0777, true);
                     chmod($path, 0777);
                 }
                 $file->saveAs($path . $time . $model->name);
                 chmod($path . $time . $model->name, 0777);
                 echo json_encode(array(array("name" => $time . $model->name, "title" => $model->title, "description" => $model->description, "type" => $model->mime_type, "size" => $model->size, "url" => $publicPath . $time . $model->name, "thumbnail_url" => $publicPath . $time . $model->name, "delete_url" => $this->createUrl("/gallery/image/delete", array("id" => $model->id)), "delete_type" => "POST")));
             } else {
                 echo json_encode(array(array("error" => $model->getErrors('file'))));
                 Yii::log("XUploadAction: " . CVarDumper::dumpAsString($model->getErrors()), CLogger::LEVEL_ERROR, "xupload.actions.XUploadAction");
             }
         } else {
             throw new CHttpException(500, "Could not upload file");
         }
     }
 }
示例#26
0
    public function run()
    {
        $page = $this->page;
        foreach ($this->fields as $field) {
            switch ($field) {
                case 'title':
                    ?>
                <h1 itemprop="headline"><?php 
                    echo $page->title;
                    ?>
</h1>
                <?php 
                    break;
                case 'content':
                    echo '<div class="rte-text" itemprop="articleBody">' . $page->content . "</div>";
                    break;
                case 'created_at':
                    echo '<div class="post-time">' . Yii::t('app', 'Posted on ') . '<span itemprop="datePublished">' . date('F d, Y h:m A', strtotime($page->created_at)) . "</span></div>";
                    break;
                case 'excerpt':
                    if (!empty($page->content)) {
                        ?>
                    <div class="field">
                        <div class="field_value">
                            <?php 
                        echo $page->getExcerpt();
                        ?>
                        </div>
                    </div>
                    <?php 
                    }
                    break;
                case 'sub-pages':
                    if (count($page->pages)) {
                        ?>
                    <h2><?php 
                        echo CHtml::link(Yii::t('app', Awecms::pluralize('Sub-Page', 'Sub-Pages', count($page->pages))), array('/page/page'));
                        ?>
</h2>
                    <ul class="sub_pages">
                        <?php 
                        if (is_array($page->pages)) {
                            foreach ($page->pages as $foreignobj) {
                                echo '<li>';
                                echo CHtml::link($foreignobj->title, array('/page/page/view', 'id' => $foreignobj->id));
                            }
                        }
                        ?>
                        </ul>
                        <?php 
                    }
                    break;
                case 'categories':
                    if (Yii::app()->hasModule('category') && count($page->categories)) {
                        ?>
                        <h2><?php 
                        echo CHtml::link(Yii::t('app', Awecms::pluralize('Category', 'Categories', count($page->categories))), array('/category/category'));
                        ?>
</h2>
                        <ul class="categories">
                            <?php 
                        if (is_array($page->categories)) {
                            foreach ($page->categories as $foreignobj) {
                                echo '<li>
                                    <a href="' . Yii::app()->createUrl('/category/category/view', array('id' => $foreignobj->id)) . '">
                                    <span itemprop="articleSection">' . $foreignobj->name . '</span>
                                    </a>
                                    </li>';
                            }
                        }
                        ?>
                            </ul>
                            <?php 
                    }
                    break;
                case 'views':
                    if (!empty($page->views)) {
                        ?>
                            <div class="field">
                                <?php 
                        echo CHtml::encode($page->getAttributeLabel('views'));
                        ?>
:
                                <?php 
                        echo $page->views;
                        ?>
                            </div>
                            <?php 
                    }
                    break;
                case 'tags':
                    if (Yii::app()->hasModule('tag')) {
                        $tags = $page->getTags();
                        if (!empty($tags)) {
                            ?>
                                <div class="field">
                                    <div class="field-name"><?php 
                            echo Yii::t('app', 'Tags');
                            ?>
:</div>
                                    <div class="field-value">
                                        <?php 
                            echo '<span class="tags" itemprop="keywords">' . implode(', ', $tags) . '</span>';
                            ?>
                                    </div>
                                </div>
                                <?php 
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
示例#27
0
 public function generateGridViewColumn($column)
 {
     if ($column->isForeignKey) {
         $columnName = $column->name;
         $relations = $this->getRelations();
         $relatedModel = null;
         $relatedModelName = null;
         foreach ($relations as $relationName => $relation) {
             if ($relation[2] == $columnName) {
                 $relatedModel = CActiveRecord::model($relation[1]);
                 $relatedColumnName = $relationName . '->' . AweCrudCode::getIdentificationColumnFromTableSchema($relatedModel->tableSchema);
                 $relatedModelName = $relation[1];
             }
         }
         $filter = '';
         if ($relatedModel) {
             $foreign_pk = Awecms::getPrimaryKeyColumn($relatedModel);
             $foreign_identificationColumn = self::getIdentificationColumnFromTableSchema($relatedModel->getTableSchema());
             $relatedModelName = get_class($relatedModel);
             $filter = "CHtml::listData({$relatedModelName}::model()->findAll(array('order'=>'{$foreign_identificationColumn}')),'{$foreign_pk}','{$foreign_identificationColumn}')";
         }
         return "array(\n                      'name'   => '{$column->name}',\n                      'value'  => 'isset(\$data->{$relatedColumnName})?\$data->{$relatedColumnName}:\"\"',\n                      'filter' => {$filter},\n                )";
     }
     // Boolean or bit.
     if (strtoupper($column->dbType) == 'TINYINT(1)' || strtoupper($column->dbType) == 'BIT' || strtoupper($column->dbType) == 'BOOL' || strtoupper($column->dbType) == 'BOOLEAN') {
         if ($this->isJToggleColumnEnabled) {
             return "array(\n                    'class' => 'JToggleColumn',\n                    'name' => '{$column->name}',\n                    'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),\n                    'model' => get_class(\$model),\n                    'htmlOptions' => array('style' => 'text-align:center;')\n                    )";
         } else {
             return "array(\n                    'name' => '{$column->name}',\n                    'value' => '(\$data->{$column->name} === 0) ? Yii::t(\\'app\\', \\'No\\') : Yii::t(\\'app\\', \\'Yes\\')',\n                    'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),\n                    )";
         }
     } else {
         if (strtoupper($column->dbType) == 'DATE' || strtoupper($column->dbType) == 'TIMESTAMP') {
             return "array(\n                    'name' => '{$column->name}',\n                    'value' => 'Yii::app()->dateFormatter->format(\"dd/MM/y\",strtotime(\$data->{$column->name}))',\n                    'filter' => false,\n                    )";
         } else {
             return "array(\n                      'name'   => '{$column->name}',\n                      'value'  => 'isset(\$data->{$column->name})?\$data->{$column->name}:\"\"',\n                      'filter' => false,\n                )";
         }
     }
 }
示例#28
0
文件: _form.php 项目: awecode/awecms
?>
        <?php 
echo $form->dropDownList($model, 'controller', Awecms::getControllersInPair($model->module));
?>
        <?php 
echo $form->error($model, 'controller');
?>
    </div>


    <div class="row">
        <?php 
echo $form->labelEx($model, 'action');
?>
        <?php 
echo $form->dropDownList($model, 'action', Awecms::getInPair(Yii::app()->metadata->getActions(ucfirst($model->controller) . 'Controller', $model->module)));
?>
        <?php 
echo $form->error($model, 'action');
?>
    </div>

    <label for="roles"><strong><?php 
echo Yii::t('app', 'Roles');
?>
:</strong></label>

    <div id="defaultRoles" class="row nm_row">
        <?php 
echo $form->checkBox($model, 'all');
?>
示例#29
0
文件: _form.php 项目: awecode/awecms
?>
        <?php 
echo $form->error($model, 'name');
?>
    </div><!-- row -->

    <div class="row">

        <?php 
echo CHtml::radioButton('MenuItem[type]', $model->type == 'module', array('value' => 'module', 'id' => 'radio_module'));
?>
        <?php 
echo Yii::t('app', 'Module') . ' ';
?>
        <?php 
echo Chtml::dropDownList('MenuItem[module]', $model->link, Awecms::getModulesWithPath(), array('onfocus' => 'js:$("#radio_module").attr("checked", "checked");'));
?>
        <br/>

        <?php 
// echo CHtml::radioButton('MenuItem[type]', $model->type == 'action', array('value' => 'action'));
?>
        <?php 
// echo Yii::t('app', 'Action');
//        print_r(Awecms::getAllActions());
?>
        <!--<br/>-->
        <?php 
if (Yii::app()->hasModule('page')) {
    echo CHtml::radioButton('MenuItem[type]', $model->type == 'content', array('value' => 'content', 'id' => 'radio_content'));
    echo Yii::t('app', 'Content') . ' ';
示例#30
0
文件: index.php 项目: awecode/awecms
<?php

$this->breadcrumbs = array('Settings', Yii::t('app', Awecms::generateFriendlyName($action)));
$this->menu = Settings::getCategoriesAsLinks($action);
echo CHtml::link('Add settings field', array('/settings/add/' . $action));
$this->widget('EDynamicForm', array('id' => 'id', 'class' => 'settings', 'model' => $settings, 'selector' => false));