예제 #1
0
<?php

$model = 'blog_article';
$blog_article = aql::profile($model, IDE);
$primary_table = aql::get_primary_table($model);
$blog_article_id = $blog_article['blog_article_id'];
$blog_article_ide = $blog_article['blog_article_ide'];
$title = $blog_article['title'] ? $blog_article['title'] : 'Write A New Post';
$head_arr[] = "<script src = '/lib/swfupload/swfupload.js' type = 'text/javascript'></script>";
$head_arr[] = "<script src = '/modules/media/upload/handlers.js' type = 'text/javascript'></script>";
$head_arr[] = "<link type='text/css' rel='stylesheet' href='/modules/media/upload/progress.css' />";
template::inc('intranet', 'top');
?>
	<div id = "back_to_blogs"><a href = "/admin/blog/post/">&laquo; Back to Blog Posts</a></div>
<?php 
//$theme_ab1 = "undo,redo,|,bold,italic,underline,strikethrough,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,styleselect";
//$theme_ab2 = "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,sub,sup,charmap,|,link,unlink,anchor,image,cleanup,help,|,code,|,removeformat,|,fullscreen,|,preview";
$theme_ab1 = "undo,redo,|,bold,italic,underline,strikethrough,forecolor,backcolor,|,bullist,numlist,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect";
$theme_ab2 = "cut,copy,paste,pastetext,pasteword,|,outdent,indent,blockquote,|,sub,sup,charmap,|,link,unlink,image,cleanup,|,code,|,removeformat,|,fullscreen,|,hr";
if (!$css_blog_editor) {
    $css_blog_editor = '/css/blog.css';
}
$options_article = array('resizing' => false, 'full_url' => $blog_img_absolute ? true : false, 'theme' => 'advanced', 'multi_buttons' => true, 'theme_ab1' => $theme_ab1, 'theme_ab2' => $theme_ab2, 'theme_ab3' => "", 'theme_ab4' => "", 'width' => '675', 'height' => '520', 'css' => $css_blog_editor);
$theme_ab1_notes = "bold,italic,underline,strikethrough,forecolor,backcolor,hr";
$options_notes = array('resizing' => true, 'theme' => 'advanced', 'multi_buttons' => true, 'theme_ab1' => $theme_ab1_notes, 'theme_ab2' => '', 'theme_ab3' => "", 'theme_ab4' => "", 'height' => '120', 'width' => '257');
$settings = array('article-content' => $options_article, 'note' => $options_notes);
helper::tinymce($settings);
aql::form($model);
template::inc('intranet', 'bottom');
예제 #2
0
 /**
  * @param   string  $param1
  * @param   string  $param2
  * @param   mixed   $options
  * @return  mixed
  */
 public static function value($param1, $param2, $options = array())
 {
     if (!$param2) {
         return null;
     }
     // third param can be a db connection resource
     if (is_object($options) && get_class($options) == 'ADODB_postgres7') {
         $db_conn = $options;
         $options = array();
     }
     // get connection
     $db_conn = $db_conn ?: $options['db'];
     $db_conn = $db_conn ?: self::getDB();
     $is_aql = aql::is_aql($param1);
     // normalize primary table and aql
     if ($is_aql) {
         $aql = $param1;
         $primary_table = aql::get_primary_table($aql);
     } else {
         list($primary_table, $field) = explode('.', $param1);
         $aql = "{$primary_table} { {$field} }";
     }
     // get where
     $multiple = false;
     $where = call_user_func(function () use($primary_table, $param2, &$multiple) {
         $spr = '%s.%s = \'%s\'';
         $decrypt = function ($r) use($primary_table) {
             return is_numeric($r) ? $r : decrypt($r, $primary_table);
         };
         if (is_numeric($param2)) {
             return sprintf($spr, $primary_table, 'id', $param2);
         }
         if (!is_array($param2)) {
             // check for ide
             $id = $decrypt($param2);
             if (is_numeric($id)) {
                 return sprintf($spr, $primary_table, 'id', $id);
             }
             // otherwise check for slug field on table
             if (!aql2array::table_field_exists($primary_table, 'slug')) {
                 return;
             }
             return sprintf($spr, $primary_table, 'slug', $param2);
         }
         // this is an array
         $multiple = true;
         $param2 = array_filter(array_map($decrypt, $param2));
         $param2[] = -1;
         $ids = implode(',', $param2);
         return "{$primary_table}.id in ({$ids})";
     });
     // return if we dont find a where clause
     if (!$where) {
         return false;
     }
     $clause = array($primary_table => array('where' => array($where), 'order by' => 'id asc'));
     $rs = aql::select($aql, $clause, null, null, null, $db_conn);
     if ($multiple) {
         return $rs;
     }
     if ($is_aql) {
         return $rs[0];
     }
     return $rs[0][$field];
 }
 /**
  * Parses the innards of the table definition block for info
  * @param   string  $aql
  * @param   array   $parent     (if in a subquery)
  * @return  array   { fields, subqueries, objects, clauses }
  */
 public function inner($aql, $parent = array())
 {
     $tmp = array();
     $subqueries = $this->split_tables($aql, true);
     $subqueries = $subqueries[0];
     if (is_array($subqueries)) {
         $subs = array();
         $sub = '';
         foreach ($subqueries as $k => $v) {
             if (stripos(trim($v), "'") > 2 || stripos(trim($v), "'") === false) {
                 // FOR MULTIPLE SUBQUERIES
                 $aql = str_replace($v, '', $aql);
                 if (!preg_match('/\\},$/', trim($v))) {
                     $sub .= $v;
                 } else {
                     $sub .= $v;
                     $sub = substr($sub, 0, -1);
                     $subs[] = $sub;
                     $sub = '';
                 }
             }
         }
         $subs[] = $sub;
         foreach ($subs as $s) {
             $sub = $this->init($s, $parent);
             if (!empty($sub)) {
                 $keys = array_keys($sub);
                 $tmp['subqueries'][$keys[0]] = $sub;
             }
         }
     }
     // remove opening brace and before and last brace and whitespace
     $aql = trim(substr(substr($aql, 0, -1), strpos($aql, '{') + 1));
     // get clauses
     foreach (array_reverse(self::$clauses) as $cl) {
         $pattern = sprintf('/(?:\\b%s\\b)%s/i', $cl, "(?=(?:(?:[^']*+'){2})*+[^']*+\\z)");
         $split = preg_split($pattern, $aql, 2);
         $aql = $split[0];
         if ($split[1]) {
             $tmp[$cl] = $split[1];
         }
     }
     preg_match_all(self::$object_pattern, $aql, $matches);
     $aql = str_replace($matches[0], '', $aql);
     foreach ($matches['model'] as $k => $v) {
         $primary_table = aql::get_primary_table($v);
         $constructor_arg = $matches['param'][$k] ?: $primary_table . '_id';
         $object_tmp = array('model' => $v, 'primary_table' => $primary_table, 'constructor argument' => $constructor_arg);
         $tmp_as = $matches['as'][$k] ?: $v;
         if ($matches['sub'][$k]) {
             $object_tmp['plural'] = true;
             $object_tmp['sub_where'] = $this->subquery_where($primary_table, $primary_table, $parent['table'], $parent['as']);
         }
         $tmp['objects'][$tmp_as] = $object_tmp;
     }
     $i = 1;
     $fields = explodeOnComma($aql);
     array_walk($fields, function ($field, $_, $o) use($parent, &$tmp, &$i) {
         $add_field = function ($alias, $value, $type = 'fields') use(&$tmp) {
             $tmp[$type][$alias] = $value;
         };
         $field = trim($field);
         if (empty($field)) {
             return;
         }
         if ($field == '*') {
             $fields = $o->get_table_fields($parent['table']);
             if (is_array($fields)) {
                 foreach ($fields as $f) {
                     $tmp['fields'][$f] = $parent['as'] . '.' . $f;
                 }
             }
             return;
         }
         $as = array_map('trim', preg_split("/\\bas\\b{$o->not_in_quotes}/", $field));
         $alias = $as[1] ?: $as[0];
         if (strpos($alias, "'") !== false) {
             $alias = 'field_' . $i;
         }
         if (!$as[0] || !$alias) {
             return;
         }
         if (preg_match("/(case|when){$o->not_in_quotes}/im", $as[0])) {
             // this is a case when
             $add_field($alias, trim($o->parse_case_when($as[0], $parent['as'])));
         } else {
             if (strpos($as[0], ')') !== false) {
                 // this is a "function" we call it an aggregate for now
                 $a = array_map('trim', explode('(', $as[0]));
                 if (!empty($a[0])) {
                     $alias = $alias == $as[0] ? $a[0] : $alias;
                     if ($tmp['aggregates'][$alias]) {
                         $j = '1';
                         while (true) {
                             if ($tmp['aggregates'][$alias . '_' . $j]) {
                                 $j++;
                                 continue;
                             }
                             $alias = $alias . '_' . $i;
                             break;
                         }
                     }
                     // end if alias is already taken.
                     $add_field($alias, $o->aggregate_add_table_name($parent['as'], $as[0]), 'aggregates');
                 } else {
                     $add_field($alias, $as[0]);
                 }
             } else {
                 // regular field
                 $add_field($alias, trim($o->add_table_name($parent['as'], $as[0])));
             }
         }
         $i++;
     }, $this);
     $tmp['fields'] = $tmp['fields'] ?: array();
     $tmp['aggregates'] = $tmp['aggregates'] ?: array();
     foreach (array('order by', 'group by') as $cl) {
         $tmp[$cl] = $this->check_clause(explodeOnComma($tmp[$cl]), $parent, array_merge($tmp['fields'], $tmp['aggregates']));
     }
     $tmp['where'] = preg_split('/\\band\\b(?=(?:(?:(?:[^()]++|\\.)*+[()]){2})*+(?:[^())]++|\\.)*+$)/i', $tmp['where']);
     return $tmp;
 }
예제 #4
0
 private function checkProfile($piece, $i, $file, $path)
 {
     // find primary_table via model if it is specified
     if ($this->settings['model']) {
         $aql = \aql::get_aql($this->settings['model']);
         $this->settings['primary_table'] = \aql::get_primary_table($aql);
     }
     // throw error if no primary_table
     if (!$this->settings['primary_table']) {
         header("HTTP/1.1 503 Service Temporarily Unavailable");
         header("Status: 503 Service Temporarily Unavailable");
         header("Retry-After: 1");
         throw new \Exception('Profile Page Error: $primary_table not specified on file. <br />' . $file);
         return false;
     }
     // set to profile
     $decrypted = \decrypt($piece, $this->settings['primary_table']);
     if ($piece == 'add-new' || is_numeric($decrypted)) {
         $this->addToPageAndPath($file, $path, $i);
         return true;
     }
     return false;
 }