Ejemplo n.º 1
0
 function codemirror($attrs)
 {
     $url = zotop::module('codemirror', 'url');
     $options = new stdClass();
     $options->path = $url . '/codemirror/js/';
     $options->parserfile = array('parsexml.js');
     $options->stylesheet = array($url . '/codemirror/css/xmlcolors.css');
     $options->height = is_numeric($attrs['height']) ? $attrs['height'] . 'px' : $attrs['height'];
     $options->width = is_numeric($attrs['width']) ? $width . 'px' : $attrs['width'];
     $options->continuousScanning = 500;
     $options->autoMatchParens = true;
     if ($attrs['linenumbers'] !== false) {
         $options->lineNumbers = true;
         $options->textWrapping = false;
     }
     if ($attrs['tabmode'] == '') {
         $options->tabMode = 'shift';
     }
     $html = array();
     $html[] = html::script($url . '/codemirror/js/codemirror.js');
     $html[] = html::stylesheet($url . '/codemirror/css/codemirror.css');
     $html[] = '	' . field::textarea($attrs);
     $html[] = '<script type="text/javascript">';
     $html[] = '	var editor = CodeMirror.fromTextArea("' . $attrs['name'] . '", ' . json_encode($options) . ');';
     $html[] = '$(function(){';
     $html[] = '	$("form").submit(function(){';
     $html[] = '		$("textarea[name=+' . $attrs['name'] . '+]").val(editor.getCode());';
     $html[] = '	});';
     $html[] = '})';
     $html[] = '</script>';
     return implode("\n", $html);
 }
Ejemplo n.º 2
0
 public function getActive()
 {
     $active = array();
     $modules = zotop::module();
     foreach ($modules as $module) {
         if ($module['status'] >= 0) {
             $active[$module['id']] = $module;
         }
     }
     return $active;
 }
Ejemplo n.º 3
0
 public function actionIndex()
 {
     $module = zotop::module('content');
     $menus = array(array('id' => 'category', 'icon' => '', 'title' => '内容管理', 'url' => zotop::url('content/content'), 'description' => '内容管理,添加,编辑以及删除等操作'), array('id' => 'category', 'icon' => '', 'title' => '栏目管理', 'url' => zotop::url('content/category'), 'description' => '栏目分类管理,新建栏目及调整栏目顺序'), array('id' => 'category', 'icon' => '', 'title' => '模型管理', 'url' => zotop::url('content/model'), 'description' => '内容模型管理,可以自定义内容模型'), array('id' => 'category', 'icon' => '', 'title' => '模块设置', 'url' => zotop::url('content/setting'), 'description' => '内容模块的相关设置'));
     $page = new page();
     $page->set('title', $module['title']);
     //$page->set('description', $module['description']);
     $page->set('navbar', $this->navbar());
     $page->set('module', $module);
     $page->set('menus', $menus);
     $page->display();
 }
Ejemplo n.º 4
0
 public function actionSide()
 {
     $m = array();
     $modules = (array) zotop::module();
     foreach ($modules as $module) {
         if ($module['type'] == 'com') {
             $module['href'] = zotop::url($module['id']);
             $m[$module['id']] = $module;
         }
     }
     $page = new side();
     $page->set('modules', $page->navlist($m));
     $page->display();
 }
Ejemplo n.º 5
0
 public function getTemplatePath($action = '')
 {
     if (empty($this->template)) {
         if (empty($action)) {
             $action = application::getAction();
         }
         $module = application::getModule();
         $controller = application::getController();
         $path = zotop::module($module, 'path');
         $path = $path . DS . router::application() . DS . 'template' . DS . $controller . DS . $action . '.php';
         return $path;
     }
     return $this->template;
 }
Ejemplo n.º 6
0
 public function indexAction()
 {
     $apps = array();
     $modules = (array) zotop::module();
     foreach ($modules as $module) {
         if ($module['type'] == 'plugin') {
             $apps[] = $module;
         }
     }
     $page = new page();
     $page->set('apps', $apps);
     $page->addScript('$common/js/side.js');
     $page->body = array('class' => 'side');
     $page->display();
 }
Ejemplo n.º 7
0
 public function actionSide()
 {
     $modules = (array) zotop::module();
     foreach ($modules as $id => $module) {
         if ($module['type'] != 'com') {
             unset($modules[$id]);
         } else {
             $modules[$id]['href'] = zotop::url($module['id']);
         }
     }
     $page = new side();
     $page->title = '系统管理';
     $page->set('modules', $modules);
     $page->display();
 }
Ejemplo n.º 8
0
 function xheditor_rc1($attrs)
 {
     $attrs['class'] = isset($attrs['class']) ? 'editor ' . $attrs['class'] : 'editor';
     $tools = array('image' => '<a href="' . zotop::url('system/image/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-imageuploader button-icon"></span><span class="button-text">插入图片</span></a>', 'file' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-fileuploader button-icon"></span><span class="button-text">插入文件</span></a>', 'template' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-template button-icon"></span><span class="button-text">插入模板</span></a>');
     $tools = zotop::filter('editor.tools', $tools);
     $tools = arr::take('tools', $attrs) === false ? array() : $tools;
     $url = zotop::module('xheditor', 'url');
     $html[] = html::script($url . '/editor/xheditor-zh-cn.min.js');
     $html[] = html::script($url . '/common/global.js');
     if (is_array($tools) && !empty($tools)) {
         $html[] = '<div class="field-toolbar">';
         foreach ($tools as $tool) {
             $html[] = ' ' . $tool;
         }
         $html[] = '</div>';
     }
     $html[] = '	' . field::textarea($attrs);
     return implode("\n", $html);
 }
Ejemplo n.º 9
0
 /**
  * 用于实例化一个模型{module}.{model},如 zotop.user,实例化系统模块的user模型
  *
  *
  * @param $name 模型名称空间
  * @return object(model)
  */
 public static function model($name = '')
 {
     static $models = array();
     if (empty($name)) {
         return new model();
     }
     if (isset($models[$name])) {
         return $models[$name];
     }
     list($module, $model) = explode('.', $name);
     $modelName = $model . '_model';
     if (!class_exists($modelName)) {
         $modelPath = zotop::module($module, 'root') . DS . 'models' . DS . $model . '.php';
         zotop::load($modelPath);
     }
     if (class_exists($modelName)) {
         $m = new $modelName();
         $models[$name] = $m;
         return $m;
     }
     zotop::error(100, '未能找到模型', zotop::t('<h2>未能找到模型{$modelName},请检查模型文件是否存在错误</h2>文件地址:{$modelPath}', array('modelName' => $modelName, 'modelPath' => $modelPath)));
 }
Ejemplo n.º 10
0
 /**
  * 用于实例化一个模型{module}.{model},如 zotop.user,实例化系统模块的user模型
  *
  *
  * @param $name 模型名称空间
  * @return object(model)
  */
 public static function model($name = '')
 {
     static $models = array();
     if (empty($name)) {
         return new model();
     }
     if (isset($models[$name])) {
         return $models[$name];
     }
     list($module, $model) = explode('.', $name);
     $modelName = $model . '_model';
     if (!class_exists($modelName)) {
         $modelPath = zotop::module($module, 'path') . DS . 'models' . DS . $model . '.php';
         if (zotop::load($modelPath) == false) {
             zotop::error(zotop::t('<h2>请检查相应的模型文件是否存在</h2>文件地址:{$modelPath}', array('modelPath' => $modelPath)));
         }
     }
     if (class_exists($modelName)) {
         $m = new $modelName();
         $m->moduleName = $module;
         $models[$name] = $m;
         return $m;
     }
     zotop::error(zotop::t('<h2>请检查相应的模型文件中是否存在模型类 {$modelName}</h2>文件地址:{$modelPath}', array('modelPath' => $modelPath, 'modelName' => $modelName)));
 }
Ejemplo n.º 11
0
 /**
  * 存储简单类型数据,字符串,数组
  * @param string $file 完整的file名称或者system.data.setting
  * @param mix $value 值
  * @param int $expire 缓存时间
  * 
  * @return mix
  */
 public static function data($file, $value = '', $expire = 0)
 {
     static $files = array();
     if (strtolower(substr($file, -4)) != '.php' && strpos($file, DS) == false) {
         //应该对应module的数据
         $moduleID = substr($file, 0, strpos($file, '.'));
         $modulePath = zotop::module($moduleID, 'path');
         $fileName = substr($file, strpos($file, '.') + 1);
         //根据module返回文件路径
         $file = $modulePath . DS . str_replace('.', DS, $fileName) . '.php';
     }
     if ('' !== $value) {
         if (is_null($value)) {
             $result = unlink($file);
             if ($result) {
                 unset($files[$file]);
             }
             return $result;
         } else {
             $content = "<?php\nif (!defined('ZOTOP')) exit();\n//" . sprintf('%012d', $expire) . "\nreturn " . var_export($value, true) . ";\n?>";
             $result = file_put_contents($file, $content);
             $files[$file] = $value;
         }
         return true;
     }
     if (isset($files[$file])) {
         return $files[$file];
     }
     if (file_exists($file) && false !== ($content = file_get_contents($file))) {
         $expire = (int) substr($content, strpos($content, '//') + 2, 12);
         if ($expire != 0 && time() > filemtime($file) + $expire) {
             unlink($file);
             //过期删除
             return false;
         }
         $value = eval(substr($content, strpos($content, '//') + 14, -2));
         $files[$file] = $value;
     } else {
         $value = false;
     }
     return $value;
 }
Ejemplo n.º 12
0
 public static function controllerPath()
 {
     $controller = router::controller();
     if ($controller) {
         return zotop::module(router::module(), 'root') . DS . router::application() . DS . router::controller() . '.php';
     }
     return '';
 }
Ejemplo n.º 13
0
 /**
  * 返回当前的控制器的真实路径
  *
  * @return string
  */
 public static function getControllerPath()
 {
     $controller = application::getController();
     $module = application::getModule();
     $path = zotop::module($module, 'root') . DS . router::application() . DS . $controller . '.php';
     return $path;
 }
Ejemplo n.º 14
0
 public static function module($id = '')
 {
     $id = empty($id) ? router::module() : $id;
     if ($id) {
         return zotop::module($id, 'url');
     }
     return '';
 }
Ejemplo n.º 15
0
 public static function template($namespace = '')
 {
     if (empty($namespace)) {
         $namespace = application::module() . '/' . application::controller() . '/' . application::action();
     }
     $namespace = str_replace('.', '/', $namespace);
     $namespaces = explode('/', $namespace);
     switch (count($namespaces)) {
         case 1:
             $module = application::module();
             $namespace = $namespaces[0];
             break;
         default:
             $module = array_shift($namespaces);
             $namespace = implode('/', $namespaces);
             break;
     }
     $template = zotop::module($module, 'path') . DS . ZOTOP_APPLICATION . DS . 'template' . DS . str_replace('/', DS, $namespace) . '.php';
     return $template;
 }
Ejemplo n.º 16
0
box::footer();
?>

<?php 
box::header(array('title' => zotop::module('blog', 'name')));
?>
<table class="table">	
	<tr><td><?php 
echo zotop::module('blog', 'description');
?>
</td></tr>
	<tr><td>版本:<?php 
echo zotop::module('blog', 'version');
?>
</td></tr>
	<tr><td>作者:<?php 
echo zotop::module('blog', 'author');
?>
</td></tr>
	<tr><td>主页:<?php 
echo html::a(zotop::module('blog', 'homepage'));
?>
</td></tr>
</table>
<?php 
box::footer();
?>
</div>
</div>
<?php 
$this->footer();
Ejemplo n.º 17
0
 /**
  * 返回当前的控制器的真实路径
  *
  * @return string
  */
 public static function getControllerPath()
 {
     $controller = application::getController();
     $module = application::getModule();
     $path = zotop::module($module, 'path');
     if (empty($path)) {
         zotop::error(array('title' => '系统错误', 'content' => zotop::t('<h2>未能找到相应模块,请检查模块是否未安装或者已被禁用?</h2>模块名称:{$module}', array('module' => $module))));
     }
     $path = $path . DS . router::application() . DS . $controller . '.php';
     return $path;
 }