Beispiel #1
0
 /**
  * 获取文件的完整url
  *
  * @param string $url
  * @return string
  */
 public static function url($url, $domain = false)
 {
     //如果不是完整的链接,如:http://www.zotop.com/a/b/1.gif ,则将相对连接处理成绝对链接
     if (strpos($url, '://') === false && $url[0] != '/' && $url[0] != '$') {
         $url = $domain ? '$domain/$root' . $url : '$root/' . $url;
     }
     //解析url中的特殊字符串
     $url = url::decode($url);
     return $url;
 }
Beispiel #2
0
 /**
  * Index page, used to display all inspirations.
  * This method may look a little "odd" there is  a reason for this, 
  * the kohana orm shares the same instances across multiple objects. 
  * This means that we can not build all of the queries at the same time, 
  * they can not be set until all previous queries are completed (stupid). 
  * 
  * I have tried to reduce code repertition by using arrays, but its still ugly. 
  * 
  */
 public function index($page = 1, $application = 'all', $industry = 'all')
 {
     //gigo :: this is a work around for the jquery, curerently the these vars are entered into the system via a slickify jquery module that
     // seem to like to run thml entities upon the values of the items regardless of that is sent into it.
     $application = html_entity_decode($application);
     $industry = html_entity_decode($industry);
     $this->template->title = 'Inspirations';
     $view = new view(url::routes_area() . 'index');
     $where = array();
     // Filter the results by the application and industry if needed
     $view->selected_application = false;
     if ($application != 'all') {
         // find the application ID
         $application = orm::factory('application')->like('name', url::decode($application))->find();
         // gigo check
         if ($application->loaded) {
             $where['application_id'] = $application->id;
             // set the aopplication ID as part of the where, used when getting inspirations and its pagination
             $view->selected_application = $application;
             // set the vaule used to set the selected filter on the page.
         }
     }
     $view->selected_industry = false;
     if ($industry != 'all') {
         // find the application ID
         $industry = orm::factory('industry')->where('name', url::decode($industry))->find();
         // gigo check
         if ($industry->loaded) {
             $where['industry_id'] = $industry->id;
             // set the industry ID as part of the where, used when getting inspirations and its pagination
             $view->selected_industry = $industry;
             // set the vaule used to set the selected filter on the page.
         }
     }
     // add pagination, we are sending thorugh 16 items as this is easyly divisable.
     $total = orm::factory('inspiration');
     foreach ($where as $field => $value) {
         $total->where($field, $value);
     }
     $paging = new Pagination(array('total_items' => $total->count_all(), 'items_per_page' => self::NUMBER_OF_ITEMS_PER_PAGE));
     $inspirations = orm::factory('inspiration');
     foreach ($where as $field => $value) {
         $inspirations->where($field, $value);
     }
     $this->breadcrumbs->add()->url('inspiration')->title('Inspiration');
     $this->breadcrumbs->add()->url(false)->title('Showcase');
     $view->breadcrumbs = $this->breadcrumbs->cut();
     $view->inspirations = $inspirations->find_all($paging->items_per_page, $paging->sql_offset);
     $view->applications = orm::factory('application')->find_all();
     $view->industries = orm::factory('industry')->find_all();
     $view->pagination = $paging->render();
     $view->page_number = $paging->page_number();
     $this->template->content = $view;
 }
Beispiel #3
0
 /**
  * This will call the parentxontent controller to populate the view, while sending throught he type of content that it is 
  * as well as the paper_id, which will be used to autocomplete the paper combo box withg the correct result. 
  * @see Content_Controller::add()
  */
 public function add($paper_id = NULL)
 {
     $paper = orm::factory('paper', $paper_id);
     // load the paper so that we can get all the details required to populate the breadrumbs
     if ($paper->loaded) {
         $this->breadcrumbs->add()->url('products/papers/edit/' . url::encode($paper->name))->title(url::decode($paper->name));
         $this->breadcrumbs->add()->url('products/papers/technicals/index/' . $paper->id)->title('Technicals');
         $this->breadcrumbs->add()->url(false)->title('Add');
     }
     parent::add('technical', $paper->id);
 }
Beispiel #4
0
 /**
  * 根据参数生成完整的URL,如:url::build('site://zotop/index/default/arg1/arg2',array('param1'=>'1'),'#top')
  *
  * @param string 		$uri 		如:{application}://{module}/{controller}/{action}/{arg1}/arg2 组成
  * @param array|string 	$params 	URL参数 ,一般为数组,也可以是字符串,如:param1/1/param2/2
  * @param string 		$extra	 	额外数据:如锚点信息等
  * @return string		如:/index.php/module/controller/action/arg1/arg2?param1=1&param2=2#top
  */
 public static function build($uri = '', $params = null, $extra = '')
 {
     $application = '';
     if (strpos($uri, '://')) {
         list($application, $uri) = explode('://', $uri);
     }
     //获取入口文件地址
     if (empty($application)) {
         $base = url::scriptname();
     } else {
         $base = zotop::application($application, 'url') . '/' . zotop::application($application, 'base');
         $base = url::decode($base);
     }
     //uri处理
     if ($u = explode('/', trim($uri, '/'))) {
         //获取namespace 和 arguments
         $namespace = array_slice($u, 0, 3);
         $namespace = implode('/', $namespace);
         $arguments = array_slice($u, 3);
         //namespace切换
         $namespace = zotop::filter('zotop.namespace', $namespace, &$arguments);
         foreach ($arguments as $arg) {
             $querystring .= '/' . $arg;
         }
         //querystring
         $querystring = $namespace . $querystring;
         $querystring = empty($querystring) ? '' : '/' . $uri;
         $querystring .= empty($suffix) ? '' : $suffix;
     }
     //处理id/5/n/6 形式的参数
     if (!is_array($params)) {
         $args = explode('/', $params);
         while ($key = array_shift($args)) {
             $params[$key] = array_shift($args);
         }
     }
     if (is_array($params) && !empty($params)) {
         if (strpos($querystring, '?')) {
             $querystring .= '&' . http_build_query($params);
         } else {
             $querystring .= '?' . http_build_query($params);
         }
     }
     //组装url
     $url = $base . $querystring . $extra;
     $url = url::clean($url);
     return $url;
 }
Beispiel #5
0
 public function view($name)
 {
     $name = url::decode($name);
     // check it exists and is published
     $campaign = orm::factory('campaign')->where('name', $name)->where('status', 'approved')->find();
     if ($campaign->loaded) {
         $this->breadcrumbs->add()->url('campaigns')->title('Campaigns');
         $this->breadcrumbs->add()->url(false)->title($campaign->name);
         $this->template->title = 'Campaigns › ' . $campaign->name;
         $view = new view(url::location());
         $view->campaign = $campaign;
         $view->breadcrumbs = $this->breadcrumbs->cut();
         $this->template->content = $view;
     } else {
         $this->notification->add($this->i18n['system.campaign.invalid']);
         url::redirect(url::routes_area());
     }
 }
Beispiel #6
0
 /**
  * Add a sheet to a finsih/paper - allows adding multiple gsms.
  * @param string $paper_name the name of the paper - will be used to auto set the finish listbox
  */
 public function add($paper_name = NULL)
 {
     $paper_name = url::decode($paper_name);
     if ($this->access->allowed('sheets', 'create')) {
         $this->template->title = 'Add Sheet';
         $view = new view(url::routes_area() . 'add');
         $view->post = $this->post;
         $this->breadcrumbs->add()->url('products/papers/edit/' . url::encode($paper_name))->title($paper_name);
         $this->breadcrumbs->add()->url(url::routes_area() . 'index/' . url::encode($paper_name))->title('Sheets');
         $this->breadcrumbs->add()->url(false)->title('Add Sheet');
         $view->paper_name = $paper_name;
         $view->papers = ORM::factory('paper')->where('status !=', 'deleted')->find_all();
         $view->finishes = ORM::factory('finish')->find_all();
         $this->template->content = $view;
     } else {
         url::failed();
     }
 }
Beispiel #7
0
 /**
  * View a Paper
  */
 public function view($name)
 {
     $name = url::decode($name);
     // get the paper and populate the padded field, as we will be using to to display the gsm table.
     $paper = ORM::factory('paper')->where('name', $name)->where('status', 'approved')->find();
     //->populate_padded_gsm();
     if ($paper->loaded) {
         $view = new View('products/papers/view');
         $this->template->title = $paper->name;
         $this->breadcrumbs->add()->url(url::current())->title($paper->name);
         $view->breadcrumbs = $this->breadcrumbs->get();
         $view->finishes = $paper->finishes;
         $view->paper = $paper;
         $this->template->content = $view;
     } else {
         $this->notification->add($this->i18n['system.paper.error']);
         url::redirect(url::routes_area() . 'index');
     }
 }
Beispiel #8
0
 public function actionEdit($file = '')
 {
     $file = empty($file) ? zotop::get('file') : $file;
     $file = trim(url::decode($file), '/');
     $filepath = ZOTOP_PATH_ROOT . DS . str_replace('/', DS, $file);
     if (form::isPostBack()) {
         $content = request::post('source');
         $content = trim($content);
         if (empty($content)) {
             msg::error('内容为空,无法保存!');
         }
         file::write($filepath, trim($content));
         msg::success('内容保存成功!');
     }
     $filecontent = file::read($filepath);
     $page = new dialog();
     $page->title = '文件编辑器';
     $page->set('file', $file);
     $page->set('filepath', $filepath);
     $page->set('filecontent', $filecontent);
     $page->display();
 }
Beispiel #9
0
 public function actionIndex($dir = '')
 {
     $dir = empty($dir) ? zotop::get('dir') : $dir;
     $dir = url::decode($dir);
     $path = ZOTOP_PATH_ROOT . DS . trim($dir, DS);
     $path = path::clean($path);
     //获取当前目录的子目录及子文件
     $folders = (array) folder::folders($path);
     $files = (array) folder::files($path);
     $position = '<a href="' . zotop::url('webftp/index/index') . '">root</a>';
     $dirs = arr::dirpath($dir, '/');
     foreach ($dirs as $d) {
         $position .= ' <em>/</em> <a href="' . zotop::url('webftp/index/index', array('dir' => rawurlencode($d[1]))) . '">' . $d[0] . '</a>';
     }
     $page = new page();
     $page->title = '文件管理器';
     $page->set('position', $position);
     $page->set('navbar', $this->navbar($dir));
     $page->set('folders', $folders);
     $page->set('files', $files);
     $page->set('path', $path);
     $page->set('dir', $dir);
     $page->display();
 }
Beispiel #10
0
 /**
  * 模块的配置获取
  *
  * @param string|array $id 应用的ID,如:admin
  * @param string $key 键名称,如:name
  * @return mix
  */
 public function module($id = '', $key = '')
 {
     static $modules = array();
     if (empty($modules)) {
         $modules = (array) zotop::config('zotop.module');
     }
     if (is_array($modules)) {
         $modules += array('zotop' => array('id' => 'zotop', 'title' => 'zotop', 'path' => '$modules/zotop', 'url' => '$modules/zotop', 'status' => 1), 'system' => array('id' => 'system', 'title' => 'system', 'path' => '$modules/system', 'url' => '$modules/system', 'status' => 1));
         foreach ($modules as $k => $m) {
             $modules[$k]['path'] = path::decode($modules[$k]['path']);
             $modules[$k]['url'] = url::decode($modules[$k]['url']);
         }
     }
     if (empty($id)) {
         return $modules;
     }
     if (is_array($id)) {
         $modules = array_merge($modules, $id);
         zotop::config('zotop.module', $modules);
         return $modules;
     }
     //return module
     if (is_string($id)) {
         $module = array();
         if (isset($modules[strtolower($id)])) {
             $module = $modules[strtolower($id)];
         } else {
             return null;
         }
         if (empty($key)) {
             return $module;
         }
         return $module[strtolower($key)];
     }
 }
Beispiel #11
0
 public function actionDelete($file)
 {
     $file = empty($file) ? zotop::get('file') : $file;
     $file = trim(url::decode($file), '/');
     $filepath = site::template($file);
     if (file::delete($filepath)) {
         msg::success('删除成功', url::referer());
     }
     msg::error('删除失败');
 }
Beispiel #12
0
<div class="" style="width:100%;height:460px;overflow:hidden;">
	<div id="SourceEditorLoading" style="height:460px;line-height:460px;text-align:center;">正在加载编辑器,请稍后……</div>
	<div id="SourceEditorPannel"></div>
	<?php 
echo field::get('textarea', array('name' => 'source', 'value' => $content));
?>
	<script type="text/javascript">
		//显示按钮
		dialog.setTitle('编辑:<?php 
echo $file;
?>
').setWidth(800).setTip('小提示:快捷键 Ctrl+S 可以快速保存').setButtons([{text:'保 存',callback:save},{text:'关 闭'}]);
		//加载编辑器
		var so = new SWFObject("<?php 
echo url::decode('$common/swf/ScriptEditor.swf');
?>
", "SourceEditor", "100%", "460", "9", "#ffffff");
			so.addVariable("Language","<?php 
echo file::ext($file);
?>
");
			so.addVariable("AfterInit","setContent");
			so.addParam("wmode", "Opaque");
			so.write("SourceEditorPannel");
		
		function setContent(){
			content = $("textarea[name=source]").val();					
			$("#SourceEditor").get(0).setText(content);
			$('#SourceEditorLoading').hide();
		}
Beispiel #13
0
 /**
  * This method is used to display all of the papers with in an lightboxes
  *
  *57
  * @param $name the name of the lightboxes
  * @param $user the created of the lightboxes, we add this as a required, as a form of security through obsuritiy.
  * 				makes it alot harder to browse through lighboxes with out having the name and creator.
  */
 public function view_old($email, $name)
 {
     $redirect = true;
     // flag for redirecting on error.
     // readd any quotes it may have had
     $name = url::decode($name);
     if ($this->access->allowed('lightboxes', 'read')) {
         // get the user.
         $user = ORM::factory('user')->where('email', $email)->find();
         if ($user->loaded) {
             $lightbox = ORM::factory('lightbox')->where('creator_id', $user->id)->where('name', $name)->find();
             if ($lightbox->loaded) {
                 // only show if the lightboxes is public of if the owner is the person currently logged in.
                 if ($lightbox->status == 'approved' || $this->current && $this->current->id == $lightbox->creator_id) {
                     $view = new view(url::routes_area() . 'view');
                     // add one to the views for the lightbox.
                     $lightbox->views += 1;
                     $lightbox->save(false);
                     $view->lightbox = $lightbox;
                     if ($this->current && $this->current->id == $user->id) {
                         $view->is_owner = true;
                     }
                     $view->current_user = $this->current;
                     //$view->is_owner = ($this->current && $this->current->id == $user->id); // @todo :: add check against lightbox moderator priv.
                     $this->breadcrumbs->add()->url(url::current())->title($lightbox->name);
                     $view->breadcrumbs = $this->breadcrumbs->get();
                     $this->breadcrumbs->delete();
                     $this->template->content = $view;
                     $redirect = false;
                     // dont redirect as everythign worked.
                 } else {
                     $this->notification->add($this->i18n['system.lightbox.status']);
                 }
             } else {
                 $this->notification->add($this->i18n['system.lightbox.invalid']);
             }
         } else {
             $this->notification->add($this->i18n['system.user.invalid']);
         }
     } else {
         $this->notification->add($this->i18n['system.lightbox.login']);
     }
     // if there was an error, redirect away.
     if ($redirect) {
         url::redirect('account');
     }
 }
Beispiel #14
0
 public function edit($paper_name)
 {
     $paper_name = url::decode($paper_name);
     if ($this->access->allowed('papers', 'update')) {
         if ($paper_name) {
             $this->breadcrumbs->add()->url(false)->title($paper_name . ' Overview');
             $this->template->title = ucwords($paper_name);
             $view = new view(url::routes_area() . 'edit');
             $paper = ORM::factory('paper')->find(array('name' => $paper_name));
             if ($paper->loaded) {
                 $view->paper = $paper;
                 $view->finishes = ORM::factory('finish')->find_all();
                 $view->colors = ORM::factory('color')->find_all();
                 $view->characteristics = ORM::factory('characteristic')->find_all();
                 $view->styles = ORM::factory('style')->find_all();
                 $view->environmentals = ORM::factory('environmental')->find_all();
                 $view->availablities = ORM::factory('availablity')->find_all();
                 $view->applications = ORM::factory('application')->find_all();
                 $this->template->content = $view;
             } else {
                 $this->notification->add($this->i18n['system.paper.invalid'], $paper_name);
                 url::redirect(url::area());
             }
         } else {
             $this->notification->add($this->i18n['system.paper.invalid'], $paper_name);
             url::redirect(url::area());
         }
     } else {
         url::failed();
     }
 }
Beispiel #15
0
 /**
  * 模块的配置获取
  *
  * @param string|array $id 应用的ID,如:admin
  * @param string $key 键名称,如:name
  * @return mix
  */
 public function module($id = '', $key = '')
 {
     static $modules = array();
     //fetch config
     if (empty($modules)) {
         $modules = zotop::config('zotop.module');
     }
     //fetch default config
     if (empty($modules)) {
         $modules = (include ZPATH_CONFIG . DS . 'module.php');
         //set config
         zotop::config('zotop.module', $modules);
     }
     if (is_array($modules)) {
         foreach ($modules as $k => $m) {
             $modules[$k]['path'] = path::decode($modules[$k]['path']);
             $modules[$k]['url'] = url::decode($modules[$k]['url']);
         }
     }
     //return modules
     if (empty($id)) {
         return $modules;
     }
     //set and return modules
     if (is_array($id)) {
         $modules = array_merge($modules, $id);
         zotop::config('zotop.module', $modules);
         return $modules;
     }
     //return module
     if (is_string($id)) {
         $module = array();
         if (isset($modules[strtolower($id)])) {
             $module = $modules[strtolower($id)];
         }
         if (empty($key)) {
             return $module;
         }
         return $module[strtolower($key)];
     }
 }
Beispiel #16
0
 public static function script($href, $attrs = array())
 {
     static $scripts = array();
     $str = '';
     if (is_array($href)) {
         foreach ($href as $src) {
             $str .= html::script($src, $attrs);
         }
     } else {
         //如果不是是直接输出的话
         if (strpos($href, ';') == 0) {
             $href = url::clean($href);
             $href = url::decode($href);
             //一个页面只允许加载一次
             if (isset($scripts[strtolower($href)])) {
                 return '';
             }
             $scripts[strtolower($href)] = true;
             $attrs['type'] = 'text/javascript';
             $attrs['src'] = $href . '?v' . zotop::config('zotop.version');
             $str = '<script' . html::attributes($attrs) . '></script>';
         } else {
             $attrs['type'] = 'text/javascript';
             $str = '<script' . html::attributes($attrs) . '>' . $href . '</script>';
         }
     }
     return $str;
 }
Beispiel #17
0
 /**
  * 创建一个超链接传入uri或者完整的url
  *
  * @param string URL或者URI字符串
  * @param array 图片的其它属性
  * @return string 链接字符串
  *
  */
 public static function image($url, $attrs = array())
 {
     //如果不是完整的链接,如:http://www.zotop.com/a/b/1.gif ,则将相对连接处理成绝对链接
     if (strpos($url, '://') === false && $url[0] != '/') {
         $url = url::root() . '/' . $url;
     }
     //解析url中的特殊字符串
     $url = url::decode($url);
     return '<img src="' . $url . '" ' . html::attributes($attrs) . '/>';
 }
Beispiel #18
0
    form::header();
    table::header('list sortable');
    foreach ($configs as $config) {
        $type = $config['type'];
        $description = $config['description'];
        $settings = (array) json_decode($config['settings']);
        $attrs = array('name' => $config['id'], 'value' => $config['value']);
        $attrs = array_merge($attrs, $settings);
        $column = array();
        $input = '';
        if ($type == 'folder') {
            $input .= '<div style="float:left;width:50px;height:100%;text-align:center;"><img src="' . url::decode('$theme/image/fileext/big/folder.gif') . '" width="32px"></div>';
            $input .= '<a href="' . zotop::url('zotop/config/index', array('parentid' => $config['id'])) . '"><b>' . $config['title'] . '</b></a><h5>' . $config['description'] . '</h5>';
            $input .= field::get('hidden', $attrs);
        } else {
            $input .= '<div style="float:left;width:50px;height:100%;text-align:center;"><img src="' . url::decode('$theme/image/fileext/big/file.gif') . '" width="32px"></div>';
            $input .= '<div style="float:left;width:160px;height:100%;"><b>' . $config['title'] . '</b><h5 class="red">' . $config['id'] . '</h5></div>';
            $input .= '<div style="float:left;">' . field::get($type, $attrs) . '<h5>' . $config['description'] . '</h5>' . '</div>';
        }
        $column['input'] = $input;
        $column['manage edit'] = '<a href="' . zotop::url('zotop/config/edit', array('id' => $config['id'])) . '" class="dialog">修改</a>';
        $column['manage delete'] = '<a href="' . zotop::url('zotop/config/delete', array('id' => $config['id'])) . '" class="confirm">删除</a>';
        table::row($column, 'select');
    }
    table::footer();
    form::bottom('<span class="zotop-tip">拖动并保存,改变顺序</span>');
    form::footer(array(array('type' => 'submit', 'value' => '保 存'), array('type' => 'back')));
}
?>

<?php