示例#1
0
 /**
  * Process a multi level array of actions into a JQM list.
  * @param array $actions
  * @return string
  */
 public function processActions(array $actions = array())
 {
     $output = array();
     foreach ($actions as $action) {
         if (!empty($action[hmController::LIST_DIVIDER])) {
             $output[] = $this->hm->getTpl('widgets/dividerli', array('text' => $action[hmController::LIST_DIVIDER]));
         } elseif (!isset($action['permission']) || $action['permission'] === true) {
             if (isset($action['dialog'])) {
                 $action['dialog'] = ' data-rel="dialog"';
                 $action['transition'] = $action['transition'] ? $action['transition'] : 'pop';
             } else {
                 $action['transition'] = $action['transition'] ? $action['transition'] : 'slide';
                 $action['dialog'] = '';
             }
             $action['icon'] = $action['icon'] ? $action['icon'] : 'arrow-r';
             $lps = '';
             if (count($action['linkparams']) > 0) {
                 foreach ($action['linkparams'] as $lp => $lpv) {
                     $lps .= '&' . $lp . '=' . $lpv;
                 }
             }
             $action['link'] = $this->hm->url . '?hma=' . $action['action'] . $lps;
             $output[] = $this->hm->getTpl('widgets/rowAction', $action);
         }
     }
     return implode("\n", $output);
 }
示例#2
0
 /**
  * Checks authentication for the current MODX User / Session.
  * Sets hmRequest::authorized with a boolean value indicating authentication status.
  * Also processes logout and login.
  */
 public function checkAuthentication()
 {
     $this->authorized = $this->modx->user && $this->modx->user->hasSessionContext('mgr');
     /* If we are authorized, the $this->authorized variable will have a value
      ***/
     if ($this->authorized) {
         // Check if it needs to log out
         if ($_GET['hma'] == 'logout') {
             $return = $this->hm->runProcessor(array('action' => 'logout', 'location' => 'security'), $this->modx);
             if ($return['success'] == 1) {
                 $this->action = array('hma' => 'login', 'options' => array('message' => 'Successfully logged out.'));
                 $this->authorized = false;
                 // We redirect to make sure the session is available to other scripts.
                 return $this->modx->sendRedirect($this->hm->config['baseUrl']);
             } else {
                 $this->action = array('hma' => 'home', 'options' => array('message' => $return['message']));
             }
         } else {
             $this->action = $_GET['hma'] ? array('hma' => $_GET['hma'], 'options' => array('source' => 'get')) : array('hma' => 'home', 'options' => array('source' => 'default'));
         }
     } else {
         if (!$this->authorized) {
             // Check if there is a login attempt, and if so validate it
             if ($_POST['hm_action'] == 'login') {
                 $return = $this->hm->runProcessor(array('action' => 'login', 'location' => 'security'), $this->modx);
                 if ($return['success'] == 1) {
                     $this->action = array('hma' => 'home', 'options' => array('source' => 'login'));
                     // We redirect to make sure the session is available to other scripts.
                     return $this->modx->sendRedirect($this->hm->config['baseUrl']);
                 } else {
                     $msg = $return['message'];
                     $this->action = array('hma' => 'login', 'options' => array('message' => $msg));
                 }
                 // Show the "login" action -> a login form.
             } else {
                 $this->action = array('hma' => 'login', 'options' => array('source' => 'default'));
             }
         }
     }
 }
示例#3
0
 /**
  * @param xPDOObject|array $field
  * @return array
  */
 public function prepareSelect($field)
 {
     $field = is_object($field) ? $field->toArray() : $field;
     $optionList = array();
     if (is_array($field['options'])) {
         foreach ($field['options'] as $opt) {
             $sel = $opt['value'] == $field['value'] ? ' selected="selected" ' : '';
             $optionList[] = $this->hm->getTpl('fields/select.option', array('value' => $opt['value'], 'name' => $opt['name'], 'selected' => $sel));
         }
     }
     $field['options'] = implode("\n", $optionList);
     return $field;
 }
示例#4
0
文件: index.php 项目: rossng/HandyMan
dirname(dirname(dirname(dirname(__FILE__)))) . 'core.config.php';
require_once 'C:/wamp/www/revolution/core/model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->getParser();
$modx->getService('lexicon', 'modLexicon');
define('HANDYMAN', true);
$hmo = '';
/* Include the main HandyMan class.
 * This class takes care of authentification and provides the extension
 * with functions to execute the requests.
 *
 * After inclusion, set up the $hm variable as the main object.
 **/
include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/core/components/handyman/classes/handyman.class.php';
$hm = new HandyMan($modx);
$hm->initialize();
$hm->modx->getService('h2t', 'html2textile', $hm->config['corePath'] . 'classes/textile/');
$hm->modx->getService('t2h', 'Textile', $hm->config['corePath'] . 'classes/textile/');
$case = !empty($_REQUEST['case']) ? $_REQUEST['case'] : 1;
$original = file_get_contents('data/' . $case . '.html');
$textiled = $hm->modx->h2t->detextile($original);
$html = $hm->modx->t2h->TextileThis($textiled);
$amts = 25;
$i = 0;
$recursingTextile = $textiled;
$recursingHtml = $html;
while ($i < $amts) {
    $recursingTextile = $hm->modx->h2t->detextile($recursingHtml);
    $recursingHtml = $hm->modx->t2h->TextileThis($recursingTextile);
    $i++;
示例#5
0
文件: index.php 项目: rossng/HandyMan
 * Instantiate the main MODX class for the manager context, load the parser and the lexicon service.
 */
$modx = new modX();
$modx->initialize('mgr');
$modx->getParser();
$modx->getService('lexicon', 'modLexicon');
$modx->setOption('modRequest.class', 'modRequest');
$modx->getRequest();
/* Include the main HandyMan class.
 * This class takes care of authentication and provides the extension
 * with functions to execute the requests.
 *
 * After inclusion, set up the $hm variable as the main object.
 **/
define('HANDYMAN', true);
$hmPath = $modx->getOption('handyman.core_path');
if (empty($hmPath)) {
    $hmPath = MODX_CORE_PATH . 'components/handyman/';
}
require_once $hmPath . 'classes/handyman.class.php';
$hm = new HandyMan($modx);
$hm->initialize();
/* The $hm->action variable is an array set with the request and additional
 * information. Take it, and parse it with the $hm->processAction function.
 * Set it to the $hmo variable for later output.
 **/
$output = $hm->request->handle();
/* Use the collected data to output the HandyMan UI with the parseMarkup
 * function. Takes three properties: meta data, body and footer text.
 **/
$hm->end($output);