예제 #1
0
if (isset($_SESSION['mw_payment_success'])) {
    mw()->user_manager->session_del('mw_payment_success');
    $payment_success = true;
}
if (isset($_REQUEST['mw_payment_success'])) {
    $payment_success = true;
} elseif (isset($_REQUEST['mw_payment_failure'])) {
    $payment_success = true;
}
$requires_registration = get_option('shop_require_registration', 'website') == 'y';
$requires_terms = get_option('shop_require_terms', 'website') == 'y';
$template = get_option('data-template', $params['id']);
$template_file = false;
$module_template = false;
if ($template != false and strtolower($template) != 'none') {
    $template_css_prefix = no_ext($template);
    $template_file = module_templates($params['type'], $template);
} else {
    if ($template == false and isset($params['template'])) {
        $module_template = $params['template'];
        $template_file = module_templates($params['type'], $module_template);
    } else {
        $template_file = module_templates($params['type'], 'default');
    }
}
?>

<script type="text/javascript">
    mw.require("tools.js");
    mw.require("shop.js");
예제 #2
0
function no_version($uri)
{
    if (!strstr($uri, '.')) {
        return $uri;
    }
    $uri = no_ext($uri);
    $array = explode('.', $uri);
    $candidate = $array[count($array) - 1];
    if (is_numeric($candidate)) {
        array_pop($array);
    }
    return implode('.', $array);
}
예제 #3
0
/**
 * Get all available languages as array.
 *
 * To set user language you must create cookie named "lang"
 *
 * @return array The languages array
 *
 * @example
 * <code>
 * //get all languages
 * $langs = get_available_languages();
 * var_dump($langs);
 * </code>
 *
 * <code>
 * //set language for the user
 *  setcookie("lang", 'en'); //sets english language
 * </code>
 */
function get_available_languages()
{
    global $mw_all_langs;
    if (!empty($mw_all_langs)) {
        return $mw_all_langs;
    }
    $lang_dir = mw_includes_path() . 'language' . DIRECTORY_SEPARATOR;
    $files = array();
    foreach (glob($lang_dir . '*.json') as $filename) {
        $item = basename($filename);
        $item = no_ext($item);
        $mw_all_langs[] = $item;
    }
    return $mw_all_langs;
}
예제 #4
0
 private function import()
 {
     if (!$this->login_is_book_admin('Commentator')) {
         $this->kickout();
     }
     // Set params
     $archive = no_ext($this->uri->segment(3));
     $this->data['hide_edit_bar'] = true;
     switch ($archive) {
         case 'system':
             // Import from another Scalar book on the same install
             $this->data['view'] = 'import_system';
             break;
         default:
             // Translate the import URL to information about the archive
             $archive_title = str_replace('_', ' ', $archive);
             $archives_rdf_url = confirm_slash(APPPATH) . 'rdf/xsl/archives.rdf';
             $archives_rdf = file_get_contents($archives_rdf_url);
             $archives_rdf = str_replace('{$base_url}', confirm_slash($this->data['app_root']), $archives_rdf);
             $archives = $this->rdf_store->parse($archives_rdf);
             $found = array();
             foreach ($archives as $archive_uri => $archive) {
                 $title = $archive['http://purl.org/dc/elements/1.1/title'][0]['value'];
                 $identifier = @$archive['http://purl.org/dc/terms/identifier'][0]['value'];
                 if (strtolower($title) == strtolower($archive_title)) {
                     $found[$archive_uri] = $archive;
                 }
                 if (!isset($found[$archive_uri]) && strtolower($identifier) == strtolower($archive_title)) {
                     $found[$archive_uri] = $archive;
                 }
             }
             if (!$found) {
                 die('Could not find archive');
             }
             $this->data['external'] = $this->rdf_store->helper($found);
             // API key from config if applicable
             $id = $this->data['external']->getPropValue('http://purl.org/dc/terms/identifier');
             if (empty($id)) {
                 $id = $this->data['external']->getPropValue('http://purl.org/dc/elements/1.1/title');
             }
             $id = strtolower($id);
             $archive_api_key = $this->config->item($id . '_key');
             $this->data['archive_api_key'] = !empty($archive_api_key) ? trim($archive_api_key) : null;
             $this->data['view'] = __FUNCTION__;
     }
 }
예제 #5
0
 /**
  * Output information about a group of pages based on class name
  */
 public function instancesof($class = '')
 {
     if ('system' == $class) {
         return self::system();
     }
     // Built-in pages
     try {
         $class = no_ext($class);
         $type = $category = null;
         $rel = RDF_Object::REL_CHILDREN_ONLY;
         switch ($class) {
             case 'content':
                 $model = 'pages';
                 break;
             case 'page':
             case 'composite':
                 $model = 'pages';
                 $type = 'composite';
                 break;
             case 'file':
             case 'media':
                 $model = 'pages';
                 $type = 'media';
                 break;
             case 'review':
             case 'commentary':
             case 'term':
                 $model = 'pages';
                 $category = $class;
                 break;
             case 'annotation':
             case 'reply':
             case 'tag':
             case 'path':
             case 'reference':
                 $this->load->model($class . '_model', plural($class));
                 $model = plural($class);
                 break;
             default:
                 header(StatusCodes::httpHeaderFor(StatusCodes::HTTP_NOT_FOUND));
                 exit;
         }
         $content = $this->{$model}->get_all($this->data['book']->book_id, $type, $category, $this->data['hidden'] ? false : true);
         $this->rdf_object->index($this->data['content'], array('book' => $this->data['book'], 'content' => $content, 'base_uri' => $this->data['base_uri'], 'method' => __FUNCTION__ . '/' . $class, 'restrict' => $this->data['restrict'], 'rel' => $rel, 'sq' => $this->data['sq'], 'versions' => $this->data['versions'] ? RDF_Object::VERSIONS_ALL : RDF_Object::VERSIONS_MOST_RECENT, 'ref' => $this->data['references'] ? RDF_Object::REFERENCES_ALL : RDF_Object::REFERENCES_NONE, 'prov' => $this->data['provenance'] ? RDF_Object::PROVENANCE_ALL : RDF_Object::PROVENANCE_NONE, 'pagination' => $this->data['pagination'], 'max_recurses' => $this->data['recursion']));
         $this->rdf_object->serialize($this->data['content'], $this->data['format']);
     } catch (Exception $e) {
         header(StatusCodes::httpHeaderFor(StatusCodes::HTTP_INTERNAL_SERVER_ERROR));
         exit;
     }
     $this->template->set_template('blank');
     $this->template->write_view('content', 'modules/data/' . $this->data['format'], $this->data);
     $this->template->render();
 }
예제 #6
0
 public function dir_tree_build($dir, $params = false)
 {
     $params = parse_params($params);
     $class = 'directory_tree';
     if (isset($params['class'])) {
         $class = $params['class'];
     }
     $title_class = 'is_folder';
     if (isset($params['title_class'])) {
         $title_class = $params['title_class'];
     }
     $basedir = '';
     if (isset($params['dir_name'])) {
         $basedir = $params['dir_name'];
     }
     $max_depth = 100;
     if (isset($params['max_depth'])) {
         $max_depth = $params['max_depth'];
     }
     $url_param = 'file';
     if (isset($params['url_param'])) {
         $url_param = $params['url_param'];
     }
     if (isset($params['url'])) {
         $url = $params['url'];
     } else {
         $url = mw()->url->current(true, true);
     }
     static $level = 0;
     if ($max_depth > $level) {
         ++$level;
         $ffs = scandir($dir);
         echo '<ul class="' . $class . ' depth_' . $level . '">';
         foreach ($ffs as $ff) {
             $is_hidden = substr($ff, 0, 1);
             if ($is_hidden == '_') {
             } else {
                 $file1 = $ff;
                 if (strlen($file1) > 3) {
                     $pos = strpos($file1, '_', 1);
                     if ($pos != false) {
                         $substr = substr($file1, 0, $pos);
                         if (intval($substr) > 0) {
                             $file1 = substr($file1, $pos, strlen($file1));
                             $file1 = ltrim($file1, '_');
                         }
                     }
                 }
                 $file1 = str_replace('_', ' ', $file1);
                 if ($ff != '.' && $ff != '..') {
                     echo '<li class="' . $class . ' depth_' . $level . '">';
                     if (is_dir($dir . '/' . $ff)) {
                         $is_index = $dir . DS . $ff . DS . 'index.php';
                         $link_href = '';
                         if (is_file($is_index)) {
                             $link = $dir . '/' . $ff . '/index.php';
                             if (trim($basedir) != '') {
                                 $link = normalize_path($link, false);
                                 $basedir = normalize_path($basedir, false);
                                 $link = str_replace($basedir . DS, '', $link);
                                 $link = str_replace('\\', '/', $link);
                                 $link = urlencode($link);
                             }
                             $active_class = '';
                             if (isset($_REQUEST[$url_param]) and urldecode($_REQUEST[$url_param]) == $link) {
                                 $active_class = ' active ';
                             }
                             $file1 = "<a class='{$active_class}' href='{$url}?{$url_param}={$link}'>{$file1}</a>";
                         }
                         $h_start = $level == 1 ? '<h2 class="' . $title_class . '">' : '<h3 class="' . $title_class . '">';
                         $h_close = $level == 1 ? '</h2>' : '</h3>';
                         echo $h_start . $file1 . $h_close;
                         $this->dir_tree_build($dir . '/' . $ff, $params);
                     } else {
                         $file1 = no_ext($file1);
                         $link = $dir . '/' . $ff;
                         if (trim($basedir) != '') {
                             $link = normalize_path($link, false);
                             $basedir = normalize_path($basedir, false);
                             $link = str_replace($basedir . DS, '', $link);
                         }
                         $link = str_replace('\\', '/', $link);
                         $class_path = str_replace('/', '--', $link);
                         $class_path = str_replace(' ', '_', $class_path);
                         $class_path = str_replace('.', '_', $class_path);
                         $active_class = '';
                         if (isset($_REQUEST[$url_param]) and urldecode($_REQUEST[$url_param]) == $link) {
                             $active_class = ' active ';
                         }
                         $link_href = $file1;
                         if ($link != false) {
                             $link = urlencode($link);
                             $link_href = "<a class='{$active_class} page_{$class_path} ' href='{$url}?{$url_param}={$link}'>{$file1}</a>";
                         }
                         echo $link_href;
                     }
                     echo '</li>';
                 }
             }
         }
         echo '</ul>';
     }
     --$level;
 }