Beispiel #1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new AppManager();
     }
     return self::$instance;
 }
 public function actionCreate()
 {
     $model = new Crud();
     $form = new Form('codegen.CrudForm', $model);
     if ($form->submitted() && $model->validate()) {
         Yii::import('codegen.controllers.FormAdminController');
         FormAdminController::generateAndSaveForm($model->class);
         $params = $model->attributes;
         $params['module'] = AppManager::getModelModule($model->class);
         $controllers_path = 'codegen.views.templates.crud.controllers';
         $controllers_files = glob(Yii::getPathOfAlias($controllers_path) . DS . '*');
         foreach ($controllers_files as $controller_file) {
             $file_name = pathinfo($controller_file, PATHINFO_FILENAME);
             $code = $this->renderPartial($controllers_path . '.' . $file_name, $params, true);
             $file_name = $model->class . $file_name . '.php';
             $dir = MODULES_PATH . $params['module'] . DS . 'controllers' . DS;
             if (!is_dir($dir)) {
                 mkdir($dir, 0777, true);
                 chmod($dir, 0777);
             }
             $file_path = $dir . $file_name;
             file_put_contents($file_path, $code);
             chmod($file_path, 0777);
         }
         $views_path = 'codegen.views.templates.crud.views';
         $views_files = glob(Yii::getPathOfAlias($views_path) . DS . '*' . DS . '*');
         foreach ($views_files as $view_file) {
             $view_file = str_replace(Yii::getPathOfAlias($views_path), '', $view_file);
             $file_name = pathinfo($view_file, PATHINFO_BASENAME);
             $file_code = $this->renderPartial($views_path . str_replace(array(DS, '.php'), array('.', ''), $view_file), $params, true);
             $view_file_path = MODULES_PATH . $params['module'] . DS . 'views' . $view_file;
             $view_file_dir = pathinfo($view_file_path, PATHINFO_DIRNAME);
             $child_dir = pathinfo($view_file_dir, PATHINFO_FILENAME);
             if ($child_dir == 'client') {
                 $view_file_dir = str_replace('client', lcfirst($model->class), $view_file_dir);
             } else {
                 if ($child_dir == 'admin') {
                     $view_file_dir = str_replace('admin', lcfirst($model->class) . 'Admin', $view_file_dir);
                 }
             }
             if (!is_dir($view_file_dir)) {
                 mkdir($view_file_dir, 0777, true);
                 chmod($view_file_dir, 0777);
             }
             $file_path = $view_file_dir . DS . $file_name;
             file_put_contents($file_path, $file_code);
             chmod($file_path, 0777);
         }
         $msg = "Добавьте  в метод adminMenu()  в файле " . ucfirst($params['module']) . "Module.php<br/>\r\n                   'Управление {$params['instrumental']}'    => Yii::app()->createUrl('/{$params['module']}/" . lcfirst($params['class']) . "Admin/manage'), <br/>\r\n                   'Создать {$params['accusative']}' => Yii::app()->createUrl(''/{$params['module']}/" . lcfirst($params['class']) . "Admin/create'),";
         Yii::app()->user->setFlash(Controller::MSG_SUCCESS, 'CRUD создан!');
         Yii::app()->user->setFlash(Controller::MSG_INFO, $msg);
         $this->redirect($_SERVER['REQUEST_URI']);
     }
     $this->render('create', array('form' => $form));
 }
 public function actionManage($module_id = null)
 {
     $model = new Param('search');
     $model->unsetAttributes();
     if (isset($_GET['Param'])) {
         $model->attributes = $_GET['Param'];
     }
     $params = array('model' => $model);
     if ($module_id) {
         $params['module_id'] = $module_id;
         $params['module_name'] = AppManager::getModuleName($module_id);
     }
     $this->render('manage', $params);
 }
 public function testAllPages()
 {
     $this->loginAdmin();
     $modules = AppManager::getModulesData();
     foreach ($modules as $module) {
         if (!$module["admin_menu"]) {
             continue;
         }
         foreach ($module["admin_menu"] as $title => $url) {
             $this->open($url);
             $this->assertFalse($this->isTextPresent('Error'), "Error on page " . $url);
             $this->assertFalse($this->isTextPresent('Exception'), "Exception on page " . $url);
             $this->assertElementNotPresent('//body[@jserror]', "Javascript error on page " . $url);
         }
     }
 }
 /**
 	     <div class="itemHeader">
       <div class="itemlogo"><img src="../styles/images/fanfou.gif" alt="fanfou"></div>
       <div class="itemlogo"><img src="../styles/images/person_image.gif" alt="person"></div>
       <a href="[__who_url]" title="浏览[__who]的共享">[__who]</a>在
       <a href="[__where_url]" title="[__where]">[__where]</a>
       共享了
       <a href="[__title__link]" title="[__Title]">[__Title]</a>
     </div>
 */
 private function buildItemHeader()
 {
     $memApp = AccountManager::getInstance()->getMemAppBySynid($this->rssItem->synid);
     $appObj = AppManager::getInstance()->getAppByAppid($memApp->appid);
     $html = ' <div class="itemHeader">';
     // <div class="itemlogo"><img src="../styles/images/fanfou.gif" alt="fanfou"></div>
     $html .= '<div class="itemlogo"><img src="' . $appObj->getLogoUrl() . '" alt="' . $appObj->name . '"></div>';
     // <div class="itemlogo"><img src="../styles/images/person_image.gif" alt="person"></div>
     $memberObj = AccountManager::getInstance()->getMemberByMemid($memApp->memid);
     $html .= '<div class="itemlogo"><img src="' . $memberObj->getPersonalImage() . '" alt="' . $memberObj->name . '"></div>';
     //<a href="[__who_url]" title="浏览[__who]的共享">[__who]</a>在
     $html .= '<a href="http://www.friendsharing.com/memid=' . $memberObj->memid . '" title="浏览' . $memberObj->name . '的共享">' . $memberObj->name . '</a>在';
     //		 <a href="[__where_url]" title="[__where]">[__where]</a> 共享了
     $html .= '<a href="' . $memApp->rssurl . '" title="' . $appObj->name . '">' . $appObj->name . '</a>共享了';
     //      <a href="[__title__link]" title="[__Title]">[__Title]</a>
     $html .= '<a href="' . $this->rssItem->link . '" title="' . $this->rssItem->title . '">' . $this->rssItem->title . '</a>';
     $html .= '</div>';
     return $html;
 }
Beispiel #6
0
<?php

$this->tabs = array('Добавить параметр' => $this->createUrl('create'));
$this->widget('AdminGridView', array('id' => 'settings-grid', 'dataProvider' => $model->search(isset($module_id) ? $module_id : null), 'filter' => $model, 'columns' => array(array('name' => 'module_id', 'value' => 'AppManager::getModuleName($data->module_id)', 'filter' => AppManager::getModulesNames()), array('name' => 'name', 'htmlOptions' => array('update' => true)), array('name' => 'value', 'value' => '$data->formated_value;', 'type' => 'raw'), array('class' => 'CButtonColumn', 'template' => '{updateValue} {view} {update} {delete}', 'buttons' => array('updateValue' => array('imageUrl' => '/img/icons/floppy.png', 'label' => 'Изменить значение', 'url' => 'Yii::app()->controller->createUrl("update", array("id" => $data->id, "scenario" => "value_update"))', 'options' => array('class' => 'popup')))))));
Beispiel #7
0
 public function getModelName()
 {
     $models = AppManager::getModels();
     if (isset($models[$this->model_id])) {
         return call_user_func(array($this->model_id, 'name'));
     } else {
         return '<span style="color:red">не существует</span>';
     }
 }
Beispiel #8
0
    public static function getModulesClientMenu()
    {
        if (!self::$_modules_client_menu)
        {
            $modules_urls = array();

            $modules = self::getModulesData(true);

            foreach ($modules as $module)
            {
                if (method_exists($module['class'], 'clientMenu'))
                {
                    $client_menu = call_user_func(array($module['class'], 'clientMenu'));
                    if (is_array($client_menu))
                    {
                        $modules_urls = array_merge($modules_urls, $client_menu);
                    }
                }
            }

            self::$_modules_client_menu = array_flip($modules_urls);
        }

        return self::$_modules_client_menu;
    }
Beispiel #9
0
<?php

return array('activeForm' => array('id' => 'form-form'), 'elements' => array('model' => array('type' => 'dropdownlist', 'items' => AppManager::getModels())), 'buttons' => array('submit' => array('type' => 'submit', 'value' => t('Создать'))));
Beispiel #10
0
<?php

$this->page_title = 'Разделы меню :: ' . $menu->name;
$this->tabs = ["управление меню" => $this->createUrl('/content/menuAdmin/manage'), "добавить раздел" => $this->createUrl('create', ['menu_id' => $menu->id, 'parent_id' => $root->id, 'back' => 'manage']), "сортировка" => $this->createUrl('sorting', ['root_id' => $root->id, 'menu_id' => $menu->id])];
$this->widget('AdminGridView', ['id' => 'menu-section-grid', 'dataProvider' => $model->search($root->id), 'filter' => $model, 'template' => '{summary}<br/>{pager}<br/>{items}<br/>{pager}', 'columns' => [['name' => 'title', 'value' => function ($data) {
    return CHtml::link($data->nbsp_title, Yii::app()->controller->createUrl("update", ["id" => $data->id, 'back' => 'manage']), ["level" => $data->level, "class" => "node_link"]);
}, 'type' => 'raw'], 'url', ['header' => 'Принадлежность', 'type' => 'raw', 'value' => function ($data, $row) {
    $img_url = Yii::app()->getModule('content')->assetsUrl() . '/img';
    $src = '';
    $htmlOptions = [];
    if ($data->page_id) {
        $src = $img_url . '/page.png';
        $htmlOptions['title'] = 'Привязка к странице: ' . $data->title;
    } elseif ($data->module_url) {
        $src = $img_url . '/module.png';
        $modules_urls = AppManager::getModulesClientMenu();
        if (isset($modules_urls[$data->module_id][$data->module_url])) {
            $htmlOptions['title'] = 'Привязка к модулю: ' . $modules_urls[$data->module_id][$data->module_url];
        } else {
            $htmlOptions['title'] = 'Неверная привязка к несуществующему разделу модуля!';
            $htmlOptions['style'] = 'border:2px dashed red';
        }
    }
    if ($src) {
        return CHtml::image($src, $htmlOptions['title'], $htmlOptions);
    }
}, 'htmlOptions' => ['width' => '1px']], ['class' => 'PublishedColumn', 'name' => 'is_published'], ['class' => 'CButtonColumn', 'template' => '{create} {update} {delete}', 'buttons' => ['create' => ['label' => 'добавить дочерний раздел', 'imageUrl' => '/img/admin/child.png', 'url' => 'Yii::app()->controller->createUrl("create",["menu_id" => $data->menu->id, "parent_id" => $data->id, "back" => "manage"])'], 'update' => ['url' => 'Yii::app()->controller->createUrl("update",["id" => $data->id, "back" => "manage"])']]]]]);
 protected function getModulesTasks()
 {
     $tasks = array();
     $modules = AppManager::getModulesNames();
     foreach ($modules as $module_name => $module_desc) {
         $operations = array();
         $module_actions = AppManager::getModuleActions(ucfirst($module_name) . 'Module');
         foreach ($module_actions as $controller => $actions) {
             $prefix = str_replace('Controller', '', $controller);
             foreach ($actions as $name => $description) {
                 $name = $prefix . '_' . $name;
                 $exists = AuthItem::model()->exists(" name = '{$name}' AND type = '" . CAuthItem::TYPE_OPERATION . "'");
                 $operations[] = array('name' => $name, 'description' => $description, 'exists' => $exists);
             }
         }
         $exists = AuthItem::model()->exists(" name = '{$module_name}' AND type = '" . CAuthItem::TYPE_TASK . "'");
         $tasks[] = array('exists' => $exists, 'name' => $module_name, 'description' => $module_desc, 'operations' => $operations);
     }
     return $tasks;
 }
<?php

require 'friend.php';
require "appmanager.php";
if (AppManager::checkAppCode($_REQUEST['appcode'])) {
    switch ($_REQUEST['type']) {
        case 'GET_FRIEND_LIST':
            echo json_encode(array("friends" => FriendManager::getFriendsById($_REQUEST['id'])));
            break;
        case 'GET_FRIEND_BY_FID':
            echo json_encode(FriendManager::getFriendByFid($_REQUEST['fid']));
            break;
        case 'FRIEND_REMOVE':
            echo FriendManager::removeFriend($_REQUEST['uid'], $_REQUEST['fid']) + FriendManager::removeFriend($_REQUEST['fid'], $_REQUEST['uid']);
            break;
        case 'SET_SHARE':
            echo FriendManager::setShare($_REQUEST['uid'], $_REQUEST['fid'], $_REQUEST['share']);
            break;
        case 'STOP_SHARE':
            echo FriendManager::stopShare($_REQUEST['uid'], $_REQUEST['fid']);
            break;
        case 'GET_SHARE':
            echo FriendManager::getShare($_REQUEST['uid'], $_REQUEST['fid']);
            break;
        default:
            echo "Unknown type";
    }
}
Beispiel #13
0
<?php

$app = AppManager::getInstance();
$index = new \App\Controllers\AppController($app);
$ws = new \App\Controllers\WebserviceController($app);
Beispiel #14
0
 public function renderContent()
 {
     $this->render('AdminMenu', array('modules' => AppManager::getModulesData(true, true)));
 }
Beispiel #15
0
<?php

if ($this->model->isNewRecord) {
    $items = array();
} else {
    $model = $this->model->model_id;
    $items = array();
    $objects = $model::model()->findAll();
    foreach ($objects as $i => $object) {
        $items[$object->id] = (string) $object;
    }
}
return array('activeForm' => array('id' => 'meta-tag-form'), 'elements' => array('model_id' => array('type' => 'dropdownlist', 'items' => AppManager::getModels(array('meta_tags' => true)), 'prompt' => 'не выбрана', 'disabled' => $this->model->isNewRecord ? false : true), 'object_id' => array('type' => 'dropdownlist', 'label' => 'Объект', 'items' => $items, 'disabled' => $this->model->isNewRecord ? false : true), 'title' => array('type' => 'text'), 'description' => array('type' => 'text'), 'keywords' => array('type' => 'text')), 'buttons' => array('submit' => array('type' => 'submit', 'value' => $this->model->isNewRecord ? 'создать' : 'сохранить', 'id' => 'meta_tag_submit')));
Beispiel #16
0
 public static function getModulesClientMenu()
 {
     if (!self::$_modules_client_menu) {
         $modules_urls = array();
         $modules = self::getModulesData(true);
         foreach ($modules as $module) {
             if (method_exists($module['class'], 'clientMenu')) {
                 $modules_urls[$module['dir']] = array_flip(call_user_func(array($module['class'], 'clientMenu')));
             }
         }
         self::$_modules_client_menu = $modules_urls;
     }
     return self::$_modules_client_menu;
 }
Beispiel #17
0
<?php

/**.
 * This is an example of packeging an php Application for Example purpose
 * 
 * Created under the CCC Licence. 
 * 
 * @author Jan-David Siegl <*****@*****.**>
 * @since 09.08.2015
 */
function __autoload($name)
{
    include $name . ".php";
}
$config = parse_ini_file("config.ini");
AppManager::run($config);
Beispiel #18
0
    <?php 
/**
 * @author Sławomir Żytko <*****@*****.**>
 * @copyright (c) 2014, Amsterdam Standard
 */
require_once "phar://vegaser.phar" . DIRECTORY_SEPARATOR . "common.php";
function __autoload($name)
{
    require_once 'phar://vegaser.phar' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $name) . '.php';
}
AppManager::run($argv);
Beispiel #19
0
<?php

//Yii::app()->clientScript->registerScript(
//    'model->form',
//    '
//    $("#model-form input[name=preview]").click(function() {
//        updateCode();
//    });
//
//    function updateCode() {
//        var data = $("#model-form").serialize();
//        $.post("/codegen/modelAdmin/getCode", data, function(html) {
//            $("#code_place").html(html);
//        });
//    }
//    ',
//    CClientScript::POS_READY
//);
return array('activeForm' => array('id' => 'model-form'), 'elements' => array('table' => array('type' => 'text'), 'class' => array('type' => 'text'), 'name' => array('type' => 'text'), 'module' => array('type' => 'dropdownlist', 'items' => CHtml::listData(AppManager::getModulesData(), 'dir', 'name'), 'empty' => 'не выбран'), 'behaviors' => array('type' => 'multi_select', 'items' => array_flip(Model::$extra_behaviors))), 'buttons' => array('submit' => array('type' => 'submit', 'value' => t('Создать')), 'preview' => array('type' => 'button', 'value' => 'Предпросмотр')));
Beispiel #20
0
echo "----------------begin add memebers---------------------";
echo "<br>";
AccountManager::getInstance()->registerMemeber('*****@*****.**', '蔡杰Gmail', '111111');
AccountManager::getInstance()->registerMemeber('*****@*****.**', '蔡杰Hotmail', '111111');
AccountManager::getInstance()->registerMemeber('*****@*****.**', '张三', '111111');
AccountManager::getInstance()->registerMemeber('*****@*****.**', '李四', '111111');
AccountManager::getInstance()->registerMemeber('*****@*****.**', '王二麻子', '111111');
AccountManager::getInstance()->registerMemeber('*****@*****.**', 'user0', '111111');
AccountManager::getInstance()->registerMemeber('user1fs', 'user1', '111111');
echo "----------------end add memebers---------------------";
echo "<br>";
echo "<br>";
echo "----------------begin add app---------------------";
echo "<br>";
AppManager::getInstance()->loadAllApps();
$appbasic = AppManager::getInstance()->getAppByAppid(1);
echo "----------------end add app---------------------";
echo "<br>";
echo "<br>";
echo "----------------begin member register app---------------------";
echo "<br>";
$memberObj = AccountManager::getInstance()->getMemberByEmail('*****@*****.**');
AccountManager::getInstance()->registerMemApp($memberObj->memid, AppConstants::$APP_TESTSITE[0]);
$memberObj = AccountManager::getInstance()->getMemberByEmail('*****@*****.**');
AccountManager::getInstance()->registerMemApp($memberObj->memid, AppConstants::$APP_FANFOU[0]);
echo "----------------end member register app---------------------";
echo "<br>";
echo "<br>";
echo "----------------begin add test rss items---------------------";
echo "<br>";
var_dump(RssManager::getInstance()->getLatestItems());
Beispiel #21
0
    var oprions_element = $("#Param_options").parents("dl:eq(0)");

    if ($("#Param_element").val() != "select") {
        oprions_element.hide();
    }

    $("#Param_element").change(function() {
        if ($(this).val() == "select") {
            oprions_element.show();
        }
        else {
            oprions_element.hide();
        }
    });
    ', CClientScript::POS_READY);
if ($this->model->scenario == Param::SCENARIO_VALUE_UPDATE) {
    $elements = array('name' => array('type' => 'text', 'disabled' => true));
    if ($this->model->element == Param::ELEMENT_SELECT) {
        $items = array();
        foreach (explode("\n", $this->model->options) as $option) {
            list($name, $value) = explode(Param::OPTION_NAME_VALUE_SEPARATOR, $option);
            $items[trim($name)] = trim($value);
        }
        $elements['value'] = array('type' => 'dropdownlist', 'items' => $items);
    } else {
        $elements['value'] = array('type' => $this->model->element);
    }
} else {
    $elements = array('module_id' => array('type' => 'dropdownlist', 'items' => CHtml::listData(AppManager::getModulesData(), 'dir', 'name')), 'name' => array('type' => 'text'), 'code' => array('type' => 'text'), 'element' => array('type' => 'dropdownlist', 'items' => Param::$elements), 'options' => array('type' => 'textarea', 'label' => 'Список значений (Каждое название' . Param::OPTION_NAME_VALUE_SEPARATOR . 'значение на новой строке)'));
}
return array('enctype' => 'multipart/form-data', 'activeForm' => array('id' => 'Param-form'), 'elements' => $elements, 'buttons' => array('submit' => array('type' => 'submit', 'value' => 'Сохранить')));
 public function actionModules()
 {
     $this->render('modules', array('modules' => AppManager::getModulesData(), 'active_modules' => AppManager::getActiveModulesArray()));
 }
Beispiel #23
0
<?php

Yii::app()->clientScript->registerScript('crud-form', '
    $("#crud-form").after("<div id=\'files_div\'><div>");

    $("#Crud_model").change(function() {
        var model = $(this).val();

        if (model) {
            $("#files_div").load("/codegen/crudAdmin/getFiles/model/" + model);
        }
        else {
            $("#files_div").html("");
        }
    });
    ', CClientScript::POS_READY);
return array('activeForm' => array('id' => 'crud-form', 'enableAjaxValidation' => false, 'clientOptions' => array('validateOnSubmit' => false)), 'elements' => array('class' => array('type' => 'dropdownlist', 'items' => AppManager::getModels(), 'empty' => 'не выбрано', 'label' => 'Модель'), 'genetive' => array('type' => 'text', 'label' => 'Добавление кого?, чего?'), 'instrumental' => array('type' => 'text', 'label' => 'Управление кем?, чем?'), 'accusative' => array('type' => 'text', 'label' => 'Создать кого?, что?')), 'buttons' => array('submit' => array('type' => 'submit', 'value' => t('Создать'))));
Beispiel #24
0
 public static function getActionUrl($action, $params = array())
 {
     $model = lcfirst(get_called_class());
     $module = AppManager::getModelModule($model);
     return Yii::app()->createUrl("/{$module}/{$model}/{$action}", $params);
 }
Beispiel #25
0
<?php

$tables = Yii::app()->db->schema->tableNames;
$tables = array_combine($tables, $tables);
return array('activeForm' => array('id' => 'migration-form', 'enableAjaxValidation' => false), 'elements' => array('module' => array('type' => 'dropdownlist', 'items' => AppManager::getModulesNames(), 'label' => t('Модуль')), 'table' => array('type' => 'dropdownlist', 'items' => $tables, 'label' => t('Таблица'))), 'buttons' => array('submit' => array('type' => 'submit', 'value' => t('Создать'))));