/** * Get item from queue as Structure if array put into queue * * @return mixed|\Sokil\Mongo\Structure */ public function dequeue() { $value = $this->dequeuePlain(); if (!is_array($value)) { return $value; } $structure = new Structure(); $structure->mergeUnmodified($value); return $structure; }
/** * Add a Block to a pixel to a given coordinate depending * on a pixels color * * @param \ImagickPixel $pixel * @param Structure $structure * @param $x * @param $y * @param $z */ protected function addBlockForPixel(\ImagickPixel $pixel, Structure $structure, $x, $y, $z) { $color = $pixel->getColor(); $type = $this->blockTypeColorMapping->getBlockTypeForRgbColor($color['r'], $color['g'], $color['b']); if (null === $type) { return; } // if meta is null it becomes 0 $meta = (int) $type->getMeta(); $structure->createBlock($type->getName(), array('x' => $x, 'y' => $y, 'z' => $z), $meta); }
public function post_save($entry_id, $data, $option) { if (empty($option)) { return; } // Get the url title first $entry = ee()->db->select('url_title, channel_id')->from('channel_titles')->where('entry_id', $entry_id)->get()->row_array(); if (!isset($entry['url_title'])) { return; } $url_title = $entry['url_title']; $channel_id = $entry['channel_id']; $parent_entry_id = 0; // Now figure where to drop this entry if (count($option) < 2) { // Only one place we can drop it $parent_entry_id = current($option); } else { // we have to pick a parent $parent_entry_id = $option[rand(0, count($option) - 1)]; } // Let structure do the heavy lifting require_once PATH_THIRD . 'structure/sql.structure.php'; $structure_sql = new Sql_structure(); $channel_type = $structure_sql->get_channel_type($channel_id); // If the current channel is not assigned as any sort of Structure channel, then stop if ($channel_type == 'page') { $site_pages = $structure_sql->get_site_pages(); // get form fields $entry_data = array('channel_id' => $channel_id, 'entry_id' => $entry_id, 'uri' => $url_title, 'template_id' => $structure_sql->get_default_template($channel_id), 'listing_cid' => 0, 'hidden' => 'n'); $site_pages = $structure_sql->get_site_pages(); if (!isset($site_pages['uris'][$parent_entry_id])) { return; } $entry_data['parent_id'] = $parent_entry_id; $parent_uri = $site_pages['uris'][$parent_entry_id] . '/'; $entry_data['uri'] = $structure_sql->create_page_uri($parent_uri, $entry_data['uri']); require_once PATH_THIRD . 'structure/mod.structure.php'; $structure_model = new Structure(); $structure_model->set_data($entry_data); } // Cleanup unset($structure_sql); unset($structure_model); // We need to update the config->item('site_pages') // now other wise it won't register for the next loop $res = ee()->db->select('site_pages')->from('sites')->where('site_id', '1')->get()->row_array(); ee()->config->set_item('site_pages', unserialize(base64_decode($res['site_pages']))); }
public function loadConfig() { //todo fix empty config caching $cache = new \CPHPCache(); $cacheFile = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/cache/" . $cache->GetPath(__CLASS__); // проверяем, обновлялся ли конфиг $cacheWritten = filemtime($cacheFile); $configWritten = filemtime($this->configFile); // устаревший кеш или неудачно начатый кеш перезаписываем if ($configWritten > $cacheWritten || !$cache->InitCache(self::TTL, __CLASS__, '/')) { $cache->Clean(__CLASS__, '/'); try { parent::loadConfig(); if ($cache->StartDataCache(self::TTL, __CLASS__, '/')) { $cache->EndDataCache(array('config' => $this->config)); } else { _log('Caching failed', 'widgets'); } } catch (Exception $e) { _log('loading config error: ' . $e->getMessage(), 'widgets'); } } else { $vars = $cache->GetVars(); $this->config = $vars['config']; } }
/** * Builds the HTML code for the main container * * @return String the HTML code */ public function getHtml() { $ret = $this->indent() . \Html::openElement('div', array('class' => $this->getClassString())); $ret .= parent::getHtml(); $ret .= $this->indent(-1) . '</div>'; return $ret; }
public function run($functionName = '', $functionRun = '') { $datas = Structure::datas(); $parameters = $datas['parameters']; $isFile = $datas['isFile']; $function = $datas['function']; if (file_exists($isFile)) { if ($functionName === $function) { if (is_callable($functionRun)) { if (APP_TYPE === 'local') { set_error_handler('Exceptions::table'); } call_user_func_array($functionRun, $parameters); if (APP_TYPE === 'local') { restore_error_handler(); } } else { // Sayfa bilgisine erişilemezse hata bildir. if (!Config::get('Route', 'show404')) { // Hatayı ekrana yazdır. echo Error::message('Error', 'callUserFuncArrayError', $functionRun); // Hatayı rapor et. report('Error', getMessage('Error', 'callUserFuncArrayError'), 'SystemCallUserFuncArrayError'); // Çalışmayı durdur. return false; } else { redirect(Config::get('Route', 'show404')); } } } } }
public function getHome() { Session::put('old_RequestSegment2', ''); //is root? //if (Request::is('/') && Locale::countEnable() > 1) return Redirect::to('/' . App::getLocale(), 301); //is OnePage? if (Config::get('core::display.onepage')) { $data = array(); $data['onepage'] = OnePage::first(); return View::make('theme::public.onepage', $data); } else { //Find good page $urls = Urls::getRoutes(); foreach ($urls as $url) { if ($url['url'] == '/' && $url['locale_id'] == App::getLocale()) { $structure = Structure::where('i18n_url', $url['i18n_id'])->first(); if (!empty($structure)) { if ($structure->structurable_type != 'OnePage') { $page = $structure->structurable; return View::make('pager::public.pages.page', compact('page')); } } } } return App::abort(404); } }
/** * удалить узел */ public function action_delete() { $id = $this->request->param('id'); $this->modelStructure->delete($id); $this->modelStructureArticle->deleteByParent($id); $this->redirect($this->config->routePath . "/index"); }
/** * ContentController::index() * * The Home page */ public function index($args) { $this->setContent('browser_title', SITE_TITLE . ': The ' . LAWS_NAME . ', for Humans.'); /* * Initialize the sidebar variable. */ $sidebar = ' <section> <p>Powered by <a href="http://www.statedecoded.com/">The State Decoded</a>.</p> </section>'; /* * Put the shorthand $sidebar variable into its proper place. */ $this->setContent('sidebar', $sidebar); unset($sidebar); /* * Get an object containing a listing of the fundamental units of the code. */ $struct = new Structure(); $structures = $struct->list_children(); /* * Initialize the body variable. */ $body .= ' <article> <h1>' . ucwords($structures->{0}->label) . 's of the ' . LAWS_NAME . '</h1> <p>These are the fundamental units of the ' . LAWS_NAME . '.</p>'; if (!empty($structures)) { $body .= '<dl class="level-1">'; foreach ($structures as $structure) { $body .= ' <dt><a href="' . $structure->url . '">' . $structure->identifier . '</a></dt> <dd><a href="' . $structure->url . '">' . $structure->name . '</a></dd>'; } $body .= '</dl>'; } $body .= '</article>'; /* * Put the shorthand $body variable into its proper place. */ $this->setContent('body', $body); unset($body); return $this->renderContent(); }
private function _recursiveRead($directory) { if (self::$depth > 0 && self::$currentDepth >= self::$depth) { return []; } self::$currentDepth++; $structure = []; $handle = opendir($directory); while (($item = readdir($handle)) !== false) { $path = $directory . '/' . $item; if (!in_array($item, $this->skip)) { if (is_dir($path)) { $structure[] = ['id' => $this->GUID(), 'text' => $item, 'type' => self::FOLDER, 'children' => $this->_recursiveRead($path)]; if (self::$currentDepth < 0) { self::$currentDepth = 0; } } else { $structure[] = ['id' => $this->GUID(), 'text' => $item, 'type' => self::FILE]; } } } self::$currentDepth--; usort($structure, function ($a, $b) { if ($a['type'] == self::FOLDER && $b['type'] == self::FOLDER) { if (strcasecmp($a['text'], $b['text']) < 0) { return -1; } if (strcasecmp($a['text'], $b['text']) > 0) { return 1; } } if ($a['type'] == self::FILE && $b['type'] == self::FILE) { if (strcasecmp($a['text'], $b['text']) < 0) { return -1; } if (strcasecmp($a['text'], $b['text']) > 0) { return 1; } } if ($a['type'] == self::FOLDER && $b['type'] == self::FILE) { return -1; } if ($a['type'] == self::FILE && $b['type'] == self::FOLDER) { return 1; } }); closedir($handle); return $structure; }
public static function routes() { static::loadModules(); foreach (static::$modulesObjects as $object) { $object->routes(); } //Load login routes.. login, logoff, etc.. Router::register("GET", "manager/api/config/", function () { header("Content-Type: text/javascript; charset=utf-8"); if (Request::isLocal()) { if (@DB::query("select id from " . J_TP . "manager_users LIMIT 1;")->success === false) { DB::query("CREATE TABLE `" . J_TP . "manager_users` (\n\t\t\t\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`name` varchar(255) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`email` varchar(255) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`typeID` int(11) unsigned NULL,\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`username` varchar(255) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`password` varchar(40) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`active` int(11) DEFAULT NULL,\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); $user = ORM::make("manager_users"); $user->name = "Joy Interactive"; $user->email = "*****@*****.**"; $user->username = "******"; $user->password = "******"; $user->typeID = 1; $user->active = 1; $user->save(); } if (@DB::query("select id from " . J_TP . "manager_tokens LIMIT 1;")->success === false) { DB::query("CREATE TABLE `" . J_TP . "manager_tokens` (\n\t\t\t\t\t\t\t\t`id` int(40) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`userID` int(11) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`typeID` int(11) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`token` varchar(100) DEFAULT NULL,\n\t\t\t\t\t\t\t\t`expirationDate` datetime DEFAULT NULL,\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"); } } $config = array(); $config["api_url"] = URL::to("api/"); return "window.config = " . json_encode($config); }); Router::register("GET", "manager/api/structure/", function () { return Response::json(Structure::modules()); }); Router::register("POST", "manager/api/token/", function () { return User::generateToken(); }); Router::register("POST", "manager/api/token/renew/", function () { return User::renewToken(); }); Router::register("GET", "manager/api/logout/", function () { return User::logout(); }); Router::register("GET", "manager/api/customJS/", function () { $path = J_MANAGERPATH . "custom.js"; if (file_exists($path)) { return File::get($path); } }); }
/** * @param null $data * @param $failed * @return bool */ public function checkType($data = null, &$failed = null) { if (!$this->getNumeric()) { return parent::checkType($data, $failed); } else { if (is_null($data)) { $data = $this->getData(); } if ($this->getNull() && is_null($data)) { return true; } $valid = is_numeric($data); if (!$valid) { $failed = Structure::typeof($data); } return $valid; } }
/** * 创建Models中的数据库操作对象 * @param string $className 类名或表名 * @param string $app 应用名,访问其他应用的Model * @return object 数据库连接对象 */ function D($className = null, $app = "") { $db = null; //如果没有传表名或类名,则直接创建DB对象,但不能对表进行操作 if (is_null($className)) { $class = "D" . DRIVER; $db = new $class(); } else { $className = strtolower($className); $model = Structure::model($className, $app); $model = new $model(); //如果表结构不存在,则获取表结构 $model->setTable($className); $db = $model; } if ($app == "") { $db->path = APP_PATH; } else { $db->path = PROJECT_PATH . strtolower($app) . '/'; } return $db; }
public function getUrlAndTitle() { require_once 'NieuwsItem.php'; $oNieuwsItem = new NieuwsItem(); $oNieuwsItem->setId($this->_iId); $oStructure = Structure::getInstance(); $iParent = $oStructure->getParentNodeIdByModule('nieuws'); if ($iParent == 0 || $oStructure->isOffline($iParent) === true) { // item is niet te herleiden tot een pagina return array('url' => '', 'title' => ''); } $oMainModule = new Swis_MainModule($iParent); $aPath = Structure::getPathToNodeWithInfo($iParent); $sTitle = ''; foreach (array_reverse($aPath) as $aNode) { if ($aNode['special_page'] == 0) { $sTitle .= empty($sTitle) ? $aNode['title'] : ' - ' . $aNode['title']; } } $oMainModule = new Swis_MainModule($iParent); return array('url' => $oMainModule->get('item') . $oNieuwsItem->get('link'), 'title' => $sTitle); }
public function pushEach($fieldName, array $values) { // value must be list, not dictionary $values = array_values($values); // prepasre to store $values = Structure::prepareToStore($values); // no $push operator found if (!isset($this->operators['$push'])) { $this->operators['$push'] = array(); } // no field name found if (!isset($this->operators['$push'][$fieldName])) { $this->operators['$push'][$fieldName] = array('$each' => $values); } else { if (!is_array($this->operators['$push'][$fieldName]) || !isset($this->operators['$push'][$fieldName]['$each'])) { $oldValue = $this->operators['$push'][$fieldName]; $this->operators['$push'][$fieldName] = array('$each' => array_merge(array($oldValue), $values)); } else { $this->operators['$push'][$fieldName]['$each'] = array_merge($this->operators['$push'][$fieldName]['$each'], $values); } } return $this; }
public function run($functionName = '', $functionRun = '', $route = array()) { if (!empty($this->route)) { $route = $this->route; } if (is_array($route) && !empty($route)) { Config::set('Route', 'changeUri', $route); } $datas = Structure::data(); $parameters = $datas['parameters']; $isFile = $datas['file']; $function = $datas['function']; if (($functionName === 'construct' || $functionName === 'destruct') && is_callable($functionRun)) { call_user_func_array($functionRun, $parameters); } if (file_exists($isFile)) { if (strtolower($function) === 'index' && strtolower($functionName) === 'main') { $function = 'main'; } if ($functionName === $function) { if (is_callable($functionRun)) { call_user_func_array($functionRun, $parameters); } else { // Sayfa bilgisine erişilemezse hata bildir. if (!Config::get('Route', 'show404')) { // Hatayı rapor et. report('Error', lang('Error', 'callUserFuncArrayError'), 'SystemCallUserFuncArrayError'); // Hatayı ekrana yazdır. die(Error::message('Error', 'callUserFuncArrayError', $functionRun)); } else { redirect(Config::get('Route', 'show404')); } } } } }
/** * Retrieve all of the material relevant to a given law. */ function get_law() { /* * We're going to need access to the database connection throughout this class. */ global $db; /* * If neither a section number nor a law ID has been passed to this function, then there's * nothing to do. */ if (!isset($this->section_number) && !isset($this->law_id)) { return FALSE; } /* * If we haven't specified which fields that we want, then assume that we want all of them. */ if (!isset($this->config) || !is_object($this->config)) { $this->config = new StdClass(); $this->config->get_all = TRUE; } /* * Define the level of detail that we want from this method. By default, we return * everything that we have for this law. */ if (!isset($this->config) || $this->config->get_all == TRUE) { $this->config->get_text = TRUE; $this->config->get_structure = TRUE; $this->config->get_amendment_attempts = TRUE; $this->config->get_court_decisions = TRUE; $this->config->get_metadata = TRUE; $this->config->get_references = TRUE; $this->config->get_related_laws = TRUE; $this->config->get_tags = TRUE; $this->config->render_html = TRUE; } /* * Assemble the query that we'll use to get this law. */ $sql = 'SELECT id AS section_id, structure_id, section AS section_number, catch_line, history, text AS full_text, order_by FROM laws'; $sql_args = array(); /* * If we're requesting a specific law by ID. */ if (isset($this->law_id)) { /* * If it's just a single law ID, then just request the one. */ if (!is_array($this->law_id)) { $sql .= ' WHERE id = :id'; $sql_args[':id'] = $this->law_id; } elseif (is_array($this->law_id)) { $sql .= ' WHERE ('; /* * Step through the list. */ $law_count = count($this->law_id); for ($i = 0; $i < $law_count; $i++) { $sql .= " id = :id{$i}"; $sql_args[":id{$i}"] = $this->law_id[$i]; if ($i < $law_count - 1) { $sql .= ' OR'; } } $sql .= ')'; } } else { $sql .= ' WHERE section = :section_number AND edition_id = :edition_id'; $sql_args[':section_number'] = $this->section_number; if (isset($this->edition_id)) { $sql_args[':edition_id'] = $this->edition_id; } else { $sql_args[':edition_id'] = EDITION_ID; } } $statement = $db->prepare($sql); $result = $statement->execute($sql_args); if ($result === FALSE || $statement->rowCount() == 0) { return FALSE; } /* * Return the result as an object. */ $tmp = $statement->fetch(PDO::FETCH_OBJ); /* * Bring this law into the object scope. */ foreach ($tmp as $key => $value) { $this->{$key} = $value; } /* * Clean up the typography in the full text. */ $this->full_text = wptexturize($this->full_text); /* * Now get the text for this law, subsection by subsection. */ if ($this->config->get_text === TRUE) { /* * When invoking this method in a loop, $this->text can pile up on itself. If the text * property is already set, clear it out. */ if (isset($this->text)) { unset($this->text); } $sql = 'SELECT id, text, type, (SELECT GROUP_CONCAT(identifier ORDER BY sequence ASC SEPARATOR "|") FROM text_sections WHERE text_id=text.id GROUP BY text_id) AS prefixes FROM text WHERE law_id = :law_id ORDER BY text.sequence ASC'; $sql_args = array(':law_id' => $this->section_id); $statement = $db->prepare($sql); $result = $statement->execute($sql_args); /* * If the query fails, or if no results are found, return false -- we can't make a * match. */ if ($result === FALSE || $statement->rowCount() == 0) { return FALSE; } /* * Iterate through all of the sections of text to save to our object. */ $i = 0; while ($tmp = $statement->fetch(PDO::FETCH_OBJ)) { $tmp->prefixes = explode('|', $tmp->prefixes); $tmp->prefix = end($tmp->prefixes); $tmp->entire_prefix = implode('', $tmp->prefixes); $tmp->prefix_anchor = str_replace(' ', '_', $tmp->entire_prefix); $tmp->level = count($tmp->prefixes); /* * Pretty it up, converting all straight quotes into directional quotes, double * dashes into em dashes, etc. */ if ($tmp->type != 'table') { $tmp->text = wptexturize($tmp->text); } /* * Append this section. */ if (!isset($this->text)) { $this->text = new StdClass(); } $this->text->{$i} = $tmp; $i++; } } /* * Determine this law's structural position. */ if ($this->config->get_structure = TRUE) { /* * Create a new instance of the Structure class. */ $struct = new Structure(); /* * Our structure ID provides a starting point to identify this law's ancestry. */ $struct->id = $this->structure_id; /* * Save the law's ancestry. */ $this->ancestry = $struct->id_ancestry(); /* * Short of a parser error, there’s no reason why a law should not have an ancestry. In * case of this unlikely possibility, just erase the false element. */ if ($this->ancestry === FALSE) { unset($this->ancestry); } /* * Get the listing of all other sections in the structural unit that contains this * section. */ $this->structure_contents = $struct->list_laws(); /* * Figure out what the next and prior sections are (we may have 0-1 of either). Iterate * through all of the contents of the chapter. (It's possible that there are no next or * prior sections, such as in a single-item structural unit.) */ if ($this->structure_contents !== FALSE) { $tmp = count((array) $this->structure_contents); for ($i = 0; $i < $tmp; $i++) { /* * When we get to our current section, that's when we get to work. */ if ($this->structure_contents->{$i}->id == $this->section_id) { $j = $i - 1; $k = $i + 1; if (isset($this->structure_contents->{$j})) { $this->previous_section = $this->structure_contents->{$j}; } if (isset($this->structure_contents->{$k})) { $this->next_section = $this->structure_contents->{$k}; } break; } } } } /* * Gather all metadata stored about this law. */ if ($this->config->get_metadata == TRUE) { $this->metadata = Law::get_metadata(); } /* * Gather any tags applied to this law. */ if ($this->config->get_tags == TRUE) { $sql = 'SELECT text FROM tags WHERE law_id = ' . $db->quote($this->section_id); $result = $db->query($sql); if ($result !== TRUE && $result->rowCount() > 0) { $this->tags = new stdClass(); $i = 0; while ($tag = $result->fetch(PDO::FETCH_OBJ)) { $this->tags->{$i} = $tag->text; $i++; } } } /* * Create a new instance of the State() class. */ $state = new State(); $state->section_id = $this->section_id; $state->section_number = $this->section_number; /* * Get the amendment attempts for this law and include those (if there are any). But * only if we have specifically requested this data. That's because, on most installations, * this will be making a call to a third-party service (e.g., Open States), and such a call * is expensive. */ if ($this->config->get_amendment_attempts == TRUE) { if (method_exists($state, 'get_amendment_attempts')) { if ($state->get_amendment_attempts() !== FALSE) { $this->amendment_attempts = $state->bills; } } } /* * Get the court decisions that affect this law and include those (if there are any). But * only if we have specifically requested this data. That's because, on most installations, * this will be making a call to a third-party service and such a call is expensive. */ if ($this->config->get_court_decisions == TRUE) { /* * If we already have this data cached as metadata. */ if (isset($this->metadata->court_decisions)) { $this->court_decisions = $this->metadata->court_decisions; } else { if (method_exists($state, 'get_court_decisions')) { if ($state->get_court_decisions() !== FALSE) { $this->court_decisions = $state->decisions; } } } } /* * Get the URL for this law on its official state web page. */ if (method_exists($state, 'official_url')) { $this->official_url = $state->official_url(); } /* * Translate the history of this law into plain English. */ if (method_exists($state, 'translate_history')) { if (isset($this->metadata->history)) { $state->history = $this->metadata->history; $this->history_text = $state->translate_history(); } } /* * Generate citations for this law. */ if (method_exists($state, 'citations')) { $state->section_number = $this->section_number; $state->citations(); $this->citation = $state->citation; } /* * Get the references to this law among other laws and include those (if there are any). */ if ($this->config->get_references == TRUE) { $this->references = Law::get_references(); } /* * Gather all laws that are textually similar to this law. */ if ($this->config->get_related_laws == TRUE) { //$this->metadata = Law::get_related(); } /* * Pretty up the text for the catch line. */ $this->catch_line = wptexturize($this->catch_line); /* * Provide the URL for this section. */ $sql = 'SELECT url, token FROM permalinks WHERE relational_id = :id AND object_type = :object_type'; $statement = $db->prepare($sql); $sql_args = array(':id' => $this->section_id, ':object_type' => 'law'); $result = $statement->execute($sql_args); if ($result !== FALSE && $statement->rowCount() > 0) { $permalink = $statement->fetch(PDO::FETCH_OBJ); $this->url = $permalink->url; $this->token = $permalink->token; } /* * List the URLs for the textual formats in which this section is available. */ if (!isset($this->formats)) { $this->formats = new StdClass(); } $this->formats->txt = substr($this->url, 0, -1) . '.txt'; $this->formats->json = substr($this->url, 0, -1) . '.json'; $this->formats->json = substr($this->url, 0, -1) . '.xml'; /* * Create metadata in the Dublin Core format. */ $this->dublin_core = new stdClass(); $this->dublin_core->Title = $this->catch_line; $this->dublin_core->Type = 'Text'; $this->dublin_core->Format = 'text/html'; $this->dublin_core->Identifier = SECTION_SYMBOL . ' ' . $this->section_number; $this->dublin_core->Relation = LAWS_NAME; /* * If the request specifies that rendered HTML should be returned, then generate that. */ if (isset($this->config->render_html) && $this->config->render_html === TRUE) { $this->html = Law::render(); } /* * Provide a plain text version of this law. */ $this->plain_text = Law::render_plain_text(); /* * Provide a plain text document header. */ $this->plain_text = str_repeat(' ', round((81 - strlen(LAWS_NAME)) / 2)) . strtoupper(LAWS_NAME) . "\n\n" . wordwrap(strtoupper($this->catch_line) . ' (' . SECTION_SYMBOL . ' ' . $this->section_number . ')', 80, "\n", TRUE) . "\n\n" . $this->plain_text; if (!empty($this->history)) { $this->plain_text .= "\n" . wordwrap('HISTORY: ' . $this->history, 80, "\n", TRUE); } $law = $this; unset($law->config); return $law; }
function getRecordFromRow( $row, $columnIndex, Structure $structure ) { $result = new ArrayRecord( $structure ); foreach ( $structure->getAttributes() as $attribute ) { $result->setAttributeValue( $attribute, $row[$columnIndex] ); $columnIndex++; } return $result; }
function getRecordAsEditTableCells( IdStack $idPath, Editor $editor, Structure $visibleStructure, Record $record, &$startColumn = 0 ) { $result = ''; $childEditorMap = $editor->getAttributeEditorMap(); foreach ( $visibleStructure->getAttributes() as $visibleAttribute ) { $childEditor = $childEditorMap->getEditorForAttribute( $visibleAttribute ); if ( $childEditor != null ) { $attribute = $childEditor->getAttribute(); $type = $attribute->type; $value = $record->getAttributeValue( $attribute ); $idPath->pushAttribute( $attribute ); if ( $childEditor instanceof RecordTableCellEditor ) { $result .= getRecordAsEditTableCells( $idPath, $childEditor, $visibleAttribute->type, $value, $startColumn ); } else { if ( $childEditor->showEditField( $idPath ) ) { $displayValue = $childEditor->edit( $idPath, $value ); } else { $displayValue = ""; } $result .= '<td class="' . getHTMLClassForType( $type, $attribute ) . ' column-' . parityClass( $startColumn ) . '">' . $displayValue . '</td>'; $startColumn++; } $idPath->popAttribute(); } else { $result .= "<td/>"; } } return $result; }
public static function clearLastFail() { Structure::$lastFail = null; }
/** * Returns pages from one given parent page * * @TODO Check and finish writing * Planned for 1.0 * * @param FTL_Binding * * @return mixed */ public static function tag_pages(FTL_Binding $tag) { $cache = $tag->getAttribute('cache', TRUE); // Tag cache // if ($cache == TRUE && ($str = self::get_cache(FTL_Binding $tag)) !== FALSE) // return $str; // Returned string $str = ''; $parent = $tag->getAttribute('parent'); $mode = $tag->getAttribute('mode', 'flat'); $levels = $tag->getAttribute('levels'); $menu_name = $tag->getAttribute('menu'); $parent_page = NULL; // Display hidden navigation elements ? $display_hidden = $tag->getAttribute('display_hidden', FALSE); $limit = $tag->getAttribute('limit'); if (!is_null($parent)) { if (strval(abs((int) $parent)) == (string) $parent) { $parent_page = self::get_page_by_id($parent); } else { if (substr($parent, 0, 1) == '-') { $parent_page = self::get_relative_parent_page(self::registry('page'), $parent, $display_hidden); } else { if ($parent == 'this') { $parent_page = self::registry('page'); } else { $parent_page = self::get_page_by_code($parent); } } } } $data = self::registry('pages'); if (!empty($parent_page)) { if ($mode == 'tree') { $pages = Structure::get_tree_navigation($data, $parent_page['id_page']); } else { $pages = array(); Structure::get_nested_structure($data, $pages, $parent_page['id_page']); } } else { $pages = self::registry('pages'); } // Limit pages to a certain level if (!is_null($levels)) { $levels = (int) $levels; for ($i = count($pages) - 1; $i >= 0; $i--) { if ($pages[$i]['level'] > $levels) { unset($pages[$i]); } } $pages = array_values($pages); } // Limit pages to a certain menu if (!is_null($menu_name)) { // By default main menu $id_menu = 1; foreach (self::registry('menus') as $menu) { if ($menu_name == $menu['name']) { $id_menu = $menu['id_menu']; } } for ($i = count($pages) - 1; $i >= 0; $i--) { if ($pages[$i]['id_menu'] != $id_menu) { unset($pages[$i]); } } $pages = array_values($pages); } if ($display_hidden == FALSE) { $pages = array_values(array_filter($pages, array('TagManager_Page', '_filter_appearing_pages'))); } if (!is_null($limit)) { $pages = array_slice($pages, 0, $limit); } $count = count($pages); foreach ($pages as $key => $page) { // Render the article $tag->set('page', $page); $tag->set('index', $key); $tag->set('count', $count); $str .= $tag->expand(); } $output = self::wrap($tag, $str); // Tag cache self::set_cache($tag, $output); return $output; }
<?php require 'structure.php'; $structure = new Structure(); echo $structure->header('Advanced Scripting', 'Snarflatt'); echo "<p>This is the index content part.</p>"; echo $structure->footer();
public function actionIndex() { //分配焦点图到页面 $focusmap = $this->getPictureFormImg(3,3); //分配5个旅游信息到页面 并分页显示 $travelsM = new Travel; $criteria=new CDbCriteria; $criteria->select = "id,title,to_addr,daynumber,thumb,current_audlt_price"; $criteria->condition = "enabled=1"; $criteria->order = "updatetime desc"; $criteria->compare('id',$travelsM->id,false,'or'); $count=$travelsM->count($criteria); $pages=new CPagination($count); $pages->pageSize=5; $pages->applyLimit($criteria); $travels = $travelsM->findAll($criteria); //end pagination //分配特色团到页面(这里的特色团是flag标记为 1 的产品信息) $teseTuan = $travelsM->findAll(array( 'select'=>'id,title,current_audlt_price', 'condition'=>'flag=1 and enabled=1', 'order'=>'sort desc', 'limit'=>15, )); //分配15个排序最靠前的旅游产品 作为 热门路线 $hottravels = $travelsM->findAll(array( 'select'=>'id,title', 'condition'=>'enabled=1', 'order'=>'sort desc', 'limit'=>15, )); //分配新闻内容到页面 $news = $this->getLastestNews(7); //分配旅游类型 $types = Yii::app()->db->createCommand("select yp_travel.type as id,yp_traveltype.name as name,count(yp_traveltype.name) as total from yp_travel,yp_traveltype where yp_travel.type=yp_traveltype.id and yp_travel.enabled<>0 group by yp_traveltype.name")->queryAll(); //分配旅游 出发地 $departurenum = $this->getTravelMdid();//array() $departurename = $this->getDepartureList();//array() $departures = Yii::app()->db->createCommand("select yp_departure.id as id, yp_departure.name as name,count(yp_travel.from_addr) as total from yp_travel,yp_departure where yp_travel.from_addr=yp_departure.id and yp_travel.enabled<>0 group by yp_travel.from_addr")->queryAll(); //旅游目的地 //$dests = Yii::app()->db->createCommand("select yp_travel.to_addr as name,count(yp_travel.to_addr) as total from yp_travel,yp_destination where yp_travel.to_addr=yp_destination.name group by yp_travel.to_addr")->queryAll(); //隐藏页面内容 $struct = Structure::model()->find(array('select'=>'enabled','condition'=>'id=9')); $this->render('index',array( 'focusmap'=>$focusmap, 'travels'=>$travels, 'news'=>$news, 'hottravels'=>$hottravels, 'types'=>$types, 'teseTuan'=>$teseTuan, 'departures'=>$departures, 'departurenum'=>$departurenum, 'departurename'=>$departurename, 'pages'=>$pages, 'struct'=>$struct, )); }
public static function getXmlDoc($intId) { global $_PATHS; $objStructure = Structure::selectByPk($intId); $strXml = $_PATHS['structures'] . $objStructure->getFileName() . ".xml"; //*** Init DOM object. $objDoc = new DOMDocument("1.0", "UTF-8"); $objDoc->formatOutput = false; $objDoc->preserveWhiteSpace = true; if (is_file($strXml)) { $objDoc->load($strXml); } else { $objDoc->loadXML($strXml); } return $objDoc; }
function get_tree_navigation($data, $id_parent, $startDepth = 0, $maxDepth = -1, $articles = FALSE) { // Pages array $arr = array(); // Return array $select_data = array(); Structure::get_nested_structure($data, $arr, $id_parent, $startDepth, $maxDepth, $articles); return $arr; }
/** * @param mixed $data * @param $failed * @return bool */ public function check($data = null, &$failed = null) { $valid = parent::check($data, $failed) && $this->checkLength($data, $failed); if (!$valid) { Structure::$lastFail = $failed; } return $valid; }
protected function getSubStructureForAttribute( Structure $structure, Attribute $attribute ) { $attributes = $structure->getAttributes(); $result = null; $i = 0; while ( $result == null && $i < count( $attributes ) ) if ( $attribute->id == $attributes[$i]->id ) $result = $attributes[$i]->type; else $i++; return $result; }
/** * Give this any kind of array * to get some kirby style structure * * @param mixed $data * @param mixed $page * @param mixed $key * @return mixed */ function structure($data, $page = null, $key = null) { if (is_null($page)) { $page = page(); } if (is_array($data)) { $result = new Structure(); $result->page = $page; foreach ($data as $key => $value) { $result->append($key, structure($value, $page, $key)); } return $result; } else { if (is_a($data, 'Field')) { return $data; } else { return new Field($page, $key, $data); } } }
<?php $pageID = 'home'; $title = 'Ajax File Upload'; require 'socket.php'; require 'structure.php'; $structure = new Structure(); echo $structure->header($title); ?> <!-- 11/01/2015 --> <form id="form" class="sales-lead" method="POST"> <select id="makes" name="makes"></select> <select id="models" name="models"></select> <select id="engines" name="engines"></select> <br /> <br /> <input name="firstname" id="name" size="30" type="text"><br> Your name:<br> <span class="nameError"> Please enter your name</span></br> <input name="email" id="email" size="30" type="text"><br> Your email:<br> <span class="emailError"> Please enter your E-mail </span></br> <input name="phone" id="phone" size="30" type="text"><br> Your phone:<br> <span class="phoneError"> Please enter your phone</span></br> <input name="zip" id="zip" size="5" type="text"><br> Your Zip Code:<br> <span class="zipCodeError"> Please enter Zip Code</span></br> <span class="zipCodeErrorTow"> Please enter a valid Zip Code</span></br> <span class="zipCodeErrorThree"> Please enter a valid Zip Code</span></br>
/** * Return a tree navigation based on the given helper. * One helper is needed to use this tag. * The default helper is /application/helpers/navigation_helper->get_tree_navigation() * If you wish to change the * * @param FTL_Binding object * * @return string * * @usage <ion:tree_navigation [helper="navigation::your_helper_method"] /> * */ public static function tag_tree_navigation(FTL_Binding $tag) { // Page : Asked one through the page tag $page = $tag->get('page'); // Current page if (is_null($page)) { $page = self::registry('page'); } // If 404 : Put empty vars, so the menu will prints out without errors /* if ( !isset($page['id_page'])) { $page = array( 'id_page' => '', 'id_parent' => '' ); } */ // Menu : Main menu by default $menu_name = $tag->getAttribute('menu', 'main'); $id_menu = 1; foreach (self::registry('menus') as $menu) { if ($menu_name == $menu['name']) { $id_menu = $menu['id_menu']; break; } } // Attribute level, else parent page level + 1 $from_level = $tag->getAttribute('level', 0); // Depth $depth = $tag->getAttribute('depth', -1); // Attribute : active class, first_class, last_class $active_class = $tag->getAttribute('active_class', 'active'); $first_class = $tag->getAttribute('first_class', ''); $last_class = $tag->getAttribute('last_class', ''); // Display hidden navigation elements ? $display_hidden = $tag->getAttribute('display_hidden', FALSE); // Includes articles as menu elements $with_articles = $tag->getAttribute('articles', FALSE); // Attribute : HTML Tree container ID & class attribute $id = $tag->getAttribute('id'); if (strpos($id, 'id') !== FALSE) { $id = str_replace('\'', '"', $id); } $class = $tag->getAttribute('class'); if (strpos($active_class, 'class') !== FALSE) { $active_class = str_replace('\'', '"', $active_class); } // Attribute : Helper to use to print out the tree navigation $helper = $tag->getAttribute('helper', 'navigation'); // Get helper method $helper_function = substr(strrchr($helper, ':'), 1) ? substr(strrchr($helper, ':'), 1) : 'get_tree_navigation'; $helper = strpos($helper, ':') !== FALSE ? substr($helper, 0, strpos($helper, ':')) : $helper; // load the helper self::$ci->load->helper($helper); // Page from locals : By ref because of active_class definition // $pages = $tag->locals->_pages; $pages = self::registry('pages'); /* Get the reference parent page ID * Note : this is depending on the whished level. * If the curent page level > asked level, we need to find recursively the parent page which has the good level. * This is done to avoid tree cut when navigation to a child page * * e.g : * * On the "services" page and each subpage, we want the tree navigation composed by the sub-pages of "services" * We are in the page "offer" * We have to find out that the level 1 parent is "services" * * Page structure Level * * home 0 * |_ about 1 * |_ services 1 <- We want all the nested nav starting at level 1 from this parent page * |_ development 2 * |_ design 2 * |_ offer 3 <- We are here. * |_ portfolio 3 */ $page_level = isset($page['level']) ? $page['level'] : 0; // Asked Level exists $parent_page = array('id_page' => $from_level > 0 ? $page['id_page'] : 0, 'id_parent' => isset($page['id_parent']) ? $page['id_parent'] : 0); if ($from_level !== FALSE) { $parent_page = array('id_page' => $from_level > 0 ? $page['id_page'] : 0, 'id_parent' => isset($page['id_parent']) ? $page['id_parent'] : 0); } else { foreach ($pages as $p) { // Parent page is the id_subnav page if ($p['id_page'] == $page['id_subnav']) { $parent_page = $p; } } } // Find out the wished parent page while ($page_level >= $from_level && $from_level > 0) { $potential_parent_page = array(); foreach ($pages as $p) { if ($p['id_page'] == $parent_page['id_parent']) { $potential_parent_page = $p; break; } } if (!empty($potential_parent_page)) { $parent_page = $potential_parent_page; $page_level = $parent_page['level']; } else { $page_level--; } } // Active pages array. Array of ID $active_pages = Structure::get_active_pages($pages, $page['id_page']); foreach ($pages as $key => $p) { $pages[$key]['active_class'] = in_array($p['id_page'], $active_pages) ? $active_class : ''; } // Filter on 'appears'=>'1' $nav_pages = $pages; if ($display_hidden === FALSE) { $nav_pages = array_values(array_filter($pages, array('TagManager_Page', '_filter_appearing_pages'))); } $final_nav_pages = $nav_pages_list = array(); foreach ($nav_pages as $k => $np) { if ($np['id_menu'] == $id_menu) { $final_nav_pages[] = $np; $nav_pages_list[] = $np['id_page']; } } // Should we include articles ? $articles = FALSE; if ($with_articles == TRUE) { $entity = self::get_entity(); $id_active_article = $entity['type'] == 'article' ? $entity['id_entity'] : NULL; foreach ($final_nav_pages as $key => $p) { // TODO : Change for future "Articles" lib call $tag->set('page', $p); $articles = TagManager_Article::get_articles($tag); // Set active article if (!is_null($id_active_article)) { foreach ($articles as $akey => $a) { if ($a['id_article'] == $id_active_article) { $articles[$akey]['active_class'] = $active_class; $articles[$akey]['is_active'] = TRUE; } } } $final_nav_pages[$key]['articles'] = $articles; } } // Get the tree navigation array $tree = Structure::get_tree_navigation($final_nav_pages, $parent_page['id_page'], $from_level, $depth, $articles); // Return the helper function if (function_exists($helper_function)) { return call_user_func($helper_function, $tree, $id, $class, $first_class, $last_class); } }