Пример #1
0
 public function indexAction()
 {
     $messages = array();
     $form = new BootstrapForm('bootstrap');
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         $form->setData($post);
         $messages[] = _a('Form submitted successfully.');
         //$rename = 'demo_for_upload_%random%';
         $rename = function ($name) {
             //$extension = pathinfo($name, PATHINFO_EXTENSION);
             $name = 'test_for_upload_' . $name;
             return $name;
         };
         $uploader = new Upload(array('rename' => $rename));
         $uploader->setExtension('jpg,png,gif,txt,zip,rar');
         //->setRename('tmp.%random%');
         //->setImageSize(array('maxWidth' => 600, 'maxHeight' => 500));
         if ($uploader->isValid()) {
             $uploader->receive();
             $file = $uploader->getUploaded('upload_demo');
             $messages[] = sprintf(_a('File uploaded and saved as %s'), $file);
         }
     }
     $this->view()->assign(array('form' => $form, 'messages' => $messages));
 }
Пример #2
0
 /**
  * Edit a block
  */
 public function editAction()
 {
     if ($this->request->isPost()) {
         $id = $this->request->getPost('id');
     } else {
         $id = $this->params('id');
     }
     $widget = $this->getModel('widget')->find($id);
     $this->type = $widget->type;
     $form = $this->getForm();
     if ($this->request->isPost()) {
         $status = $this->processPost($form);
         if ($status > 0) {
             $message = _a('Block data saved successfully.');
             $this->jump(array('action' => 'index', 'name' => ''), $message);
             return;
         } elseif ($status < 0) {
             $message = _a('Block data not saved.');
         } else {
             $message = _a('Invalid data, please check and re-submit.');
         }
     } else {
         $blockRow = Pi::model('block_root')->find($widget->block);
         $values = $blockRow->toArray();
         $values['id'] = $id;
         $values['content'] = $widget->meta;
         $form->setData($values);
         $message = '';
     }
     $this->view()->assign('form', $form);
     $this->view()->assign('message', $message);
     $this->view()->setTemplate('system:component/form');
 }
Пример #3
0
 public function init()
 {
     $this->add(array('name' => 'title', 'options' => array('label' => __('Title')), 'attributes' => array('type' => 'text', 'required' => true)));
     $this->add(array('name' => 'name', 'options' => array('label' => __('Unique name')), 'attributes' => array('type' => 'text', 'required' => true)));
     $this->add(array('name' => 'description', 'options' => array('label' => __('Description')), 'attributes' => array('type' => 'text')));
     $set = '';
     switch ($this->contentType) {
         case 'html':
             $editor = 'html';
             break;
         case 'markdown':
             $editor = 'markitup';
             $set = 'markdown';
             break;
         case 'text':
         default:
             $editor = 'textarea';
             break;
     }
     $this->add(array('name' => 'content', 'options' => array('label' => __('Content'), 'editor' => $editor, 'set' => $set), 'attributes' => array('type' => 'editor', 'class' => 'span6', 'description' => _a('Tags supported: `%sitename%` - site name; `%siteurl%` - site root URL; `%slogan%` - site slogan'))));
     $this->add(array('name' => 'type', 'type' => 'hidden', 'attributes' => array('value' => $this->contentType)));
     $this->add(array('name' => 'security', 'type' => 'csrf'));
     $this->add(array('name' => 'id', 'type' => 'hidden'));
     $this->add(array('name' => 'submit', 'type' => 'submit', 'attributes' => array('value' => __('Submit'))));
 }
Пример #4
0
function get_info($sid, $type)
{
    $url = 'http://www.xiami.com/song/playlist/id/' . $sid . '/type/' . $type;
    $useCookie = $type == 9 ? 1 : null;
    $result = curl_http($url, $useCookie);
    $data = array();
    if ($result) {
        $res = str_replace(array('<![CDATA[', ']]>'), array('', ''), $result);
        if ($res == $result) {
            $data['info'] = '请使用国内代理!';
            return $data;
        }
        $res = preg_replace('/&(?!#?[a-z0-9]+;)/', '&amp;', $res);
        $xml = simplexml_load_string($res);
        $arr = json_decode(json_encode($xml), true);
        $html = '';
        $track = $arr['trackList']['track'];
        $close = '<div class="close" title="关闭">×</div>';
        if ($type == 0) {
            $song = 'http://www.xiami.com/song/gethqsong/sid/' . $sid;
            $json = curl_http($song, 1);
            $location = $json ? json_decode($json)->location : '';
            $location = $json ? $json['trackList']['track']['location'] : '';
            if ($location) {
                $data['src'] = get_location($location);
                $data['status'] = 1;
            } else {
                $data['info'] = '获取歌曲链接失败!';
                return $data;
            }
            $html = '<div class="info-item"><img src="' . $track['pic'] . '"><div><strong>标题:</strong>' . $track['songName'] . '</div><div><strong>艺人:</strong>' . _a($track['artist'], $track['artist_id'], 'artist') . '</div>';
            $html .= is_string($track['album_name']) ? '<div><strong>专辑:</strong>' . _a($track['album_name'], $track['album_id'], 'album') . '</div>' : '';
            $html .= is_string($track['lyric']) ? '<div><strong>歌词:</strong>' . $track['lyric'] . '</div>' : '';
            $html .= '<strong id="song">歌曲:</strong><div id="case"><label id="case-label"><input id="src" onmouseover="this.select()" value="' . $data['src'] . '"></label></div>';
            $html .= $close . '</div>';
        } else {
            $title = $type == 3 ? '精选集曲目:' : '今日歌单曲目:';
            $html = '<div class="info-item">';
            $html .= $type == 1 ? '<img src="' . $track[0]['pic'] . '"><div><strong>专辑:</strong>' . $track[0]['album_name'] . '</div><div><strong>艺人:</strong>' . _a($track[0]['artist'], $track[0]['artist_id'], 'artist') : '';
            $html .= $type == 2 ? '<div><strong>' . $track[0]['artist'] . '的热门曲目:</strong>' : '';
            $html .= $type == 3 || $type == 9 ? '<div><strong>' . $title . '</strong>' : '';
            $html .= '</div><ol>';
            foreach ($track as $item) {
                $html .= '<li>' . _a($item['songName'], $item['song_id'], 'song');
                $html .= $type == 3 || $type == 9 ? ' - ' . _a($item['artist'], $item['artist_id'], 'artist') : '';
                if ($type != 1) {
                    $html .= ' - 《' . _a($item['album_name'], $item['album_id'], 'album') . '》';
                }
                $html .= '</li>';
            }
            $html .= '</ol>' . $close . '</div>';
            $data['status'] = 1;
        }
        $data['info'] = htmlspecialchars($html);
    } else {
        $data['info'] = '解析失败!';
    }
    return $data;
}
Пример #5
0
 /**
  * {@inheritDoc}
  */
 public function init()
 {
     $this->add(array('name' => 'title', 'options' => array('label' => _a('Title')), 'attributes' => array('type' => 'text')));
     $this->add(array('name' => 'icon', 'options' => array('label' => _a('Font-awsome icon')), 'attributes' => array('type' => 'text', 'description' => _a('Check http://fortawesome.github.io/Font-Awesome/icons/'))));
     $this->add(array('name' => 'order', 'options' => array('label' => _a('Order')), 'attributes' => array('type' => 'text')));
     $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden')));
     $this->add(array('name' => 'op', 'attributes' => array('type' => 'hidden', 'value' => 'save')));
     $this->add(array('name' => 'submit', 'type' => 'submit', 'attributes' => array('class' => 'btn btn-primary')));
 }
Пример #6
0
 protected function assignModules()
 {
     $rowset = Pi::model('module')->select(array('active' => 1));
     $modules = array();
     foreach ($rowset as $row) {
         $modules[$row->id] = array('name' => $row->name, 'title' => $row->title);
     }
     $modules[0] = array('name' => '', 'title' => _a('Custom blocks'));
     $this->view()->assign('modules', array_values($modules));
 }
Пример #7
0
 /**
  * Analysis media data
  * 
  * @return ViewModel 
  */
 public function indexAction()
 {
     $module = $this->getModule();
     // Get top 10 media resources
     $topMedias = Pi::api('stats', $module)->getTopTotal(10);
     // Get top submitter
     $userSubmitToday = $this->getTopSubmitter(1, 10);
     $userSubmit7 = $this->getTopSubmitter(7, 10);
     $userSubmit30 = $this->getTopSubmitter(30, 10);
     $userSubmitEver = $this->getTopSubmitter(null, 10);
     $this->view()->assign(array('title' => _a('Statistic'), 'medias' => $topMedias, 'user' => array('today' => $userSubmitToday, 'week' => $userSubmit7, 'month' => $userSubmit30, 'ever' => $userSubmitEver)));
 }
Пример #8
0
 /**
  * {@inheritDoc}
  */
 protected function verifyResult(Result $result)
 {
     if (!$result->isValid()) {
         return $result;
     }
     $adminRoles = Pi::service('user')->getRole($result->getData('id'));
     if (!$adminRoles) {
         Pi::service('authentication')->clearIdentity();
         $result->setCode(-4)->setMessage(_a('Not privileged.'));
     }
     return $result;
 }
Пример #9
0
 /**
  * AJAX: Check update availability
  *
  * @return array
  */
 public function checkAction()
 {
     if ($this->request->isPost()) {
         // Type: module, theme
         $type = $this->params()->fromPost('type', 'module');
         // Names: name of modules to check
         $name = $this->params()->fromPost('name');
     } else {
         // Type: module, theme
         $type = $this->params('type', 'module');
         // Names: name of modules to check
         $name = $this->params('name');
     }
     if (is_scalar($name)) {
         // 1 - update available; 0 - no update; -1 - error occurred
         $status = rand(-1, 1);
         $version = '1.2.3';
         switch ($status) {
             case 1:
                 $message = sprintf(_a('A new version %s is available'), $version);
                 break;
             case 0:
                 $message = _a('No update available');
                 break;
             case -1:
             default:
                 $message = _a('Error occurred, check later.');
                 break;
         }
         $result = array('status' => $status, 'message' => $message);
     } else {
         foreach ($name as $key) {
             // 1 - update available; 0 - no update; -1 - error occurred
             $status = rand(-1, 1);
             $version = '1.2.3';
             switch ($status) {
                 case 1:
                     $message = sprintf(_a('A new version %s is available'), $version);
                     break;
                 case 0:
                     $message = _a('No update available');
                     break;
                 case -1:
                 default:
                     $message = _a('Error occurred, check later.');
                     break;
             }
             $result[$key] = array('status' => $status, 'message' => $message);
         }
     }
     return $result;
 }
Пример #10
0
 /**
  * Update carousel blocks
  *
  * @param Event $e
  * @return bool
  */
 public function updateCarousel(Event $e)
 {
     $version = $e->getParam('version');
     if (version_compare($version, '1.1.0', '>')) {
         return true;
     }
     $rowset = Pi::model('block_root')->select(array('type' => 'carousel'));
     foreach ($rowset as $row) {
         $row->config = array('width' => array('title' => _a('Image width'), 'edit' => 'text', 'filter' => 'int'), 'height' => array('title' => _a('Image height'), 'edit' => 'text', 'filter' => 'int'), 'interval' => array('title' => _a('Time interval (ms)'), 'edit' => 'text', 'filter' => 'int', 'value' => 4000), 'pause' => array('title' => _a('Mouse event'), 'description' => _a('Event to pause cycle'), 'edit' => array('type' => 'select', 'options' => array('options' => array('hover' => 'hover'))), 'value' => 'hover'));
         $row->save();
     }
     return true;
 }
Пример #11
0
 /**
  * Get admin mode list
  *
  * @param null|string $mode
  *
  * @return array
  */
 public static function modes($mode = null)
 {
     $modes = array(array('name' => AdminMode::MODE_ACCESS, 'label' => _a('Operation', 'system:admin'), 'icon' => 'fa fa-wrench'), array('name' => AdminMode::MODE_ADMIN, 'label' => _a('Setting', 'system:admin'), 'icon' => 'fa fa-cogs'), array('name' => AdminMode::MODE_DEPLOYMENT, 'label' => _a('Deployment', 'system:admin'), 'icon' => 'fa fa-cloud-upload', 'link' => ''));
     if (AdminMode::MODE_ADMIN == $mode) {
         $module = Pi::service('url')->getRouteMatch()->getParam('name');
     } else {
         $module = Pi::service('module')->current() ?: 'system';
     }
     array_walk($modes, function (&$config) use($mode, $module) {
         $config['active'] = $mode == $config['name'] ? 1 : 0;
         if (!isset($config['link'])) {
             $config['link'] = Pi::service('url')->assemble('admin', array('module' => 'system', 'controller' => 'dashboard', 'action' => 'mode', 'mode' => $config['name']), array('query' => array('name' => $module)));
         }
     });
     return $modes;
 }
Пример #12
0
 /**
  * Add a block
  *
  * @param array  $block
  * @param string $type
  *
  * @return array
  */
 public function add(array $block, $type = '')
 {
     $type = $type ?: $block['type'];
     switch ($type) {
         case 'list':
             $block['config'] = array('width' => array('title' => _a('Image width'), 'edit' => 'text', 'filter' => 'int'), 'height' => array('title' => _a('Image height'), 'edit' => 'text', 'filter' => 'int'));
             break;
         case 'carousel':
             $block['config'] = array('width' => array('title' => _a('Image width'), 'edit' => 'text', 'filter' => 'int'), 'height' => array('title' => _a('Image height'), 'edit' => 'text', 'filter' => 'int'), 'interval' => array('title' => _a('Time interval (ms)'), 'edit' => 'text', 'filter' => 'int', 'value' => 4000), 'pause' => array('title' => _a('Mouse event'), 'description' => _a('Event to pause cycle'), 'edit' => array('type' => 'select', 'options' => array('options' => array('hover' => 'hover'))), 'value' => 'hover'));
             break;
         default:
             break;
     }
     $result = Pi::api('block', 'system')->add($block);
     return $result;
 }
Пример #13
0
 /**
  * Dashboard
  *
  * @return void
  */
 public function indexAction()
 {
     //$module = $this->params('module');
     $module = $this->params('name', $this->moduleName('system'));
     // Jump to a specific component if available
     $navConfig = Pi::registry('navigation')->read('system-component');
     if ($navConfig) {
         foreach ($navConfig as $key => $config) {
             $page = $config;
             break;
         }
         $this->redirect($page['route'], array('module' => $page['module'], 'controller' => $page['controller'], 'name' => $module));
     }
     // Display module dashboard
     $directory = Pi::service('module')->directory($module);
     $callback = sprintf('Module\\%s\\Dashboard::summary', ucfirst($directory));
     $summary = '';
     if (is_callable($callback)) {
         $summary = call_user_func($callback, $module);
     }
     $modules = Pi::registry('modulelist')->read();
     $data = $modules[$module];
     $meta = Pi::service('module')->loadMeta($directory, 'meta');
     $author = Pi::service('module')->loadMeta($directory, 'author');
     $data['description'] = $meta['description'];
     $data['author'] = $author;
     /*
     if (empty($meta['logo'])) {
         $data['logo'] = Pi::url('static/image/module.png');
     } else {
         $data['logo'] = Pi::service('asset')->getModuleAsset(
             $meta['logo'],
             $module
         );
     }
     */
     if (empty($data['update'])) {
         $data['update'] = _a('Never updated.');
     } else {
         $data['update'] = _date($data['update']);
     }
     $this->view()->assign('summary', $summary);
     $this->view()->assign('data', $data);
     $this->view()->assign('title', _a('Dashboard'));
     $this->view()->setTemplate('dashboard-module', 'system');
 }
Пример #14
0
 /**
  * Add a root category, and its child as default category
  * 
  * @param Event $e 
  */
 public function initCategory(Event $e)
 {
     // Skip if the initial data is exists
     $sqlPath = sprintf('%s/%s', Pi::path('module'), self::INIT_FILE_NAME);
     if (file_exists($sqlPath)) {
         return true;
     }
     // Add a root category and its child category
     $module = $this->event->getParam('module');
     $model = Pi::model('category', $module);
     $data = array('id' => null, 'name' => 'root', 'slug' => 'root', 'title' => _a('Root'), 'description' => _a('Module root category'));
     $result = $model->add($data);
     $defaultCategory = array('id' => null, 'name' => 'default', 'slug' => 'slug', 'title' => _a('Default'), 'description' => _a('The default category can not be delete, but can be modified!'));
     $parent = $model->select(array('name' => 'root'))->current();
     $model->add($defaultCategory, $parent);
     return $result;
 }
Пример #15
0
function flatly_hook_themes_submenu($content = '')
{
    global $user_config;
    $separator = "&nbsp;&nbsp;&nbsp;";
    $logged_in = $user_config['username'];
    $tooltips_logged_in = _('Logged in as') . ' ' . $logged_in;
    $credit = $user_config['credit'];
    $tooltips_credit = _('Your credit');
    $ret = '<div>';
    $ret .= '<span class="playsms-icon glyphicon glyphicon-user" alt="' . $tooltips_logged_in . '" title="' . $tooltips_logged_in . '"></span>' . $logged_in;
    $ret .= $separator . '<span class="playsms-icon glyphicon glyphicon-usd" alt="' . $tooltips_credit . '" title="' . $tooltips_credit . '"></span><div id="submenu-credit-show">' . $credit . '</div>';
    if (auth_login_as_check()) {
        $ret .= $separator . _a('index.php?app=main&inc=core_auth&route=logout', _('return'));
    }
    $ret .= $content;
    $ret .= '</div>';
    return $ret;
}
Пример #16
0
 /**
  * Default page 
  */
 public function indexAction()
 {
     $topVisitsEver = Entity::getTotalVisits(10);
     $topVisits7 = Entity::getVisitsRecently(7, 10);
     $topVisits30 = Entity::getVisitsRecently(30, 10);
     $totalEver = Stats::getTotalRecently();
     $total7 = Stats::getTotalRecently(7);
     $total30 = Stats::getTotalRecently(30);
     $totalEverByCategory = Stats::getTotalRecentlyByCategory();
     $total7ByCategory = Stats::getTotalRecentlyByCategory(7);
     $total30ByCategory = Stats::getTotalRecentlyByCategory(30);
     $topSubmittersEver = Stats::getSubmittersRecently(null, 10);
     $topSubmitters7 = Stats::getSubmittersRecently(7, 10);
     $topSubmitters30 = Stats::getSubmittersRecently(30, 10);
     if ($this->config('enable_tag') && Pi::service('tag')->active()) {
         $topTags = Pi::service('tag')->top(10, $this->getModule(), null);
         $this->view()->assign('topTags', $topTags);
     }
     $this->view()->assign(array('title' => _a('Statistic'), 'topVisitsEver' => $topVisitsEver, 'topVisits7' => $topVisits7, 'topVisits30' => $topVisits30, 'totalEver' => $totalEver, 'total7' => $total7, 'total30' => $total30, 'totalEverByCategory' => $totalEverByCategory, 'total7ByCategory' => $total7ByCategory, 'total30ByCategory' => $total30ByCategory, 'topSubmittersEver' => $topSubmittersEver, 'topSubmitters7' => $topSubmitters7, 'topSubmitters30' => $topSubmitters30));
 }
Пример #17
0
 /**
  * Create blocks
  *
  * @param Event $e
  */
 public function createBlock(Event $e)
 {
     $model = Pi::model('widget', 'widget');
     /*
     // Feature block
     $block = array(
         'module'        => 'widget',
         'name'          => 'feature',
         'title'         => _a('Pi Engine features'),
         'description'   => _a('Introduction to Pi Engine.'),
         'type'          => 'html',
         'content'       => _a('WIDGET_PI_ENGINE_FEATURE'),
     );
     $result = Pi::api('block', 'system')->add($block);
     $id = $result['root'];
     if ($id) {
         $widget = array(
             'block' => $id,
             'name'  => $block['name'],
             'meta'  => $block['content'],
             'type'  => $block['type'],
             'time'  => time(),
         );
         $row = $model->createRow($widget);
         $row->save();
     }
     */
     // Spotlight block
     $block = array('module' => 'widget', 'name' => 'highlights', 'title' => _a('Pi Highlights'), 'description' => _a('Introduction to Pi Engine with carousel.'), 'type' => 'carousel', 'template' => 'carousel/bootstrap');
     $images = array(array('caption' => _a('Sustainable ecosystem'), 'desc' => _a('A sustainable ecosystem built upon open standard, open source code, open development and open management on Github.'), 'link' => 'http://pialog.org', 'image' => Pi::url('static/image/pi-ecosystem.png')), array('caption' => _a('Engineered development'), 'desc' => _a('Quality ensured engineering development with short learning curve, low skill requirements with clean MVC architecture, semantic templating, sophisticated API and strict starndards.'), 'link' => 'http://pialog.org', 'image' => Pi::url('static/image/pi-engineering.png')), array('caption' => _a('Visualization of application management'), 'desc' => _a('Easy and responsive application and content management based on visualized mangement tools and interface with page and widget mechanism.'), 'link' => 'http://pialog.org', 'image' => Pi::url('static/image/pi-visualization.png')), array('caption' => _a('Agile compliant development workflow'), 'desc' => _a('Role oriented architecture and deployment skeleton supports managable agile development workflow.'), 'link' => 'http://pialog.org', 'image' => Pi::url('static/image/pi-agile.png')));
     $block['content'] = json_encode($images);
     $result = Pi::api('block', 'widget')->add($block);
     $id = $result['root'];
     if ($id) {
         $widget = array('block' => $id, 'name' => $block['name'], 'meta' => $block['content'], 'type' => $block['type'], 'time' => time());
         $row = $model->createRow($widget);
         $row->save();
     }
 }
Пример #18
0
 public function init()
 {
     $this->add(array('name' => 'title', 'options' => array('label' => _a('Page title')), 'attributes' => array('type' => 'text')));
     $this->add(array('name' => 'name', 'options' => array('label' => _a('Unique name')), 'attributes' => array('type' => 'text', 'description' => _a('Only alphabet, number and underscore allowed.'))));
     $this->add(array('name' => 'slug', 'options' => array('label' => _a('SEO slug')), 'attributes' => array('type' => 'text', 'description' => _a('Unique slug for SEO URL.'))));
     if ('phtml' == $this->markup) {
         $this->add(array('name' => 'content', 'options' => array('label' => _a('Template name')), 'attributes' => array('description' => _a('Select a template from `usr/custom/module/page/template/front/` w/o extension.'))));
     } else {
         $set = '';
         switch ($this->markup) {
             case 'html':
                 $editor = 'html';
                 break;
             case 'markdown':
                 $editor = 'markitup';
                 $set = 'markdown';
                 break;
             case 'text':
             default:
                 $editor = 'textarea';
                 break;
         }
         $this->add(array('name' => 'content', 'type' => 'editor', 'options' => array('label' => _a('Content'), 'editor' => $editor, 'set' => $set), 'attributes' => array('rows' => 5)));
     }
     // extra_seo
     $this->add(array('name' => 'extra_seo', 'type' => 'fieldset', 'options' => array('label' => _a('SEO settings'))));
     // seo_title
     $this->add(array('name' => 'seo_title', 'options' => array('label' => _a('SEO Title')), 'attributes' => array('type' => 'text', 'description' => _a('To be used for HTML head meta.'))));
     // seo_keywords
     $this->add(array('name' => 'seo_keywords', 'options' => array('label' => _a('SEO Keywords')), 'attributes' => array('type' => 'text', 'description' => _a('To be used for HTML head meta.'))));
     // seo_description
     $this->add(array('name' => 'seo_description', 'options' => array('label' => _a('SEO Description')), 'attributes' => array('type' => 'text', 'description' => _a('To be used for HTML head meta.'))));
     // Enable for online
     $this->add(array('name' => 'active', 'type' => 'checkbox', 'options' => array('label' => _a('Active')), 'attributes' => array('value' => '1')));
     $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden', 'value' => 0)));
     $this->add(array('name' => 'markup', 'attributes' => array('type' => 'hidden', 'value' => $this->markup)));
     $this->add(array('name' => 'submit', 'type' => 'submit', 'attributes' => array('value' => __('Submit'))));
 }
Пример #19
0
 /**
  * List of custom pages
  */
 public function indexAction()
 {
     $templates = array();
     $path = Pi::path('custom/module/page/template/front');
     $iterator = new \DirectoryIterator($path);
     foreach ($iterator as $fileinfo) {
         if (!$fileinfo->isFile()) {
             continue;
         }
         $name = $fileinfo->getFilename();
         $extension = pathinfo($name, PATHINFO_EXTENSION);
         if ('phtml' != $extension) {
             continue;
         }
         $name = pathinfo($name, PATHINFO_FILENAME);
         $file = $fileinfo->getPathname();
         $template = array('name' => $name, 'time' => filemtime($file), 'size' => filesize($file));
         $templates[] = $template;
     }
     $this->view()->assign('templates', $templates);
     $this->view()->assign('title', _a('Template list'));
     $this->view()->setTemplate('template-list');
 }
Пример #20
0
 /**
  * Pre-install pages for: Terms of service, Privacy,
  * About us, Contact us, Join us, Help, Sitemap
  *
  * @param Event $e
  */
 public function postInstall(Event $e)
 {
     $module = $e->getParam('module');
     $apiHandler = Pi::api('api', 'page')->setModule($module);
     // Add demo pages
     $path = Pi::service('i18n')->getPath(array('module/page', '')) . '/install';
     if (!is_dir($path)) {
         $path = Pi::service('i18n')->getPath(array('module/page', ''), 'en') . '/install';
     }
     $metaFile = $path . '/meta.txt';
     $meta = array_map('trim', file($metaFile));
     $meta = array_filter($meta);
     $pages = array_chunk($meta, 3);
     foreach ($pages as $page) {
         if (count($page) < 3) {
             break;
         }
         list($name, $markup, $title) = $page;
         $file = sprintf('%s/%s.txt', $path, $name);
         if (file_exists($file)) {
             $content = file_get_contents($file);
             $content = str_replace(array('SITE_URL', 'SITE_NAME'), array(Pi::url('www'), Pi::config('sitename')), $content);
         } else {
             $content = '';
         }
         $page = compact('name', 'markup', 'title', 'content');
         $apiHandler->add($page);
     }
     // Add pre-defined pages
     $pages = array(array('name' => 'demo', 'slug' => 'phtml-demo', 'markup' => 'phtml', 'title' => _a('Demo for PHTML page'), 'content' => 'page-demo'), array('name' => 'feed', 'slug' => 'feed', 'markup' => 'phtml', 'title' => _a('RSS Feed'), 'content' => 'page-feed'), array('name' => 'sitemap', 'slug' => 'sitemap', 'markup' => 'phtml', 'title' => _a('Sitemap'), 'content' => 'page-sitemap'), array('name' => 'xml-sitemap', 'slug' => 'xml-sitemap', 'markup' => 'phtml', 'title' => _a('XML Sitemap'), 'content' => 'page-xml-sitemap'));
     foreach ($pages as $page) {
         $apiHandler->add($page);
     }
     $result = array('status' => true, 'message' => _a('Pages added.'));
     $this->setResult('post-install', $result);
 }
Пример #21
0
 /**
  * Enable/disable a type
  *
  * @return bool
  */
 public function enableAction()
 {
     $id = _get('id', 'int') ?: 1;
     $flag = _get('flag', 'int');
     $return = _get('return');
     $row = Pi::model('type', 'comment')->find($id);
     if (!$row) {
         $status = -1;
         $message = _a('Type was not found.');
     } else {
         if ($flag == (int) $row['active']) {
             $status = 0;
             $message = _a('Invalid operation.');
         } else {
             $row['active'] = $flag;
             try {
                 $row->save();
                 $status = 1;
                 $message = _a('Operation succeeded.');
             } catch (\Exception $e) {
                 $status = 0;
                 $message = _a('Operation failed.');
             }
         }
     }
     // Clear cache
     if ($status > 0) {
         Pi::registry('type', 'comment')->flush();
     }
     if (!$return) {
         $this->jump(array('action' => 'index'), $message, $status == 1 ? 'success' : 'error');
     } else {
         $result = array('status' => (int) $status, 'message' => $message, 'data' => $id);
         return $result;
     }
 }
Пример #22
0
<?php

/**
 * Pi Engine (http://pialog.org)
 *
 * @link            http://code.pialog.org for the Pi Engine source repository
 * @copyright       Copyright (c) Pi Engine http://pialog.org
 * @license         http://pialog.org/license.txt New BSD License
 */
/**
 * @author Hossein Azizabadi <*****@*****.**>
 */
return array('category' => array(array('title' => _a('Admin'), 'name' => 'admin'), array('title' => _a('News module'), 'name' => 'news'), array('title' => _a('Guide module'), 'name' => 'guide'), array('title' => _a('View'), 'name' => 'view'), array('title' => _a('Social'), 'name' => 'social'), array('title' => _a('Manage'), 'name' => 'manage'), array('title' => _a('Order'), 'name' => 'order')), 'item' => array('admin_perpage' => array('category' => 'admin', 'title' => _a('Perpage'), 'description' => '', 'edit' => 'text', 'filter' => 'number_int', 'value' => 10), 'use_news_topic' => array('category' => 'news', 'title' => _a('Use news topics'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'use_guide_category' => array('category' => 'guide', 'title' => _a('Use guide category'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'use_guide_location' => array('category' => 'guide', 'title' => _a('Use guide location'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'filter_location_level' => array('title' => _a('Select location level for show on filter form'), 'description' => '', 'edit' => array('type' => 'select', 'options' => array('options' => array(1 => _a('level 1'), 2 => _a('level 2'), 3 => _a('level 3'), 4 => _a('level 4'), 5 => _a('level 5')))), 'filter' => 'number_int', 'value' => 1, 'category' => 'guide'), 'view_list_type' => array('title' => _a('Event list type'), 'description' => '', 'edit' => array('type' => 'select', 'options' => array('options' => array('line' => _a('Line : each event on one line'), 'box' => _a('Box : each event as box and 3 box on one line')))), 'filter' => 'text', 'value' => 'event', 'category' => 'view'), 'view_perpage' => array('category' => 'view', 'title' => _a('Perpage'), 'description' => '', 'edit' => 'text', 'filter' => 'number_int', 'value' => 10), 'related_event' => array('category' => 'view', 'title' => _a('Show related event'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'related_event_type' => array('title' => _a('Related event type'), 'description' => '', 'edit' => array('type' => 'select', 'options' => array('options' => array('event' => _a('By event module topics'), 'guide' => _a('By guide module categories')))), 'filter' => 'text', 'value' => 'event', 'category' => 'view'), 'image_homepage' => array('category' => 'view', 'title' => _a('Set wide image for homepage'), 'description' => '', 'edit' => 'text', 'filter' => 'string', 'value' => ''), 'price_filter' => array('category' => 'view', 'title' => _a('Price filter'), 'description' => _a('Input method : 100-200,Between 100 to 200|200-300,Between 200 to 300|'), 'edit' => 'textarea', 'filter' => 'string', 'value' => ''), 'social_sharing' => array('title' => _t('Social sharing items'), 'description' => '', 'edit' => array('type' => 'multi_checkbox', 'options' => array('options' => Pi::service('social_sharing')->getList())), 'filter' => 'array', 'category' => 'social'), 'manage_active' => array('category' => 'manage', 'title' => _a('Manage event by users'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'manage_approval' => array('category' => 'manage', 'title' => _a('Auto approval user events'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'order_active' => array('category' => 'order', 'title' => _a('Active order'), 'description' => _a('Manage event registration, ticket stock and activate orders'), 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'order_free' => array('category' => 'order', 'title' => _a('Show free word for free events'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'order_discount' => array('category' => 'order', 'title' => _a('Active discount system'), 'description' => _a('Discount percent for each rule on each event'), 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'text_description_index' => array('category' => 'head_meta', 'title' => _a('Description for index page'), 'description' => '', 'edit' => 'textarea', 'filter' => 'string', 'value' => '')));
Пример #23
0
    public function home()
    {
        global $core, $bio;
        $page = 15;
        $today = _htimestamp('md');
        _pre($bio->v('is_bio'), true);
        _style('status_post');
        // Friends birthday
        if ($bio->v('auth_member')) {
            $sql = "SELECT bio_id, bio_alias, bio_name\r\n\t\t\t\tFROM _bio\r\n\t\t\t\tWHERE bio_id IN (\r\n\t\t\t\t\t\tSELECT fan_of\r\n\t\t\t\t\t\tFROM _bio_fans\r\n\t\t\t\t\t\tWHERE fan_assoc = ?\r\n\t\t\t\t\t)\r\n\t\t\t\t\tAND bio_active = ?\r\n\t\t\t\t\tAND bio_birth LIKE '%??'\r\n\t\t\t\tORDER BY bio_name";
            $birthday = _rowset(sql_filter($sql, $bio->v('bio_id'), 1, $today));
        } else {
            $sql = "SELECT bio_id, bio_alias, bio_name, bio_avatar, bio_avatar_up\r\n\t\t\t\tFROM _bio\r\n\t\t\t\tWHERE bio_level = ?\r\n\t\t\t\t\tAND bio_birth LIKE '%??'\r\n\t\t\t\tORDER BY bio_name";
            $birthday = _rowset(sql_filter($sql, 1, $today));
        }
        foreach ($birthday as $i => $row) {
            if (!$i) {
                _style('birthday');
            }
            _style('birthday.row', array('A' => _a($row), 'NAME' => $row['bio_name'], 'AVATAR' => _avatar($row)));
        }
        // Board topics
        if ($bio->v('auth_member')) {
            $sql = 'SELECT t.topic_id, t.topic_alias, t.topic_title, h.highlight_class
				FROM _board_topics t
				INNER JOIN _board_forums f ON f.forum_id = t.topic_forum
				LEFT JOIN _board_highlight h ON t.topic_highlight = h.highlight_id
				RIGHT JOIN _board_disallow d ON t.topic_id = d.disallow_topic AND d.disallow_bio = ?
				WHERE t.topic_show = ?
				ORDER BY t.topic_shine DESC, t.topic_time DESC
				LIMIT ??';
            $topics = _rowset(sql_filter($sql, $bio->v('bio_id'), 1, 10));
        } else {
            $sql = 'SELECT t.topic_id, t.topic_alias, t.topic_title, h.highlight_class
				FROM _board_topics t
				INNER JOIN _board_forums f ON f.forum_id = t.topic_forum
				LEFT JOIN _board_highlight h ON t.topic_highlight = h.highlight_id
				WHERE t.topic_show = ?
				ORDER BY t.topic_shine DESC, t.topic_time DESC
				LIMIT ??';
            $topics = _rowset(sql_filter($sql, 1, 10));
        }
        foreach ($topics as $i => $row) {
            if (!$i) {
                _style('board_topics');
            }
            _style('board_topics.row', _vs(array('ID' => $row['topic_id'], 'TITLE' => $row['topic_title'], 'CLASS' => $row['highlight_class']), 'TOPIC'));
        }
        if ($bio->v('auth_member')) {
            // Messages
            $sql = 'SELECT *
				FROM _bio_messages
				INNER JOIN _bio ON message_from = bio_id
				INNER JOIN _bio_messages_type ON message_type = type_id
				WHERE message_to = ?
					AND message_active = ?
				ORDER BY message_time DESC';
            $messages = _rowset(sql_filter($sql, $bio->v('bio_id'), 1));
            foreach ($messages as $i => $row) {
                if (!$i) {
                    _style('messages');
                }
                _style('messages.row', array('U_MESSAGE' => _link(), '' => ''));
            }
            // Friend requests
            $sql = 'SELECT b.bio_alias, b.bio_name
				FROM _bio_friends
				INNER JOIN _bio ON friend_assoc = bio_id
				WHERE friend_bio = ?
					AND friend_pending = ?
				ORDER BY friend_time DESC';
            $requests = _rowset(sql_filter($sql, $bio->v('bio_id'), 1));
            foreach ($requests as $i => $row) {
                if (!$i) {
                    _style('friend_request');
                }
                _style('friend_request.row', array('U_APPROVE' => _link('home', array('x1' => 'friend', 'x2' => 'approve', 'a' => $row['bio_alias'])), 'U_DENY' => _link('home', array('x1' => 'friend', 'x2' => 'deny', 'a' => $row['bio_alias'])), 'A' => _a($row), 'BIO_NAME' => $row['bio_name']));
            }
        }
        // Banners
        $this->announce('home');
        return;
    }
Пример #24
0
<?php

/**
 * Pi Engine (http://pialog.org)
 *
 * @link            http://code.pialog.org for the Pi Engine source repository
 * @copyright       Copyright (c) Pi Engine http://pialog.org
 * @license         http://pialog.org/license.txt New BSD License
 */
/**
 * @author Hossein Azizabadi <*****@*****.**>
 */
return array('front' => array('manage' => array('label' => _a('Manage events'), 'permission' => array('resource' => 'manage'), 'route' => 'event', 'module' => 'event', 'controller' => 'manage')), 'admin' => array('event' => array('label' => _a('Event'), 'permission' => array('resource' => 'event'), 'route' => 'admin', 'module' => 'event', 'controller' => 'event', 'action' => 'index'), 'order' => array('label' => _a('List of order'), 'permission' => array('resource' => 'order'), 'route' => 'admin', 'module' => 'event', 'controller' => 'order', 'action' => 'index'), 'tools' => array('label' => _a('Tools'), 'permission' => array('resource' => 'tools'), 'route' => 'admin', 'module' => 'event', 'controller' => 'tools', 'action' => 'index')));
Пример #25
0
<?php

/**
 * Pi Engine (http://pialog.org)
 *
 * @link            http://code.pialog.org for the Pi Engine source repository
 * @copyright       Copyright (c) Pi Engine http://pialog.org
 * @license         http://pialog.org/license.txt New BSD License
 */
/**
 * @author Hossein Azizabadi <*****@*****.**>
 */
return array('admin' => array('plans' => array('title' => _a('Plans'), 'access' => array()), 'category' => array('title' => _a('Category'), 'access' => array()), 'order' => array('title' => _a('Order'), 'access' => array())));
Пример #26
0
<?php

/**
 * Pi Engine (http://pialog.org)
 *
 * @link            http://code.pialog.org for the Pi Engine source repository
 * @copyright       Copyright (c) Pi Engine http://pialog.org
 * @license         http://pialog.org/license.txt New BSD License
 */
/**
 * @author Hossein Azizabadi <*****@*****.**>
 */
return array('meta' => array('title' => _a('Support'), 'description' => _a('Support ticket system'), 'version' => '0.1.1', 'license' => 'New BSD', 'logo' => 'image/logo.png', 'readme' => 'docs/readme.txt', 'demo' => 'http://pialog', 'icon' => 'fa-life-ring'), 'author' => array('Name' => 'Hossein Azizabadi', 'email' => '*****@*****.**', 'website' => 'http://pialog', 'credits' => 'Pi Engine Team'), 'resource' => array('database' => 'database.php', 'config' => 'config.php', 'permission' => 'permission.php', 'page' => 'page.php', 'navigation' => 'navigation.php', 'route' => 'route.php'));
Пример #27
0
 /**
  * Users of a role
  */
 public function userAction()
 {
     $role = $this->params('name', 'member');
     // Operation: add, remove
     $op = $this->params('op');
     // User value
     $name = $this->params('user');
     // User value field: uid, identity, name, email
     $field = $this->params('field', 'uid');
     $roles = Pi::registry('role')->read();
     $model = Pi::model('user_role');
     //$message = '';
     if ($op && $name) {
         if ('remove' == $op) {
             $uid = (int) $name;
             $data = array('role' => $role, 'uid' => $uid);
             $count = $model->count($data);
             if ($count) {
                 $status = 1;
                 $model->delete($data);
                 $message = _a('User removed from the role.');
                 $data = array('id' => $uid);
             } else {
                 $status = 0;
                 $message = _a('User not in the role.');
                 $data = array('id' => $uid);
             }
         } else {
             if ('uid' == $field) {
                 $name = (int) $name;
                 $field = 'id';
             }
             $user = Pi::service('user')->getUser($name, $field);
             $uid = $user ? (int) $user->get('id') : 0;
             if ($uid) {
                 $data = array('role' => $role, 'uid' => $uid);
                 $count = $model->count($data);
                 if (!$count) {
                     $status = 1;
                     $data['section'] = $roles[$role]['section'];
                     $row = $model->createRow($data);
                     $row->save();
                     $message = _a('User added to the role.');
                     $data = array('id' => $uid, 'name' => Pi::service('user')->get($uid, 'name'), 'url' => Pi::service('user')->getUrl('profile', $uid));
                     if (1 == $status) {
                         $this->setAccount($user, $role);
                     }
                 } else {
                     $status = 0;
                     $message = _a('User already in the role.');
                     $data = array('uid' => $uid);
                 }
             } else {
                 $status = 0;
                 $message = _a('User not found.');
                 $data = array('name' => $name);
             }
         }
         return compact('status', 'message', 'data');
     }
     $page = _get('page', 'int') ?: 1;
     $limit = 20;
     $offset = ($page - 1) * $limit;
     $select = $model->select();
     $select->where(array('role' => $role))->limit(20)->offset($offset);
     $rowset = $model->selectWith($select);
     $uids = array();
     foreach ($rowset as $row) {
         $uids[] = (int) $row['uid'];
     }
     $users = Pi::service('user')->mget($uids, array('id', 'name'));
     $avatars = Pi::service('avatar')->getList($uids, 'small');
     array_walk($users, function (&$user) use($avatars) {
         //$user['avatar'] = $avatars[$uid];
         $user['url'] = Pi::service('user')->getUrl('profile', $user['id']);
     });
     foreach ($uids as $uid) {
         if (isset($users[$uid])) {
             continue;
         }
         $users[$uid] = array('id' => $uid, 'name' => '');
     }
     $count = $model->count(array('role' => $role));
     if ($count >= $limit) {
         $count = $model->count(array('role' => $role));
     }
     /*
     $paginator = Paginator::factory($count, array(
         'page'          => $page,
         'url_options'   => array(
             'params'    => array('role' => $role),
         ),
     ));
     */
     $title = sprintf(_a('Users of role %s'), $roles[$role]['title']);
     $paginator = array('page' => $page, 'count' => $count, 'limit' => $limit);
     $data = array('title' => $title, 'users' => array_values($users), 'paginator' => $paginator);
     return $data;
 }
Пример #28
0
<?php

/**
 * Pi Engine (http://pialog.org)
 *
 * @link            http://code.pialog.org for the Pi Engine source repository
 * @copyright       Copyright (c) Pi Engine http://pialog.org
 * @license         http://pialog.org/license.txt BSD 3-Clause License
 */
/**
 * Comment specs
 *
 * @see Pi\Application\Installer\Resource\Comment
 * @author Taiwen Jiang <*****@*****.**>
 */
return array('article' => array('title' => _a('Article comments'), 'icon' => 'icon-post', 'callback' => 'Module\\Comment\\Api\\Article', 'locator' => array('controller' => 'demo', 'action' => 'index', 'identifier' => 'id', 'params' => array('enable' => 'yes'))), 'custom' => array('title' => _a('Custom comments'), 'icon' => 'icon-post', 'callback' => 'Module\\Comment\\Api\\Custom', 'locator' => 'Module\\Comment\\Api\\Custom'));
Пример #29
0
 public function __construct()
 {
     $this->messageTemplates = array(self::TAKEN => _a('Page name already exists.'));
     parent::__construct();
 }
Пример #30
0
 /**
  * AJAX method to rename a module
  *
  * @return array Result pair of status and message
  */
 public function renameAction()
 {
     //$post = $this->params()->fromPost();
     $title = _post('title');
     if (empty($title)) {
         return array('status' => 0, 'message' => _a('Title is required.'));
     }
     $id = _post('id', 'int');
     $name = _post('name', 'regexp', array('regexp' => '/^[a-z0-9_]+$/i'));
     if ($id) {
         $row = Pi::model('module')->find($id);
     } else {
         $row = Pi::model('module')->find($name, 'name');
     }
     if (!$row) {
         return array('status' => 0, 'message' => _a('Module is not found.'));
     }
     $row->title = $title;
     $row->save();
     Pi::registry('module')->clear();
     Pi::registry('modulelist')->clear();
     return array('status' => 1, 'data' => array('title' => $row->title));
 }